@lexical/react 0.15.0 → 0.16.0

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.
Files changed (118) hide show
  1. package/LexicalAutoEmbedPlugin.dev.js +12 -24
  2. package/LexicalAutoEmbedPlugin.dev.mjs +2 -2
  3. package/LexicalAutoEmbedPlugin.prod.js +4 -5
  4. package/LexicalAutoEmbedPlugin.prod.mjs +1 -1
  5. package/LexicalBlockWithAlignableContents.dev.js +9 -20
  6. package/LexicalBlockWithAlignableContents.dev.mjs +5 -4
  7. package/LexicalBlockWithAlignableContents.prod.js +4 -4
  8. package/LexicalBlockWithAlignableContents.prod.mjs +1 -1
  9. package/LexicalCharacterLimitPlugin.dev.js +10 -22
  10. package/LexicalCharacterLimitPlugin.dev.mjs +5 -5
  11. package/LexicalCharacterLimitPlugin.prod.js +9 -9
  12. package/LexicalCharacterLimitPlugin.prod.mjs +1 -1
  13. package/LexicalCheckListPlugin.dev.js +2 -0
  14. package/LexicalCheckListPlugin.dev.mjs +2 -0
  15. package/LexicalCheckListPlugin.prod.js +2 -2
  16. package/LexicalCheckListPlugin.prod.mjs +1 -1
  17. package/LexicalClearEditorPlugin.dev.js +4 -0
  18. package/LexicalClearEditorPlugin.dev.mjs +4 -0
  19. package/LexicalClickableLinkPlugin.d.ts +3 -1
  20. package/LexicalClickableLinkPlugin.dev.js +3 -2
  21. package/LexicalClickableLinkPlugin.dev.mjs +2 -2
  22. package/LexicalClickableLinkPlugin.js.flow +3 -1
  23. package/LexicalClickableLinkPlugin.mjs +1 -0
  24. package/LexicalClickableLinkPlugin.node.mjs +1 -0
  25. package/LexicalClickableLinkPlugin.prod.js +4 -3
  26. package/LexicalClickableLinkPlugin.prod.mjs +1 -1
  27. package/LexicalCollaborationPlugin.dev.js +2 -1
  28. package/LexicalCollaborationPlugin.dev.mjs +2 -1
  29. package/LexicalCollaborationPlugin.prod.js +9 -9
  30. package/LexicalCollaborationPlugin.prod.mjs +1 -1
  31. package/LexicalComposer.dev.js +12 -19
  32. package/LexicalComposer.dev.mjs +9 -4
  33. package/LexicalComposer.prod.js +3 -4
  34. package/LexicalComposer.prod.mjs +1 -1
  35. package/LexicalContentEditable.dev.js +20 -34
  36. package/LexicalContentEditable.dev.mjs +16 -18
  37. package/LexicalContentEditable.prod.js +3 -4
  38. package/LexicalContentEditable.prod.mjs +1 -1
  39. package/LexicalContextMenuPlugin.dev.js +6 -1
  40. package/LexicalContextMenuPlugin.dev.mjs +6 -1
  41. package/LexicalContextMenuPlugin.prod.js +15 -15
  42. package/LexicalContextMenuPlugin.prod.mjs +1 -1
  43. package/LexicalErrorBoundary.d.ts +3 -1
  44. package/LexicalErrorBoundary.dev.js +11 -7
  45. package/LexicalErrorBoundary.dev.mjs +10 -7
  46. package/LexicalErrorBoundary.js.flow +4 -1
  47. package/LexicalErrorBoundary.mjs +1 -0
  48. package/LexicalErrorBoundary.node.mjs +1 -0
  49. package/LexicalErrorBoundary.prod.js +4 -4
  50. package/LexicalErrorBoundary.prod.mjs +1 -1
  51. package/LexicalHorizontalRuleNode.d.ts +2 -2
  52. package/LexicalHorizontalRuleNode.dev.js +16 -21
  53. package/LexicalHorizontalRuleNode.dev.mjs +13 -6
  54. package/LexicalHorizontalRuleNode.prod.js +5 -5
  55. package/LexicalHorizontalRuleNode.prod.mjs +1 -1
  56. package/LexicalNestedComposer.dev.js +11 -22
  57. package/LexicalNestedComposer.dev.mjs +5 -4
  58. package/LexicalNestedComposer.prod.js +5 -5
  59. package/LexicalNestedComposer.prod.mjs +1 -1
  60. package/LexicalNodeMenuPlugin.dev.js +6 -1
  61. package/LexicalNodeMenuPlugin.dev.mjs +6 -1
  62. package/LexicalNodeMenuPlugin.prod.js +13 -13
  63. package/LexicalNodeMenuPlugin.prod.mjs +1 -1
  64. package/LexicalOnChangePlugin.dev.js +4 -0
  65. package/LexicalOnChangePlugin.dev.mjs +4 -0
  66. package/LexicalPlainTextPlugin.dev.js +24 -28
  67. package/LexicalPlainTextPlugin.dev.mjs +19 -11
  68. package/LexicalPlainTextPlugin.js.flow +1 -1
  69. package/LexicalPlainTextPlugin.prod.js +4 -4
  70. package/LexicalPlainTextPlugin.prod.mjs +1 -1
  71. package/LexicalRichTextPlugin.dev.js +24 -28
  72. package/LexicalRichTextPlugin.dev.mjs +19 -11
  73. package/LexicalRichTextPlugin.js.flow +1 -1
  74. package/LexicalRichTextPlugin.prod.js +4 -4
  75. package/LexicalRichTextPlugin.prod.mjs +1 -1
  76. package/LexicalTableOfContents.d.ts +6 -13
  77. package/LexicalTableOfContents.dev.js +10 -2
  78. package/LexicalTableOfContents.dev.mjs +10 -2
  79. package/LexicalTableOfContents.js.flow +3 -7
  80. package/LexicalTableOfContents.prod.js +1 -1
  81. package/LexicalTableOfContentsPlugin.d.ts +20 -0
  82. package/LexicalTableOfContentsPlugin.dev.js +198 -0
  83. package/LexicalTableOfContentsPlugin.dev.mjs +196 -0
  84. package/LexicalTableOfContentsPlugin.js +11 -0
  85. package/LexicalTableOfContentsPlugin.js.flow +18 -0
  86. package/LexicalTableOfContentsPlugin.mjs +12 -0
  87. package/LexicalTableOfContentsPlugin.node.mjs +10 -0
  88. package/LexicalTableOfContentsPlugin.prod.js +12 -0
  89. package/LexicalTableOfContentsPlugin.prod.mjs +9 -0
  90. package/LexicalTreeView.d.ts +3 -1
  91. package/LexicalTreeView.dev.js +5 -3
  92. package/LexicalTreeView.dev.mjs +5 -3
  93. package/LexicalTreeView.js.flow +2 -0
  94. package/LexicalTreeView.prod.js +3 -3
  95. package/LexicalTreeView.prod.mjs +1 -1
  96. package/LexicalTypeaheadMenuPlugin.dev.js +6 -1
  97. package/LexicalTypeaheadMenuPlugin.dev.mjs +6 -1
  98. package/LexicalTypeaheadMenuPlugin.prod.js +17 -17
  99. package/LexicalTypeaheadMenuPlugin.prod.mjs +1 -1
  100. package/package.json +50 -20
  101. package/useLexicalEditable.d.ts +11 -1
  102. package/useLexicalEditable.dev.js +16 -1
  103. package/useLexicalEditable.dev.mjs +15 -1
  104. package/useLexicalEditable.js.flow +4 -1
  105. package/useLexicalEditable.mjs +2 -1
  106. package/useLexicalEditable.node.mjs +2 -1
  107. package/useLexicalEditable.prod.js +1 -1
  108. package/useLexicalEditable.prod.mjs +1 -1
  109. package/useLexicalIsTextContentEmpty.dev.js +4 -0
  110. package/useLexicalIsTextContentEmpty.dev.mjs +4 -0
  111. package/useLexicalSubscription.d.ts +4 -1
  112. package/useLexicalSubscription.dev.js +7 -1
  113. package/useLexicalSubscription.dev.mjs +6 -1
  114. package/useLexicalSubscription.js.flow +4 -1
  115. package/useLexicalSubscription.mjs +2 -1
  116. package/useLexicalSubscription.node.mjs +2 -1
  117. package/useLexicalSubscription.prod.js +2 -2
  118. package/useLexicalSubscription.prod.mjs +1 -1
