@yurikilian/lex4 1.5.3 → 1.5.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lex4Editor.d.ts","sourceRoot":"","sources":["../../src/components/Lex4Editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0E,MAAM,OAAO,CAAC;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAkB/D,OAAO,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Lex4Editor.d.ts","sourceRoot":"","sources":["../../src/components/Lex4Editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0E,MAAM,OAAO,CAAC;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAkB/D,OAAO,eAAe,CAAC;AA4VvB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,0FA+BrB,CAAC"}
|
package/dist/lex4-editor.cjs
CHANGED
|
@@ -5677,8 +5677,32 @@ const EditorWithHandle = React.forwardRef(({ captureHistoryShortcutsOnWindow, on
|
|
|
5677
5677
|
} = useDocument();
|
|
5678
5678
|
const { handleFactories } = useExtensions();
|
|
5679
5679
|
const t = useTranslations();
|
|
5680
|
-
const
|
|
5681
|
-
const
|
|
5680
|
+
const documentRef = React.useRef(doc);
|
|
5681
|
+
const activeEditorRef = React.useRef(activeEditor);
|
|
5682
|
+
const activeCaretRegionRef = React.useRef(activeCaretPosition == null ? void 0 : activeCaretPosition.region);
|
|
5683
|
+
const historySidebarOpenRef = React.useRef(historySidebarOpen);
|
|
5684
|
+
const runHistoryActionRef = React.useRef(runHistoryAction);
|
|
5685
|
+
const insertedDocumentContentLabelRef = React.useRef(t.history.actions.insertedDocumentContent);
|
|
5686
|
+
React.useEffect(() => {
|
|
5687
|
+
documentRef.current = doc;
|
|
5688
|
+
}, [doc]);
|
|
5689
|
+
React.useEffect(() => {
|
|
5690
|
+
activeEditorRef.current = activeEditor;
|
|
5691
|
+
}, [activeEditor]);
|
|
5692
|
+
React.useEffect(() => {
|
|
5693
|
+
activeCaretRegionRef.current = activeCaretPosition == null ? void 0 : activeCaretPosition.region;
|
|
5694
|
+
}, [activeCaretPosition == null ? void 0 : activeCaretPosition.region]);
|
|
5695
|
+
React.useEffect(() => {
|
|
5696
|
+
historySidebarOpenRef.current = historySidebarOpen;
|
|
5697
|
+
}, [historySidebarOpen]);
|
|
5698
|
+
React.useEffect(() => {
|
|
5699
|
+
runHistoryActionRef.current = runHistoryAction;
|
|
5700
|
+
}, [runHistoryAction]);
|
|
5701
|
+
React.useEffect(() => {
|
|
5702
|
+
insertedDocumentContentLabelRef.current = t.history.actions.insertedDocumentContent;
|
|
5703
|
+
}, [t.history.actions.insertedDocumentContent]);
|
|
5704
|
+
const getDocument = React.useCallback(() => documentRef.current, []);
|
|
5705
|
+
const getActiveEditor = React.useCallback(() => activeEditorRef.current, []);
|
|
5682
5706
|
const extensionCtx = useExtensionContext(getDocument, getActiveEditor);
|
|
5683
5707
|
React.useImperativeHandle(ref, () => {
|
|
5684
5708
|
const handle = {
|
|
@@ -5686,21 +5710,22 @@ const EditorWithHandle = React.forwardRef(({ captureHistoryShortcutsOnWindow, on
|
|
|
5686
5710
|
setHistorySidebarOpen(open);
|
|
5687
5711
|
},
|
|
5688
5712
|
toggleHistorySidebar: () => {
|
|
5689
|
-
setHistorySidebarOpen(!
|
|
5713
|
+
setHistorySidebarOpen(!historySidebarOpenRef.current);
|
|
5690
5714
|
},
|
|
5691
5715
|
insertDocumentContent: (documentToInsert) => {
|
|
5692
|
-
|
|
5716
|
+
const currentActiveEditor = activeEditorRef.current;
|
|
5717
|
+
if (!currentActiveEditor || activeCaretRegionRef.current !== "body") {
|
|
5693
5718
|
return false;
|
|
5694
5719
|
}
|
|
5695
5720
|
let inserted = false;
|
|
5696
|
-
|
|
5721
|
+
runHistoryActionRef.current(
|
|
5697
5722
|
{
|
|
5698
|
-
label:
|
|
5723
|
+
label: insertedDocumentContentLabelRef.current,
|
|
5699
5724
|
source: "toolbar",
|
|
5700
5725
|
region: "document"
|
|
5701
5726
|
},
|
|
5702
5727
|
() => {
|
|
5703
|
-
inserted = insertDocumentContent(
|
|
5728
|
+
inserted = insertDocumentContent(currentActiveEditor, documentToInsert);
|
|
5704
5729
|
}
|
|
5705
5730
|
);
|
|
5706
5731
|
return inserted;
|
|
@@ -5711,16 +5736,7 @@ const EditorWithHandle = React.forwardRef(({ captureHistoryShortcutsOnWindow, on
|
|
|
5711
5736
|
Object.assign(handle, methods);
|
|
5712
5737
|
}
|
|
5713
5738
|
return handle;
|
|
5714
|
-
}, [
|
|
5715
|
-
activeCaretPosition == null ? void 0 : activeCaretPosition.region,
|
|
5716
|
-
activeEditor,
|
|
5717
|
-
extensionCtx,
|
|
5718
|
-
handleFactories,
|
|
5719
|
-
historySidebarOpen,
|
|
5720
|
-
runHistoryAction,
|
|
5721
|
-
setHistorySidebarOpen,
|
|
5722
|
-
t.history.actions.insertedDocumentContent
|
|
5723
|
-
]);
|
|
5739
|
+
}, [extensionCtx, handleFactories, setHistorySidebarOpen]);
|
|
5724
5740
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5725
5741
|
EditorChrome,
|
|
5726
5742
|
{
|