@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.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mergeRegister, $wrapNodeInElement, $insertNodeToNearestRoot, $getNearestNodeOfType, $findMatchingParent as $findMatchingParent$1, calculateZoomLevel } from '@lexical/utils';
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
2
|
+
import * as React9 from 'react';
|
|
3
|
+
import React9__default, { forwardRef, useState, useCallback, useRef, useEffect, useMemo, useImperativeHandle, Suspense } from 'react';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
6
6
|
import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
@@ -642,7 +642,7 @@ function parseDimFromStyleOrAttr(img3) {
|
|
|
642
642
|
var ImageComponent2, isGoogleDocCheckboxImg, $convertImageElement, ImageNode, $createImageNode, $isImageNode;
|
|
643
643
|
var init_ImageNode = __esm({
|
|
644
644
|
"src/Nodes/ImageNode.tsx"() {
|
|
645
|
-
ImageComponent2 =
|
|
645
|
+
ImageComponent2 = React9.lazy(() => Promise.resolve().then(() => (init_ImageComponent(), ImageComponent_exports)));
|
|
646
646
|
isGoogleDocCheckboxImg = (img3) => {
|
|
647
647
|
return img3.parentElement != null && img3.parentElement.tagName === "LI" && img3.previousSibling === null && img3.getAttribute("aria-roledescription") === "checkbox";
|
|
648
648
|
};
|
|
@@ -1061,7 +1061,7 @@ var init_InlineImageComponent = __esm({
|
|
|
1061
1061
|
var InlineImageComponent2, $convertInlineImageElement, InlineImageNode, $createInlineImageNode, $isInlineImageNode;
|
|
1062
1062
|
var init_InlineImageNode = __esm({
|
|
1063
1063
|
"src/Nodes/InlineImageNode.tsx"() {
|
|
1064
|
-
InlineImageComponent2 =
|
|
1064
|
+
InlineImageComponent2 = React9.lazy(() => Promise.resolve().then(() => (init_InlineImageComponent(), InlineImageComponent_exports)));
|
|
1065
1065
|
$convertInlineImageElement = (domNode) => {
|
|
1066
1066
|
if (isHTMLElement(domNode) && domNode.nodeName === "IMG") {
|
|
1067
1067
|
const { alt: altText, src, width, height } = domNode;
|
|
@@ -1702,7 +1702,7 @@ function VideoResizer({
|
|
|
1702
1702
|
onResizeStart,
|
|
1703
1703
|
onResizeEnd
|
|
1704
1704
|
}) {
|
|
1705
|
-
const resizeState =
|
|
1705
|
+
const resizeState = React9.useRef(null);
|
|
1706
1706
|
const startResize = (e, dir) => {
|
|
1707
1707
|
e.preventDefault();
|
|
1708
1708
|
e.stopPropagation();
|
|
@@ -1829,15 +1829,15 @@ function YouTubeComponent({
|
|
|
1829
1829
|
height,
|
|
1830
1830
|
editor
|
|
1831
1831
|
}) {
|
|
1832
|
-
const wrapperRef =
|
|
1833
|
-
const containerRef =
|
|
1834
|
-
const iframeRef =
|
|
1835
|
-
const isResizingRef =
|
|
1832
|
+
const wrapperRef = React9.useRef(null);
|
|
1833
|
+
const containerRef = React9.useRef(null);
|
|
1834
|
+
const iframeRef = React9.useRef(null);
|
|
1835
|
+
const isResizingRef = React9.useRef(false);
|
|
1836
1836
|
const [isNodeSelected, setNodeSelected, clearNodeSelection] = useLexicalNodeSelection(nodeKey);
|
|
1837
|
-
const [isHovered, setIsHovered] =
|
|
1838
|
-
const [isResizing, setIsResizing] =
|
|
1839
|
-
const [isPlaying, setIsPlaying] =
|
|
1840
|
-
|
|
1837
|
+
const [isHovered, setIsHovered] = React9.useState(false);
|
|
1838
|
+
const [isResizing, setIsResizing] = React9.useState(false);
|
|
1839
|
+
const [isPlaying, setIsPlaying] = React9.useState(false);
|
|
1840
|
+
React9.useEffect(() => {
|
|
1841
1841
|
return mergeRegister(
|
|
1842
1842
|
editor.registerCommand(
|
|
1843
1843
|
FORMAT_ELEMENT_COMMAND,
|
|
@@ -2226,13 +2226,13 @@ function AutocompletePlugin({
|
|
|
2226
2226
|
prefixWindow = 300
|
|
2227
2227
|
}) {
|
|
2228
2228
|
const [editor] = useLexicalComposerContext();
|
|
2229
|
-
const ghostKeyRef =
|
|
2230
|
-
const idleTimerRef =
|
|
2231
|
-
const inflightRef =
|
|
2232
|
-
const reqCounterRef =
|
|
2233
|
-
const lastTriggerRef =
|
|
2234
|
-
const lastShownCtxRef =
|
|
2235
|
-
const clearGhost =
|
|
2229
|
+
const ghostKeyRef = React9.useRef(null);
|
|
2230
|
+
const idleTimerRef = React9.useRef(null);
|
|
2231
|
+
const inflightRef = React9.useRef(null);
|
|
2232
|
+
const reqCounterRef = React9.useRef(0);
|
|
2233
|
+
const lastTriggerRef = React9.useRef("");
|
|
2234
|
+
const lastShownCtxRef = React9.useRef("");
|
|
2235
|
+
const clearGhost = React9.useCallback(() => {
|
|
2236
2236
|
editor.update(
|
|
2237
2237
|
() => {
|
|
2238
2238
|
const key = ghostKeyRef.current;
|
|
@@ -2244,7 +2244,7 @@ function AutocompletePlugin({
|
|
|
2244
2244
|
{ tag: "autocomplete-ghost" }
|
|
2245
2245
|
);
|
|
2246
2246
|
}, [editor]);
|
|
2247
|
-
const upsertGhost =
|
|
2247
|
+
const upsertGhost = React9.useCallback(
|
|
2248
2248
|
(text, insertAtCharOffset) => {
|
|
2249
2249
|
editor.update(
|
|
2250
2250
|
() => {
|
|
@@ -2308,12 +2308,12 @@ function AutocompletePlugin({
|
|
|
2308
2308
|
},
|
|
2309
2309
|
[editor]
|
|
2310
2310
|
);
|
|
2311
|
-
const cancelInflight =
|
|
2311
|
+
const cancelInflight = React9.useCallback(() => {
|
|
2312
2312
|
if (!inflightRef.current) return;
|
|
2313
2313
|
inflightRef.current.dismiss();
|
|
2314
2314
|
inflightRef.current = null;
|
|
2315
2315
|
}, []);
|
|
2316
|
-
const resetIdleTimer =
|
|
2316
|
+
const resetIdleTimer = React9.useCallback(
|
|
2317
2317
|
(callback) => {
|
|
2318
2318
|
if (idleTimerRef.current) {
|
|
2319
2319
|
clearTimeout(idleTimerRef.current);
|
|
@@ -2328,7 +2328,7 @@ function AutocompletePlugin({
|
|
|
2328
2328
|
},
|
|
2329
2329
|
[idleMs, cancelInflight, clearGhost]
|
|
2330
2330
|
);
|
|
2331
|
-
const fireQuery =
|
|
2331
|
+
const fireQuery = React9.useCallback(() => {
|
|
2332
2332
|
if (!useQuery || isReadOnly) return;
|
|
2333
2333
|
let context = "";
|
|
2334
2334
|
let prefix = "";
|
|
@@ -2400,7 +2400,7 @@ function AutocompletePlugin({
|
|
|
2400
2400
|
upsertGhost,
|
|
2401
2401
|
onSuggestionShown
|
|
2402
2402
|
]);
|
|
2403
|
-
|
|
2403
|
+
React9.useEffect(() => {
|
|
2404
2404
|
if (!useQuery || isReadOnly) return;
|
|
2405
2405
|
return editor.registerUpdateListener(({ tags }) => {
|
|
2406
2406
|
if (tags.has("history-merge") || tags.has("collaboration")) return;
|
|
@@ -2409,7 +2409,7 @@ function AutocompletePlugin({
|
|
|
2409
2409
|
resetIdleTimer(fireQuery);
|
|
2410
2410
|
});
|
|
2411
2411
|
}, [editor, useQuery, isReadOnly, resetIdleTimer, fireQuery]);
|
|
2412
|
-
|
|
2412
|
+
React9.useEffect(() => {
|
|
2413
2413
|
if (!useQuery || isReadOnly) return;
|
|
2414
2414
|
return editor.registerCommand(
|
|
2415
2415
|
SELECTION_CHANGE_COMMAND,
|
|
@@ -2433,7 +2433,7 @@ function AutocompletePlugin({
|
|
|
2433
2433
|
COMMAND_PRIORITY_LOW
|
|
2434
2434
|
);
|
|
2435
2435
|
}, [editor, useQuery, isReadOnly, resetIdleTimer, fireQuery]);
|
|
2436
|
-
|
|
2436
|
+
React9.useEffect(() => {
|
|
2437
2437
|
return editor.registerCommand(
|
|
2438
2438
|
KEY_DOWN_COMMAND,
|
|
2439
2439
|
(e) => {
|
|
@@ -2474,7 +2474,7 @@ function AutocompletePlugin({
|
|
|
2474
2474
|
COMMAND_PRIORITY_HIGH
|
|
2475
2475
|
);
|
|
2476
2476
|
}, [editor, clearGhost, onSuggestionAccept, prefixWindow]);
|
|
2477
|
-
|
|
2477
|
+
React9.useEffect(() => {
|
|
2478
2478
|
return () => {
|
|
2479
2479
|
cancelInflight();
|
|
2480
2480
|
if (idleTimerRef.current) clearTimeout(idleTimerRef.current);
|
|
@@ -2482,18 +2482,14 @@ function AutocompletePlugin({
|
|
|
2482
2482
|
}, [cancelInflight]);
|
|
2483
2483
|
return null;
|
|
2484
2484
|
}
|
|
2485
|
-
function clamp2(n, min, max) {
|
|
2486
|
-
return Math.max(min, Math.min(max, n));
|
|
2487
|
-
}
|
|
2488
2485
|
function useFloatingPortalContainer(editor) {
|
|
2489
2486
|
const [container, setContainer] = useState(null);
|
|
2490
2487
|
useEffect(() => {
|
|
2491
2488
|
const root = editor.getRootElement();
|
|
2492
2489
|
if (!root) return;
|
|
2493
|
-
const panelOrLayer = root.closest(".ms-Panel-main") || root.closest(".ms-Panel") || root.closest(".ms-Layer") || document.body;
|
|
2494
2490
|
const host = document.createElement("div");
|
|
2495
2491
|
host.className = "lexical-floating-ui-host";
|
|
2496
|
-
|
|
2492
|
+
document.body.appendChild(host);
|
|
2497
2493
|
setContainer(host);
|
|
2498
2494
|
return () => {
|
|
2499
2495
|
host.remove();
|
|
@@ -2502,6 +2498,22 @@ function useFloatingPortalContainer(editor) {
|
|
|
2502
2498
|
}, [editor]);
|
|
2503
2499
|
return container;
|
|
2504
2500
|
}
|
|
2501
|
+
function getFixedPositionOrigin(fromElement) {
|
|
2502
|
+
let node = fromElement.parentElement;
|
|
2503
|
+
while (node && node !== document.body && node !== document.documentElement) {
|
|
2504
|
+
const style = getComputedStyle(node);
|
|
2505
|
+
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);
|
|
2506
|
+
if (createsContainingBlock) {
|
|
2507
|
+
const rect = node.getBoundingClientRect();
|
|
2508
|
+
return { top: rect.top, left: rect.left };
|
|
2509
|
+
}
|
|
2510
|
+
node = node.parentElement;
|
|
2511
|
+
}
|
|
2512
|
+
return { top: 0, left: 0 };
|
|
2513
|
+
}
|
|
2514
|
+
function clamp2(n, min, max) {
|
|
2515
|
+
return Math.max(min, Math.min(max, n));
|
|
2516
|
+
}
|
|
2505
2517
|
function setPopupPositionFixed(popupEl, rect, topBoundary) {
|
|
2506
2518
|
const GAP = 8;
|
|
2507
2519
|
const MARGIN = 8;
|
|
@@ -2509,6 +2521,9 @@ function setPopupPositionFixed(popupEl, rect, topBoundary) {
|
|
|
2509
2521
|
let left = rect.left;
|
|
2510
2522
|
if (top < topBoundary) top = rect.bottom + GAP;
|
|
2511
2523
|
left = clamp2(left, MARGIN, window.innerWidth - popupEl.offsetWidth - MARGIN);
|
|
2524
|
+
const origin = getFixedPositionOrigin(popupEl);
|
|
2525
|
+
top -= origin.top;
|
|
2526
|
+
left -= origin.left;
|
|
2512
2527
|
popupEl.style.top = `${top}px`;
|
|
2513
2528
|
popupEl.style.left = `${left}px`;
|
|
2514
2529
|
}
|
|
@@ -3131,23 +3146,6 @@ var getSelectedNode2 = (selection) => {
|
|
|
3131
3146
|
var VERTICAL_GAP = 10;
|
|
3132
3147
|
var HORIZONTAL_OFFSET = 5;
|
|
3133
3148
|
var VIEWPORT_MARGIN = 8;
|
|
3134
|
-
function useFloatingPortalContainer2(editor) {
|
|
3135
|
-
const [container, setContainer] = useState(null);
|
|
3136
|
-
useEffect(() => {
|
|
3137
|
-
const root = editor.getRootElement();
|
|
3138
|
-
if (!root) return;
|
|
3139
|
-
const panelOrLayer = root.closest(".ms-Panel-main") || root.closest(".ms-Panel") || root.closest(".ms-Layer") || document.body;
|
|
3140
|
-
const host = document.createElement("div");
|
|
3141
|
-
host.className = "lexical-floating-ui-host";
|
|
3142
|
-
panelOrLayer.appendChild(host);
|
|
3143
|
-
setContainer(host);
|
|
3144
|
-
return () => {
|
|
3145
|
-
host.remove();
|
|
3146
|
-
setContainer(null);
|
|
3147
|
-
};
|
|
3148
|
-
}, [editor]);
|
|
3149
|
-
return container;
|
|
3150
|
-
}
|
|
3151
3149
|
var setFloatingElemPositionForLinkEditor = (targetRect, floatingElem, topBoundary = VIEWPORT_MARGIN, verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET) => {
|
|
3152
3150
|
if (targetRect === null) {
|
|
3153
3151
|
floatingElem.style.opacity = "0";
|
|
@@ -3164,6 +3162,9 @@ var setFloatingElemPositionForLinkEditor = (targetRect, floatingElem, topBoundar
|
|
|
3164
3162
|
top = topBoundary;
|
|
3165
3163
|
}
|
|
3166
3164
|
left = Math.max(VIEWPORT_MARGIN, Math.min(left, window.innerWidth - floatingElemRect.width - VIEWPORT_MARGIN));
|
|
3165
|
+
const origin = getFixedPositionOrigin(floatingElem);
|
|
3166
|
+
top -= origin.top;
|
|
3167
|
+
left -= origin.left;
|
|
3167
3168
|
floatingElem.style.opacity = "1";
|
|
3168
3169
|
floatingElem.style.transform = "none";
|
|
3169
3170
|
floatingElem.style.top = `${top}px`;
|
|
@@ -3418,7 +3419,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3418
3419
|
var useFloatingLinkEditorToolbar = (editor, anchorElem, isLinkEditMode, setIsLinkEditMode) => {
|
|
3419
3420
|
const [activeEditor, setActiveEditor] = useState(editor);
|
|
3420
3421
|
const [isLink, setIsLink] = useState(false);
|
|
3421
|
-
const portalContainer =
|
|
3422
|
+
const portalContainer = useFloatingPortalContainer(editor);
|
|
3422
3423
|
useEffect(() => {
|
|
3423
3424
|
function $updateToolbar() {
|
|
3424
3425
|
const selection = $getSelection();
|
|
@@ -3493,7 +3494,6 @@ var FloatingLinkEditorPlugin = ({ anchorElem, isLinkEditMode, setIsLinkEditMode
|
|
|
3493
3494
|
setIsLinkEditMode
|
|
3494
3495
|
);
|
|
3495
3496
|
};
|
|
3496
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React10.useLayoutEffect : React10.useEffect;
|
|
3497
3497
|
var AoModal = ({
|
|
3498
3498
|
isOpen,
|
|
3499
3499
|
onDismiss,
|
|
@@ -3503,18 +3503,8 @@ var AoModal = ({
|
|
|
3503
3503
|
actions,
|
|
3504
3504
|
children
|
|
3505
3505
|
}) => {
|
|
3506
|
-
const [
|
|
3507
|
-
const
|
|
3508
|
-
useIsomorphicLayoutEffect(() => {
|
|
3509
|
-
if (isOpen && mountRef.current) {
|
|
3510
|
-
const root = mountRef.current.closest(".lexical-rich-editor-root");
|
|
3511
|
-
if (root) {
|
|
3512
|
-
setHostElement(root);
|
|
3513
|
-
} else {
|
|
3514
|
-
setHostElement(mountRef.current.parentElement);
|
|
3515
|
-
}
|
|
3516
|
-
}
|
|
3517
|
-
}, [isOpen]);
|
|
3506
|
+
const [editor] = useLexicalComposerContext();
|
|
3507
|
+
const hostElement = useFloatingPortalContainer(editor);
|
|
3518
3508
|
if (!isOpen) return null;
|
|
3519
3509
|
const modalContent = /* @__PURE__ */ jsx("div", { className: "aoModalBackdrop", onClick: onDismiss, children: /* @__PURE__ */ jsxs(
|
|
3520
3510
|
FluentProvider,
|
|
@@ -3541,10 +3531,8 @@ var AoModal = ({
|
|
|
3541
3531
|
]
|
|
3542
3532
|
}
|
|
3543
3533
|
) });
|
|
3544
|
-
if (hostElement)
|
|
3545
|
-
|
|
3546
|
-
}
|
|
3547
|
-
return /* @__PURE__ */ jsx("div", { ref: mountRef, style: { display: "none" } });
|
|
3534
|
+
if (!hostElement) return null;
|
|
3535
|
+
return createPortal(modalContent, hostElement);
|
|
3548
3536
|
};
|
|
3549
3537
|
|
|
3550
3538
|
// src/Plugins/ImagePlugin.tsx
|
|
@@ -4417,8 +4405,8 @@ function RefApiPlugin({
|
|
|
4417
4405
|
focusedRef
|
|
4418
4406
|
}) {
|
|
4419
4407
|
const [editor] = useLexicalComposerContext();
|
|
4420
|
-
const cleanBaselineRef =
|
|
4421
|
-
|
|
4408
|
+
const cleanBaselineRef = React9__default.useRef(null);
|
|
4409
|
+
React9__default.useEffect(() => {
|
|
4422
4410
|
const capture = () => {
|
|
4423
4411
|
if (cleanBaselineRef.current === null) {
|
|
4424
4412
|
cleanBaselineRef.current = getUserContentSignature(editor);
|
|
@@ -4632,28 +4620,28 @@ function SpellPopover({
|
|
|
4632
4620
|
onImprove,
|
|
4633
4621
|
onAcceptGrammar
|
|
4634
4622
|
}) {
|
|
4635
|
-
const ref =
|
|
4623
|
+
const ref = React9.useRef(null);
|
|
4636
4624
|
const type = state.issue.type ?? "spelling";
|
|
4637
|
-
const [pos, setPos] =
|
|
4638
|
-
|
|
4625
|
+
const [pos, setPos] = React9.useState({ left: state.x, top: state.y });
|
|
4626
|
+
React9.useEffect(() => {
|
|
4639
4627
|
if (!ref.current) return;
|
|
4640
4628
|
const { offsetHeight: h, offsetWidth: w } = ref.current;
|
|
4641
4629
|
const top = state.y + h > window.innerHeight - 8 ? state.y - h - 32 : state.y;
|
|
4642
4630
|
setPos({ left: Math.min(state.x, window.innerWidth - w - 8), top });
|
|
4643
4631
|
}, [state.x, state.y]);
|
|
4644
|
-
|
|
4632
|
+
React9.useEffect(() => {
|
|
4645
4633
|
const h = (e) => {
|
|
4646
4634
|
if (ref.current && !ref.current.contains(e.target)) onClose();
|
|
4647
4635
|
};
|
|
4648
4636
|
document.addEventListener("mousedown", h, true);
|
|
4649
4637
|
return () => document.removeEventListener("mousedown", h, true);
|
|
4650
4638
|
}, [onClose]);
|
|
4651
|
-
|
|
4639
|
+
React9.useEffect(() => {
|
|
4652
4640
|
const h = () => onClose();
|
|
4653
4641
|
window.addEventListener("scroll", h, { capture: true, passive: true });
|
|
4654
4642
|
return () => window.removeEventListener("scroll", h, true);
|
|
4655
4643
|
}, [onClose]);
|
|
4656
|
-
|
|
4644
|
+
React9.useEffect(() => {
|
|
4657
4645
|
const h = (e) => {
|
|
4658
4646
|
if (e.key === "Escape") onClose();
|
|
4659
4647
|
};
|
|
@@ -4770,17 +4758,17 @@ function SpellCheckPlugin({
|
|
|
4770
4758
|
enabled = true
|
|
4771
4759
|
}) {
|
|
4772
4760
|
const [editor] = useLexicalComposerContext();
|
|
4773
|
-
const timerRef =
|
|
4774
|
-
const dismissRef =
|
|
4775
|
-
const reqIdRef =
|
|
4776
|
-
const lastTextRef =
|
|
4777
|
-
const applyingRef =
|
|
4778
|
-
const grammarCorrectionRef =
|
|
4779
|
-
const [popover, setPopover] =
|
|
4780
|
-
|
|
4761
|
+
const timerRef = React9.useRef(null);
|
|
4762
|
+
const dismissRef = React9.useRef(null);
|
|
4763
|
+
const reqIdRef = React9.useRef(0);
|
|
4764
|
+
const lastTextRef = React9.useRef("");
|
|
4765
|
+
const applyingRef = React9.useRef(false);
|
|
4766
|
+
const grammarCorrectionRef = React9.useRef(void 0);
|
|
4767
|
+
const [popover, setPopover] = React9.useState(null);
|
|
4768
|
+
React9.useEffect(() => {
|
|
4781
4769
|
injectCSS();
|
|
4782
4770
|
}, []);
|
|
4783
|
-
const clearErrors =
|
|
4771
|
+
const clearErrors = React9.useCallback(() => {
|
|
4784
4772
|
setPopover(null);
|
|
4785
4773
|
grammarCorrectionRef.current = void 0;
|
|
4786
4774
|
applyingRef.current = true;
|
|
@@ -4796,7 +4784,7 @@ function SpellCheckPlugin({
|
|
|
4796
4784
|
}
|
|
4797
4785
|
);
|
|
4798
4786
|
}, [editor]);
|
|
4799
|
-
const applyIssues =
|
|
4787
|
+
const applyIssues = React9.useCallback(
|
|
4800
4788
|
(issues, improvedText, trimOffset = 0) => {
|
|
4801
4789
|
let savedCharOffset = -1;
|
|
4802
4790
|
editor.getEditorState().read(() => {
|
|
@@ -4939,7 +4927,7 @@ function SpellCheckPlugin({
|
|
|
4939
4927
|
},
|
|
4940
4928
|
[editor]
|
|
4941
4929
|
);
|
|
4942
|
-
|
|
4930
|
+
React9.useEffect(() => {
|
|
4943
4931
|
let currentRoot = null;
|
|
4944
4932
|
const onClick = (e) => {
|
|
4945
4933
|
const span = e.target.closest("[data-spell-offset]");
|
|
@@ -4983,7 +4971,7 @@ function SpellCheckPlugin({
|
|
|
4983
4971
|
if (currentRoot) currentRoot.removeEventListener("click", onClick);
|
|
4984
4972
|
};
|
|
4985
4973
|
}, [editor]);
|
|
4986
|
-
const handleAccept =
|
|
4974
|
+
const handleAccept = React9.useCallback(
|
|
4987
4975
|
(replacement, nodeKey) => {
|
|
4988
4976
|
let original = "";
|
|
4989
4977
|
editor.getEditorState().read(() => {
|
|
@@ -5009,7 +4997,7 @@ function SpellCheckPlugin({
|
|
|
5009
4997
|
},
|
|
5010
4998
|
[editor, onSpellCheckAccept, popover]
|
|
5011
4999
|
);
|
|
5012
|
-
const handleDismiss =
|
|
5000
|
+
const handleDismiss = React9.useCallback(
|
|
5013
5001
|
(nodeKey) => {
|
|
5014
5002
|
editor.update(
|
|
5015
5003
|
() => {
|
|
@@ -5023,7 +5011,7 @@ function SpellCheckPlugin({
|
|
|
5023
5011
|
},
|
|
5024
5012
|
[editor]
|
|
5025
5013
|
);
|
|
5026
|
-
const handleImprove =
|
|
5014
|
+
const handleImprove = React9.useCallback(
|
|
5027
5015
|
(text) => {
|
|
5028
5016
|
const original = lastTextRef.current;
|
|
5029
5017
|
applyingRef.current = true;
|
|
@@ -5043,7 +5031,7 @@ function SpellCheckPlugin({
|
|
|
5043
5031
|
},
|
|
5044
5032
|
[editor, onSpellCheckAccept]
|
|
5045
5033
|
);
|
|
5046
|
-
const handleAcceptGrammar =
|
|
5034
|
+
const handleAcceptGrammar = React9.useCallback(
|
|
5047
5035
|
(corrected) => {
|
|
5048
5036
|
const original = lastTextRef.current;
|
|
5049
5037
|
applyingRef.current = true;
|
|
@@ -5063,7 +5051,7 @@ function SpellCheckPlugin({
|
|
|
5063
5051
|
},
|
|
5064
5052
|
[editor, onSpellCheckAccept]
|
|
5065
5053
|
);
|
|
5066
|
-
|
|
5054
|
+
React9.useEffect(() => {
|
|
5067
5055
|
if (!enabled || !useSpellCheck) return;
|
|
5068
5056
|
return editor.registerUpdateListener(({ tags }) => {
|
|
5069
5057
|
if (applyingRef.current) return;
|
|
@@ -5101,13 +5089,13 @@ function SpellCheckPlugin({
|
|
|
5101
5089
|
}, idleMs);
|
|
5102
5090
|
});
|
|
5103
5091
|
}, [editor, useSpellCheck, enabled, idleMs, applyIssues, clearErrors]);
|
|
5104
|
-
|
|
5092
|
+
React9.useEffect(() => {
|
|
5105
5093
|
if (!enabled) {
|
|
5106
5094
|
clearErrors();
|
|
5107
5095
|
lastTextRef.current = "";
|
|
5108
5096
|
}
|
|
5109
5097
|
}, [enabled, clearErrors]);
|
|
5110
|
-
|
|
5098
|
+
React9.useEffect(
|
|
5111
5099
|
() => () => {
|
|
5112
5100
|
dismissRef.current?.();
|
|
5113
5101
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
@@ -5128,13 +5116,13 @@ function SpellCheckPlugin({
|
|
|
5128
5116
|
}
|
|
5129
5117
|
function TableActionMenuPlugin({ disabled = false }) {
|
|
5130
5118
|
const [editor] = useLexicalComposerContext();
|
|
5131
|
-
const [isInTable, setIsInTable] =
|
|
5132
|
-
const [anchorRect, setAnchorRect] =
|
|
5133
|
-
const [contentRight, setContentRight] =
|
|
5134
|
-
const [open, setOpen] =
|
|
5135
|
-
const openRef =
|
|
5136
|
-
const savedAnchorRef =
|
|
5137
|
-
const measureContentRight =
|
|
5119
|
+
const [isInTable, setIsInTable] = React9.useState(false);
|
|
5120
|
+
const [anchorRect, setAnchorRect] = React9.useState(null);
|
|
5121
|
+
const [contentRight, setContentRight] = React9.useState(null);
|
|
5122
|
+
const [open, setOpen] = React9.useState(false);
|
|
5123
|
+
const openRef = React9.useRef(false);
|
|
5124
|
+
const savedAnchorRef = React9.useRef(null);
|
|
5125
|
+
const measureContentRight = React9.useCallback((cellDom) => {
|
|
5138
5126
|
try {
|
|
5139
5127
|
const range = document.createRange();
|
|
5140
5128
|
range.selectNodeContents(cellDom);
|
|
@@ -5144,7 +5132,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5144
5132
|
return null;
|
|
5145
5133
|
}
|
|
5146
5134
|
}, []);
|
|
5147
|
-
const updateFromSelection =
|
|
5135
|
+
const updateFromSelection = React9.useCallback(() => {
|
|
5148
5136
|
if (openRef.current) return;
|
|
5149
5137
|
const root = editor.getRootElement();
|
|
5150
5138
|
if (!root) return;
|
|
@@ -5195,7 +5183,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5195
5183
|
}
|
|
5196
5184
|
});
|
|
5197
5185
|
}, [editor, measureContentRight]);
|
|
5198
|
-
|
|
5186
|
+
React9.useEffect(() => {
|
|
5199
5187
|
return mergeRegister(
|
|
5200
5188
|
editor.registerCommand(
|
|
5201
5189
|
SELECTION_CHANGE_COMMAND,
|
|
@@ -5210,7 +5198,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5210
5198
|
})
|
|
5211
5199
|
);
|
|
5212
5200
|
}, [editor, updateFromSelection]);
|
|
5213
|
-
|
|
5201
|
+
React9.useEffect(() => {
|
|
5214
5202
|
return editor.registerCommand(
|
|
5215
5203
|
KEY_DOWN_COMMAND,
|
|
5216
5204
|
(event) => {
|
|
@@ -5252,7 +5240,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5252
5240
|
);
|
|
5253
5241
|
}, [editor, disabled]);
|
|
5254
5242
|
const canShow = isInTable && !!anchorRect && !disabled;
|
|
5255
|
-
const handleStyle =
|
|
5243
|
+
const handleStyle = React9.useMemo(() => {
|
|
5256
5244
|
if (!anchorRect) return void 0;
|
|
5257
5245
|
const top = Math.max(8, anchorRect.top + 6);
|
|
5258
5246
|
const clampedCellRight = Math.min(anchorRect.right, window.innerWidth - 8);
|
|
@@ -5267,7 +5255,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5267
5255
|
const dangerStyle = {
|
|
5268
5256
|
color: "var(--colorPaletteRedForeground1)"
|
|
5269
5257
|
};
|
|
5270
|
-
const run =
|
|
5258
|
+
const run = React9.useCallback(
|
|
5271
5259
|
(fn) => {
|
|
5272
5260
|
if (disabled) return;
|
|
5273
5261
|
openRef.current = false;
|
|
@@ -5828,22 +5816,22 @@ var hsvToRgb = (h, s, v) => {
|
|
|
5828
5816
|
};
|
|
5829
5817
|
};
|
|
5830
5818
|
var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange }) => {
|
|
5831
|
-
const [open, setOpen] =
|
|
5832
|
-
const btnRef =
|
|
5833
|
-
const setOpenAndNotify =
|
|
5819
|
+
const [open, setOpen] = React9.useState(false);
|
|
5820
|
+
const btnRef = React9.useRef(null);
|
|
5821
|
+
const setOpenAndNotify = React9.useCallback(
|
|
5834
5822
|
(next) => {
|
|
5835
5823
|
setOpen(next);
|
|
5836
5824
|
onOpenChange?.(next);
|
|
5837
5825
|
},
|
|
5838
5826
|
[onOpenChange]
|
|
5839
5827
|
);
|
|
5840
|
-
const handleDismiss =
|
|
5841
|
-
const preventDismissOnEvent =
|
|
5828
|
+
const handleDismiss = React9.useCallback(() => setOpenAndNotify(false), [setOpenAndNotify]);
|
|
5829
|
+
const preventDismissOnEvent = React9.useCallback(
|
|
5842
5830
|
(ev) => ev.type !== "click",
|
|
5843
5831
|
[]
|
|
5844
5832
|
);
|
|
5845
|
-
const [, forceReposition] =
|
|
5846
|
-
|
|
5833
|
+
const [, forceReposition] = React9.useState(0);
|
|
5834
|
+
React9.useEffect(() => {
|
|
5847
5835
|
if (!open) return;
|
|
5848
5836
|
let rafId = null;
|
|
5849
5837
|
const reposition = () => {
|
|
@@ -5861,15 +5849,15 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5861
5849
|
window.removeEventListener("resize", reposition);
|
|
5862
5850
|
};
|
|
5863
5851
|
}, [open]);
|
|
5864
|
-
const appliedHex =
|
|
5865
|
-
const [hex, setHexState] =
|
|
5866
|
-
const [hexText, setHexText] =
|
|
5867
|
-
const { r, g, b } =
|
|
5868
|
-
const hsv =
|
|
5869
|
-
const [h, setH] =
|
|
5870
|
-
const [s, setS] =
|
|
5871
|
-
const [v, setV] =
|
|
5872
|
-
const commit =
|
|
5852
|
+
const appliedHex = React9.useMemo(() => normalizeHex(value || "#000000"), [value]);
|
|
5853
|
+
const [hex, setHexState] = React9.useState(appliedHex);
|
|
5854
|
+
const [hexText, setHexText] = React9.useState(appliedHex);
|
|
5855
|
+
const { r, g, b } = React9.useMemo(() => hexToRgb(hex), [hex]);
|
|
5856
|
+
const hsv = React9.useMemo(() => rgbToHsv(r, g, b), [r, g, b]);
|
|
5857
|
+
const [h, setH] = React9.useState(hsv.h);
|
|
5858
|
+
const [s, setS] = React9.useState(hsv.s);
|
|
5859
|
+
const [v, setV] = React9.useState(hsv.v);
|
|
5860
|
+
const commit = React9.useCallback(
|
|
5873
5861
|
(nextHex) => {
|
|
5874
5862
|
const rgb = hexToRgb(nextHex);
|
|
5875
5863
|
const next = rgbToHsv(rgb.r, rgb.g, rgb.b);
|
|
@@ -5882,7 +5870,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5882
5870
|
},
|
|
5883
5871
|
[onChange]
|
|
5884
5872
|
);
|
|
5885
|
-
const commitFromHsv =
|
|
5873
|
+
const commitFromHsv = React9.useCallback(
|
|
5886
5874
|
(hh, ss, vv) => {
|
|
5887
5875
|
const rgb = hsvToRgb(hh, ss, vv);
|
|
5888
5876
|
const nextHex = rgbToHex(rgb.r, rgb.g, rgb.b);
|
|
@@ -5895,8 +5883,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5895
5883
|
},
|
|
5896
5884
|
[onChange]
|
|
5897
5885
|
);
|
|
5898
|
-
const wasOpenRef =
|
|
5899
|
-
|
|
5886
|
+
const wasOpenRef = React9.useRef(open);
|
|
5887
|
+
React9.useEffect(() => {
|
|
5900
5888
|
const justOpened = open && !wasOpenRef.current;
|
|
5901
5889
|
wasOpenRef.current = open;
|
|
5902
5890
|
if (!justOpened) return;
|
|
@@ -5908,8 +5896,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5908
5896
|
setS(next.s);
|
|
5909
5897
|
setV(next.v);
|
|
5910
5898
|
}, [appliedHex, open]);
|
|
5911
|
-
const svRef =
|
|
5912
|
-
const svPointFromEvent =
|
|
5899
|
+
const svRef = React9.useRef(null);
|
|
5900
|
+
const svPointFromEvent = React9.useCallback((clientX, clientY) => {
|
|
5913
5901
|
if (!svRef.current) return null;
|
|
5914
5902
|
const rect = svRef.current.getBoundingClientRect();
|
|
5915
5903
|
const x = clamp3(clientX - rect.left, 0, rect.width);
|
|
@@ -5918,9 +5906,9 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5918
5906
|
const vv = rect.height === 0 ? 0 : 1 - y / rect.height;
|
|
5919
5907
|
return { ss, vv };
|
|
5920
5908
|
}, []);
|
|
5921
|
-
const hRef =
|
|
5909
|
+
const hRef = React9.useRef(h);
|
|
5922
5910
|
hRef.current = h;
|
|
5923
|
-
const handleSVPointerDown =
|
|
5911
|
+
const handleSVPointerDown = React9.useCallback(
|
|
5924
5912
|
(e) => {
|
|
5925
5913
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
5926
5914
|
const pt = svPointFromEvent(e.clientX, e.clientY);
|
|
@@ -5928,7 +5916,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5928
5916
|
},
|
|
5929
5917
|
[svPointFromEvent, commitFromHsv]
|
|
5930
5918
|
);
|
|
5931
|
-
const handleSVPointerMove =
|
|
5919
|
+
const handleSVPointerMove = React9.useCallback(
|
|
5932
5920
|
(e) => {
|
|
5933
5921
|
if (e.buttons !== 1) return;
|
|
5934
5922
|
const pt = svPointFromEvent(e.clientX, e.clientY);
|
|
@@ -5936,18 +5924,18 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5936
5924
|
},
|
|
5937
5925
|
[svPointFromEvent, commitFromHsv]
|
|
5938
5926
|
);
|
|
5939
|
-
const hueRef =
|
|
5940
|
-
const sRef =
|
|
5927
|
+
const hueRef = React9.useRef(null);
|
|
5928
|
+
const sRef = React9.useRef(s);
|
|
5941
5929
|
sRef.current = s;
|
|
5942
|
-
const vRef =
|
|
5930
|
+
const vRef = React9.useRef(v);
|
|
5943
5931
|
vRef.current = v;
|
|
5944
|
-
const huePointFromEvent =
|
|
5932
|
+
const huePointFromEvent = React9.useCallback((clientX) => {
|
|
5945
5933
|
if (!hueRef.current) return null;
|
|
5946
5934
|
const rect = hueRef.current.getBoundingClientRect();
|
|
5947
5935
|
const x = clamp3(clientX - rect.left, 0, rect.width);
|
|
5948
5936
|
return rect.width === 0 ? 0 : x / rect.width * 360;
|
|
5949
5937
|
}, []);
|
|
5950
|
-
const handleHuePointerDown =
|
|
5938
|
+
const handleHuePointerDown = React9.useCallback(
|
|
5951
5939
|
(e) => {
|
|
5952
5940
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
5953
5941
|
const hh = huePointFromEvent(e.clientX);
|
|
@@ -5955,7 +5943,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5955
5943
|
},
|
|
5956
5944
|
[huePointFromEvent, commitFromHsv]
|
|
5957
5945
|
);
|
|
5958
|
-
const handleHuePointerMove =
|
|
5946
|
+
const handleHuePointerMove = React9.useCallback(
|
|
5959
5947
|
(e) => {
|
|
5960
5948
|
if (e.buttons !== 1) return;
|
|
5961
5949
|
const hh = huePointFromEvent(e.clientX);
|
|
@@ -5963,7 +5951,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5963
5951
|
},
|
|
5964
5952
|
[huePointFromEvent, commitFromHsv]
|
|
5965
5953
|
);
|
|
5966
|
-
const handleHexChange =
|
|
5954
|
+
const handleHexChange = React9.useCallback(
|
|
5967
5955
|
(_, val) => {
|
|
5968
5956
|
const next = val ?? "";
|
|
5969
5957
|
setHexText(next);
|
|
@@ -5971,12 +5959,12 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5971
5959
|
},
|
|
5972
5960
|
[commit]
|
|
5973
5961
|
);
|
|
5974
|
-
const handleHexBlur =
|
|
5962
|
+
const handleHexBlur = React9.useCallback(() => {
|
|
5975
5963
|
commit(normalizeHex(hexText));
|
|
5976
5964
|
}, [hexText, commit]);
|
|
5977
|
-
const svThumb =
|
|
5978
|
-
const hueThumb =
|
|
5979
|
-
const hueColor =
|
|
5965
|
+
const svThumb = React9.useMemo(() => ({ left: `${s * 100}%`, top: `${(1 - v) * 100}%` }), [s, v]);
|
|
5966
|
+
const hueThumb = React9.useMemo(() => ({ left: `${h / 360 * 100}%` }), [h]);
|
|
5967
|
+
const hueColor = React9.useMemo(() => {
|
|
5980
5968
|
const { r: r2, g: g2, b: b2 } = hsvToRgb(h, 1, 1);
|
|
5981
5969
|
return rgbToHex(r2, g2, b2);
|
|
5982
5970
|
}, [h]);
|
|
@@ -6222,8 +6210,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
6222
6210
|
};
|
|
6223
6211
|
var ColorPickerPlugin = ({ disabled }) => {
|
|
6224
6212
|
const [editor] = useLexicalComposerContext();
|
|
6225
|
-
const [{ color, bgColor }, setColors] =
|
|
6226
|
-
const lastRangeSelectionRef =
|
|
6213
|
+
const [{ color, bgColor }, setColors] = React9__default.useState({ color: "#000000", bgColor: "#ffffff" });
|
|
6214
|
+
const lastRangeSelectionRef = React9__default.useRef(null);
|
|
6227
6215
|
const updateToolbar = () => {
|
|
6228
6216
|
const selection = $getSelection();
|
|
6229
6217
|
if ($isRangeSelection(selection)) {
|
|
@@ -6233,7 +6221,7 @@ var ColorPickerPlugin = ({ disabled }) => {
|
|
|
6233
6221
|
setColors({ color: c, bgColor: bg });
|
|
6234
6222
|
}
|
|
6235
6223
|
};
|
|
6236
|
-
|
|
6224
|
+
React9__default.useEffect(() => {
|
|
6237
6225
|
return mergeRegister(
|
|
6238
6226
|
editor.registerUpdateListener(({ editorState }) => {
|
|
6239
6227
|
editorState.read(() => updateToolbar());
|
|
@@ -6248,7 +6236,7 @@ var ColorPickerPlugin = ({ disabled }) => {
|
|
|
6248
6236
|
)
|
|
6249
6237
|
);
|
|
6250
6238
|
}, [editor]);
|
|
6251
|
-
const wasEditorActiveRef =
|
|
6239
|
+
const wasEditorActiveRef = React9__default.useRef(false);
|
|
6252
6240
|
const handleOpenChange = (open) => {
|
|
6253
6241
|
if (open) {
|
|
6254
6242
|
const root = editor.getRootElement();
|
|
@@ -6466,9 +6454,9 @@ var useStyles3 = makeStyles({
|
|
|
6466
6454
|
var FontSizePlugin = ({ disabled }) => {
|
|
6467
6455
|
const [editor] = useLexicalComposerContext();
|
|
6468
6456
|
const styles = useStyles3();
|
|
6469
|
-
const [fontSize2, setFontSize] =
|
|
6457
|
+
const [fontSize2, setFontSize] = React9.useState(String(DEFAULT_FONT_SIZE));
|
|
6470
6458
|
const fg = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
6471
|
-
|
|
6459
|
+
React9.useEffect(() => {
|
|
6472
6460
|
const readFontSize = () => {
|
|
6473
6461
|
const selection = $getSelection();
|
|
6474
6462
|
if ($isRangeSelection(selection)) {
|
|
@@ -6875,7 +6863,7 @@ var ToolBarPlugins = (props) => {
|
|
|
6875
6863
|
const [alignment, setAlignment] = useState("left");
|
|
6876
6864
|
const [hasTextSelection, setHasTextSelection] = useState(false);
|
|
6877
6865
|
const [decoratorOpen, setDecoratorOpen] = useState(false);
|
|
6878
|
-
const decoratorSelectingRef =
|
|
6866
|
+
const decoratorSelectingRef = React9__default.useRef(false);
|
|
6879
6867
|
const presetGroups = props.customToolbar ?? getToolbarGroupsByLevel(props.level);
|
|
6880
6868
|
const pluginGroups = useMemo(() => sanitizePluginGroups(presetGroups), [presetGroups]);
|
|
6881
6869
|
const updateToolbarPlugins = () => {
|
|
@@ -6947,7 +6935,7 @@ var ToolBarPlugins = (props) => {
|
|
|
6947
6935
|
}
|
|
6948
6936
|
});
|
|
6949
6937
|
};
|
|
6950
|
-
|
|
6938
|
+
React9__default.useEffect(() => {
|
|
6951
6939
|
return mergeRegister(
|
|
6952
6940
|
editor.registerEditableListener((editable) => {
|
|
6953
6941
|
setIsEditable(editable);
|
|
@@ -7821,7 +7809,7 @@ var ToolBarPlugins = (props) => {
|
|
|
7821
7809
|
padding: "0px",
|
|
7822
7810
|
minHeight: 36
|
|
7823
7811
|
},
|
|
7824
|
-
children: pluginGroups.map((group, groupIndex) => /* @__PURE__ */ jsx(
|
|
7812
|
+
children: pluginGroups.map((group, groupIndex) => /* @__PURE__ */ jsx(React9__default.Fragment, { children: group.map((token, tokenIndex) => {
|
|
7825
7813
|
try {
|
|
7826
7814
|
return renderToken(token, groupIndex, tokenIndex);
|
|
7827
7815
|
} catch {
|
|
@@ -8148,12 +8136,12 @@ function EditorReadyPlugin({ onReady }) {
|
|
|
8148
8136
|
var ContentEditorComponent = forwardRef(
|
|
8149
8137
|
(props, ref) => {
|
|
8150
8138
|
const isReadOnly = !!props.readOnly;
|
|
8151
|
-
const resolvedSpellCheck =
|
|
8139
|
+
const resolvedSpellCheck = React9__default.useMemo(
|
|
8152
8140
|
() => props.spellCheckFn ? _makeSpellCheckFn(props.spellCheckFn) : props.useSpellCheck,
|
|
8153
8141
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8154
8142
|
[props.spellCheckFn, props.useSpellCheck]
|
|
8155
8143
|
);
|
|
8156
|
-
const resolvedQuery =
|
|
8144
|
+
const resolvedQuery = React9__default.useMemo(
|
|
8157
8145
|
() => props.suggestFn ? _makeQueryFn(props.suggestFn) : props.useQuery,
|
|
8158
8146
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8159
8147
|
[props.suggestFn, props.useQuery]
|
|
@@ -8181,7 +8169,7 @@ var ContentEditorComponent = forwardRef(
|
|
|
8181
8169
|
const onAnchorRef = (elem) => {
|
|
8182
8170
|
if (elem) setFloatingAnchorElem(elem);
|
|
8183
8171
|
};
|
|
8184
|
-
const initialConfig =
|
|
8172
|
+
const initialConfig = React9__default.useMemo(() => {
|
|
8185
8173
|
const config = {
|
|
8186
8174
|
namespace: props.namespace ?? "",
|
|
8187
8175
|
theme,
|
|
@@ -8271,7 +8259,7 @@ var ContentEditorComponent = forwardRef(
|
|
|
8271
8259
|
previousOverLimitRef.current = isOverLimit;
|
|
8272
8260
|
}
|
|
8273
8261
|
}, [isOverLimit, wordCount, props.wordLimit, props.onWordLimitExceeded]);
|
|
8274
|
-
const validationErrors =
|
|
8262
|
+
const validationErrors = React9__default.useMemo(() => {
|
|
8275
8263
|
const errors = [];
|
|
8276
8264
|
const custom = props.validationMessages ?? {};
|
|
8277
8265
|
const { words, chars, images, links, tables } = metrics;
|