@tarviks/lexical-rich-editor 1.3.2 → 1.3.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/index.css +2 -3
- package/dist/index.css.map +1 -1
- package/dist/index.js +292 -304
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -154
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var utils = require('@lexical/utils');
|
|
4
|
-
var
|
|
4
|
+
var React9 = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
7
7
|
var useLexicalEditable = require('@lexical/react/useLexicalEditable');
|
|
@@ -49,7 +49,7 @@ function _interopNamespace(e) {
|
|
|
49
49
|
return Object.freeze(n);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
var
|
|
52
|
+
var React9__namespace = /*#__PURE__*/_interopNamespace(React9);
|
|
53
53
|
|
|
54
54
|
var __defProp = Object.defineProperty;
|
|
55
55
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -83,12 +83,12 @@ var init_ImageResizer = __esm({
|
|
|
83
83
|
setShowCaption,
|
|
84
84
|
captionsEnabled
|
|
85
85
|
}) => {
|
|
86
|
-
const controlWrapperRef =
|
|
87
|
-
const userSelect =
|
|
86
|
+
const controlWrapperRef = React9.useRef(null);
|
|
87
|
+
const userSelect = React9.useRef({
|
|
88
88
|
priority: "",
|
|
89
89
|
value: "default"
|
|
90
90
|
});
|
|
91
|
-
const positioningRef =
|
|
91
|
+
const positioningRef = React9.useRef({
|
|
92
92
|
currentHeight: 0,
|
|
93
93
|
currentWidth: 0,
|
|
94
94
|
direction: 0,
|
|
@@ -419,15 +419,15 @@ var init_ImageComponent = __esm({
|
|
|
419
419
|
};
|
|
420
420
|
ImageComponent = ({ src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled }) => {
|
|
421
421
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
422
|
-
const [selection, setSelection] =
|
|
423
|
-
const [isLoadError, setIsLoadError] =
|
|
424
|
-
const [isResizing, setIsResizing] =
|
|
422
|
+
const [selection, setSelection] = React9.useState(null);
|
|
423
|
+
const [isLoadError, setIsLoadError] = React9.useState(false);
|
|
424
|
+
const [isResizing, setIsResizing] = React9.useState(false);
|
|
425
425
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
426
|
-
const activeEditorRef =
|
|
427
|
-
const buttonRef =
|
|
428
|
-
const imageRef =
|
|
426
|
+
const activeEditorRef = React9.useRef(null);
|
|
427
|
+
const buttonRef = React9.useRef(null);
|
|
428
|
+
const imageRef = React9.useRef(null);
|
|
429
429
|
const isEditable = useLexicalEditable.useLexicalEditable();
|
|
430
|
-
const $onDelete =
|
|
430
|
+
const $onDelete = React9.useCallback(
|
|
431
431
|
(payload) => {
|
|
432
432
|
const deleteSelection = lexical.$getSelection();
|
|
433
433
|
if (isSelected && lexical.$isNodeSelection(deleteSelection)) {
|
|
@@ -443,7 +443,7 @@ var init_ImageComponent = __esm({
|
|
|
443
443
|
},
|
|
444
444
|
[isSelected]
|
|
445
445
|
);
|
|
446
|
-
const $onEnter =
|
|
446
|
+
const $onEnter = React9.useCallback(
|
|
447
447
|
(event) => {
|
|
448
448
|
const latestSelection = lexical.$getSelection();
|
|
449
449
|
const buttonElem = buttonRef.current;
|
|
@@ -463,7 +463,7 @@ var init_ImageComponent = __esm({
|
|
|
463
463
|
},
|
|
464
464
|
[caption, isSelected, showCaption]
|
|
465
465
|
);
|
|
466
|
-
const $onEscape =
|
|
466
|
+
const $onEscape = React9.useCallback(
|
|
467
467
|
(event) => {
|
|
468
468
|
if (activeEditorRef.current === caption || buttonRef.current === event.target) {
|
|
469
469
|
lexical.$setSelection(null);
|
|
@@ -480,7 +480,7 @@ var init_ImageComponent = __esm({
|
|
|
480
480
|
},
|
|
481
481
|
[caption, editor, setSelected]
|
|
482
482
|
);
|
|
483
|
-
const onClick =
|
|
483
|
+
const onClick = React9.useCallback(
|
|
484
484
|
(payload) => {
|
|
485
485
|
const event = payload;
|
|
486
486
|
if (isResizing) {
|
|
@@ -499,7 +499,7 @@ var init_ImageComponent = __esm({
|
|
|
499
499
|
},
|
|
500
500
|
[isResizing, isSelected, setSelected, clearSelection]
|
|
501
501
|
);
|
|
502
|
-
const onRightClick =
|
|
502
|
+
const onRightClick = React9.useCallback(
|
|
503
503
|
(event) => {
|
|
504
504
|
editor.getEditorState().read(() => {
|
|
505
505
|
const latestSelection = lexical.$getSelection();
|
|
@@ -514,7 +514,7 @@ var init_ImageComponent = __esm({
|
|
|
514
514
|
},
|
|
515
515
|
[editor]
|
|
516
516
|
);
|
|
517
|
-
|
|
517
|
+
React9.useEffect(() => {
|
|
518
518
|
const rootElement = editor.getRootElement();
|
|
519
519
|
const unregister = utils.mergeRegister(
|
|
520
520
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -602,7 +602,7 @@ var init_ImageComponent = __esm({
|
|
|
602
602
|
};
|
|
603
603
|
const draggable = !isResizing;
|
|
604
604
|
const isFocused = (isSelected || isResizing) && isEditable;
|
|
605
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
605
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React9.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
606
606
|
"div",
|
|
607
607
|
{
|
|
608
608
|
draggable,
|
|
@@ -663,7 +663,7 @@ function parseDimFromStyleOrAttr(img3) {
|
|
|
663
663
|
var ImageComponent2, isGoogleDocCheckboxImg, $convertImageElement, ImageNode, $createImageNode, $isImageNode;
|
|
664
664
|
var init_ImageNode = __esm({
|
|
665
665
|
"src/Nodes/ImageNode.tsx"() {
|
|
666
|
-
ImageComponent2 =
|
|
666
|
+
ImageComponent2 = React9__namespace.lazy(() => Promise.resolve().then(() => (init_ImageComponent(), ImageComponent_exports)));
|
|
667
667
|
isGoogleDocCheckboxImg = (img3) => {
|
|
668
668
|
return img3.parentElement != null && img3.parentElement.tagName === "LI" && img3.previousSibling === null && img3.getAttribute("aria-roledescription") === "checkbox";
|
|
669
669
|
};
|
|
@@ -908,14 +908,14 @@ var init_InlineImageComponent = __esm({
|
|
|
908
908
|
};
|
|
909
909
|
InlineImageComponent = ({ src, altText, nodeKey, width, height, showCaption, caption, position }) => {
|
|
910
910
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
911
|
-
const [isResizing, setIsResizing] =
|
|
912
|
-
const [selection, setSelection] =
|
|
913
|
-
const activeEditorRef =
|
|
914
|
-
const imageRef =
|
|
915
|
-
const buttonRef =
|
|
911
|
+
const [isResizing, setIsResizing] = React9.useState(false);
|
|
912
|
+
const [selection, setSelection] = React9.useState(null);
|
|
913
|
+
const activeEditorRef = React9.useRef(null);
|
|
914
|
+
const imageRef = React9.useRef(null);
|
|
915
|
+
const buttonRef = React9.useRef(null);
|
|
916
916
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
917
917
|
const isEditable = useLexicalEditable.useLexicalEditable();
|
|
918
|
-
const $onDelete =
|
|
918
|
+
const $onDelete = React9.useCallback(
|
|
919
919
|
(payload) => {
|
|
920
920
|
const deleteSelection = lexical.$getSelection();
|
|
921
921
|
if (isSelected && lexical.$isNodeSelection(deleteSelection)) {
|
|
@@ -933,7 +933,7 @@ var init_InlineImageComponent = __esm({
|
|
|
933
933
|
},
|
|
934
934
|
[isSelected]
|
|
935
935
|
);
|
|
936
|
-
const $onEnter =
|
|
936
|
+
const $onEnter = React9.useCallback(
|
|
937
937
|
(event) => {
|
|
938
938
|
const latestSelection = lexical.$getSelection();
|
|
939
939
|
const buttonElem = buttonRef.current;
|
|
@@ -953,7 +953,7 @@ var init_InlineImageComponent = __esm({
|
|
|
953
953
|
},
|
|
954
954
|
[caption, isSelected, showCaption]
|
|
955
955
|
);
|
|
956
|
-
const $onEscape =
|
|
956
|
+
const $onEscape = React9.useCallback(
|
|
957
957
|
(event) => {
|
|
958
958
|
if (activeEditorRef.current === caption || buttonRef.current === event.target) {
|
|
959
959
|
lexical.$setSelection(null);
|
|
@@ -970,7 +970,7 @@ var init_InlineImageComponent = __esm({
|
|
|
970
970
|
},
|
|
971
971
|
[caption, editor, setSelected]
|
|
972
972
|
);
|
|
973
|
-
const onClick =
|
|
973
|
+
const onClick = React9.useCallback(
|
|
974
974
|
(payload) => {
|
|
975
975
|
const event = payload;
|
|
976
976
|
if (isResizing) {
|
|
@@ -989,7 +989,7 @@ var init_InlineImageComponent = __esm({
|
|
|
989
989
|
},
|
|
990
990
|
[isResizing, isSelected, setSelected, clearSelection]
|
|
991
991
|
);
|
|
992
|
-
|
|
992
|
+
React9.useEffect(() => {
|
|
993
993
|
let isMounted = true;
|
|
994
994
|
const unregister = utils.mergeRegister(
|
|
995
995
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -1047,7 +1047,7 @@ var init_InlineImageComponent = __esm({
|
|
|
1047
1047
|
};
|
|
1048
1048
|
const draggable = !isResizing;
|
|
1049
1049
|
const isFocused = (isSelected || isResizing) && isEditable;
|
|
1050
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1050
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React9.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { draggable, style: { position: "relative", display: "inline-block" }, children: [
|
|
1051
1051
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1052
1052
|
LazyImage2,
|
|
1053
1053
|
{
|
|
@@ -1082,7 +1082,7 @@ var init_InlineImageComponent = __esm({
|
|
|
1082
1082
|
var InlineImageComponent2, $convertInlineImageElement, InlineImageNode, $createInlineImageNode, $isInlineImageNode;
|
|
1083
1083
|
var init_InlineImageNode = __esm({
|
|
1084
1084
|
"src/Nodes/InlineImageNode.tsx"() {
|
|
1085
|
-
InlineImageComponent2 =
|
|
1085
|
+
InlineImageComponent2 = React9__namespace.lazy(() => Promise.resolve().then(() => (init_InlineImageComponent(), InlineImageComponent_exports)));
|
|
1086
1086
|
$convertInlineImageElement = (domNode) => {
|
|
1087
1087
|
if (lexical.isHTMLElement(domNode) && domNode.nodeName === "IMG") {
|
|
1088
1088
|
const { alt: altText, src, width, height } = domNode;
|
|
@@ -1537,7 +1537,7 @@ init_InlineImageNode();
|
|
|
1537
1537
|
var PageBreakComponent = ({ nodeKey }) => {
|
|
1538
1538
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
1539
1539
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
1540
|
-
const $onDelete =
|
|
1540
|
+
const $onDelete = React9.useCallback(
|
|
1541
1541
|
(event) => {
|
|
1542
1542
|
event.preventDefault();
|
|
1543
1543
|
const deleteSelection = lexical.$getSelection();
|
|
@@ -1552,7 +1552,7 @@ var PageBreakComponent = ({ nodeKey }) => {
|
|
|
1552
1552
|
},
|
|
1553
1553
|
[isSelected]
|
|
1554
1554
|
);
|
|
1555
|
-
|
|
1555
|
+
React9.useEffect(() => {
|
|
1556
1556
|
return utils.mergeRegister(
|
|
1557
1557
|
editor.registerCommand(
|
|
1558
1558
|
lexical.CLICK_COMMAND,
|
|
@@ -1581,7 +1581,7 @@ var PageBreakComponent = ({ nodeKey }) => {
|
|
|
1581
1581
|
)
|
|
1582
1582
|
);
|
|
1583
1583
|
}, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
|
|
1584
|
-
|
|
1584
|
+
React9.useEffect(() => {
|
|
1585
1585
|
const pbElem = editor.getElementByKey(nodeKey);
|
|
1586
1586
|
if (pbElem !== null) {
|
|
1587
1587
|
pbElem.className = isSelected ? "selected" : "";
|
|
@@ -1723,7 +1723,7 @@ function VideoResizer({
|
|
|
1723
1723
|
onResizeStart,
|
|
1724
1724
|
onResizeEnd
|
|
1725
1725
|
}) {
|
|
1726
|
-
const resizeState =
|
|
1726
|
+
const resizeState = React9__namespace.useRef(null);
|
|
1727
1727
|
const startResize = (e, dir) => {
|
|
1728
1728
|
e.preventDefault();
|
|
1729
1729
|
e.stopPropagation();
|
|
@@ -1850,15 +1850,15 @@ function YouTubeComponent({
|
|
|
1850
1850
|
height,
|
|
1851
1851
|
editor
|
|
1852
1852
|
}) {
|
|
1853
|
-
const wrapperRef =
|
|
1854
|
-
const containerRef =
|
|
1855
|
-
const iframeRef =
|
|
1856
|
-
const isResizingRef =
|
|
1853
|
+
const wrapperRef = React9__namespace.useRef(null);
|
|
1854
|
+
const containerRef = React9__namespace.useRef(null);
|
|
1855
|
+
const iframeRef = React9__namespace.useRef(null);
|
|
1856
|
+
const isResizingRef = React9__namespace.useRef(false);
|
|
1857
1857
|
const [isNodeSelected, setNodeSelected, clearNodeSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
1858
|
-
const [isHovered, setIsHovered] =
|
|
1859
|
-
const [isResizing, setIsResizing] =
|
|
1860
|
-
const [isPlaying, setIsPlaying] =
|
|
1861
|
-
|
|
1858
|
+
const [isHovered, setIsHovered] = React9__namespace.useState(false);
|
|
1859
|
+
const [isResizing, setIsResizing] = React9__namespace.useState(false);
|
|
1860
|
+
const [isPlaying, setIsPlaying] = React9__namespace.useState(false);
|
|
1861
|
+
React9__namespace.useEffect(() => {
|
|
1862
1862
|
return utils.mergeRegister(
|
|
1863
1863
|
editor.registerCommand(
|
|
1864
1864
|
lexical.FORMAT_ELEMENT_COMMAND,
|
|
@@ -2247,13 +2247,13 @@ function AutocompletePlugin({
|
|
|
2247
2247
|
prefixWindow = 300
|
|
2248
2248
|
}) {
|
|
2249
2249
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
2250
|
-
const ghostKeyRef =
|
|
2251
|
-
const idleTimerRef =
|
|
2252
|
-
const inflightRef =
|
|
2253
|
-
const reqCounterRef =
|
|
2254
|
-
const lastTriggerRef =
|
|
2255
|
-
const lastShownCtxRef =
|
|
2256
|
-
const clearGhost =
|
|
2250
|
+
const ghostKeyRef = React9__namespace.useRef(null);
|
|
2251
|
+
const idleTimerRef = React9__namespace.useRef(null);
|
|
2252
|
+
const inflightRef = React9__namespace.useRef(null);
|
|
2253
|
+
const reqCounterRef = React9__namespace.useRef(0);
|
|
2254
|
+
const lastTriggerRef = React9__namespace.useRef("");
|
|
2255
|
+
const lastShownCtxRef = React9__namespace.useRef("");
|
|
2256
|
+
const clearGhost = React9__namespace.useCallback(() => {
|
|
2257
2257
|
editor.update(
|
|
2258
2258
|
() => {
|
|
2259
2259
|
const key = ghostKeyRef.current;
|
|
@@ -2265,7 +2265,7 @@ function AutocompletePlugin({
|
|
|
2265
2265
|
{ tag: "autocomplete-ghost" }
|
|
2266
2266
|
);
|
|
2267
2267
|
}, [editor]);
|
|
2268
|
-
const upsertGhost =
|
|
2268
|
+
const upsertGhost = React9__namespace.useCallback(
|
|
2269
2269
|
(text, insertAtCharOffset) => {
|
|
2270
2270
|
editor.update(
|
|
2271
2271
|
() => {
|
|
@@ -2329,12 +2329,12 @@ function AutocompletePlugin({
|
|
|
2329
2329
|
},
|
|
2330
2330
|
[editor]
|
|
2331
2331
|
);
|
|
2332
|
-
const cancelInflight =
|
|
2332
|
+
const cancelInflight = React9__namespace.useCallback(() => {
|
|
2333
2333
|
if (!inflightRef.current) return;
|
|
2334
2334
|
inflightRef.current.dismiss();
|
|
2335
2335
|
inflightRef.current = null;
|
|
2336
2336
|
}, []);
|
|
2337
|
-
const resetIdleTimer =
|
|
2337
|
+
const resetIdleTimer = React9__namespace.useCallback(
|
|
2338
2338
|
(callback) => {
|
|
2339
2339
|
if (idleTimerRef.current) {
|
|
2340
2340
|
clearTimeout(idleTimerRef.current);
|
|
@@ -2349,7 +2349,7 @@ function AutocompletePlugin({
|
|
|
2349
2349
|
},
|
|
2350
2350
|
[idleMs, cancelInflight, clearGhost]
|
|
2351
2351
|
);
|
|
2352
|
-
const fireQuery =
|
|
2352
|
+
const fireQuery = React9__namespace.useCallback(() => {
|
|
2353
2353
|
if (!useQuery || isReadOnly) return;
|
|
2354
2354
|
let context = "";
|
|
2355
2355
|
let prefix = "";
|
|
@@ -2421,7 +2421,7 @@ function AutocompletePlugin({
|
|
|
2421
2421
|
upsertGhost,
|
|
2422
2422
|
onSuggestionShown
|
|
2423
2423
|
]);
|
|
2424
|
-
|
|
2424
|
+
React9__namespace.useEffect(() => {
|
|
2425
2425
|
if (!useQuery || isReadOnly) return;
|
|
2426
2426
|
return editor.registerUpdateListener(({ tags }) => {
|
|
2427
2427
|
if (tags.has("history-merge") || tags.has("collaboration")) return;
|
|
@@ -2430,7 +2430,7 @@ function AutocompletePlugin({
|
|
|
2430
2430
|
resetIdleTimer(fireQuery);
|
|
2431
2431
|
});
|
|
2432
2432
|
}, [editor, useQuery, isReadOnly, resetIdleTimer, fireQuery]);
|
|
2433
|
-
|
|
2433
|
+
React9__namespace.useEffect(() => {
|
|
2434
2434
|
if (!useQuery || isReadOnly) return;
|
|
2435
2435
|
return editor.registerCommand(
|
|
2436
2436
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
@@ -2454,7 +2454,7 @@ function AutocompletePlugin({
|
|
|
2454
2454
|
lexical.COMMAND_PRIORITY_LOW
|
|
2455
2455
|
);
|
|
2456
2456
|
}, [editor, useQuery, isReadOnly, resetIdleTimer, fireQuery]);
|
|
2457
|
-
|
|
2457
|
+
React9__namespace.useEffect(() => {
|
|
2458
2458
|
return editor.registerCommand(
|
|
2459
2459
|
lexical.KEY_DOWN_COMMAND,
|
|
2460
2460
|
(e) => {
|
|
@@ -2495,7 +2495,7 @@ function AutocompletePlugin({
|
|
|
2495
2495
|
lexical.COMMAND_PRIORITY_HIGH
|
|
2496
2496
|
);
|
|
2497
2497
|
}, [editor, clearGhost, onSuggestionAccept, prefixWindow]);
|
|
2498
|
-
|
|
2498
|
+
React9__namespace.useEffect(() => {
|
|
2499
2499
|
return () => {
|
|
2500
2500
|
cancelInflight();
|
|
2501
2501
|
if (idleTimerRef.current) clearTimeout(idleTimerRef.current);
|
|
@@ -2503,18 +2503,14 @@ function AutocompletePlugin({
|
|
|
2503
2503
|
}, [cancelInflight]);
|
|
2504
2504
|
return null;
|
|
2505
2505
|
}
|
|
2506
|
-
function clamp2(n, min, max) {
|
|
2507
|
-
return Math.max(min, Math.min(max, n));
|
|
2508
|
-
}
|
|
2509
2506
|
function useFloatingPortalContainer(editor) {
|
|
2510
|
-
const [container, setContainer] =
|
|
2511
|
-
|
|
2507
|
+
const [container, setContainer] = React9.useState(null);
|
|
2508
|
+
React9.useEffect(() => {
|
|
2512
2509
|
const root = editor.getRootElement();
|
|
2513
2510
|
if (!root) return;
|
|
2514
|
-
const panelOrLayer = root.closest(".ms-Panel-main") || root.closest(".ms-Panel") || root.closest(".ms-Layer") || document.body;
|
|
2515
2511
|
const host = document.createElement("div");
|
|
2516
2512
|
host.className = "lexical-floating-ui-host";
|
|
2517
|
-
|
|
2513
|
+
document.body.appendChild(host);
|
|
2518
2514
|
setContainer(host);
|
|
2519
2515
|
return () => {
|
|
2520
2516
|
host.remove();
|
|
@@ -2523,6 +2519,22 @@ function useFloatingPortalContainer(editor) {
|
|
|
2523
2519
|
}, [editor]);
|
|
2524
2520
|
return container;
|
|
2525
2521
|
}
|
|
2522
|
+
function getFixedPositionOrigin(fromElement) {
|
|
2523
|
+
let node = fromElement.parentElement;
|
|
2524
|
+
while (node && node !== document.body && node !== document.documentElement) {
|
|
2525
|
+
const style = getComputedStyle(node);
|
|
2526
|
+
const createsContainingBlock = style.transform && style.transform !== "none" || style.perspective && style.perspective !== "none" || style.filter && style.filter !== "none" || style.backdropFilter && style.backdropFilter !== "none" || style.willChange && /transform|perspective|filter/.test(style.willChange) || style.contain && /paint|layout|strict|content/.test(style.contain);
|
|
2527
|
+
if (createsContainingBlock) {
|
|
2528
|
+
const rect = node.getBoundingClientRect();
|
|
2529
|
+
return { top: rect.top, left: rect.left };
|
|
2530
|
+
}
|
|
2531
|
+
node = node.parentElement;
|
|
2532
|
+
}
|
|
2533
|
+
return { top: 0, left: 0 };
|
|
2534
|
+
}
|
|
2535
|
+
function clamp2(n, min, max) {
|
|
2536
|
+
return Math.max(min, Math.min(max, n));
|
|
2537
|
+
}
|
|
2526
2538
|
function setPopupPositionFixed(popupEl, rect, topBoundary) {
|
|
2527
2539
|
const GAP = 8;
|
|
2528
2540
|
const MARGIN = 8;
|
|
@@ -2530,6 +2542,9 @@ function setPopupPositionFixed(popupEl, rect, topBoundary) {
|
|
|
2530
2542
|
let left = rect.left;
|
|
2531
2543
|
if (top < topBoundary) top = rect.bottom + GAP;
|
|
2532
2544
|
left = clamp2(left, MARGIN, window.innerWidth - popupEl.offsetWidth - MARGIN);
|
|
2545
|
+
const origin = getFixedPositionOrigin(popupEl);
|
|
2546
|
+
top -= origin.top;
|
|
2547
|
+
left -= origin.left;
|
|
2533
2548
|
popupEl.style.top = `${top}px`;
|
|
2534
2549
|
popupEl.style.left = `${left}px`;
|
|
2535
2550
|
}
|
|
@@ -2546,22 +2561,22 @@ function FloatingCharacterStylesEditor({
|
|
|
2546
2561
|
isEditable,
|
|
2547
2562
|
readOnly
|
|
2548
2563
|
}) {
|
|
2549
|
-
const popupRef =
|
|
2550
|
-
const mouseDownRef =
|
|
2564
|
+
const popupRef = React9.useRef(null);
|
|
2565
|
+
const mouseDownRef = React9.useRef(false);
|
|
2551
2566
|
const theme2 = react.useTheme();
|
|
2552
2567
|
const disabled = !(isEditable ?? editor.isEditable()) || !!readOnly;
|
|
2553
|
-
const format =
|
|
2568
|
+
const format = React9.useCallback(
|
|
2554
2569
|
(type) => {
|
|
2555
2570
|
if (disabled) return;
|
|
2556
2571
|
editor.dispatchCommand(lexical.FORMAT_TEXT_COMMAND, type);
|
|
2557
2572
|
},
|
|
2558
2573
|
[editor, disabled]
|
|
2559
2574
|
);
|
|
2560
|
-
const toggleLink =
|
|
2575
|
+
const toggleLink = React9.useCallback(() => {
|
|
2561
2576
|
if (disabled) return;
|
|
2562
2577
|
editor.dispatchCommand(link.TOGGLE_LINK_COMMAND, isLink ? null : "https://");
|
|
2563
2578
|
}, [editor, disabled, isLink]);
|
|
2564
|
-
const updatePosition =
|
|
2579
|
+
const updatePosition = React9.useCallback(() => {
|
|
2565
2580
|
const popupEl = popupRef.current;
|
|
2566
2581
|
if (!popupEl) return;
|
|
2567
2582
|
const sel = window.getSelection();
|
|
@@ -2589,7 +2604,7 @@ function FloatingCharacterStylesEditor({
|
|
|
2589
2604
|
}
|
|
2590
2605
|
popupEl.classList.add("is-open");
|
|
2591
2606
|
}, [editor]);
|
|
2592
|
-
|
|
2607
|
+
React9.useEffect(() => {
|
|
2593
2608
|
const onResize = () => editor.getEditorState().read(updatePosition);
|
|
2594
2609
|
const onScroll = () => editor.getEditorState().read(updatePosition);
|
|
2595
2610
|
const root = editor.getRootElement();
|
|
@@ -2602,7 +2617,7 @@ function FloatingCharacterStylesEditor({
|
|
|
2602
2617
|
root?.removeEventListener("scroll", onScroll);
|
|
2603
2618
|
};
|
|
2604
2619
|
}, [editor, updatePosition]);
|
|
2605
|
-
|
|
2620
|
+
React9.useEffect(() => {
|
|
2606
2621
|
editor.getEditorState().read(updatePosition);
|
|
2607
2622
|
return utils.mergeRegister(
|
|
2608
2623
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -2773,18 +2788,18 @@ function getSelectedNode(selection$1) {
|
|
|
2773
2788
|
return isBackward ? selection.$isAtNodeEnd(selection$1.focus) ? anchorNode : focusNode : selection.$isAtNodeEnd(selection$1.anchor) ? focusNode : anchorNode;
|
|
2774
2789
|
}
|
|
2775
2790
|
function useCharacterStylesPopup(editor, opts) {
|
|
2776
|
-
const [isText, setIsText] =
|
|
2777
|
-
const [isLink, setIsLink] =
|
|
2778
|
-
const [isBold, setIsBold] =
|
|
2779
|
-
const [isItalic, setIsItalic] =
|
|
2780
|
-
const [isUnderline, setIsUnderline] =
|
|
2781
|
-
const [isStrikethrough, setIsStrikethrough] =
|
|
2782
|
-
const [isSubscript, setIsSubscript] =
|
|
2783
|
-
const [isSuperscript, setIsSuperscript] =
|
|
2784
|
-
const [isCode, setIsCode] =
|
|
2791
|
+
const [isText, setIsText] = React9.useState(false);
|
|
2792
|
+
const [isLink, setIsLink] = React9.useState(false);
|
|
2793
|
+
const [isBold, setIsBold] = React9.useState(false);
|
|
2794
|
+
const [isItalic, setIsItalic] = React9.useState(false);
|
|
2795
|
+
const [isUnderline, setIsUnderline] = React9.useState(false);
|
|
2796
|
+
const [isStrikethrough, setIsStrikethrough] = React9.useState(false);
|
|
2797
|
+
const [isSubscript, setIsSubscript] = React9.useState(false);
|
|
2798
|
+
const [isSuperscript, setIsSuperscript] = React9.useState(false);
|
|
2799
|
+
const [isCode, setIsCode] = React9.useState(false);
|
|
2785
2800
|
const isEditable = opts?.isEditable ?? editor.isEditable();
|
|
2786
2801
|
const portalContainer = useFloatingPortalContainer(editor);
|
|
2787
|
-
const updatePopupState =
|
|
2802
|
+
const updatePopupState = React9.useCallback(() => {
|
|
2788
2803
|
editor.getEditorState().read(() => {
|
|
2789
2804
|
const selection = lexical.$getSelection();
|
|
2790
2805
|
const nativeSelection = window.getSelection();
|
|
@@ -2816,7 +2831,7 @@ function useCharacterStylesPopup(editor, opts) {
|
|
|
2816
2831
|
}
|
|
2817
2832
|
});
|
|
2818
2833
|
}, [editor]);
|
|
2819
|
-
|
|
2834
|
+
React9.useEffect(() => {
|
|
2820
2835
|
document.addEventListener("selectionchange", updatePopupState);
|
|
2821
2836
|
document.addEventListener("focusin", updatePopupState);
|
|
2822
2837
|
return () => {
|
|
@@ -2824,7 +2839,7 @@ function useCharacterStylesPopup(editor, opts) {
|
|
|
2824
2839
|
document.removeEventListener("focusin", updatePopupState);
|
|
2825
2840
|
};
|
|
2826
2841
|
}, [updatePopupState]);
|
|
2827
|
-
|
|
2842
|
+
React9.useEffect(() => editor.registerUpdateListener(updatePopupState), [editor, updatePopupState]);
|
|
2828
2843
|
if (!portalContainer || !isText || isLink) return null;
|
|
2829
2844
|
return reactDom.createPortal(
|
|
2830
2845
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3107,8 +3122,8 @@ function splitHeadingsAtBrSequences(html) {
|
|
|
3107
3122
|
}
|
|
3108
3123
|
var CustomOnChangePlugin = ({ value, onChange }) => {
|
|
3109
3124
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
3110
|
-
const initializedRef =
|
|
3111
|
-
|
|
3125
|
+
const initializedRef = React9.useRef(false);
|
|
3126
|
+
React9.useEffect(() => {
|
|
3112
3127
|
if (!value || initializedRef.current) return;
|
|
3113
3128
|
initializedRef.current = true;
|
|
3114
3129
|
editor.update(() => {
|
|
@@ -3152,23 +3167,6 @@ var getSelectedNode2 = (selection$1) => {
|
|
|
3152
3167
|
var VERTICAL_GAP = 10;
|
|
3153
3168
|
var HORIZONTAL_OFFSET = 5;
|
|
3154
3169
|
var VIEWPORT_MARGIN = 8;
|
|
3155
|
-
function useFloatingPortalContainer2(editor) {
|
|
3156
|
-
const [container, setContainer] = React10.useState(null);
|
|
3157
|
-
React10.useEffect(() => {
|
|
3158
|
-
const root = editor.getRootElement();
|
|
3159
|
-
if (!root) return;
|
|
3160
|
-
const panelOrLayer = root.closest(".ms-Panel-main") || root.closest(".ms-Panel") || root.closest(".ms-Layer") || document.body;
|
|
3161
|
-
const host = document.createElement("div");
|
|
3162
|
-
host.className = "lexical-floating-ui-host";
|
|
3163
|
-
panelOrLayer.appendChild(host);
|
|
3164
|
-
setContainer(host);
|
|
3165
|
-
return () => {
|
|
3166
|
-
host.remove();
|
|
3167
|
-
setContainer(null);
|
|
3168
|
-
};
|
|
3169
|
-
}, [editor]);
|
|
3170
|
-
return container;
|
|
3171
|
-
}
|
|
3172
3170
|
var setFloatingElemPositionForLinkEditor = (targetRect, floatingElem, topBoundary = VIEWPORT_MARGIN, verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET) => {
|
|
3173
3171
|
if (targetRect === null) {
|
|
3174
3172
|
floatingElem.style.opacity = "0";
|
|
@@ -3185,6 +3183,9 @@ var setFloatingElemPositionForLinkEditor = (targetRect, floatingElem, topBoundar
|
|
|
3185
3183
|
top = topBoundary;
|
|
3186
3184
|
}
|
|
3187
3185
|
left = Math.max(VIEWPORT_MARGIN, Math.min(left, window.innerWidth - floatingElemRect.width - VIEWPORT_MARGIN));
|
|
3186
|
+
const origin = getFixedPositionOrigin(floatingElem);
|
|
3187
|
+
top -= origin.top;
|
|
3188
|
+
left -= origin.left;
|
|
3188
3189
|
floatingElem.style.opacity = "1";
|
|
3189
3190
|
floatingElem.style.transform = "none";
|
|
3190
3191
|
floatingElem.style.top = `${top}px`;
|
|
@@ -3212,12 +3213,12 @@ var preventDefault = (event) => {
|
|
|
3212
3213
|
event.preventDefault();
|
|
3213
3214
|
};
|
|
3214
3215
|
var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLinkEditMode }) => {
|
|
3215
|
-
const [editedLinkUrl, setEditedLinkUrl] =
|
|
3216
|
-
const [lastSelection, setLastSelection] =
|
|
3217
|
-
const [linkUrl, setLinkUrl] =
|
|
3218
|
-
const editorRef =
|
|
3219
|
-
const inputRef =
|
|
3220
|
-
const $updateLinkEditor =
|
|
3216
|
+
const [editedLinkUrl, setEditedLinkUrl] = React9.useState("https://");
|
|
3217
|
+
const [lastSelection, setLastSelection] = React9.useState(null);
|
|
3218
|
+
const [linkUrl, setLinkUrl] = React9.useState("");
|
|
3219
|
+
const editorRef = React9.useRef(null);
|
|
3220
|
+
const inputRef = React9.useRef(null);
|
|
3221
|
+
const $updateLinkEditor = React9.useCallback(() => {
|
|
3221
3222
|
const selection = lexical.$getSelection();
|
|
3222
3223
|
if (lexical.$isRangeSelection(selection)) {
|
|
3223
3224
|
const node = getSelectedNode2(selection);
|
|
@@ -3258,7 +3259,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3258
3259
|
}
|
|
3259
3260
|
return true;
|
|
3260
3261
|
}, [editor, setIsLinkEditMode, isLinkEditMode, isLink, linkUrl]);
|
|
3261
|
-
|
|
3262
|
+
React9.useEffect(() => {
|
|
3262
3263
|
const update = () => {
|
|
3263
3264
|
editor.getEditorState().read(() => {
|
|
3264
3265
|
$updateLinkEditor();
|
|
@@ -3274,7 +3275,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3274
3275
|
root?.removeEventListener("scroll", update);
|
|
3275
3276
|
};
|
|
3276
3277
|
}, [editor, $updateLinkEditor]);
|
|
3277
|
-
|
|
3278
|
+
React9.useEffect(() => {
|
|
3278
3279
|
return utils.mergeRegister(
|
|
3279
3280
|
editor.registerUpdateListener(({ editorState }) => {
|
|
3280
3281
|
editorState.read(() => {
|
|
@@ -3302,12 +3303,12 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3302
3303
|
)
|
|
3303
3304
|
);
|
|
3304
3305
|
}, [editor, $updateLinkEditor, setIsLink, isLink]);
|
|
3305
|
-
|
|
3306
|
+
React9.useEffect(() => {
|
|
3306
3307
|
editor.getEditorState().read(() => {
|
|
3307
3308
|
$updateLinkEditor();
|
|
3308
3309
|
});
|
|
3309
3310
|
}, [editor, $updateLinkEditor]);
|
|
3310
|
-
|
|
3311
|
+
React9.useEffect(() => {
|
|
3311
3312
|
if (isLinkEditMode && inputRef.current) {
|
|
3312
3313
|
inputRef.current.focus();
|
|
3313
3314
|
}
|
|
@@ -3437,10 +3438,10 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3437
3438
|
] }) });
|
|
3438
3439
|
};
|
|
3439
3440
|
var useFloatingLinkEditorToolbar = (editor, anchorElem, isLinkEditMode, setIsLinkEditMode) => {
|
|
3440
|
-
const [activeEditor, setActiveEditor] =
|
|
3441
|
-
const [isLink, setIsLink] =
|
|
3442
|
-
const portalContainer =
|
|
3443
|
-
|
|
3441
|
+
const [activeEditor, setActiveEditor] = React9.useState(editor);
|
|
3442
|
+
const [isLink, setIsLink] = React9.useState(false);
|
|
3443
|
+
const portalContainer = useFloatingPortalContainer(editor);
|
|
3444
|
+
React9.useEffect(() => {
|
|
3444
3445
|
function $updateToolbar() {
|
|
3445
3446
|
const selection = lexical.$getSelection();
|
|
3446
3447
|
if (lexical.$isRangeSelection(selection)) {
|
|
@@ -3514,7 +3515,6 @@ var FloatingLinkEditorPlugin = ({ anchorElem, isLinkEditMode, setIsLinkEditMode
|
|
|
3514
3515
|
setIsLinkEditMode
|
|
3515
3516
|
);
|
|
3516
3517
|
};
|
|
3517
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React10__namespace.useLayoutEffect : React10__namespace.useEffect;
|
|
3518
3518
|
var AoModal = ({
|
|
3519
3519
|
isOpen,
|
|
3520
3520
|
onDismiss,
|
|
@@ -3524,18 +3524,8 @@ var AoModal = ({
|
|
|
3524
3524
|
actions,
|
|
3525
3525
|
children
|
|
3526
3526
|
}) => {
|
|
3527
|
-
const [
|
|
3528
|
-
const
|
|
3529
|
-
useIsomorphicLayoutEffect(() => {
|
|
3530
|
-
if (isOpen && mountRef.current) {
|
|
3531
|
-
const root = mountRef.current.closest(".lexical-rich-editor-root");
|
|
3532
|
-
if (root) {
|
|
3533
|
-
setHostElement(root);
|
|
3534
|
-
} else {
|
|
3535
|
-
setHostElement(mountRef.current.parentElement);
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
}, [isOpen]);
|
|
3527
|
+
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
3528
|
+
const hostElement = useFloatingPortalContainer(editor);
|
|
3539
3529
|
if (!isOpen) return null;
|
|
3540
3530
|
const modalContent = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aoModalBackdrop", onClick: onDismiss, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3541
3531
|
reactComponents.FluentProvider,
|
|
@@ -3562,10 +3552,8 @@ var AoModal = ({
|
|
|
3562
3552
|
]
|
|
3563
3553
|
}
|
|
3564
3554
|
) });
|
|
3565
|
-
if (hostElement)
|
|
3566
|
-
|
|
3567
|
-
}
|
|
3568
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: mountRef, style: { display: "none" } });
|
|
3555
|
+
if (!hostElement) return null;
|
|
3556
|
+
return reactDom.createPortal(modalContent, hostElement);
|
|
3569
3557
|
};
|
|
3570
3558
|
|
|
3571
3559
|
// src/Plugins/ImagePlugin.tsx
|
|
@@ -3592,8 +3580,8 @@ var InsertImageByURL = ({
|
|
|
3592
3580
|
onClick,
|
|
3593
3581
|
disabled
|
|
3594
3582
|
}) => {
|
|
3595
|
-
const [altText, setAltText] =
|
|
3596
|
-
const [src, setSrc] =
|
|
3583
|
+
const [altText, setAltText] = React9.useState("");
|
|
3584
|
+
const [src, setSrc] = React9.useState("");
|
|
3597
3585
|
const isDisabled = disabled || src === "";
|
|
3598
3586
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { tokens: { childrenGap: 6, padding: "10px 0px 0px 0px" }, children: [
|
|
3599
3587
|
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "Enter URL", size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3649,16 +3637,16 @@ var InsertImageDialog = ({
|
|
|
3649
3637
|
maxImageSizeMB,
|
|
3650
3638
|
validationMessages
|
|
3651
3639
|
}) => {
|
|
3652
|
-
const [src, setSrc] =
|
|
3653
|
-
const [altText, setAltText] =
|
|
3654
|
-
const [isOpen, setIsOpen] =
|
|
3655
|
-
const [selectedValue, setSelectedValue] =
|
|
3656
|
-
const [fileName, setFileName] =
|
|
3657
|
-
const [fileSizeError, setFileSizeError] =
|
|
3658
|
-
const hasModifier =
|
|
3640
|
+
const [src, setSrc] = React9.useState("");
|
|
3641
|
+
const [altText, setAltText] = React9.useState("");
|
|
3642
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
3643
|
+
const [selectedValue, setSelectedValue] = React9.useState("Upload");
|
|
3644
|
+
const [fileName, setFileName] = React9.useState("");
|
|
3645
|
+
const [fileSizeError, setFileSizeError] = React9.useState(null);
|
|
3646
|
+
const hasModifier = React9.useRef(false);
|
|
3659
3647
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
3660
3648
|
const isDisabled = disabled || src === "" || !!fileSizeError;
|
|
3661
|
-
|
|
3649
|
+
React9.useEffect(() => {
|
|
3662
3650
|
hasModifier.current = false;
|
|
3663
3651
|
const handler = (e) => {
|
|
3664
3652
|
hasModifier.current = e.altKey;
|
|
@@ -3804,7 +3792,7 @@ var InsertImageDialog = ({
|
|
|
3804
3792
|
};
|
|
3805
3793
|
var ImagesPlugin = ({ captionsEnabled }) => {
|
|
3806
3794
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
3807
|
-
|
|
3795
|
+
React9.useEffect(() => {
|
|
3808
3796
|
if (!editor.hasNodes([ImageNode])) {
|
|
3809
3797
|
throw new Error("ImagesPlugin: ImageNode not registered on editor");
|
|
3810
3798
|
}
|
|
@@ -3996,13 +3984,13 @@ var InsertInlineImageDialog = ({
|
|
|
3996
3984
|
maxImageSizeMB,
|
|
3997
3985
|
validationMessages
|
|
3998
3986
|
}) => {
|
|
3999
|
-
const hasModifier =
|
|
4000
|
-
const [src, setSrc] =
|
|
4001
|
-
const [isOpen, setIsOpen] =
|
|
4002
|
-
const [altText, setAltText] =
|
|
4003
|
-
const [fileName, setFileName] =
|
|
4004
|
-
const [position, setPosition] =
|
|
4005
|
-
const [fileSizeError, setFileSizeError] =
|
|
3987
|
+
const hasModifier = React9.useRef(false);
|
|
3988
|
+
const [src, setSrc] = React9.useState("");
|
|
3989
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
3990
|
+
const [altText, setAltText] = React9.useState("");
|
|
3991
|
+
const [fileName, setFileName] = React9.useState("");
|
|
3992
|
+
const [position, setPosition] = React9.useState("left");
|
|
3993
|
+
const [fileSizeError, setFileSizeError] = React9.useState(null);
|
|
4006
3994
|
const styles = useStyles();
|
|
4007
3995
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
4008
3996
|
const isDisabled = disabled || src === "" || !!fileSizeError;
|
|
@@ -4033,7 +4021,7 @@ var InsertInlineImageDialog = ({
|
|
|
4033
4021
|
};
|
|
4034
4022
|
reader.readAsDataURL(file);
|
|
4035
4023
|
};
|
|
4036
|
-
|
|
4024
|
+
React9.useEffect(() => {
|
|
4037
4025
|
const handler = (e) => {
|
|
4038
4026
|
hasModifier.current = e.altKey;
|
|
4039
4027
|
};
|
|
@@ -4179,7 +4167,7 @@ var InsertInlineImageDialog = ({
|
|
|
4179
4167
|
};
|
|
4180
4168
|
var InlineImagePlugin = () => {
|
|
4181
4169
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4182
|
-
|
|
4170
|
+
React9.useEffect(() => {
|
|
4183
4171
|
if (!editor.hasNodes([InlineImageNode])) {
|
|
4184
4172
|
throw new Error("ImagesPlugin: ImageNode not registered on editor");
|
|
4185
4173
|
}
|
|
@@ -4322,7 +4310,7 @@ var getDragSelection2 = (event) => {
|
|
|
4322
4310
|
var INSERT_PAGE_BREAK = lexical.createCommand();
|
|
4323
4311
|
function PageBreakPlugin() {
|
|
4324
4312
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4325
|
-
|
|
4313
|
+
React9.useEffect(() => {
|
|
4326
4314
|
if (!editor.hasNodes([PageBreakNode])) {
|
|
4327
4315
|
throw new Error(
|
|
4328
4316
|
"PageBreakPlugin: PageBreakNode is not registered on editor"
|
|
@@ -4438,8 +4426,8 @@ function RefApiPlugin({
|
|
|
4438
4426
|
focusedRef
|
|
4439
4427
|
}) {
|
|
4440
4428
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4441
|
-
const cleanBaselineRef =
|
|
4442
|
-
|
|
4429
|
+
const cleanBaselineRef = React9__namespace.default.useRef(null);
|
|
4430
|
+
React9__namespace.default.useEffect(() => {
|
|
4443
4431
|
const capture = () => {
|
|
4444
4432
|
if (cleanBaselineRef.current === null) {
|
|
4445
4433
|
cleanBaselineRef.current = getUserContentSignature(editor);
|
|
@@ -4460,7 +4448,7 @@ function RefApiPlugin({
|
|
|
4460
4448
|
unregister();
|
|
4461
4449
|
};
|
|
4462
4450
|
}, [editor]);
|
|
4463
|
-
|
|
4451
|
+
React9.useImperativeHandle(
|
|
4464
4452
|
forwardedRef,
|
|
4465
4453
|
() => ({
|
|
4466
4454
|
setValue: (html$1) => {
|
|
@@ -4653,28 +4641,28 @@ function SpellPopover({
|
|
|
4653
4641
|
onImprove,
|
|
4654
4642
|
onAcceptGrammar
|
|
4655
4643
|
}) {
|
|
4656
|
-
const ref =
|
|
4644
|
+
const ref = React9__namespace.useRef(null);
|
|
4657
4645
|
const type = state.issue.type ?? "spelling";
|
|
4658
|
-
const [pos, setPos] =
|
|
4659
|
-
|
|
4646
|
+
const [pos, setPos] = React9__namespace.useState({ left: state.x, top: state.y });
|
|
4647
|
+
React9__namespace.useEffect(() => {
|
|
4660
4648
|
if (!ref.current) return;
|
|
4661
4649
|
const { offsetHeight: h, offsetWidth: w } = ref.current;
|
|
4662
4650
|
const top = state.y + h > window.innerHeight - 8 ? state.y - h - 32 : state.y;
|
|
4663
4651
|
setPos({ left: Math.min(state.x, window.innerWidth - w - 8), top });
|
|
4664
4652
|
}, [state.x, state.y]);
|
|
4665
|
-
|
|
4653
|
+
React9__namespace.useEffect(() => {
|
|
4666
4654
|
const h = (e) => {
|
|
4667
4655
|
if (ref.current && !ref.current.contains(e.target)) onClose();
|
|
4668
4656
|
};
|
|
4669
4657
|
document.addEventListener("mousedown", h, true);
|
|
4670
4658
|
return () => document.removeEventListener("mousedown", h, true);
|
|
4671
4659
|
}, [onClose]);
|
|
4672
|
-
|
|
4660
|
+
React9__namespace.useEffect(() => {
|
|
4673
4661
|
const h = () => onClose();
|
|
4674
4662
|
window.addEventListener("scroll", h, { capture: true, passive: true });
|
|
4675
4663
|
return () => window.removeEventListener("scroll", h, true);
|
|
4676
4664
|
}, [onClose]);
|
|
4677
|
-
|
|
4665
|
+
React9__namespace.useEffect(() => {
|
|
4678
4666
|
const h = (e) => {
|
|
4679
4667
|
if (e.key === "Escape") onClose();
|
|
4680
4668
|
};
|
|
@@ -4791,17 +4779,17 @@ function SpellCheckPlugin({
|
|
|
4791
4779
|
enabled = true
|
|
4792
4780
|
}) {
|
|
4793
4781
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4794
|
-
const timerRef =
|
|
4795
|
-
const dismissRef =
|
|
4796
|
-
const reqIdRef =
|
|
4797
|
-
const lastTextRef =
|
|
4798
|
-
const applyingRef =
|
|
4799
|
-
const grammarCorrectionRef =
|
|
4800
|
-
const [popover, setPopover] =
|
|
4801
|
-
|
|
4782
|
+
const timerRef = React9__namespace.useRef(null);
|
|
4783
|
+
const dismissRef = React9__namespace.useRef(null);
|
|
4784
|
+
const reqIdRef = React9__namespace.useRef(0);
|
|
4785
|
+
const lastTextRef = React9__namespace.useRef("");
|
|
4786
|
+
const applyingRef = React9__namespace.useRef(false);
|
|
4787
|
+
const grammarCorrectionRef = React9__namespace.useRef(void 0);
|
|
4788
|
+
const [popover, setPopover] = React9__namespace.useState(null);
|
|
4789
|
+
React9__namespace.useEffect(() => {
|
|
4802
4790
|
injectCSS();
|
|
4803
4791
|
}, []);
|
|
4804
|
-
const clearErrors =
|
|
4792
|
+
const clearErrors = React9__namespace.useCallback(() => {
|
|
4805
4793
|
setPopover(null);
|
|
4806
4794
|
grammarCorrectionRef.current = void 0;
|
|
4807
4795
|
applyingRef.current = true;
|
|
@@ -4817,7 +4805,7 @@ function SpellCheckPlugin({
|
|
|
4817
4805
|
}
|
|
4818
4806
|
);
|
|
4819
4807
|
}, [editor]);
|
|
4820
|
-
const applyIssues =
|
|
4808
|
+
const applyIssues = React9__namespace.useCallback(
|
|
4821
4809
|
(issues, improvedText, trimOffset = 0) => {
|
|
4822
4810
|
let savedCharOffset = -1;
|
|
4823
4811
|
editor.getEditorState().read(() => {
|
|
@@ -4960,7 +4948,7 @@ function SpellCheckPlugin({
|
|
|
4960
4948
|
},
|
|
4961
4949
|
[editor]
|
|
4962
4950
|
);
|
|
4963
|
-
|
|
4951
|
+
React9__namespace.useEffect(() => {
|
|
4964
4952
|
let currentRoot = null;
|
|
4965
4953
|
const onClick = (e) => {
|
|
4966
4954
|
const span = e.target.closest("[data-spell-offset]");
|
|
@@ -5004,7 +4992,7 @@ function SpellCheckPlugin({
|
|
|
5004
4992
|
if (currentRoot) currentRoot.removeEventListener("click", onClick);
|
|
5005
4993
|
};
|
|
5006
4994
|
}, [editor]);
|
|
5007
|
-
const handleAccept =
|
|
4995
|
+
const handleAccept = React9__namespace.useCallback(
|
|
5008
4996
|
(replacement, nodeKey) => {
|
|
5009
4997
|
let original = "";
|
|
5010
4998
|
editor.getEditorState().read(() => {
|
|
@@ -5030,7 +5018,7 @@ function SpellCheckPlugin({
|
|
|
5030
5018
|
},
|
|
5031
5019
|
[editor, onSpellCheckAccept, popover]
|
|
5032
5020
|
);
|
|
5033
|
-
const handleDismiss =
|
|
5021
|
+
const handleDismiss = React9__namespace.useCallback(
|
|
5034
5022
|
(nodeKey) => {
|
|
5035
5023
|
editor.update(
|
|
5036
5024
|
() => {
|
|
@@ -5044,7 +5032,7 @@ function SpellCheckPlugin({
|
|
|
5044
5032
|
},
|
|
5045
5033
|
[editor]
|
|
5046
5034
|
);
|
|
5047
|
-
const handleImprove =
|
|
5035
|
+
const handleImprove = React9__namespace.useCallback(
|
|
5048
5036
|
(text) => {
|
|
5049
5037
|
const original = lastTextRef.current;
|
|
5050
5038
|
applyingRef.current = true;
|
|
@@ -5064,7 +5052,7 @@ function SpellCheckPlugin({
|
|
|
5064
5052
|
},
|
|
5065
5053
|
[editor, onSpellCheckAccept]
|
|
5066
5054
|
);
|
|
5067
|
-
const handleAcceptGrammar =
|
|
5055
|
+
const handleAcceptGrammar = React9__namespace.useCallback(
|
|
5068
5056
|
(corrected) => {
|
|
5069
5057
|
const original = lastTextRef.current;
|
|
5070
5058
|
applyingRef.current = true;
|
|
@@ -5084,7 +5072,7 @@ function SpellCheckPlugin({
|
|
|
5084
5072
|
},
|
|
5085
5073
|
[editor, onSpellCheckAccept]
|
|
5086
5074
|
);
|
|
5087
|
-
|
|
5075
|
+
React9__namespace.useEffect(() => {
|
|
5088
5076
|
if (!enabled || !useSpellCheck) return;
|
|
5089
5077
|
return editor.registerUpdateListener(({ tags }) => {
|
|
5090
5078
|
if (applyingRef.current) return;
|
|
@@ -5122,13 +5110,13 @@ function SpellCheckPlugin({
|
|
|
5122
5110
|
}, idleMs);
|
|
5123
5111
|
});
|
|
5124
5112
|
}, [editor, useSpellCheck, enabled, idleMs, applyIssues, clearErrors]);
|
|
5125
|
-
|
|
5113
|
+
React9__namespace.useEffect(() => {
|
|
5126
5114
|
if (!enabled) {
|
|
5127
5115
|
clearErrors();
|
|
5128
5116
|
lastTextRef.current = "";
|
|
5129
5117
|
}
|
|
5130
5118
|
}, [enabled, clearErrors]);
|
|
5131
|
-
|
|
5119
|
+
React9__namespace.useEffect(
|
|
5132
5120
|
() => () => {
|
|
5133
5121
|
dismissRef.current?.();
|
|
5134
5122
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
@@ -5149,13 +5137,13 @@ function SpellCheckPlugin({
|
|
|
5149
5137
|
}
|
|
5150
5138
|
function TableActionMenuPlugin({ disabled = false }) {
|
|
5151
5139
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5152
|
-
const [isInTable, setIsInTable] =
|
|
5153
|
-
const [anchorRect, setAnchorRect] =
|
|
5154
|
-
const [contentRight, setContentRight] =
|
|
5155
|
-
const [open, setOpen] =
|
|
5156
|
-
const openRef =
|
|
5157
|
-
const savedAnchorRef =
|
|
5158
|
-
const measureContentRight =
|
|
5140
|
+
const [isInTable, setIsInTable] = React9__namespace.useState(false);
|
|
5141
|
+
const [anchorRect, setAnchorRect] = React9__namespace.useState(null);
|
|
5142
|
+
const [contentRight, setContentRight] = React9__namespace.useState(null);
|
|
5143
|
+
const [open, setOpen] = React9__namespace.useState(false);
|
|
5144
|
+
const openRef = React9__namespace.useRef(false);
|
|
5145
|
+
const savedAnchorRef = React9__namespace.useRef(null);
|
|
5146
|
+
const measureContentRight = React9__namespace.useCallback((cellDom) => {
|
|
5159
5147
|
try {
|
|
5160
5148
|
const range = document.createRange();
|
|
5161
5149
|
range.selectNodeContents(cellDom);
|
|
@@ -5165,7 +5153,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5165
5153
|
return null;
|
|
5166
5154
|
}
|
|
5167
5155
|
}, []);
|
|
5168
|
-
const updateFromSelection =
|
|
5156
|
+
const updateFromSelection = React9__namespace.useCallback(() => {
|
|
5169
5157
|
if (openRef.current) return;
|
|
5170
5158
|
const root = editor.getRootElement();
|
|
5171
5159
|
if (!root) return;
|
|
@@ -5216,7 +5204,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5216
5204
|
}
|
|
5217
5205
|
});
|
|
5218
5206
|
}, [editor, measureContentRight]);
|
|
5219
|
-
|
|
5207
|
+
React9__namespace.useEffect(() => {
|
|
5220
5208
|
return utils.mergeRegister(
|
|
5221
5209
|
editor.registerCommand(
|
|
5222
5210
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
@@ -5231,7 +5219,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5231
5219
|
})
|
|
5232
5220
|
);
|
|
5233
5221
|
}, [editor, updateFromSelection]);
|
|
5234
|
-
|
|
5222
|
+
React9__namespace.useEffect(() => {
|
|
5235
5223
|
return editor.registerCommand(
|
|
5236
5224
|
lexical.KEY_DOWN_COMMAND,
|
|
5237
5225
|
(event) => {
|
|
@@ -5273,7 +5261,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5273
5261
|
);
|
|
5274
5262
|
}, [editor, disabled]);
|
|
5275
5263
|
const canShow = isInTable && !!anchorRect && !disabled;
|
|
5276
|
-
const handleStyle =
|
|
5264
|
+
const handleStyle = React9__namespace.useMemo(() => {
|
|
5277
5265
|
if (!anchorRect) return void 0;
|
|
5278
5266
|
const top = Math.max(8, anchorRect.top + 6);
|
|
5279
5267
|
const clampedCellRight = Math.min(anchorRect.right, window.innerWidth - 8);
|
|
@@ -5288,7 +5276,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5288
5276
|
const dangerStyle = {
|
|
5289
5277
|
color: "var(--colorPaletteRedForeground1)"
|
|
5290
5278
|
};
|
|
5291
|
-
const run =
|
|
5279
|
+
const run = React9__namespace.useCallback(
|
|
5292
5280
|
(fn) => {
|
|
5293
5281
|
if (disabled) return;
|
|
5294
5282
|
openRef.current = false;
|
|
@@ -5391,17 +5379,17 @@ function TableCellResizer({
|
|
|
5391
5379
|
editor,
|
|
5392
5380
|
anchorElem
|
|
5393
5381
|
}) {
|
|
5394
|
-
const targetRef =
|
|
5395
|
-
const resizerRef =
|
|
5396
|
-
const tableRectRef =
|
|
5397
|
-
const mouseStartPosRef =
|
|
5398
|
-
const [mouseCurrentPos, updateMouseCurrentPos] =
|
|
5399
|
-
const [activeCell, updateActiveCell] =
|
|
5400
|
-
const [isSelectingGrid, updateIsSelectingGrid] =
|
|
5401
|
-
const [draggingDirection, updateDraggingDirection] =
|
|
5382
|
+
const targetRef = React9.useRef(null);
|
|
5383
|
+
const resizerRef = React9.useRef(null);
|
|
5384
|
+
const tableRectRef = React9.useRef(null);
|
|
5385
|
+
const mouseStartPosRef = React9.useRef(null);
|
|
5386
|
+
const [mouseCurrentPos, updateMouseCurrentPos] = React9.useState(null);
|
|
5387
|
+
const [activeCell, updateActiveCell] = React9.useState(null);
|
|
5388
|
+
const [isSelectingGrid, updateIsSelectingGrid] = React9.useState(false);
|
|
5389
|
+
const [draggingDirection, updateDraggingDirection] = React9.useState(
|
|
5402
5390
|
null
|
|
5403
5391
|
);
|
|
5404
|
-
|
|
5392
|
+
React9.useEffect(() => {
|
|
5405
5393
|
return editor.registerCommand(
|
|
5406
5394
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
5407
5395
|
() => {
|
|
@@ -5424,7 +5412,7 @@ function TableCellResizer({
|
|
|
5424
5412
|
lexical.COMMAND_PRIORITY_HIGH
|
|
5425
5413
|
);
|
|
5426
5414
|
}, [editor]);
|
|
5427
|
-
const resetState =
|
|
5415
|
+
const resetState = React9.useCallback(() => {
|
|
5428
5416
|
updateActiveCell(null);
|
|
5429
5417
|
targetRef.current = null;
|
|
5430
5418
|
updateDraggingDirection(null);
|
|
@@ -5432,7 +5420,7 @@ function TableCellResizer({
|
|
|
5432
5420
|
tableRectRef.current = null;
|
|
5433
5421
|
updateMouseCurrentPos(null);
|
|
5434
5422
|
}, []);
|
|
5435
|
-
|
|
5423
|
+
React9.useEffect(() => {
|
|
5436
5424
|
const onMouseMove = (event) => {
|
|
5437
5425
|
if (draggingDirection) {
|
|
5438
5426
|
updateMouseCurrentPos({ x: event.clientX, y: event.clientY });
|
|
@@ -5476,7 +5464,7 @@ function TableCellResizer({
|
|
|
5476
5464
|
};
|
|
5477
5465
|
}, [activeCell, draggingDirection, editor, resetState, anchorElem]);
|
|
5478
5466
|
const isHeightChanging = (direction) => direction === "bottom";
|
|
5479
|
-
const updateRowHeight =
|
|
5467
|
+
const updateRowHeight = React9.useCallback(
|
|
5480
5468
|
(newHeight) => {
|
|
5481
5469
|
if (!activeCell) return;
|
|
5482
5470
|
editor.update(() => {
|
|
@@ -5493,7 +5481,7 @@ function TableCellResizer({
|
|
|
5493
5481
|
},
|
|
5494
5482
|
[activeCell, editor]
|
|
5495
5483
|
);
|
|
5496
|
-
const updateColumnWidth =
|
|
5484
|
+
const updateColumnWidth = React9.useCallback(
|
|
5497
5485
|
(newWidth) => {
|
|
5498
5486
|
if (!activeCell) return;
|
|
5499
5487
|
editor.update(() => {
|
|
@@ -5515,7 +5503,7 @@ function TableCellResizer({
|
|
|
5515
5503
|
},
|
|
5516
5504
|
[activeCell, editor]
|
|
5517
5505
|
);
|
|
5518
|
-
const toggleResize =
|
|
5506
|
+
const toggleResize = React9.useCallback(
|
|
5519
5507
|
(direction) => (event) => {
|
|
5520
5508
|
event.preventDefault();
|
|
5521
5509
|
event.stopPropagation();
|
|
@@ -5546,7 +5534,7 @@ function TableCellResizer({
|
|
|
5546
5534
|
},
|
|
5547
5535
|
[activeCell, draggingDirection, resetState, updateColumnWidth, updateRowHeight]
|
|
5548
5536
|
);
|
|
5549
|
-
const getResizers =
|
|
5537
|
+
const getResizers = React9.useCallback(() => {
|
|
5550
5538
|
const empty = { bottom: {}, right: {} };
|
|
5551
5539
|
if (!activeCell) return empty;
|
|
5552
5540
|
const cellRect = activeCell.elem.getBoundingClientRect();
|
|
@@ -5621,7 +5609,7 @@ function TableCellResizerPlugin({
|
|
|
5621
5609
|
anchorElem
|
|
5622
5610
|
}) {
|
|
5623
5611
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5624
|
-
return
|
|
5612
|
+
return React9.useMemo(
|
|
5625
5613
|
() => reactDom.createPortal(/* @__PURE__ */ jsxRuntime.jsx(TableCellResizer, { editor, anchorElem }), anchorElem),
|
|
5626
5614
|
[editor, anchorElem]
|
|
5627
5615
|
);
|
|
@@ -5849,22 +5837,22 @@ var hsvToRgb = (h, s, v) => {
|
|
|
5849
5837
|
};
|
|
5850
5838
|
};
|
|
5851
5839
|
var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange }) => {
|
|
5852
|
-
const [open, setOpen] =
|
|
5853
|
-
const btnRef =
|
|
5854
|
-
const setOpenAndNotify =
|
|
5840
|
+
const [open, setOpen] = React9__namespace.useState(false);
|
|
5841
|
+
const btnRef = React9__namespace.useRef(null);
|
|
5842
|
+
const setOpenAndNotify = React9__namespace.useCallback(
|
|
5855
5843
|
(next) => {
|
|
5856
5844
|
setOpen(next);
|
|
5857
5845
|
onOpenChange?.(next);
|
|
5858
5846
|
},
|
|
5859
5847
|
[onOpenChange]
|
|
5860
5848
|
);
|
|
5861
|
-
const handleDismiss =
|
|
5862
|
-
const preventDismissOnEvent =
|
|
5849
|
+
const handleDismiss = React9__namespace.useCallback(() => setOpenAndNotify(false), [setOpenAndNotify]);
|
|
5850
|
+
const preventDismissOnEvent = React9__namespace.useCallback(
|
|
5863
5851
|
(ev) => ev.type !== "click",
|
|
5864
5852
|
[]
|
|
5865
5853
|
);
|
|
5866
|
-
const [, forceReposition] =
|
|
5867
|
-
|
|
5854
|
+
const [, forceReposition] = React9__namespace.useState(0);
|
|
5855
|
+
React9__namespace.useEffect(() => {
|
|
5868
5856
|
if (!open) return;
|
|
5869
5857
|
let rafId = null;
|
|
5870
5858
|
const reposition = () => {
|
|
@@ -5882,15 +5870,15 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5882
5870
|
window.removeEventListener("resize", reposition);
|
|
5883
5871
|
};
|
|
5884
5872
|
}, [open]);
|
|
5885
|
-
const appliedHex =
|
|
5886
|
-
const [hex, setHexState] =
|
|
5887
|
-
const [hexText, setHexText] =
|
|
5888
|
-
const { r, g, b } =
|
|
5889
|
-
const hsv =
|
|
5890
|
-
const [h, setH] =
|
|
5891
|
-
const [s, setS] =
|
|
5892
|
-
const [v, setV] =
|
|
5893
|
-
const commit =
|
|
5873
|
+
const appliedHex = React9__namespace.useMemo(() => normalizeHex(value || "#000000"), [value]);
|
|
5874
|
+
const [hex, setHexState] = React9__namespace.useState(appliedHex);
|
|
5875
|
+
const [hexText, setHexText] = React9__namespace.useState(appliedHex);
|
|
5876
|
+
const { r, g, b } = React9__namespace.useMemo(() => hexToRgb(hex), [hex]);
|
|
5877
|
+
const hsv = React9__namespace.useMemo(() => rgbToHsv(r, g, b), [r, g, b]);
|
|
5878
|
+
const [h, setH] = React9__namespace.useState(hsv.h);
|
|
5879
|
+
const [s, setS] = React9__namespace.useState(hsv.s);
|
|
5880
|
+
const [v, setV] = React9__namespace.useState(hsv.v);
|
|
5881
|
+
const commit = React9__namespace.useCallback(
|
|
5894
5882
|
(nextHex) => {
|
|
5895
5883
|
const rgb = hexToRgb(nextHex);
|
|
5896
5884
|
const next = rgbToHsv(rgb.r, rgb.g, rgb.b);
|
|
@@ -5903,7 +5891,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5903
5891
|
},
|
|
5904
5892
|
[onChange]
|
|
5905
5893
|
);
|
|
5906
|
-
const commitFromHsv =
|
|
5894
|
+
const commitFromHsv = React9__namespace.useCallback(
|
|
5907
5895
|
(hh, ss, vv) => {
|
|
5908
5896
|
const rgb = hsvToRgb(hh, ss, vv);
|
|
5909
5897
|
const nextHex = rgbToHex(rgb.r, rgb.g, rgb.b);
|
|
@@ -5916,8 +5904,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5916
5904
|
},
|
|
5917
5905
|
[onChange]
|
|
5918
5906
|
);
|
|
5919
|
-
const wasOpenRef =
|
|
5920
|
-
|
|
5907
|
+
const wasOpenRef = React9__namespace.useRef(open);
|
|
5908
|
+
React9__namespace.useEffect(() => {
|
|
5921
5909
|
const justOpened = open && !wasOpenRef.current;
|
|
5922
5910
|
wasOpenRef.current = open;
|
|
5923
5911
|
if (!justOpened) return;
|
|
@@ -5929,8 +5917,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5929
5917
|
setS(next.s);
|
|
5930
5918
|
setV(next.v);
|
|
5931
5919
|
}, [appliedHex, open]);
|
|
5932
|
-
const svRef =
|
|
5933
|
-
const svPointFromEvent =
|
|
5920
|
+
const svRef = React9__namespace.useRef(null);
|
|
5921
|
+
const svPointFromEvent = React9__namespace.useCallback((clientX, clientY) => {
|
|
5934
5922
|
if (!svRef.current) return null;
|
|
5935
5923
|
const rect = svRef.current.getBoundingClientRect();
|
|
5936
5924
|
const x = clamp3(clientX - rect.left, 0, rect.width);
|
|
@@ -5939,9 +5927,9 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5939
5927
|
const vv = rect.height === 0 ? 0 : 1 - y / rect.height;
|
|
5940
5928
|
return { ss, vv };
|
|
5941
5929
|
}, []);
|
|
5942
|
-
const hRef =
|
|
5930
|
+
const hRef = React9__namespace.useRef(h);
|
|
5943
5931
|
hRef.current = h;
|
|
5944
|
-
const handleSVPointerDown =
|
|
5932
|
+
const handleSVPointerDown = React9__namespace.useCallback(
|
|
5945
5933
|
(e) => {
|
|
5946
5934
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
5947
5935
|
const pt = svPointFromEvent(e.clientX, e.clientY);
|
|
@@ -5949,7 +5937,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5949
5937
|
},
|
|
5950
5938
|
[svPointFromEvent, commitFromHsv]
|
|
5951
5939
|
);
|
|
5952
|
-
const handleSVPointerMove =
|
|
5940
|
+
const handleSVPointerMove = React9__namespace.useCallback(
|
|
5953
5941
|
(e) => {
|
|
5954
5942
|
if (e.buttons !== 1) return;
|
|
5955
5943
|
const pt = svPointFromEvent(e.clientX, e.clientY);
|
|
@@ -5957,18 +5945,18 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5957
5945
|
},
|
|
5958
5946
|
[svPointFromEvent, commitFromHsv]
|
|
5959
5947
|
);
|
|
5960
|
-
const hueRef =
|
|
5961
|
-
const sRef =
|
|
5948
|
+
const hueRef = React9__namespace.useRef(null);
|
|
5949
|
+
const sRef = React9__namespace.useRef(s);
|
|
5962
5950
|
sRef.current = s;
|
|
5963
|
-
const vRef =
|
|
5951
|
+
const vRef = React9__namespace.useRef(v);
|
|
5964
5952
|
vRef.current = v;
|
|
5965
|
-
const huePointFromEvent =
|
|
5953
|
+
const huePointFromEvent = React9__namespace.useCallback((clientX) => {
|
|
5966
5954
|
if (!hueRef.current) return null;
|
|
5967
5955
|
const rect = hueRef.current.getBoundingClientRect();
|
|
5968
5956
|
const x = clamp3(clientX - rect.left, 0, rect.width);
|
|
5969
5957
|
return rect.width === 0 ? 0 : x / rect.width * 360;
|
|
5970
5958
|
}, []);
|
|
5971
|
-
const handleHuePointerDown =
|
|
5959
|
+
const handleHuePointerDown = React9__namespace.useCallback(
|
|
5972
5960
|
(e) => {
|
|
5973
5961
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
5974
5962
|
const hh = huePointFromEvent(e.clientX);
|
|
@@ -5976,7 +5964,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5976
5964
|
},
|
|
5977
5965
|
[huePointFromEvent, commitFromHsv]
|
|
5978
5966
|
);
|
|
5979
|
-
const handleHuePointerMove =
|
|
5967
|
+
const handleHuePointerMove = React9__namespace.useCallback(
|
|
5980
5968
|
(e) => {
|
|
5981
5969
|
if (e.buttons !== 1) return;
|
|
5982
5970
|
const hh = huePointFromEvent(e.clientX);
|
|
@@ -5984,7 +5972,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5984
5972
|
},
|
|
5985
5973
|
[huePointFromEvent, commitFromHsv]
|
|
5986
5974
|
);
|
|
5987
|
-
const handleHexChange =
|
|
5975
|
+
const handleHexChange = React9__namespace.useCallback(
|
|
5988
5976
|
(_, val) => {
|
|
5989
5977
|
const next = val ?? "";
|
|
5990
5978
|
setHexText(next);
|
|
@@ -5992,12 +5980,12 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5992
5980
|
},
|
|
5993
5981
|
[commit]
|
|
5994
5982
|
);
|
|
5995
|
-
const handleHexBlur =
|
|
5983
|
+
const handleHexBlur = React9__namespace.useCallback(() => {
|
|
5996
5984
|
commit(normalizeHex(hexText));
|
|
5997
5985
|
}, [hexText, commit]);
|
|
5998
|
-
const svThumb =
|
|
5999
|
-
const hueThumb =
|
|
6000
|
-
const hueColor =
|
|
5986
|
+
const svThumb = React9__namespace.useMemo(() => ({ left: `${s * 100}%`, top: `${(1 - v) * 100}%` }), [s, v]);
|
|
5987
|
+
const hueThumb = React9__namespace.useMemo(() => ({ left: `${h / 360 * 100}%` }), [h]);
|
|
5988
|
+
const hueColor = React9__namespace.useMemo(() => {
|
|
6001
5989
|
const { r: r2, g: g2, b: b2 } = hsvToRgb(h, 1, 1);
|
|
6002
5990
|
return rgbToHex(r2, g2, b2);
|
|
6003
5991
|
}, [h]);
|
|
@@ -6243,8 +6231,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
6243
6231
|
};
|
|
6244
6232
|
var ColorPickerPlugin = ({ disabled }) => {
|
|
6245
6233
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6246
|
-
const [{ color, bgColor }, setColors] =
|
|
6247
|
-
const lastRangeSelectionRef =
|
|
6234
|
+
const [{ color, bgColor }, setColors] = React9__namespace.default.useState({ color: "#000000", bgColor: "#ffffff" });
|
|
6235
|
+
const lastRangeSelectionRef = React9__namespace.default.useRef(null);
|
|
6248
6236
|
const updateToolbar = () => {
|
|
6249
6237
|
const selection$1 = lexical.$getSelection();
|
|
6250
6238
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
@@ -6254,7 +6242,7 @@ var ColorPickerPlugin = ({ disabled }) => {
|
|
|
6254
6242
|
setColors({ color: c, bgColor: bg });
|
|
6255
6243
|
}
|
|
6256
6244
|
};
|
|
6257
|
-
|
|
6245
|
+
React9__namespace.default.useEffect(() => {
|
|
6258
6246
|
return utils.mergeRegister(
|
|
6259
6247
|
editor.registerUpdateListener(({ editorState }) => {
|
|
6260
6248
|
editorState.read(() => updateToolbar());
|
|
@@ -6269,7 +6257,7 @@ var ColorPickerPlugin = ({ disabled }) => {
|
|
|
6269
6257
|
)
|
|
6270
6258
|
);
|
|
6271
6259
|
}, [editor]);
|
|
6272
|
-
const wasEditorActiveRef =
|
|
6260
|
+
const wasEditorActiveRef = React9__namespace.default.useRef(false);
|
|
6273
6261
|
const handleOpenChange = (open) => {
|
|
6274
6262
|
if (open) {
|
|
6275
6263
|
const root = editor.getRootElement();
|
|
@@ -6361,9 +6349,9 @@ var FONT_FAMILY_OPTIONS = [
|
|
|
6361
6349
|
var FontFamilyPlugin = ({ disabled = false }) => {
|
|
6362
6350
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6363
6351
|
const styles = useStyles2();
|
|
6364
|
-
const [fontFamily, setFontFamily] =
|
|
6352
|
+
const [fontFamily, setFontFamily] = React9.useState("");
|
|
6365
6353
|
const fg = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
6366
|
-
|
|
6354
|
+
React9.useEffect(() => {
|
|
6367
6355
|
const readFontFamily = () => {
|
|
6368
6356
|
const selection$1 = lexical.$getSelection();
|
|
6369
6357
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
@@ -6385,7 +6373,7 @@ var FontFamilyPlugin = ({ disabled = false }) => {
|
|
|
6385
6373
|
)
|
|
6386
6374
|
);
|
|
6387
6375
|
}, [editor]);
|
|
6388
|
-
const handleClick =
|
|
6376
|
+
const handleClick = React9.useCallback(
|
|
6389
6377
|
(option) => {
|
|
6390
6378
|
if (disabled) return;
|
|
6391
6379
|
editor.update(() => {
|
|
@@ -6487,9 +6475,9 @@ var useStyles3 = reactComponents.makeStyles({
|
|
|
6487
6475
|
var FontSizePlugin = ({ disabled }) => {
|
|
6488
6476
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6489
6477
|
const styles = useStyles3();
|
|
6490
|
-
const [fontSize2, setFontSize] =
|
|
6478
|
+
const [fontSize2, setFontSize] = React9__namespace.useState(String(DEFAULT_FONT_SIZE));
|
|
6491
6479
|
const fg = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
6492
|
-
|
|
6480
|
+
React9__namespace.useEffect(() => {
|
|
6493
6481
|
const readFontSize = () => {
|
|
6494
6482
|
const selection$1 = lexical.$getSelection();
|
|
6495
6483
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
@@ -6659,9 +6647,9 @@ function PageSetupPlugin({ disabled, value, onChange }) {
|
|
|
6659
6647
|
}
|
|
6660
6648
|
var TableItemPlugin = ({ disabled }) => {
|
|
6661
6649
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6662
|
-
const [columns, setColumns] =
|
|
6663
|
-
const [rows, setRows] =
|
|
6664
|
-
const [isOpen, setIsOpen] =
|
|
6650
|
+
const [columns, setColumns] = React9.useState("");
|
|
6651
|
+
const [rows, setRows] = React9.useState("");
|
|
6652
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
6665
6653
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
6666
6654
|
const onAddTable = () => {
|
|
6667
6655
|
if (disabled) return;
|
|
@@ -6748,8 +6736,8 @@ var TableItemPlugin = ({ disabled }) => {
|
|
|
6748
6736
|
] });
|
|
6749
6737
|
};
|
|
6750
6738
|
var YoutubeUploadPlugin = ({ disabled }) => {
|
|
6751
|
-
const [url, setURL] =
|
|
6752
|
-
const [isOpen, setIsOpen] =
|
|
6739
|
+
const [url, setURL] = React9.useState("");
|
|
6740
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
6753
6741
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6754
6742
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#424242";
|
|
6755
6743
|
const onHandleEmbeded = () => {
|
|
@@ -6881,24 +6869,24 @@ var ToolBarPlugins = (props) => {
|
|
|
6881
6869
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6882
6870
|
const theme2 = react.useTheme();
|
|
6883
6871
|
const styles = useStyles4();
|
|
6884
|
-
const [selectNodeType, setSelectNodeType] =
|
|
6885
|
-
const [isEditable, setIsEditable] =
|
|
6886
|
-
const [isBold, setIsBold] =
|
|
6887
|
-
const [isItalic, setIsItalic] =
|
|
6888
|
-
const [isUnderline, setIsUnderline] =
|
|
6889
|
-
const [isStrikethrough, setIsStrikethrough] =
|
|
6890
|
-
const [isSuperscript, setIsSuperscript] =
|
|
6891
|
-
const [isSubscript, setIsSubscript] =
|
|
6892
|
-
const [isHighlight, setIsHighlight] =
|
|
6893
|
-
const [isUppercase, setIsUppercase] =
|
|
6894
|
-
const [isLowercase, setIsLowercase] =
|
|
6895
|
-
const [isCapitalize, setIsCapitalize] =
|
|
6896
|
-
const [alignment, setAlignment] =
|
|
6897
|
-
const [hasTextSelection, setHasTextSelection] =
|
|
6898
|
-
const [decoratorOpen, setDecoratorOpen] =
|
|
6899
|
-
const decoratorSelectingRef =
|
|
6872
|
+
const [selectNodeType, setSelectNodeType] = React9.useState("paragraph");
|
|
6873
|
+
const [isEditable, setIsEditable] = React9.useState(() => editor.isEditable());
|
|
6874
|
+
const [isBold, setIsBold] = React9.useState(false);
|
|
6875
|
+
const [isItalic, setIsItalic] = React9.useState(false);
|
|
6876
|
+
const [isUnderline, setIsUnderline] = React9.useState(false);
|
|
6877
|
+
const [isStrikethrough, setIsStrikethrough] = React9.useState(false);
|
|
6878
|
+
const [isSuperscript, setIsSuperscript] = React9.useState(false);
|
|
6879
|
+
const [isSubscript, setIsSubscript] = React9.useState(false);
|
|
6880
|
+
const [isHighlight, setIsHighlight] = React9.useState(false);
|
|
6881
|
+
const [isUppercase, setIsUppercase] = React9.useState(false);
|
|
6882
|
+
const [isLowercase, setIsLowercase] = React9.useState(false);
|
|
6883
|
+
const [isCapitalize, setIsCapitalize] = React9.useState(false);
|
|
6884
|
+
const [alignment, setAlignment] = React9.useState("left");
|
|
6885
|
+
const [hasTextSelection, setHasTextSelection] = React9.useState(false);
|
|
6886
|
+
const [decoratorOpen, setDecoratorOpen] = React9.useState(false);
|
|
6887
|
+
const decoratorSelectingRef = React9__namespace.default.useRef(false);
|
|
6900
6888
|
const presetGroups = props.customToolbar ?? getToolbarGroupsByLevel(props.level);
|
|
6901
|
-
const pluginGroups =
|
|
6889
|
+
const pluginGroups = React9.useMemo(() => sanitizePluginGroups(presetGroups), [presetGroups]);
|
|
6902
6890
|
const updateToolbarPlugins = () => {
|
|
6903
6891
|
const selection = lexical.$getSelection();
|
|
6904
6892
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -6968,7 +6956,7 @@ var ToolBarPlugins = (props) => {
|
|
|
6968
6956
|
}
|
|
6969
6957
|
});
|
|
6970
6958
|
};
|
|
6971
|
-
|
|
6959
|
+
React9__namespace.default.useEffect(() => {
|
|
6972
6960
|
return utils.mergeRegister(
|
|
6973
6961
|
editor.registerEditableListener((editable) => {
|
|
6974
6962
|
setIsEditable(editable);
|
|
@@ -7842,7 +7830,7 @@ var ToolBarPlugins = (props) => {
|
|
|
7842
7830
|
padding: "0px",
|
|
7843
7831
|
minHeight: 36
|
|
7844
7832
|
},
|
|
7845
|
-
children: pluginGroups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7833
|
+
children: pluginGroups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsx(React9__namespace.default.Fragment, { children: group.map((token, tokenIndex) => {
|
|
7846
7834
|
try {
|
|
7847
7835
|
return renderToken(token, groupIndex, tokenIndex);
|
|
7848
7836
|
} catch {
|
|
@@ -7861,7 +7849,7 @@ function isYoutubeLikeNode(node) {
|
|
|
7861
7849
|
}
|
|
7862
7850
|
function YoutubeDeletePlugin() {
|
|
7863
7851
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7864
|
-
|
|
7852
|
+
React9.useEffect(() => {
|
|
7865
7853
|
const removeIfYoutubeAtCursor = (direction) => {
|
|
7866
7854
|
const selection = lexical.$getSelection();
|
|
7867
7855
|
if (!lexical.$isRangeSelection(selection)) return false;
|
|
@@ -7893,7 +7881,7 @@ function YoutubeDeletePlugin() {
|
|
|
7893
7881
|
lexical.COMMAND_PRIORITY_HIGH
|
|
7894
7882
|
);
|
|
7895
7883
|
}, [editor]);
|
|
7896
|
-
|
|
7884
|
+
React9.useEffect(() => {
|
|
7897
7885
|
return editor.registerCommand(
|
|
7898
7886
|
lexical.KEY_DELETE_COMMAND,
|
|
7899
7887
|
() => {
|
|
@@ -7982,14 +7970,14 @@ var theme = {
|
|
|
7982
7970
|
};
|
|
7983
7971
|
function ReadOnlyPlugin({ readonly }) {
|
|
7984
7972
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7985
|
-
|
|
7973
|
+
React9.useEffect(() => {
|
|
7986
7974
|
editor.setEditable(!readonly);
|
|
7987
7975
|
}, [editor, readonly]);
|
|
7988
7976
|
return null;
|
|
7989
7977
|
}
|
|
7990
7978
|
function BrowserSpellCheckPlugin({ enabled }) {
|
|
7991
7979
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7992
|
-
|
|
7980
|
+
React9.useEffect(() => {
|
|
7993
7981
|
const el = editor.getRootElement();
|
|
7994
7982
|
if (!el) return;
|
|
7995
7983
|
el.spellcheck = enabled;
|
|
@@ -8004,8 +7992,8 @@ function ContentMetricsPlugin({
|
|
|
8004
7992
|
onMetricsChange
|
|
8005
7993
|
}) {
|
|
8006
7994
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
8007
|
-
const prevRef =
|
|
8008
|
-
|
|
7995
|
+
const prevRef = React9.useRef({ words: 0, chars: 0, images: 0, links: 0, tables: 0 });
|
|
7996
|
+
React9.useEffect(() => {
|
|
8009
7997
|
return editor.registerUpdateListener(({ dirtyElements, dirtyLeaves }) => {
|
|
8010
7998
|
if (dirtyElements.size === 0 && dirtyLeaves.size === 0) return;
|
|
8011
7999
|
const root = editor.getRootElement();
|
|
@@ -8034,7 +8022,7 @@ function FocusEventsPlugin({
|
|
|
8034
8022
|
containerRef
|
|
8035
8023
|
}) {
|
|
8036
8024
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
8037
|
-
|
|
8025
|
+
React9.useEffect(() => {
|
|
8038
8026
|
const root = editor.getRootElement();
|
|
8039
8027
|
if (!root) return;
|
|
8040
8028
|
const handleFocusIn = () => {
|
|
@@ -8158,51 +8146,51 @@ function _makeQueryFn(fn) {
|
|
|
8158
8146
|
}
|
|
8159
8147
|
function EditorReadyPlugin({ onReady }) {
|
|
8160
8148
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
8161
|
-
const calledRef =
|
|
8162
|
-
|
|
8149
|
+
const calledRef = React9.useRef(false);
|
|
8150
|
+
React9.useEffect(() => {
|
|
8163
8151
|
if (!onReady || calledRef.current) return;
|
|
8164
8152
|
calledRef.current = true;
|
|
8165
8153
|
onReady(editor);
|
|
8166
8154
|
}, [editor, onReady]);
|
|
8167
8155
|
return null;
|
|
8168
8156
|
}
|
|
8169
|
-
var ContentEditorComponent =
|
|
8157
|
+
var ContentEditorComponent = React9.forwardRef(
|
|
8170
8158
|
(props, ref) => {
|
|
8171
8159
|
const isReadOnly = !!props.readOnly;
|
|
8172
|
-
const resolvedSpellCheck =
|
|
8160
|
+
const resolvedSpellCheck = React9__namespace.default.useMemo(
|
|
8173
8161
|
() => props.spellCheckFn ? _makeSpellCheckFn(props.spellCheckFn) : props.useSpellCheck,
|
|
8174
8162
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8175
8163
|
[props.spellCheckFn, props.useSpellCheck]
|
|
8176
8164
|
);
|
|
8177
|
-
const resolvedQuery =
|
|
8165
|
+
const resolvedQuery = React9__namespace.default.useMemo(
|
|
8178
8166
|
() => props.suggestFn ? _makeQueryFn(props.suggestFn) : props.useQuery,
|
|
8179
8167
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8180
8168
|
[props.suggestFn, props.useQuery]
|
|
8181
8169
|
);
|
|
8182
|
-
const [floatingAnchorElem, setFloatingAnchorElem] =
|
|
8183
|
-
const [isLinkEditMode, setIsLinkEditMode] =
|
|
8184
|
-
const [metrics, setMetrics] =
|
|
8170
|
+
const [floatingAnchorElem, setFloatingAnchorElem] = React9.useState(null);
|
|
8171
|
+
const [isLinkEditMode, setIsLinkEditMode] = React9.useState(false);
|
|
8172
|
+
const [metrics, setMetrics] = React9.useState({
|
|
8185
8173
|
words: 0,
|
|
8186
8174
|
chars: 0,
|
|
8187
8175
|
images: 0,
|
|
8188
8176
|
links: 0,
|
|
8189
8177
|
tables: 0
|
|
8190
8178
|
});
|
|
8191
|
-
const handleMetrics =
|
|
8192
|
-
const [pageSetup, setPageSetup] =
|
|
8179
|
+
const handleMetrics = React9.useCallback((m) => setMetrics(m), []);
|
|
8180
|
+
const [pageSetup, setPageSetup] = React9.useState(DEFAULT_PAGE_SETUP);
|
|
8193
8181
|
const pageCanvas = resolvePageCanvasMetrics(pageSetup);
|
|
8194
8182
|
const wordCount = metrics.words;
|
|
8195
|
-
const contentEditableDomRef =
|
|
8196
|
-
const previousOverLimitRef =
|
|
8197
|
-
const focusedRef =
|
|
8183
|
+
const contentEditableDomRef = React9.useRef(null);
|
|
8184
|
+
const previousOverLimitRef = React9.useRef(false);
|
|
8185
|
+
const focusedRef = React9.useRef(false);
|
|
8198
8186
|
const setFocused = (focused) => {
|
|
8199
8187
|
focusedRef.current = focused;
|
|
8200
8188
|
};
|
|
8201
|
-
const containerRef =
|
|
8189
|
+
const containerRef = React9.useRef(null);
|
|
8202
8190
|
const onAnchorRef = (elem) => {
|
|
8203
8191
|
if (elem) setFloatingAnchorElem(elem);
|
|
8204
8192
|
};
|
|
8205
|
-
const initialConfig =
|
|
8193
|
+
const initialConfig = React9__namespace.default.useMemo(() => {
|
|
8206
8194
|
const config = {
|
|
8207
8195
|
namespace: props.namespace ?? "",
|
|
8208
8196
|
theme,
|
|
@@ -8280,7 +8268,7 @@ var ContentEditorComponent = React10.forwardRef(
|
|
|
8280
8268
|
}
|
|
8281
8269
|
};
|
|
8282
8270
|
const isOverLimit = props.wordLimit !== void 0 && wordCount > props.wordLimit;
|
|
8283
|
-
|
|
8271
|
+
React9.useEffect(() => {
|
|
8284
8272
|
if (props.wordLimit === void 0 || !props.onWordLimitExceeded) return;
|
|
8285
8273
|
const wasOverLimit = previousOverLimitRef.current;
|
|
8286
8274
|
if (isOverLimit !== wasOverLimit) {
|
|
@@ -8292,7 +8280,7 @@ var ContentEditorComponent = React10.forwardRef(
|
|
|
8292
8280
|
previousOverLimitRef.current = isOverLimit;
|
|
8293
8281
|
}
|
|
8294
8282
|
}, [isOverLimit, wordCount, props.wordLimit, props.onWordLimitExceeded]);
|
|
8295
|
-
const validationErrors =
|
|
8283
|
+
const validationErrors = React9__namespace.default.useMemo(() => {
|
|
8296
8284
|
const errors = [];
|
|
8297
8285
|
const custom = props.validationMessages ?? {};
|
|
8298
8286
|
const { words, chars, images, links, tables } = metrics;
|
|
@@ -8349,8 +8337,8 @@ var ContentEditorComponent = React10.forwardRef(
|
|
|
8349
8337
|
props.noTables,
|
|
8350
8338
|
props.validationMessages
|
|
8351
8339
|
]);
|
|
8352
|
-
const previousErrorTypesRef =
|
|
8353
|
-
|
|
8340
|
+
const previousErrorTypesRef = React9.useRef("");
|
|
8341
|
+
React9.useEffect(() => {
|
|
8354
8342
|
if (!props.onValidationChange) return;
|
|
8355
8343
|
const key = validationErrors.map((e) => e.type).join(",");
|
|
8356
8344
|
if (key !== previousErrorTypesRef.current) {
|