@lexical/react 0.14.4 → 0.15.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 (287) hide show
  1. package/LexicalAutoEmbedPlugin.dev.js +17 -1
  2. package/LexicalAutoEmbedPlugin.dev.mjs +3 -0
  3. package/LexicalAutoEmbedPlugin.js +2 -0
  4. package/LexicalAutoEmbedPlugin.mjs +2 -0
  5. package/LexicalAutoEmbedPlugin.node.mjs +2 -0
  6. package/LexicalAutoEmbedPlugin.prod.js +6 -4
  7. package/LexicalAutoEmbedPlugin.prod.mjs +2 -0
  8. package/LexicalAutoFocusPlugin.dev.js +3 -0
  9. package/LexicalAutoFocusPlugin.dev.mjs +3 -0
  10. package/LexicalAutoFocusPlugin.js +2 -0
  11. package/LexicalAutoFocusPlugin.mjs +2 -0
  12. package/LexicalAutoFocusPlugin.node.mjs +2 -0
  13. package/LexicalAutoFocusPlugin.prod.js +2 -0
  14. package/LexicalAutoFocusPlugin.prod.mjs +2 -0
  15. package/LexicalAutoLinkPlugin.dev.js +9 -4
  16. package/LexicalAutoLinkPlugin.dev.mjs +10 -5
  17. package/LexicalAutoLinkPlugin.js +2 -0
  18. package/LexicalAutoLinkPlugin.mjs +2 -0
  19. package/LexicalAutoLinkPlugin.node.mjs +2 -0
  20. package/LexicalAutoLinkPlugin.prod.js +12 -10
  21. package/LexicalAutoLinkPlugin.prod.mjs +3 -1
  22. package/LexicalBlockWithAlignableContents.dev.js +20 -4
  23. package/LexicalBlockWithAlignableContents.dev.mjs +6 -3
  24. package/LexicalBlockWithAlignableContents.js +2 -0
  25. package/LexicalBlockWithAlignableContents.mjs +2 -0
  26. package/LexicalBlockWithAlignableContents.node.mjs +2 -0
  27. package/LexicalBlockWithAlignableContents.prod.js +6 -4
  28. package/LexicalBlockWithAlignableContents.prod.mjs +2 -0
  29. package/LexicalCharacterLimitPlugin.dev.js +21 -4
  30. package/LexicalCharacterLimitPlugin.dev.mjs +7 -3
  31. package/LexicalCharacterLimitPlugin.js +2 -0
  32. package/LexicalCharacterLimitPlugin.mjs +2 -0
  33. package/LexicalCharacterLimitPlugin.node.mjs +2 -0
  34. package/LexicalCharacterLimitPlugin.prod.js +11 -9
  35. package/LexicalCharacterLimitPlugin.prod.mjs +3 -1
  36. package/LexicalCheckListPlugin.dev.js +3 -0
  37. package/LexicalCheckListPlugin.dev.mjs +3 -0
  38. package/LexicalCheckListPlugin.js +2 -0
  39. package/LexicalCheckListPlugin.mjs +2 -0
  40. package/LexicalCheckListPlugin.node.mjs +2 -0
  41. package/LexicalCheckListPlugin.prod.js +2 -0
  42. package/LexicalCheckListPlugin.prod.mjs +2 -0
  43. package/LexicalClearEditorPlugin.dev.js +5 -2
  44. package/LexicalClearEditorPlugin.dev.mjs +7 -4
  45. package/LexicalClearEditorPlugin.js +2 -0
  46. package/LexicalClearEditorPlugin.mjs +2 -0
  47. package/LexicalClearEditorPlugin.node.mjs +2 -0
  48. package/LexicalClearEditorPlugin.prod.js +3 -1
  49. package/LexicalClearEditorPlugin.prod.mjs +3 -1
  50. package/LexicalClickableLinkPlugin.dev.js +14 -13
  51. package/LexicalClickableLinkPlugin.dev.mjs +14 -13
  52. package/LexicalClickableLinkPlugin.js +2 -0
  53. package/LexicalClickableLinkPlugin.mjs +2 -0
  54. package/LexicalClickableLinkPlugin.node.mjs +2 -0
  55. package/LexicalClickableLinkPlugin.prod.js +5 -4
  56. package/LexicalClickableLinkPlugin.prod.mjs +3 -1
  57. package/LexicalCollaborationContext.dev.js +3 -0
  58. package/LexicalCollaborationContext.dev.mjs +3 -0
  59. package/LexicalCollaborationContext.js +2 -0
  60. package/LexicalCollaborationContext.mjs +2 -0
  61. package/LexicalCollaborationContext.node.mjs +2 -0
  62. package/LexicalCollaborationContext.prod.js +2 -0
  63. package/LexicalCollaborationContext.prod.mjs +2 -0
  64. package/LexicalCollaborationPlugin.dev.js +19 -2
  65. package/LexicalCollaborationPlugin.dev.mjs +4 -0
  66. package/LexicalCollaborationPlugin.js +2 -0
  67. package/LexicalCollaborationPlugin.mjs +2 -0
  68. package/LexicalCollaborationPlugin.node.mjs +2 -0
  69. package/LexicalCollaborationPlugin.prod.js +12 -10
  70. package/LexicalCollaborationPlugin.prod.mjs +2 -0
  71. package/LexicalComposer.dev.js +19 -3
  72. package/LexicalComposer.dev.mjs +7 -4
  73. package/LexicalComposer.js +2 -0
  74. package/LexicalComposer.mjs +2 -0
  75. package/LexicalComposer.node.mjs +2 -0
  76. package/LexicalComposer.prod.js +5 -3
  77. package/LexicalComposer.prod.mjs +3 -1
  78. package/LexicalComposerContext.dev.js +3 -0
  79. package/LexicalComposerContext.dev.mjs +3 -0
  80. package/LexicalComposerContext.js +2 -0
  81. package/LexicalComposerContext.mjs +2 -0
  82. package/LexicalComposerContext.node.mjs +2 -0
  83. package/LexicalComposerContext.prod.js +4 -2
  84. package/LexicalComposerContext.prod.mjs +3 -1
  85. package/LexicalContentEditable.dev.js +18 -3
  86. package/LexicalContentEditable.dev.mjs +6 -4
  87. package/LexicalContentEditable.js +2 -0
  88. package/LexicalContentEditable.mjs +2 -0
  89. package/LexicalContentEditable.node.mjs +2 -0
  90. package/LexicalContentEditable.prod.js +6 -3
  91. package/LexicalContentEditable.prod.mjs +3 -1
  92. package/LexicalContextMenuPlugin.dev.js +24 -7
  93. package/LexicalContextMenuPlugin.dev.mjs +11 -7
  94. package/LexicalContextMenuPlugin.js +2 -0
  95. package/LexicalContextMenuPlugin.js.flow +12 -0
  96. package/LexicalContextMenuPlugin.mjs +2 -0
  97. package/LexicalContextMenuPlugin.node.mjs +2 -0
  98. package/LexicalContextMenuPlugin.prod.js +18 -16
  99. package/LexicalContextMenuPlugin.prod.mjs +3 -1
  100. package/LexicalDecoratorBlockNode.d.ts +1 -0
  101. package/LexicalDecoratorBlockNode.dev.js +6 -0
  102. package/LexicalDecoratorBlockNode.dev.mjs +6 -0
  103. package/LexicalDecoratorBlockNode.js +2 -0
  104. package/LexicalDecoratorBlockNode.mjs +2 -0
  105. package/LexicalDecoratorBlockNode.node.mjs +2 -0
  106. package/LexicalDecoratorBlockNode.prod.js +3 -1
  107. package/LexicalDecoratorBlockNode.prod.mjs +3 -1
  108. package/LexicalEditorRefPlugin.dev.js +17 -1
  109. package/LexicalEditorRefPlugin.dev.mjs +3 -0
  110. package/LexicalEditorRefPlugin.js +2 -0
  111. package/LexicalEditorRefPlugin.js.flow +19 -0
  112. package/LexicalEditorRefPlugin.mjs +2 -0
  113. package/LexicalEditorRefPlugin.node.mjs +2 -0
  114. package/LexicalEditorRefPlugin.prod.js +3 -1
  115. package/LexicalEditorRefPlugin.prod.mjs +2 -0
  116. package/LexicalErrorBoundary.dev.js +21 -5
  117. package/LexicalErrorBoundary.dev.mjs +3 -0
  118. package/LexicalErrorBoundary.js +2 -0
  119. package/LexicalErrorBoundary.mjs +2 -0
  120. package/LexicalErrorBoundary.node.mjs +2 -0
  121. package/LexicalErrorBoundary.prod.js +6 -4
  122. package/LexicalErrorBoundary.prod.mjs +2 -0
  123. package/LexicalHashtagPlugin.dev.js +5 -2
  124. package/LexicalHashtagPlugin.dev.mjs +5 -2
  125. package/LexicalHashtagPlugin.js +2 -0
  126. package/LexicalHashtagPlugin.mjs +2 -0
  127. package/LexicalHashtagPlugin.node.mjs +2 -0
  128. package/LexicalHashtagPlugin.prod.js +2 -0
  129. package/LexicalHashtagPlugin.prod.mjs +2 -0
  130. package/LexicalHistoryPlugin.dev.js +4 -0
  131. package/LexicalHistoryPlugin.dev.mjs +4 -0
  132. package/LexicalHistoryPlugin.js +2 -0
  133. package/LexicalHistoryPlugin.mjs +2 -0
  134. package/LexicalHistoryPlugin.node.mjs +2 -0
  135. package/LexicalHistoryPlugin.prod.js +2 -0
  136. package/LexicalHistoryPlugin.prod.mjs +2 -0
  137. package/LexicalHorizontalRuleNode.dev.js +22 -6
  138. package/LexicalHorizontalRuleNode.dev.mjs +8 -5
  139. package/LexicalHorizontalRuleNode.js +2 -0
  140. package/LexicalHorizontalRuleNode.mjs +2 -0
  141. package/LexicalHorizontalRuleNode.node.mjs +2 -0
  142. package/LexicalHorizontalRuleNode.prod.js +7 -5
  143. package/LexicalHorizontalRuleNode.prod.mjs +2 -0
  144. package/LexicalHorizontalRulePlugin.dev.js +3 -0
  145. package/LexicalHorizontalRulePlugin.dev.mjs +3 -0
  146. package/LexicalHorizontalRulePlugin.js +2 -0
  147. package/LexicalHorizontalRulePlugin.mjs +2 -0
  148. package/LexicalHorizontalRulePlugin.node.mjs +2 -0
  149. package/LexicalHorizontalRulePlugin.prod.js +2 -0
  150. package/LexicalHorizontalRulePlugin.prod.mjs +2 -0
  151. package/LexicalLinkPlugin.dev.js +6 -3
  152. package/LexicalLinkPlugin.dev.mjs +7 -4
  153. package/LexicalLinkPlugin.js +2 -0
  154. package/LexicalLinkPlugin.mjs +2 -0
  155. package/LexicalLinkPlugin.node.mjs +2 -0
  156. package/LexicalLinkPlugin.prod.js +3 -1
  157. package/LexicalLinkPlugin.prod.mjs +3 -1
  158. package/LexicalListPlugin.dev.js +4 -0
  159. package/LexicalListPlugin.dev.mjs +4 -0
  160. package/LexicalListPlugin.js +2 -0
  161. package/LexicalListPlugin.mjs +2 -0
  162. package/LexicalListPlugin.node.mjs +2 -0
  163. package/LexicalListPlugin.prod.js +2 -0
  164. package/LexicalListPlugin.prod.mjs +2 -0
  165. package/LexicalMarkdownShortcutPlugin.dev.js +3 -0
  166. package/LexicalMarkdownShortcutPlugin.dev.mjs +3 -0
  167. package/LexicalMarkdownShortcutPlugin.js +2 -0
  168. package/LexicalMarkdownShortcutPlugin.mjs +2 -0
  169. package/LexicalMarkdownShortcutPlugin.node.mjs +2 -0
  170. package/LexicalMarkdownShortcutPlugin.prod.js +2 -0
  171. package/LexicalMarkdownShortcutPlugin.prod.mjs +2 -0
  172. package/LexicalNestedComposer.dev.js +17 -1
  173. package/LexicalNestedComposer.dev.mjs +3 -0
  174. package/LexicalNestedComposer.js +2 -0
  175. package/LexicalNestedComposer.mjs +2 -0
  176. package/LexicalNestedComposer.node.mjs +2 -0
  177. package/LexicalNestedComposer.prod.js +7 -5
  178. package/LexicalNestedComposer.prod.mjs +3 -1
  179. package/LexicalNodeEventPlugin.dev.js +3 -0
  180. package/LexicalNodeEventPlugin.dev.mjs +3 -0
  181. package/LexicalNodeEventPlugin.js +2 -0
  182. package/LexicalNodeEventPlugin.js.flow +12 -0
  183. package/LexicalNodeEventPlugin.mjs +2 -0
  184. package/LexicalNodeEventPlugin.node.mjs +2 -0
  185. package/LexicalNodeEventPlugin.prod.js +2 -0
  186. package/LexicalNodeEventPlugin.prod.mjs +2 -0
  187. package/LexicalNodeMenuPlugin.dev.js +25 -8
  188. package/LexicalNodeMenuPlugin.dev.mjs +11 -7
  189. package/LexicalNodeMenuPlugin.js +2 -0
  190. package/LexicalNodeMenuPlugin.mjs +2 -0
  191. package/LexicalNodeMenuPlugin.node.mjs +2 -0
  192. package/LexicalNodeMenuPlugin.prod.js +17 -15
  193. package/LexicalNodeMenuPlugin.prod.mjs +3 -1
  194. package/LexicalOnChangePlugin.dev.js +5 -2
  195. package/LexicalOnChangePlugin.dev.mjs +7 -4
  196. package/LexicalOnChangePlugin.js +2 -0
  197. package/LexicalOnChangePlugin.mjs +2 -0
  198. package/LexicalOnChangePlugin.node.mjs +2 -0
  199. package/LexicalOnChangePlugin.prod.js +3 -1
  200. package/LexicalOnChangePlugin.prod.mjs +3 -1
  201. package/LexicalPlainTextPlugin.dev.js +26 -7
  202. package/LexicalPlainTextPlugin.dev.mjs +13 -7
  203. package/LexicalPlainTextPlugin.js +2 -0
  204. package/LexicalPlainTextPlugin.mjs +2 -0
  205. package/LexicalPlainTextPlugin.node.mjs +2 -0
  206. package/LexicalPlainTextPlugin.prod.js +6 -4
  207. package/LexicalPlainTextPlugin.prod.mjs +3 -1
  208. package/LexicalRichTextPlugin.dev.js +26 -7
  209. package/LexicalRichTextPlugin.dev.mjs +13 -7
  210. package/LexicalRichTextPlugin.js +2 -0
  211. package/LexicalRichTextPlugin.mjs +2 -0
  212. package/LexicalRichTextPlugin.node.mjs +2 -0
  213. package/LexicalRichTextPlugin.prod.js +6 -4
  214. package/LexicalRichTextPlugin.prod.mjs +3 -1
  215. package/LexicalTabIndentationPlugin.dev.js +5 -2
  216. package/LexicalTabIndentationPlugin.dev.mjs +5 -2
  217. package/LexicalTabIndentationPlugin.js +2 -0
  218. package/LexicalTabIndentationPlugin.mjs +2 -0
  219. package/LexicalTabIndentationPlugin.node.mjs +2 -0
  220. package/LexicalTabIndentationPlugin.prod.js +2 -0
  221. package/LexicalTabIndentationPlugin.prod.mjs +2 -0
  222. package/LexicalTableOfContents.d.ts +1 -1
  223. package/LexicalTableOfContents.dev.js +47 -8
  224. package/LexicalTableOfContents.dev.mjs +48 -9
  225. package/LexicalTableOfContents.js +2 -0
  226. package/LexicalTableOfContents.mjs +2 -0
  227. package/LexicalTableOfContents.node.mjs +2 -0
  228. package/LexicalTableOfContents.prod.js +6 -4
  229. package/LexicalTableOfContents.prod.mjs +3 -1
  230. package/LexicalTablePlugin.dev.js +28 -2
  231. package/LexicalTablePlugin.dev.mjs +31 -5
  232. package/LexicalTablePlugin.js +2 -0
  233. package/LexicalTablePlugin.mjs +2 -0
  234. package/LexicalTablePlugin.node.mjs +2 -0
  235. package/LexicalTablePlugin.prod.js +9 -5
  236. package/LexicalTablePlugin.prod.mjs +3 -1
  237. package/LexicalTreeView.dev.js +18 -2
  238. package/LexicalTreeView.dev.mjs +3 -0
  239. package/LexicalTreeView.js +2 -0
  240. package/LexicalTreeView.mjs +2 -0
  241. package/LexicalTreeView.node.mjs +2 -0
  242. package/LexicalTreeView.prod.js +5 -3
  243. package/LexicalTreeView.prod.mjs +2 -0
  244. package/LexicalTypeaheadMenuPlugin.dev.js +25 -8
  245. package/LexicalTypeaheadMenuPlugin.dev.mjs +11 -7
  246. package/LexicalTypeaheadMenuPlugin.js +2 -0
  247. package/LexicalTypeaheadMenuPlugin.mjs +2 -0
  248. package/LexicalTypeaheadMenuPlugin.node.mjs +2 -0
  249. package/LexicalTypeaheadMenuPlugin.prod.js +21 -19
  250. package/LexicalTypeaheadMenuPlugin.prod.mjs +3 -1
  251. package/package.json +20 -19
  252. package/shared/useCharacterLimit.d.ts +1 -1
  253. package/useLexicalEditable.dev.js +6 -2
  254. package/useLexicalEditable.dev.mjs +8 -4
  255. package/useLexicalEditable.js +2 -0
  256. package/useLexicalEditable.mjs +2 -0
  257. package/useLexicalEditable.node.mjs +2 -0
  258. package/useLexicalEditable.prod.js +3 -1
  259. package/useLexicalEditable.prod.mjs +3 -1
  260. package/useLexicalIsTextContentEmpty.dev.js +5 -2
  261. package/useLexicalIsTextContentEmpty.dev.mjs +7 -4
  262. package/useLexicalIsTextContentEmpty.js +2 -0
  263. package/useLexicalIsTextContentEmpty.mjs +2 -0
  264. package/useLexicalIsTextContentEmpty.node.mjs +2 -0
  265. package/useLexicalIsTextContentEmpty.prod.js +3 -1
  266. package/useLexicalIsTextContentEmpty.prod.mjs +3 -1
  267. package/useLexicalNodeSelection.dev.js +3 -0
  268. package/useLexicalNodeSelection.dev.mjs +4 -1
  269. package/useLexicalNodeSelection.js +2 -0
  270. package/useLexicalNodeSelection.mjs +2 -0
  271. package/useLexicalNodeSelection.node.mjs +2 -0
  272. package/useLexicalNodeSelection.prod.js +2 -0
  273. package/useLexicalNodeSelection.prod.mjs +3 -1
  274. package/useLexicalSubscription.dev.js +5 -2
  275. package/useLexicalSubscription.dev.mjs +7 -4
  276. package/useLexicalSubscription.js +2 -0
  277. package/useLexicalSubscription.mjs +2 -0
  278. package/useLexicalSubscription.node.mjs +2 -0
  279. package/useLexicalSubscription.prod.js +3 -1
  280. package/useLexicalSubscription.prod.mjs +3 -1
  281. package/useLexicalTextEntity.dev.js +3 -0
  282. package/useLexicalTextEntity.dev.mjs +3 -0
  283. package/useLexicalTextEntity.js +2 -0
  284. package/useLexicalTextEntity.mjs +2 -0
  285. package/useLexicalTextEntity.node.mjs +2 -0
  286. package/useLexicalTextEntity.prod.js +2 -0
  287. package/useLexicalTextEntity.prod.mjs +2 -0
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalNestedComposer.dev.mjs') : import('./LexicalNestedComposer.prod.mjs'));
8
10
  export const LexicalNestedComposer = mod.LexicalNestedComposer;
