@yurikilian/lex4 1.5.2 → 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.
- package/dist/components/BlockTypePicker.d.ts.map +1 -1
- package/dist/components/Lex4Editor.d.ts.map +1 -1
- package/dist/extensions/extension-context.d.ts +3 -3
- package/dist/extensions/extension-context.d.ts.map +1 -1
- package/dist/lex4-editor.cjs +55 -29
- package/dist/lex4-editor.cjs.map +1 -1
- package/dist/lex4-editor.js +55 -29
- package/dist/lex4-editor.js.map +1 -1
- package/dist/style.css +43 -3
- package/package.json +1 -1
package/dist/lex4-editor.js
CHANGED
|
@@ -1458,33 +1458,33 @@ const createLucideIcon = (iconName, iconNode) => {
|
|
|
1458
1458
|
* This source code is licensed under the ISC license.
|
|
1459
1459
|
* See the LICENSE file in the root directory of this source tree.
|
|
1460
1460
|
*/
|
|
1461
|
-
const __iconNode$
|
|
1461
|
+
const __iconNode$r = [
|
|
1462
1462
|
["path", { d: "m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16", key: "xik6mr" }],
|
|
1463
1463
|
["path", { d: "M15.697 14h5.606", key: "1stdlc" }],
|
|
1464
1464
|
["path", { d: "m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16", key: "d5nyq2" }],
|
|
1465
1465
|
["path", { d: "M3.304 13h6.392", key: "1q3zxz" }]
|
|
1466
1466
|
];
|
|
1467
|
-
const ALargeSmall = createLucideIcon("a-large-small", __iconNode$
|
|
1467
|
+
const ALargeSmall = createLucideIcon("a-large-small", __iconNode$r);
|
|
1468
1468
|
/**
|
|
1469
1469
|
* @license lucide-react v1.8.0 - ISC
|
|
1470
1470
|
*
|
|
1471
1471
|
* This source code is licensed under the ISC license.
|
|
1472
1472
|
* See the LICENSE file in the root directory of this source tree.
|
|
1473
1473
|
*/
|
|
1474
|
-
const __iconNode$
|
|
1474
|
+
const __iconNode$q = [
|
|
1475
1475
|
[
|
|
1476
1476
|
"path",
|
|
1477
1477
|
{ d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8", key: "mg9rjx" }
|
|
1478
1478
|
]
|
|
1479
1479
|
];
|
|
1480
|
-
const Bold = createLucideIcon("bold", __iconNode$
|
|
1480
|
+
const Bold = createLucideIcon("bold", __iconNode$q);
|
|
1481
1481
|
/**
|
|
1482
1482
|
* @license lucide-react v1.8.0 - ISC
|
|
1483
1483
|
*
|
|
1484
1484
|
* This source code is licensed under the ISC license.
|
|
1485
1485
|
* See the LICENSE file in the root directory of this source tree.
|
|
1486
1486
|
*/
|
|
1487
|
-
const __iconNode$
|
|
1487
|
+
const __iconNode$p = [
|
|
1488
1488
|
[
|
|
1489
1489
|
"path",
|
|
1490
1490
|
{ d: "M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1", key: "ezmyqa" }
|
|
@@ -1497,7 +1497,15 @@ const __iconNode$o = [
|
|
|
1497
1497
|
}
|
|
1498
1498
|
]
|
|
1499
1499
|
];
|
|
1500
|
-
const Braces = createLucideIcon("braces", __iconNode$
|
|
1500
|
+
const Braces = createLucideIcon("braces", __iconNode$p);
|
|
1501
|
+
/**
|
|
1502
|
+
* @license lucide-react v1.8.0 - ISC
|
|
1503
|
+
*
|
|
1504
|
+
* This source code is licensed under the ISC license.
|
|
1505
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1506
|
+
*/
|
|
1507
|
+
const __iconNode$o = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
|
|
1508
|
+
const Check = createLucideIcon("check", __iconNode$o);
|
|
1501
1509
|
/**
|
|
1502
1510
|
* @license lucide-react v1.8.0 - ISC
|
|
1503
1511
|
*
|
|
@@ -1997,7 +2005,9 @@ const EMPTY_RESOLVED = {
|
|
|
1997
2005
|
handleFactories: []
|
|
1998
2006
|
};
|
|
1999
2007
|
const ExtensionResolvedContext = createContext(EMPTY_RESOLVED);
|
|
2000
|
-
function
|
|
2008
|
+
function extensionArraysEqual(a, b) {
|
|
2009
|
+
if (a === b) return true;
|
|
2010
|
+
if (!a || !b) return !a && !b;
|
|
2001
2011
|
if (a.length !== b.length) return false;
|
|
2002
2012
|
for (let i = 0; i < a.length; i++) {
|
|
2003
2013
|
if (a[i] !== b[i]) return false;
|
|
@@ -2005,12 +2015,11 @@ function arraysEqual(a, b) {
|
|
|
2005
2015
|
return true;
|
|
2006
2016
|
}
|
|
2007
2017
|
const ExtensionProvider = ({ extensions, children }) => {
|
|
2008
|
-
const
|
|
2018
|
+
const prevExtensionsRef = useRef(void 0);
|
|
2009
2019
|
const resolvedRef = useRef(EMPTY_RESOLVED);
|
|
2010
|
-
|
|
2011
|
-
if (!arraysEqual(currentNames, prevNamesRef.current)) {
|
|
2020
|
+
if (!extensionArraysEqual(extensions, prevExtensionsRef.current)) {
|
|
2012
2021
|
resolvedRef.current = extensions && extensions.length > 0 ? resolveExtensions(extensions) : EMPTY_RESOLVED;
|
|
2013
|
-
|
|
2022
|
+
prevExtensionsRef.current = extensions;
|
|
2014
2023
|
}
|
|
2015
2024
|
const resolved = resolvedRef.current;
|
|
2016
2025
|
let wrapped = /* @__PURE__ */ jsx(Fragment, { children });
|
|
@@ -2609,7 +2618,8 @@ const BlockTypePicker = ({ value, onChange }) => {
|
|
|
2609
2618
|
children: option.shortLabel
|
|
2610
2619
|
}
|
|
2611
2620
|
),
|
|
2612
|
-
/* @__PURE__ */ jsx("span", { className: "lex4-block-type-item-label", children: label })
|
|
2621
|
+
/* @__PURE__ */ jsx("span", { className: "lex4-block-type-item-label", children: label }),
|
|
2622
|
+
/* @__PURE__ */ jsx("span", { className: "lex4-block-type-item-check", "aria-hidden": "true", children: active ? /* @__PURE__ */ jsx(Check, { size: 14 }) : null })
|
|
2613
2623
|
]
|
|
2614
2624
|
},
|
|
2615
2625
|
option.value
|
|
@@ -5665,8 +5675,32 @@ const EditorWithHandle = forwardRef(({ captureHistoryShortcutsOnWindow, onSave,
|
|
|
5665
5675
|
} = useDocument();
|
|
5666
5676
|
const { handleFactories } = useExtensions();
|
|
5667
5677
|
const t = useTranslations();
|
|
5668
|
-
const
|
|
5669
|
-
const
|
|
5678
|
+
const documentRef = useRef(doc);
|
|
5679
|
+
const activeEditorRef = useRef(activeEditor);
|
|
5680
|
+
const activeCaretRegionRef = useRef(activeCaretPosition == null ? void 0 : activeCaretPosition.region);
|
|
5681
|
+
const historySidebarOpenRef = useRef(historySidebarOpen);
|
|
5682
|
+
const runHistoryActionRef = useRef(runHistoryAction);
|
|
5683
|
+
const insertedDocumentContentLabelRef = useRef(t.history.actions.insertedDocumentContent);
|
|
5684
|
+
useEffect(() => {
|
|
5685
|
+
documentRef.current = doc;
|
|
5686
|
+
}, [doc]);
|
|
5687
|
+
useEffect(() => {
|
|
5688
|
+
activeEditorRef.current = activeEditor;
|
|
5689
|
+
}, [activeEditor]);
|
|
5690
|
+
useEffect(() => {
|
|
5691
|
+
activeCaretRegionRef.current = activeCaretPosition == null ? void 0 : activeCaretPosition.region;
|
|
5692
|
+
}, [activeCaretPosition == null ? void 0 : activeCaretPosition.region]);
|
|
5693
|
+
useEffect(() => {
|
|
5694
|
+
historySidebarOpenRef.current = historySidebarOpen;
|
|
5695
|
+
}, [historySidebarOpen]);
|
|
5696
|
+
useEffect(() => {
|
|
5697
|
+
runHistoryActionRef.current = runHistoryAction;
|
|
5698
|
+
}, [runHistoryAction]);
|
|
5699
|
+
useEffect(() => {
|
|
5700
|
+
insertedDocumentContentLabelRef.current = t.history.actions.insertedDocumentContent;
|
|
5701
|
+
}, [t.history.actions.insertedDocumentContent]);
|
|
5702
|
+
const getDocument = useCallback(() => documentRef.current, []);
|
|
5703
|
+
const getActiveEditor = useCallback(() => activeEditorRef.current, []);
|
|
5670
5704
|
const extensionCtx = useExtensionContext(getDocument, getActiveEditor);
|
|
5671
5705
|
useImperativeHandle(ref, () => {
|
|
5672
5706
|
const handle = {
|
|
@@ -5674,21 +5708,22 @@ const EditorWithHandle = forwardRef(({ captureHistoryShortcutsOnWindow, onSave,
|
|
|
5674
5708
|
setHistorySidebarOpen(open);
|
|
5675
5709
|
},
|
|
5676
5710
|
toggleHistorySidebar: () => {
|
|
5677
|
-
setHistorySidebarOpen(!
|
|
5711
|
+
setHistorySidebarOpen(!historySidebarOpenRef.current);
|
|
5678
5712
|
},
|
|
5679
5713
|
insertDocumentContent: (documentToInsert) => {
|
|
5680
|
-
|
|
5714
|
+
const currentActiveEditor = activeEditorRef.current;
|
|
5715
|
+
if (!currentActiveEditor || activeCaretRegionRef.current !== "body") {
|
|
5681
5716
|
return false;
|
|
5682
5717
|
}
|
|
5683
5718
|
let inserted = false;
|
|
5684
|
-
|
|
5719
|
+
runHistoryActionRef.current(
|
|
5685
5720
|
{
|
|
5686
|
-
label:
|
|
5721
|
+
label: insertedDocumentContentLabelRef.current,
|
|
5687
5722
|
source: "toolbar",
|
|
5688
5723
|
region: "document"
|
|
5689
5724
|
},
|
|
5690
5725
|
() => {
|
|
5691
|
-
inserted = insertDocumentContent(
|
|
5726
|
+
inserted = insertDocumentContent(currentActiveEditor, documentToInsert);
|
|
5692
5727
|
}
|
|
5693
5728
|
);
|
|
5694
5729
|
return inserted;
|
|
@@ -5699,16 +5734,7 @@ const EditorWithHandle = forwardRef(({ captureHistoryShortcutsOnWindow, onSave,
|
|
|
5699
5734
|
Object.assign(handle, methods);
|
|
5700
5735
|
}
|
|
5701
5736
|
return handle;
|
|
5702
|
-
}, [
|
|
5703
|
-
activeCaretPosition == null ? void 0 : activeCaretPosition.region,
|
|
5704
|
-
activeEditor,
|
|
5705
|
-
extensionCtx,
|
|
5706
|
-
handleFactories,
|
|
5707
|
-
historySidebarOpen,
|
|
5708
|
-
runHistoryAction,
|
|
5709
|
-
setHistorySidebarOpen,
|
|
5710
|
-
t.history.actions.insertedDocumentContent
|
|
5711
|
-
]);
|
|
5737
|
+
}, [extensionCtx, handleFactories, setHistorySidebarOpen]);
|
|
5712
5738
|
return /* @__PURE__ */ jsx(
|
|
5713
5739
|
EditorChrome,
|
|
5714
5740
|
{
|