@yurikilian/lex4 1.5.4 → 1.5.6
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/components/Lex4Editor.d.ts.map +1 -1
- package/dist/lex4-editor.cjs +37 -30
- package/dist/lex4-editor.cjs.map +1 -1
- package/dist/lex4-editor.js +37 -30
- package/dist/lex4-editor.js.map +1 -1
- package/dist/style.css +5 -0
- package/package.json +1 -1
package/dist/lex4-editor.js
CHANGED
|
@@ -5702,39 +5702,46 @@ const EditorWithHandle = forwardRef(({ captureHistoryShortcutsOnWindow, onSave,
|
|
|
5702
5702
|
const getDocument = useCallback(() => documentRef.current, []);
|
|
5703
5703
|
const getActiveEditor = useCallback(() => activeEditorRef.current, []);
|
|
5704
5704
|
const extensionCtx = useExtensionContext(getDocument, getActiveEditor);
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5705
|
+
const handleRef = useRef({});
|
|
5706
|
+
const extensionMethodKeysRef = useRef([]);
|
|
5707
|
+
const handle = handleRef.current;
|
|
5708
|
+
handle.setHistorySidebarOpen = (open) => {
|
|
5709
|
+
setHistorySidebarOpen(open);
|
|
5710
|
+
};
|
|
5711
|
+
handle.toggleHistorySidebar = () => {
|
|
5712
|
+
setHistorySidebarOpen(!historySidebarOpenRef.current);
|
|
5713
|
+
};
|
|
5714
|
+
handle.insertDocumentContent = (documentToInsert) => {
|
|
5715
|
+
const currentActiveEditor = activeEditorRef.current;
|
|
5716
|
+
if (!currentActiveEditor || activeCaretRegionRef.current !== "body") {
|
|
5717
|
+
return false;
|
|
5718
|
+
}
|
|
5719
|
+
let inserted = false;
|
|
5720
|
+
runHistoryActionRef.current(
|
|
5721
|
+
{
|
|
5722
|
+
label: insertedDocumentContentLabelRef.current,
|
|
5723
|
+
source: "toolbar",
|
|
5724
|
+
region: "document"
|
|
5712
5725
|
},
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
if (!currentActiveEditor || activeCaretRegionRef.current !== "body") {
|
|
5716
|
-
return false;
|
|
5717
|
-
}
|
|
5718
|
-
let inserted = false;
|
|
5719
|
-
runHistoryActionRef.current(
|
|
5720
|
-
{
|
|
5721
|
-
label: insertedDocumentContentLabelRef.current,
|
|
5722
|
-
source: "toolbar",
|
|
5723
|
-
region: "document"
|
|
5724
|
-
},
|
|
5725
|
-
() => {
|
|
5726
|
-
inserted = insertDocumentContent(currentActiveEditor, documentToInsert);
|
|
5727
|
-
}
|
|
5728
|
-
);
|
|
5729
|
-
return inserted;
|
|
5726
|
+
() => {
|
|
5727
|
+
inserted = insertDocumentContent(currentActiveEditor, documentToInsert);
|
|
5730
5728
|
}
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5729
|
+
);
|
|
5730
|
+
return inserted;
|
|
5731
|
+
};
|
|
5732
|
+
for (const key of extensionMethodKeysRef.current) {
|
|
5733
|
+
delete handle[key];
|
|
5734
|
+
}
|
|
5735
|
+
const extensionMethodKeys = [];
|
|
5736
|
+
for (const factory of handleFactories) {
|
|
5737
|
+
const methods = factory(extensionCtx);
|
|
5738
|
+
for (const [key, method] of Object.entries(methods)) {
|
|
5739
|
+
handle[key] = method;
|
|
5740
|
+
extensionMethodKeys.push(key);
|
|
5735
5741
|
}
|
|
5736
|
-
|
|
5737
|
-
|
|
5742
|
+
}
|
|
5743
|
+
extensionMethodKeysRef.current = extensionMethodKeys;
|
|
5744
|
+
useImperativeHandle(ref, () => handle, []);
|
|
5738
5745
|
return /* @__PURE__ */ jsx(
|
|
5739
5746
|
EditorChrome,
|
|
5740
5747
|
{
|