@trafica/editor 1.0.38 → 1.0.39
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 +10 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7849,6 +7849,7 @@ function EditorCore({
|
|
|
7849
7849
|
}) {
|
|
7850
7850
|
const containerRef = react.useRef(null);
|
|
7851
7851
|
const isRenderingRef = react.useRef(false);
|
|
7852
|
+
const skipRestoreSelectionRef = react.useRef(false);
|
|
7852
7853
|
const scrollCaretIntoView = react.useCallback(() => {
|
|
7853
7854
|
var _a, _b;
|
|
7854
7855
|
const sel = window.getSelection();
|
|
@@ -7961,8 +7962,14 @@ function EditorCore({
|
|
|
7961
7962
|
react.useLayoutEffect(() => {
|
|
7962
7963
|
const container = containerRef.current;
|
|
7963
7964
|
if (!container || !state.selection) return;
|
|
7965
|
+
if (skipRestoreSelectionRef.current) {
|
|
7966
|
+
skipRestoreSelectionRef.current = false;
|
|
7967
|
+
return;
|
|
7968
|
+
}
|
|
7969
|
+
isRenderingRef.current = true;
|
|
7964
7970
|
restoreSelection(container, state.selection);
|
|
7965
7971
|
scrollCaretIntoView();
|
|
7972
|
+
isRenderingRef.current = false;
|
|
7966
7973
|
}, [state.selection]);
|
|
7967
7974
|
react.useEffect(() => {
|
|
7968
7975
|
const container = containerRef.current;
|
|
@@ -8027,6 +8034,7 @@ function EditorCore({
|
|
|
8027
8034
|
if (currentSelection && JSON.stringify(currentSelection.anchor) === JSON.stringify(captured.anchor) && JSON.stringify(currentSelection.focus) === JSON.stringify(captured.focus)) {
|
|
8028
8035
|
return;
|
|
8029
8036
|
}
|
|
8037
|
+
skipRestoreSelectionRef.current = true;
|
|
8030
8038
|
const tr = createTransaction();
|
|
8031
8039
|
tr.steps.push(tr_setSelection(captured));
|
|
8032
8040
|
engine.dispatch(tr);
|
|
@@ -8409,10 +8417,9 @@ function EditorCore({
|
|
|
8409
8417
|
if (!container) return;
|
|
8410
8418
|
const selection = captureSelection(container);
|
|
8411
8419
|
if (!selection) return;
|
|
8420
|
+
skipRestoreSelectionRef.current = true;
|
|
8412
8421
|
const tr = createTransaction();
|
|
8413
|
-
tr.steps.push(
|
|
8414
|
-
tr_setSelection(selection)
|
|
8415
|
-
);
|
|
8422
|
+
tr.steps.push(tr_setSelection(selection));
|
|
8416
8423
|
engine.dispatch(tr);
|
|
8417
8424
|
}, [engine]);
|
|
8418
8425
|
const imageResizeRef = react.useRef(null);
|