@@ -3,9 +3,11 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- 'use strict';var d=require("@lexical/react/LexicalCollaborationContext"),m=require("@lexical/react/LexicalComposerContext"),q=require("react");function t(a){let h=new URLSearchParams;h.append("code",a);for(let e=1;e<arguments.length;e++)h.append("v",arguments[e]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${h} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
8
- function u(a){a=a.transform();return null!==a?new Set([a]):new Set}
9
- exports.LexicalNestedComposer=function({initialEditor:a,children:h,initialNodes:e,initialTheme:v,skipCollabChecks:w}){let r=q.useRef(!1),n=q.useContext(m.LexicalComposerContext);null==n&&t(9);let [f,{getTheme:x}]=n,z=q.useMemo(()=>{var c=v||x()||void 0;const y=m.createLexicalComposerContext(n,c);void 0!==c&&(a._config.theme=c);a._parentEditor=f;if(e)for(var b of e){var g=c=null;"function"!==typeof b&&(g=b,b=g.replace,c=g.with,g=g.withKlass||null);const l=a._nodes.get(b.getType());a._nodes.set(b.getType(),
10
- {exportDOM:l?l.exportDOM:void 0,klass:b,replace:c,replaceWithKlass:g,transforms:u(b)})}else{b=a._nodes=new Map(f._nodes);for(const [l,k]of b)a._nodes.set(l,{exportDOM:k.exportDOM,klass:k.klass,replace:k.replace,replaceWithKlass:k.replaceWithKlass,transforms:u(k.klass)})}a._config.namespace=f._config.namespace;a._editable=f._editable;return[a,y]},[]),{isCollabActive:A,yjsDocMap:B}=d.useCollaborationContext(),p=w||r.current||B.has(a.getKey());q.useEffect(()=>{p&&(r.current=!0)},[p]);q.useEffect(()=>
11
- f.registerEditableListener(c=>{a.setEditable(c)}),[a,f]);return q.createElement(m.LexicalComposerContext.Provider,{value:z},!A||p?h:null)}
8
+
9
+ 'use strict';var b=require("@lexical/react/LexicalCollaborationContext"),h=require("@lexical/react/LexicalComposerContext"),n=require("react"),p=Object.create(null);if(n)for(var t in n)p[t]=n[t];p.default=n;var u;
10
+ function v(a){let k=new URLSearchParams;k.append("code",a);for(let e=1;e<arguments.length;e++)k.append("v",arguments[e]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${k} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}u=v&&v.__esModule&&Object.prototype.hasOwnProperty.call(v,"default")?v["default"]:v;function x(a){a=a.transform();return null!==a?new Set([a]):new Set}
11
+ exports.LexicalNestedComposer=function({initialEditor:a,children:k,initialNodes:e,initialTheme:y,skipCollabChecks:z}){let w=n.useRef(!1),q=n.useContext(h.LexicalComposerContext);null==q&&u(9);let [f,{getTheme:A}]=q,C=n.useMemo(()=>{var d=y||A()||void 0;const B=h.createLexicalComposerContext(q,d);void 0!==d&&(a._config.theme=d);a._parentEditor=f;if(e)for(var c of e){var g=d=null;"function"!==typeof c&&(g=c,c=g.replace,d=g.with,g=g.withKlass||null);const m=a._nodes.get(c.getType());a._nodes.set(c.getType(),
12
+ {exportDOM:m?m.exportDOM:void 0,klass:c,replace:d,replaceWithKlass:g,transforms:x(c)})}else{c=a._nodes=new Map(f._nodes);for(const [m,l]of c)a._nodes.set(m,{exportDOM:l.exportDOM,klass:l.klass,replace:l.replace,replaceWithKlass:l.replaceWithKlass,transforms:x(l.klass)})}a._config.namespace=f._config.namespace;a._editable=f._editable;return[a,B]},[]),{isCollabActive:D,yjsDocMap:E}=b.useCollaborationContext(),r=z||w.current||E.has(a.getKey());n.useEffect(()=>{r&&(w.current=!0)},[r]);n.useEffect(()=>
13
+ f.registerEditableListener(d=>{a.setEditable(d)}),[a,f]);return p.createElement(h.LexicalComposerContext.Provider,{value:C},!D||r?k:null)}
@@ -3,5 +3,7 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- import{useCollaborationContext as e}from"@lexical/react/LexicalCollaborationContext";import{LexicalComposerContext as t,createLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import*as o from"react";import{useRef as n,useContext as l,useMemo as i,useEffect as a}from"react";var s=function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)};function c(e){const t=e.transform();return null!==t?new Set([t]):new Set}function p({initialEditor:p,children:f,initialNodes:d,initialTheme:m,skipCollabChecks:u}){const h=n(!1),x=l(t);null==x&&s(9);const[g,{getTheme:v}]=x,_=i((()=>{const e=m||v()||void 0,t=r(x,e);if(void 0!==e&&(p._config.theme=e),p._parentEditor=g,d)for(let e of d){let t=null,r=null;if("function"!=typeof e){const o=e;e=o.replace,t=o.with,r=o.withKlass||null}const o=p._nodes.get(e.getType());p._nodes.set(e.getType(),{exportDOM:o?o.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:r,transforms:c(e)})}else{const e=p._nodes=new Map(g._nodes);for(const[t,r]of e)p._nodes.set(t,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,transforms:c(r.klass)})}return p._config.namespace=g._config.namespace,p._editable=g._editable,[p,t]}),[]),{isCollabActive:w,yjsDocMap:b}=e(),C=u||h.current||b.has(p.getKey());return a((()=>{C&&(h.current=!0)}),[C]),a((()=>g.registerEditableListener((e=>{p.setEditable(e)}))),[p,g]),o.createElement(t.Provider,{value:_},!w||C?f:null)}export{p as LexicalNestedComposer};
8
+
9
+ import{useCollaborationContext as e}from"@lexical/react/LexicalCollaborationContext";import{LexicalComposerContext as t,createLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import*as o from"react";import{useRef as n,useContext as l,useMemo as a,useEffect as i}from"react";function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c=s((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function p(e){const t=e.transform();return null!==t?new Set([t]):new Set}function f({initialEditor:s,children:f,initialNodes:d,initialTheme:u,skipCollabChecks:m}){const h=n(!1),x=l(t);null==x&&c(9);const[_,{getTheme:g}]=x,v=a((()=>{const e=u||g()||void 0,t=r(x,e);if(void 0!==e&&(s._config.theme=e),s._parentEditor=_,d)for(let e of d){let t=null,r=null;if("function"!=typeof e){const o=e;e=o.replace,t=o.with,r=o.withKlass||null}const o=s._nodes.get(e.getType());s._nodes.set(e.getType(),{exportDOM:o?o.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:r,transforms:p(e)})}else{const e=s._nodes=new Map(_._nodes);for(const[t,r]of e)s._nodes.set(t,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,transforms:p(r.klass)})}return s._config.namespace=_._config.namespace,s._editable=_._editable,[s,t]}),[]),{isCollabActive:w,yjsDocMap:b}=e(),M=m||h.current||b.has(s.getKey());return i((()=>{M&&(h.current=!0)}),[M]),i((()=>_.registerEditableListener((e=>{s.setEditable(e)}))),[s,_]),o.createElement(t.Provider,{value:v},!w||M?f:null)}export{f as LexicalNestedComposer};
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict';
8
10
 
9
11
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
@@ -18,6 +20,7 @@ var react = require('react');
18
20
  * LICENSE file in the root directory of this source tree.
19
21
  *
20
22
  */
23
+
21
24
  const capturedEvents = new Set(['mouseenter', 'mouseleave']);
22
25
  function NodeEventPlugin({
23
26
  nodeType,
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
8
10
  import { $findMatchingParent } from '@lexical/utils';
9
11
  import { $getNearestNodeFromDOMNode } from 'lexical';
@@ -16,6 +18,7 @@ import { useRef, useEffect } from 'react';
16
18
  * LICENSE file in the root directory of this source tree.
17
19
  *
18
20
  */
21
+
19
22
  const capturedEvents = new Set(['mouseenter', 'mouseleave']);
20
23
  function NodeEventPlugin({
21
24
  nodeType,
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict'
8
10
  const LexicalNodeEventPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalNodeEventPlugin.dev.js') : require('./LexicalNodeEventPlugin.prod.js');
9
11
  module.exports = LexicalNodeEventPlugin;
@@ -0,0 +1,12 @@
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
+ * @flow strict
8
+ */
9
+
10
+ /**
11
+ * LexicalNodeEventPlugin
12
+ */
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import * as modDev from './LexicalNodeEventPlugin.dev.mjs';
8
10
  import * as modProd from './LexicalNodeEventPlugin.prod.mjs';
9
11
  const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalNodeEventPlugin.dev.mjs') : import('./LexicalNodeEventPlugin.prod.mjs'));
8
10
  export const NodeEventPlugin = mod.NodeEventPlugin;
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict';var g=require("@lexical/react/LexicalComposerContext"),m=require("@lexical/utils"),n=require("lexical"),p=require("react");let q=new Set(["mouseenter","mouseleave"]);
8
10
  exports.NodeEventPlugin=function({nodeType:d,eventType:e,eventListener:h}){let [c]=g.useLexicalComposerContext(),k=p.useRef(h);k.current=h;p.useEffect(()=>{let f=q.has(e),l=b=>{c.update(()=>{var a=n.$getNearestNodeFromDOMNode(b.target);null!==a&&(a=f?a instanceof d?a:null:m.$findMatchingParent(a,r=>r instanceof d),null!==a&&k.current(b,c,a.getKey()))})};return c.registerRootListener((b,a)=>{b&&b.addEventListener(e,l,f);a&&a.removeEventListener(e,l,f)})},[c,d]);return null}
@@ -3,5 +3,7 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as t}from"@lexical/utils";import{$getNearestNodeFromDOMNode as n}from"lexical";import{useRef as r,useEffect as o}from"react";const i=new Set(["mouseenter","mouseleave"]);function l({nodeType:l,eventType:s,eventListener:c}){const[u]=e(),a=r(c);return a.current=c,o((()=>{const e=i.has(s),r=r=>{u.update((()=>{const o=n(r.target);if(null!==o){const n=e?o instanceof l?o:null:t(o,(e=>e instanceof l));if(null!==n)return void a.current(r,u,n.getKey())}}))};return u.registerRootListener(((t,n)=>{t&&t.addEventListener(s,r,e),n&&n.removeEventListener(s,r,e)}))}),[u,l]),null}export{l as NodeEventPlugin};
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict';
8
10
 
9
11
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
@@ -11,6 +13,19 @@ var lexical = require('lexical');
11
13
  var React = require('react');
12
14
  var utils = require('@lexical/utils');
13
15
 
16
+ function _interopNamespaceDefault(e) {
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ for (var k in e) {
20
+ n[k] = e[k];
21
+ }
22
+ }
23
+ n.default = e;
24
+ return n;
25
+ }
26
+
27
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
28
+
14
29
  /**
15
30
  * Copyright (c) Meta Platforms, Inc. and affiliates.
16
31
  *
@@ -28,8 +43,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
28
43
  * LICENSE file in the root directory of this source tree.
29
44
  *
30
45
  */
46
+
31
47
  const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
32
- var useLayoutEffect = useLayoutEffectImpl;
33
48
 
34
49
  /**
35
50
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -38,6 +53,7 @@ var useLayoutEffect = useLayoutEffectImpl;
38
53
  * LICENSE file in the root directory of this source tree.
39
54
  *
40
55
  */
56
+
41
57
  class MenuOption {
42
58
  constructor(key) {
43
59
  this.key = key;
@@ -125,7 +141,7 @@ function $splitNodeContainingQuery(match) {
125
141
  function getScrollParent(element, includeHidden) {
126
142
  let style = getComputedStyle(element);
127
143
  const excludeStaticParent = style.position === 'absolute';
128
- const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
144
+ const overflowRegex = /(auto|scroll)/;
129
145
  if (style.position === 'fixed') {
130
146
  return document.body;
131
147
  }
@@ -152,7 +168,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
152
168
  React.useEffect(() => {
153
169
  if (targetElement != null && resolution != null) {
154
170
  const rootElement = editor.getRootElement();
155
- const rootScrollParent = rootElement != null ? getScrollParent(rootElement, false) : document.body;
171
+ const rootScrollParent = rootElement != null ? getScrollParent(rootElement) : document.body;
156
172
  let ticking = false;
157
173
  let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
158
174
  const handleScroll = function () {
@@ -224,7 +240,7 @@ function LexicalMenu({
224
240
  }
225
241
  };
226
242
  }, [editor]);
227
- useLayoutEffect(() => {
243
+ useLayoutEffectImpl(() => {
228
244
  if (options === null) {
229
245
  setHighlightedIndex(null);
230
246
  } else if (selectedIndex === null) {
@@ -336,7 +352,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
336
352
  if (left + menuWidth > rootElementRect.right) {
337
353
  containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
338
354
  }
339
- if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
355
+ if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
340
356
  containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
341
357
  }
342
358
  }
@@ -388,9 +404,10 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
388
404
  * LICENSE file in the root directory of this source tree.
389
405
  *
390
406
  */
407
+
391
408
  function startTransition(callback) {
392
- if (React.startTransition) {
393
- React.startTransition(callback);
409
+ if (React__namespace.startTransition) {
410
+ React__namespace.startTransition(callback);
394
411
  } else {
395
412
  callback();
396
413
  }
@@ -452,7 +469,7 @@ function LexicalNodeMenuPlugin({
452
469
  });
453
470
  }
454
471
  }, [editor, positionOrCloseMenu, nodeKey]);
455
- return resolution === null || editor === null ? null : /*#__PURE__*/React.createElement(LexicalMenu, {
472
+ return resolution === null || editor === null ? null : /*#__PURE__*/React__namespace.createElement(LexicalMenu, {
456
473
  close: closeNodeMenu,
457
474
  resolution: resolution,
458
475
  editor: editor,
@@ -3,11 +3,13 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
8
10
  import { createCommand, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection, $isRangeSelection, $getNodeByKey } from 'lexical';
9
11
  import * as React from 'react';
10
- import { useLayoutEffect as useLayoutEffect$1, useEffect, useState, useCallback, useMemo, useRef } from 'react';
12
+ import { useLayoutEffect, useEffect, useState, useCallback, useMemo, useRef } from 'react';
11
13
  import { mergeRegister } from '@lexical/utils';
12
14
 
13
15
  /**
@@ -27,8 +29,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
27
29
  * LICENSE file in the root directory of this source tree.
28
30
  *
29
31
  */
30
- const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect$1 : useEffect;
31
- var useLayoutEffect = useLayoutEffectImpl;
32
+
33
+ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
32
34
 
33
35
  /**
34
36
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -37,6 +39,7 @@ var useLayoutEffect = useLayoutEffectImpl;
37
39
  * LICENSE file in the root directory of this source tree.
38
40
  *
39
41
  */
42
+
40
43
  class MenuOption {
41
44
  constructor(key) {
42
45
  this.key = key;
@@ -124,7 +127,7 @@ function $splitNodeContainingQuery(match) {
124
127
  function getScrollParent(element, includeHidden) {
125
128
  let style = getComputedStyle(element);
126
129
  const excludeStaticParent = style.position === 'absolute';
127
- const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
130
+ const overflowRegex = /(auto|scroll)/;
128
131
  if (style.position === 'fixed') {
129
132
  return document.body;
130
133
  }
@@ -151,7 +154,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
151
154
  useEffect(() => {
152
155
  if (targetElement != null && resolution != null) {
153
156
  const rootElement = editor.getRootElement();
154
- const rootScrollParent = rootElement != null ? getScrollParent(rootElement, false) : document.body;
157
+ const rootScrollParent = rootElement != null ? getScrollParent(rootElement) : document.body;
155
158
  let ticking = false;
156
159
  let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
157
160
  const handleScroll = function () {
@@ -223,7 +226,7 @@ function LexicalMenu({
223
226
  }
224
227
  };
225
228
  }, [editor]);
226
- useLayoutEffect(() => {
229
+ useLayoutEffectImpl(() => {
227
230
  if (options === null) {
228
231
  setHighlightedIndex(null);
229
232
  } else if (selectedIndex === null) {
@@ -335,7 +338,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
335
338
  if (left + menuWidth > rootElementRect.right) {
336
339
  containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
337
340
  }
338
- if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
341
+ if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
339
342
  containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
340
343
  }
341
344
  }
@@ -387,6 +390,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
387
390
  * LICENSE file in the root directory of this source tree.
388
391
  *
389
392
  */
393
+
390
394
  function startTransition(callback) {
391
395
  if (React.startTransition) {
392
396
  React.startTransition(callback);
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict'
8
10
  const LexicalNodeMenuPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalNodeMenuPlugin.dev.js') : require('./LexicalNodeMenuPlugin.prod.js');
9
11
  module.exports = LexicalNodeMenuPlugin;
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import * as modDev from './LexicalNodeMenuPlugin.dev.mjs';
8
10
  import * as modProd from './LexicalNodeMenuPlugin.prod.mjs';
9
11
  const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalNodeMenuPlugin.dev.mjs') : import('./LexicalNodeMenuPlugin.prod.mjs'));
8
10
  export const LexicalNodeMenuPlugin = mod.LexicalNodeMenuPlugin;
9
11
  export const MenuOption = mod.MenuOption;
@@ -3,19 +3,21 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- 'use strict';var k=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),x=require("react"),y=require("@lexical/utils"),z="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?x.useLayoutEffect:x.useEffect;class A{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}
8
- let B=b=>{const a=document.getElementById("typeahead-menu");if(a){var d=a.getBoundingClientRect();d.top+d.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>d.top&&a.scrollIntoView({block:"center"});b.scrollIntoView({block:"nearest"})}};
9
- function C(b){var a=t.$getSelection();if(!t.$isRangeSelection(a)||!a.isCollapsed())return null;var d=a.anchor;if("text"!==d.type)return null;a=d.getNode();if(!a.isSimpleText())return null;d=d.offset;let l=a.getTextContent().slice(0,d);var f=b.matchingString;b=b.replaceableString.length;for(let n=b;n<=f.length;n++)l.substr(-n)===f.substr(0,n)&&(b=n);b=d-b;if(0>b)return null;let p;0===b?[p]=a.splitText(d):[,p]=a.splitText(b,d);return p}
10
- function D(b,a){let d=getComputedStyle(b),l="absolute"===d.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===d.position)return document.body;for(;b=b.parentElement;)if(d=getComputedStyle(b),(!l||"static"!==d.position)&&a.test(d.overflow+d.overflowY+d.overflowX))return b;return document.body}function E(b,a){b=b.getBoundingClientRect();a=a.getBoundingClientRect();return b.top>a.top&&b.top<a.bottom}
11
- function F(b,a,d,l){let [f]=k.useLexicalComposerContext();x.useEffect(()=>{if(null!=a&&null!=b){let p=f.getRootElement(),n=null!=p?D(p,!1):document.body,w=!1,m=E(a,n),c=function(){w||(window.requestAnimationFrame(function(){d();w=!1}),w=!0);const q=E(a,n);q!==m&&(m=q,null!=l&&l(q))},g=new ResizeObserver(d);window.addEventListener("resize",d);document.addEventListener("scroll",c,{capture:!0,passive:!0});g.observe(a);return()=>{g.unobserve(a);window.removeEventListener("resize",d);document.removeEventListener("scroll",
12
- c,!0)}}},[a,f,l,d,b])}let G=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
13
- function H({close:b,editor:a,anchorElementRef:d,resolution:l,options:f,menuRenderFn:p,onSelectOption:n,shouldSplitNodeWithQuery:w=!1,commandPriority:m=t.COMMAND_PRIORITY_LOW}){let [c,g]=x.useState(null);x.useEffect(()=>{g(0)},[l.match&&l.match.matchingString]);let q=x.useCallback(e=>{a.update(()=>{const h=null!=l.match&&w?C(l.match):null;n(e,h,b,l.match?l.match.matchingString:"")})},[a,w,l.match,n,b]),r=x.useCallback(e=>{const h=a.getRootElement();null!==h&&(h.setAttribute("aria-activedescendant",
14
- "typeahead-item-"+e),g(e))},[a]);x.useEffect(()=>()=>{let e=a.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[a]);z(()=>{null===f?g(null):null===c&&r(0)},[f,c,r]);x.useEffect(()=>y.mergeRegister(a.registerCommand(G,({option:e})=>e.ref&&null!=e.ref.current?(B(e.ref.current),!0):!1,m)),[a,r,m]);x.useEffect(()=>y.mergeRegister(a.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>{if(null!==f&&f.length&&null!==c){let h=c!==f.length-1?c+1:0;r(h);let u=f[h];null!=u.ref&&u.ref.current&&
15
- a.dispatchCommand(G,{index:h,option:u});e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>{if(null!==f&&f.length&&null!==c){var h=0!==c?c-1:f.length-1;r(h);h=f[h];null!=h.ref&&h.ref.current&&B(h.ref.current);e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(t.KEY_ESCAPE_COMMAND,e=>{e.preventDefault();e.stopImmediatePropagation();b();return!0},m),a.registerCommand(t.KEY_TAB_COMMAND,e=>{if(null===f||null===c||null==
16
- f[c])return!1;e.preventDefault();e.stopImmediatePropagation();q(f[c]);return!0},m),a.registerCommand(t.KEY_ENTER_COMMAND,e=>{if(null===f||null===c||null==f[c])return!1;null!==e&&(e.preventDefault(),e.stopImmediatePropagation());q(f[c]);return!0},m)),[q,b,a,f,c,r,m]);let v=x.useMemo(()=>({options:f,selectOptionAndCleanUp:q,selectedIndex:c,setHighlightedIndex:g}),[q,c,f]);return p(d,v,l.match?l.match.matchingString:"")}
17
- function I(b,a,d,l=document.body){let [f]=k.useLexicalComposerContext(),p=x.useRef(document.createElement("div")),n=x.useCallback(()=>{p.current.style.top=p.current.style.bottom;const m=f.getRootElement(),c=p.current;var g=c.firstChild;if(null!==m&&null!==b){const {left:r,top:v,width:e,height:h}=b.getRect();c.style.top=`${v+window.pageYOffset+p.current.offsetHeight+3}px`;c.style.left=`${r+window.pageXOffset}px`;c.style.height=`${h}px`;c.style.width=`${e}px`;if(null!==g){g.style.top=`${v}`;var q=g.getBoundingClientRect();
18
- g=q.height;q=q.width;const u=m.getBoundingClientRect();r+q>u.right&&(c.style.left=`${u.right-q+window.pageXOffset}px`);(v+g>window.innerHeight||v+g>u.bottom)&&v-u.top>g&&(c.style.top=`${v-g+window.pageYOffset-h}px`)}c.isConnected||(null!=d&&(c.className=d),c.setAttribute("aria-label","Typeahead menu"),c.setAttribute("id","typeahead-menu"),c.setAttribute("role","listbox"),c.style.display="block",c.style.position="absolute",l.append(c));p.current=c;m.setAttribute("aria-controls","typeahead-menu")}},
19
- [f,b,d,l]);x.useEffect(()=>{let m=f.getRootElement();if(null!==b)return n(),()=>{null!==m&&m.removeAttribute("aria-controls");let c=p.current;null!==c&&c.isConnected&&c.remove()}},[f,n,b]);let w=x.useCallback(m=>{null!==b&&(m||a(null))},[b,a]);F(b,p.current,n,w);return p}function J(b){x.startTransition?x.startTransition(b):b()}
20
- exports.LexicalNodeMenuPlugin=function({options:b,nodeKey:a,onClose:d,onOpen:l,onSelectOption:f,menuRenderFn:p,anchorClassName:n,commandPriority:w=t.COMMAND_PRIORITY_LOW,parent:m}){let [c]=k.useLexicalComposerContext(),[g,q]=x.useState(null);n=I(g,q,n,m);let r=x.useCallback(()=>{q(null);null!=d&&null!==g&&d()},[d,g]),v=x.useCallback(h=>{q(h);null!=l&&null===g&&l(h)},[l,g]),e=x.useCallback(()=>{a?c.update(()=>{const h=t.$getNodeByKey(a),u=c.getElementByKey(a);null!=h&&null!=u&&null==g&&J(()=>v({getRect:()=>
21
- u.getBoundingClientRect()}))}):null==a&&null!=g&&r()},[r,c,a,v,g]);x.useEffect(()=>{e()},[e,a]);x.useEffect(()=>{if(null!=a)return c.registerUpdateListener(({dirtyElements:h})=>{h.get(a)&&e()})},[c,e,a]);return null===g||null===c?null:x.createElement(H,{close:r,resolution:g,editor:c,anchorElementRef:n,options:b,menuRenderFn:p,onSelectOption:f,commandPriority:w})};exports.MenuOption=A
8
+
9
+ 'use strict';var k=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),x=require("react"),y=require("@lexical/utils"),z=Object.create(null);if(x)for(var A in x)z[A]=x[A];z.default=x;let B="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?x.useLayoutEffect:x.useEffect;class C{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}
10
+ let D=b=>{const a=document.getElementById("typeahead-menu");if(a){var f=a.getBoundingClientRect();f.top+f.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>f.top&&a.scrollIntoView({block:"center"});b.scrollIntoView({block:"nearest"})}};
11
+ function E(b){var a=t.$getSelection();if(!t.$isRangeSelection(a)||!a.isCollapsed())return null;var f=a.anchor;if("text"!==f.type)return null;a=f.getNode();if(!a.isSimpleText())return null;f=f.offset;let l=a.getTextContent().slice(0,f);var e=b.matchingString;b=b.replaceableString.length;for(let n=b;n<=e.length;n++)l.substr(-n)===e.substr(0,n)&&(b=n);b=f-b;if(0>b)return null;let p;0===b?[p]=a.splitText(f):[,p]=a.splitText(b,f);return p}
12
+ function F(b){let a=getComputedStyle(b),f="absolute"===a.position,l=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;b=b.parentElement;)if(a=getComputedStyle(b),(!f||"static"!==a.position)&&l.test(a.overflow+a.overflowY+a.overflowX))return b;return document.body}function G(b,a){b=b.getBoundingClientRect();a=a.getBoundingClientRect();return b.top>a.top&&b.top<a.bottom}
13
+ function H(b,a,f,l){let [e]=k.useLexicalComposerContext();x.useEffect(()=>{if(null!=a&&null!=b){let p=e.getRootElement(),n=null!=p?F(p):document.body,w=!1,m=G(a,n),c=function(){w||(window.requestAnimationFrame(function(){f();w=!1}),w=!0);const q=G(a,n);q!==m&&(m=q,null!=l&&l(q))},g=new ResizeObserver(f);window.addEventListener("resize",f);document.addEventListener("scroll",c,{capture:!0,passive:!0});g.observe(a);return()=>{g.unobserve(a);window.removeEventListener("resize",f);document.removeEventListener("scroll",
14
+ c,!0)}}},[a,e,l,f,b])}let I=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
15
+ function J({close:b,editor:a,anchorElementRef:f,resolution:l,options:e,menuRenderFn:p,onSelectOption:n,shouldSplitNodeWithQuery:w=!1,commandPriority:m=t.COMMAND_PRIORITY_LOW}){let [c,g]=x.useState(null);x.useEffect(()=>{g(0)},[l.match&&l.match.matchingString]);let q=x.useCallback(d=>{a.update(()=>{const h=null!=l.match&&w?E(l.match):null;n(d,h,b,l.match?l.match.matchingString:"")})},[a,w,l.match,n,b]),r=x.useCallback(d=>{const h=a.getRootElement();null!==h&&(h.setAttribute("aria-activedescendant",
16
+ "typeahead-item-"+d),g(d))},[a]);x.useEffect(()=>()=>{let d=a.getRootElement();null!==d&&d.removeAttribute("aria-activedescendant")},[a]);B(()=>{null===e?g(null):null===c&&r(0)},[e,c,r]);x.useEffect(()=>y.mergeRegister(a.registerCommand(I,({option:d})=>d.ref&&null!=d.ref.current?(D(d.ref.current),!0):!1,m)),[a,r,m]);x.useEffect(()=>y.mergeRegister(a.registerCommand(t.KEY_ARROW_DOWN_COMMAND,d=>{if(null!==e&&e.length&&null!==c){let h=c!==e.length-1?c+1:0;r(h);let u=e[h];null!=u.ref&&u.ref.current&&
17
+ a.dispatchCommand(I,{index:h,option:u});d.preventDefault();d.stopImmediatePropagation()}return!0},m),a.registerCommand(t.KEY_ARROW_UP_COMMAND,d=>{if(null!==e&&e.length&&null!==c){var h=0!==c?c-1:e.length-1;r(h);h=e[h];null!=h.ref&&h.ref.current&&D(h.ref.current);d.preventDefault();d.stopImmediatePropagation()}return!0},m),a.registerCommand(t.KEY_ESCAPE_COMMAND,d=>{d.preventDefault();d.stopImmediatePropagation();b();return!0},m),a.registerCommand(t.KEY_TAB_COMMAND,d=>{if(null===e||null===c||null==
18
+ e[c])return!1;d.preventDefault();d.stopImmediatePropagation();q(e[c]);return!0},m),a.registerCommand(t.KEY_ENTER_COMMAND,d=>{if(null===e||null===c||null==e[c])return!1;null!==d&&(d.preventDefault(),d.stopImmediatePropagation());q(e[c]);return!0},m)),[q,b,a,e,c,r,m]);let v=x.useMemo(()=>({options:e,selectOptionAndCleanUp:q,selectedIndex:c,setHighlightedIndex:g}),[q,c,e]);return p(f,v,l.match?l.match.matchingString:"")}
19
+ function K(b,a,f,l=document.body){let [e]=k.useLexicalComposerContext(),p=x.useRef(document.createElement("div")),n=x.useCallback(()=>{p.current.style.top=p.current.style.bottom;const m=e.getRootElement(),c=p.current;var g=c.firstChild;if(null!==m&&null!==b){const {left:r,top:v,width:d,height:h}=b.getRect();c.style.top=`${v+window.pageYOffset+p.current.offsetHeight+3}px`;c.style.left=`${r+window.pageXOffset}px`;c.style.height=`${h}px`;c.style.width=`${d}px`;if(null!==g){g.style.top=`${v}`;var q=g.getBoundingClientRect();
20
+ g=q.height;q=q.width;const u=m.getBoundingClientRect();r+q>u.right&&(c.style.left=`${u.right-q+window.pageXOffset}px`);(v+g>window.innerHeight||v+g>u.bottom)&&v-u.top>g+h&&(c.style.top=`${v-g+window.pageYOffset-h}px`)}c.isConnected||(null!=f&&(c.className=f),c.setAttribute("aria-label","Typeahead menu"),c.setAttribute("id","typeahead-menu"),c.setAttribute("role","listbox"),c.style.display="block",c.style.position="absolute",l.append(c));p.current=c;m.setAttribute("aria-controls","typeahead-menu")}},
21
+ [e,b,f,l]);x.useEffect(()=>{let m=e.getRootElement();if(null!==b)return n(),()=>{null!==m&&m.removeAttribute("aria-controls");let c=p.current;null!==c&&c.isConnected&&c.remove()}},[e,n,b]);let w=x.useCallback(m=>{null!==b&&(m||a(null))},[b,a]);H(b,p.current,n,w);return p}function L(b){z.startTransition?z.startTransition(b):b()}
22
+ exports.LexicalNodeMenuPlugin=function({options:b,nodeKey:a,onClose:f,onOpen:l,onSelectOption:e,menuRenderFn:p,anchorClassName:n,commandPriority:w=t.COMMAND_PRIORITY_LOW,parent:m}){let [c]=k.useLexicalComposerContext(),[g,q]=x.useState(null);n=K(g,q,n,m);let r=x.useCallback(()=>{q(null);null!=f&&null!==g&&f()},[f,g]),v=x.useCallback(h=>{q(h);null!=l&&null===g&&l(h)},[l,g]),d=x.useCallback(()=>{a?c.update(()=>{const h=t.$getNodeByKey(a),u=c.getElementByKey(a);null!=h&&null!=u&&null==g&&L(()=>v({getRect:()=>
23
+ u.getBoundingClientRect()}))}):null==a&&null!=g&&r()},[r,c,a,v,g]);x.useEffect(()=>{d()},[d,a]);x.useEffect(()=>{if(null!=a)return c.registerUpdateListener(({dirtyElements:h})=>{h.get(a)&&d()})},[c,d,a]);return null===g||null===c?null:z.createElement(J,{close:r,resolution:g,editor:c,anchorElementRef:n,options:b,menuRenderFn:p,onSelectOption:e,commandPriority:w})};exports.MenuOption=C
@@ -3,5 +3,7 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- 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 l,KEY_TAB_COMMAND as r,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as s,$getSelection as u,$isRangeSelection as c,$getNodeByKey as a}from"lexical";import*as m from"react";import{useLayoutEffect as d,useEffect as p,useState as f,useCallback as g,useMemo as h,useRef as y}from"react";import{mergeRegister as w}from"@lexical/utils";var b="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?d:p;class v{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const C=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 R(e,n,o,l){const[r]=t();p((()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,l=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)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t,!1):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!=l&&l(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,r,l,o,e])}const x=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:e,anchorElementRef:a,resolution:m,options:d,menuRenderFn:y,onSelectOption:v,shouldSplitNodeWithQuery:E=!1,commandPriority:R=s}){const[O,I]=f(null),S=m.match&&m.match.matchingString;p((()=>{I(0)}),[S]);const A=g((n=>{e.update((()=>{const e=null!=m.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 l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,s=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.substr(-n)===e.substr(0,n)&&(o=n);return o}(r,t.matchingString,i);if(s<0)return null;let a;return 0===s?[a]=o.splitText(l):[,a]=o.splitText(s,l),a}(m.match):null;v(n,e,t,m.match?m.match.matchingString:"")}))}),[e,E,m.match,v,t]),P=g((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),I(t))}),[e]);p((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),b((()=>{null===d?I(null):null===O&&P(0)}),[d,O,P]),p((()=>w(e.registerCommand(x,(({option:t})=>!(!t.ref||null==t.ref.current)&&(C(t.ref.current),!0)),R))),[e,P,R]),p((()=>w(e.registerCommand(n,(t=>{const n=t;if(null!==d&&d.length&&null!==O){const t=O!==d.length-1?O+1:0;P(t);const o=d[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(x,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),R),e.registerCommand(o,(t=>{const e=t;if(null!==d&&d.length&&null!==O){const t=0!==O?O-1:d.length-1;P(t);const n=d[t];null!=n.ref&&n.ref.current&&C(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),e.registerCommand(l,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),R),e.registerCommand(r,(t=>{const e=t;return null!==d&&null!==O&&null!=d[O]&&(e.preventDefault(),e.stopImmediatePropagation(),A(d[O]),!0)}),R),e.registerCommand(i,(t=>null!==d&&null!==O&&null!=d[O]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(d[O]),!0)),R))),[A,t,e,d,O,P,R]);return y(a,h((()=>({options:d,selectOptionAndCleanUp:A,selectedIndex:O,setHighlightedIndex:I})),[A,O,d]),m.match?m.match.matchingString:"")}function I({options:e,nodeKey:n,onClose:o,onOpen:l,onSelectOption:r,menuRenderFn:i,anchorClassName:u,commandPriority:c=s,parent:d}){const[h]=t(),[w,b]=f(null),v=function(e,n,o,l=document.body){const[r]=t(),i=y(document.createElement("div")),s=g((()=>{i.current.style.top=i.current.style.bottom;const t=r.getRootElement(),n=i.current,s=n.firstChild;if(null!==t&&null!==e){const{left:r,top:u,width:c,height:a}=e.getRect(),m=i.current.offsetHeight;if(n.style.top=`${u+window.pageYOffset+m+3}px`,n.style.left=`${r+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,l=e.width,i=t.getBoundingClientRect();r+l>i.right&&(n.style.left=`${i.right-l+window.pageXOffset}px`),(u+o>window.innerHeight||u+o>i.bottom)&&u-i.top>o&&(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",l.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[r,e,o,l]);p((()=>{const t=r.getRootElement();if(null!==e)return s(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[r,s,e]);const u=g((t=>{null!==e&&(t||n(null))}),[e,n]);return R(e,i.current,s,u),i}(w,b,u,d),C=g((()=>{b(null),null!=o&&null!==w&&o()}),[o,w]),E=g((t=>{b(t),null!=l&&null===w&&l(t)}),[l,w]),x=g((()=>{n?h.update((()=>{const t=a(n),e=h.getElementByKey(n);var o;null!=t&&null!=e&&null==w&&(o=()=>E({getRect:()=>e.getBoundingClientRect()}),m.startTransition?m.startTransition(o):o())})):null==n&&null!=w&&C()}),[C,h,n,E,w]);return p((()=>{x()}),[x,n]),p((()=>{if(null!=n)return h.registerUpdateListener((({dirtyElements:t})=>{t.get(n)&&x()}))}),[h,x,n]),null===w||null===h?null:m.createElement(O,{close:C,resolution:w,editor:h,anchorElementRef:v,options:e,menuRenderFn:i,onSelectOption:r,commandPriority:c})}export{I as LexicalNodeMenuPlugin,v as MenuOption};
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 l,KEY_TAB_COMMAND as r,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as s,$getSelection as u,$isRangeSelection as c,$getNodeByKey as a}from"lexical";import*as m from"react";import{useLayoutEffect as d,useEffect as p,useState as f,useCallback as g,useMemo as h,useRef as y}from"react";import{mergeRegister as w}from"@lexical/utils";const b="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?d:p;class v{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const C=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 R(e,n,o,l){const[r]=t();p((()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,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!=l&&l(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,r,l,o,e])}const x=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:e,anchorElementRef:a,resolution:m,options:d,menuRenderFn:y,onSelectOption:v,shouldSplitNodeWithQuery:E=!1,commandPriority:R=s}){const[O,I]=f(null),S=m.match&&m.match.matchingString;p((()=>{I(0)}),[S]);const A=g((n=>{e.update((()=>{const e=null!=m.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 l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,s=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.substr(-n)===e.substr(0,n)&&(o=n);return o}(r,t.matchingString,i);if(s<0)return null;let a;return 0===s?[a]=o.splitText(l):[,a]=o.splitText(s,l),a}(m.match):null;v(n,e,t,m.match?m.match.matchingString:"")}))}),[e,E,m.match,v,t]),P=g((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),I(t))}),[e]);p((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),b((()=>{null===d?I(null):null===O&&P(0)}),[d,O,P]),p((()=>w(e.registerCommand(x,(({option:t})=>!(!t.ref||null==t.ref.current)&&(C(t.ref.current),!0)),R))),[e,P,R]),p((()=>w(e.registerCommand(n,(t=>{const n=t;if(null!==d&&d.length&&null!==O){const t=O!==d.length-1?O+1:0;P(t);const o=d[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(x,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),R),e.registerCommand(o,(t=>{const e=t;if(null!==d&&d.length&&null!==O){const t=0!==O?O-1:d.length-1;P(t);const n=d[t];null!=n.ref&&n.ref.current&&C(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),e.registerCommand(l,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),R),e.registerCommand(r,(t=>{const e=t;return null!==d&&null!==O&&null!=d[O]&&(e.preventDefault(),e.stopImmediatePropagation(),A(d[O]),!0)}),R),e.registerCommand(i,(t=>null!==d&&null!==O&&null!=d[O]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(d[O]),!0)),R))),[A,t,e,d,O,P,R]);return y(a,h((()=>({options:d,selectOptionAndCleanUp:A,selectedIndex:O,setHighlightedIndex:I})),[A,O,d]),m.match?m.match.matchingString:"")}function I({options:e,nodeKey:n,onClose:o,onOpen:l,onSelectOption:r,menuRenderFn:i,anchorClassName:u,commandPriority:c=s,parent:d}){const[h]=t(),[w,b]=f(null),v=function(e,n,o,l=document.body){const[r]=t(),i=y(document.createElement("div")),s=g((()=>{i.current.style.top=i.current.style.bottom;const t=r.getRootElement(),n=i.current,s=n.firstChild;if(null!==t&&null!==e){const{left:r,top:u,width:c,height:a}=e.getRect(),m=i.current.offsetHeight;if(n.style.top=`${u+window.pageYOffset+m+3}px`,n.style.left=`${r+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,l=e.width,i=t.getBoundingClientRect();r+l>i.right&&(n.style.left=`${i.right-l+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",l.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[r,e,o,l]);p((()=>{const t=r.getRootElement();if(null!==e)return s(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[r,s,e]);const u=g((t=>{null!==e&&(t||n(null))}),[e,n]);return R(e,i.current,s,u),i}(w,b,u,d),C=g((()=>{b(null),null!=o&&null!==w&&o()}),[o,w]),E=g((t=>{b(t),null!=l&&null===w&&l(t)}),[l,w]),x=g((()=>{n?h.update((()=>{const t=a(n),e=h.getElementByKey(n);var o;null!=t&&null!=e&&null==w&&(o=()=>E({getRect:()=>e.getBoundingClientRect()}),m.startTransition?m.startTransition(o):o())})):null==n&&null!=w&&C()}),[C,h,n,E,w]);return p((()=>{x()}),[x,n]),p((()=>{if(null!=n)return h.registerUpdateListener((({dirtyElements:t})=>{t.get(n)&&x()}))}),[h,x,n]),null===w||null===h?null:m.createElement(O,{close:C,resolution:w,editor:h,anchorElementRef:v,options:e,menuRenderFn:i,onSelectOption:r,commandPriority:c})}export{I as LexicalNodeMenuPlugin,v as MenuOption};
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict';
8
10
 
9
11
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
@@ -26,8 +28,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
26
28
  * LICENSE file in the root directory of this source tree.
27
29
  *
28
30
  */
31
+
29
32
  const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
30
- var useLayoutEffect = useLayoutEffectImpl;
31
33
 
32
34
  /**
33
35
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -36,13 +38,14 @@ var useLayoutEffect = useLayoutEffectImpl;
36
38
  * LICENSE file in the root directory of this source tree.
37
39
  *
38
40
  */
41
+
39
42
  function OnChangePlugin({
40
43
  ignoreHistoryMergeTagChange = true,
41
44
  ignoreSelectionChange = false,
42
45
  onChange
43
46
  }) {
44
47
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
45
- useLayoutEffect(() => {
48
+ useLayoutEffectImpl(() => {
46
49
  if (onChange) {
47
50
  return editor.registerUpdateListener(({
48
51
  editorState,
@@ -3,9 +3,11 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
8
- import { useLayoutEffect as useLayoutEffect$1, useEffect } from 'react';
10
+ import { useLayoutEffect, useEffect } from 'react';
9
11
 
10
12
  /**
11
13
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -24,8 +26,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
24
26
  * LICENSE file in the root directory of this source tree.
25
27
  *
26
28
  */
27
- const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect$1 : useEffect;
28
- var useLayoutEffect = useLayoutEffectImpl;
29
+
30
+ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
29
31
 
30
32
  /**
31
33
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -34,13 +36,14 @@ var useLayoutEffect = useLayoutEffectImpl;
34
36
  * LICENSE file in the root directory of this source tree.
35
37
  *
36
38
  */
39
+
37
40
  function OnChangePlugin({
38
41
  ignoreHistoryMergeTagChange = true,
39
42
  ignoreSelectionChange = false,
40
43
  onChange
41
44
  }) {
42
45
  const [editor] = useLexicalComposerContext();
43
- useLayoutEffect(() => {
46
+ useLayoutEffectImpl(() => {
44
47
  if (onChange) {
45
48
  return editor.registerUpdateListener(({
46
49
  editorState,
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict'
8
10
  const LexicalOnChangePlugin = process.env.NODE_ENV === 'development' ? require('./LexicalOnChangePlugin.dev.js') : require('./LexicalOnChangePlugin.prod.js');
9
11
  module.exports = LexicalOnChangePlugin;
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import * as modDev from './LexicalOnChangePlugin.dev.mjs';
8
10
  import * as modProd from './LexicalOnChangePlugin.prod.mjs';
9
11
  const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalOnChangePlugin.dev.mjs') : import('./LexicalOnChangePlugin.prod.mjs'));
8
10
  export const OnChangePlugin = mod.OnChangePlugin;
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- 'use strict';var c=require("@lexical/react/LexicalComposerContext"),g=require("react"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;
8
+
9
+ 'use strict';var c=require("@lexical/react/LexicalComposerContext"),g=require("react");let h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;
8
10
  exports.OnChangePlugin=function({ignoreHistoryMergeTagChange:d=!0,ignoreSelectionChange:e=!1,onChange:a}){let [b]=c.useLexicalComposerContext();h(()=>{if(a)return b.registerUpdateListener(({editorState:k,dirtyElements:l,dirtyLeaves:m,prevEditorState:n,tags:f})=>{e&&0===l.size&&0===m.size||d&&f.has("history-merge")||n.isEmpty()||a(k,b,f)})},[b,d,e,a]);return null}
@@ -3,5 +3,7 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as r}from"react";var o="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:r;function i({ignoreHistoryMergeTagChange:t=!0,ignoreSelectionChange:r=!1,onChange:i}){const[n]=e();return o((()=>{if(i)return n.registerUpdateListener((({editorState:e,dirtyElements:o,dirtyLeaves:a,prevEditorState:s,tags:d})=>{r&&0===o.size&&0===a.size||t&&d.has("history-merge")||s.isEmpty()||i(e,n,d)}))}),[n,t,r,i]),null}export{i as OnChangePlugin};
8
+
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as o}from"react";const r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:o;function i({ignoreHistoryMergeTagChange:t=!0,ignoreSelectionChange:o=!1,onChange:i}){const[n]=e();return r((()=>{if(i)return n.registerUpdateListener((({editorState:e,dirtyElements:r,dirtyLeaves:a,prevEditorState:d,tags:s})=>{o&&0===r.size&&0===a.size||t&&s.has("history-merge")||d.isEmpty()||i(e,n,s)}))}),[n,t,o,i]),null}export{i as OnChangePlugin};