Enforce avatar character limits when editing from Dialogue Review
@@ -6,7 +6,9 @@ import trimlines, { textNumLines } from "../../lib/helpers/trimlines";
import l10n from "../../lib/helpers/l10n";
import { SceneShape, ActorShape, EventShape } from "../../reducers/stateShape";
-const DialogueReviewLine = ({ dialogueLine, onChange, ...props }) => (
+const DialogueReviewLine = ({ dialogueLine, onChange, ...props }) => {
+ const maxPerLine = dialogueLine.line.args.avatarId ? 16 : 18;
+ return (
<div>
{Array.isArray(dialogueLine.line.args.text) ? (
dialogueLine.line.args.text.map((text, textIndex) => (
@@ -17,7 +19,7 @@ const DialogueReviewLine = ({ dialogueLine, onChange, ...props }) => (
.split("\n")
.map(
(line, index, lines) =>
- `${line.length}/${index === 2 ? 16 : 18}`
+ `${line.length}/${index === 2 ? 16 : maxPerLine}`
)
.join(", ")}
</p>
@@ -32,7 +34,7 @@ const DialogueReviewLine = ({ dialogueLine, onChange, ...props }) => (
onChange(
dialogueLine.line.args.text.map((value, valueIndex) => {
if (valueIndex === textIndex) {
- return trimlines(e.currentTarget.value);
+ return trimlines(e.currentTarget.value, maxPerLine);
}
return value;
})
@@ -48,7 +50,8 @@ const DialogueReviewLine = ({ dialogueLine, onChange, ...props }) => (
{(dialogueLine.line.args.text || "")
.split("\n")
.map(
- (line, index, lines) => `${line.length}/${index === 2 ? 16 : 18}`
+ (line, index, lines) =>
+ `${line.length}/${index === 2 ? 16 : maxPerLine}`
)
.join(", ")}
</p>
@@ -60,13 +63,14 @@ const DialogueReviewLine = ({ dialogueLine, onChange, ...props }) => (
value={dialogueLine.line.args.text}
placeholder={l10n("FIELD_TEXT_PLACEHOLDER")}
onChange={e => {
- onChange(trimlines(e.currentTarget.value));
+ onChange(trimlines(e.currentTarget.value, maxPerLine));
}}
/>
</div>
)}
</div>
);
+};
DialogueReviewLine.propTypes = {
dialogueLine: PropTypes.shape({
