@lingjingai/script-editor 0.1.24 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +56 -24
- package/dist/index.js.map +1 -1
- package/dist/style.css +15 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -648,6 +648,7 @@ function EditableText({
|
|
|
648
648
|
const [editing, setEditing] = useState(autoEdit);
|
|
649
649
|
const [draft, setDraft] = useState(value);
|
|
650
650
|
const caretRef = useRef(null);
|
|
651
|
+
const entryHeightRef = useRef(null);
|
|
651
652
|
const inputRef = useRef(null);
|
|
652
653
|
const committedRef = useRef(value);
|
|
653
654
|
const editingSignal = useContext(EditingSignalContext);
|
|
@@ -699,7 +700,10 @@ function EditableText({
|
|
|
699
700
|
if (!editing) return;
|
|
700
701
|
const el = inputRef.current;
|
|
701
702
|
if (!el) return;
|
|
702
|
-
if (multiline)
|
|
703
|
+
if (multiline) {
|
|
704
|
+
autoSize(el, entryHeightRef.current);
|
|
705
|
+
entryHeightRef.current = null;
|
|
706
|
+
}
|
|
703
707
|
el.focus();
|
|
704
708
|
const caret = caretRef.current;
|
|
705
709
|
const pos = caret == null ? el.value.length : Math.min(caret, el.value.length);
|
|
@@ -714,6 +718,7 @@ function EditableText({
|
|
|
714
718
|
const sel = window.getSelection();
|
|
715
719
|
if (sel && !sel.isCollapsed) return;
|
|
716
720
|
caretRef.current = caretOffsetFromPoint(e.clientX, e.clientY);
|
|
721
|
+
entryHeightRef.current = multiline ? e.currentTarget.getBoundingClientRect().height : null;
|
|
717
722
|
setDraft(committedRef.current);
|
|
718
723
|
draftRef.current = committedRef.current;
|
|
719
724
|
setEditing(true);
|
|
@@ -781,9 +786,10 @@ function EditableText({
|
|
|
781
786
|
};
|
|
782
787
|
return multiline ? /* @__PURE__ */ jsx("textarea", { ...common, rows: 1 }) : /* @__PURE__ */ jsx("input", { ...common, type: "text" });
|
|
783
788
|
}
|
|
784
|
-
function autoSize(el) {
|
|
789
|
+
function autoSize(el, entryHeight) {
|
|
785
790
|
el.style.height = "auto";
|
|
786
|
-
|
|
791
|
+
const nextHeight = el.scrollHeight;
|
|
792
|
+
el.style.height = entryHeight && Math.abs(nextHeight - entryHeight) <= 1 ? `${entryHeight}px` : `${nextHeight}px`;
|
|
787
793
|
}
|
|
788
794
|
function FormatToggle({
|
|
789
795
|
value,
|
|
@@ -2454,7 +2460,19 @@ function SceneItemRowImpl({
|
|
|
2454
2460
|
if (type === "action" /* Action */) {
|
|
2455
2461
|
body = /* @__PURE__ */ jsxs("p", { className: "lj-se-asian-action", children: [
|
|
2456
2462
|
/* @__PURE__ */ jsx("span", { className: "lj-se-asian-action-mark", children: "\u25B3" }),
|
|
2457
|
-
/* @__PURE__ */ jsx(
|
|
2463
|
+
/* @__PURE__ */ jsx(
|
|
2464
|
+
EditableText,
|
|
2465
|
+
{
|
|
2466
|
+
multiline: true,
|
|
2467
|
+
value: content,
|
|
2468
|
+
disabled,
|
|
2469
|
+
autoEdit,
|
|
2470
|
+
onEditEnd,
|
|
2471
|
+
placeholder: "\u8F93\u5165\u52A8\u4F5C\u2026",
|
|
2472
|
+
className: "lj-se-asian-content",
|
|
2473
|
+
onSave
|
|
2474
|
+
}
|
|
2475
|
+
)
|
|
2458
2476
|
] });
|
|
2459
2477
|
} else if (type === "narration" /* Narration */) {
|
|
2460
2478
|
body = /* @__PURE__ */ jsx("p", { className: "lj-se-asian-narration", children: /* @__PURE__ */ jsx(EditableText, { multiline: true, value: content, disabled, autoEdit, onEditEnd, placeholder: "\u8F93\u5165\u65C1\u767D\u2026", onSave }) });
|
|
@@ -2463,29 +2481,43 @@ function SceneItemRowImpl({
|
|
|
2463
2481
|
const tone = isInner ? "inner" : "dialogue";
|
|
2464
2482
|
const tag = isInner ? emotion ? `OS\xB7${emotion}` : "OS" : emotion;
|
|
2465
2483
|
body = /* @__PURE__ */ jsxs("p", { className: cn("lj-se-asian-cueline", isInner && "is-inner"), children: [
|
|
2466
|
-
|
|
2467
|
-
|
|
2484
|
+
/* @__PURE__ */ jsxs("span", { className: "lj-se-asian-cue-prefix", children: [
|
|
2485
|
+
multiSpeaker ? /* @__PURE__ */ jsx("strong", { className: "lj-se-asian-speaker", style: resolvedActor ? { color: getActorCueVar(resolvedActorId, tone) } : void 0, children: /* @__PURE__ */ jsx(HighlightedText, { text: getDialogueSpeakerLabel(item, actorMap, speakerMap) }) }) : /* @__PURE__ */ jsx(
|
|
2486
|
+
SelectField,
|
|
2487
|
+
{
|
|
2488
|
+
value: resolvedActorId,
|
|
2489
|
+
options: actorOptions,
|
|
2490
|
+
disabled,
|
|
2491
|
+
placeholder: "\u672A\u77E5\u89D2\u8272",
|
|
2492
|
+
className: cn("lj-se-asian-speaker lj-se-asian-speaker--select", resolvedActorId && !resolvedActor && "is-orphan"),
|
|
2493
|
+
style: resolvedActor ? { color: getActorCueVar(resolvedActorId, tone) } : void 0,
|
|
2494
|
+
onChange: onSaveActor
|
|
2495
|
+
}
|
|
2496
|
+
),
|
|
2497
|
+
!multiSpeaker ? /* @__PURE__ */ jsxs("span", { className: "lj-se-asian-tag", children: [
|
|
2498
|
+
"\uFF08",
|
|
2499
|
+
/* @__PURE__ */ jsx(EditableText, { value: item.emotion ?? "", disabled, placeholder: isInner ? "OS" : "\u60C5\u7EEA", onSave: onSaveEmotion }),
|
|
2500
|
+
"\uFF09"
|
|
2501
|
+
] }) : tag ? /* @__PURE__ */ jsxs("span", { className: "lj-se-asian-tag", children: [
|
|
2502
|
+
"\uFF08",
|
|
2503
|
+
tag,
|
|
2504
|
+
"\uFF09"
|
|
2505
|
+
] }) : null,
|
|
2506
|
+
/* @__PURE__ */ jsx("span", { className: "lj-se-asian-colon", children: "\uFF1A" })
|
|
2507
|
+
] }),
|
|
2508
|
+
/* @__PURE__ */ jsx(
|
|
2509
|
+
EditableText,
|
|
2468
2510
|
{
|
|
2469
|
-
|
|
2470
|
-
|
|
2511
|
+
multiline: true,
|
|
2512
|
+
value: content,
|
|
2471
2513
|
disabled,
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2514
|
+
autoEdit,
|
|
2515
|
+
onEditEnd,
|
|
2516
|
+
placeholder: "\u8F93\u5165\u5BF9\u767D\u2026",
|
|
2517
|
+
className: "lj-se-asian-content",
|
|
2518
|
+
onSave
|
|
2476
2519
|
}
|
|
2477
|
-
)
|
|
2478
|
-
!multiSpeaker ? /* @__PURE__ */ jsxs("span", { className: "lj-se-asian-tag", children: [
|
|
2479
|
-
"\uFF08",
|
|
2480
|
-
/* @__PURE__ */ jsx(EditableText, { value: item.emotion ?? "", disabled, placeholder: isInner ? "OS" : "\u60C5\u7EEA", onSave: onSaveEmotion }),
|
|
2481
|
-
"\uFF09"
|
|
2482
|
-
] }) : tag ? /* @__PURE__ */ jsxs("span", { className: "lj-se-asian-tag", children: [
|
|
2483
|
-
"\uFF08",
|
|
2484
|
-
tag,
|
|
2485
|
-
"\uFF09"
|
|
2486
|
-
] }) : null,
|
|
2487
|
-
/* @__PURE__ */ jsx("span", { className: "lj-se-asian-colon", children: "\uFF1A" }),
|
|
2488
|
-
/* @__PURE__ */ jsx(EditableText, { multiline: true, value: content, disabled, autoEdit, onEditEnd, placeholder: "\u8F93\u5165\u5BF9\u767D\u2026", onSave })
|
|
2520
|
+
)
|
|
2489
2521
|
] });
|
|
2490
2522
|
}
|
|
2491
2523
|
return /* @__PURE__ */ jsxs("div", { className: "lj-se-row lj-se-row--asian group", children: [
|