@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockTypePicker.d.ts","sourceRoot":"","sources":["../../src/components/BlockTypePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAYpE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAiBnF;AAMD,UAAU,oBAAoB;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"BlockTypePicker.d.ts","sourceRoot":"","sources":["../../src/components/BlockTypePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAYpE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAiBnF;AAMD,UAAU,oBAAoB;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAkG1D,CAAC"}
|
|
@@ -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"}
|
|
@@ -2,9 +2,9 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { ResolvedExtensions, ExtensionContext, Lex4Extension } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Provides resolved extension data to all child components.
|
|
5
|
-
* Extensions are resolved when the
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Extensions are resolved when the extension instances change.
|
|
6
|
+
* This keeps providers and side panels in sync when an extension
|
|
7
|
+
* keeps the same name but receives fresh configuration.
|
|
8
8
|
*/
|
|
9
9
|
export declare const ExtensionProvider: React.FC<{
|
|
10
10
|
extensions?: Lex4Extension[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-context.d.ts","sourceRoot":"","sources":["../../src/extensions/extension-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqD,MAAM,OAAO,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"extension-context.d.ts","sourceRoot":"","sources":["../../src/extensions/extension-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqD,MAAM,OAAO,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA2B7C;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAuBA,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,IAAI,kBAAkB,CAElD;AAMD,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAO1E,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB;UAGvB,CAAC,iBAAiB,MAAM,KAAG,CAAC,GAAG,SAAS;UACxC,CAAC,iBAAiB,MAAM,SAAS,CAAC;EAI3C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,gBAAgB,CAAC,aAAa,CAAC,EAC5C,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,GACnD,gBAAgB,CAWlB"}
|
package/dist/lex4-editor.cjs
CHANGED
|
@@ -1460,33 +1460,33 @@ const createLucideIcon = (iconName, iconNode) => {
|
|
|
1460
1460
|
* This source code is licensed under the ISC license.
|
|
1461
1461
|
* See the LICENSE file in the root directory of this source tree.
|
|
1462
1462
|
*/
|
|
1463
|
-
const __iconNode$
|
|
1463
|
+
const __iconNode$r = [
|
|
1464
1464
|
["path", { d: "m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16", key: "xik6mr" }],
|
|
1465
1465
|
["path", { d: "M15.697 14h5.606", key: "1stdlc" }],
|
|
1466
1466
|
["path", { d: "m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16", key: "d5nyq2" }],
|
|
1467
1467
|
["path", { d: "M3.304 13h6.392", key: "1q3zxz" }]
|
|
1468
1468
|
];
|
|
1469
|
-
const ALargeSmall = createLucideIcon("a-large-small", __iconNode$
|
|
1469
|
+
const ALargeSmall = createLucideIcon("a-large-small", __iconNode$r);
|
|
1470
1470
|
/**
|
|
1471
1471
|
* @license lucide-react v1.8.0 - ISC
|
|
1472
1472
|
*
|
|
1473
1473
|
* This source code is licensed under the ISC license.
|
|
1474
1474
|
* See the LICENSE file in the root directory of this source tree.
|
|
1475
1475
|
*/
|
|
1476
|
-
const __iconNode$
|
|
1476
|
+
const __iconNode$q = [
|
|
1477
1477
|
[
|
|
1478
1478
|
"path",
|
|
1479
1479
|
{ 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" }
|
|
1480
1480
|
]
|
|
1481
1481
|
];
|
|
1482
|
-
const Bold = createLucideIcon("bold", __iconNode$
|
|
1482
|
+
const Bold = createLucideIcon("bold", __iconNode$q);
|
|
1483
1483
|
/**
|
|
1484
1484
|
* @license lucide-react v1.8.0 - ISC
|
|
1485
1485
|
*
|
|
1486
1486
|
* This source code is licensed under the ISC license.
|
|
1487
1487
|
* See the LICENSE file in the root directory of this source tree.
|
|
1488
1488
|
*/
|
|
1489
|
-
const __iconNode$
|
|
1489
|
+
const __iconNode$p = [
|
|
1490
1490
|
[
|
|
1491
1491
|
"path",
|
|
1492
1492
|
{ 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" }
|
|
@@ -1499,7 +1499,15 @@ const __iconNode$o = [
|
|
|
1499
1499
|
}
|
|
1500
1500
|
]
|
|
1501
1501
|
];
|
|
1502
|
-
const Braces = createLucideIcon("braces", __iconNode$
|
|
1502
|
+
const Braces = createLucideIcon("braces", __iconNode$p);
|
|
1503
|
+
/**
|
|
1504
|
+
* @license lucide-react v1.8.0 - ISC
|
|
1505
|
+
*
|
|
1506
|
+
* This source code is licensed under the ISC license.
|
|
1507
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1508
|
+
*/
|
|
1509
|
+
const __iconNode$o = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
|
|
1510
|
+
const Check = createLucideIcon("check", __iconNode$o);
|
|
1503
1511
|
/**
|
|
1504
1512
|
* @license lucide-react v1.8.0 - ISC
|
|
1505
1513
|
*
|
|
@@ -1999,7 +2007,9 @@ const EMPTY_RESOLVED = {
|
|
|
1999
2007
|
handleFactories: []
|
|
2000
2008
|
};
|
|
2001
2009
|
const ExtensionResolvedContext = React.createContext(EMPTY_RESOLVED);
|
|
2002
|
-
function
|
|
2010
|
+
function extensionArraysEqual(a, b) {
|
|
2011
|
+
if (a === b) return true;
|
|
2012
|
+
if (!a || !b) return !a && !b;
|
|
2003
2013
|
if (a.length !== b.length) return false;
|
|
2004
2014
|
for (let i = 0; i < a.length; i++) {
|
|
2005
2015
|
if (a[i] !== b[i]) return false;
|
|
@@ -2007,12 +2017,11 @@ function arraysEqual(a, b) {
|
|
|
2007
2017
|
return true;
|
|
2008
2018
|
}
|
|
2009
2019
|
const ExtensionProvider = ({ extensions, children }) => {
|
|
2010
|
-
const
|
|
2020
|
+
const prevExtensionsRef = React.useRef(void 0);
|
|
2011
2021
|
const resolvedRef = React.useRef(EMPTY_RESOLVED);
|
|
2012
|
-
|
|
2013
|
-
if (!arraysEqual(currentNames, prevNamesRef.current)) {
|
|
2022
|
+
if (!extensionArraysEqual(extensions, prevExtensionsRef.current)) {
|
|
2014
2023
|
resolvedRef.current = extensions && extensions.length > 0 ? resolveExtensions(extensions) : EMPTY_RESOLVED;
|
|
2015
|
-
|
|
2024
|
+
prevExtensionsRef.current = extensions;
|
|
2016
2025
|
}
|
|
2017
2026
|
const resolved = resolvedRef.current;
|
|
2018
2027
|
let wrapped = /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
@@ -2611,7 +2620,8 @@ const BlockTypePicker = ({ value, onChange }) => {
|
|
|
2611
2620
|
children: option.shortLabel
|
|
2612
2621
|
}
|
|
2613
2622
|
),
|
|
2614
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "lex4-block-type-item-label", children: label })
|
|
2623
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "lex4-block-type-item-label", children: label }),
|
|
2624
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "lex4-block-type-item-check", "aria-hidden": "true", children: active ? /* @__PURE__ */ jsxRuntime.jsx(Check, { size: 14 }) : null })
|
|
2615
2625
|
]
|
|
2616
2626
|
},
|
|
2617
2627
|
option.value
|
|
@@ -5667,8 +5677,32 @@ const EditorWithHandle = React.forwardRef(({ captureHistoryShortcutsOnWindow, on
|
|
|
5667
5677
|
} = useDocument();
|
|
5668
5678
|
const { handleFactories } = useExtensions();
|
|
5669
5679
|
const t = useTranslations();
|
|
5670
|
-
const
|
|
5671
|
-
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, []);
|
|
5672
5706
|
const extensionCtx = useExtensionContext(getDocument, getActiveEditor);
|
|
5673
5707
|
React.useImperativeHandle(ref, () => {
|
|
5674
5708
|
const handle = {
|
|
@@ -5676,21 +5710,22 @@ const EditorWithHandle = React.forwardRef(({ captureHistoryShortcutsOnWindow, on
|
|
|
5676
5710
|
setHistorySidebarOpen(open);
|
|
5677
5711
|
},
|
|
5678
5712
|
toggleHistorySidebar: () => {
|
|
5679
|
-
setHistorySidebarOpen(!
|
|
5713
|
+
setHistorySidebarOpen(!historySidebarOpenRef.current);
|
|
5680
5714
|
},
|
|
5681
5715
|
insertDocumentContent: (documentToInsert) => {
|
|
5682
|
-
|
|
5716
|
+
const currentActiveEditor = activeEditorRef.current;
|
|
5717
|
+
if (!currentActiveEditor || activeCaretRegionRef.current !== "body") {
|
|
5683
5718
|
return false;
|
|
5684
5719
|
}
|
|
5685
5720
|
let inserted = false;
|
|
5686
|
-
|
|
5721
|
+
runHistoryActionRef.current(
|
|
5687
5722
|
{
|
|
5688
|
-
label:
|
|
5723
|
+
label: insertedDocumentContentLabelRef.current,
|
|
5689
5724
|
source: "toolbar",
|
|
5690
5725
|
region: "document"
|
|
5691
5726
|
},
|
|
5692
5727
|
() => {
|
|
5693
|
-
inserted = insertDocumentContent(
|
|
5728
|
+
inserted = insertDocumentContent(currentActiveEditor, documentToInsert);
|
|
5694
5729
|
}
|
|
5695
5730
|
);
|
|
5696
5731
|
return inserted;
|
|
@@ -5701,16 +5736,7 @@ const EditorWithHandle = React.forwardRef(({ captureHistoryShortcutsOnWindow, on
|
|
|
5701
5736
|
Object.assign(handle, methods);
|
|
5702
5737
|
}
|
|
5703
5738
|
return handle;
|
|
5704
|
-
}, [
|
|
5705
|
-
activeCaretPosition == null ? void 0 : activeCaretPosition.region,
|
|
5706
|
-
activeEditor,
|
|
5707
|
-
extensionCtx,
|
|
5708
|
-
handleFactories,
|
|
5709
|
-
historySidebarOpen,
|
|
5710
|
-
runHistoryAction,
|
|
5711
|
-
setHistorySidebarOpen,
|
|
5712
|
-
t.history.actions.insertedDocumentContent
|
|
5713
|
-
]);
|
|
5739
|
+
}, [extensionCtx, handleFactories, setHistorySidebarOpen]);
|
|
5714
5740
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5715
5741
|
EditorChrome,
|
|
5716
5742
|
{
|