@@ -6,6 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var e=require("@lexical/link"),m=require("@lexical/react/LexicalComposerContext"),r=require("@lexical/utils"),t=require("lexical"),u=require("react");
10
- module.exports=function({newTab:n=!0,disabled:p=!1}){let [h]=m.useLexicalComposerContext();u.useEffect(()=>{let l=b=>{const c=b.target;if(c instanceof Node){var d=t.getNearestEditorFromDOMNode(c);if(null!==d){var f=null,k=null;d.update(()=>{var a=t.$getNearestNodeFromDOMNode(c);if(null!==a&&(a=r.$findMatchingParent(a,t.$isElementNode),!p))if(e.$isLinkNode(a))f=a.sanitizeUrl(a.getURL()),k=a.getTarget();else{a:{a=r.isHTMLAnchorElement;let g=c;for(;null!=g;){if(a(g)){a=g;break a}g=g.parentNode}a=null}null!==
11
- a&&(f=a.href,k=a.target)}});if(null!==f&&""!==f){d=h.getEditorState().read(t.$getSelection);if(!t.$isRangeSelection(d)||d.isCollapsed())d="auxclick"===b.type&&1===b.button,window.open(f,n||d||b.metaKey||b.ctrlKey||"_blank"===k?"_blank":"_self");b.preventDefault()}}}},q=b=>{1===b.button&&l(b)};return h.registerRootListener((b,c)=>{null!==c&&(c.removeEventListener("click",l),c.removeEventListener("mouseup",q));null!==b&&(b.addEventListener("click",l),b.addEventListener("mouseup",q))})},[h,n,p]);return null}
9
+ 'use strict';var e=require("@lexical/link"),m=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),t=require("lexical"),u=require("react");
10
+ function v({newTab:p=!0,disabled:q=!1}){let [h]=m.useLexicalComposerContext();u.useEffect(()=>{let l=b=>{const c=b.target;if(c instanceof Node){var d=t.getNearestEditorFromDOMNode(c);if(null!==d){var f=null,k=null;d.update(()=>{var a=t.$getNearestNodeFromDOMNode(c);if(null!==a&&(a=n.$findMatchingParent(a,t.$isElementNode),!q))if(e.$isLinkNode(a))f=a.sanitizeUrl(a.getURL()),k=a.getTarget();else{a:{a=n.isHTMLAnchorElement;let g=c;for(;null!=g;){if(a(g)){a=g;break a}g=g.parentNode}a=null}null!==a&&(f=
11
+ a.href,k=a.target)}});if(null!==f&&""!==f){d=h.getEditorState().read(t.$getSelection);if(!t.$isRangeSelection(d)||d.isCollapsed())d="auxclick"===b.type&&1===b.button,window.open(f,p||d||b.metaKey||b.ctrlKey||"_blank"===k?"_blank":"_self");b.preventDefault()}}}},r=b=>{1===b.button&&l(b)};return h.registerRootListener((b,c)=>{null!==c&&(c.removeEventListener("click",l),c.removeEventListener("mouseup",r));null!==b&&(b.addEventListener("click",l),b.addEventListener("mouseup",r))})},[h,p,q]);return null}
12
+ exports.ClickableLinkPlugin=v;exports.default=v
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$isLinkNode as e}from"@lexical/link";import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as n,isHTMLAnchorElement as r}from"@lexical/utils";import{getNearestEditorFromDOMNode as l,$getNearestNodeFromDOMNode as o,$isElementNode as i,$getSelection as u,$isRangeSelection as a}from"lexical";import{useEffect as s}from"react";function c({newTab:c=!0,disabled:f=!1}){const[m]=t();return s((()=>{const t=t=>{const s=t.target;if(!(s instanceof Node))return;const p=l(s);if(null===p)return;let d=null,v=null;if(p.update((()=>{const t=o(s);if(null!==t){const l=n(t,i);if(!f)if(e(l))d=l.sanitizeUrl(l.getURL()),v=l.getTarget();else{const e=function(e,t){let n=e;for(;null!=n;){if(t(n))return n;n=n.parentNode}return null}(s,r);null!==e&&(d=e.href,v=e.target)}}})),null===d||""===d)return;const x=m.getEditorState().read(u);if(a(x)&&!x.isCollapsed())return void t.preventDefault();const g="auxclick"===t.type&&1===t.button;window.open(d,c||g||t.metaKey||t.ctrlKey||"_blank"===v?"_blank":"_self"),t.preventDefault()},s=e=>{1===e.button&&t(e)};return m.registerRootListener(((e,n)=>{null!==n&&(n.removeEventListener("click",t),n.removeEventListener("mouseup",s)),null!==e&&(e.addEventListener("click",t),e.addEventListener("mouseup",s))}))}),[m,c,f]),null}export{c as default};
9
+ import{$isLinkNode as e}from"@lexical/link";import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as n,isHTMLAnchorElement as r}from"@lexical/utils";import{getNearestEditorFromDOMNode as l,$getNearestNodeFromDOMNode as o,$isElementNode as i,$getSelection as u,$isRangeSelection as a}from"lexical";import{useEffect as s}from"react";function c({newTab:c=!0,disabled:f=!1}){const[m]=t();return s((()=>{const t=t=>{const s=t.target;if(!(s instanceof Node))return;const p=l(s);if(null===p)return;let d=null,v=null;if(p.update((()=>{const t=o(s);if(null!==t){const l=n(t,i);if(!f)if(e(l))d=l.sanitizeUrl(l.getURL()),v=l.getTarget();else{const e=function(e,t){let n=e;for(;null!=n;){if(t(n))return n;n=n.parentNode}return null}(s,r);null!==e&&(d=e.href,v=e.target)}}})),null===d||""===d)return;const x=m.getEditorState().read(u);if(a(x)&&!x.isCollapsed())return void t.preventDefault();const g="auxclick"===t.type&&1===t.button;window.open(d,c||g||t.metaKey||t.ctrlKey||"_blank"===v?"_blank":"_self"),t.preventDefault()},s=e=>{1===e.button&&t(e)};return m.registerRootListener(((e,n)=>{null!==n&&(n.removeEventListener("click",t),n.removeEventListener("mouseup",s)),null!==e&&(e.addEventListener("click",t),e.addEventListener("mouseup",s))}))}),[m,c,f]),null}export{c as ClickableLinkPlugin,c as default};
@@ -16,6 +16,7 @@ var yjs = require('@lexical/yjs');
16
16
  var lexical = require('lexical');
17
17
  var reactDom = require('react-dom');
18
18
  var yjs$1 = require('yjs');
19
+ var jsxRuntime = require('react/jsx-runtime');
19
20
 
20
21
  function _interopNamespaceDefault(e) {
21
22
  var n = Object.create(null);
@@ -123,7 +124,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
123
124
  const ref = element => {
124
125
  binding.cursorsContainer = element;
125
126
  };
126
- return /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__namespace.createElement("div", {
127
+ return /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/jsxRuntime.jsx("div", {
127
128
  ref: ref
128
129
  }), cursorsContainerRef && cursorsContainerRef.current || document.body);
129
130
  }, [binding, cursorsContainerRef]);
@@ -15,6 +15,7 @@ import { createBinding, initLocalState, syncLexicalUpdateToYjs, TOGGLE_CONNECT_C
15
15
  import { COMMAND_PRIORITY_EDITOR, FOCUS_COMMAND, BLUR_COMMAND, UNDO_COMMAND, REDO_COMMAND, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $getRoot, $createParagraphNode, $getSelection } from 'lexical';
16
16
  import { createPortal } from 'react-dom';
17
17
  import { UndoManager } from 'yjs';
18
+ import { jsx } from 'react/jsx-runtime';
18
19
 
19
20
  /**
20
21
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -109,7 +110,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
109
110
  const ref = element => {
110
111
  binding.cursorsContainer = element;
111
112
  };
112
- return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", {
113
+ return /*#__PURE__*/createPortal( /*#__PURE__*/jsx("div", {
113
114
  ref: ref
114
115
  }), cursorsContainerRef && cursorsContainerRef.current || document.body);
115
116
  }, [binding, cursorsContainerRef]);
