@tarviks/lexical-rich-editor 1.3.1 → 1.3.2

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.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import { mergeRegister, $wrapNodeInElement, $insertNodeToNearestRoot, $getNearestNodeOfType, $findMatchingParent as $findMatchingParent$1, calculateZoomLevel } from '@lexical/utils';
2
- import * as React9 from 'react';
3
- import React9__default, { forwardRef, useState, useCallback, useRef, useEffect, useMemo, useImperativeHandle, Suspense } from 'react';
2
+ import * as React10 from 'react';
3
+ import React10__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';
7
7
  import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
8
8
  import { createCommand, DecoratorNode, COMMAND_PRIORITY_HIGH, TextNode, ElementNode, SELECTION_CHANGE_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, $getSelection, $isRangeSelection, $findMatchingParent, COMMAND_PRIORITY_LOW, KEY_DOWN_COMMAND, $getNodeByKey, $createRangeSelection, $setSelection, $createParagraphNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR, PASTE_COMMAND, DRAGSTART_COMMAND, DRAGOVER_COMMAND, DROP_COMMAND, $getRoot, $createTextNode, $isTextNode, $isElementNode, FORMAT_ELEMENT_COMMAND, CLICK_COMMAND, $isNodeSelection, $applyNodeReplacement, FORMAT_TEXT_COMMAND, $isDecoratorNode, $getNearestNodeFromDOMNode, COMMAND_PRIORITY_CRITICAL, REDO_COMMAND, UNDO_COMMAND, getDOMSelection, KEY_ESCAPE_COMMAND, isHTMLElement, getDOMSelectionFromTarget, $isLineBreakNode, SKIP_SELECTION_FOCUS_TAG, createEditor, KEY_ENTER_COMMAND } from 'lexical';
9
9
  import { mergeStyleSets, Stack, css, useTheme, Callout, TextField } from '@fluentui/react';
10
- import { makeStyles, FluentProvider, webLightTheme, Menu, MenuTrigger, MenuPopover, MenuList, MenuGroup, MenuGroupHeader, MenuItem, MenuDivider, Dropdown, Option, Button, ToolbarDivider, MenuItemRadio, Dialog, DialogTrigger, DialogSurface, DialogBody, DialogTitle, DialogContent, Field, Input, DialogActions, MessageBar, MessageBarBody } from '@fluentui/react-components';
10
+ import { makeStyles, FluentProvider, webLightTheme, Menu, MenuTrigger, MenuPopover, MenuList, MenuGroup, MenuGroupHeader, MenuItem, MenuDivider, Dropdown, Option, Button, ToolbarDivider, MenuItemRadio, Field, Input, MessageBar, MessageBarBody } from '@fluentui/react-components';
11
11
  import { CodeHighlightNode, CodeNode, $isCodeHighlightNode } from '@lexical/code';
12
12
  import { LinkNode, AutoLinkNode, $isLinkNode, $isAutoLinkNode, TOGGLE_LINK_COMMAND, $createLinkNode } from '@lexical/link';
13
13
  import { ListNode, ListItemNode, $isListNode, REMOVE_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, $removeList, $insertList, $isListItemNode } from '@lexical/list';
@@ -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 = React9.lazy(() => Promise.resolve().then(() => (init_ImageComponent(), ImageComponent_exports)));
645
+ ImageComponent2 = React10.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 = React9.lazy(() => Promise.resolve().then(() => (init_InlineImageComponent(), InlineImageComponent_exports)));
1064
+ InlineImageComponent2 = React10.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 = React9.useRef(null);
1705
+ const resizeState = React10.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 = React9.useRef(null);
1833
- const containerRef = React9.useRef(null);
1834
- const iframeRef = React9.useRef(null);
1835
- const isResizingRef = React9.useRef(false);
1832
+ const wrapperRef = React10.useRef(null);
1833
+ const containerRef = React10.useRef(null);
1834
+ const iframeRef = React10.useRef(null);
1835
+ const isResizingRef = React10.useRef(false);
1836
1836
  const [isNodeSelected, setNodeSelected, clearNodeSelection] = useLexicalNodeSelection(nodeKey);
