@tarviks/lexical-rich-editor 1.3.2 → 1.3.3

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