@lingjingai/script-editor 0.1.25 → 0.1.27
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 +13 -4
- package/dist/index.js.map +1 -1
- 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,
|
|
@@ -3103,6 +3109,8 @@ function AssetStateTimeline({
|
|
|
3103
3109
|
};
|
|
3104
3110
|
};
|
|
3105
3111
|
const clearPointerState = (pointerId) => {
|
|
3112
|
+
const nodeCaptureTarget = dragRef.current?.captureTarget;
|
|
3113
|
+
if (nodeCaptureTarget?.hasPointerCapture(pointerId)) nodeCaptureTarget.releasePointerCapture(pointerId);
|
|
3106
3114
|
if (rootRef.current?.hasPointerCapture(pointerId)) rootRef.current.releasePointerCapture(pointerId);
|
|
3107
3115
|
dragRef.current = null;
|
|
3108
3116
|
boxRef.current = null;
|
|
@@ -3120,12 +3128,13 @@ function AssetStateTimeline({
|
|
|
3120
3128
|
setSelectedKeys(keys);
|
|
3121
3129
|
dragRef.current = {
|
|
3122
3130
|
pointerId: e.pointerId,
|
|
3131
|
+
captureTarget: e.currentTarget,
|
|
3123
3132
|
startX: e.clientX,
|
|
3124
3133
|
startY: e.clientY,
|
|
3125
3134
|
keys,
|
|
3126
3135
|
dragging: false
|
|
3127
3136
|
};
|
|
3128
|
-
|
|
3137
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
3129
3138
|
};
|
|
3130
3139
|
const dragLabel = (keys) => {
|
|
3131
3140
|
if (keys.size !== 1) return `${keys.size} \u573A`;
|