1837
- const [isHovered, setIsHovered] = React9.useState(false);
1838
- const [isResizing, setIsResizing] = React9.useState(false);
1839
- const [isPlaying, setIsPlaying] = React9.useState(false);
1840
- React9.useEffect(() => {
1837
+ const [isHovered, setIsHovered] = React10.useState(false);
1838
+ const [isResizing, setIsResizing] = React10.useState(false);
1839
+ const [isPlaying, setIsPlaying] = React10.useState(false);
1840
+ React10.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 = 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(() => {
2229
+ const ghostKeyRef = React10.useRef(null);
2230
+ const idleTimerRef = React10.useRef(null);
2231
+ const inflightRef = React10.useRef(null);
2232
+ const reqCounterRef = React10.useRef(0);
2233
+ const lastTriggerRef = React10.useRef("");
2234
+ const lastShownCtxRef = React10.useRef("");
2235
+ const clearGhost = React10.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 = React9.useCallback(
2247
+ const upsertGhost = React10.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 = React9.useCallback(() => {
2311
+ const cancelInflight = React10.useCallback(() => {
2312
2312
  if (!inflightRef.current) return;
2313
2313
  inflightRef.current.dismiss();
2314
2314
  inflightRef.current = null;
2315
2315
  }, []);
2316
- const resetIdleTimer = React9.useCallback(
2316
+ const resetIdleTimer = React10.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 = React9.useCallback(() => {
2331
+ const fireQuery = React10.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
- React9.useEffect(() => {
2403
+ React10.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
- React9.useEffect(() => {
2412
+ React10.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
- React9.useEffect(() => {
2436
+ React10.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
- React9.useEffect(() => {
2477
+ React10.useEffect(() => {
2478
2478
  return () => {
2479
2479
  cancelInflight();
2480
2480
  if (idleTimerRef.current) clearTimeout(idleTimerRef.current);
@@ -3130,28 +3130,44 @@ var getSelectedNode2 = (selection) => {
3130
3130
  };
3131
3131
  var VERTICAL_GAP = 10;
3132
3132
  var HORIZONTAL_OFFSET = 5;
3133
- var setFloatingElemPositionForLinkEditor = (targetRect, floatingElem, anchorElem, verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET) => {
3134
- const scrollerElem = anchorElem.parentElement;
3135
- if (targetRect === null || !scrollerElem) {
3133
+ 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
+ var setFloatingElemPositionForLinkEditor = (targetRect, floatingElem, topBoundary = VIEWPORT_MARGIN, verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET) => {
3152
+ if (targetRect === null) {
3136
3153
  floatingElem.style.opacity = "0";
3137
3154
  floatingElem.style.transform = "translate(-10000px, -10000px)";
3138
3155
  return;
3139
3156
  }
3140
3157
  const floatingElemRect = floatingElem.getBoundingClientRect();
3141
- const anchorElementRect = anchorElem.getBoundingClientRect();
3142
- const editorScrollerRect = scrollerElem.getBoundingClientRect();
3143
- let top = targetRect.top - verticalGap;
3158
+ let top = targetRect.bottom + verticalGap;
3144
3159
  let left = targetRect.left - horizontalOffset;
3145
- if (top < editorScrollerRect.top) {
3146
- top += floatingElemRect.height + targetRect.height + verticalGap * 2;
3160
+ if (top + floatingElemRect.height > window.innerHeight - VIEWPORT_MARGIN) {
3161
+ top = targetRect.top - floatingElemRect.height - verticalGap;
3147
3162
  }
3148
- if (left + floatingElemRect.width > editorScrollerRect.right) {
3149
- left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset;
3163
+ if (top < topBoundary) {
3164
+ top = topBoundary;
3150
3165
  }
3151
- top -= anchorElementRect.top;
3152
- left -= anchorElementRect.left;
3166
+ left = Math.max(VIEWPORT_MARGIN, Math.min(left, window.innerWidth - floatingElemRect.width - VIEWPORT_MARGIN));
3153
3167
  floatingElem.style.opacity = "1";
3154
- floatingElem.style.transform = `translate(${left}px, ${top}px)`;
3168
+ floatingElem.style.transform = "none";
3169
+ floatingElem.style.top = `${top}px`;
3170
+ floatingElem.style.left = `${left}px`;
3155
3171
  };
3156
3172
  var SUPPORTED_URL_PROTOCOLS = /* @__PURE__ */ new Set([
3157
3173
  "http:",
@@ -3174,7 +3190,7 @@ var sanitizeUrl = (url) => {
3174
3190
  var preventDefault = (event) => {
3175
3191
  event.preventDefault();
3176
3192
  };
3177
- var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMode, setIsLinkEditMode }) => {
3193
+ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLinkEditMode }) => {
3178
3194
  const [editedLinkUrl, setEditedLinkUrl] = useState("https://");
3179
3195
  const [lastSelection, setLastSelection] = useState(null);
3180
3196
  const [linkUrl, setLinkUrl] = useState("");
@@ -3206,38 +3222,37 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMod
3206
3222
  if (isLink && selection !== null && nativeSelection !== null && rootElement !== null && rootElement.contains(nativeSelection.anchorNode) && editor.isEditable()) {
3207
3223
  const domRect = nativeSelection.focusNode?.parentElement?.getBoundingClientRect();
3208
3224
  if (domRect) {
3209
- domRect.y += 40;
3210
- setFloatingElemPositionForLinkEditor(domRect, editorElem, anchorElem);
3225
+ const toolbarEl = rootElement.closest(".lexical-rich-editor-root")?.querySelector(".editor-toolbar-root");
3226
+ const topBoundary = toolbarEl ? toolbarEl.getBoundingClientRect().bottom + 8 : 8;
3227
+ setFloatingElemPositionForLinkEditor(domRect, editorElem, topBoundary);
3211
3228
  }
3212
3229
  setLastSelection(selection);
3213
3230
  } else if (!activeElement || activeElement.className !== "aoLinkInput") {
3214
3231
  if (rootElement !== null) {
3215
- setFloatingElemPositionForLinkEditor(null, editorElem, anchorElem);
3232
+ setFloatingElemPositionForLinkEditor(null, editorElem);
3216
3233
  }
3217
3234
  setLastSelection(null);
3218
3235
  setIsLinkEditMode(false);
3219
3236
  setLinkUrl("");
3220
3237
  }
3221
3238
  return true;
3222
- }, [anchorElem, editor, setIsLinkEditMode, isLinkEditMode, isLink, linkUrl]);
3239
+ }, [editor, setIsLinkEditMode, isLinkEditMode, isLink, linkUrl]);
3223
3240
  useEffect(() => {
3224
- const scrollerElem = anchorElem.parentElement;
3225
3241
  const update = () => {
3226
3242
  editor.getEditorState().read(() => {
3227
3243
  $updateLinkEditor();
3228
3244
  });
3229
3245
  };
3246
+ const root = editor.getRootElement();
3230
3247
  window.addEventListener("resize", update);
3231
- if (scrollerElem) {
3232
- scrollerElem.addEventListener("scroll", update);
3233
- }
3248
+ window.addEventListener("scroll", update, true);
3249
+ root?.addEventListener("scroll", update, { passive: true });
3234
3250
  return () => {
3235
3251
  window.removeEventListener("resize", update);
3236
- if (scrollerElem) {
3237
- scrollerElem.removeEventListener("scroll", update);
3238
- }
3252
+ window.removeEventListener("scroll", update, true);
3253
+ root?.removeEventListener("scroll", update);
3239
3254
  };
3240
- }, [anchorElem.parentElement, editor, $updateLinkEditor]);
3255
+ }, [editor, $updateLinkEditor]);
3241
3256
  useEffect(() => {
3242
3257
  return mergeRegister(
3243
3258
  editor.registerUpdateListener(({ editorState }) => {
@@ -3403,6 +3418,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMod
3403
3418
  var useFloatingLinkEditorToolbar = (editor, anchorElem, isLinkEditMode, setIsLinkEditMode) => {
3404
3419
  const [activeEditor, setActiveEditor] = useState(editor);
3405
3420
  const [isLink, setIsLink] = useState(false);
3421
+ const portalContainer = useFloatingPortalContainer2(editor);
3406
3422
  useEffect(() => {
3407
3423
  function $updateToolbar() {
3408
3424
  const selection = $getSelection();
@@ -3450,7 +3466,7 @@ var useFloatingLinkEditorToolbar = (editor, anchorElem, isLinkEditMode, setIsLin
3450
3466
  )
3451
3467
  );
3452
3468
  }, [editor]);
3453
- if (!anchorElem || !(anchorElem instanceof HTMLElement)) {
3469
+ if (!anchorElem || !(anchorElem instanceof HTMLElement) || !portalContainer) {
3454
3470
  return null;
3455
3471
  }
3456
3472
  return createPortal(
@@ -3460,12 +3476,11 @@ var useFloatingLinkEditorToolbar = (editor, anchorElem, isLinkEditMode, setIsLin
3460
3476
  isLink,
3461
3477
  editor: activeEditor,
3462
3478
  setIsLink,
3463
- anchorElem,
3464
3479
  isLinkEditMode,
3465
3480
  setIsLinkEditMode
3466
3481
  }
3467
3482
  ),
3468
- anchorElem
3483
+ portalContainer
3469
3484
  );
3470
3485
  };
3471
3486
  var FloatingLinkEditorPlugin = ({ anchorElem, isLinkEditMode, setIsLinkEditMode }) => {
@@ -3478,6 +3493,61 @@ var FloatingLinkEditorPlugin = ({ anchorElem, isLinkEditMode, setIsLinkEditMode
3478
3493
  setIsLinkEditMode
3479
3494
  );
3480
3495
  };
3496
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React10.useLayoutEffect : React10.useEffect;
3497
+ var AoModal = ({
3498
+ isOpen,
3499
+ onDismiss,
3500
+ title,
3501
+ maxWidth = 280,
3502
+ // Default to a smaller, compact size
3503
+ actions,
3504
+ children
3505
+ }) => {
3506
+ const [hostElement, setHostElement] = React10.useState(null);
3507
+ const mountRef = React10.useRef(null);
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]);
3518
+ if (!isOpen) return null;
3519
+ const modalContent = /* @__PURE__ */ jsx("div", { className: "aoModalBackdrop", onClick: onDismiss, children: /* @__PURE__ */ jsxs(
3520
+ FluentProvider,
3521
+ {
3522
+ theme: webLightTheme,
3523
+ className: "aoModalWrapper aoModalContainer",
3524
+ style: { maxWidth, width: "90vw" },
3525
+ onClick: (e) => e.stopPropagation(),
3526
+ children: [
3527
+ /* @__PURE__ */ jsxs("div", { className: "aoModalHeader", children: [
3528
+ /* @__PURE__ */ jsx("h2", { className: "aoModalTitle", children: title }),
3529
+ /* @__PURE__ */ jsx(
3530
+ "button",
3531
+ {
3532
+ className: "aoModalCloseButton",
3533
+ "aria-label": "Close popup",
3534
+ onClick: onDismiss,
3535
+ children: "\u2715"
3536
+ }
3537
+ )
3538
+ ] }),
3539
+ /* @__PURE__ */ jsx("div", { className: "aoModalBody", children }),
3540
+ actions && /* @__PURE__ */ jsx("div", { className: "aoModalActions", children: actions })
3541
+ ]
3542
+ }
3543
+ ) });
3544
+ if (hostElement) {
3545
+ return createPortal(modalContent, hostElement);
3546
+ }
3547
+ return /* @__PURE__ */ jsx("div", { ref: mountRef, style: { display: "none" } });
3548
+ };
3549
+
3550
+ // src/Plugins/ImagePlugin.tsx
3481
3551
  init_ImageNode();
3482
3552
  var INSERT_IMAGE_COMMAND = createCommand("INSERT_IMAGE_COMMAND");
3483
3553
  var readClipboardImageAsDataURL = async (event) => {
@@ -3611,108 +3681,105 @@ var InsertImageDialog = ({
3611
3681
  };
3612
3682
  reader.readAsDataURL(file);
3613
3683
  };
3614
- return /* @__PURE__ */ jsxs(
3615
- Dialog,
3616
- {
3617
- open: disabled ? false : isOpen,
3618
- onOpenChange: (_, data) => {
3619
- if (!disabled) setIsOpen(data.open);
3684
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3685
+ /* @__PURE__ */ jsx(
3686
+ Button,
3687
+ {
3688
+ size: "small",
3689
+ title: "Add Image",
3690
+ disabled,
3691
+ icon: /* @__PURE__ */ jsx(ImageAddRegular, { style: { color: iconColor } }),
3692
+ style: {
3693
+ background: isOpen && !disabled ? "#ebebeb" : "none",
3694
+ border: "none",
3695
+ margin: 2,
3696
+ opacity: disabled ? 0.55 : 1,
3697
+ cursor: disabled ? "not-allowed" : "pointer"
3698
+ },
3699
+ onClick: () => {
3700
+ if (disabled) return;
3701
+ setIsOpen((prev) => !prev);
3702
+ setSrc("");
3703
+ setAltText("");
3704
+ setFileName("");
3705
+ }
3620
3706
  },
3621
- children: [
3622
- /* @__PURE__ */ jsx(DialogTrigger, { disableButtonEnhancement: true, children: /* @__PURE__ */ jsx(
3623
- Button,
3624
- {
3625
- size: "small",
3626
- title: "Add Image",
3627
- disabled,
3628
- icon: /* @__PURE__ */ jsx(ImageAddRegular, { style: { color: iconColor } }),
3629
- style: {
3630
- background: isOpen && !disabled ? "#ebebeb" : "none",
3631
- border: "none",
3632
- margin: 2,
3633
- opacity: disabled ? 0.55 : 1,
3634
- cursor: disabled ? "not-allowed" : "pointer"
3635
- },
3636
- onClick: () => {
3637
- if (disabled) return;
3638
- setIsOpen((prev) => !prev);
3639
- setSrc("");
3640
- setAltText("");
3641
- setFileName("");
3642
- }
3643
- },
3644
- "upload-image"
3645
- ) }),
3646
- /* @__PURE__ */ jsx(DialogSurface, { style: { maxWidth: 340 }, children: /* @__PURE__ */ jsxs(DialogBody, { children: [
3647
- /* @__PURE__ */ jsx(DialogTitle, { children: "Insert image" }),
3648
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsxs(Stack, { tokens: { childrenGap: 8 }, children: [
3649
- /* @__PURE__ */ jsx(Field, { label: "Upload", size: "small", children: /* @__PURE__ */ jsxs(
3650
- "label",
3651
- {
3652
- style: {
3653
- cursor: disabled ? "not-allowed" : "pointer",
3654
- display: "flex",
3655
- alignItems: "center",
3656
- gap: 8,
3657
- opacity: disabled ? 0.75 : 1
3658
- },
3659
- children: [
3707
+ "upload-image"
3708
+ ),
3709
+ /* @__PURE__ */ jsx(
3710
+ AoModal,
3711
+ {
3712
+ isOpen: disabled ? false : isOpen,
3713
+ onDismiss: () => !disabled && setIsOpen(false),
3714
+ title: "Insert image",
3715
+ maxWidth: 340,
3716
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
3717
+ /* @__PURE__ */ jsx(Button, { size: "small", disabled: isDisabled, onClick: () => onClick({ altText, src }), children: "Add" }),
3718
+ /* @__PURE__ */ jsx(Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
3719
+ ] }),
3720
+ children: /* @__PURE__ */ jsxs(Stack, { tokens: { childrenGap: 8 }, children: [
3721
+ /* @__PURE__ */ jsx(Field, { label: "Upload", size: "small", children: /* @__PURE__ */ jsxs(
3722
+ "label",
3723
+ {
3724
+ style: {
3725
+ cursor: disabled ? "not-allowed" : "pointer",
3726
+ display: "flex",
3727
+ alignItems: "center",
3728
+ gap: 8,
3729
+ opacity: disabled ? 0.75 : 1
3730
+ },
3731
+ children: [
3732
+ /* @__PURE__ */ jsx(
3733
+ "input",
3734
+ {
3735
+ type: "file",
3736
+ accept: "image/*",
3737
+ style: { display: "none" },
3738
+ disabled,
3739
+ onChange: loadImage
3740
+ },
3741
+ "inline-image-upload"
3742
+ ),
3743
+ /* @__PURE__ */ jsxs(Stack, { horizontal: true, children: [
3660
3744
  /* @__PURE__ */ jsx(
3661
- "input",
3745
+ AttachFilled,
3662
3746
  {
3663
- type: "file",
3664
- accept: "image/*",
3665
- style: { display: "none" },
3666
- disabled,
3667
- onChange: loadImage
3668
- },
3669
- "inline-image-upload"
3670
- ),
3671
- /* @__PURE__ */ jsxs(Stack, { horizontal: true, children: [
3672
- /* @__PURE__ */ jsx(
3673
- AttachFilled,
3674
- {
3675
- style: {
3676
- fontSize: "16px",
3677
- color: disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#808080",
3678
- marginTop: 2
3679
- }
3747
+ style: {
3748
+ fontSize: "16px",
3749
+ color: disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#808080",
3750
+ marginTop: 2
3680
3751
  }
3681
- ),
3682
- !fileName && /* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "#808080" }, children: "Upload File" })
3683
- ] }),
3684
- fileName && /* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "#808080" }, children: fileName })
3685
- ]
3686
- }
3687
- ) }),
3688
- fileSizeError && /* @__PURE__ */ jsx(MessageBar, { intent: "error", style: { marginTop: 4 }, children: /* @__PURE__ */ jsx(MessageBarBody, { children: fileSizeError }) }),
3689
- /* @__PURE__ */ jsx(Field, { label: "Alt Text", size: "small", children: /* @__PURE__ */ jsx(
3690
- Input,
3691
- {
3692
- placeholder: "Alt text",
3693
- appearance: "underline",
3694
- disabled,
3695
- onChange: (_, d) => setAltText(d.value),
3696
- value: altText
3697
- }
3698
- ) }),
3699
- selectedValue === "URL" && /* @__PURE__ */ jsx(
3700
- InsertImageByURL,
3701
- {
3702
- disabled,
3703
- setIsOpen: (open) => setIsOpen(open),
3704
- onClick: (payload) => onClick(payload)
3705
- }
3706
- )
3707
- ] }) }),
3708
- /* @__PURE__ */ jsxs(DialogActions, { children: [
3709
- /* @__PURE__ */ jsx(Button, { size: "small", disabled: isDisabled, onClick: () => onClick({ altText, src }), children: "Add" }),
3710
- /* @__PURE__ */ jsx(Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
3711
- ] })
3712
- ] }) })
3713
- ]
3714
- }
3715
- );
3752
+ }
3753
+ ),
3754
+ !fileName && /* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "#808080" }, children: "Upload File" })
3755
+ ] }),
3756
+ fileName && /* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "#808080" }, children: fileName })
3757
+ ]
3758
+ }
3759
+ ) }),
3760
+ fileSizeError && /* @__PURE__ */ jsx(MessageBar, { intent: "error", style: { marginTop: 4 }, children: /* @__PURE__ */ jsx(MessageBarBody, { children: fileSizeError }) }),
3761
+ /* @__PURE__ */ jsx(Field, { label: "Alt Text", size: "small", children: /* @__PURE__ */ jsx(
3762
+ Input,
3763
+ {
3764
+ placeholder: "Alt text",
3765
+ appearance: "underline",
3766
+ disabled,
3767
+ onChange: (_, d) => setAltText(d.value),
3768
+ value: altText
3769
+ }
3770
+ ) }),
3771
+ selectedValue === "URL" && /* @__PURE__ */ jsx(
3772
+ InsertImageByURL,
3773
+ {
3774
+ disabled,
3775
+ setIsOpen: (open) => setIsOpen(open),
3776
+ onClick: (payload) => onClick(payload)
3777
+ }
3778
+ )
3779
+ ] })
3780
+ }
3781
+ )
3782
+ ] });
3716
3783
  };
3717
3784
  var ImagesPlugin = ({ captionsEnabled }) => {
3718
3785
  const [editor] = useLexicalComposerContext();
@@ -3962,135 +4029,132 @@ var InsertInlineImageDialog = ({
3962
4029
  setFileName("");
3963
4030
  setFileSizeError(null);
3964
4031
  };
3965
- return /* @__PURE__ */ jsxs(
3966
- Dialog,
3967
- {
3968
- open: disabled ? false : isOpen,
3969
- onOpenChange: (_, data) => {
3970
- if (!disabled) setIsOpen(data.open);
4032
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4033
+ /* @__PURE__ */ jsx(
4034
+ Button,
4035
+ {
4036
+ size: "small",
4037
+ title: "Add Inline Image",
4038
+ disabled,
4039
+ icon: /* @__PURE__ */ jsx(ImageEditRegular, { style: { color: iconColor } }),
4040
+ style: {
4041
+ background: isOpen && !disabled ? "#ebebeb" : "none",
4042
+ border: "none",
4043
+ margin: 2,
4044
+ opacity: disabled ? 0.55 : 1,
4045
+ cursor: disabled ? "not-allowed" : "pointer"
4046
+ },
4047
+ onClick: () => {
4048
+ if (disabled) return;
4049
+ setIsOpen((prev) => !prev);
4050
+ setAltText("");
4051
+ setSrc("");
4052
+ setFileName("");
4053
+ }
3971
4054
  },
3972
- children: [
3973
- /* @__PURE__ */ jsx(DialogTrigger, { disableButtonEnhancement: true, children: /* @__PURE__ */ jsx(
3974
- Button,
3975
- {
3976
- size: "small",
3977
- title: "Add Inline Image",
3978
- disabled,
3979
- icon: /* @__PURE__ */ jsx(ImageEditRegular, { style: { color: iconColor } }),
3980
- style: {
3981
- background: isOpen && !disabled ? "#ebebeb" : "none",
3982
- border: "none",
3983
- margin: 2,
3984
- opacity: disabled ? 0.55 : 1,
3985
- cursor: disabled ? "not-allowed" : "pointer"
4055
+ "upload-inline-image"
4056
+ ),
4057
+ /* @__PURE__ */ jsx(
4058
+ AoModal,
4059
+ {
4060
+ isOpen: disabled ? false : isOpen,
4061
+ onDismiss: () => !disabled && setIsOpen(false),
4062
+ title: "Insert inline image",
4063
+ maxWidth: 360,
4064
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
4065
+ /* @__PURE__ */ jsx(
4066
+ Button,
4067
+ {
4068
+ size: "small",
4069
+ disabled: isDisabled,
4070
+ onClick: handleOnClick,
4071
+ children: "Add"
3986
4072
  },
3987
- onClick: () => {
3988
- if (disabled) return;
3989
- setIsOpen((prev) => !prev);
3990
- setAltText("");
3991
- setSrc("");
3992
- setFileName("");
3993
- }
3994
- },
3995
- "upload-inline-image"
3996
- ) }),
3997
- /* @__PURE__ */ jsx(DialogSurface, { style: { maxWidth: 360 }, children: /* @__PURE__ */ jsxs(DialogBody, { children: [
3998
- /* @__PURE__ */ jsx(DialogTitle, { children: "Insert inline image" }),
3999
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsxs(Stack, { tokens: { childrenGap: 8 }, children: [
4000
- /* @__PURE__ */ jsx(Field, { label: "Upload", size: "small", children: /* @__PURE__ */ jsxs(
4001
- "label",
4002
- {
4003
- style: {
4004
- cursor: disabled ? "not-allowed" : "pointer",
4005
- display: "flex",
4006
- alignItems: "center",
4007
- gap: 8,
4008
- opacity: disabled ? 0.75 : 1
4009
- },
4010
- children: [
4073
+ "file-inline-upload-btn"
4074
+ ),
4075
+ /* @__PURE__ */ jsx(
4076
+ Button,
4077
+ {
4078
+ size: "small",
4079
+ disabled,
4080
+ onClick: () => setIsOpen(false),
4081
+ children: "Cancel"
4082
+ },
4083
+ "file-inline-upload-cancel"
4084
+ )
4085
+ ] }),
4086
+ children: /* @__PURE__ */ jsxs(Stack, { tokens: { childrenGap: 8 }, children: [
4087
+ /* @__PURE__ */ jsx(Field, { label: "Upload", size: "small", children: /* @__PURE__ */ jsxs(
4088
+ "label",
4089
+ {
4090
+ style: {
4091
+ cursor: disabled ? "not-allowed" : "pointer",
4092
+ display: "flex",
4093
+ alignItems: "center",
4094
+ gap: 8,
4095
+ opacity: disabled ? 0.75 : 1
4096
+ },
4097
+ children: [
4098
+ /* @__PURE__ */ jsx(
4099
+ "input",
4100
+ {
4101
+ type: "file",
4102
+ accept: "image/*",
4103
+ style: { display: "none" },
4104
+ disabled,
4105
+ onChange: loadImage
4106
+ },
4107
+ "inline-image-upload"
4108
+ ),
4109
+ /* @__PURE__ */ jsxs(Stack, { horizontal: true, children: [
4011
4110
  /* @__PURE__ */ jsx(
4012
- "input",
4111
+ AttachFilled,
4013
4112
  {
4014
- type: "file",
4015
- accept: "image/*",
4016
- style: { display: "none" },
4017
- disabled,
4018
- onChange: loadImage
4019
- },
4020
- "inline-image-upload"
4021
- ),
4022
- /* @__PURE__ */ jsxs(Stack, { horizontal: true, children: [
4023
- /* @__PURE__ */ jsx(
4024
- AttachFilled,
4025
- {
4026
- style: {
4027
- fontSize: "16px",
4028
- color: disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#808080",
4029
- marginTop: 2
4030
- }
4113
+ style: {
4114
+ fontSize: "16px",
4115
+ color: disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#808080",
4116
+ marginTop: 2
4031
4117
  }
4032
- ),
4033
- !fileName && /* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "#808080" }, children: "Upload File" })
4034
- ] }),
4035
- fileName && /* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "#808080" }, children: fileName })
4036
- ]
4037
- }
4038
- ) }),
4039
- /* @__PURE__ */ jsx(Field, { label: "Position", size: "small", children: /* @__PURE__ */ jsxs(
4040
- Dropdown,
4041
- {
4042
- className: styles.alignDropdown,
4043
- disabled,
4044
- value: position === "full" ? "Full" : position === "right" ? "Right" : "Left",
4045
- selectedOptions: [position ?? "left"],
4046
- listbox: { style: { width: "120px" } },
4047
- root: { style: { borderBottom: "1px solid black" } },
4048
- onOptionSelect: (_, data) => setPosition(data.optionValue),
4049
- children: [
4050
- /* @__PURE__ */ jsx(Option, { value: "left", children: "Left" }, "left"),
4051
- /* @__PURE__ */ jsx(Option, { value: "right", children: "Right" }, "right"),
4052
- /* @__PURE__ */ jsx(Option, { value: "full", children: "Full" }, "full")
4053
- ]
4054
- }
4055
- ) }),
4056
- fileSizeError && /* @__PURE__ */ jsx(MessageBar, { intent: "error", style: { marginTop: 4 }, children: /* @__PURE__ */ jsx(MessageBarBody, { children: fileSizeError }) }),
4057
- /* @__PURE__ */ jsx(Field, { label: "Alt Text", size: "small", children: /* @__PURE__ */ jsx(
4058
- Input,
4059
- {
4060
- placeholder: "Alt text",
4061
- appearance: "underline",
4062
- disabled,
4063
- value: altText,
4064
- onChange: (_, d) => setAltText(d.value)
4065
- }
4066
- ) })
4067
- ] }) }),
4068
- /* @__PURE__ */ jsxs(DialogActions, { children: [
4069
- /* @__PURE__ */ jsx(
4070
- Button,
4071
- {
4072
- size: "small",
4073
- disabled: isDisabled,
4074
- onClick: handleOnClick,
4075
- children: "Add"
4076
- },
4077
- "file-inline-upload-btn"
4078
- ),
4079
- /* @__PURE__ */ jsx(
4080
- Button,
4081
- {
4082
- size: "small",
4083
- disabled,
4084
- onClick: () => setIsOpen(false),
4085
- children: "Cancel"
4086
- },
4087
- "file-inline-upload-cancel"
4088
- )
4089
- ] })
4090
- ] }) })
4091
- ]
4092
- }
4093
- );
4118
+ }
4119
+ ),
4120
+ !fileName && /* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "#808080" }, children: "Upload File" })
4121
+ ] }),
4122
+ fileName && /* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "#808080" }, children: fileName })
4123
+ ]
4124
+ }
4125
+ ) }),
4126
+ /* @__PURE__ */ jsx(Field, { label: "Position", size: "small", children: /* @__PURE__ */ jsxs(
4127
+ Dropdown,
4128
+ {
4129
+ className: styles.alignDropdown,
4130
+ disabled,
4131
+ value: position === "full" ? "Full" : position === "right" ? "Right" : "Left",
4132
+ selectedOptions: [position ?? "left"],
4133
+ listbox: { style: { width: "120px" } },
4134
+ root: { style: { borderBottom: "1px solid black" } },
4135
+ onOptionSelect: (_, data) => setPosition(data.optionValue),
4136
+ children: [
4137
+ /* @__PURE__ */ jsx(Option, { value: "left", children: "Left" }, "left"),
4138
+ /* @__PURE__ */ jsx(Option, { value: "right", children: "Right" }, "right"),
4139
+ /* @__PURE__ */ jsx(Option, { value: "full", children: "Full" }, "full")
4140
+ ]
4141
+ }
4142
+ ) }),
4143
+ fileSizeError && /* @__PURE__ */ jsx(MessageBar, { intent: "error", style: { marginTop: 4 }, children: /* @__PURE__ */ jsx(MessageBarBody, { children: fileSizeError }) }),
4144
+ /* @__PURE__ */ jsx(Field, { label: "Alt Text", size: "small", children: /* @__PURE__ */ jsx(
4145
+ Input,
4146
+ {
4147
+ placeholder: "Alt text",
4148
+ appearance: "underline",
4149
+ disabled,
4150
+ value: altText,
4151
+ onChange: (_, d) => setAltText(d.value)
4152
+ }
4153
+ ) })
4154
+ ] })
4155
+ }
4156
+ )
4157
+ ] });
4094
4158
  };
4095
4159
  var InlineImagePlugin = () => {
4096
4160
  const [editor] = useLexicalComposerContext();
@@ -4353,8 +4417,8 @@ function RefApiPlugin({
4353
4417
  focusedRef
4354
4418
  }) {
4355
4419
  const [editor] = useLexicalComposerContext();
4356
- const cleanBaselineRef = React9__default.useRef(null);
4357
- React9__default.useEffect(() => {
4420
+ const cleanBaselineRef = React10__default.useRef(null);
4421
+ React10__default.useEffect(() => {
4358
4422
  const capture = () => {
4359
4423
  if (cleanBaselineRef.current === null) {
4360
4424
  cleanBaselineRef.current = getUserContentSignature(editor);
@@ -4568,28 +4632,28 @@ function SpellPopover({
4568
4632
  onImprove,
4569
4633
  onAcceptGrammar
4570
4634
  }) {
4571
- const ref = React9.useRef(null);
4635
+ const ref = React10.useRef(null);
4572
4636
  const type = state.issue.type ?? "spelling";
4573
- const [pos, setPos] = React9.useState({ left: state.x, top: state.y });
4574
- React9.useEffect(() => {
4637
+ const [pos, setPos] = React10.useState({ left: state.x, top: state.y });
4638
+ React10.useEffect(() => {
4575
4639
  if (!ref.current) return;
4576
4640
  const { offsetHeight: h, offsetWidth: w } = ref.current;
4577
4641
  const top = state.y + h > window.innerHeight - 8 ? state.y - h - 32 : state.y;
4578
4642
  setPos({ left: Math.min(state.x, window.innerWidth - w - 8), top });
4579
4643
  }, [state.x, state.y]);
4580
- React9.useEffect(() => {
4644
+ React10.useEffect(() => {
4581
4645
  const h = (e) => {
4582
4646
  if (ref.current && !ref.current.contains(e.target)) onClose();
4583
4647
  };
4584
4648
  document.addEventListener("mousedown", h, true);
4585
4649
  return () => document.removeEventListener("mousedown", h, true);
4586
4650
  }, [onClose]);
4587
- React9.useEffect(() => {
4651
+ React10.useEffect(() => {
4588
4652
  const h = () => onClose();
4589
4653
  window.addEventListener("scroll", h, { capture: true, passive: true });
4590
4654
  return () => window.removeEventListener("scroll", h, true);
4591
4655
  }, [onClose]);
4592
- React9.useEffect(() => {
4656
+ React10.useEffect(() => {
4593
4657
  const h = (e) => {
4594
4658
  if (e.key === "Escape") onClose();
4595
4659
  };
@@ -4706,17 +4770,17 @@ function SpellCheckPlugin({
4706
4770
  enabled = true
4707
4771
  }) {
4708
4772
  const [editor] = useLexicalComposerContext();
4709
- const timerRef = React9.useRef(null);
4710
- const dismissRef = React9.useRef(null);
4711
- const reqIdRef = React9.useRef(0);
4712
- const lastTextRef = React9.useRef("");
4713
- const applyingRef = React9.useRef(false);
4714
- const grammarCorrectionRef = React9.useRef(void 0);
4715
- const [popover, setPopover] = React9.useState(null);
4716
- React9.useEffect(() => {
4773
+ const timerRef = React10.useRef(null);
4774
+ const dismissRef = React10.useRef(null);
4775
+ const reqIdRef = React10.useRef(0);
4776
+ const lastTextRef = React10.useRef("");
4777
+ const applyingRef = React10.useRef(false);
4778
+ const grammarCorrectionRef = React10.useRef(void 0);
4779
+ const [popover, setPopover] = React10.useState(null);
4780
+ React10.useEffect(() => {
4717
4781
  injectCSS();
4718
4782
  }, []);
4719
- const clearErrors = React9.useCallback(() => {
4783
+ const clearErrors = React10.useCallback(() => {
4720
4784
  setPopover(null);
4721
4785
  grammarCorrectionRef.current = void 0;
4722
4786
  applyingRef.current = true;
@@ -4732,7 +4796,7 @@ function SpellCheckPlugin({
4732
4796
  }
4733
4797
  );
4734
4798
  }, [editor]);
4735
- const applyIssues = React9.useCallback(
4799
+ const applyIssues = React10.useCallback(
4736
4800
  (issues, improvedText, trimOffset = 0) => {
4737
4801
  let savedCharOffset = -1;
4738
4802
  editor.getEditorState().read(() => {
@@ -4875,7 +4939,7 @@ function SpellCheckPlugin({
4875
4939
  },
4876
4940
  [editor]
4877
4941
  );
4878
- React9.useEffect(() => {
4942
+ React10.useEffect(() => {
4879
4943
  let currentRoot = null;
4880
4944
  const onClick = (e) => {
4881
4945
  const span = e.target.closest("[data-spell-offset]");
@@ -4919,7 +4983,7 @@ function SpellCheckPlugin({
4919
4983
  if (currentRoot) currentRoot.removeEventListener("click", onClick);
4920
4984
  };
4921
4985
  }, [editor]);
4922
- const handleAccept = React9.useCallback(
4986
+ const handleAccept = React10.useCallback(
4923
4987
  (replacement, nodeKey) => {
4924
4988
  let original = "";
4925
4989
  editor.getEditorState().read(() => {
@@ -4945,7 +5009,7 @@ function SpellCheckPlugin({
4945
5009
  },
4946
5010
  [editor, onSpellCheckAccept, popover]
4947
5011
  );
4948
- const handleDismiss = React9.useCallback(
5012
+ const handleDismiss = React10.useCallback(
4949
5013
  (nodeKey) => {
4950
5014
  editor.update(
4951
5015
  () => {
@@ -4959,7 +5023,7 @@ function SpellCheckPlugin({
4959
5023
  },
4960
5024
  [editor]
4961
5025
  );
4962
- const handleImprove = React9.useCallback(
5026
+ const handleImprove = React10.useCallback(
4963
5027
  (text) => {
4964
5028
  const original = lastTextRef.current;
4965
5029
  applyingRef.current = true;
@@ -4979,7 +5043,7 @@ function SpellCheckPlugin({
4979
5043
  },
4980
5044
  [editor, onSpellCheckAccept]
4981
5045
  );
4982
- const handleAcceptGrammar = React9.useCallback(
5046
+ const handleAcceptGrammar = React10.useCallback(
4983
5047
  (corrected) => {
4984
5048
  const original = lastTextRef.current;
4985
5049
  applyingRef.current = true;
@@ -4999,7 +5063,7 @@ function SpellCheckPlugin({
4999
5063
  },
5000
5064
  [editor, onSpellCheckAccept]
5001
5065
  );
5002
- React9.useEffect(() => {
5066
+ React10.useEffect(() => {
5003
5067
  if (!enabled || !useSpellCheck) return;
5004
5068
  return editor.registerUpdateListener(({ tags }) => {
5005
5069
  if (applyingRef.current) return;
@@ -5037,13 +5101,13 @@ function SpellCheckPlugin({
5037
5101
  }, idleMs);
5038
5102
  });
5039
5103
  }, [editor, useSpellCheck, enabled, idleMs, applyIssues, clearErrors]);
5040
- React9.useEffect(() => {
5104
+ React10.useEffect(() => {
5041
5105
  if (!enabled) {
5042
5106
  clearErrors();
5043
5107
  lastTextRef.current = "";
5044
5108
  }
5045
5109
  }, [enabled, clearErrors]);
5046
- React9.useEffect(
5110
+ React10.useEffect(
5047
5111
  () => () => {
5048
5112
  dismissRef.current?.();
5049
5113
  if (timerRef.current) clearTimeout(timerRef.current);
@@ -5064,13 +5128,13 @@ function SpellCheckPlugin({
5064
5128
  }
5065
5129
  function TableActionMenuPlugin({ disabled = false }) {
5066
5130
  const [editor] = useLexicalComposerContext();
5067
- const [isInTable, setIsInTable] = React9.useState(false);
5068
- const [anchorRect, setAnchorRect] = React9.useState(null);
5069
- const [contentRight, setContentRight] = React9.useState(null);
5070
- const [open, setOpen] = React9.useState(false);
5071
- const openRef = React9.useRef(false);
5072
- const savedAnchorRef = React9.useRef(null);
5073
- const measureContentRight = React9.useCallback((cellDom) => {
5131
+ const [isInTable, setIsInTable] = React10.useState(false);
5132
+ const [anchorRect, setAnchorRect] = React10.useState(null);
5133
+ const [contentRight, setContentRight] = React10.useState(null);
5134
+ const [open, setOpen] = React10.useState(false);
5135
+ const openRef = React10.useRef(false);
5136
+ const savedAnchorRef = React10.useRef(null);
5137
+ const measureContentRight = React10.useCallback((cellDom) => {
5074
5138
  try {
5075
5139
  const range = document.createRange();
5076
5140
  range.selectNodeContents(cellDom);
@@ -5080,7 +5144,7 @@ function TableActionMenuPlugin({ disabled = false }) {
5080
5144
  return null;
5081
5145
  }
5082
5146
  }, []);
5083
- const updateFromSelection = React9.useCallback(() => {
5147
+ const updateFromSelection = React10.useCallback(() => {
5084
5148
  if (openRef.current) return;
5085
5149
  const root = editor.getRootElement();
5086
5150
  if (!root) return;
@@ -5131,7 +5195,7 @@ function TableActionMenuPlugin({ disabled = false }) {
5131
5195
  }
5132
5196
  });
5133
5197
  }, [editor, measureContentRight]);
5134
- React9.useEffect(() => {
5198
+ React10.useEffect(() => {
5135
5199
  return mergeRegister(
5136
5200
  editor.registerCommand(
5137
5201
  SELECTION_CHANGE_COMMAND,
@@ -5146,7 +5210,7 @@ function TableActionMenuPlugin({ disabled = false }) {
5146
5210
  })
5147
5211
  );
5148
5212
  }, [editor, updateFromSelection]);
5149
- React9.useEffect(() => {
5213
+ React10.useEffect(() => {
5150
5214
  return editor.registerCommand(
5151
5215
  KEY_DOWN_COMMAND,
5152
5216
  (event) => {
@@ -5188,7 +5252,7 @@ function TableActionMenuPlugin({ disabled = false }) {
5188
5252
  );
5189
5253
  }, [editor, disabled]);
5190
5254
  const canShow = isInTable && !!anchorRect && !disabled;
5191
- const handleStyle = React9.useMemo(() => {
5255
+ const handleStyle = React10.useMemo(() => {
5192
5256
  if (!anchorRect) return void 0;
5193
5257
  const top = Math.max(8, anchorRect.top + 6);
5194
5258
  const clampedCellRight = Math.min(anchorRect.right, window.innerWidth - 8);
@@ -5203,7 +5267,7 @@ function TableActionMenuPlugin({ disabled = false }) {
5203
5267
  const dangerStyle = {
5204
5268
  color: "var(--colorPaletteRedForeground1)"
5205
5269
  };
5206
- const run = React9.useCallback(
5270
+ const run = React10.useCallback(
5207
5271
  (fn) => {
5208
5272
  if (disabled) return;
5209
5273
  openRef.current = false;
@@ -5764,22 +5828,22 @@ var hsvToRgb = (h, s, v) => {
5764
5828
  };
5765
5829
  };
5766
5830
  var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange }) => {
5767
- const [open, setOpen] = React9.useState(false);
5768
- const btnRef = React9.useRef(null);
5769
- const setOpenAndNotify = React9.useCallback(
5831
+ const [open, setOpen] = React10.useState(false);
5832
+ const btnRef = React10.useRef(null);
5833
+ const setOpenAndNotify = React10.useCallback(
5770
5834
  (next) => {
5771
5835
  setOpen(next);
5772
5836
  onOpenChange?.(next);
5773
5837
  },
5774
5838
  [onOpenChange]
5775
5839
  );
5776
- const handleDismiss = React9.useCallback(() => setOpenAndNotify(false), [setOpenAndNotify]);
5777
- const preventDismissOnEvent = React9.useCallback(
5840
+ const handleDismiss = React10.useCallback(() => setOpenAndNotify(false), [setOpenAndNotify]);
5841
+ const preventDismissOnEvent = React10.useCallback(
5778
5842
  (ev) => ev.type !== "click",
5779
5843
  []
5780
5844
  );
5781
- const [, forceReposition] = React9.useState(0);
5782
- React9.useEffect(() => {
5845
+ const [, forceReposition] = React10.useState(0);
5846
+ React10.useEffect(() => {
5783
5847
  if (!open) return;
5784
5848
  let rafId = null;
5785
5849
  const reposition = () => {
@@ -5797,15 +5861,15 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
5797
5861
  window.removeEventListener("resize", reposition);
5798
5862
  };
5799
5863
  }, [open]);
5800
- const appliedHex = React9.useMemo(() => normalizeHex(value || "#000000"), [value]);
5801
- const [hex, setHexState] = React9.useState(appliedHex);
5802
- const [hexText, setHexText] = React9.useState(appliedHex);
5803
- const { r, g, b } = React9.useMemo(() => hexToRgb(hex), [hex]);
5804
- const hsv = React9.useMemo(() => rgbToHsv(r, g, b), [r, g, b]);
5805
- const [h, setH] = React9.useState(hsv.h);
5806
- const [s, setS] = React9.useState(hsv.s);
5807
- const [v, setV] = React9.useState(hsv.v);
5808
- const commit = React9.useCallback(
5864
+ const appliedHex = React10.useMemo(() => normalizeHex(value || "#000000"), [value]);
5865
+ const [hex, setHexState] = React10.useState(appliedHex);
5866
+ const [hexText, setHexText] = React10.useState(appliedHex);
5867
+ const { r, g, b } = React10.useMemo(() => hexToRgb(hex), [hex]);
5868
+ const hsv = React10.useMemo(() => rgbToHsv(r, g, b), [r, g, b]);
5869
+ const [h, setH] = React10.useState(hsv.h);
5870
+ const [s, setS] = React10.useState(hsv.s);
5871
+ const [v, setV] = React10.useState(hsv.v);
5872
+ const commit = React10.useCallback(
5809
5873
  (nextHex) => {
5810
5874
  const rgb = hexToRgb(nextHex);
5811
5875
  const next = rgbToHsv(rgb.r, rgb.g, rgb.b);
@@ -5818,7 +5882,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
5818
5882
  },
5819
5883
  [onChange]
5820
5884
  );
5821
- const commitFromHsv = React9.useCallback(
5885
+ const commitFromHsv = React10.useCallback(
5822
5886
  (hh, ss, vv) => {
5823
5887
  const rgb = hsvToRgb(hh, ss, vv);
5824
5888
  const nextHex = rgbToHex(rgb.r, rgb.g, rgb.b);
@@ -5831,8 +5895,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
5831
5895
  },
5832
5896
  [onChange]
5833
5897
  );
5834
- const wasOpenRef = React9.useRef(open);
5835
- React9.useEffect(() => {
5898
+ const wasOpenRef = React10.useRef(open);
5899
+ React10.useEffect(() => {
5836
5900
  const justOpened = open && !wasOpenRef.current;
5837
5901
  wasOpenRef.current = open;
5838
5902
  if (!justOpened) return;
@@ -5844,8 +5908,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
5844
5908
  setS(next.s);
5845
5909
  setV(next.v);
5846
5910
  }, [appliedHex, open]);
5847
- const svRef = React9.useRef(null);
5848
- const svPointFromEvent = React9.useCallback((clientX, clientY) => {
5911
+ const svRef = React10.useRef(null);
5912
+ const svPointFromEvent = React10.useCallback((clientX, clientY) => {
5849
5913
  if (!svRef.current) return null;
5850
5914
  const rect = svRef.current.getBoundingClientRect();
5851
5915
  const x = clamp3(clientX - rect.left, 0, rect.width);
@@ -5854,9 +5918,9 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
5854
5918
  const vv = rect.height === 0 ? 0 : 1 - y / rect.height;
5855
5919
  return { ss, vv };
5856
5920
  }, []);
5857
- const hRef = React9.useRef(h);
5921
+ const hRef = React10.useRef(h);
5858
5922
  hRef.current = h;
5859
- const handleSVPointerDown = React9.useCallback(
5923
+ const handleSVPointerDown = React10.useCallback(
5860
5924
  (e) => {
5861
5925
  e.currentTarget.setPointerCapture(e.pointerId);
5862
5926
  const pt = svPointFromEvent(e.clientX, e.clientY);
@@ -5864,7 +5928,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
5864
5928
  },
5865
5929
  [svPointFromEvent, commitFromHsv]
5866
5930
  );
5867
- const handleSVPointerMove = React9.useCallback(
5931
+ const handleSVPointerMove = React10.useCallback(
5868
5932
  (e) => {
5869
5933
  if (e.buttons !== 1) return;
5870
5934
  const pt = svPointFromEvent(e.clientX, e.clientY);
@@ -5872,18 +5936,18 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
5872
5936
  },
5873
5937
  [svPointFromEvent, commitFromHsv]
5874
5938
  );
5875
- const hueRef = React9.useRef(null);
5876
- const sRef = React9.useRef(s);
5939
+ const hueRef = React10.useRef(null);
5940
+ const sRef = React10.useRef(s);
5877
5941
  sRef.current = s;
5878
- const vRef = React9.useRef(v);
5942
+ const vRef = React10.useRef(v);
5879
5943
  vRef.current = v;
5880
- const huePointFromEvent = React9.useCallback((clientX) => {
5944
+ const huePointFromEvent = React10.useCallback((clientX) => {
5881
5945
  if (!hueRef.current) return null;
5882
5946
  const rect = hueRef.current.getBoundingClientRect();
5883
5947
  const x = clamp3(clientX - rect.left, 0, rect.width);
5884
5948
  return rect.width === 0 ? 0 : x / rect.width * 360;
5885
5949
  }, []);
5886
- const handleHuePointerDown = React9.useCallback(
5950
+ const handleHuePointerDown = React10.useCallback(
5887
5951
  (e) => {
5888
5952
  e.currentTarget.setPointerCapture(e.pointerId);
5889
5953
  const hh = huePointFromEvent(e.clientX);
@@ -5891,7 +5955,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
5891
5955
  },
5892
5956
  [huePointFromEvent, commitFromHsv]
5893
5957
  );
5894
- const handleHuePointerMove = React9.useCallback(
5958
+ const handleHuePointerMove = React10.useCallback(
5895
5959
  (e) => {
5896
5960
  if (e.buttons !== 1) return;
5897
5961
  const hh = huePointFromEvent(e.clientX);
@@ -5899,7 +5963,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
5899
5963
  },
5900
5964
  [huePointFromEvent, commitFromHsv]
5901
5965
  );
5902
- const handleHexChange = React9.useCallback(
5966
+ const handleHexChange = React10.useCallback(
5903
5967
  (_, val) => {
5904
5968
  const next = val ?? "";
5905
5969
  setHexText(next);
@@ -5907,12 +5971,12 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
5907
5971
  },
5908
5972
  [commit]
5909
5973
  );
5910
- const handleHexBlur = React9.useCallback(() => {
5974
+ const handleHexBlur = React10.useCallback(() => {
5911
5975
  commit(normalizeHex(hexText));
5912
5976
  }, [hexText, commit]);
5913
- const svThumb = React9.useMemo(() => ({ left: `${s * 100}%`, top: `${(1 - v) * 100}%` }), [s, v]);
5914
- const hueThumb = React9.useMemo(() => ({ left: `${h / 360 * 100}%` }), [h]);
5915
- const hueColor = React9.useMemo(() => {
5977
+ const svThumb = React10.useMemo(() => ({ left: `${s * 100}%`, top: `${(1 - v) * 100}%` }), [s, v]);
5978
+ const hueThumb = React10.useMemo(() => ({ left: `${h / 360 * 100}%` }), [h]);
5979
+ const hueColor = React10.useMemo(() => {
5916
5980
  const { r: r2, g: g2, b: b2 } = hsvToRgb(h, 1, 1);
5917
5981
  return rgbToHex(r2, g2, b2);
5918
5982
  }, [h]);
@@ -6158,8 +6222,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
6158
6222
  };
6159
6223
  var ColorPickerPlugin = ({ disabled }) => {
6160
6224
  const [editor] = useLexicalComposerContext();
6161
- const [{ color, bgColor }, setColors] = React9__default.useState({ color: "#000000", bgColor: "#ffffff" });
6162
- const lastRangeSelectionRef = React9__default.useRef(null);
6225
+ const [{ color, bgColor }, setColors] = React10__default.useState({ color: "#000000", bgColor: "#ffffff" });
6226
+ const lastRangeSelectionRef = React10__default.useRef(null);
6163
6227
  const updateToolbar = () => {
6164
6228
  const selection = $getSelection();
6165
6229
  if ($isRangeSelection(selection)) {
@@ -6169,7 +6233,7 @@ var ColorPickerPlugin = ({ disabled }) => {
6169
6233
  setColors({ color: c, bgColor: bg });
6170
6234
  }
6171
6235
  };
6172
- React9__default.useEffect(() => {
6236
+ React10__default.useEffect(() => {
6173
6237
  return mergeRegister(
6174
6238
  editor.registerUpdateListener(({ editorState }) => {
6175
6239
  editorState.read(() => updateToolbar());
@@ -6184,7 +6248,7 @@ var ColorPickerPlugin = ({ disabled }) => {
6184
6248
  )
6185
6249
  );
6186
6250
  }, [editor]);
6187
- const wasEditorActiveRef = React9__default.useRef(false);
6251
+ const wasEditorActiveRef = React10__default.useRef(false);
6188
6252
  const handleOpenChange = (open) => {
6189
6253
  if (open) {
6190
6254
  const root = editor.getRootElement();
@@ -6402,9 +6466,9 @@ var useStyles3 = makeStyles({
6402
6466
  var FontSizePlugin = ({ disabled }) => {
6403
6467
  const [editor] = useLexicalComposerContext();
6404
6468
  const styles = useStyles3();
6405
- const [fontSize2, setFontSize] = React9.useState(String(DEFAULT_FONT_SIZE));
6469
+ const [fontSize2, setFontSize] = React10.useState(String(DEFAULT_FONT_SIZE));
6406
6470
  const fg = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
6407
- React9.useEffect(() => {
6471
+ React10.useEffect(() => {
6408
6472
  const readFontSize = () => {
6409
6473
  const selection = $getSelection();
6410
6474
  if ($isRangeSelection(selection)) {
@@ -6591,79 +6655,76 @@ var TableItemPlugin = ({ disabled }) => {
6591
6655
  setColumns("");
6592
6656
  setIsOpen(false);
6593
6657
  };
6594
- return /* @__PURE__ */ jsxs(
6595
- Dialog,
6596
- {
6597
- open: disabled ? false : isOpen,
6598
- onOpenChange: (_, data) => {
6599
- if (!disabled) setIsOpen(data.open);
6658
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
6659
+ /* @__PURE__ */ jsx(
6660
+ Button,
6661
+ {
6662
+ size: "small",
6663
+ title: "Add table",
6664
+ disabled,
6665
+ icon: /* @__PURE__ */ jsx(TableAddRegular, { style: { color: iconColor } }),
6666
+ style: {
6667
+ background: isOpen && !disabled ? "#ebebeb" : "none",
6668
+ border: "none",
6669
+ margin: 2,
6670
+ opacity: disabled ? 0.55 : 1,
6671
+ cursor: disabled ? "not-allowed" : "pointer"
6672
+ },
6673
+ onClick: () => {
6674
+ if (disabled) return;
6675
+ setIsOpen((prev) => !prev);
6676
+ setRows("");
6677
+ setColumns("");
6678
+ }
6600
6679
  },
6601
- children: [
6602
- /* @__PURE__ */ jsx(DialogTrigger, { disableButtonEnhancement: true, children: /* @__PURE__ */ jsx(
6603
- Button,
6604
- {
6605
- size: "small",
6606
- title: "Add table",
6607
- disabled,
6608
- icon: /* @__PURE__ */ jsx(TableAddRegular, { style: { color: iconColor } }),
6609
- style: {
6610
- background: isOpen && !disabled ? "#ebebeb" : "none",
6611
- border: "none",
6612
- margin: 2,
6613
- opacity: disabled ? 0.55 : 1,
6614
- cursor: disabled ? "not-allowed" : "pointer"
6615
- },
6616
- onClick: () => {
6617
- if (disabled) return;
6618
- setIsOpen((prev) => !prev);
6619
- setRows("");
6620
- setColumns("");
6680
+ "insert-table-nodes"
6681
+ ),
6682
+ /* @__PURE__ */ jsx(
6683
+ AoModal,
6684
+ {
6685
+ isOpen: disabled ? false : isOpen,
6686
+ onDismiss: () => !disabled && setIsOpen(false),
6687
+ title: "Insert table",
6688
+ maxWidth: 300,
6689
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
6690
+ /* @__PURE__ */ jsx(
6691
+ Button,
6692
+ {
6693
+ size: "small",
6694
+ appearance: "primary",
6695
+ disabled: disabled || !rows || !columns,
6696
+ onClick: onAddTable,
6697
+ children: "Add"
6621
6698
  }
6622
- },
6623
- "insert-table-nodes"
6624
- ) }),
6625
- /* @__PURE__ */ jsx(DialogSurface, { style: { maxWidth: 300 }, children: /* @__PURE__ */ jsxs(DialogBody, { children: [
6626
- /* @__PURE__ */ jsx(DialogTitle, { children: "Insert table" }),
6627
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsxs(Stack, { tokens: { childrenGap: 8 }, children: [
6628
- /* @__PURE__ */ jsx(Field, { label: "Rows", size: "small", children: /* @__PURE__ */ jsx(
6629
- Input,
6630
- {
6631
- autoFocus: !disabled,
6632
- value: rows,
6633
- placeholder: "Rows",
6634
- appearance: "underline",
6635
- disabled,
6636
- onChange: (_, v) => setRows(v.value)
6637
- }
6638
- ) }),
6639
- /* @__PURE__ */ jsx(Field, { label: "Columns", size: "small", children: /* @__PURE__ */ jsx(
6640
- Input,
6641
- {
6642
- value: columns,
6643
- placeholder: "Columns",
6644
- appearance: "underline",
6645
- disabled,
6646
- onChange: (_, v) => setColumns(v.value)
6647
- }
6648
- ) })
6649
- ] }) }),
6650
- /* @__PURE__ */ jsxs(DialogActions, { children: [
6651
- /* @__PURE__ */ jsx(
6652
- Button,
6653
- {
6654
- size: "small",
6655
- appearance: "primary",
6656
- disabled: disabled || !rows || !columns,
6657
- onClick: onAddTable,
6658
- children: "Add"
6659
- }
6660
- ),
6661
- /* @__PURE__ */ jsx(Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
6662
- ] })
6663
- ] }) })
6664
- ]
6665
- }
6666
- );
6699
+ ),
6700
+ /* @__PURE__ */ jsx(Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
6701
+ ] }),
6702
+ children: /* @__PURE__ */ jsxs(Stack, { tokens: { childrenGap: 8 }, children: [
6703
+ /* @__PURE__ */ jsx(Field, { label: "Rows", size: "small", children: /* @__PURE__ */ jsx(
6704
+ Input,
6705
+ {
6706
+ autoFocus: !disabled,
6707
+ value: rows,
6708
+ placeholder: "Rows",
6709
+ appearance: "underline",
6710
+ disabled,
6711
+ onChange: (_, v) => setRows(v.value)
6712
+ }
6713
+ ) }),
6714
+ /* @__PURE__ */ jsx(Field, { label: "Columns", size: "small", children: /* @__PURE__ */ jsx(
6715
+ Input,
6716
+ {
6717
+ value: columns,
6718
+ placeholder: "Columns",
6719
+ appearance: "underline",
6720
+ disabled,
6721
+ onChange: (_, v) => setColumns(v.value)
6722
+ }
6723
+ ) })
6724
+ ] })
6725
+ }
6726
+ )
6727
+ ] });
6667
6728
  };
6668
6729
  var YoutubeUploadPlugin = ({ disabled }) => {
6669
6730
  const [url, setURL] = useState("");
@@ -6683,57 +6744,54 @@ var YoutubeUploadPlugin = ({ disabled }) => {
6683
6744
  setURL("");
6684
6745
  setIsOpen(false);
6685
6746
  };
6686
- return /* @__PURE__ */ jsxs(
6687
- Dialog,
6688
- {
6689
- open: disabled ? false : isOpen,
6690
- onOpenChange: (_, data) => {
6691
- if (!disabled) setIsOpen(data.open);
6747
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
6748
+ /* @__PURE__ */ jsx(
6749
+ Button,
6750
+ {
6751
+ title: "Add youtube URL",
6752
+ size: "small",
6753
+ disabled,
6754
+ icon: /* @__PURE__ */ jsx(VideoClipRegular, { style: { color: iconColor } }),
6755
+ style: {
6756
+ background: isOpen && !disabled ? "#ebebeb" : "none",
6757
+ border: "none",
6758
+ margin: 2,
6759
+ opacity: disabled ? 0.55 : 1,
6760
+ cursor: disabled ? "not-allowed" : "pointer"
6761
+ },
6762
+ onClick: () => {
6763
+ if (disabled) return;
6764
+ setIsOpen((prev) => !prev);
6765
+ setURL("");
6766
+ }
6692
6767
  },
6693
- children: [
6694
- /* @__PURE__ */ jsx(DialogTrigger, { disableButtonEnhancement: true, children: /* @__PURE__ */ jsx(
6695
- Button,
6768
+ "upload-video"
6769
+ ),
6770
+ /* @__PURE__ */ jsx(
6771
+ AoModal,
6772
+ {
6773
+ isOpen: disabled ? false : isOpen,
6774
+ onDismiss: () => !disabled && setIsOpen(false),
6775
+ title: "Embed YouTube video",
6776
+ maxWidth: 320,
6777
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
6778
+ /* @__PURE__ */ jsx(Button, { size: "small", disabled: disabled || !url, onClick: onHandleEmbeded, children: "Add" }),
6779
+ /* @__PURE__ */ jsx(Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
6780
+ ] }),
6781
+ children: /* @__PURE__ */ jsx(Stack, { tokens: { childrenGap: 8 }, children: /* @__PURE__ */ jsx(Field, { label: "URL", size: "small", children: /* @__PURE__ */ jsx(
6782
+ Input,
6696
6783
  {
6697
- title: "Add youtube URL",
6698
- size: "small",
6784
+ autoFocus: !disabled,
6699
6785
  disabled,
6700
- icon: /* @__PURE__ */ jsx(VideoClipRegular, { style: { color: iconColor } }),
6701
- style: {
6702
- background: isOpen && !disabled ? "#ebebeb" : "none",
6703
- border: "none",
6704
- margin: 2,
6705
- opacity: disabled ? 0.55 : 1,
6706
- cursor: disabled ? "not-allowed" : "pointer"
6707
- },
6708
- onClick: () => {
6709
- if (disabled) return;
6710
- setIsOpen((prev) => !prev);
6711
- setURL("");
6712
- }
6713
- },
6714
- "upload-video"
6715
- ) }),
6716
- /* @__PURE__ */ jsx(DialogSurface, { style: { maxWidth: 320 }, children: /* @__PURE__ */ jsxs(DialogBody, { children: [
6717
- /* @__PURE__ */ jsx(DialogTitle, { children: "Embed YouTube video" }),
6718
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Stack, { tokens: { childrenGap: 8 }, children: /* @__PURE__ */ jsx(Field, { label: "URL", size: "small", children: /* @__PURE__ */ jsx(
6719
- Input,
6720
- {
6721
- autoFocus: !disabled,
6722
- disabled,
6723
- value: url,
6724
- appearance: "underline",
6725
- placeholder: "Add Youtube video URL",
6726
- onChange: (_, v) => setURL(v.value)
6727
- }
6728
- ) }) }) }),
6729
- /* @__PURE__ */ jsxs(DialogActions, { children: [
6730
- /* @__PURE__ */ jsx(Button, { size: "small", disabled: disabled || !url, onClick: onHandleEmbeded, children: "Add" }),
6731
- /* @__PURE__ */ jsx(Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
6732
- ] })
6733
- ] }) })
6734
- ]
6735
- }
6736
- );
6786
+ value: url,
6787
+ appearance: "underline",
6788
+ placeholder: "Add Youtube video URL",
6789
+ onChange: (_, v) => setURL(v.value)
6790
+ }
6791
+ ) }) })
6792
+ }
6793
+ )
6794
+ ] });
6737
6795
  };
6738
6796
  var TextAlphaListLtrFilled = ({ style }) => /* @__PURE__ */ jsxs("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", style, children: [
6739
6797
  /* @__PURE__ */ jsx("path", { d: "M8.75 4a.75.75 0 1 0 0 1.5h7.5a.75.75 0 0 0 0-1.5h-7.5Z" }),
@@ -6815,8 +6873,9 @@ var ToolBarPlugins = (props) => {
6815
6873
  const [isLowercase, setIsLowercase] = useState(false);
6816
6874
  const [isCapitalize, setIsCapitalize] = useState(false);
6817
6875
  const [alignment, setAlignment] = useState("left");
6876
+ const [hasTextSelection, setHasTextSelection] = useState(false);
6818
6877
  const [decoratorOpen, setDecoratorOpen] = useState(false);
6819
- const decoratorSelectingRef = React9__default.useRef(false);
6878
+ const decoratorSelectingRef = React10__default.useRef(false);
6820
6879
  const presetGroups = props.customToolbar ?? getToolbarGroupsByLevel(props.level);
6821
6880
  const pluginGroups = useMemo(() => sanitizePluginGroups(presetGroups), [presetGroups]);
6822
6881
  const updateToolbarPlugins = () => {
@@ -6833,8 +6892,10 @@ var ToolBarPlugins = (props) => {
6833
6892
  setIsLowercase(false);
6834
6893
  setIsCapitalize(false);
6835
6894
  setSelectNodeType("paragraph");
6895
+ setHasTextSelection(false);
6836
6896
  return;
6837
6897
  }
6898
+ setHasTextSelection(!selection.isCollapsed());
6838
6899
  setIsBold(selection.hasFormat("bold"));
6839
6900
  setIsItalic(selection.hasFormat("italic"));
6840
6901
  setIsUnderline(selection.hasFormat("underline"));
@@ -6886,7 +6947,7 @@ var ToolBarPlugins = (props) => {
6886
6947
  }
6887
6948
  });
6888
6949
  };
6889
- React9__default.useEffect(() => {
6950
+ React10__default.useEffect(() => {
6890
6951
  return mergeRegister(
6891
6952
  editor.registerEditableListener((editable) => {
6892
6953
  setIsEditable(editable);
@@ -7090,7 +7151,7 @@ var ToolBarPlugins = (props) => {
7090
7151
  return /* @__PURE__ */ jsx(
7091
7152
  InsertLinkPlugin,
7092
7153
  {
7093
- disabled: !isEditable || props.readOnly,
7154
+ disabled: !isEditable || props.readOnly || !hasTextSelection,
7094
7155
  setIsLinkEditMode: props.setIsLinkEditMode
7095
7156
  },
7096
7157
  key
@@ -7760,7 +7821,7 @@ var ToolBarPlugins = (props) => {
7760
7821
  padding: "0px",
7761
7822
  minHeight: 36
7762
7823
  },
7763
- children: pluginGroups.map((group, groupIndex) => /* @__PURE__ */ jsx(React9__default.Fragment, { children: group.map((token, tokenIndex) => {
7824
+ children: pluginGroups.map((group, groupIndex) => /* @__PURE__ */ jsx(React10__default.Fragment, { children: group.map((token, tokenIndex) => {
7764
7825
  try {
7765
7826
  return renderToken(token, groupIndex, tokenIndex);
7766
7827
  } catch {
@@ -8087,12 +8148,12 @@ function EditorReadyPlugin({ onReady }) {
8087
8148
  var ContentEditorComponent = forwardRef(
8088
8149
  (props, ref) => {
8089
8150
  const isReadOnly = !!props.readOnly;
8090
- const resolvedSpellCheck = React9__default.useMemo(
8151
+ const resolvedSpellCheck = React10__default.useMemo(
8091
8152
  () => props.spellCheckFn ? _makeSpellCheckFn(props.spellCheckFn) : props.useSpellCheck,
8092
8153
  // eslint-disable-next-line react-hooks/exhaustive-deps
8093
8154
  [props.spellCheckFn, props.useSpellCheck]
8094
8155
  );
8095
- const resolvedQuery = React9__default.useMemo(
8156
+ const resolvedQuery = React10__default.useMemo(
8096
8157
  () => props.suggestFn ? _makeQueryFn(props.suggestFn) : props.useQuery,
8097
8158
  // eslint-disable-next-line react-hooks/exhaustive-deps
8098
8159
  [props.suggestFn, props.useQuery]
@@ -8120,7 +8181,7 @@ var ContentEditorComponent = forwardRef(
8120
8181
  const onAnchorRef = (elem) => {
8121
8182
  if (elem) setFloatingAnchorElem(elem);
8122
8183
  };
8123
- const initialConfig = React9__default.useMemo(() => {
8184
+ const initialConfig = React10__default.useMemo(() => {
8124
8185
  const config = {
8125
8186
  namespace: props.namespace ?? "",
8126
8187
  theme,
@@ -8156,8 +8217,13 @@ var ContentEditorComponent = forwardRef(
8156
8217
  color: "var(--colorNeutralForeground3, grey)",
8157
8218
  position: "absolute",
8158
8219
  top: props.level !== "none" /* None */ ? "17px" : "27px",
8159
- left: pageCanvas.paddingPx,
8160
- right: pageCanvas.paddingPx,
8220
+ left: 0,
8221
+ right: 0,
8222
+ maxWidth: pageCanvas.widthPx,
8223
+ marginLeft: pageCanvas.widthPx !== void 0 ? "auto" : void 0,
8224
+ marginRight: pageCanvas.widthPx !== void 0 ? "auto" : void 0,
8225
+ paddingLeft: pageCanvas.paddingPx,
8226
+ paddingRight: pageCanvas.paddingPx,
8161
8227
  fontSize: "14px",
8162
8228
  pointerEvents: "none",
8163
8229
  userSelect: "none"
@@ -8205,7 +8271,7 @@ var ContentEditorComponent = forwardRef(
8205
8271
  previousOverLimitRef.current = isOverLimit;
8206
8272
  }
8207
8273
  }, [isOverLimit, wordCount, props.wordLimit, props.onWordLimitExceeded]);
8208
- const validationErrors = React9__default.useMemo(() => {
8274
+ const validationErrors = React10__default.useMemo(() => {
8209
8275
  const errors = [];
8210
8276
  const custom = props.validationMessages ?? {};
8211
8277
  const { words, chars, images, links, tables } = metrics;
@@ -8274,7 +8340,7 @@ var ContentEditorComponent = forwardRef(
8274
8340
  const trimmedErrorMessage = props.errorMessage?.trim() || "";
8275
8341
  const hasValidationError = validationErrors.length > 0 || !!trimmedErrorMessage;
8276
8342
  return /* @__PURE__ */ jsx(FluentProvider, { theme: webLightTheme, style: { height: "100%" }, children: /* @__PURE__ */ jsxs(LexicalComposer, { initialConfig, children: [
8277
- /* @__PURE__ */ jsx("div", { ref: containerRef, className: "lexical-rich-editor-root", style: { height: "100%" }, children: /* @__PURE__ */ jsxs(
8343
+ /* @__PURE__ */ jsx("div", { ref: containerRef, className: "lexical-rich-editor-root", style: { height: "100%", position: "relative" }, children: /* @__PURE__ */ jsxs(
8278
8344
  Stack,
8279
8345
  {
8280
8346
  style: {