@@ -6,13 +6,13 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var e=require("@lexical/react/LexicalCollaborationContext"),g=require("@lexical/react/LexicalComposerContext"),k=require("react"),z=require("@lexical/utils"),C=require("@lexical/yjs"),D=require("lexical"),L=require("react-dom"),M=require("yjs"),N=Object.create(null);if(k)for(var O in k)N[O]=k[O];N.default=k;
10
- function P(b,c,a,d,f,A,B,v,w,n,t){let q=k.useRef(!1),[x,r]=k.useState(d.get(c)),h=k.useMemo(()=>C.createBinding(b,a,c,x,d,n),[b,a,c,d,x,n]),p=k.useCallback(()=>{a.connect()},[a]),y=k.useCallback(()=>{try{a.disconnect()}catch(m){}},[a]);k.useEffect(()=>{let {root:m}=h,{awareness:E}=a,F=({status:l})=>{b.dispatchCommand(C.CONNECTED_COMMAND,"connected"===l)},G=l=>{B&&l&&m.isEmpty()&&0===m._xmlText._length&&!1===q.current&&Q(b,w);q.current=!1},H=()=>{C.syncCursorPositions(h,a)},I=(l,u)=>{u=u.origin;u!==
11
- h&&C.syncYjsChangesToLexical(h,a,l,u instanceof M.UndoManager)};C.initLocalState(a,f,A,document.activeElement===b.getRootElement(),t||{});let J=l=>{R(b,h);r(l);d.set(c,l);q.current=!0};a.on("reload",J);a.on("status",F);a.on("sync",G);E.on("update",H);m.getSharedType().observeDeep(I);let V=b.registerUpdateListener(({prevEditorState:l,editorState:u,dirtyLeaves:S,dirtyElements:T,normalizedNodes:U,tags:K})=>{!1===K.has("skip-collab")&&C.syncLexicalUpdateToYjs(h,a,l,u,T,S,U,K)});p();return()=>{!1===q.current&&
12
- y();a.off("sync",G);a.off("status",F);a.off("reload",J);E.off("update",H);m.getSharedType().unobserveDeep(I);d.delete(c);V()}},[h,A,p,y,d,b,c,w,f,a,B,t]);let W=k.useMemo(()=>L.createPortal(N.createElement("div",{ref:m=>{h.cursorsContainer=m}}),v&&v.current||document.body),[h,v]);k.useEffect(()=>b.registerCommand(C.TOGGLE_CONNECT_COMMAND,m=>{void 0!==p&&void 0!==y&&(m?(console.log("Collaboration connected!"),p()):(console.log("Collaboration disconnected!"),y()));return!0},D.COMMAND_PRIORITY_EDITOR),
13
- [p,y,b]);return[W,h]}function X(b,c,a,d,f){k.useEffect(()=>z.mergeRegister(b.registerCommand(D.FOCUS_COMMAND,()=>{C.setLocalStateFocus(c,a,d,!0,f||{});return!1},D.COMMAND_PRIORITY_EDITOR),b.registerCommand(D.BLUR_COMMAND,()=>{C.setLocalStateFocus(c,a,d,!1,f||{});return!1},D.COMMAND_PRIORITY_EDITOR)),[d,b,a,c,f])}
14
- function Y(b,c){let a=k.useMemo(()=>C.createUndoManager(c,c.root.getSharedType()),[c]);k.useEffect(()=>z.mergeRegister(b.registerCommand(D.UNDO_COMMAND,()=>{a.undo();return!0},D.COMMAND_PRIORITY_EDITOR),b.registerCommand(D.REDO_COMMAND,()=>{a.redo();return!0},D.COMMAND_PRIORITY_EDITOR)));let d=k.useCallback(()=>{a.clear()},[a]);N.useEffect(()=>{let f=()=>{b.dispatchCommand(D.CAN_UNDO_COMMAND,0<a.undoStack.length);b.dispatchCommand(D.CAN_REDO_COMMAND,0<a.redoStack.length)};a.on("stack-item-added",
9
+ 'use strict';var e=require("@lexical/react/LexicalCollaborationContext"),g=require("@lexical/react/LexicalComposerContext"),k=require("react"),B=require("@lexical/utils"),C=require("@lexical/yjs"),D=require("lexical"),L=require("react-dom"),M=require("yjs"),N=require("react/jsx-runtime"),O=Object.create(null);if(k)for(var P in k)O[P]=k[P];O.default=k;
10
+ function Q(b,c,a,d,f,z,A,v,w,n,t){let q=k.useRef(!1),[x,r]=k.useState(d.get(c)),h=k.useMemo(()=>C.createBinding(b,a,c,x,d,n),[b,a,c,d,x,n]),p=k.useCallback(()=>{a.connect()},[a]),y=k.useCallback(()=>{try{a.disconnect()}catch(m){}},[a]);k.useEffect(()=>{let {root:m}=h,{awareness:E}=a,F=({status:l})=>{b.dispatchCommand(C.CONNECTED_COMMAND,"connected"===l)},G=l=>{A&&l&&m.isEmpty()&&0===m._xmlText._length&&!1===q.current&&R(b,w);q.current=!1},H=()=>{C.syncCursorPositions(h,a)},I=(l,u)=>{u=u.origin;u!==
11
+ h&&C.syncYjsChangesToLexical(h,a,l,u instanceof M.UndoManager)};C.initLocalState(a,f,z,document.activeElement===b.getRootElement(),t||{});let J=l=>{S(b,h);r(l);d.set(c,l);q.current=!0};a.on("reload",J);a.on("status",F);a.on("sync",G);E.on("update",H);m.getSharedType().observeDeep(I);let W=b.registerUpdateListener(({prevEditorState:l,editorState:u,dirtyLeaves:T,dirtyElements:U,normalizedNodes:V,tags:K})=>{!1===K.has("skip-collab")&&C.syncLexicalUpdateToYjs(h,a,l,u,U,T,V,K)});p();return()=>{!1===q.current&&
12
+ y();a.off("sync",G);a.off("status",F);a.off("reload",J);E.off("update",H);m.getSharedType().unobserveDeep(I);d.delete(c);W()}},[h,z,p,y,d,b,c,w,f,a,A,t]);let X=k.useMemo(()=>L.createPortal(N.jsx("div",{ref:m=>{h.cursorsContainer=m}}),v&&v.current||document.body),[h,v]);k.useEffect(()=>b.registerCommand(C.TOGGLE_CONNECT_COMMAND,m=>{void 0!==p&&void 0!==y&&(m?(console.log("Collaboration connected!"),p()):(console.log("Collaboration disconnected!"),y()));return!0},D.COMMAND_PRIORITY_EDITOR),[p,y,b]);
13
+ return[X,h]}function Y(b,c,a,d,f){k.useEffect(()=>B.mergeRegister(b.registerCommand(D.FOCUS_COMMAND,()=>{C.setLocalStateFocus(c,a,d,!0,f||{});return!1},D.COMMAND_PRIORITY_EDITOR),b.registerCommand(D.BLUR_COMMAND,()=>{C.setLocalStateFocus(c,a,d,!1,f||{});return!1},D.COMMAND_PRIORITY_EDITOR)),[d,b,a,c,f])}
14
+ function Z(b,c){let a=k.useMemo(()=>C.createUndoManager(c,c.root.getSharedType()),[c]);k.useEffect(()=>B.mergeRegister(b.registerCommand(D.UNDO_COMMAND,()=>{a.undo();return!0},D.COMMAND_PRIORITY_EDITOR),b.registerCommand(D.REDO_COMMAND,()=>{a.redo();return!0},D.COMMAND_PRIORITY_EDITOR)));let d=k.useCallback(()=>{a.clear()},[a]);O.useEffect(()=>{let f=()=>{b.dispatchCommand(D.CAN_UNDO_COMMAND,0<a.undoStack.length);b.dispatchCommand(D.CAN_REDO_COMMAND,0<a.redoStack.length)};a.on("stack-item-added",
15
15
  f);a.on("stack-item-popped",f);a.on("stack-cleared",f);return()=>{a.off("stack-item-added",f);a.off("stack-item-popped",f);a.off("stack-cleared",f)}},[b,a]);return d}
16
- function Q(b,c){b.update(()=>{var a=D.$getRoot();if(a.isEmpty())if(c)switch(typeof c){case "string":var d=b.parseEditorState(c);b.setEditorState(d,{tag:"history-merge"});break;case "object":b.setEditorState(c,{tag:"history-merge"});break;case "function":b.update(()=>{D.$getRoot().isEmpty()&&c(b)},{tag:"history-merge"})}else d=D.$createParagraphNode(),a.append(d),{activeElement:a}=document,(null!==D.$getSelection()||null!==a&&a===b.getRootElement())&&d.select()},{tag:"history-merge"})}
17
- function R(b,c){b.update(()=>{let d=D.$getRoot();d.clear();d.select()},{tag:"skip-collab"});if(null!=c.cursors&&(b=c.cursors,null!=b&&(c=c.cursorsContainer,null!=c))){b=Array.from(b.values());for(let d=0;d<b.length;d++){var a=b[d].selection;if(a&&null!=a.selections){a=a.selections;for(let f=0;f<a.length;f++)c.removeChild(a[d])}}}}
18
- exports.CollaborationPlugin=function({id:b,providerFactory:c,shouldBootstrap:a,username:d,cursorColor:f,cursorsContainerRef:A,initialEditorState:B,excludedProperties:v,awarenessData:w}){let n=e.useCollaborationContext(d,f),{yjsDocMap:t,name:q,color:x}=n,[r]=g.useLexicalComposerContext();k.useEffect(()=>{n.isCollabActive=!0;return()=>{null==r._parentEditor&&(n.isCollabActive=!1)}},[n,r]);d=k.useMemo(()=>c(b,t),[b,c,t]);let [h,p]=P(r,b,d,t,q,x,a,A,B,v,w);n.clientID=p.clientID;Y(r,p);X(r,d,q,x,w);return h}
16
+ function R(b,c){b.update(()=>{var a=D.$getRoot();if(a.isEmpty())if(c)switch(typeof c){case "string":var d=b.parseEditorState(c);b.setEditorState(d,{tag:"history-merge"});break;case "object":b.setEditorState(c,{tag:"history-merge"});break;case "function":b.update(()=>{D.$getRoot().isEmpty()&&c(b)},{tag:"history-merge"})}else d=D.$createParagraphNode(),a.append(d),{activeElement:a}=document,(null!==D.$getSelection()||null!==a&&a===b.getRootElement())&&d.select()},{tag:"history-merge"})}
17
+ function S(b,c){b.update(()=>{let d=D.$getRoot();d.clear();d.select()},{tag:"skip-collab"});if(null!=c.cursors&&(b=c.cursors,null!=b&&(c=c.cursorsContainer,null!=c))){b=Array.from(b.values());for(let d=0;d<b.length;d++){var a=b[d].selection;if(a&&null!=a.selections){a=a.selections;for(let f=0;f<a.length;f++)c.removeChild(a[d])}}}}
18
+ exports.CollaborationPlugin=function({id:b,providerFactory:c,shouldBootstrap:a,username:d,cursorColor:f,cursorsContainerRef:z,initialEditorState:A,excludedProperties:v,awarenessData:w}){let n=e.useCollaborationContext(d,f),{yjsDocMap:t,name:q,color:x}=n,[r]=g.useLexicalComposerContext();k.useEffect(()=>{n.isCollabActive=!0;return()=>{null==r._parentEditor&&(n.isCollabActive=!1)}},[n,r]);d=k.useMemo(()=>c(b,t),[b,c,t]);let [h,p]=Q(r,b,d,t,q,x,a,z,A,v,w);n.clientID=p.clientID;Z(r,p);Y(r,d,q,x,w);return h}
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useCollaborationContext as e}from"@lexical/react/LexicalCollaborationContext";import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import*as o from"react";import{useRef as r,useState as n,useMemo as s,useCallback as c,useEffect as a}from"react";import{mergeRegister as i}from"@lexical/utils";import{createBinding as l,initLocalState as d,syncLexicalUpdateToYjs as m,TOGGLE_CONNECT_COMMAND as u,setLocalStateFocus as f,createUndoManager as p,CONNECTED_COMMAND as g,syncCursorPositions as y,syncYjsChangesToLexical as C}from"@lexical/yjs";import{COMMAND_PRIORITY_EDITOR as h,FOCUS_COMMAND as E,BLUR_COMMAND as v,UNDO_COMMAND as b,REDO_COMMAND as x,CAN_UNDO_COMMAND as k,CAN_REDO_COMMAND as S,$getRoot as D,$createParagraphNode as j,$getSelection as L}from"lexical";import{createPortal as T}from"react-dom";import{UndoManager as w}from"yjs";function A(e,t,i,f,p,E,v,b,x,k,S){const A=r(!1),[R,_]=n(f.get(t)),I=s((()=>l(e,i,t,R,f,k)),[e,i,t,f,R,k]),z=c((()=>{i.connect()}),[i]),B=c((()=>{try{i.disconnect()}catch(e){}}),[i]);a((()=>{const{root:o}=I,{awareness:r}=i,n=({status:t})=>{e.dispatchCommand(g,"connected"===t)},s=t=>{v&&t&&o.isEmpty()&&0===o._xmlText._length&&!1===A.current&&function(e,t){e.update((()=>{const o=D();if(o.isEmpty())if(t)switch(typeof t){case"string":{const o=e.parseEditorState(t);e.setEditorState(o,{tag:"history-merge"});break}case"object":e.setEditorState(t,{tag:"history-merge"});break;case"function":e.update((()=>{D().isEmpty()&&t(e)}),{tag:"history-merge"})}else{const t=j();o.append(t);const{activeElement:r}=document;(null!==L()||null!==r&&r===e.getRootElement())&&t.select()}}),{tag:"history-merge"})}(e,x),A.current=!1},c=()=>{y(I,i)},a=(e,t)=>{const o=t.origin;if(o!==I){C(I,i,e,o instanceof w)}};d(i,p,E,document.activeElement===e.getRootElement(),S||{});const l=o=>{!function(e,t){if(e.update((()=>{const e=D();e.clear(),e.select()}),{tag:"skip-collab"}),null==t.cursors)return;const o=t.cursors;if(null==o)return;const r=t.cursorsContainer;if(null==r)return;const n=Array.from(o.values());for(let e=0;e<n.length;e++){const t=n[e].selection;if(t&&null!=t.selections){const o=t.selections;for(let t=0;t<o.length;t++)r.removeChild(o[e])}}}(e,I),_(o),f.set(t,o),A.current=!0};i.on("reload",l),i.on("status",n),i.on("sync",s),r.on("update",c),o.getSharedType().observeDeep(a);const u=e.registerUpdateListener((({prevEditorState:e,editorState:t,dirtyLeaves:o,dirtyElements:r,normalizedNodes:n,tags:s})=>{!1===s.has("skip-collab")&&m(I,i,e,t,r,o,n,s)}));return z(),()=>{!1===A.current&&B(),i.off("sync",s),i.off("status",n),i.off("reload",l),r.off("update",c),o.getSharedType().unobserveDeep(a),f.delete(t),u()}}),[I,E,z,B,f,e,t,x,p,i,v,S]);const F=s((()=>T(o.createElement("div",{ref:e=>{I.cursorsContainer=e}}),b&&b.current||document.body)),[I,b]);return a((()=>e.registerCommand(u,(e=>{if(void 0!==z&&void 0!==B){e?(console.log("Collaboration connected!"),z()):(console.log("Collaboration disconnected!"),B())}return!0}),h)),[z,B,e]),[F,I]}function R(e,t){const r=s((()=>p(t,t.root.getSharedType())),[t]);a((()=>i(e.registerCommand(b,(()=>(r.undo(),!0)),h),e.registerCommand(x,(()=>(r.redo(),!0)),h))));const n=c((()=>{r.clear()}),[r]);return o.useEffect((()=>{const t=()=>{e.dispatchCommand(k,r.undoStack.length>0),e.dispatchCommand(S,r.redoStack.length>0)};return r.on("stack-item-added",t),r.on("stack-item-popped",t),r.on("stack-cleared",t),()=>{r.off("stack-item-added",t),r.off("stack-item-popped",t),r.off("stack-cleared",t)}}),[e,r]),n}function _({id:o,providerFactory:r,shouldBootstrap:n,username:c,cursorColor:l,cursorsContainerRef:d,initialEditorState:m,excludedProperties:u,awarenessData:p}){const g=e(c,l),{yjsDocMap:y,name:C,color:b}=g,[x]=t();a((()=>(g.isCollabActive=!0,()=>{null==x._parentEditor&&(g.isCollabActive=!1)})),[g,x]);const k=s((()=>r(o,y)),[o,r,y]),[S,D]=A(x,o,k,y,C,b,n,d,m,u,p);return g.clientID=D.clientID,R(x,D),function(e,t,o,r,n){a((()=>i(e.registerCommand(E,(()=>(f(t,o,r,!0,n||{}),!1)),h),e.registerCommand(v,(()=>(f(t,o,r,!1,n||{}),!1)),h))),[r,e,o,t,n])}(x,k,C,b,p),S}export{_ as CollaborationPlugin};
9
+ import{useCollaborationContext as t}from"@lexical/react/LexicalCollaborationContext";import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import*as o from"react";import{useRef as r,useState as n,useMemo as s,useCallback as c,useEffect as a}from"react";import{mergeRegister as i}from"@lexical/utils";import{createBinding as l,initLocalState as d,syncLexicalUpdateToYjs as m,TOGGLE_CONNECT_COMMAND as u,setLocalStateFocus as f,createUndoManager as p,CONNECTED_COMMAND as g,syncCursorPositions as y,syncYjsChangesToLexical as C}from"@lexical/yjs";import{COMMAND_PRIORITY_EDITOR as h,FOCUS_COMMAND as E,BLUR_COMMAND as v,UNDO_COMMAND as x,REDO_COMMAND as b,CAN_UNDO_COMMAND as k,CAN_REDO_COMMAND as S,$getRoot as D,$createParagraphNode as j,$getSelection as L}from"lexical";import{createPortal as T}from"react-dom";import{UndoManager as w}from"yjs";import{jsx as A}from"react/jsx-runtime";function R(t,e,o,i,f,p,E,v,x,b,k){const S=r(!1),[R,_]=n(i.get(e)),I=s((()=>l(t,o,e,R,i,b)),[t,o,e,i,R,b]),z=c((()=>{o.connect()}),[o]),B=c((()=>{try{o.disconnect()}catch(t){}}),[o]);a((()=>{const{root:r}=I,{awareness:n}=o,s=({status:e})=>{t.dispatchCommand(g,"connected"===e)},c=e=>{E&&e&&r.isEmpty()&&0===r._xmlText._length&&!1===S.current&&function(t,e){t.update((()=>{const o=D();if(o.isEmpty())if(e)switch(typeof e){case"string":{const o=t.parseEditorState(e);t.setEditorState(o,{tag:"history-merge"});break}case"object":t.setEditorState(e,{tag:"history-merge"});break;case"function":t.update((()=>{D().isEmpty()&&e(t)}),{tag:"history-merge"})}else{const e=j();o.append(e);const{activeElement:r}=document;(null!==L()||null!==r&&r===t.getRootElement())&&e.select()}}),{tag:"history-merge"})}(t,x),S.current=!1},a=()=>{y(I,o)},l=(t,e)=>{const r=e.origin;if(r!==I){C(I,o,t,r instanceof w)}};d(o,f,p,document.activeElement===t.getRootElement(),k||{});const u=o=>{!function(t,e){if(t.update((()=>{const t=D();t.clear(),t.select()}),{tag:"skip-collab"}),null==e.cursors)return;const o=e.cursors;if(null==o)return;const r=e.cursorsContainer;if(null==r)return;const n=Array.from(o.values());for(let t=0;t<n.length;t++){const e=n[t].selection;if(e&&null!=e.selections){const o=e.selections;for(let e=0;e<o.length;e++)r.removeChild(o[t])}}}(t,I),_(o),i.set(e,o),S.current=!0};o.on("reload",u),o.on("status",s),o.on("sync",c),n.on("update",a),r.getSharedType().observeDeep(l);const h=t.registerUpdateListener((({prevEditorState:t,editorState:e,dirtyLeaves:r,dirtyElements:n,normalizedNodes:s,tags:c})=>{!1===c.has("skip-collab")&&m(I,o,t,e,n,r,s,c)}));return z(),()=>{!1===S.current&&B(),o.off("sync",c),o.off("status",s),o.off("reload",u),n.off("update",a),r.getSharedType().unobserveDeep(l),i.delete(e),h()}}),[I,p,z,B,i,t,e,x,f,o,E,k]);const F=s((()=>T(A("div",{ref:t=>{I.cursorsContainer=t}}),v&&v.current||document.body)),[I,v]);return a((()=>t.registerCommand(u,(t=>{if(void 0!==z&&void 0!==B){t?(console.log("Collaboration connected!"),z()):(console.log("Collaboration disconnected!"),B())}return!0}),h)),[z,B,t]),[F,I]}function _(t,e){const r=s((()=>p(e,e.root.getSharedType())),[e]);a((()=>i(t.registerCommand(x,(()=>(r.undo(),!0)),h),t.registerCommand(b,(()=>(r.redo(),!0)),h))));const n=c((()=>{r.clear()}),[r]);return o.useEffect((()=>{const e=()=>{t.dispatchCommand(k,r.undoStack.length>0),t.dispatchCommand(S,r.redoStack.length>0)};return r.on("stack-item-added",e),r.on("stack-item-popped",e),r.on("stack-cleared",e),()=>{r.off("stack-item-added",e),r.off("stack-item-popped",e),r.off("stack-cleared",e)}}),[t,r]),n}function I({id:o,providerFactory:r,shouldBootstrap:n,username:c,cursorColor:l,cursorsContainerRef:d,initialEditorState:m,excludedProperties:u,awarenessData:p}){const g=t(c,l),{yjsDocMap:y,name:C,color:x}=g,[b]=e();a((()=>(g.isCollabActive=!0,()=>{null==b._parentEditor&&(g.isCollabActive=!1)})),[g,b]);const k=s((()=>r(o,y)),[o,r,y]),[S,D]=R(b,o,k,y,C,x,n,d,m,u,p);return g.clientID=D.clientID,_(b,D),function(t,e,o,r,n){a((()=>i(t.registerCommand(E,(()=>(f(e,o,r,!0,n||{}),!1)),h),t.registerCommand(v,(()=>(f(e,o,r,!1,n||{}),!1)),h))),[r,t,o,e,n])}(b,k,C,x,p),S}export{I as CollaborationPlugin};
@@ -10,20 +10,8 @@
10
10
 
11
11
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
12
12
  var lexical = require('lexical');
13
- var React = require('react');
14
-
15
- function _interopNamespaceDefault(e) {
16
- var n = Object.create(null);
17
- if (e) {
18
- for (var k in e) {
19
- n[k] = e[k];
20
- }
21
- }
22
- n.default = e;
23
- return n;
24
- }
25
-
26
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
13
+ var react = require('react');
14
+ var jsxRuntime = require('react/jsx-runtime');
27
15
 
28
16
  /**
29
17
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -43,7 +31,11 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
43
31
  *
44
32
  */
45
33
 
46
- const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
34
+
35
+ // This workaround is no longer necessary in React 19,
36
+ // but we currently support React >=17.x
37
+ // https://github.com/facebook/react/pull/26395
38
+ const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
47
39
 
48
40
  /**
49
41
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -60,7 +52,7 @@ function LexicalComposer({
60
52
  initialConfig,
61
53
  children
62
54
  }) {
63
- const composerContext = React.useMemo(() => {
55
+ const composerContext = react.useMemo(() => {
64
56
  const {
65
57
  theme,
66
58
  namespace,
@@ -97,9 +89,10 @@ function LexicalComposer({
97
89
  // We only do this for init
98
90
  // eslint-disable-next-line react-hooks/exhaustive-deps
99
91
  }, []);
100
- return /*#__PURE__*/React__namespace.createElement(LexicalComposerContext.LexicalComposerContext.Provider, {
101
- value: composerContext
102
- }, children);
92
+ return /*#__PURE__*/jsxRuntime.jsx(LexicalComposerContext.LexicalComposerContext.Provider, {
93
+ value: composerContext,
94
+ children: children
95
+ });
103
96
  }
104
97
  function initializeEditor(editor, initialEditorState) {
105
98
  if (initialEditorState === null) {
@@ -8,8 +8,8 @@
8
8
 
9
9
  import { createLexicalComposerContext, LexicalComposerContext } from '@lexical/react/LexicalComposerContext';
10
10
  import { createEditor, $getRoot, $createParagraphNode, $getSelection } from 'lexical';
11
- import * as React from 'react';
12
11
  import { useLayoutEffect, useEffect, useMemo } from 'react';
12
+ import { jsx } from 'react/jsx-runtime';
13
13
 
14
14
  /**
15
15
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -29,6 +29,10 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
29
29
  *
30
30
  */
31
31
 
32
+
33
+ // This workaround is no longer necessary in React 19,
34
+ // but we currently support React >=17.x
35
+ // https://github.com/facebook/react/pull/26395
32
36
  const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
33
37
 
34
38
  /**
@@ -83,9 +87,10 @@ function LexicalComposer({
83
87
  // We only do this for init
84
88
  // eslint-disable-next-line react-hooks/exhaustive-deps
85
89
  }, []);
86
- return /*#__PURE__*/React.createElement(LexicalComposerContext.Provider, {
87
- value: composerContext
88
- }, children);
90
+ return /*#__PURE__*/jsx(LexicalComposerContext.Provider, {
91
+ value: composerContext,
92
+ children: children
93
+ });
89
94
  }
90
95
  function initializeEditor(editor, initialEditorState) {
91
96
  if (initialEditorState === null) {
@@ -6,7 +6,6 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("lexical"),g=require("react"),h=Object.create(null);if(g)for(var n in g)h[n]=g[n];h.default=g;let p="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,q=p?g.useLayoutEffect:g.useEffect,r={tag:"history-merge"};
10
- function t(a,c){if(null!==c)if(void 0===c)a.update(()=>{var b=f.$getRoot();if(b.isEmpty()){let d=f.$createParagraphNode();b.append(d);b=p?document.activeElement:null;(null!==f.$getSelection()||null!==b&&b===a.getRootElement())&&d.select()}},r);else if(null!==c)switch(typeof c){case "string":let b=a.parseEditorState(c);a.setEditorState(b,r);break;case "object":a.setEditorState(c,r);break;case "function":a.update(()=>{f.$getRoot().isEmpty()&&c(a)},r)}}
11
- exports.LexicalComposer=function({initialConfig:a,children:c}){let b=g.useMemo(()=>{const {theme:d,namespace:k,editor__DEPRECATED:u,nodes:v,onError:w,editorState:x,html:y}=a,z=e.createLexicalComposerContext(null,d);let l=u||null;if(null===l){const m=f.createEditor({editable:a.editable,html:y,namespace:k,nodes:v,onError:A=>w(A,m),theme:d});t(m,x);l=m}return[l,z]},[]);q(()=>{let d=a.editable,[k]=b;k.setEditable(void 0!==d?d:!0)},[]);return h.createElement(e.LexicalComposerContext.Provider,{value:b},
12
- c)}
9
+ 'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("lexical"),g=require("react"),m=require("react/jsx-runtime");let n="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,p=n?g.useLayoutEffect:g.useEffect,q={tag:"history-merge"};
10
+ function r(a,c){if(null!==c)if(void 0===c)a.update(()=>{var b=f.$getRoot();if(b.isEmpty()){let d=f.$createParagraphNode();b.append(d);b=n?document.activeElement:null;(null!==f.$getSelection()||null!==b&&b===a.getRootElement())&&d.select()}},q);else if(null!==c)switch(typeof c){case "string":let b=a.parseEditorState(c);a.setEditorState(b,q);break;case "object":a.setEditorState(c,q);break;case "function":a.update(()=>{f.$getRoot().isEmpty()&&c(a)},q)}}
11
+ exports.LexicalComposer=function({initialConfig:a,children:c}){let b=g.useMemo(()=>{const {theme:d,namespace:h,editor__DEPRECATED:t,nodes:u,onError:v,editorState:w,html:x}=a,y=e.createLexicalComposerContext(null,d);let k=t||null;if(null===k){const l=f.createEditor({editable:a.editable,html:x,namespace:h,nodes:u,onError:z=>v(z,l),theme:d});r(l,w);k=l}return[k,y]},[]);p(()=>{let d=a.editable,[h]=b;h.setEditable(void 0!==d?d:!0)},[]);return m.jsx(e.LexicalComposerContext.Provider,{value:b,children:c})}
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{createLexicalComposerContext as e,LexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createEditor as o,$getRoot as n,$createParagraphNode as i,$getSelection as r}from"lexical";import*as l from"react";import{useLayoutEffect as a,useEffect as c,useMemo as s}from"react";const d="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,m=d?a:c,u={tag:"history-merge"};function p({initialConfig:a,children:c}){const p=s((()=>{const{theme:t,namespace:l,editor__DEPRECATED:c,nodes:s,onError:m,editorState:p,html:f}=a,E=e(null,t);let b=c||null;if(null===b){const e=o({editable:a.editable,html:f,namespace:l,nodes:s,onError:t=>m(t,e),theme:t});!function(e,t){if(null===t)return;if(void 0===t)e.update((()=>{const t=n();if(t.isEmpty()){const o=i();t.append(o);const n=d?document.activeElement:null;(null!==r()||null!==n&&n===e.getRootElement())&&o.select()}}),u);else if(null!==t)switch(typeof t){case"string":{const o=e.parseEditorState(t);e.setEditorState(o,u);break}case"object":e.setEditorState(t,u);break;case"function":e.update((()=>{n().isEmpty()&&t(e)}),u)}}(e,p),b=e}return[b,E]}),[]);return m((()=>{const e=a.editable,[t]=p;t.setEditable(void 0===e||e)}),[]),l.createElement(t.Provider,{value:p},c)}export{p as LexicalComposer};
9
+ import{createLexicalComposerContext as e,LexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createEditor as o,$getRoot as n,$createParagraphNode as i,$getSelection as r}from"lexical";import{useLayoutEffect as l,useEffect as c,useMemo as a}from"react";import{jsx as d}from"react/jsx-runtime";const s="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,m=s?l:c,u={tag:"history-merge"};function p({initialConfig:l,children:c}){const p=a((()=>{const{theme:t,namespace:c,editor__DEPRECATED:a,nodes:d,onError:m,editorState:p,html:f}=l,E=e(null,t);let h=a||null;if(null===h){const e=o({editable:l.editable,html:f,namespace:c,nodes:d,onError:t=>m(t,e),theme:t});!function(e,t){if(null===t)return;if(void 0===t)e.update((()=>{const t=n();if(t.isEmpty()){const o=i();t.append(o);const n=s?document.activeElement:null;(null!==r()||null!==n&&n===e.getRootElement())&&o.select()}}),u);else if(null!==t)switch(typeof t){case"string":{const o=e.parseEditorState(t);e.setEditorState(o,u);break}case"object":e.setEditorState(t,u);break;case"function":e.update((()=>{n().isEmpty()&&t(e)}),u)}}(e,p),h=e}return[h,E]}),[]);return m((()=>{const e=l.editable,[t]=p;t.setEditable(void 0===e||e)}),[]),d(t.Provider,{value:p,children:c})}export{p as LexicalComposer};
@@ -9,35 +9,8 @@
9
9
  'use strict';
10
10
 
11
11
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
12
- var React = require('react');
13
-
14
- function _interopNamespaceDefault(e) {
15
- var n = Object.create(null);
16
- if (e) {
17
- for (var k in e) {
18
- n[k] = e[k];
19
- }
20
- }
21
- n.default = e;
22
- return n;
23
- }
24
-
25
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
26
-
27
- function _extends() {
28
- _extends = Object.assign ? Object.assign.bind() : function (target) {
29
- for (var i = 1; i < arguments.length; i++) {
30
- var source = arguments[i];
31
- for (var key in source) {
32
- if (Object.prototype.hasOwnProperty.call(source, key)) {
33
- target[key] = source[key];
34
- }
35
- }
36
- }
37
- return target;
38
- };
39
- return _extends.apply(this, arguments);
40
- }
12
+ var react = require('react');
13
+ var jsxRuntime = require('react/jsx-runtime');
41
14
 
42
15
  /**
43
16
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -57,7 +30,19 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
57
30
  *
58
31
  */
59
32
 
60
- const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
33
+
34
+ // This workaround is no longer necessary in React 19,
35
+ // but we currently support React >=17.x
36
+ // https://github.com/facebook/react/pull/26395
37
+ const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
38
+
39
+ /**
40
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
41
+ *
42
+ * This source code is licensed under the MIT license found in the
43
+ * LICENSE file in the root directory of this source tree.
44
+ *
45
+ */
61
46
 
62
47
  function ContentEditable({
63
48
  ariaActiveDescendant,
@@ -81,8 +66,8 @@ function ContentEditable({
81
66
  ...rest
82
67
  }) {
83
68
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
84
- const [isEditable, setEditable] = React.useState(false);
85
- const ref = React.useCallback(rootElement => {
69
+ const [isEditable, setEditable] = react.useState(false);
70
+ const ref = react.useCallback(rootElement => {
86
71
  // defaultView is required for a root element.
87
72
  // In multi-window setups, the defaultView may not exist at certain points.
88
73
  if (rootElement && rootElement.ownerDocument && rootElement.ownerDocument.defaultView) {
@@ -95,7 +80,8 @@ function ContentEditable({
95
80
  setEditable(currentIsEditable);
96
81
  });
97
82
  }, [editor]);
98
- return /*#__PURE__*/React__namespace.createElement("div", _extends({}, rest, {
83
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
84
+ ...rest,
99
85
  "aria-activedescendant": !isEditable ? undefined : ariaActiveDescendant,
100
86
  "aria-autocomplete": !isEditable ? 'none' : ariaAutoComplete,
101
87
  "aria-controls": !isEditable ? undefined : ariaControls,
@@ -117,7 +103,7 @@ function ContentEditable({
117
103
  spellCheck: spellCheck,
118
104
  style: style,
119
105
  tabIndex: tabIndex
120
- }));
106
+ });
121
107
  }
122
108
 
123
109
  exports.ContentEditable = ContentEditable;
@@ -7,23 +7,8 @@
7
7
  */
8
8
 
9
9
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
10
- import * as React from 'react';
11
10
  import { useLayoutEffect, useEffect, useState, useCallback } from 'react';
12
-
13
- function _extends() {
14
- _extends = Object.assign ? Object.assign.bind() : function (target) {
15
- for (var i = 1; i < arguments.length; i++) {
16
- var source = arguments[i];
17
- for (var key in source) {
18
- if (Object.prototype.hasOwnProperty.call(source, key)) {
19
- target[key] = source[key];
20
- }
21
- }
22
- }
23
- return target;
24
- };
25
- return _extends.apply(this, arguments);
26
- }
11
+ import { jsx } from 'react/jsx-runtime';
27
12
 
28
13
  /**
29
14
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -43,8 +28,20 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
43
28
  *
44
29
  */
45
30
 
31
+
32
+ // This workaround is no longer necessary in React 19,
33
+ // but we currently support React >=17.x
34
+ // https://github.com/facebook/react/pull/26395
46
35
  const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
47
36
 
37
+ /**
38
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ *
43
+ */
44
+
48
45
  function ContentEditable({
49
46
  ariaActiveDescendant,
50
47
  ariaAutoComplete,
@@ -81,7 +78,8 @@ function ContentEditable({
81
78
  setEditable(currentIsEditable);
82
79
  });
83
80
  }, [editor]);
84
- return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
81
+ return /*#__PURE__*/jsx("div", {
82
+ ...rest,
85
83
  "aria-activedescendant": !isEditable ? undefined : ariaActiveDescendant,
86
84
  "aria-autocomplete": !isEditable ? 'none' : ariaAutoComplete,
87
85
  "aria-controls": !isEditable ? undefined : ariaControls,
@@ -103,7 +101,7 @@ function ContentEditable({
103
101
  spellCheck: spellCheck,
104
102
  style: style,
105
103
  tabIndex: tabIndex
106
- }));
104
+ });
107
105
  }
108
106
 
109
107
  export { ContentEditable };
@@ -6,7 +6,6 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var a=require("@lexical/react/LexicalComposerContext"),k=require("react"),l=Object.create(null);if(k)for(var m in k)l[m]=k[m];l.default=k;function q(){q=Object.assign?Object.assign.bind():function(h){for(var e=1;e<arguments.length;e++){var f=arguments[e],c;for(c in f)Object.prototype.hasOwnProperty.call(f,c)&&(h[c]=f[c])}return h};return q.apply(this,arguments)}
10
- let r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
11
- exports.ContentEditable=function({ariaActiveDescendant:h,ariaAutoComplete:e,ariaControls:f,ariaDescribedBy:c,ariaExpanded:t,ariaLabel:u,ariaLabelledBy:v,ariaMultiline:w,ariaOwns:x,ariaRequired:y,autoCapitalize:z,className:A,id:B,role:n="textbox",spellCheck:C=!0,style:D,tabIndex:E,"data-testid":F,...G}){let [g]=a.useLexicalComposerContext(),[b,p]=k.useState(!1),H=k.useCallback(d=>{d&&d.ownerDocument&&d.ownerDocument.defaultView&&g.setRootElement(d)},[g]);r(()=>{p(g.isEditable());return g.registerEditableListener(d=>
12
- {p(d)})},[g]);return l.createElement("div",q({},G,{"aria-activedescendant":b?h:void 0,"aria-autocomplete":b?e:"none","aria-controls":b?f:void 0,"aria-describedby":c,"aria-expanded":b?"combobox"===n?!!t:void 0:void 0,"aria-label":u,"aria-labelledby":v,"aria-multiline":w,"aria-owns":b?x:void 0,"aria-readonly":b?void 0:!0,"aria-required":y,autoCapitalize:z,className:A,contentEditable:b,"data-testid":F,id:B,ref:H,role:n,spellCheck:C,style:D,tabIndex:E}))}
9
+ 'use strict';var d=require("@lexical/react/LexicalComposerContext"),g=require("react"),h=require("react/jsx-runtime");let k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;
10
+ exports.ContentEditable=function({ariaActiveDescendant:l,ariaAutoComplete:m,ariaControls:n,ariaDescribedBy:p,ariaExpanded:q,ariaLabel:r,ariaLabelledBy:t,ariaMultiline:u,ariaOwns:v,ariaRequired:w,autoCapitalize:x,className:y,id:z,role:e="textbox",spellCheck:A=!0,style:B,tabIndex:C,"data-testid":D,...E}){let [c]=d.useLexicalComposerContext(),[a,f]=g.useState(!1),F=g.useCallback(b=>{b&&b.ownerDocument&&b.ownerDocument.defaultView&&c.setRootElement(b)},[c]);k(()=>{f(c.isEditable());return c.registerEditableListener(b=>
11
+ {f(b)})},[c]);return h.jsx("div",{...E,"aria-activedescendant":a?l:void 0,"aria-autocomplete":a?m:"none","aria-controls":a?n:void 0,"aria-describedby":p,"aria-expanded":a?"combobox"===e?!!q:void 0:void 0,"aria-label":r,"aria-labelledby":t,"aria-multiline":u,"aria-owns":a?v:void 0,"aria-readonly":a?void 0:!0,"aria-required":w,autoCapitalize:x,className:y,contentEditable:a,"data-testid":D,id:z,ref:F,role:e,spellCheck:A,style:B,tabIndex:C})}
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import*as a from"react";import{useLayoutEffect as t,useEffect as i,useState as r,useCallback as o}from"react";function n(){return n=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},n.apply(this,arguments)}const d="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:i;function l({ariaActiveDescendant:t,ariaAutoComplete:i,ariaControls:l,ariaDescribedBy:c,ariaExpanded:s,ariaLabel:b,ariaLabelledBy:m,ariaMultiline:u,ariaOwns:p,ariaRequired:v,autoCapitalize:f,className:w,id:x,role:y="textbox",spellCheck:C=!0,style:E,tabIndex:h,"data-testid":O,...g}){const[D]=e(),[L,j]=r(!1),k=o((e=>{e&&e.ownerDocument&&e.ownerDocument.defaultView&&D.setRootElement(e)}),[D]);return d((()=>(j(D.isEditable()),D.registerEditableListener((e=>{j(e)})))),[D]),a.createElement("div",n({},g,{"aria-activedescendant":L?t:void 0,"aria-autocomplete":L?i:"none","aria-controls":L?l:void 0,"aria-describedby":c,"aria-expanded":L&&"combobox"===y?!!s:void 0,"aria-label":b,"aria-labelledby":m,"aria-multiline":u,"aria-owns":L?p:void 0,"aria-readonly":!L||void 0,"aria-required":v,autoCapitalize:f,className:w,contentEditable:L,"data-testid":O,id:x,ref:k,role:y,spellCheck:C,style:E,tabIndex:h}))}export{l as ContentEditable};
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as a,useEffect as i,useState as t,useCallback as o}from"react";import{jsx as r}from"react/jsx-runtime";const d="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?a:i;function n({ariaActiveDescendant:a,ariaAutoComplete:i,ariaControls:n,ariaDescribedBy:l,ariaExpanded:c,ariaLabel:s,ariaLabelledBy:m,ariaMultiline:u,ariaOwns:b,ariaRequired:p,autoCapitalize:x,className:w,id:v,role:f="textbox",spellCheck:y=!0,style:C,tabIndex:E,"data-testid":D,...L}){const[h]=e(),[k,q]=t(!1),z=o((e=>{e&&e.ownerDocument&&e.ownerDocument.defaultView&&h.setRootElement(e)}),[h]);return d((()=>(q(h.isEditable()),h.registerEditableListener((e=>{q(e)})))),[h]),r("div",{...L,"aria-activedescendant":k?a:void 0,"aria-autocomplete":k?i:"none","aria-controls":k?n:void 0,"aria-describedby":l,"aria-expanded":k&&"combobox"===f?!!c:void 0,"aria-label":s,"aria-labelledby":m,"aria-multiline":u,"aria-owns":k?b:void 0,"aria-readonly":!k||void 0,"aria-required":p,autoCapitalize:x,className:w,contentEditable:k,"data-testid":D,id:v,ref:z,role:f,spellCheck:y,style:C,tabIndex:E})}export{n as ContentEditable};
@@ -12,6 +12,7 @@ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
12
12
  var utils = require('@lexical/utils');
13
13
  var lexical = require('lexical');
14
14
  var React = require('react');
15
+ var jsxRuntime = require('react/jsx-runtime');
15
16
 
16
17
  function _interopNamespaceDefault(e) {
17
18
  var n = Object.create(null);
@@ -44,6 +45,10 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
44
45
  *
45
46
  */
46
47
 
48
+
49
+ // This workaround is no longer necessary in React 19,
50
+ // but we currently support React >=17.x
51
+ // https://github.com/facebook/react/pull/26395
47
52
  const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
48
53
 
49
54
  /**
@@ -459,7 +464,7 @@ function LexicalContextMenuPlugin({
459
464
  document.addEventListener('click', handleClick);
460
465
  return () => document.removeEventListener('click', handleClick);
461
466
  }, [editor, handleClick]);
462
- return resolution === null || editor === null ? null : /*#__PURE__*/React__namespace.createElement(LexicalMenu, {
467
+ return resolution === null || editor === null ? null : /*#__PURE__*/jsxRuntime.jsx(LexicalMenu, {
463
468
  close: closeNodeMenu,
464
469
  resolution: resolution,
465
470
  editor: editor,
@@ -11,6 +11,7 @@ import { mergeRegister, calculateZoomLevel } from '@lexical/utils';
11
11
  import { createCommand, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection, $isRangeSelection } from 'lexical';
12
12
  import * as React from 'react';
13
13
  import { useLayoutEffect, useEffect, useState, useCallback, useMemo, useRef } from 'react';
14
+ import { jsx } from 'react/jsx-runtime';
14
15
 
15
16
  /**
16
17
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -30,6 +31,10 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
30
31
  *
31
32
  */
32
33
 
34
+
35
+ // This workaround is no longer necessary in React 19,
36
+ // but we currently support React >=17.x
37
+ // https://github.com/facebook/react/pull/26395
33
38
  const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
34
39
 
35
40
  /**
@@ -445,7 +450,7 @@ function LexicalContextMenuPlugin({
445
450
  document.addEventListener('click', handleClick);
446
451
  return () => document.removeEventListener('click', handleClick);
447
452
  }, [editor, handleClick]);
448
- return resolution === null || editor === null ? null : /*#__PURE__*/React.createElement(LexicalMenu, {
453
+ return resolution === null || editor === null ? null : /*#__PURE__*/jsx(LexicalMenu, {
449
454
  close: closeNodeMenu,
450
455
  resolution: resolution,
451
456
  editor: editor,
@@ -6,19 +6,19 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var g=require("@lexical/react/LexicalComposerContext"),w=require("@lexical/utils"),y=require("lexical"),A=require("react"),B=Object.create(null);if(A)for(var C in A)B[C]=A[C];B.default=A;let D="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?A.useLayoutEffect:A.useEffect;class E{constructor(c){this.key=c;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(c){this.ref={current:c}}}
10
- let F=c=>{const a=document.getElementById("typeahead-menu");if(a){var f=a.getBoundingClientRect();f.top+f.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>f.top&&a.scrollIntoView({block:"center"});c.scrollIntoView({block:"nearest"})}};
11
- function G(c){var a=y.$getSelection();if(!y.$isRangeSelection(a)||!a.isCollapsed())return null;var f=a.anchor;if("text"!==f.type)return null;a=f.getNode();if(!a.isSimpleText())return null;f=f.offset;let k=a.getTextContent().slice(0,f);var d=c.matchingString;c=c.replaceableString.length;for(let n=c;n<=d.length;n++)k.substr(-n)===d.substr(0,n)&&(c=n);c=f-c;if(0>c)return null;let p;0===c?[p]=a.splitText(f):[,p]=a.splitText(c,f);return p}
12
- function H(c){let a=getComputedStyle(c),f="absolute"===a.position,k=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;c=c.parentElement;)if(a=getComputedStyle(c),(!f||"static"!==a.position)&&k.test(a.overflow+a.overflowY+a.overflowX))return c;return document.body}function I(c,a){c=c.getBoundingClientRect();a=a.getBoundingClientRect();return c.top>a.top&&c.top<a.bottom}
13
- function J(c,a,f,k){let [d]=g.useLexicalComposerContext();A.useEffect(()=>{if(null!=a&&null!=c){let p=d.getRootElement(),n=null!=p?H(p):document.body,x=!1,m=I(a,n),b=function(){x||(window.requestAnimationFrame(function(){f();x=!1}),x=!0);const q=I(a,n);q!==m&&(m=q,null!=k&&k(q))},h=new ResizeObserver(f);window.addEventListener("resize",f);document.addEventListener("scroll",b,{capture:!0,passive:!0});h.observe(a);return()=>{h.unobserve(a);window.removeEventListener("resize",f);document.removeEventListener("scroll",
14
- b,!0)}}},[a,d,k,f,c])}let K=y.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
15
- function L({close:c,editor:a,anchorElementRef:f,resolution:k,options:d,menuRenderFn:p,onSelectOption:n,shouldSplitNodeWithQuery:x=!1,commandPriority:m=y.COMMAND_PRIORITY_LOW}){let [b,h]=A.useState(null);A.useEffect(()=>{h(0)},[k.match&&k.match.matchingString]);let q=A.useCallback(e=>{a.update(()=>{const l=null!=k.match&&x?G(k.match):null;n(e,l,c,k.match?k.match.matchingString:"")})},[a,x,k.match,n,c]),t=A.useCallback(e=>{const l=a.getRootElement();null!==l&&(l.setAttribute("aria-activedescendant",
16
- "typeahead-item-"+e),h(e))},[a]);A.useEffect(()=>()=>{let e=a.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[a]);D(()=>{null===d?h(null):null===b&&t(0)},[d,b,t]);A.useEffect(()=>w.mergeRegister(a.registerCommand(K,({option:e})=>e.ref&&null!=e.ref.current?(F(e.ref.current),!0):!1,m)),[a,t,m]);A.useEffect(()=>w.mergeRegister(a.registerCommand(y.KEY_ARROW_DOWN_COMMAND,e=>{if(null!==d&&d.length&&null!==b){let l=b!==d.length-1?b+1:0;t(l);let u=d[l];null!=u.ref&&u.ref.current&&
17
- a.dispatchCommand(K,{index:l,option:u});e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(y.KEY_ARROW_UP_COMMAND,e=>{if(null!==d&&d.length&&null!==b){var l=0!==b?b-1:d.length-1;t(l);l=d[l];null!=l.ref&&l.ref.current&&F(l.ref.current);e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(y.KEY_ESCAPE_COMMAND,e=>{e.preventDefault();e.stopImmediatePropagation();c();return!0},m),a.registerCommand(y.KEY_TAB_COMMAND,e=>{if(null===d||null===b||null==
18
- d[b])return!1;e.preventDefault();e.stopImmediatePropagation();q(d[b]);return!0},m),a.registerCommand(y.KEY_ENTER_COMMAND,e=>{if(null===d||null===b||null==d[b])return!1;null!==e&&(e.preventDefault(),e.stopImmediatePropagation());q(d[b]);return!0},m)),[q,c,a,d,b,t,m]);let v=A.useMemo(()=>({options:d,selectOptionAndCleanUp:q,selectedIndex:b,setHighlightedIndex:h}),[q,b,d]);return p(f,v,k.match?k.match.matchingString:"")}
19
- function M(c,a,f,k=document.body){let [d]=g.useLexicalComposerContext(),p=A.useRef(document.createElement("div")),n=A.useCallback(()=>{p.current.style.top=p.current.style.bottom;const m=d.getRootElement(),b=p.current;var h=b.firstChild;if(null!==m&&null!==c){const {left:t,top:v,width:e,height:l}=c.getRect();b.style.top=`${v+window.pageYOffset+p.current.offsetHeight+3}px`;b.style.left=`${t+window.pageXOffset}px`;b.style.height=`${l}px`;b.style.width=`${e}px`;if(null!==h){h.style.top=`${v}`;var q=h.getBoundingClientRect();
9
+ 'use strict';var g=require("@lexical/react/LexicalComposerContext"),w=require("@lexical/utils"),z=require("lexical"),A=require("react"),B=require("react/jsx-runtime"),C=Object.create(null);if(A)for(var D in A)C[D]=A[D];C.default=A;let E="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?A.useLayoutEffect:A.useEffect;
10
+ class F{constructor(c){this.key=c;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(c){this.ref={current:c}}}let G=c=>{const a=document.getElementById("typeahead-menu");if(a){var f=a.getBoundingClientRect();f.top+f.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>f.top&&a.scrollIntoView({block:"center"});c.scrollIntoView({block:"nearest"})}};
11
+ function H(c){var a=z.$getSelection();if(!z.$isRangeSelection(a)||!a.isCollapsed())return null;var f=a.anchor;if("text"!==f.type)return null;a=f.getNode();if(!a.isSimpleText())return null;f=f.offset;let k=a.getTextContent().slice(0,f);var d=c.matchingString;c=c.replaceableString.length;for(let n=c;n<=d.length;n++)k.substr(-n)===d.substr(0,n)&&(c=n);c=f-c;if(0>c)return null;let p;0===c?[p]=a.splitText(f):[,p]=a.splitText(c,f);return p}
12
+ function I(c){let a=getComputedStyle(c),f="absolute"===a.position,k=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;c=c.parentElement;)if(a=getComputedStyle(c),(!f||"static"!==a.position)&&k.test(a.overflow+a.overflowY+a.overflowX))return c;return document.body}function J(c,a){c=c.getBoundingClientRect();a=a.getBoundingClientRect();return c.top>a.top&&c.top<a.bottom}
13
+ function K(c,a,f,k){let [d]=g.useLexicalComposerContext();A.useEffect(()=>{if(null!=a&&null!=c){let p=d.getRootElement(),n=null!=p?I(p):document.body,x=!1,m=J(a,n),b=function(){x||(window.requestAnimationFrame(function(){f();x=!1}),x=!0);const q=J(a,n);q!==m&&(m=q,null!=k&&k(q))},h=new ResizeObserver(f);window.addEventListener("resize",f);document.addEventListener("scroll",b,{capture:!0,passive:!0});h.observe(a);return()=>{h.unobserve(a);window.removeEventListener("resize",f);document.removeEventListener("scroll",
14
+ b,!0)}}},[a,d,k,f,c])}let L=z.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
15
+ function M({close:c,editor:a,anchorElementRef:f,resolution:k,options:d,menuRenderFn:p,onSelectOption:n,shouldSplitNodeWithQuery:x=!1,commandPriority:m=z.COMMAND_PRIORITY_LOW}){let [b,h]=A.useState(null);A.useEffect(()=>{h(0)},[k.match&&k.match.matchingString]);let q=A.useCallback(e=>{a.update(()=>{const l=null!=k.match&&x?H(k.match):null;n(e,l,c,k.match?k.match.matchingString:"")})},[a,x,k.match,n,c]),t=A.useCallback(e=>{const l=a.getRootElement();null!==l&&(l.setAttribute("aria-activedescendant",
16
+ "typeahead-item-"+e),h(e))},[a]);A.useEffect(()=>()=>{let e=a.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[a]);E(()=>{null===d?h(null):null===b&&t(0)},[d,b,t]);A.useEffect(()=>w.mergeRegister(a.registerCommand(L,({option:e})=>e.ref&&null!=e.ref.current?(G(e.ref.current),!0):!1,m)),[a,t,m]);A.useEffect(()=>w.mergeRegister(a.registerCommand(z.KEY_ARROW_DOWN_COMMAND,e=>{if(null!==d&&d.length&&null!==b){let l=b!==d.length-1?b+1:0;t(l);let u=d[l];null!=u.ref&&u.ref.current&&
17
+ a.dispatchCommand(L,{index:l,option:u});e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(z.KEY_ARROW_UP_COMMAND,e=>{if(null!==d&&d.length&&null!==b){var l=0!==b?b-1:d.length-1;t(l);l=d[l];null!=l.ref&&l.ref.current&&G(l.ref.current);e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(z.KEY_ESCAPE_COMMAND,e=>{e.preventDefault();e.stopImmediatePropagation();c();return!0},m),a.registerCommand(z.KEY_TAB_COMMAND,e=>{if(null===d||null===b||null==
18
+ d[b])return!1;e.preventDefault();e.stopImmediatePropagation();q(d[b]);return!0},m),a.registerCommand(z.KEY_ENTER_COMMAND,e=>{if(null===d||null===b||null==d[b])return!1;null!==e&&(e.preventDefault(),e.stopImmediatePropagation());q(d[b]);return!0},m)),[q,c,a,d,b,t,m]);let v=A.useMemo(()=>({options:d,selectOptionAndCleanUp:q,selectedIndex:b,setHighlightedIndex:h}),[q,b,d]);return p(f,v,k.match?k.match.matchingString:"")}
19
+ function N(c,a,f,k=document.body){let [d]=g.useLexicalComposerContext(),p=A.useRef(document.createElement("div")),n=A.useCallback(()=>{p.current.style.top=p.current.style.bottom;const m=d.getRootElement(),b=p.current;var h=b.firstChild;if(null!==m&&null!==c){const {left:t,top:v,width:e,height:l}=c.getRect();b.style.top=`${v+window.pageYOffset+p.current.offsetHeight+3}px`;b.style.left=`${t+window.pageXOffset}px`;b.style.height=`${l}px`;b.style.width=`${e}px`;if(null!==h){h.style.top=`${v}`;var q=h.getBoundingClientRect();
20
20
  h=q.height;q=q.width;const u=m.getBoundingClientRect();t+q>u.right&&(b.style.left=`${u.right-q+window.pageXOffset}px`);(v+h>window.innerHeight||v+h>u.bottom)&&v-u.top>h+l&&(b.style.top=`${v-h+window.pageYOffset-l}px`)}b.isConnected||(null!=f&&(b.className=f),b.setAttribute("aria-label","Typeahead menu"),b.setAttribute("id","typeahead-menu"),b.setAttribute("role","listbox"),b.style.display="block",b.style.position="absolute",k.append(b));p.current=b;m.setAttribute("aria-controls","typeahead-menu")}},
21
- [d,c,f,k]);A.useEffect(()=>{let m=d.getRootElement();if(null!==c)return n(),()=>{null!==m&&m.removeAttribute("aria-controls");let b=p.current;null!==b&&b.isConnected&&b.remove()}},[d,n,c]);let x=A.useCallback(m=>{null!==c&&(m||a(null))},[c,a]);J(c,p.current,n,x);return p}
22
- exports.LexicalContextMenuPlugin=function({options:c,onWillOpen:a,onClose:f,onOpen:k,onSelectOption:d,menuRenderFn:p,anchorClassName:n,commandPriority:x=y.COMMAND_PRIORITY_LOW,parent:m}){let [b]=g.useLexicalComposerContext(),[h,q]=A.useState(null),t=B.useRef(null);n=M(h,q,n,m);let v=A.useCallback(()=>{q(null);null!=f&&null!==h&&f()},[f,h]),e=A.useCallback(r=>{q(r);null!=k&&null===h&&k(r)},[k,h]),l=A.useCallback(r=>{r.preventDefault();null!=a&&a(r);const z=w.calculateZoomLevel(r.target);e({getRect:()=>
23
- new DOMRect(r.clientX/z,r.clientY/z,1,1)})},[e,a]),u=A.useCallback(r=>{null===h||null==t.current||null==r.target||t.current.contains(r.target)||v()},[v,h]);A.useEffect(()=>{let r=b.getRootElement();if(r)return r.addEventListener("contextmenu",l),()=>r.removeEventListener("contextmenu",l)},[b,l]);A.useEffect(()=>{document.addEventListener("click",u);return()=>document.removeEventListener("click",u)},[b,u]);return null===h||null===b?null:B.createElement(L,{close:v,resolution:h,editor:b,anchorElementRef:n,
24
- options:c,menuRenderFn:(r,z)=>p(r,z,{setMenuRef:N=>{t.current=N}}),onSelectOption:d,commandPriority:x})};exports.MenuOption=E
21
+ [d,c,f,k]);A.useEffect(()=>{let m=d.getRootElement();if(null!==c)return n(),()=>{null!==m&&m.removeAttribute("aria-controls");let b=p.current;null!==b&&b.isConnected&&b.remove()}},[d,n,c]);let x=A.useCallback(m=>{null!==c&&(m||a(null))},[c,a]);K(c,p.current,n,x);return p}
22
+ exports.LexicalContextMenuPlugin=function({options:c,onWillOpen:a,onClose:f,onOpen:k,onSelectOption:d,menuRenderFn:p,anchorClassName:n,commandPriority:x=z.COMMAND_PRIORITY_LOW,parent:m}){let [b]=g.useLexicalComposerContext(),[h,q]=A.useState(null),t=C.useRef(null);n=N(h,q,n,m);let v=A.useCallback(()=>{q(null);null!=f&&null!==h&&f()},[f,h]),e=A.useCallback(r=>{q(r);null!=k&&null===h&&k(r)},[k,h]),l=A.useCallback(r=>{r.preventDefault();null!=a&&a(r);const y=w.calculateZoomLevel(r.target);e({getRect:()=>
23
+ new DOMRect(r.clientX/y,r.clientY/y,1,1)})},[e,a]),u=A.useCallback(r=>{null===h||null==t.current||null==r.target||t.current.contains(r.target)||v()},[v,h]);A.useEffect(()=>{let r=b.getRootElement();if(r)return r.addEventListener("contextmenu",l),()=>r.removeEventListener("contextmenu",l)},[b,l]);A.useEffect(()=>{document.addEventListener("click",u);return()=>document.removeEventListener("click",u)},[b,u]);return null===h||null===b?null:B.jsx(M,{close:v,resolution:h,editor:b,anchorElementRef:n,options:c,
24
+ menuRenderFn:(r,y)=>p(r,y,{setMenuRef:O=>{t.current=O}}),onSelectOption:d,commandPriority:x})};exports.MenuOption=F
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{mergeRegister as e,calculateZoomLevel as n}from"@lexical/utils";import{createCommand as o,KEY_ARROW_DOWN_COMMAND as l,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as i,KEY_TAB_COMMAND as u,KEY_ENTER_COMMAND as c,COMMAND_PRIORITY_LOW as s,$getSelection as a,$isRangeSelection as m}from"lexical";import*as d from"react";import{useLayoutEffect as p,useEffect as f,useState as g,useCallback as h,useMemo as w,useRef as v}from"react";const y="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?p:f;class b{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const E=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function C(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function R(e,n,o,l){const[r]=t();f((()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,u=C(n,e);const c=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=C(n,e);t!==u&&(u=t,null!=l&&l(t))},s=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",c,{capture:!0,passive:!0}),s.observe(n),()=>{s.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",c,!0)}}}),[n,r,l,o,e])}const x=o("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:n,anchorElementRef:o,resolution:d,options:p,menuRenderFn:v,onSelectOption:b,shouldSplitNodeWithQuery:C=!1,commandPriority:R=s}){const[O,I]=g(null),S=d.match&&d.match.matchingString;f((()=>{I(0)}),[S]);const A=h((e=>{n.update((()=>{const n=null!=d.match&&C?function(t){const e=a();if(!m(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,u=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.substr(-n)===e.substr(0,n)&&(o=n);return o}(r,t.matchingString,i);if(u<0)return null;let c;return 0===u?[c]=o.splitText(l):[,c]=o.splitText(u,l),c}(d.match):null;b(e,n,t,d.match?d.match.matchingString:"")}))}),[n,C,d.match,b,t]),L=h((t=>{const e=n.getRootElement();null!==e&&(e.setAttribute("aria-activedescendant","typeahead-item-"+t),I(t))}),[n]);f((()=>()=>{const t=n.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[n]),y((()=>{null===p?I(null):null===O&&L(0)}),[p,O,L]),f((()=>e(n.registerCommand(x,(({option:t})=>!(!t.ref||null==t.ref.current)&&(E(t.ref.current),!0)),R))),[n,L,R]),f((()=>e(n.registerCommand(l,(t=>{const e=t;if(null!==p&&p.length&&null!==O){const t=O!==p.length-1?O+1:0;L(t);const o=p[t];null!=o.ref&&o.ref.current&&n.dispatchCommand(x,{index:t,option:o}),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(r,(t=>{const e=t;if(null!==p&&p.length&&null!==O){const t=0!==O?O-1:p.length-1;L(t);const n=p[t];null!=n.ref&&n.ref.current&&E(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(i,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),R),n.registerCommand(u,(t=>{const e=t;return null!==p&&null!==O&&null!=p[O]&&(e.preventDefault(),e.stopImmediatePropagation(),A(p[O]),!0)}),R),n.registerCommand(c,(t=>null!==p&&null!==O&&null!=p[O]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(p[O]),!0)),R))),[A,t,n,p,O,L,R]);return v(o,w((()=>({options:p,selectOptionAndCleanUp:A,selectedIndex:O,setHighlightedIndex:I})),[A,O,p]),d.match?d.match.matchingString:"")}function I({options:e,onWillOpen:o,onClose:l,onOpen:r,onSelectOption:i,menuRenderFn:u,anchorClassName:c,commandPriority:a=s,parent:m}){const[p]=t(),[w,y]=g(null),b=d.useRef(null),E=function(e,n,o,l=document.body){const[r]=t(),i=v(document.createElement("div")),u=h((()=>{i.current.style.top=i.current.style.bottom;const t=r.getRootElement(),n=i.current,u=n.firstChild;if(null!==t&&null!==e){const{left:r,top:c,width:s,height:a}=e.getRect(),m=i.current.offsetHeight;if(n.style.top=`${c+window.pageYOffset+m+3}px`,n.style.left=`${r+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${s}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,l=e.width,i=t.getBoundingClientRect();r+l>i.right&&(n.style.left=`${i.right-l+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>i.bottom)&&c-i.top>o+a&&(n.style.top=c-o+window.pageYOffset-a+"px")}n.isConnected||(null!=o&&(n.className=o),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("id","typeahead-menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute",l.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[r,e,o,l]);f((()=>{const t=r.getRootElement();if(null!==e)return u(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[r,u,e]);const c=h((t=>{null!==e&&(t||n(null))}),[e,n]);return R(e,i.current,u,c),i}(w,y,c,m),C=h((()=>{y(null),null!=l&&null!==w&&l()}),[l,w]),x=h((t=>{y(t),null!=r&&null===w&&r(t)}),[r,w]),I=h((t=>{t.preventDefault(),null!=o&&o(t);const e=n(t.target);x({getRect:()=>new DOMRect(t.clientX/e,t.clientY/e,1,1)})}),[x,o]),S=h((t=>{null===w||null==b.current||null==t.target||b.current.contains(t.target)||C()}),[C,w]);return f((()=>{const t=p.getRootElement();if(t)return t.addEventListener("contextmenu",I),()=>t.removeEventListener("contextmenu",I)}),[p,I]),f((()=>(document.addEventListener("click",S),()=>document.removeEventListener("click",S))),[p,S]),null===w||null===p?null:d.createElement(O,{close:C,resolution:w,editor:p,anchorElementRef:E,options:e,menuRenderFn:(t,e)=>u(t,e,{setMenuRef:t=>{b.current=t}}),onSelectOption:i,commandPriority:a})}export{I as LexicalContextMenuPlugin,b as MenuOption};
9
+ import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{mergeRegister as e,calculateZoomLevel as n}from"@lexical/utils";import{createCommand as o,KEY_ARROW_DOWN_COMMAND as l,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as i,KEY_TAB_COMMAND as u,KEY_ENTER_COMMAND as c,COMMAND_PRIORITY_LOW as s,$getSelection as a,$isRangeSelection as m}from"lexical";import*as d from"react";import{useLayoutEffect as p,useEffect as f,useState as g,useCallback as h,useMemo as w,useRef as v}from"react";import{jsx as y}from"react/jsx-runtime";const b="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?p:f;class C{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const E=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function R(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function x(e,n,o,l){const[r]=t();f((()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,u=R(n,e);const c=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=R(n,e);t!==u&&(u=t,null!=l&&l(t))},s=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",c,{capture:!0,passive:!0}),s.observe(n),()=>{s.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",c,!0)}}}),[n,r,l,o,e])}const O=o("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function I({close:t,editor:n,anchorElementRef:o,resolution:d,options:p,menuRenderFn:v,onSelectOption:y,shouldSplitNodeWithQuery:C=!1,commandPriority:R=s}){const[x,I]=g(null),S=d.match&&d.match.matchingString;f((()=>{I(0)}),[S]);const A=h((e=>{n.update((()=>{const n=null!=d.match&&C?function(t){const e=a();if(!m(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,u=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.substr(-n)===e.substr(0,n)&&(o=n);return o}(r,t.matchingString,i);if(u<0)return null;let c;return 0===u?[c]=o.splitText(l):[,c]=o.splitText(u,l),c}(d.match):null;y(e,n,t,d.match?d.match.matchingString:"")}))}),[n,C,d.match,y,t]),L=h((t=>{const e=n.getRootElement();null!==e&&(e.setAttribute("aria-activedescendant","typeahead-item-"+t),I(t))}),[n]);f((()=>()=>{const t=n.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[n]),b((()=>{null===p?I(null):null===x&&L(0)}),[p,x,L]),f((()=>e(n.registerCommand(O,(({option:t})=>!(!t.ref||null==t.ref.current)&&(E(t.ref.current),!0)),R))),[n,L,R]),f((()=>e(n.registerCommand(l,(t=>{const e=t;if(null!==p&&p.length&&null!==x){const t=x!==p.length-1?x+1:0;L(t);const o=p[t];null!=o.ref&&o.ref.current&&n.dispatchCommand(O,{index:t,option:o}),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(r,(t=>{const e=t;if(null!==p&&p.length&&null!==x){const t=0!==x?x-1:p.length-1;L(t);const n=p[t];null!=n.ref&&n.ref.current&&E(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(i,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),R),n.registerCommand(u,(t=>{const e=t;return null!==p&&null!==x&&null!=p[x]&&(e.preventDefault(),e.stopImmediatePropagation(),A(p[x]),!0)}),R),n.registerCommand(c,(t=>null!==p&&null!==x&&null!=p[x]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(p[x]),!0)),R))),[A,t,n,p,x,L,R]);return v(o,w((()=>({options:p,selectOptionAndCleanUp:A,selectedIndex:x,setHighlightedIndex:I})),[A,x,p]),d.match?d.match.matchingString:"")}function S({options:e,onWillOpen:o,onClose:l,onOpen:r,onSelectOption:i,menuRenderFn:u,anchorClassName:c,commandPriority:a=s,parent:m}){const[p]=t(),[w,b]=g(null),C=d.useRef(null),E=function(e,n,o,l=document.body){const[r]=t(),i=v(document.createElement("div")),u=h((()=>{i.current.style.top=i.current.style.bottom;const t=r.getRootElement(),n=i.current,u=n.firstChild;if(null!==t&&null!==e){const{left:r,top:c,width:s,height:a}=e.getRect(),m=i.current.offsetHeight;if(n.style.top=`${c+window.pageYOffset+m+3}px`,n.style.left=`${r+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${s}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,l=e.width,i=t.getBoundingClientRect();r+l>i.right&&(n.style.left=`${i.right-l+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>i.bottom)&&c-i.top>o+a&&(n.style.top=c-o+window.pageYOffset-a+"px")}n.isConnected||(null!=o&&(n.className=o),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("id","typeahead-menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute",l.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[r,e,o,l]);f((()=>{const t=r.getRootElement();if(null!==e)return u(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[r,u,e]);const c=h((t=>{null!==e&&(t||n(null))}),[e,n]);return x(e,i.current,u,c),i}(w,b,c,m),R=h((()=>{b(null),null!=l&&null!==w&&l()}),[l,w]),O=h((t=>{b(t),null!=r&&null===w&&r(t)}),[r,w]),S=h((t=>{t.preventDefault(),null!=o&&o(t);const e=n(t.target);O({getRect:()=>new DOMRect(t.clientX/e,t.clientY/e,1,1)})}),[O,o]),A=h((t=>{null===w||null==C.current||null==t.target||C.current.contains(t.target)||R()}),[R,w]);return f((()=>{const t=p.getRootElement();if(t)return t.addEventListener("contextmenu",S),()=>t.removeEventListener("contextmenu",S)}),[p,S]),f((()=>(document.addEventListener("click",A),()=>document.removeEventListener("click",A))),[p,A]),null===w||null===p?null:y(I,{close:R,resolution:w,editor:p,anchorElementRef:E,options:e,menuRenderFn:(t,e)=>u(t,e,{setMenuRef:t=>{C.current=t}}),onSelectOption:i,commandPriority:a})}export{S as LexicalContextMenuPlugin,C as MenuOption};