@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,22 +6,22 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var k=require("@lexical/react/LexicalComposerContext"),q=require("lexical"),y=require("react"),z=require("@lexical/utils"),B=Object.create(null);if(y)for(var C in y)B[C]=y[C];B.default=y;let D="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?y.useLayoutEffect:y.useEffect;class E{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}
10
- let F=b=>{const a=document.getElementById("typeahead-menu");if(a){var c=a.getBoundingClientRect();c.top+c.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>c.top&&a.scrollIntoView({block:"center"});b.scrollIntoView({block:"nearest"})}};
11
- function G(b){var a=q.$getSelection();if(!q.$isRangeSelection(a)||!a.isCollapsed())return null;var c=a.anchor;if("text"!==c.type)return null;a=c.getNode();if(!a.isSimpleText())return null;c=c.offset;let d=a.getTextContent().slice(0,c);var f=b.matchingString;b=b.replaceableString.length;for(let r=b;r<=f.length;r++)d.substr(-r)===f.substr(0,r)&&(b=r);b=c-b;if(0>b)return null;let n;0===b?[n]=a.splitText(c):[,n]=a.splitText(b,c);return n}
12
- function J(b){let a=getComputedStyle(b),c="absolute"===a.position,d=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;b=b.parentElement;)if(a=getComputedStyle(b),(!c||"static"!==a.position)&&d.test(a.overflow+a.overflowY+a.overflowX))return b;return document.body}function K(b,a){b=b.getBoundingClientRect();a=a.getBoundingClientRect();return b.top>a.top&&b.top<a.bottom}
13
- function L(b,a,c,d){let [f]=k.useLexicalComposerContext();y.useEffect(()=>{if(null!=a&&null!=b){let n=f.getRootElement(),r=null!=n?J(n):document.body,v=!1,p=K(a,r),e=function(){v||(window.requestAnimationFrame(function(){c();v=!1}),v=!0);const l=K(a,r);l!==p&&(p=l,null!=d&&d(l))},h=new ResizeObserver(c);window.addEventListener("resize",c);document.addEventListener("scroll",e,{capture:!0,passive:!0});h.observe(a);return()=>{h.unobserve(a);window.removeEventListener("resize",c);document.removeEventListener("scroll",
14
- e,!0)}}},[a,f,d,c,b])}let M=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
15
- function N({close:b,editor:a,anchorElementRef:c,resolution:d,options:f,menuRenderFn:n,onSelectOption:r,shouldSplitNodeWithQuery:v=!1,commandPriority:p=q.COMMAND_PRIORITY_LOW}){let [e,h]=y.useState(null);y.useEffect(()=>{h(0)},[d.match&&d.match.matchingString]);let l=y.useCallback(g=>{a.update(()=>{const m=null!=d.match&&v?G(d.match):null;r(g,m,b,d.match?d.match.matchingString:"")})},[a,v,d.match,r,b]),t=y.useCallback(g=>{const m=a.getRootElement();null!==m&&(m.setAttribute("aria-activedescendant",
16
- "typeahead-item-"+g),h(g))},[a]);y.useEffect(()=>()=>{let g=a.getRootElement();null!==g&&g.removeAttribute("aria-activedescendant")},[a]);D(()=>{null===f?h(null):null===e&&t(0)},[f,e,t]);y.useEffect(()=>z.mergeRegister(a.registerCommand(M,({option:g})=>g.ref&&null!=g.ref.current?(F(g.ref.current),!0):!1,p)),[a,t,p]);y.useEffect(()=>z.mergeRegister(a.registerCommand(q.KEY_ARROW_DOWN_COMMAND,g=>{if(null!==f&&f.length&&null!==e){let m=e!==f.length-1?e+1:0;t(m);let w=f[m];null!=w.ref&&w.ref.current&&
17
- a.dispatchCommand(M,{index:m,option:w});g.preventDefault();g.stopImmediatePropagation()}return!0},p),a.registerCommand(q.KEY_ARROW_UP_COMMAND,g=>{if(null!==f&&f.length&&null!==e){var m=0!==e?e-1:f.length-1;t(m);m=f[m];null!=m.ref&&m.ref.current&&F(m.ref.current);g.preventDefault();g.stopImmediatePropagation()}return!0},p),a.registerCommand(q.KEY_ESCAPE_COMMAND,g=>{g.preventDefault();g.stopImmediatePropagation();b();return!0},p),a.registerCommand(q.KEY_TAB_COMMAND,g=>{if(null===f||null===e||null==
9
+ 'use strict';var k=require("@lexical/react/LexicalComposerContext"),q=require("lexical"),y=require("react"),z=require("@lexical/utils"),B=require("react/jsx-runtime"),C=Object.create(null);if(y)for(var D in y)C[D]=y[D];C.default=y;let E="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?y.useLayoutEffect:y.useEffect;
10
+ class F{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}let G=b=>{const a=document.getElementById("typeahead-menu");if(a){var c=a.getBoundingClientRect();c.top+c.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>c.top&&a.scrollIntoView({block:"center"});b.scrollIntoView({block:"nearest"})}};
11
+ function J(b){var a=q.$getSelection();if(!q.$isRangeSelection(a)||!a.isCollapsed())return null;var c=a.anchor;if("text"!==c.type)return null;a=c.getNode();if(!a.isSimpleText())return null;c=c.offset;let d=a.getTextContent().slice(0,c);var f=b.matchingString;b=b.replaceableString.length;for(let r=b;r<=f.length;r++)d.substr(-r)===f.substr(0,r)&&(b=r);b=c-b;if(0>b)return null;let n;0===b?[n]=a.splitText(c):[,n]=a.splitText(b,c);return n}
12
+ function K(b){let a=getComputedStyle(b),c="absolute"===a.position,d=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;b=b.parentElement;)if(a=getComputedStyle(b),(!c||"static"!==a.position)&&d.test(a.overflow+a.overflowY+a.overflowX))return b;return document.body}function L(b,a){b=b.getBoundingClientRect();a=a.getBoundingClientRect();return b.top>a.top&&b.top<a.bottom}
13
+ function M(b,a,c,d){let [f]=k.useLexicalComposerContext();y.useEffect(()=>{if(null!=a&&null!=b){let n=f.getRootElement(),r=null!=n?K(n):document.body,v=!1,p=L(a,r),e=function(){v||(window.requestAnimationFrame(function(){c();v=!1}),v=!0);const l=L(a,r);l!==p&&(p=l,null!=d&&d(l))},h=new ResizeObserver(c);window.addEventListener("resize",c);document.addEventListener("scroll",e,{capture:!0,passive:!0});h.observe(a);return()=>{h.unobserve(a);window.removeEventListener("resize",c);document.removeEventListener("scroll",
14
+ e,!0)}}},[a,f,d,c,b])}let N=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
15
+ function O({close:b,editor:a,anchorElementRef:c,resolution:d,options:f,menuRenderFn:n,onSelectOption:r,shouldSplitNodeWithQuery:v=!1,commandPriority:p=q.COMMAND_PRIORITY_LOW}){let [e,h]=y.useState(null);y.useEffect(()=>{h(0)},[d.match&&d.match.matchingString]);let l=y.useCallback(g=>{a.update(()=>{const m=null!=d.match&&v?J(d.match):null;r(g,m,b,d.match?d.match.matchingString:"")})},[a,v,d.match,r,b]),t=y.useCallback(g=>{const m=a.getRootElement();null!==m&&(m.setAttribute("aria-activedescendant",
16
+ "typeahead-item-"+g),h(g))},[a]);y.useEffect(()=>()=>{let g=a.getRootElement();null!==g&&g.removeAttribute("aria-activedescendant")},[a]);E(()=>{null===f?h(null):null===e&&t(0)},[f,e,t]);y.useEffect(()=>z.mergeRegister(a.registerCommand(N,({option:g})=>g.ref&&null!=g.ref.current?(G(g.ref.current),!0):!1,p)),[a,t,p]);y.useEffect(()=>z.mergeRegister(a.registerCommand(q.KEY_ARROW_DOWN_COMMAND,g=>{if(null!==f&&f.length&&null!==e){let m=e!==f.length-1?e+1:0;t(m);let w=f[m];null!=w.ref&&w.ref.current&&
17
+ a.dispatchCommand(N,{index:m,option:w});g.preventDefault();g.stopImmediatePropagation()}return!0},p),a.registerCommand(q.KEY_ARROW_UP_COMMAND,g=>{if(null!==f&&f.length&&null!==e){var m=0!==e?e-1:f.length-1;t(m);m=f[m];null!=m.ref&&m.ref.current&&G(m.ref.current);g.preventDefault();g.stopImmediatePropagation()}return!0},p),a.registerCommand(q.KEY_ESCAPE_COMMAND,g=>{g.preventDefault();g.stopImmediatePropagation();b();return!0},p),a.registerCommand(q.KEY_TAB_COMMAND,g=>{if(null===f||null===e||null==
18
18
  f[e])return!1;g.preventDefault();g.stopImmediatePropagation();l(f[e]);return!0},p),a.registerCommand(q.KEY_ENTER_COMMAND,g=>{if(null===f||null===e||null==f[e])return!1;null!==g&&(g.preventDefault(),g.stopImmediatePropagation());l(f[e]);return!0},p)),[l,b,a,f,e,t,p]);let u=y.useMemo(()=>({options:f,selectOptionAndCleanUp:l,selectedIndex:e,setHighlightedIndex:h}),[l,e,f]);return n(c,u,d.match?d.match.matchingString:"")}
19
- function O(b,a,c,d=document.body){let [f]=k.useLexicalComposerContext(),n=y.useRef(document.createElement("div")),r=y.useCallback(()=>{n.current.style.top=n.current.style.bottom;const p=f.getRootElement(),e=n.current;var h=e.firstChild;if(null!==p&&null!==b){const {left:t,top:u,width:g,height:m}=b.getRect();e.style.top=`${u+window.pageYOffset+n.current.offsetHeight+3}px`;e.style.left=`${t+window.pageXOffset}px`;e.style.height=`${m}px`;e.style.width=`${g}px`;if(null!==h){h.style.top=`${u}`;var l=h.getBoundingClientRect();
19
+ function P(b,a,c,d=document.body){let [f]=k.useLexicalComposerContext(),n=y.useRef(document.createElement("div")),r=y.useCallback(()=>{n.current.style.top=n.current.style.bottom;const p=f.getRootElement(),e=n.current;var h=e.firstChild;if(null!==p&&null!==b){const {left:t,top:u,width:g,height:m}=b.getRect();e.style.top=`${u+window.pageYOffset+n.current.offsetHeight+3}px`;e.style.left=`${t+window.pageXOffset}px`;e.style.height=`${m}px`;e.style.width=`${g}px`;if(null!==h){h.style.top=`${u}`;var l=h.getBoundingClientRect();
20
20
  h=l.height;l=l.width;const w=p.getBoundingClientRect();t+l>w.right&&(e.style.left=`${w.right-l+window.pageXOffset}px`);(u+h>window.innerHeight||u+h>w.bottom)&&u-w.top>h+m&&(e.style.top=`${u-h+window.pageYOffset-m}px`)}e.isConnected||(null!=c&&(e.className=c),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("id","typeahead-menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute",d.append(e));n.current=e;p.setAttribute("aria-controls","typeahead-menu")}},
21
- [f,b,c,d]);y.useEffect(()=>{let p=f.getRootElement();if(null!==b)return r(),()=>{null!==p&&p.removeAttribute("aria-controls");let e=n.current;null!==e&&e.isConnected&&e.remove()}},[f,r,b]);let v=y.useCallback(p=>{null!==b&&(p||a(null))},[b,a]);L(b,n.current,r,v);return n}function P(b,a,c){var d=c.getSelection();if(null===d||!d.isCollapsed)return!1;c=d.anchorNode;d=d.anchorOffset;if(null==c||null==d)return!1;try{a.setStart(c,b),a.setEnd(c,d)}catch(f){return!1}return!0}
22
- function Q(b){let a=null;b.getEditorState().read(()=>{var c=q.$getSelection();if(q.$isRangeSelection(c)){var d=c.anchor;"text"!==d.type?a=null:(c=d.getNode(),c.isSimpleText()?(d=d.offset,a=c.getTextContent().slice(0,d)):a=null)}});return a}function R(b,a){return 0!==a?!1:b.getEditorState().read(()=>{var c=q.$getSelection();return q.$isRangeSelection(c)?(c=c.anchor.getNode().getPreviousSibling(),q.$isTextNode(c)&&c.isTextEntity()):!1})}function S(b){B.startTransition?B.startTransition(b):b()}
23
- let T=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
24
- exports.LexicalTypeaheadMenuPlugin=function({options:b,onQueryChange:a,onSelectOption:c,onOpen:d,onClose:f,menuRenderFn:n,triggerFn:r,anchorClassName:v,commandPriority:p=q.COMMAND_PRIORITY_LOW,parent:e}){let [h]=k.useLexicalComposerContext(),[l,t]=y.useState(null);v=O(l,t,v,e);let u=y.useCallback(()=>{t(null);null!=f&&null!==l&&f()},[f,l]),g=y.useCallback(m=>{t(m);null!=d&&null===l&&d(m)},[d,l]);y.useEffect(()=>{let m=h.registerUpdateListener(()=>{h.getEditorState().read(()=>{const w=h._window||window,
25
- A=w.document.createRange(),H=q.$getSelection(),I=Q(h);if(q.$isRangeSelection(H)&&H.isCollapsed()&&null!==I&&null!==A){var x=r(I,h);a(x?x.matchingString:null);null===x||R(h,x.leadOffset)||null===P(x.leadOffset,A,w)?u():S(()=>g({getRect:()=>A.getBoundingClientRect(),match:x}))}else u()})});return()=>{m()}},[h,r,a,l,u,g]);return null===l||null===h?null:B.createElement(N,{close:u,resolution:l,editor:h,anchorElementRef:v,options:b,menuRenderFn:n,shouldSplitNodeWithQuery:!0,onSelectOption:c,commandPriority:p})};
26
- exports.MenuOption=E;exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=T;exports.getScrollParent=function(b,a){let c=getComputedStyle(b),d="absolute"===c.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===c.position)return document.body;for(;b=b.parentElement;)if(c=getComputedStyle(b),(!d||"static"!==c.position)&&a.test(c.overflow+c.overflowY+c.overflowX))return b;return document.body};
27
- exports.useBasicTypeaheadTriggerMatch=function(b,{minLength:a=1,maxLength:c=75}){return y.useCallback(d=>{d=(new RegExp("(^|\\s|\\()(["+b+"]((?:[^"+(b+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+c+"}))$")).exec(d);if(null!==d){let f=d[1],n=d[3];if(n.length>=a)return{leadOffset:d.index+f.length,matchingString:n,replaceableString:d[2]}}return null},[c,a,b])};exports.useDynamicPositioning=L
21
+ [f,b,c,d]);y.useEffect(()=>{let p=f.getRootElement();if(null!==b)return r(),()=>{null!==p&&p.removeAttribute("aria-controls");let e=n.current;null!==e&&e.isConnected&&e.remove()}},[f,r,b]);let v=y.useCallback(p=>{null!==b&&(p||a(null))},[b,a]);M(b,n.current,r,v);return n}function Q(b,a,c){var d=c.getSelection();if(null===d||!d.isCollapsed)return!1;c=d.anchorNode;d=d.anchorOffset;if(null==c||null==d)return!1;try{a.setStart(c,b),a.setEnd(c,d)}catch(f){return!1}return!0}
22
+ function R(b){let a=null;b.getEditorState().read(()=>{var c=q.$getSelection();if(q.$isRangeSelection(c)){var d=c.anchor;"text"!==d.type?a=null:(c=d.getNode(),c.isSimpleText()?(d=d.offset,a=c.getTextContent().slice(0,d)):a=null)}});return a}function S(b,a){return 0!==a?!1:b.getEditorState().read(()=>{var c=q.$getSelection();return q.$isRangeSelection(c)?(c=c.anchor.getNode().getPreviousSibling(),q.$isTextNode(c)&&c.isTextEntity()):!1})}function T(b){C.startTransition?C.startTransition(b):b()}
23
+ let U=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
24
+ exports.LexicalTypeaheadMenuPlugin=function({options:b,onQueryChange:a,onSelectOption:c,onOpen:d,onClose:f,menuRenderFn:n,triggerFn:r,anchorClassName:v,commandPriority:p=q.COMMAND_PRIORITY_LOW,parent:e}){let [h]=k.useLexicalComposerContext(),[l,t]=y.useState(null);v=P(l,t,v,e);let u=y.useCallback(()=>{t(null);null!=f&&null!==l&&f()},[f,l]),g=y.useCallback(m=>{t(m);null!=d&&null===l&&d(m)},[d,l]);y.useEffect(()=>{let m=h.registerUpdateListener(()=>{h.getEditorState().read(()=>{const w=h._window||window,
25
+ A=w.document.createRange(),H=q.$getSelection(),I=R(h);if(q.$isRangeSelection(H)&&H.isCollapsed()&&null!==I&&null!==A){var x=r(I,h);a(x?x.matchingString:null);null===x||S(h,x.leadOffset)||null===Q(x.leadOffset,A,w)?u():T(()=>g({getRect:()=>A.getBoundingClientRect(),match:x}))}else u()})});return()=>{m()}},[h,r,a,l,u,g]);return null===l||null===h?null:B.jsx(O,{close:u,resolution:l,editor:h,anchorElementRef:v,options:b,menuRenderFn:n,shouldSplitNodeWithQuery:!0,onSelectOption:c,commandPriority:p})};
26
+ exports.MenuOption=F;exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=U;exports.getScrollParent=function(b,a){let c=getComputedStyle(b),d="absolute"===c.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===c.position)return document.body;for(;b=b.parentElement;)if(c=getComputedStyle(b),(!d||"static"!==c.position)&&a.test(c.overflow+c.overflowY+c.overflowX))return b;return document.body};
27
+ exports.useBasicTypeaheadTriggerMatch=function(b,{minLength:a=1,maxLength:c=75}){return y.useCallback(d=>{d=(new RegExp("(^|\\s|\\()(["+b+"]((?:[^"+(b+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+c+"}))$")).exec(d);if(null!==d){let f=d[1],n=d[3];if(n.length>=a)return{leadOffset:d.index+f.length,matchingString:n,replaceableString:d[2]}}return null},[c,a,b])};exports.useDynamicPositioning=M
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,KEY_ARROW_DOWN_COMMAND as n,KEY_ARROW_UP_COMMAND as o,KEY_ESCAPE_COMMAND as r,KEY_TAB_COMMAND as l,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as s,$getSelection as u,$isRangeSelection as c,$isTextNode as a}from"lexical";import*as d from"react";import{useLayoutEffect as m,useEffect as f,useState as p,useCallback as g,useMemo as h,useRef as w}from"react";import{mergeRegister as y}from"@lexical/utils";const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?m: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 v=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 E(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function x(e,n,o,r){const[l]=t();f((()=>{if(null!=n&&null!=e){const t=l.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,s=E(n,e);const u=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=E(n,e);t!==s&&(s=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",u,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",u,!0)}}}),[n,l,r,o,e])}const S=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function R({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:w,onSelectOption:b,shouldSplitNodeWithQuery:E=!1,commandPriority:x=s}){const[R,O]=p(null),I=d.match&&d.match.matchingString;f((()=>{O(0)}),[I]);const T=g((n=>{e.update((()=>{const e=null!=d.match&&E?function(t){const e=u();if(!c(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 r=n.offset,l=o.getTextContent().slice(0,r),i=t.replaceableString.length,s=r-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}(l,t.matchingString,i);if(s<0)return null;let a;return 0===s?[a]=o.splitText(r):[,a]=o.splitText(s,r),a}(d.match):null;b(n,e,t,d.match?d.match.matchingString:"")}))}),[e,E,d.match,b,t]),A=g((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))}),[e]);f((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),C((()=>{null===m?O(null):null===R&&A(0)}),[m,R,A]),f((()=>y(e.registerCommand(S,(({option:t})=>!(!t.ref||null==t.ref.current)&&(v(t.ref.current),!0)),x))),[e,A,x]),f((()=>y(e.registerCommand(n,(t=>{const n=t;if(null!==m&&m.length&&null!==R){const t=R!==m.length-1?R+1:0;A(t);const o=m[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(S,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),x),e.registerCommand(o,(t=>{const e=t;if(null!==m&&m.length&&null!==R){const t=0!==R?R-1:m.length-1;A(t);const n=m[t];null!=n.ref&&n.ref.current&&v(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),x),e.registerCommand(r,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),x),e.registerCommand(l,(t=>{const e=t;return null!==m&&null!==R&&null!=m[R]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[R]),!0)}),x),e.registerCommand(i,(t=>null!==m&&null!==R&&null!=m[R]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[R]),!0)),x))),[T,t,e,m,R,A,x]);return w(a,h((()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:R,setHighlightedIndex:O})),[T,R,m]),d.match?d.match.matchingString:"")}const O="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function I(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=e?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}const T=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function A(t,{minLength:e=1,maxLength:n=75}){return g((o=>{const r=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+O+"\\s]")+"){0,"+n+"}))$").exec(o);if(null!==r){const t=r[1],n=r[3];if(n.length>=e)return{leadOffset:r.index+t.length,matchingString:n,replaceableString:r[2]}}return null}),[n,e,t])}function N({options:e,onQueryChange:n,onSelectOption:o,onOpen:r,onClose:l,menuRenderFn:i,triggerFn:m,anchorClassName:h,commandPriority:y=s,parent:C}){const[b]=t(),[v,E]=p(null),S=function(e,n,o,r=document.body){const[l]=t(),i=w(document.createElement("div")),s=g((()=>{i.current.style.top=i.current.style.bottom;const t=l.getRootElement(),n=i.current,s=n.firstChild;if(null!==t&&null!==e){const{left:l,top:u,width:c,height:a}=e.getRect(),d=i.current.offsetHeight;if(n.style.top=`${u+window.pageYOffset+d+3}px`,n.style.left=`${l+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==s){s.style.top=`${u}`;const e=s.getBoundingClientRect(),o=e.height,r=e.width,i=t.getBoundingClientRect();l+r>i.right&&(n.style.left=`${i.right-r+window.pageXOffset}px`),(u+o>window.innerHeight||u+o>i.bottom)&&u-i.top>o+a&&(n.style.top=u-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",r.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[l,e,o,r]);f((()=>{const t=l.getRootElement();if(null!==e)return s(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[l,s,e]);const u=g((t=>{null!==e&&(t||n(null))}),[e,n]);return x(e,i.current,s,u),i}(v,E,h,C),O=g((()=>{E(null),null!=l&&null!==v&&l()}),[l,v]),I=g((t=>{E(t),null!=r&&null===v&&r(t)}),[r,v]);return f((()=>{const t=b.registerUpdateListener((()=>{b.getEditorState().read((()=>{const t=b._window||window,e=t.document.createRange(),o=u(),r=function(t){let e=null;return t.getEditorState().read((()=>{const t=u();c(t)&&(e=function(t){const e=t.anchor;if("text"!==e.type)return null;const n=e.getNode();if(!n.isSimpleText())return null;const o=e.offset;return n.getTextContent().slice(0,o)}(t))})),e}(b);if(!c(o)||!o.isCollapsed()||null===r||null===e)return void O();const l=m(r,b);if(n(l?l.matchingString:null),null!==l&&!function(t,e){return 0===e&&t.getEditorState().read((()=>{const t=u();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return a(e)&&e.isTextEntity()}return!1}))}(b,l.leadOffset)){const n=function(t,e,n){const o=n.getSelection();if(null===o||!o.isCollapsed)return!1;const r=o.anchorNode,l=t,i=o.anchorOffset;if(null==r||null==i)return!1;try{e.setStart(r,l),e.setEnd(r,i)}catch(t){return!1}return!0}(l.leadOffset,e,t);if(null!==n)return i=()=>I({getRect:()=>e.getBoundingClientRect(),match:l}),void(d.startTransition?d.startTransition(i):i())}var i;O()}))}));return()=>{t()}}),[b,m,n,v,O,I]),null===v||null===b?null:d.createElement(R,{close:O,resolution:v,editor:b,anchorElementRef:S,options:e,menuRenderFn:i,shouldSplitNodeWithQuery:!0,onSelectOption:o,commandPriority:y})}export{N as LexicalTypeaheadMenuPlugin,b as MenuOption,O as PUNCTUATION,T as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,I as getScrollParent,A as useBasicTypeaheadTriggerMatch,x as useDynamicPositioning};
9
+ import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,KEY_ARROW_DOWN_COMMAND as n,KEY_ARROW_UP_COMMAND as o,KEY_ESCAPE_COMMAND as r,KEY_TAB_COMMAND as l,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as s,$getSelection as u,$isRangeSelection as c,$isTextNode as a}from"lexical";import*as d from"react";import{useLayoutEffect as m,useEffect as f,useState as p,useCallback as g,useMemo as h,useRef as w}from"react";import{mergeRegister as y}from"@lexical/utils";import{jsx as C}from"react/jsx-runtime";const b="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?m:f;class v{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const x=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 E(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function S(e,n,o,r){const[l]=t();f((()=>{if(null!=n&&null!=e){const t=l.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,s=E(n,e);const u=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=E(n,e);t!==s&&(s=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",u,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",u,!0)}}}),[n,l,r,o,e])}const R=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:w,onSelectOption:C,shouldSplitNodeWithQuery:v=!1,commandPriority:E=s}){const[S,O]=p(null),I=d.match&&d.match.matchingString;f((()=>{O(0)}),[I]);const T=g((n=>{e.update((()=>{const e=null!=d.match&&v?function(t){const e=u();if(!c(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 r=n.offset,l=o.getTextContent().slice(0,r),i=t.replaceableString.length,s=r-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}(l,t.matchingString,i);if(s<0)return null;let a;return 0===s?[a]=o.splitText(r):[,a]=o.splitText(s,r),a}(d.match):null;C(n,e,t,d.match?d.match.matchingString:"")}))}),[e,v,d.match,C,t]),A=g((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))}),[e]);f((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),b((()=>{null===m?O(null):null===S&&A(0)}),[m,S,A]),f((()=>y(e.registerCommand(R,(({option:t})=>!(!t.ref||null==t.ref.current)&&(x(t.ref.current),!0)),E))),[e,A,E]),f((()=>y(e.registerCommand(n,(t=>{const n=t;if(null!==m&&m.length&&null!==S){const t=S!==m.length-1?S+1:0;A(t);const o=m[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(R,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),E),e.registerCommand(o,(t=>{const e=t;if(null!==m&&m.length&&null!==S){const t=0!==S?S-1:m.length-1;A(t);const n=m[t];null!=n.ref&&n.ref.current&&x(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),E),e.registerCommand(r,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),E),e.registerCommand(l,(t=>{const e=t;return null!==m&&null!==S&&null!=m[S]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[S]),!0)}),E),e.registerCommand(i,(t=>null!==m&&null!==S&&null!=m[S]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[S]),!0)),E))),[T,t,e,m,S,A,E]);return w(a,h((()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:S,setHighlightedIndex:O})),[T,S,m]),d.match?d.match.matchingString:"")}const I="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function T(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=e?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}const A=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function N(t,{minLength:e=1,maxLength:n=75}){return g((o=>{const r=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+I+"\\s]")+"){0,"+n+"}))$").exec(o);if(null!==r){const t=r[1],n=r[3];if(n.length>=e)return{leadOffset:r.index+t.length,matchingString:n,replaceableString:r[2]}}return null}),[n,e,t])}function P({options:e,onQueryChange:n,onSelectOption:o,onOpen:r,onClose:l,menuRenderFn:i,triggerFn:m,anchorClassName:h,commandPriority:y=s,parent:b}){const[v]=t(),[x,E]=p(null),R=function(e,n,o,r=document.body){const[l]=t(),i=w(document.createElement("div")),s=g((()=>{i.current.style.top=i.current.style.bottom;const t=l.getRootElement(),n=i.current,s=n.firstChild;if(null!==t&&null!==e){const{left:l,top:u,width:c,height:a}=e.getRect(),d=i.current.offsetHeight;if(n.style.top=`${u+window.pageYOffset+d+3}px`,n.style.left=`${l+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==s){s.style.top=`${u}`;const e=s.getBoundingClientRect(),o=e.height,r=e.width,i=t.getBoundingClientRect();l+r>i.right&&(n.style.left=`${i.right-r+window.pageXOffset}px`),(u+o>window.innerHeight||u+o>i.bottom)&&u-i.top>o+a&&(n.style.top=u-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",r.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[l,e,o,r]);f((()=>{const t=l.getRootElement();if(null!==e)return s(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[l,s,e]);const u=g((t=>{null!==e&&(t||n(null))}),[e,n]);return S(e,i.current,s,u),i}(x,E,h,b),I=g((()=>{E(null),null!=l&&null!==x&&l()}),[l,x]),T=g((t=>{E(t),null!=r&&null===x&&r(t)}),[r,x]);return f((()=>{const t=v.registerUpdateListener((()=>{v.getEditorState().read((()=>{const t=v._window||window,e=t.document.createRange(),o=u(),r=function(t){let e=null;return t.getEditorState().read((()=>{const t=u();c(t)&&(e=function(t){const e=t.anchor;if("text"!==e.type)return null;const n=e.getNode();if(!n.isSimpleText())return null;const o=e.offset;return n.getTextContent().slice(0,o)}(t))})),e}(v);if(!c(o)||!o.isCollapsed()||null===r||null===e)return void I();const l=m(r,v);if(n(l?l.matchingString:null),null!==l&&!function(t,e){return 0===e&&t.getEditorState().read((()=>{const t=u();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return a(e)&&e.isTextEntity()}return!1}))}(v,l.leadOffset)){const n=function(t,e,n){const o=n.getSelection();if(null===o||!o.isCollapsed)return!1;const r=o.anchorNode,l=t,i=o.anchorOffset;if(null==r||null==i)return!1;try{e.setStart(r,l),e.setEnd(r,i)}catch(t){return!1}return!0}(l.leadOffset,e,t);if(null!==n)return i=()=>T({getRect:()=>e.getBoundingClientRect(),match:l}),void(d.startTransition?d.startTransition(i):i())}var i;I()}))}));return()=>{t()}}),[v,m,n,x,I,T]),null===x||null===v?null:C(O,{close:I,resolution:x,editor:v,anchorElementRef:R,options:e,menuRenderFn:i,shouldSplitNodeWithQuery:!0,onSelectOption:o,commandPriority:y})}export{P as LexicalTypeaheadMenuPlugin,v as MenuOption,I as PUNCTUATION,A as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,T as getScrollParent,N as useBasicTypeaheadTriggerMatch,S as useDynamicPositioning};
package/package.json CHANGED
@@ -8,27 +8,27 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.15.0",
11
+ "version": "0.16.0",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.15.0",
14
- "@lexical/code": "0.15.0",
15
- "@lexical/devtools-core": "0.15.0",
16
- "@lexical/dragon": "0.15.0",
17
- "@lexical/hashtag": "0.15.0",
18
- "@lexical/history": "0.15.0",
19
- "@lexical/link": "0.15.0",
20
- "@lexical/list": "0.15.0",
21
- "@lexical/mark": "0.15.0",
22
- "@lexical/markdown": "0.15.0",
23
- "@lexical/overflow": "0.15.0",
24
- "@lexical/plain-text": "0.15.0",
25
- "@lexical/rich-text": "0.15.0",
26
- "@lexical/selection": "0.15.0",
27
- "@lexical/table": "0.15.0",
28
- "@lexical/text": "0.15.0",
29
- "@lexical/utils": "0.15.0",
30
- "@lexical/yjs": "0.15.0",
31
- "lexical": "0.15.0",
13
+ "@lexical/clipboard": "0.16.0",
14
+ "@lexical/code": "0.16.0",
15
+ "@lexical/devtools-core": "0.16.0",
16
+ "@lexical/dragon": "0.16.0",
17
+ "@lexical/hashtag": "0.16.0",
18
+ "@lexical/history": "0.16.0",
19
+ "@lexical/link": "0.16.0",
20
+ "@lexical/list": "0.16.0",
21
+ "@lexical/mark": "0.16.0",
22
+ "@lexical/markdown": "0.16.0",
23
+ "@lexical/overflow": "0.16.0",
24
+ "@lexical/plain-text": "0.16.0",
25
+ "@lexical/rich-text": "0.16.0",
26
+ "@lexical/selection": "0.16.0",
27
+ "@lexical/table": "0.16.0",
28
+ "@lexical/text": "0.16.0",
29
+ "@lexical/utils": "0.16.0",
30
+ "@lexical/yjs": "0.16.0",
31
+ "lexical": "0.16.0",
32
32
  "react-error-boundary": "^3.1.4"
33
33
  },
34
34
  "peerDependencies": {
@@ -1001,6 +1001,36 @@
1001
1001
  "default": "./LexicalTableOfContents.js"
1002
1002
  }
1003
1003
  },
1004
+ "./LexicalTableOfContentsPlugin": {
1005
+ "import": {
1006
+ "types": "./LexicalTableOfContentsPlugin.d.ts",
1007
+ "development": "./LexicalTableOfContentsPlugin.dev.mjs",
1008
+ "production": "./LexicalTableOfContentsPlugin.prod.mjs",
1009
+ "node": "./LexicalTableOfContentsPlugin.node.mjs",
1010
+ "default": "./LexicalTableOfContentsPlugin.mjs"
1011
+ },
1012
+ "require": {
1013
+ "types": "./LexicalTableOfContentsPlugin.d.ts",
1014
+ "development": "./LexicalTableOfContentsPlugin.dev.js",
1015
+ "production": "./LexicalTableOfContentsPlugin.prod.js",
1016
+ "default": "./LexicalTableOfContentsPlugin.js"
1017
+ }
1018
+ },
1019
+ "./LexicalTableOfContentsPlugin.js": {
1020
+ "import": {
1021
+ "types": "./LexicalTableOfContentsPlugin.d.ts",
1022
+ "development": "./LexicalTableOfContentsPlugin.dev.mjs",
1023
+ "production": "./LexicalTableOfContentsPlugin.prod.mjs",
1024
+ "node": "./LexicalTableOfContentsPlugin.node.mjs",
1025
+ "default": "./LexicalTableOfContentsPlugin.mjs"
1026
+ },
1027
+ "require": {
1028
+ "types": "./LexicalTableOfContentsPlugin.d.ts",
1029
+ "development": "./LexicalTableOfContentsPlugin.dev.js",
1030
+ "production": "./LexicalTableOfContentsPlugin.prod.js",
1031
+ "default": "./LexicalTableOfContentsPlugin.js"
1032
+ }
1033
+ },
1004
1034
  "./LexicalTablePlugin": {
1005
1035
  "import": {
1006
1036
  "types": "./LexicalTablePlugin.d.ts",
@@ -5,4 +5,14 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export default function useLexicalEditable(): boolean;
8
+ /**
9
+ * Get the current value for {@link LexicalEditor.isEditable}
10
+ * using {@link useLexicalSubscription}.
11
+ * You should prefer this over manually observing the value with
12
+ * {@link LexicalEditor.registerEditableListener},
13
+ * which is a bit tricky to do correctly, particularly when using
14
+ * React StrictMode (the default for development) or concurrency.
15
+ */
16
+ export declare function useLexicalEditable(): boolean;
17
+ /** @deprecated use the named export {@link useLexicalEditable} */
18
+ export default useLexicalEditable;
@@ -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 ? react.useLayoutEffect : react.useEffect;
33
37
 
34
38
  /**
@@ -41,6 +45,7 @@ const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffec
41
45
 
42
46
  /**
43
47
  * Shortcut to Lexical subscriptions when values are used for render.
48
+ * @param subscription - The function to create the {@link LexicalSubscription}. This function's identity must be stable (e.g. defined at module scope or with useCallback).
44
49
  */
45
50
  function useLexicalSubscription(subscription) {
46
51
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
@@ -81,8 +86,18 @@ function subscription(editor) {
81
86
  }
82
87
  };
83
88
  }
89
+
90
+ /**
91
+ * Get the current value for {@link LexicalEditor.isEditable}
92
+ * using {@link useLexicalSubscription}.
93
+ * You should prefer this over manually observing the value with
94
+ * {@link LexicalEditor.registerEditableListener},
95
+ * which is a bit tricky to do correctly, particularly when using
96
+ * React StrictMode (the default for development) or concurrency.
97
+ */
84
98
  function useLexicalEditable() {
85
99
  return useLexicalSubscription(subscription);
86
100
  }
87
101
 
88
- module.exports = useLexicalEditable;
102
+ exports.default = useLexicalEditable;
103
+ exports.useLexicalEditable = useLexicalEditable;
@@ -27,6 +27,10 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
27
27
  *
28
28
  */
29
29
 
30
+
31
+ // This workaround is no longer necessary in React 19,
32
+ // but we currently support React >=17.x
33
+ // https://github.com/facebook/react/pull/26395
30
34
  const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
31
35
 
32
36
  /**
@@ -39,6 +43,7 @@ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
39
43
 
40
44
  /**
41
45
  * Shortcut to Lexical subscriptions when values are used for render.
46
+ * @param subscription - The function to create the {@link LexicalSubscription}. This function's identity must be stable (e.g. defined at module scope or with useCallback).
42
47
  */
43
48
  function useLexicalSubscription(subscription) {
44
49
  const [editor] = useLexicalComposerContext();
@@ -79,8 +84,17 @@ function subscription(editor) {
79
84
  }
80
85
  };
81
86
  }
87
+
88
+ /**
89
+ * Get the current value for {@link LexicalEditor.isEditable}
90
+ * using {@link useLexicalSubscription}.
91
+ * You should prefer this over manually observing the value with
92
+ * {@link LexicalEditor.registerEditableListener},
93
+ * which is a bit tricky to do correctly, particularly when using
94
+ * React StrictMode (the default for development) or concurrency.
95
+ */
82
96
  function useLexicalEditable() {
83
97
  return useLexicalSubscription(subscription);
84
98
  }
85
99
 
86
- export { useLexicalEditable as default };
100
+ export { useLexicalEditable as default, useLexicalEditable };
@@ -9,4 +9,7 @@
9
9
 
10
10
  import type {LexicalEditor} from 'lexical';
11
11
 
12
- declare export default function useLexicalEditable(): boolean;
12
+ declare export function useLexicalEditable(): boolean;
13
+
14
+ /** @deprecated use the named export {@link useLexicalEditable} */
15
+ declare export default typeof useLexicalEditable;
@@ -9,4 +9,5 @@
9
9
  import * as modDev from './useLexicalEditable.dev.mjs';
10
10
  import * as modProd from './useLexicalEditable.prod.mjs';
11
11
  const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
12
- export default mod.default;
12
+ export default mod.default;
13
+ export const useLexicalEditable = mod.useLexicalEditable;
@@ -7,4 +7,5 @@
7
7
  */
8
8
 
9
9
  const mod = await (process.env.NODE_ENV === 'development' ? import('./useLexicalEditable.dev.mjs') : import('./useLexicalEditable.prod.mjs'));
10
- export default mod.default;
10
+ export default mod.default;
11
+ export const useLexicalEditable = mod.useLexicalEditable;
@@ -7,4 +7,4 @@
7
7
  */
8
8
 
9
9
  'use strict';var b=require("@lexical/react/LexicalComposerContext"),k=require("react");let l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
10
- function m(a){let [c]=b.useLexicalComposerContext(),e=k.useMemo(()=>a(c),[c,a]),d=k.useRef(e.initialValueFn()),[n,g]=k.useState(d.current);l(()=>{let {initialValueFn:p,subscribe:q}=e,f=p();d.current!==f&&(d.current=f,g(f));return q(h=>{d.current=h;g(h)})},[e,a]);return n}function r(a){return{initialValueFn:()=>a.isEditable(),subscribe:c=>a.registerEditableListener(c)}}module.exports=function(){return m(r)}
10
+ function m(a){let [c]=b.useLexicalComposerContext(),e=k.useMemo(()=>a(c),[c,a]),d=k.useRef(e.initialValueFn()),[p,g]=k.useState(d.current);l(()=>{let {initialValueFn:q,subscribe:r}=e,f=q();d.current!==f&&(d.current=f,g(f));return r(h=>{d.current=h;g(h)})},[e,a]);return p}function n(a){return{initialValueFn:()=>a.isEditable(),subscribe:c=>a.registerEditableListener(c)}}function t(){return m(n)}exports.default=t;exports.useLexicalEditable=t
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as n,useMemo as r,useRef as i,useState as o}from"react";const u="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:n;function c(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function a(){return function(t){const[n]=e(),c=r((()=>t(n)),[n,t]),a=i(c.initialValueFn()),[l,d]=o(a.current);return u((()=>{const{initialValueFn:e,subscribe:t}=c,n=e();return a.current!==n&&(a.current=n,d(n)),t((e=>{a.current=e,d(e)}))}),[c,t]),l}(c)}export{a as default};
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as n,useMemo as r,useRef as i,useState as o}from"react";const u="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:n;function c(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function a(){return function(t){const[n]=e(),c=r((()=>t(n)),[n,t]),a=i(c.initialValueFn()),[l,d]=o(a.current);return u((()=>{const{initialValueFn:e,subscribe:t}=c,n=e();return a.current!==n&&(a.current=n,d(n)),t((e=>{a.current=e,d(e)}))}),[c,t]),l}(c)}export{a as default,a as useLexicalEditable};
@@ -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 ? react.useLayoutEffect : react.useEffect;
33
37
 
34
38
  /**
@@ -27,6 +27,10 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
27
27
  *
28
28
  */
29
29
 
30
+
31
+ // This workaround is no longer necessary in React 19,
32
+ // but we currently support React >=17.x
33
+ // https://github.com/facebook/react/pull/26395
30
34
  const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
31
35
 
32
36
  /**
@@ -12,5 +12,8 @@ export type LexicalSubscription<T> = {
12
12
  };
13
13
  /**
14
14
  * Shortcut to Lexical subscriptions when values are used for render.
15
+ * @param subscription - The function to create the {@link LexicalSubscription}. This function's identity must be stable (e.g. defined at module scope or with useCallback).
15
16
  */
16
- export default function useLexicalSubscription<T>(subscription: (editor: LexicalEditor) => LexicalSubscription<T>): T;
17
+ export declare function useLexicalSubscription<T>(subscription: (editor: LexicalEditor) => LexicalSubscription<T>): T;
18
+ /** @deprecated use the named export {@link useLexicalSubscription} */
19
+ export default useLexicalSubscription;
@@ -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 ? react.useLayoutEffect : react.useEffect;
33
37
 
34
38
  /**
@@ -41,6 +45,7 @@ const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffec
41
45
 
42
46
  /**
43
47
  * Shortcut to Lexical subscriptions when values are used for render.
48
+ * @param subscription - The function to create the {@link LexicalSubscription}. This function's identity must be stable (e.g. defined at module scope or with useCallback).
44
49
  */
45
50
  function useLexicalSubscription(subscription) {
46
51
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
@@ -65,4 +70,5 @@ function useLexicalSubscription(subscription) {
65
70
  return value;
66
71
  }
67
72
 
68
- module.exports = useLexicalSubscription;
73
+ exports.default = useLexicalSubscription;
74
+ exports.useLexicalSubscription = useLexicalSubscription;
@@ -27,6 +27,10 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
27
27
  *
28
28
  */
29
29
 
30
+
31
+ // This workaround is no longer necessary in React 19,
32
+ // but we currently support React >=17.x
33
+ // https://github.com/facebook/react/pull/26395
30
34
  const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
31
35
 
32
36
  /**
@@ -39,6 +43,7 @@ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
39
43
 
40
44
  /**
41
45
  * Shortcut to Lexical subscriptions when values are used for render.
46
+ * @param subscription - The function to create the {@link LexicalSubscription}. This function's identity must be stable (e.g. defined at module scope or with useCallback).
42
47
  */
43
48
  function useLexicalSubscription(subscription) {
44
49
  const [editor] = useLexicalComposerContext();
@@ -63,4 +68,4 @@ function useLexicalSubscription(subscription) {
63
68
  return value;
64
69
  }
65
70
 
66
- export { useLexicalSubscription as default };
71
+ export { useLexicalSubscription as default, useLexicalSubscription };
@@ -14,6 +14,9 @@ export type LexicalSubscription<T> = {
14
14
  subscribe: (callback: (value: T) => void) => () => void,
15
15
  };
16
16
 
17
- declare export default function useLexicalSubscription<T>(
17
+ declare export function useLexicalSubscription<T>(
18
18
  subscription: (editor: LexicalEditor) => LexicalSubscription<T>,
19
19
  ): T;
20
+
21
+ /** @deprecated use the named export {@link useLexicalSubscription} */
22
+ declare export default typeof useLexicalSubscription;
@@ -9,4 +9,5 @@
9
9
  import * as modDev from './useLexicalSubscription.dev.mjs';
10
10
  import * as modProd from './useLexicalSubscription.prod.mjs';
11
11
  const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
12
- export default mod.default;
12
+ export default mod.default;
13
+ export const useLexicalSubscription = mod.useLexicalSubscription;
@@ -7,4 +7,5 @@
7
7
  */
8
8
 
9
9
  const mod = await (process.env.NODE_ENV === 'development' ? import('./useLexicalSubscription.dev.mjs') : import('./useLexicalSubscription.prod.mjs'));
10
- export default mod.default;
10
+ export default mod.default;
11
+ export const useLexicalSubscription = mod.useLexicalSubscription;
@@ -6,5 +6,5 @@
6
6
  *
7
7
  */
8
8
 
9
- 'use strict';var a=require("@lexical/react/LexicalComposerContext"),k=require("react");let l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
10
- module.exports=function(c){let [f]=a.useLexicalComposerContext(),d=k.useMemo(()=>c(f),[f,c]),b=k.useRef(d.initialValueFn()),[m,g]=k.useState(b.current);l(()=>{let {initialValueFn:n,subscribe:p}=d,e=n();b.current!==e&&(b.current=e,g(e));return p(h=>{b.current=h;g(h)})},[d,c]);return m}
9
+ 'use strict';var a=require("@lexical/react/LexicalComposerContext"),f=require("react");let l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;
10
+ function m(c){let [g]=a.useLexicalComposerContext(),d=f.useMemo(()=>c(g),[g,c]),b=f.useRef(d.initialValueFn()),[n,h]=f.useState(b.current);l(()=>{let {initialValueFn:p,subscribe:q}=d,e=p();b.current!==e&&(b.current=e,h(e));return q(k=>{b.current=k;h(k)})},[d,c]);return n}exports.default=m;exports.useLexicalSubscription=m
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as n,useMemo as r,useRef as o,useState as i}from"react";const c="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:n;function u(t){const[n]=e(),u=r((()=>t(n)),[n,t]),a=o(u.initialValueFn()),[d,l]=i(a.current);return c((()=>{const{initialValueFn:e,subscribe:t}=u,n=e();return a.current!==n&&(a.current=n,l(n)),t((e=>{a.current=e,l(e)}))}),[u,t]),d}export{u as default};
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as n,useMemo as r,useRef as o,useState as i}from"react";const c="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:n;function u(t){const[n]=e(),u=r((()=>t(n)),[n,t]),a=o(u.initialValueFn()),[d,l]=i(a.current);return c((()=>{const{initialValueFn:e,subscribe:t}=u,n=e();return a.current!==n&&(a.current=n,l(n)),t((e=>{a.current=e,l(e)}))}),[u,t]),d}export{u as default,u as useLexicalSubscription};