@lexical/react 0.35.1-nightly.20250924.0 → 0.36.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 (154) hide show
  1. package/ExtensionComponent.d.ts +42 -0
  2. package/LexicalAutoEmbedPlugin.dev.js +2 -0
  3. package/LexicalAutoEmbedPlugin.dev.mjs +2 -0
  4. package/LexicalAutoEmbedPlugin.prod.js +1 -1
  5. package/LexicalAutoEmbedPlugin.prod.mjs +1 -1
  6. package/LexicalAutoLinkPlugin.d.ts +2 -17
  7. package/LexicalAutoLinkPlugin.dev.js +7 -309
  8. package/LexicalAutoLinkPlugin.dev.mjs +9 -310
  9. package/LexicalAutoLinkPlugin.js.flow +4 -18
  10. package/LexicalAutoLinkPlugin.prod.js +1 -1
  11. package/LexicalAutoLinkPlugin.prod.mjs +1 -1
  12. package/LexicalClearEditorPlugin.dev.js +2 -23
  13. package/LexicalClearEditorPlugin.dev.mjs +2 -23
  14. package/LexicalClearEditorPlugin.prod.js +1 -1
  15. package/LexicalClearEditorPlugin.prod.mjs +1 -1
  16. package/LexicalClickableLinkPlugin.dev.js +5 -70
  17. package/LexicalClickableLinkPlugin.dev.mjs +6 -71
  18. package/LexicalClickableLinkPlugin.prod.js +1 -1
  19. package/LexicalClickableLinkPlugin.prod.mjs +1 -1
  20. package/LexicalCollaborationContext.prod.js +1 -1
  21. package/LexicalCollaborationContext.prod.mjs +1 -1
  22. package/LexicalCollaborationPlugin.dev.mjs +2 -2
  23. package/LexicalCollaborationPlugin.prod.mjs +1 -1
  24. package/LexicalContentEditable.dev.js +2 -3
  25. package/LexicalContentEditable.dev.mjs +2 -3
  26. package/LexicalContentEditable.prod.js +1 -1
  27. package/LexicalContentEditable.prod.mjs +1 -1
  28. package/LexicalContextMenuPlugin.dev.js +2 -0
  29. package/LexicalContextMenuPlugin.dev.mjs +4 -2
  30. package/LexicalContextMenuPlugin.prod.js +1 -1
  31. package/LexicalContextMenuPlugin.prod.mjs +1 -1
  32. package/LexicalDecoratorBlockNode.dev.js +1 -0
  33. package/LexicalDecoratorBlockNode.dev.mjs +1 -0
  34. package/LexicalDecoratorBlockNode.js.flow +7 -0
  35. package/LexicalDecoratorBlockNode.prod.js +1 -1
  36. package/LexicalDecoratorBlockNode.prod.mjs +1 -1
  37. package/LexicalDraggableBlockPlugin.dev.js +6 -0
  38. package/LexicalDraggableBlockPlugin.dev.mjs +6 -0
  39. package/LexicalDraggableBlockPlugin.prod.js +1 -1
  40. package/LexicalDraggableBlockPlugin.prod.mjs +1 -1
  41. package/LexicalExtensionComponent.dev.js +53 -0
  42. package/LexicalExtensionComponent.dev.mjs +51 -0
  43. package/LexicalExtensionComponent.js +11 -0
  44. package/LexicalExtensionComponent.js.flow +12 -0
  45. package/LexicalExtensionComponent.mjs +12 -0
  46. package/LexicalExtensionComponent.node.mjs +10 -0
  47. package/LexicalExtensionComponent.prod.js +9 -0
  48. package/LexicalExtensionComponent.prod.mjs +9 -0
  49. package/LexicalExtensionComposer.d.ts +69 -0
  50. package/LexicalExtensionComposer.dev.js +105 -0
  51. package/LexicalExtensionComposer.dev.mjs +103 -0
  52. package/LexicalExtensionComposer.js +11 -0
  53. package/LexicalExtensionComposer.js.flow +20 -0
  54. package/LexicalExtensionComposer.mjs +12 -0
  55. package/LexicalExtensionComposer.node.mjs +10 -0
  56. package/LexicalExtensionComposer.prod.js +9 -0
  57. package/LexicalExtensionComposer.prod.mjs +9 -0
  58. package/LexicalHashtagPlugin.dev.js +1 -136
  59. package/LexicalHashtagPlugin.dev.mjs +3 -138
  60. package/LexicalHashtagPlugin.prod.js +1 -1
  61. package/LexicalHashtagPlugin.prod.mjs +1 -1
  62. package/LexicalHorizontalRuleNode.d.ts +10 -11
  63. package/LexicalHorizontalRuleNode.dev.js +12 -26
  64. package/LexicalHorizontalRuleNode.dev.mjs +14 -27
  65. package/LexicalHorizontalRuleNode.js.flow +2 -3
  66. package/LexicalHorizontalRuleNode.prod.js +1 -1
  67. package/LexicalHorizontalRuleNode.prod.mjs +1 -1
  68. package/LexicalLinkPlugin.d.ts +1 -1
  69. package/LexicalLinkPlugin.dev.js +7 -52
  70. package/LexicalLinkPlugin.dev.mjs +8 -53
  71. package/LexicalLinkPlugin.prod.js +1 -1
  72. package/LexicalLinkPlugin.prod.mjs +1 -1
  73. package/LexicalListPlugin.js.flow +5 -0
  74. package/LexicalMarkdownShortcutPlugin.dev.mjs +1 -1
  75. package/LexicalMarkdownShortcutPlugin.prod.mjs +1 -1
  76. package/LexicalNestedComposer.js.flow +10 -6
  77. package/LexicalNodeContextMenuPlugin.dev.js +10 -0
  78. package/LexicalNodeContextMenuPlugin.dev.mjs +11 -1
  79. package/LexicalNodeContextMenuPlugin.prod.js +1 -1
  80. package/LexicalNodeContextMenuPlugin.prod.mjs +1 -1
  81. package/LexicalNodeMenuPlugin.dev.js +2 -0
  82. package/LexicalNodeMenuPlugin.dev.mjs +4 -2
  83. package/LexicalNodeMenuPlugin.prod.js +1 -1
  84. package/LexicalNodeMenuPlugin.prod.mjs +1 -1
  85. package/LexicalPlainTextPlugin.d.ts +1 -1
  86. package/LexicalPlainTextPlugin.dev.js +85 -30
  87. package/LexicalPlainTextPlugin.dev.mjs +85 -30
  88. package/LexicalPlainTextPlugin.prod.js +1 -1
  89. package/LexicalPlainTextPlugin.prod.mjs +1 -1
  90. package/LexicalReactExtension.dev.js +187 -0
  91. package/LexicalReactExtension.dev.mjs +184 -0
  92. package/LexicalReactExtension.js +11 -0
  93. package/LexicalReactExtension.js.flow +68 -0
  94. package/LexicalReactExtension.mjs +13 -0
  95. package/LexicalReactExtension.node.mjs +11 -0
  96. package/LexicalReactExtension.prod.js +9 -0
  97. package/LexicalReactExtension.prod.mjs +9 -0
  98. package/LexicalReactPluginHostExtension.dev.js +189 -0
  99. package/LexicalReactPluginHostExtension.dev.mjs +181 -0
  100. package/LexicalReactPluginHostExtension.js +11 -0
  101. package/LexicalReactPluginHostExtension.js.flow +84 -0
  102. package/LexicalReactPluginHostExtension.mjs +18 -0
  103. package/LexicalReactPluginHostExtension.node.mjs +16 -0
  104. package/LexicalReactPluginHostExtension.prod.js +9 -0
  105. package/LexicalReactPluginHostExtension.prod.mjs +9 -0
  106. package/LexicalReactProviderExtension.dev.js +33 -0
  107. package/LexicalReactProviderExtension.dev.mjs +31 -0
  108. package/LexicalReactProviderExtension.js +11 -0
  109. package/LexicalReactProviderExtension.js.flow +12 -0
  110. package/LexicalReactProviderExtension.mjs +12 -0
  111. package/LexicalReactProviderExtension.node.mjs +10 -0
  112. package/LexicalReactProviderExtension.prod.js +9 -0
  113. package/LexicalReactProviderExtension.prod.mjs +9 -0
  114. package/LexicalRichTextPlugin.d.ts +1 -1
  115. package/LexicalRichTextPlugin.dev.js +85 -30
  116. package/LexicalRichTextPlugin.dev.mjs +85 -30
  117. package/LexicalRichTextPlugin.prod.js +1 -1
  118. package/LexicalRichTextPlugin.prod.mjs +1 -1
  119. package/LexicalTabIndentationPlugin.d.ts +2 -2
  120. package/LexicalTabIndentationPlugin.dev.js +3 -57
  121. package/LexicalTabIndentationPlugin.dev.mjs +3 -56
  122. package/LexicalTabIndentationPlugin.prod.js +1 -1
  123. package/LexicalTabIndentationPlugin.prod.mjs +1 -1
  124. package/LexicalTreeViewExtension.dev.js +57 -0
  125. package/LexicalTreeViewExtension.dev.mjs +54 -0
  126. package/LexicalTreeViewExtension.js +11 -0
  127. package/LexicalTreeViewExtension.js.flow +12 -0
  128. package/LexicalTreeViewExtension.mjs +13 -0
  129. package/LexicalTreeViewExtension.node.mjs +11 -0
  130. package/LexicalTreeViewExtension.prod.js +9 -0
  131. package/LexicalTreeViewExtension.prod.mjs +9 -0
  132. package/LexicalTypeaheadMenuPlugin.dev.js +2 -0
  133. package/LexicalTypeaheadMenuPlugin.dev.mjs +4 -2
  134. package/LexicalTypeaheadMenuPlugin.prod.js +1 -1
  135. package/LexicalTypeaheadMenuPlugin.prod.mjs +1 -1
  136. package/ReactExtension.d.ts +41 -0
  137. package/ReactPluginHostExtension.d.ts +56 -0
  138. package/ReactProviderExtension.d.ts +9 -0
  139. package/TreeViewExtension.d.ts +18 -0
  140. package/package.json +228 -17
  141. package/shared/LegacyDecorators.d.ts +23 -0
  142. package/shared/buildEditorComponent.d.ts +11 -0
  143. package/shared/mergeRefs.d.ts +2 -1
  144. package/shared/types.d.ts +89 -0
  145. package/shared/useReactDecorators.d.ts +12 -0
  146. package/useExtensionComponent.d.ts +10 -0
  147. package/useLexicalExtensionComponent.dev.js +37 -0
  148. package/useLexicalExtensionComponent.dev.mjs +34 -0
  149. package/useLexicalExtensionComponent.js +11 -0
  150. package/useLexicalExtensionComponent.js.flow +12 -0
  151. package/useLexicalExtensionComponent.mjs +13 -0
  152. package/useLexicalExtensionComponent.node.mjs +11 -0
  153. package/useLexicalExtensionComponent.prod.js +9 -0
  154. package/useLexicalExtensionComponent.prod.mjs +9 -0
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),o=require("@lexical/utils"),l=require("react/jsx-runtime");const r="startTransition";const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,s=i?n.useLayoutEffect:n.useEffect;const u=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function c(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function a(t,o,l,r){const[i]=e.useLexicalComposerContext();n.useEffect((()=>{if(null!=o&&null!=t){const e=i.getRootElement(),t=null!=e?function(e,t){let n=getComputedStyle(e);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body}(e):document.body;let n=!1,s=c(o,t);const u=function(){n||(window.requestAnimationFrame((function(){l(),n=!1})),n=!0);const e=c(o,t);e!==s&&(s=e,null!=r&&r(e))},a=new ResizeObserver(l);return window.addEventListener("resize",l),document.addEventListener("scroll",u,{capture:!0,passive:!0}),a.observe(o),()=>{a.unobserve(o),window.removeEventListener("resize",l),document.removeEventListener("scroll",u,!0)}}}),[o,i,r,l,t])}const d=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function f({close:e,editor:l,anchorElementRef:r,resolution:i,options:c,menuRenderFn:a,onSelectOption:f,shouldSplitNodeWithQuery:m=!1,commandPriority:g=t.COMMAND_PRIORITY_LOW,preselectFirstItem:p=!0}){const[h,C]=n.useState(null),E=i.match&&i.match.matchingString;n.useEffect((()=>{p&&C(0)}),[E,p]);const x=n.useCallback((n=>{l.update((()=>{const o=null!=i.match&&m?function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return null;const o=n.anchor;if("text"!==o.type)return null;const l=o.getNode();if(!l.isSimpleText())return null;const r=o.offset,i=l.getTextContent().slice(0,r),s=e.replaceableString.length,u=r-function(e,t,n){let o=n;for(let n=o;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(o=n);return o}(i,e.matchingString,s);if(u<0)return null;let c;return 0===u?[c]=l.splitText(r):[,c]=l.splitText(u,r),c}(i.match):null;f(n,o,e,i.match?i.match.matchingString:"")}))}),[l,m,i.match,f,e]),y=n.useCallback((e=>{const t=l.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),C(e))}),[l]);n.useEffect((()=>()=>{const e=l.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")}),[l]),s((()=>{null===c?C(null):null===h&&p&&y(0)}),[c,h,y,p]),n.useEffect((()=>o.mergeRegister(l.registerCommand(d,(({option:e})=>!(!e.ref||null==e.ref.current)&&(u(e.ref.current),!0)),g))),[l,y,g]),n.useEffect((()=>o.mergeRegister(l.registerCommand(t.KEY_ARROW_DOWN_COMMAND,(e=>{const t=e;if(null!==c&&c.length){const e=null===h?0:h!==c.length-1?h+1:0;y(e);const n=c[e];null!=n.ref&&n.ref.current&&l.dispatchCommand(d,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0}),g),l.registerCommand(t.KEY_ARROW_UP_COMMAND,(e=>{const t=e;if(null!==c&&c.length){const e=null===h?c.length-1:0!==h?h-1:c.length-1;y(e);const n=c[e];null!=n.ref&&n.ref.current&&u(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0}),g),l.registerCommand(t.KEY_ESCAPE_COMMAND,(t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0}),g),l.registerCommand(t.KEY_TAB_COMMAND,(e=>{const t=e;return null!==c&&null!==h&&null!=c[h]&&(t.preventDefault(),t.stopImmediatePropagation(),x(c[h]),!0)}),g),l.registerCommand(t.KEY_ENTER_COMMAND,(e=>null!==c&&null!==h&&null!=c[h]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),x(c[h]),!0)),g))),[x,e,l,c,h,y,g]);return a(r,n.useMemo((()=>({options:c,selectOptionAndCleanUp:x,selectedIndex:h,setHighlightedIndex:C})),[x,h,c]),i.match?i.match.matchingString:"")}function m(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}const g="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";const p=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");exports.LexicalTypeaheadMenuPlugin=function({options:o,onQueryChange:s,onSelectOption:u,onOpen:c,onClose:d,menuRenderFn:g,triggerFn:p,anchorClassName:h,commandPriority:C=t.COMMAND_PRIORITY_LOW,parent:E,preselectFirstItem:x=!0,ignoreEntityBoundary:y=!1}){const[O]=e.useLexicalComposerContext(),[b,w]=n.useState(null),R=function(t,o,l,r=(i?document.body:void 0),s=!0){const[u]=e.useLexicalComposerContext(),c=i?document.createElement("div"):null,d=n.useRef(c),f=n.useCallback((()=>{if(null===d.current||void 0===r)return;d.current.style.top=d.current.style.bottom;const e=u.getRootElement(),n=d.current,o=n.firstChild;if(null!==e&&null!==t){const{left:i,top:u,width:c,height:a}=t.getRect(),f=d.current.offsetHeight;if(n.style.top=`${u+f+3+(s?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==o){o.style.top=`${u}`;const t=o.getBoundingClientRect(),l=t.height,r=t.width,c=e.getBoundingClientRect();i+r>c.right&&(n.style.left=`${c.right-r+window.pageXOffset}px`),(u+l>window.innerHeight||u+l>c.bottom)&&u-c.top>l+a&&(n.style.top=`${u-l-a+(s?window.pageYOffset:0)}px`)}n.isConnected||(m(n,l),r.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}}),[u,t,s,l,r]);n.useEffect((()=>{const e=u.getRootElement();return null!==t&&f(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=d.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}}),[u,f,t]);const g=n.useCallback((e=>{null!==t&&(e||o(null))}),[t,o]);return a(t,d.current,f,g),null!=c&&c===d.current&&(m(c,l),null!=r&&r.append(c)),d}(b,w,h,E),S=n.useCallback((()=>{w(null),null!=d&&null!==b&&d()}),[d,b]),v=n.useCallback((e=>{w(e),null!=c&&null===b&&c(e)}),[c,b]);return n.useEffect((()=>{const e=O.registerUpdateListener((()=>{O.getEditorState().read((()=>{if(!O.isEditable())return void S();const e=O._window||window,o=e.document.createRange(),l=t.$getSelection(),i=function(e){let n=null;return e.getEditorState().read((()=>{const e=t.$getSelection();t.$isRangeSelection(e)&&(n=function(e){const t=e.anchor;if("text"!==t.type)return null;const n=t.getNode();if(!n.isSimpleText())return null;const o=t.offset;return n.getTextContent().slice(0,o)}(e))})),n}(O);if(!t.$isRangeSelection(l)||!l.isCollapsed()||null===i||null===o)return void S();const u=p(i,O);if(s(u?u.matchingString:null),null!==u&&(y||!function(e,n){return 0===n&&e.getEditorState().read((()=>{const e=t.$getSelection();if(t.$isRangeSelection(e)){const n=e.anchor.getNode().getPreviousSibling();return t.$isTextNode(n)&&n.isTextEntity()}return!1}))}(O,u.leadOffset))){const l=function(e,n,o){const l=t.getDOMSelection(o);if(null===l||!l.isCollapsed)return!1;const r=l.anchorNode,i=e,s=l.anchorOffset;if(null==r||null==s)return!1;try{n.setStart(r,i),n.setEnd(r,s)}catch(e){return!1}return!0}(u.leadOffset,o,e);if(null!==l)return c=()=>v({getRect:()=>o.getBoundingClientRect(),match:u}),void(r in n?n[r](c):c())}var c;S()}))}));return()=>{e()}}),[O,p,s,b,S,v,y]),n.useEffect((()=>O.registerEditableListener((e=>{e||S()}))),[O,S]),null===b||null===O||null===R.current?null:l.jsx(f,{close:S,resolution:b,editor:O,anchorElementRef:R,options:o,menuRenderFn:g,shouldSplitNodeWithQuery:!0,onSelectOption:u,commandPriority:C,preselectFirstItem:x})},exports.MenuOption=class{constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}},exports.PUNCTUATION=g,exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=p,exports.getScrollParent=function(e,t){let n=getComputedStyle(e);const o="absolute"===n.position,l=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body},exports.useBasicTypeaheadTriggerMatch=function(e,{minLength:t=1,maxLength:o=75,punctuation:l=g,allowWhitespace:r=!1}){return n.useCallback((n=>{const i=new RegExp("(^|\\s|\\()(["+e+"]((?:"+("[^"+e+l+(r?"":"\\s")+"]")+"){0,"+o+"}))$").exec(n);if(null!==i){const e=i[1],n=i[3];if(n.length>=t)return{leadOffset:i.index+e.length,matchingString:n,replaceableString:i[2]}}return null}),[r,e,l,o,t])},exports.useDynamicPositioning=a;
9
+ "use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),o=require("@lexical/utils"),l=require("react/jsx-runtime");const r="startTransition";const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,s=i?n.useLayoutEffect:n.useEffect;const u=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function c(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function a(t,o,l,r){const[i]=e.useLexicalComposerContext();n.useEffect((()=>{if(null!=o&&null!=t){const e=i.getRootElement(),t=null!=e?function(e,t){let n=getComputedStyle(e);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body}(e):document.body;let n=!1,s=c(o,t);const u=function(){n||(window.requestAnimationFrame((function(){l(),n=!1})),n=!0);const e=c(o,t);e!==s&&(s=e,null!=r&&r(e))},a=new ResizeObserver(l);return window.addEventListener("resize",l),document.addEventListener("scroll",u,{capture:!0,passive:!0}),a.observe(o),()=>{a.unobserve(o),window.removeEventListener("resize",l),document.removeEventListener("scroll",u,!0)}}}),[o,i,r,l,t])}const d=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function f({close:e,editor:l,anchorElementRef:r,resolution:i,options:c,menuRenderFn:a,onSelectOption:f,shouldSplitNodeWithQuery:m=!1,commandPriority:g=t.COMMAND_PRIORITY_LOW,preselectFirstItem:p=!0}){const[h,C]=n.useState(null),E=i.match&&i.match.matchingString;n.useEffect((()=>{p&&C(0)}),[E,p]);const x=n.useCallback((n=>{l.update((()=>{const o=null!=i.match&&m?function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return null;const o=n.anchor;if("text"!==o.type)return null;const l=o.getNode();if(!l.isSimpleText())return null;const r=o.offset,i=l.getTextContent().slice(0,r),s=e.replaceableString.length,u=r-function(e,t,n){let o=n;for(let n=o;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(o=n);return o}(i,e.matchingString,s);if(u<0)return null;let c;return 0===u?[c]=l.splitText(r):[,c]=l.splitText(u,r),c}(i.match):null;f(n,o,e,i.match?i.match.matchingString:"")}))}),[l,m,i.match,f,e]),y=n.useCallback((e=>{const t=l.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),C(e))}),[l]);n.useEffect((()=>()=>{const e=l.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")}),[l]),s((()=>{null===c?C(null):null===h&&p&&y(0)}),[c,h,y,p]),n.useEffect((()=>o.mergeRegister(l.registerCommand(d,(({option:e})=>!(!e.ref||null==e.ref.current)&&(u(e.ref.current),!0)),g))),[l,y,g]),n.useEffect((()=>o.mergeRegister(l.registerCommand(t.KEY_ARROW_DOWN_COMMAND,(e=>{const t=e;if(null!==c&&c.length){const e=null===h?0:h!==c.length-1?h+1:0;y(e);const n=c[e];null!=n.ref&&n.ref.current&&l.dispatchCommand(d,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0}),g),l.registerCommand(t.KEY_ARROW_UP_COMMAND,(e=>{const t=e;if(null!==c&&c.length){const e=null===h?c.length-1:0!==h?h-1:c.length-1;y(e);const n=c[e];null!=n.ref&&n.ref.current&&u(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0}),g),l.registerCommand(t.KEY_ESCAPE_COMMAND,(t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0}),g),l.registerCommand(t.KEY_TAB_COMMAND,(e=>{const t=e;return null!==c&&null!==h&&null!=c[h]&&(t.preventDefault(),t.stopImmediatePropagation(),x(c[h]),!0)}),g),l.registerCommand(t.KEY_ENTER_COMMAND,(e=>null!==c&&null!==h&&null!=c[h]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),x(c[h]),!0)),g))),[x,e,l,c,h,y,g]);return a(r,n.useMemo((()=>({options:c,selectOptionAndCleanUp:x,selectedIndex:h,setHighlightedIndex:C})),[x,h,c]),i.match?i.match.matchingString:"")}function m(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}const g="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";const p=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");exports.LexicalTypeaheadMenuPlugin=function({options:o,onQueryChange:s,onSelectOption:u,onOpen:c,onClose:d,menuRenderFn:g,triggerFn:p,anchorClassName:h,commandPriority:C=t.COMMAND_PRIORITY_LOW,parent:E,preselectFirstItem:x=!0,ignoreEntityBoundary:y=!1}){const[O]=e.useLexicalComposerContext(),[b,w]=n.useState(null),R=function(t,o,l,r=(i?document.body:void 0),s=!0){const[u]=e.useLexicalComposerContext(),c=i?document.createElement("div"):null,d=n.useRef(c),f=n.useCallback((()=>{if(null===d.current||void 0===r)return;d.current.style.top=d.current.style.bottom;const e=u.getRootElement(),n=d.current,o=n.firstChild;if(null!==e&&null!==t){const{left:i,top:u,width:c,height:a}=t.getRect(),f=d.current.offsetHeight;if(n.style.top=`${u+f+3+(s?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==o){o.style.top=`${u}`;const t=o.getBoundingClientRect(),l=t.height,r=t.width,c=e.getBoundingClientRect();i+r>c.right&&(n.style.left=`${c.right-r+window.pageXOffset}px`),(u+l>window.innerHeight||u+l>c.bottom)&&u-c.top>l+a&&(n.style.top=`${u-l-a+(s?window.pageYOffset:0)}px`)}n.isConnected||(m(n,l),r.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}}),[u,t,s,l,r]);n.useEffect((()=>{const e=u.getRootElement();return null!==t&&f(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=d.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}}),[u,f,t]);const g=n.useCallback((e=>{null!==t&&(e||o(null))}),[t,o]);return a(t,d.current,f,g),null!=c&&c===d.current&&(m(c,l),null!=r&&r.append(c)),d}(b,w,h,E),S=n.useCallback((()=>{w(null),null!=d&&null!==b&&d()}),[d,b]),v=n.useCallback((e=>{w(e),null!=c&&null===b&&c(e)}),[c,b]);return n.useEffect((()=>{const e=O.registerUpdateListener((()=>{O.getEditorState().read((()=>{if(!O.isEditable())return void S();const e=O._window||window,o=e.document.createRange(),l=t.$getSelection(),i=function(e){let n=null;return e.getEditorState().read((()=>{const e=t.$getSelection();t.$isRangeSelection(e)&&(n=function(e){const t=e.anchor;if("text"!==t.type)return null;const n=t.getNode();if(!n.isSimpleText())return null;const o=t.offset;return n.getTextContent().slice(0,o)}(e))})),n}(O);if(!t.$isRangeSelection(l)||!l.isCollapsed()||null===i||null===o)return void S();const u=p(i,O);if(s(u?u.matchingString:null),null!==u&&(y||!function(e,n){return 0===n&&e.getEditorState().read((()=>{const e=t.$getSelection();if(t.$isRangeSelection(e)){const n=e.anchor.getNode().getPreviousSibling();return t.$isTextNode(n)&&n.isTextEntity()}return!1}))}(O,u.leadOffset))){const l=function(e,n,o){const l=t.getDOMSelection(o);if(null===l||!l.isCollapsed)return!1;const r=l.anchorNode,i=e,s=l.anchorOffset;if(null==r||null==s)return!1;try{n.setStart(r,i),n.setEnd(r,s)}catch(e){return!1}return!0}(u.leadOffset,o,e);if(null!==l)return c=()=>v({getRect:()=>o.getBoundingClientRect(),match:u}),void(r in n?n[r](c):c())}var c;S()}))}));return()=>{e()}}),[O,p,s,b,S,v,y]),n.useEffect((()=>O.registerEditableListener((e=>{e||S()}))),[O,S]),null===b||null===O||null===R.current?null:l.jsx(f,{close:S,resolution:b,editor:O,anchorElementRef:R,options:o,menuRenderFn:g,shouldSplitNodeWithQuery:!0,onSelectOption:u,commandPriority:C,preselectFirstItem:x})},exports.MenuOption=class{key;ref;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}},exports.PUNCTUATION=g,exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=p,exports.getScrollParent=function(e,t){let n=getComputedStyle(e);const o="absolute"===n.position,l=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body},exports.useBasicTypeaheadTriggerMatch=function(e,{minLength:t=1,maxLength:o=75,punctuation:l=g,allowWhitespace:r=!1}){return n.useCallback((n=>{const i=new RegExp("(^|\\s|\\()(["+e+"]((?:"+("[^"+e+l+(r?"":"\\s")+"]")+"){0,"+o+"}))$").exec(n);if(null!==i){const e=i[1],n=i[3];if(n.length>=t)return{leadOffset:i.index+e.length,matchingString:n,replaceableString:i[2]}}return null}),[r,e,l,o,t])},exports.useDynamicPositioning=a;
@@ -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 u,$getSelection as s,$isRangeSelection as c,getDOMSelection as a,$isTextNode as d}from"lexical";import m,{useLayoutEffect as f,useEffect as p,useState as g,useCallback as h,useMemo as w,useRef as y}from"react";import{mergeRegister as v}from"@lexical/utils";import{jsx as b}from"react/jsx-runtime";const C="startTransition";const E="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,x=E?f:p;class R{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const S=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 O(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function I(e,n,o,r){const[l]=t();p((()=>{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,u=O(n,e);const s=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=O(n,e);t!==u&&(u=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}}),[n,l,r,o,e])}const A=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function T({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:f,onSelectOption:y,shouldSplitNodeWithQuery:b=!1,commandPriority:C=u,preselectFirstItem:E=!0}){const[R,O]=g(null),I=d.match&&d.match.matchingString;p((()=>{E&&O(0)}),[I,E]);const T=h((n=>{e.update((()=>{const e=null!=d.match&&b?function(t){const e=s();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,u=r-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(l,t.matchingString,i);if(u<0)return null;let a;return 0===u?[a]=o.splitText(r):[,a]=o.splitText(u,r),a}(d.match):null;y(n,e,t,d.match?d.match.matchingString:"")}))}),[e,b,d.match,y,t]),N=h((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))}),[e]);p((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),x((()=>{null===m?O(null):null===R&&E&&N(0)}),[m,R,N,E]),p((()=>v(e.registerCommand(A,(({option:t})=>!(!t.ref||null==t.ref.current)&&(S(t.ref.current),!0)),C))),[e,N,C]),p((()=>v(e.registerCommand(n,(t=>{const n=t;if(null!==m&&m.length){const t=null===R?0:R!==m.length-1?R+1:0;N(t);const o=m[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(A,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),C),e.registerCommand(o,(t=>{const e=t;if(null!==m&&m.length){const t=null===R?m.length-1:0!==R?R-1:m.length-1;N(t);const n=m[t];null!=n.ref&&n.ref.current&&S(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),C),e.registerCommand(r,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),C),e.registerCommand(l,(t=>{const e=t;return null!==m&&null!==R&&null!=m[R]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[R]),!0)}),C),e.registerCommand(i,(t=>null!==m&&null!==R&&null!=m[R]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[R]),!0)),C))),[T,t,e,m,R,N,C]);return f(a,w((()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:R,setHighlightedIndex:O})),[T,R,m]),d.match?d.match.matchingString:"")}function N(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}const L="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function P(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 _=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function D(t,{minLength:e=1,maxLength:n=75,punctuation:o=L,allowWhitespace:r=!1}){return h((l=>{const i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+o+(r?"":"\\s")+"]")+"){0,"+n+"}))$").exec(l);if(null!==i){const t=i[1],n=i[3];if(n.length>=e)return{leadOffset:i.index+t.length,matchingString:n,replaceableString:i[2]}}return null}),[r,t,o,n,e])}function $({options:e,onQueryChange:n,onSelectOption:o,onOpen:r,onClose:l,menuRenderFn:i,triggerFn:f,anchorClassName:w,commandPriority:v=u,parent:x,preselectFirstItem:R=!0,ignoreEntityBoundary:S=!1}){const[O]=t(),[A,L]=g(null),P=function(e,n,o,r=(E?document.body:void 0),l=!0){const[i]=t(),u=E?document.createElement("div"):null,s=y(u),c=h((()=>{if(null===s.current||void 0===r)return;s.current.style.top=s.current.style.bottom;const t=i.getRootElement(),n=s.current,u=n.firstChild;if(null!==t&&null!==e){const{left:i,top:c,width:a,height:d}=e.getRect(),m=s.current.offsetHeight;if(n.style.top=`${c+m+3+(l?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${d}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,r=e.width,s=t.getBoundingClientRect();i+r>s.right&&(n.style.left=`${s.right-r+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>s.bottom)&&c-s.top>o+d&&(n.style.top=`${c-o-d+(l?window.pageYOffset:0)}px`)}n.isConnected||(N(n,o),r.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}}),[i,e,l,o,r]);p((()=>{const t=i.getRootElement();return null!==e&&c(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=s.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}}),[i,c,e]);const a=h((t=>{null!==e&&(t||n(null))}),[e,n]);return I(e,s.current,c,a),null!=u&&u===s.current&&(N(u,o),null!=r&&r.append(u)),s}(A,L,w,x),_=h((()=>{L(null),null!=l&&null!==A&&l()}),[l,A]),D=h((t=>{L(t),null!=r&&null===A&&r(t)}),[r,A]);return p((()=>{const t=O.registerUpdateListener((()=>{O.getEditorState().read((()=>{if(!O.isEditable())return void _();const t=O._window||window,e=t.document.createRange(),o=s(),r=function(t){let e=null;return t.getEditorState().read((()=>{const t=s();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}(O);if(!c(o)||!o.isCollapsed()||null===r||null===e)return void _();const l=f(r,O);if(n(l?l.matchingString:null),null!==l&&(S||!function(t,e){return 0===e&&t.getEditorState().read((()=>{const t=s();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return d(e)&&e.isTextEntity()}return!1}))}(O,l.leadOffset))){const n=function(t,e,n){const o=a(n);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=()=>D({getRect:()=>e.getBoundingClientRect(),match:l}),void(C in m?m[C](i):i())}var i;_()}))}));return()=>{t()}}),[O,f,n,A,_,D,S]),p((()=>O.registerEditableListener((t=>{t||_()}))),[O,_]),null===A||null===O||null===P.current?null:b(T,{close:_,resolution:A,editor:O,anchorElementRef:P,options:e,menuRenderFn:i,shouldSplitNodeWithQuery:!0,onSelectOption:o,commandPriority:v,preselectFirstItem:R})}export{$ as LexicalTypeaheadMenuPlugin,R as MenuOption,L as PUNCTUATION,_ as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,P as getScrollParent,D as useBasicTypeaheadTriggerMatch,I as useDynamicPositioning};
9
+ import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,COMMAND_PRIORITY_LOW as n,KEY_ARROW_DOWN_COMMAND as o,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as l,KEY_TAB_COMMAND as i,KEY_ENTER_COMMAND as u,$getSelection as s,$isRangeSelection as c,$isTextNode as a,getDOMSelection as d}from"lexical";import m,{useLayoutEffect as f,useEffect as p,useRef as g,useCallback as h,useState as w,useMemo as y}from"react";import{mergeRegister as v}from"@lexical/utils";import{jsx as b}from"react/jsx-runtime";const C="startTransition";const E="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,x=E?f:p;class R{key;ref;constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const S=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 O(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function I(e,n,o,r){const[l]=t();p((()=>{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,u=O(n,e);const s=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=O(n,e);t!==u&&(u=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}}),[n,l,r,o,e])}const A=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function T({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:f,onSelectOption:g,shouldSplitNodeWithQuery:b=!1,commandPriority:C=n,preselectFirstItem:E=!0}){const[R,O]=w(null),I=d.match&&d.match.matchingString;p((()=>{E&&O(0)}),[I,E]);const T=h((n=>{e.update((()=>{const e=null!=d.match&&b?function(t){const e=s();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,u=r-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(l,t.matchingString,i);if(u<0)return null;let a;return 0===u?[a]=o.splitText(r):[,a]=o.splitText(u,r),a}(d.match):null;g(n,e,t,d.match?d.match.matchingString:"")}))}),[e,b,d.match,g,t]),N=h((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))}),[e]);p((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),x((()=>{null===m?O(null):null===R&&E&&N(0)}),[m,R,N,E]),p((()=>v(e.registerCommand(A,(({option:t})=>!(!t.ref||null==t.ref.current)&&(S(t.ref.current),!0)),C))),[e,N,C]),p((()=>v(e.registerCommand(o,(t=>{const n=t;if(null!==m&&m.length){const t=null===R?0:R!==m.length-1?R+1:0;N(t);const o=m[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(A,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),C),e.registerCommand(r,(t=>{const e=t;if(null!==m&&m.length){const t=null===R?m.length-1:0!==R?R-1:m.length-1;N(t);const n=m[t];null!=n.ref&&n.ref.current&&S(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),C),e.registerCommand(l,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),C),e.registerCommand(i,(t=>{const e=t;return null!==m&&null!==R&&null!=m[R]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[R]),!0)}),C),e.registerCommand(u,(t=>null!==m&&null!==R&&null!=m[R]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[R]),!0)),C))),[T,t,e,m,R,N,C]);return f(a,y((()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:R,setHighlightedIndex:O})),[T,R,m]),d.match?d.match.matchingString:"")}function N(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}const L="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function P(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 _=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function D(t,{minLength:e=1,maxLength:n=75,punctuation:o=L,allowWhitespace:r=!1}){return h((l=>{const i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+o+(r?"":"\\s")+"]")+"){0,"+n+"}))$").exec(l);if(null!==i){const t=i[1],n=i[3];if(n.length>=e)return{leadOffset:i.index+t.length,matchingString:n,replaceableString:i[2]}}return null}),[r,t,o,n,e])}function $({options:e,onQueryChange:o,onSelectOption:r,onOpen:l,onClose:i,menuRenderFn:u,triggerFn:f,anchorClassName:y,commandPriority:v=n,parent:x,preselectFirstItem:R=!0,ignoreEntityBoundary:S=!1}){const[O]=t(),[A,L]=w(null),P=function(e,n,o,r=(E?document.body:void 0),l=!0){const[i]=t(),u=E?document.createElement("div"):null,s=g(u),c=h((()=>{if(null===s.current||void 0===r)return;s.current.style.top=s.current.style.bottom;const t=i.getRootElement(),n=s.current,u=n.firstChild;if(null!==t&&null!==e){const{left:i,top:c,width:a,height:d}=e.getRect(),m=s.current.offsetHeight;if(n.style.top=`${c+m+3+(l?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${d}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,r=e.width,s=t.getBoundingClientRect();i+r>s.right&&(n.style.left=`${s.right-r+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>s.bottom)&&c-s.top>o+d&&(n.style.top=`${c-o-d+(l?window.pageYOffset:0)}px`)}n.isConnected||(N(n,o),r.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}}),[i,e,l,o,r]);p((()=>{const t=i.getRootElement();return null!==e&&c(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=s.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}}),[i,c,e]);const a=h((t=>{null!==e&&(t||n(null))}),[e,n]);return I(e,s.current,c,a),null!=u&&u===s.current&&(N(u,o),null!=r&&r.append(u)),s}(A,L,y,x),_=h((()=>{L(null),null!=i&&null!==A&&i()}),[i,A]),D=h((t=>{L(t),null!=l&&null===A&&l(t)}),[l,A]);return p((()=>{const t=O.registerUpdateListener((()=>{O.getEditorState().read((()=>{if(!O.isEditable())return void _();const t=O._window||window,e=t.document.createRange(),n=s(),r=function(t){let e=null;return t.getEditorState().read((()=>{const t=s();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}(O);if(!c(n)||!n.isCollapsed()||null===r||null===e)return void _();const l=f(r,O);if(o(l?l.matchingString:null),null!==l&&(S||!function(t,e){return 0===e&&t.getEditorState().read((()=>{const t=s();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return a(e)&&e.isTextEntity()}return!1}))}(O,l.leadOffset))){const n=function(t,e,n){const o=d(n);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=()=>D({getRect:()=>e.getBoundingClientRect(),match:l}),void(C in m?m[C](i):i())}var i;_()}))}));return()=>{t()}}),[O,f,o,A,_,D,S]),p((()=>O.registerEditableListener((t=>{t||_()}))),[O,_]),null===A||null===O||null===P.current?null:b(T,{close:_,resolution:A,editor:O,anchorElementRef:P,options:e,menuRenderFn:u,shouldSplitNodeWithQuery:!0,onSelectOption:r,commandPriority:v,preselectFirstItem:R})}export{$ as LexicalTypeaheadMenuPlugin,R as MenuOption,L as PUNCTUATION,_ as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,P as getScrollParent,D as useBasicTypeaheadTriggerMatch,I as useDynamicPositioning};
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { EditorChildrenComponentProps, ReactConfig, ReactOutputs } from './shared/types';
9
+ import type { LexicalComposerContextWithEditor } from '@lexical/react/LexicalComposerContext';
10
+ export type { EditorChildrenComponentProps, ReactConfig, ReactOutputs };
11
+ /**
12
+ * @example
13
+ * The default EditorChildrenComponent implementation
14
+ * ```jsx
15
+ * return (
16
+ * <>
17
+ * {contentEditable}
18
+ * {children}
19
+ * </>
20
+ * );
21
+ * ```
22
+ */
23
+ export declare function DefaultEditorChildrenComponent({ contentEditable, children, }: EditorChildrenComponentProps): import("react/jsx-runtime").JSX.Element;
24
+ /**
25
+ * An extension to use or configure React for use with Lexical. In an editor, you
26
+ * would typically use {@link LexicalExtensionComposer} (for React projects) or
27
+ * {@link ReactPluginHostExtension} (to use React Extensions and plug-ins in a non-React
28
+ * project).
29
+ *
30
+ * See {@link ReactConfig} for more detailed exextensionations of how to use
31
+ * the config for this Extension.
32
+ *
33
+ * For an Extension developer, you can defineConfig() override the extension with
34
+ * decorators to add JSX inside the editor context that is not
35
+ * location-dependent (e.g. floating UI that does not need to be mounted in
36
+ * some specific location, or effects that return null).
37
+ */
38
+ export declare const ReactExtension: import("lexical").LexicalExtension<ReactConfig, "@lexical/react/React", {
39
+ Component: (props: Partial<import("./shared/types").EditorComponentProps>) => import("react/jsx-runtime").JSX.Element;
40
+ context: LexicalComposerContextWithEditor;
41
+ }, unknown>;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { DecoratorComponentProps } from './shared/types';
9
+ import type { JSX } from 'react';
10
+ import { type AnyLexicalExtension, type LexicalEditor, type LexicalExtensionOutput } from 'lexical';
11
+ import * as React from 'react';
12
+ import { type Container, type Root } from 'react-dom/client';
13
+ export type { DecoratorComponentProps };
14
+ export interface HostMountCommandArg {
15
+ root: Root;
16
+ }
17
+ export interface MountPluginCommandArg {
18
+ key: string;
19
+ element: JSX.Element | null;
20
+ domNode?: Element | DocumentFragment | null;
21
+ }
22
+ export declare function mountReactExtensionComponent<Extension extends AnyLexicalExtension>(editor: LexicalEditor, opts: {
23
+ extension: Extension;
24
+ props: [LexicalExtensionOutput<Extension>] extends [
25
+ {
26
+ Component: infer OutputComponentType extends React.ComponentType;
27
+ }
28
+ ] ? /** The Props from the Extension output Component */ React.ComponentProps<OutputComponentType> | null : never;
29
+ } & Omit<MountPluginCommandArg, 'element'>): void;
30
+ export declare function mountReactPluginComponent<P extends Record<never, never> = Record<never, never>>(editor: LexicalEditor, opts: {
31
+ Component: React.ComponentType<P>;
32
+ props: (P & React.Attributes) | null;
33
+ } & Omit<MountPluginCommandArg, 'element'>): void;
34
+ export declare function mountReactPluginElement(editor: LexicalEditor, opts: MountPluginCommandArg): void;
35
+ export declare function mountReactPluginHost(editor: LexicalEditor, container: Container): void;
36
+ export declare const REACT_PLUGIN_HOST_MOUNT_ROOT_COMMAND: import("lexical").LexicalCommand<HostMountCommandArg>;
37
+ export declare const REACT_PLUGIN_HOST_MOUNT_PLUGIN_COMMAND: import("lexical").LexicalCommand<MountPluginCommandArg>;
38
+ /**
39
+ * This extension provides a React host for editors that are not built
40
+ * with LexicalExtensionComposer (e.g. you are using Vanilla JS or some
41
+ * other framework).
42
+ *
43
+ * You must use {@link mountReactPluginHost} for any React content to work.
44
+ * Afterwards, you may use {@link mountReactExtensionComponent} to
45
+ * render UI for a specific React Extension.
46
+ * {@link mountReactPluginComponent} and
47
+ * {@link mountReactPluginElement} can be used to render
48
+ * legacy React plug-ins (or any React content).
49
+ */
50
+ export declare const ReactPluginHostExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/react/ReactPluginHost", {
51
+ mountReactPlugin: (arg: MountPluginCommandArg) => void;
52
+ mountReactPluginHost: (container: Container) => boolean;
53
+ mountedPluginsStore: import("@preact/signals-core").Signal<{
54
+ plugins: Map<string, MountPluginCommandArg>;
55
+ }>;
56
+ }, unknown>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * An extension used to declare that there is a LexicalExtensionComposer or
3
+ * ReactPluginHostExtension available so that we can issue runtime warnings
4
+ * when plugins that depend on React are hosted in an environment
5
+ * where it is not ever going to be rendered.
6
+ *
7
+ * It is a separate extension so it can be used as a peer dependency.
8
+ */
9
+ export declare const ReactProviderExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/react/ReactProvider", unknown, unknown>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { JSX } from 'react';
9
+ import { TreeView } from '@lexical/react/LexicalTreeView';
10
+ export type TreeViewConfig = Omit<Parameters<typeof TreeView>[0], 'editor'>;
11
+ export declare function TreeViewExtensionComponent(props: Partial<TreeViewConfig>): JSX.Element;
12
+ /**
13
+ * Provides a configured TreeView debugging tool (React dependent)
14
+ * as an output component with configurable class names.
15
+ */
16
+ export declare const TreeViewExtension: import("lexical").LexicalExtension<TreeViewConfig, "@lexical/react/TreeView", {
17
+ Component: typeof TreeViewExtensionComponent;
18
+ }, unknown>;
package/package.json CHANGED
@@ -8,25 +8,26 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.35.1-nightly.20250924.0",
11
+ "version": "0.36.0",
12
12
  "dependencies": {
13
13
  "@floating-ui/react": "^0.27.16",
14
- "@lexical/devtools-core": "0.35.1-nightly.20250924.0",
15
- "@lexical/dragon": "0.35.1-nightly.20250924.0",
16
- "@lexical/hashtag": "0.35.1-nightly.20250924.0",
17
- "@lexical/history": "0.35.1-nightly.20250924.0",
18
- "@lexical/link": "0.35.1-nightly.20250924.0",
19
- "@lexical/list": "0.35.1-nightly.20250924.0",
20
- "@lexical/mark": "0.35.1-nightly.20250924.0",
21
- "@lexical/markdown": "0.35.1-nightly.20250924.0",
22
- "@lexical/overflow": "0.35.1-nightly.20250924.0",
23
- "@lexical/plain-text": "0.35.1-nightly.20250924.0",
24
- "@lexical/rich-text": "0.35.1-nightly.20250924.0",
25
- "@lexical/table": "0.35.1-nightly.20250924.0",
26
- "@lexical/text": "0.35.1-nightly.20250924.0",
27
- "@lexical/utils": "0.35.1-nightly.20250924.0",
28
- "@lexical/yjs": "0.35.1-nightly.20250924.0",
29
- "lexical": "0.35.1-nightly.20250924.0",
14
+ "@lexical/devtools-core": "0.36.0",
15
+ "@lexical/dragon": "0.36.0",
16
+ "@lexical/extension": "0.36.0",
17
+ "@lexical/hashtag": "0.36.0",
18
+ "@lexical/history": "0.36.0",
19
+ "@lexical/link": "0.36.0",
20
+ "@lexical/list": "0.36.0",
21
+ "@lexical/mark": "0.36.0",
22
+ "@lexical/markdown": "0.36.0",
23
+ "@lexical/overflow": "0.36.0",
24
+ "@lexical/plain-text": "0.36.0",
25
+ "@lexical/rich-text": "0.36.0",
26
+ "@lexical/table": "0.36.0",
27
+ "@lexical/text": "0.36.0",
28
+ "@lexical/utils": "0.36.0",
29
+ "@lexical/yjs": "0.36.0",
30
+ "lexical": "0.36.0",
30
31
  "react-error-boundary": "^6.0.0"
31
32
  },
32
33
  "peerDependencies": {
@@ -39,6 +40,36 @@
39
40
  "directory": "packages/lexical-react"
40
41
  },
41
42
  "exports": {
43
+ "./ExtensionComponent": {
44
+ "import": {
45
+ "types": "./LexicalExtensionComponent.d.ts",
46
+ "development": "./LexicalExtensionComponent.dev.mjs",
47
+ "production": "./LexicalExtensionComponent.prod.mjs",
48
+ "node": "./LexicalExtensionComponent.node.mjs",
49
+ "default": "./LexicalExtensionComponent.mjs"
50
+ },
51
+ "require": {
52
+ "types": "./LexicalExtensionComponent.d.ts",
53
+ "development": "./LexicalExtensionComponent.dev.js",
54
+ "production": "./LexicalExtensionComponent.prod.js",
55
+ "default": "./LexicalExtensionComponent.js"
56
+ }
57
+ },
58
+ "./ExtensionComponent.js": {
59
+ "import": {
60
+ "types": "./LexicalExtensionComponent.d.ts",
61
+ "development": "./LexicalExtensionComponent.dev.mjs",
62
+ "production": "./LexicalExtensionComponent.prod.mjs",
63
+ "node": "./LexicalExtensionComponent.node.mjs",
64
+ "default": "./LexicalExtensionComponent.mjs"
65
+ },
66
+ "require": {
67
+ "types": "./LexicalExtensionComponent.d.ts",
68
+ "development": "./LexicalExtensionComponent.dev.js",
69
+ "production": "./LexicalExtensionComponent.prod.js",
70
+ "default": "./LexicalExtensionComponent.js"
71
+ }
72
+ },
42
73
  "./LexicalAutoEmbedPlugin": {
43
74
  "import": {
44
75
  "types": "./LexicalAutoEmbedPlugin.d.ts",
@@ -579,6 +610,36 @@
579
610
  "default": "./LexicalErrorBoundary.js"
580
611
  }
581
612
  },
613
+ "./LexicalExtensionComposer": {
614
+ "import": {
615
+ "types": "./LexicalExtensionComposer.d.ts",
616
+ "development": "./LexicalExtensionComposer.dev.mjs",
617
+ "production": "./LexicalExtensionComposer.prod.mjs",
618
+ "node": "./LexicalExtensionComposer.node.mjs",
619
+ "default": "./LexicalExtensionComposer.mjs"
620
+ },
621
+ "require": {
622
+ "types": "./LexicalExtensionComposer.d.ts",
623
+ "development": "./LexicalExtensionComposer.dev.js",
624
+ "production": "./LexicalExtensionComposer.prod.js",
625
+ "default": "./LexicalExtensionComposer.js"
626
+ }
627
+ },
628
+ "./LexicalExtensionComposer.js": {
629
+ "import": {
630
+ "types": "./LexicalExtensionComposer.d.ts",
631
+ "development": "./LexicalExtensionComposer.dev.mjs",
632
+ "production": "./LexicalExtensionComposer.prod.mjs",
633
+ "node": "./LexicalExtensionComposer.node.mjs",
634
+ "default": "./LexicalExtensionComposer.mjs"
635
+ },
636
+ "require": {
637
+ "types": "./LexicalExtensionComposer.d.ts",
638
+ "development": "./LexicalExtensionComposer.dev.js",
639
+ "production": "./LexicalExtensionComposer.prod.js",
640
+ "default": "./LexicalExtensionComposer.js"
641
+ }
642
+ },
582
643
  "./LexicalHashtagPlugin": {
583
644
  "import": {
584
645
  "types": "./LexicalHashtagPlugin.d.ts",
@@ -1179,6 +1240,156 @@
1179
1240
  "default": "./LexicalTypeaheadMenuPlugin.js"
1180
1241
  }
1181
1242
  },
1243
+ "./ReactExtension": {
1244
+ "import": {
1245
+ "types": "./LexicalReactExtension.d.ts",
1246
+ "development": "./LexicalReactExtension.dev.mjs",
1247
+ "production": "./LexicalReactExtension.prod.mjs",
1248
+ "node": "./LexicalReactExtension.node.mjs",
1249
+ "default": "./LexicalReactExtension.mjs"
1250
+ },
1251
+ "require": {
1252
+ "types": "./LexicalReactExtension.d.ts",
1253
+ "development": "./LexicalReactExtension.dev.js",
1254
+ "production": "./LexicalReactExtension.prod.js",
1255
+ "default": "./LexicalReactExtension.js"
1256
+ }
1257
+ },
1258
+ "./ReactExtension.js": {
1259
+ "import": {
1260
+ "types": "./LexicalReactExtension.d.ts",
1261
+ "development": "./LexicalReactExtension.dev.mjs",
1262
+ "production": "./LexicalReactExtension.prod.mjs",
1263
+ "node": "./LexicalReactExtension.node.mjs",
1264
+ "default": "./LexicalReactExtension.mjs"
1265
+ },
1266
+ "require": {
1267
+ "types": "./LexicalReactExtension.d.ts",
1268
+ "development": "./LexicalReactExtension.dev.js",
1269
+ "production": "./LexicalReactExtension.prod.js",
1270
+ "default": "./LexicalReactExtension.js"
1271
+ }
1272
+ },
1273
+ "./ReactPluginHostExtension": {
1274
+ "import": {
1275
+ "types": "./LexicalReactPluginHostExtension.d.ts",
1276
+ "development": "./LexicalReactPluginHostExtension.dev.mjs",
1277
+ "production": "./LexicalReactPluginHostExtension.prod.mjs",
1278
+ "node": "./LexicalReactPluginHostExtension.node.mjs",
1279
+ "default": "./LexicalReactPluginHostExtension.mjs"
1280
+ },
1281
+ "require": {
1282
+ "types": "./LexicalReactPluginHostExtension.d.ts",
1283
+ "development": "./LexicalReactPluginHostExtension.dev.js",
1284
+ "production": "./LexicalReactPluginHostExtension.prod.js",
1285
+ "default": "./LexicalReactPluginHostExtension.js"
1286
+ }
1287
+ },
1288
+ "./ReactPluginHostExtension.js": {
1289
+ "import": {
1290
+ "types": "./LexicalReactPluginHostExtension.d.ts",
1291
+ "development": "./LexicalReactPluginHostExtension.dev.mjs",
1292
+ "production": "./LexicalReactPluginHostExtension.prod.mjs",
1293
+ "node": "./LexicalReactPluginHostExtension.node.mjs",
1294
+ "default": "./LexicalReactPluginHostExtension.mjs"
1295
+ },
1296
+ "require": {
1297
+ "types": "./LexicalReactPluginHostExtension.d.ts",
1298
+ "development": "./LexicalReactPluginHostExtension.dev.js",
1299
+ "production": "./LexicalReactPluginHostExtension.prod.js",
1300
+ "default": "./LexicalReactPluginHostExtension.js"
1301
+ }
1302
+ },
1303
+ "./ReactProviderExtension": {
1304
+ "import": {
1305
+ "types": "./LexicalReactProviderExtension.d.ts",
1306
+ "development": "./LexicalReactProviderExtension.dev.mjs",
1307
+ "production": "./LexicalReactProviderExtension.prod.mjs",
1308
+ "node": "./LexicalReactProviderExtension.node.mjs",
1309
+ "default": "./LexicalReactProviderExtension.mjs"
1310
+ },
1311
+ "require": {
1312
+ "types": "./LexicalReactProviderExtension.d.ts",
1313
+ "development": "./LexicalReactProviderExtension.dev.js",
1314
+ "production": "./LexicalReactProviderExtension.prod.js",
1315
+ "default": "./LexicalReactProviderExtension.js"
1316
+ }
1317
+ },
1318
+ "./ReactProviderExtension.js": {
1319
+ "import": {
1320
+ "types": "./LexicalReactProviderExtension.d.ts",
1321
+ "development": "./LexicalReactProviderExtension.dev.mjs",
1322
+ "production": "./LexicalReactProviderExtension.prod.mjs",
1323
+ "node": "./LexicalReactProviderExtension.node.mjs",
1324
+ "default": "./LexicalReactProviderExtension.mjs"
1325
+ },
1326
+ "require": {
1327
+ "types": "./LexicalReactProviderExtension.d.ts",
1328
+ "development": "./LexicalReactProviderExtension.dev.js",
1329
+ "production": "./LexicalReactProviderExtension.prod.js",
1330
+ "default": "./LexicalReactProviderExtension.js"
1331
+ }
1332
+ },
1333
+ "./TreeViewExtension": {
1334
+ "import": {
1335
+ "types": "./LexicalTreeViewExtension.d.ts",
1336
+ "development": "./LexicalTreeViewExtension.dev.mjs",
1337
+ "production": "./LexicalTreeViewExtension.prod.mjs",
1338
+ "node": "./LexicalTreeViewExtension.node.mjs",
1339
+ "default": "./LexicalTreeViewExtension.mjs"
1340
+ },
1341
+ "require": {
1342
+ "types": "./LexicalTreeViewExtension.d.ts",
1343
+ "development": "./LexicalTreeViewExtension.dev.js",
1344
+ "production": "./LexicalTreeViewExtension.prod.js",
1345
+ "default": "./LexicalTreeViewExtension.js"
1346
+ }
1347
+ },
1348
+ "./TreeViewExtension.js": {
1349
+ "import": {
1350
+ "types": "./LexicalTreeViewExtension.d.ts",
1351
+ "development": "./LexicalTreeViewExtension.dev.mjs",
1352
+ "production": "./LexicalTreeViewExtension.prod.mjs",
1353
+ "node": "./LexicalTreeViewExtension.node.mjs",
1354
+ "default": "./LexicalTreeViewExtension.mjs"
1355
+ },
1356
+ "require": {
1357
+ "types": "./LexicalTreeViewExtension.d.ts",
1358
+ "development": "./LexicalTreeViewExtension.dev.js",
1359
+ "production": "./LexicalTreeViewExtension.prod.js",
1360
+ "default": "./LexicalTreeViewExtension.js"
1361
+ }
1362
+ },
1363
+ "./useExtensionComponent": {
1364
+ "import": {
1365
+ "types": "./useLexicalExtensionComponent.d.ts",
1366
+ "development": "./useLexicalExtensionComponent.dev.mjs",
1367
+ "production": "./useLexicalExtensionComponent.prod.mjs",
1368
+ "node": "./useLexicalExtensionComponent.node.mjs",
1369
+ "default": "./useLexicalExtensionComponent.mjs"
1370
+ },
1371
+ "require": {
1372
+ "types": "./useLexicalExtensionComponent.d.ts",
1373
+ "development": "./useLexicalExtensionComponent.dev.js",
1374
+ "production": "./useLexicalExtensionComponent.prod.js",
1375
+ "default": "./useLexicalExtensionComponent.js"
1376
+ }
1377
+ },
1378
+ "./useExtensionComponent.js": {
1379
+ "import": {
1380
+ "types": "./useLexicalExtensionComponent.d.ts",
1381
+ "development": "./useLexicalExtensionComponent.dev.mjs",
1382
+ "production": "./useLexicalExtensionComponent.prod.mjs",
1383
+ "node": "./useLexicalExtensionComponent.node.mjs",
1384
+ "default": "./useLexicalExtensionComponent.mjs"
1385
+ },
1386
+ "require": {
1387
+ "types": "./useLexicalExtensionComponent.d.ts",
1388
+ "development": "./useLexicalExtensionComponent.dev.js",
1389
+ "production": "./useLexicalExtensionComponent.prod.js",
1390
+ "default": "./useLexicalExtensionComponent.js"
1391
+ }
1392
+ },
1182
1393
  "./useLexicalEditable": {
1183
1394
  "import": {
1184
1395
  "types": "./useLexicalEditable.d.ts",
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { JSX } from 'react';
9
+ import { type LexicalEditor } from 'lexical';
10
+ import { type ErrorBoundaryType } from './useDecorators';
11
+ export { type ErrorBoundaryType };
12
+ /**
13
+ * @internal
14
+ *
15
+ * When using @lexical/extension, the ReactProvider is expected to handle
16
+ * rendering decorators. This component allows RichTextPlugin and
17
+ * PlainTextPlugin to be used in extension projects that have not yet
18
+ * migrated to use RichTextExtension or PlainTextExtension.
19
+ **/
20
+ export declare function LegacyDecorators({ editor, ErrorBoundary, }: {
21
+ editor: LexicalEditor;
22
+ ErrorBoundary: ErrorBoundaryType;
23
+ }): JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { type LexicalComposerContextWithEditor } from '@lexical/react/LexicalComposerContext';
9
+ import { type EditorComponentProps, type ReactConfig } from './types';
10
+ /** @internal */
11
+ export declare function buildEditorComponent(config: ReactConfig, context: LexicalComposerContextWithEditor): (props: Partial<EditorComponentProps>) => import("react/jsx-runtime").JSX.Element;
@@ -5,4 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export declare function mergeRefs<T>(...refs: Array<React.RefObject<T> | React.LegacyRef<T> | undefined | null>): React.RefCallback<T>;
8
+ import type { Ref } from 'react';
9
+ export declare function mergeRefs<T>(...refs: Ref<T>[]): (value: null | T) => void;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { LexicalComposerContextWithEditor } from '@lexical/react/LexicalComposerContext';
9
+ import type { JSX } from 'react';
10
+ export interface EditorChildrenComponentProps {
11
+ context: LexicalComposerContextWithEditor;
12
+ contentEditable: null | JSX.Element;
13
+ children?: React.ReactNode;
14
+ }
15
+ export type EditorChildrenComponentType = (props: EditorChildrenComponentProps) => JSX.Element | null;
16
+ export interface DecoratorComponentProps {
17
+ context: LexicalComposerContextWithEditor;
18
+ }
19
+ export type DecoratorComponentType = JSX.Element | ((props: DecoratorComponentProps) => JSX.Element | null);
20
+ export interface EditorComponentProps {
21
+ /**
22
+ * The EditorChildrenComponent from the config
23
+ */
24
+ EditorChildrenComponent: EditorChildrenComponentType;
25
+ /**
26
+ * The children to pass to EditorChildrenComponent
27
+ */
28
+ children?: React.ReactNode;
29
+ /**
30
+ * contentEditable from the config
31
+ */
32
+ contentEditable: JSX.Element | null;
33
+ /**
34
+ * ErrorBoundary from the config
35
+ */
36
+ ErrorBoundary: ErrorBoundaryType;
37
+ }
38
+ export type EditorComponentType = (
39
+ /** Optional overrides to any of the props, typically only children is used */
40
+ props: Partial<EditorComponentProps>) => JSX.Element;
41
+ export interface ReactConfig {
42
+ /**
43
+ * The default root element of the editor as JSX. Uses `<ContentEditable />`
44
+ * from \@lexical/react/ContentEditable by default,
45
+ * but may be null or another component.
46
+ *
47
+ * This component is responsible for calling `editor.setRootElement(elem)`.
48
+ */
49
+ contentEditable: JSX.Element | null;
50
+ /**
51
+ * The ErrorBoundary used for rendering decorators in the editor. By default
52
+ * it is `ErrorBoundary` from \@lexical/react/ErrorBoundary.
53
+ */
54
+ ErrorBoundary: ErrorBoundaryType;
55
+ /**
56
+ * The component that renders the children of the editor context, by default
57
+ * it is {@link DefaultEditorChildrenComponent} which takes the given props
58
+ * and renders them in this order:
59
+ *
60
+ * - contentEditable
61
+ * - children
62
+ */
63
+ EditorChildrenComponent: EditorChildrenComponentType;
64
+ /**
65
+ * An array of JSX or components that return JSX that should be rendered
66
+ * as children of Component. These will be merged by array concatenation.
67
+ */
68
+ decorators: readonly DecoratorComponentType[];
69
+ }
70
+ export interface ReactOutputs {
71
+ /**
72
+ * The editor component, this can be used by Extensions that depend on this to
73
+ * render the editor such as {@link ReactPluginHostExtension} or internally by
74
+ * {@link LexicalExtensionComposer}.
75
+ *
76
+ * All props have defaults based on the config and editor state, but may be
77
+ * overridden.
78
+ */
79
+ Component: EditorComponentType;
80
+ /**
81
+ * This is equivalent to useLexicalComposerContext() from \@lexical/react/LexicalComposerContext.
82
+ */
83
+ context: LexicalComposerContextWithEditor;
84
+ }
85
+ export interface ErrorBoundaryProps {
86
+ children: JSX.Element;
87
+ onError: (error: Error) => void;
88
+ }
89
+ export type ErrorBoundaryType = React.ComponentClass<ErrorBoundaryProps> | React.FC<ErrorBoundaryProps>;