All files / src/components/script DialogueReviewLine.tsx

0% Statements 0/15
0% Branches 0/25
0% Functions 0/7
0% Lines 0/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84                                                                                                                                                                       
import React from "react";
import { textNumLines } from "shared/lib/helpers/trimlines";
import l10n from "shared/lib/lang/l10n";
import { ScriptEventNormalized } from "shared/lib/entities/entitiesTypes";
import { Textarea } from "ui/form/Textarea";
 
export interface DialogueLine {
  line: ScriptEventNormalized;
  sceneName: string;
  entityName: string;
  overrideActorId?: string;
  overrideTriggerId?: string;
}
 
interface DialogueReviewLineProps {
  dialogueLine: DialogueLine;
  onChange: (value: string | string[]) => void;
}
 
const DialogueReviewLine = ({
  dialogueLine,
  onChange,
}: DialogueReviewLineProps) => {
  return (
    <div>
      {dialogueLine.line.args && Array.isArray(dialogueLine.line.args.text) ? (
        dialogueLine.line.args.text.map((text, textIndex) => (
          <div key={textIndex}>
            <p style={{ color: "#999" }}>
              {dialogueLine.entityName} — {dialogueLine.sceneName} [
              {String(text || "")
                .split("\n")
                .map((line, _index, _lines) => `${line.length}`)
                .join(", ")}
              ]
            </p>
            <Textarea
              displaySize="large"
              rows={textNumLines(text)}
              value={text}
              placeholder={l10n("FIELD_TEXT_PLACEHOLDER")}
              onChange={(e) => {
                onChange(
                  dialogueLine.line.args &&
                    Array.isArray(dialogueLine.line.args.text)
                    ? dialogueLine.line.args.text.map((value, valueIndex) => {
                        Iif (valueIndex === textIndex) {
                          return e.currentTarget.value;
                        }
                        return value;
                      })
                    : ""
                );
              }}
            />
          </div>
        ))
      ) : (
        <div>
          <p style={{ color: "#999" }}>
            {dialogueLine.entityName} — {dialogueLine.sceneName} [
            {String(dialogueLine.line.args?.text || "")
              .split("\n")
              .map((line, _index, _lines) => `${line.length}`)
              .join(", ")}
            ]
          </p>
          <Textarea
            displaySize="large"
            rows={textNumLines(String(dialogueLine.line.args?.text))}
            value={String(dialogueLine.line.args?.text)}
            placeholder={l10n("FIELD_TEXT_PLACEHOLDER")}
            onChange={(e) => {
              onChange(e.currentTarget.value);
            }}
          />
        </div>
      )}
    </div>
  );
};
 
export default DialogueReviewLine;