@lexical/react 0.14.5 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/LexicalAutoEmbedPlugin.dev.js +15 -11
  2. package/LexicalAutoEmbedPlugin.dev.mjs +5 -2
  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 -5
  7. package/LexicalAutoEmbedPlugin.prod.mjs +3 -1
  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 +14 -9
  23. package/LexicalBlockWithAlignableContents.dev.mjs +11 -7
  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 +3 -1
  29. package/LexicalCharacterLimitPlugin.dev.js +17 -12
  30. package/LexicalCharacterLimitPlugin.dev.mjs +12 -8
  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 +5 -0
  37. package/LexicalCheckListPlugin.dev.mjs +5 -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 +4 -2
  42. package/LexicalCheckListPlugin.prod.mjs +3 -1
  43. package/LexicalClearEditorPlugin.dev.js +9 -2
  44. package/LexicalClearEditorPlugin.dev.mjs +11 -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.d.ts +3 -1
  51. package/LexicalClickableLinkPlugin.dev.js +17 -15
  52. package/LexicalClickableLinkPlugin.dev.mjs +16 -15
  53. package/LexicalClickableLinkPlugin.js +2 -0
  54. package/LexicalClickableLinkPlugin.js.flow +3 -1
  55. package/LexicalClickableLinkPlugin.mjs +3 -0
  56. package/LexicalClickableLinkPlugin.node.mjs +3 -0
  57. package/LexicalClickableLinkPlugin.prod.js +6 -4
  58. package/LexicalClickableLinkPlugin.prod.mjs +3 -1
  59. package/LexicalCollaborationContext.dev.js +3 -0
  60. package/LexicalCollaborationContext.dev.mjs +3 -0
  61. package/LexicalCollaborationContext.js +2 -0
  62. package/LexicalCollaborationContext.mjs +2 -0
  63. package/LexicalCollaborationContext.node.mjs +2 -0
  64. package/LexicalCollaborationContext.prod.js +2 -0
  65. package/LexicalCollaborationContext.prod.mjs +2 -0
  66. package/LexicalCollaborationPlugin.dev.js +20 -2
  67. package/LexicalCollaborationPlugin.dev.mjs +6 -1
  68. package/LexicalCollaborationPlugin.js +2 -0
  69. package/LexicalCollaborationPlugin.mjs +2 -0
  70. package/LexicalCollaborationPlugin.node.mjs +2 -0
  71. package/LexicalCollaborationPlugin.prod.js +12 -10
  72. package/LexicalCollaborationPlugin.prod.mjs +3 -1
  73. package/LexicalComposer.dev.js +17 -8
  74. package/LexicalComposer.dev.mjs +16 -8
  75. package/LexicalComposer.js +2 -0
  76. package/LexicalComposer.mjs +2 -0
  77. package/LexicalComposer.node.mjs +2 -0
  78. package/LexicalComposer.prod.js +5 -4
  79. package/LexicalComposer.prod.mjs +3 -1
  80. package/LexicalComposerContext.dev.js +3 -0
  81. package/LexicalComposerContext.dev.mjs +3 -0
  82. package/LexicalComposerContext.js +2 -0
  83. package/LexicalComposerContext.mjs +2 -0
  84. package/LexicalComposerContext.node.mjs +2 -0
  85. package/LexicalComposerContext.prod.js +4 -2
  86. package/LexicalComposerContext.prod.mjs +3 -1
  87. package/LexicalContentEditable.dev.js +24 -23
  88. package/LexicalContentEditable.dev.mjs +22 -22
  89. package/LexicalContentEditable.js +2 -0
  90. package/LexicalContentEditable.mjs +2 -0
  91. package/LexicalContentEditable.node.mjs +2 -0
  92. package/LexicalContentEditable.prod.js +5 -3
  93. package/LexicalContentEditable.prod.mjs +3 -1
  94. package/LexicalContextMenuPlugin.dev.js +29 -7
  95. package/LexicalContextMenuPlugin.dev.mjs +17 -8
  96. package/LexicalContextMenuPlugin.js +2 -0
  97. package/LexicalContextMenuPlugin.js.flow +12 -0
  98. package/LexicalContextMenuPlugin.mjs +2 -0
  99. package/LexicalContextMenuPlugin.node.mjs +2 -0
  100. package/LexicalContextMenuPlugin.prod.js +18 -16
  101. package/LexicalContextMenuPlugin.prod.mjs +3 -1
  102. package/LexicalDecoratorBlockNode.d.ts +1 -0
  103. package/LexicalDecoratorBlockNode.dev.js +6 -0
  104. package/LexicalDecoratorBlockNode.dev.mjs +6 -0
  105. package/LexicalDecoratorBlockNode.js +2 -0
  106. package/LexicalDecoratorBlockNode.mjs +2 -0
  107. package/LexicalDecoratorBlockNode.node.mjs +2 -0
  108. package/LexicalDecoratorBlockNode.prod.js +3 -1
  109. package/LexicalDecoratorBlockNode.prod.mjs +3 -1
  110. package/LexicalEditorRefPlugin.dev.js +17 -1
  111. package/LexicalEditorRefPlugin.dev.mjs +3 -0
  112. package/LexicalEditorRefPlugin.js +2 -0
  113. package/LexicalEditorRefPlugin.js.flow +19 -0
  114. package/LexicalEditorRefPlugin.mjs +2 -0
  115. package/LexicalEditorRefPlugin.node.mjs +2 -0
  116. package/LexicalEditorRefPlugin.prod.js +3 -1
  117. package/LexicalEditorRefPlugin.prod.mjs +2 -0
  118. package/LexicalErrorBoundary.d.ts +3 -1
  119. package/LexicalErrorBoundary.dev.js +30 -10
  120. package/LexicalErrorBoundary.dev.mjs +13 -7
  121. package/LexicalErrorBoundary.js +2 -0
  122. package/LexicalErrorBoundary.js.flow +4 -1
  123. package/LexicalErrorBoundary.mjs +3 -0
  124. package/LexicalErrorBoundary.node.mjs +3 -0
  125. package/LexicalErrorBoundary.prod.js +6 -4
  126. package/LexicalErrorBoundary.prod.mjs +3 -1
  127. package/LexicalHashtagPlugin.dev.js +5 -2
  128. package/LexicalHashtagPlugin.dev.mjs +5 -2
  129. package/LexicalHashtagPlugin.js +2 -0
  130. package/LexicalHashtagPlugin.mjs +2 -0
  131. package/LexicalHashtagPlugin.node.mjs +2 -0
  132. package/LexicalHashtagPlugin.prod.js +2 -0
  133. package/LexicalHashtagPlugin.prod.mjs +2 -0
  134. package/LexicalHistoryPlugin.dev.js +4 -0
  135. package/LexicalHistoryPlugin.dev.mjs +4 -0
  136. package/LexicalHistoryPlugin.js +2 -0
  137. package/LexicalHistoryPlugin.mjs +2 -0
  138. package/LexicalHistoryPlugin.node.mjs +2 -0
  139. package/LexicalHistoryPlugin.prod.js +2 -0
  140. package/LexicalHistoryPlugin.prod.mjs +2 -0
  141. package/LexicalHorizontalRuleNode.d.ts +2 -2
  142. package/LexicalHorizontalRuleNode.dev.js +23 -12
  143. package/LexicalHorizontalRuleNode.dev.mjs +21 -11
  144. package/LexicalHorizontalRuleNode.js +2 -0
  145. package/LexicalHorizontalRuleNode.mjs +2 -0
  146. package/LexicalHorizontalRuleNode.node.mjs +2 -0
  147. package/LexicalHorizontalRuleNode.prod.js +7 -5
  148. package/LexicalHorizontalRuleNode.prod.mjs +3 -1
  149. package/LexicalHorizontalRulePlugin.dev.js +3 -0
  150. package/LexicalHorizontalRulePlugin.dev.mjs +3 -0
  151. package/LexicalHorizontalRulePlugin.js +2 -0
  152. package/LexicalHorizontalRulePlugin.mjs +2 -0
  153. package/LexicalHorizontalRulePlugin.node.mjs +2 -0
  154. package/LexicalHorizontalRulePlugin.prod.js +2 -0
  155. package/LexicalHorizontalRulePlugin.prod.mjs +2 -0
  156. package/LexicalLinkPlugin.dev.js +6 -3
  157. package/LexicalLinkPlugin.dev.mjs +7 -4
  158. package/LexicalLinkPlugin.js +2 -0
  159. package/LexicalLinkPlugin.mjs +2 -0
  160. package/LexicalLinkPlugin.node.mjs +2 -0
  161. package/LexicalLinkPlugin.prod.js +3 -1
  162. package/LexicalLinkPlugin.prod.mjs +3 -1
  163. package/LexicalListPlugin.dev.js +4 -0
  164. package/LexicalListPlugin.dev.mjs +4 -0
  165. package/LexicalListPlugin.js +2 -0
  166. package/LexicalListPlugin.mjs +2 -0
  167. package/LexicalListPlugin.node.mjs +2 -0
  168. package/LexicalListPlugin.prod.js +2 -0
  169. package/LexicalListPlugin.prod.mjs +2 -0
  170. package/LexicalMarkdownShortcutPlugin.dev.js +3 -0
  171. package/LexicalMarkdownShortcutPlugin.dev.mjs +3 -0
  172. package/LexicalMarkdownShortcutPlugin.js +2 -0
  173. package/LexicalMarkdownShortcutPlugin.mjs +2 -0
  174. package/LexicalMarkdownShortcutPlugin.node.mjs +2 -0
  175. package/LexicalMarkdownShortcutPlugin.prod.js +2 -0
  176. package/LexicalMarkdownShortcutPlugin.prod.mjs +2 -0
  177. package/LexicalNestedComposer.dev.js +14 -9
  178. package/LexicalNestedComposer.dev.mjs +8 -4
  179. package/LexicalNestedComposer.js +2 -0
  180. package/LexicalNestedComposer.mjs +2 -0
  181. package/LexicalNestedComposer.node.mjs +2 -0
  182. package/LexicalNestedComposer.prod.js +7 -5
  183. package/LexicalNestedComposer.prod.mjs +3 -1
  184. package/LexicalNodeEventPlugin.dev.js +3 -0
  185. package/LexicalNodeEventPlugin.dev.mjs +3 -0
  186. package/LexicalNodeEventPlugin.js +2 -0
  187. package/LexicalNodeEventPlugin.js.flow +12 -0
  188. package/LexicalNodeEventPlugin.mjs +2 -0
  189. package/LexicalNodeEventPlugin.node.mjs +2 -0
  190. package/LexicalNodeEventPlugin.prod.js +2 -0
  191. package/LexicalNodeEventPlugin.prod.mjs +2 -0
  192. package/LexicalNodeMenuPlugin.dev.js +30 -8
  193. package/LexicalNodeMenuPlugin.dev.mjs +17 -8
  194. package/LexicalNodeMenuPlugin.js +2 -0
  195. package/LexicalNodeMenuPlugin.mjs +2 -0
  196. package/LexicalNodeMenuPlugin.node.mjs +2 -0
  197. package/LexicalNodeMenuPlugin.prod.js +17 -15
  198. package/LexicalNodeMenuPlugin.prod.mjs +3 -1
  199. package/LexicalOnChangePlugin.dev.js +9 -2
  200. package/LexicalOnChangePlugin.dev.mjs +11 -4
  201. package/LexicalOnChangePlugin.js +2 -0
  202. package/LexicalOnChangePlugin.mjs +2 -0
  203. package/LexicalOnChangePlugin.node.mjs +2 -0
  204. package/LexicalOnChangePlugin.prod.js +3 -1
  205. package/LexicalOnChangePlugin.prod.mjs +3 -1
  206. package/LexicalPlainTextPlugin.dev.js +34 -19
  207. package/LexicalPlainTextPlugin.dev.mjs +31 -17
  208. package/LexicalPlainTextPlugin.js +2 -0
  209. package/LexicalPlainTextPlugin.js.flow +1 -1
  210. package/LexicalPlainTextPlugin.mjs +2 -0
  211. package/LexicalPlainTextPlugin.node.mjs +2 -0
  212. package/LexicalPlainTextPlugin.prod.js +6 -4
  213. package/LexicalPlainTextPlugin.prod.mjs +3 -1
  214. package/LexicalRichTextPlugin.dev.js +34 -19
  215. package/LexicalRichTextPlugin.dev.mjs +31 -17
  216. package/LexicalRichTextPlugin.js +2 -0
  217. package/LexicalRichTextPlugin.js.flow +1 -1
  218. package/LexicalRichTextPlugin.mjs +2 -0
  219. package/LexicalRichTextPlugin.node.mjs +2 -0
  220. package/LexicalRichTextPlugin.prod.js +6 -4
  221. package/LexicalRichTextPlugin.prod.mjs +3 -1
  222. package/LexicalTabIndentationPlugin.dev.js +5 -2
  223. package/LexicalTabIndentationPlugin.dev.mjs +5 -2
  224. package/LexicalTabIndentationPlugin.js +2 -0
  225. package/LexicalTabIndentationPlugin.mjs +2 -0
  226. package/LexicalTabIndentationPlugin.node.mjs +2 -0
  227. package/LexicalTabIndentationPlugin.prod.js +2 -0
  228. package/LexicalTabIndentationPlugin.prod.mjs +2 -0
  229. package/LexicalTableOfContents.d.ts +6 -13
  230. package/LexicalTableOfContents.dev.js +57 -10
  231. package/LexicalTableOfContents.dev.mjs +58 -11
  232. package/LexicalTableOfContents.js +2 -0
  233. package/LexicalTableOfContents.js.flow +3 -7
  234. package/LexicalTableOfContents.mjs +2 -0
  235. package/LexicalTableOfContents.node.mjs +2 -0
  236. package/LexicalTableOfContents.prod.js +6 -4
  237. package/LexicalTableOfContents.prod.mjs +3 -1
  238. package/LexicalTableOfContentsPlugin.d.ts +20 -0
  239. package/LexicalTableOfContentsPlugin.dev.js +198 -0
  240. package/LexicalTableOfContentsPlugin.dev.mjs +196 -0
  241. package/LexicalTableOfContentsPlugin.js +11 -0
  242. package/LexicalTableOfContentsPlugin.js.flow +18 -0
  243. package/LexicalTableOfContentsPlugin.mjs +12 -0
  244. package/LexicalTableOfContentsPlugin.node.mjs +10 -0
  245. package/LexicalTableOfContentsPlugin.prod.js +12 -0
  246. package/LexicalTableOfContentsPlugin.prod.mjs +9 -0
  247. package/LexicalTablePlugin.dev.js +28 -2
  248. package/LexicalTablePlugin.dev.mjs +31 -5
  249. package/LexicalTablePlugin.js +2 -0
  250. package/LexicalTablePlugin.mjs +2 -0
  251. package/LexicalTablePlugin.node.mjs +2 -0
  252. package/LexicalTablePlugin.prod.js +9 -5
  253. package/LexicalTablePlugin.prod.mjs +3 -1
  254. package/LexicalTreeView.d.ts +3 -1
  255. package/LexicalTreeView.dev.js +22 -4
  256. package/LexicalTreeView.dev.mjs +8 -3
  257. package/LexicalTreeView.js +2 -0
  258. package/LexicalTreeView.js.flow +2 -0
  259. package/LexicalTreeView.mjs +2 -0
  260. package/LexicalTreeView.node.mjs +2 -0
  261. package/LexicalTreeView.prod.js +5 -3
  262. package/LexicalTreeView.prod.mjs +3 -1
  263. package/LexicalTypeaheadMenuPlugin.dev.js +30 -8
  264. package/LexicalTypeaheadMenuPlugin.dev.mjs +17 -8
  265. package/LexicalTypeaheadMenuPlugin.js +2 -0
  266. package/LexicalTypeaheadMenuPlugin.mjs +2 -0
  267. package/LexicalTypeaheadMenuPlugin.node.mjs +2 -0
  268. package/LexicalTypeaheadMenuPlugin.prod.js +21 -19
  269. package/LexicalTypeaheadMenuPlugin.prod.mjs +3 -1
  270. package/package.json +50 -20
  271. package/shared/useCharacterLimit.d.ts +1 -1
  272. package/useLexicalEditable.d.ts +11 -1
  273. package/useLexicalEditable.dev.js +22 -3
  274. package/useLexicalEditable.dev.mjs +23 -5
  275. package/useLexicalEditable.js +2 -0
  276. package/useLexicalEditable.js.flow +4 -1
  277. package/useLexicalEditable.mjs +4 -1
  278. package/useLexicalEditable.node.mjs +4 -1
  279. package/useLexicalEditable.prod.js +4 -2
  280. package/useLexicalEditable.prod.mjs +3 -1
  281. package/useLexicalIsTextContentEmpty.dev.js +9 -2
  282. package/useLexicalIsTextContentEmpty.dev.mjs +11 -4
  283. package/useLexicalIsTextContentEmpty.js +2 -0
  284. package/useLexicalIsTextContentEmpty.mjs +2 -0
  285. package/useLexicalIsTextContentEmpty.node.mjs +2 -0
  286. package/useLexicalIsTextContentEmpty.prod.js +3 -1
  287. package/useLexicalIsTextContentEmpty.prod.mjs +3 -1
  288. package/useLexicalNodeSelection.dev.js +3 -0
  289. package/useLexicalNodeSelection.dev.mjs +4 -1
  290. package/useLexicalNodeSelection.js +2 -0
  291. package/useLexicalNodeSelection.mjs +2 -0
  292. package/useLexicalNodeSelection.node.mjs +2 -0
  293. package/useLexicalNodeSelection.prod.js +2 -0
  294. package/useLexicalNodeSelection.prod.mjs +3 -1
  295. package/useLexicalSubscription.d.ts +4 -1
  296. package/useLexicalSubscription.dev.js +12 -3
  297. package/useLexicalSubscription.dev.mjs +13 -5
  298. package/useLexicalSubscription.js +2 -0
  299. package/useLexicalSubscription.js.flow +4 -1
  300. package/useLexicalSubscription.mjs +4 -1
  301. package/useLexicalSubscription.node.mjs +4 -1
  302. package/useLexicalSubscription.prod.js +4 -2
  303. package/useLexicalSubscription.prod.mjs +3 -1
  304. package/useLexicalTextEntity.dev.js +3 -0
  305. package/useLexicalTextEntity.dev.mjs +3 -0
  306. package/useLexicalTextEntity.js +2 -0
  307. package/useLexicalTextEntity.mjs +2 -0
  308. package/useLexicalTextEntity.node.mjs +2 -0
  309. package/useLexicalTextEntity.prod.js +2 -0
  310. package/useLexicalTextEntity.prod.mjs +2 -0
@@ -3,12 +3,15 @@
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, $isTextNode } 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';
14
+ import { jsx } from 'react/jsx-runtime';
12
15
 
13
16
  /**
14
17
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -27,8 +30,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
27
30
  * LICENSE file in the root directory of this source tree.
28
31
  *
29
32
  */
30
- const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect$1 : useEffect;
31
- var useLayoutEffect = useLayoutEffectImpl;
33
+
34
+
35
+ // This workaround is no longer necessary in React 19,
36
+ // but we currently support React >=17.x
37
+ // https://github.com/facebook/react/pull/26395
38
+ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
32
39
 
33
40
  /**
34
41
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -37,6 +44,7 @@ var useLayoutEffect = useLayoutEffectImpl;
37
44
  * LICENSE file in the root directory of this source tree.
38
45
  *
39
46
  */
47
+
40
48
  class MenuOption {
41
49
  constructor(key) {
42
50
  this.key = key;
@@ -124,7 +132,7 @@ function $splitNodeContainingQuery(match) {
124
132
  function getScrollParent$1(element, includeHidden) {
125
133
  let style = getComputedStyle(element);
126
134
  const excludeStaticParent = style.position === 'absolute';
127
- const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
135
+ const overflowRegex = /(auto|scroll)/;
128
136
  if (style.position === 'fixed') {
129
137
  return document.body;
130
138
  }
@@ -151,7 +159,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
151
159
  useEffect(() => {
152
160
  if (targetElement != null && resolution != null) {
153
161
  const rootElement = editor.getRootElement();
154
- const rootScrollParent = rootElement != null ? getScrollParent$1(rootElement, false) : document.body;
162
+ const rootScrollParent = rootElement != null ? getScrollParent$1(rootElement) : document.body;
155
163
  let ticking = false;
156
164
  let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
157
165
  const handleScroll = function () {
@@ -223,7 +231,7 @@ function LexicalMenu({
223
231
  }
224
232
  };
225
233
  }, [editor]);
226
- useLayoutEffect(() => {
234
+ useLayoutEffectImpl(() => {
227
235
  if (options === null) {
228
236
  setHighlightedIndex(null);
229
237
  } else if (selectedIndex === null) {
@@ -335,7 +343,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
335
343
  if (left + menuWidth > rootElementRect.right) {
336
344
  containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
337
345
  }
338
- if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
346
+ if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
339
347
  containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
340
348
  }
341
349
  }
@@ -387,6 +395,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
387
395
  * LICENSE file in the root directory of this source tree.
388
396
  *
389
397
  */
398
+
390
399
  const PUNCTUATION = '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
391
400
  function getTextUpToAnchor(selection) {
392
401
  const anchor = selection.anchor;
@@ -553,7 +562,7 @@ function LexicalTypeaheadMenuPlugin({
553
562
  removeUpdateListener();
554
563
  };
555
564
  }, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead]);
556
- return resolution === null || editor === null ? null : /*#__PURE__*/React.createElement(LexicalMenu, {
565
+ return resolution === null || editor === null ? null : /*#__PURE__*/jsx(LexicalMenu, {
557
566
  close: closeTypeahead,
558
567
  resolution: resolution,
559
568
  editor: editor,
@@ -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 LexicalTypeaheadMenuPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalTypeaheadMenuPlugin.dev.js') : require('./LexicalTypeaheadMenuPlugin.prod.js');
9
11
  module.exports = LexicalTypeaheadMenuPlugin;
@@ -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 './LexicalTypeaheadMenuPlugin.dev.mjs';
8
10
  import * as modProd from './LexicalTypeaheadMenuPlugin.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('./LexicalTypeaheadMenuPlugin.dev.mjs') : import('./LexicalTypeaheadMenuPlugin.prod.mjs'));
8
10
  export const LexicalTypeaheadMenuPlugin = mod.LexicalTypeaheadMenuPlugin;
9
11
  export const MenuOption = mod.MenuOption;
@@ -3,23 +3,25 @@
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 l=require("@lexical/react/LexicalComposerContext"),q=require("lexical"),y=require("react"),A=require("@lexical/utils"),B="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?y.useLayoutEffect:y.useEffect;class C{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}
8
- let D=b=>{const a=document.getElementById("typeahead-menu");if(a){var c=a.getBoundingClientRect();c.top+c.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>c.top&&a.scrollIntoView({block:"center"});b.scrollIntoView({block:"nearest"})}};
9
- function E(b){var a=q.$getSelection();if(!q.$isRangeSelection(a)||!a.isCollapsed())return null;var c=a.anchor;if("text"!==c.type)return null;a=c.getNode();if(!a.isSimpleText())return null;c=c.offset;let d=a.getTextContent().slice(0,c);var f=b.matchingString;b=b.replaceableString.length;for(let r=b;r<=f.length;r++)d.substr(-r)===f.substr(0,r)&&(b=r);b=c-b;if(0>b)return null;let n;0===b?[n]=a.splitText(c):[,n]=a.splitText(b,c);return n}
10
- function H(b,a){let c=getComputedStyle(b),d="absolute"===c.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===c.position)return document.body;for(;b=b.parentElement;)if(c=getComputedStyle(b),(!d||"static"!==c.position)&&a.test(c.overflow+c.overflowY+c.overflowX))return b;return document.body}function I(b,a){b=b.getBoundingClientRect();a=a.getBoundingClientRect();return b.top>a.top&&b.top<a.bottom}
11
- function J(b,a,c,d){let [f]=l.useLexicalComposerContext();y.useEffect(()=>{if(null!=a&&null!=b){let n=f.getRootElement(),r=null!=n?H(n,!1):document.body,v=!1,p=I(a,r),e=function(){v||(window.requestAnimationFrame(function(){c();v=!1}),v=!0);const k=I(a,r);k!==p&&(p=k,null!=d&&d(k))},h=new ResizeObserver(c);window.addEventListener("resize",c);document.addEventListener("scroll",e,{capture:!0,passive:!0});h.observe(a);return()=>{h.unobserve(a);window.removeEventListener("resize",c);document.removeEventListener("scroll",
12
- e,!0)}}},[a,f,d,c,b])}let K=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
13
- function L({close:b,editor:a,anchorElementRef:c,resolution:d,options:f,menuRenderFn:n,onSelectOption:r,shouldSplitNodeWithQuery:v=!1,commandPriority:p=q.COMMAND_PRIORITY_LOW}){let [e,h]=y.useState(null);y.useEffect(()=>{h(0)},[d.match&&d.match.matchingString]);let k=y.useCallback(g=>{a.update(()=>{const m=null!=d.match&&v?E(d.match):null;r(g,m,b,d.match?d.match.matchingString:"")})},[a,v,d.match,r,b]),t=y.useCallback(g=>{const m=a.getRootElement();null!==m&&(m.setAttribute("aria-activedescendant",
14
- "typeahead-item-"+g),h(g))},[a]);y.useEffect(()=>()=>{let g=a.getRootElement();null!==g&&g.removeAttribute("aria-activedescendant")},[a]);B(()=>{null===f?h(null):null===e&&t(0)},[f,e,t]);y.useEffect(()=>A.mergeRegister(a.registerCommand(K,({option:g})=>g.ref&&null!=g.ref.current?(D(g.ref.current),!0):!1,p)),[a,t,p]);y.useEffect(()=>A.mergeRegister(a.registerCommand(q.KEY_ARROW_DOWN_COMMAND,g=>{if(null!==f&&f.length&&null!==e){let m=e!==f.length-1?e+1:0;t(m);let w=f[m];null!=w.ref&&w.ref.current&&
15
- a.dispatchCommand(K,{index:m,option:w});g.preventDefault();g.stopImmediatePropagation()}return!0},p),a.registerCommand(q.KEY_ARROW_UP_COMMAND,g=>{if(null!==f&&f.length&&null!==e){var m=0!==e?e-1:f.length-1;t(m);m=f[m];null!=m.ref&&m.ref.current&&D(m.ref.current);g.preventDefault();g.stopImmediatePropagation()}return!0},p),a.registerCommand(q.KEY_ESCAPE_COMMAND,g=>{g.preventDefault();g.stopImmediatePropagation();b();return!0},p),a.registerCommand(q.KEY_TAB_COMMAND,g=>{if(null===f||null===e||null==
16
- f[e])return!1;g.preventDefault();g.stopImmediatePropagation();k(f[e]);return!0},p),a.registerCommand(q.KEY_ENTER_COMMAND,g=>{if(null===f||null===e||null==f[e])return!1;null!==g&&(g.preventDefault(),g.stopImmediatePropagation());k(f[e]);return!0},p)),[k,b,a,f,e,t,p]);let u=y.useMemo(()=>({options:f,selectOptionAndCleanUp:k,selectedIndex:e,setHighlightedIndex:h}),[k,e,f]);return n(c,u,d.match?d.match.matchingString:"")}
17
- function M(b,a,c,d=document.body){let [f]=l.useLexicalComposerContext(),n=y.useRef(document.createElement("div")),r=y.useCallback(()=>{n.current.style.top=n.current.style.bottom;const p=f.getRootElement(),e=n.current;var h=e.firstChild;if(null!==p&&null!==b){const {left:t,top:u,width:g,height:m}=b.getRect();e.style.top=`${u+window.pageYOffset+n.current.offsetHeight+3}px`;e.style.left=`${t+window.pageXOffset}px`;e.style.height=`${m}px`;e.style.width=`${g}px`;if(null!==h){h.style.top=`${u}`;var k=h.getBoundingClientRect();
18
- h=k.height;k=k.width;const w=p.getBoundingClientRect();t+k>w.right&&(e.style.left=`${w.right-k+window.pageXOffset}px`);(u+h>window.innerHeight||u+h>w.bottom)&&u-w.top>h&&(e.style.top=`${u-h+window.pageYOffset-m}px`)}e.isConnected||(null!=c&&(e.className=c),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("id","typeahead-menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute",d.append(e));n.current=e;p.setAttribute("aria-controls","typeahead-menu")}},
19
- [f,b,c,d]);y.useEffect(()=>{let p=f.getRootElement();if(null!==b)return r(),()=>{null!==p&&p.removeAttribute("aria-controls");let e=n.current;null!==e&&e.isConnected&&e.remove()}},[f,r,b]);let v=y.useCallback(p=>{null!==b&&(p||a(null))},[b,a]);J(b,n.current,r,v);return n}function N(b,a,c){var d=c.getSelection();if(null===d||!d.isCollapsed)return!1;c=d.anchorNode;d=d.anchorOffset;if(null==c||null==d)return!1;try{a.setStart(c,b),a.setEnd(c,d)}catch(f){return!1}return!0}
20
- function O(b){let a=null;b.getEditorState().read(()=>{var c=q.$getSelection();if(q.$isRangeSelection(c)){var d=c.anchor;"text"!==d.type?a=null:(c=d.getNode(),c.isSimpleText()?(d=d.offset,a=c.getTextContent().slice(0,d)):a=null)}});return a}function P(b,a){return 0!==a?!1:b.getEditorState().read(()=>{var c=q.$getSelection();return q.$isRangeSelection(c)?(c=c.anchor.getNode().getPreviousSibling(),q.$isTextNode(c)&&c.isTextEntity()):!1})}function Q(b){y.startTransition?y.startTransition(b):b()}
21
- let R=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
22
- exports.LexicalTypeaheadMenuPlugin=function({options:b,onQueryChange:a,onSelectOption:c,onOpen:d,onClose:f,menuRenderFn:n,triggerFn:r,anchorClassName:v,commandPriority:p=q.COMMAND_PRIORITY_LOW,parent:e}){let [h]=l.useLexicalComposerContext(),[k,t]=y.useState(null);v=M(k,t,v,e);let u=y.useCallback(()=>{t(null);null!=f&&null!==k&&f()},[f,k]),g=y.useCallback(m=>{t(m);null!=d&&null===k&&d(m)},[d,k]);y.useEffect(()=>{let m=h.registerUpdateListener(()=>{h.getEditorState().read(()=>{const w=h._window||window,
23
- z=w.document.createRange(),F=q.$getSelection(),G=O(h);if(q.$isRangeSelection(F)&&F.isCollapsed()&&null!==G&&null!==z){var x=r(G,h);a(x?x.matchingString:null);null===x||P(h,x.leadOffset)||null===N(x.leadOffset,z,w)?u():Q(()=>g({getRect:()=>z.getBoundingClientRect(),match:x}))}else u()})});return()=>{m()}},[h,r,a,k,u,g]);return null===k||null===h?null:y.createElement(L,{close:u,resolution:k,editor:h,anchorElementRef:v,options:b,menuRenderFn:n,shouldSplitNodeWithQuery:!0,onSelectOption:c,commandPriority:p})};
24
- exports.MenuOption=C;exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=R;exports.getScrollParent=function(b,a){let c=getComputedStyle(b),d="absolute"===c.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===c.position)return document.body;for(;b=b.parentElement;)if(c=getComputedStyle(b),(!d||"static"!==c.position)&&a.test(c.overflow+c.overflowY+c.overflowX))return b;return document.body};
25
- exports.useBasicTypeaheadTriggerMatch=function(b,{minLength:a=1,maxLength:c=75}){return y.useCallback(d=>{d=(new RegExp("(^|\\s|\\()(["+b+"]((?:[^"+(b+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+c+"}))$")).exec(d);if(null!==d){let f=d[1],n=d[3];if(n.length>=a)return{leadOffset:d.index+f.length,matchingString:n,replaceableString:d[2]}}return null},[c,a,b])};exports.useDynamicPositioning=J
8
+
9
+ 'use strict';var k=require("@lexical/react/LexicalComposerContext"),q=require("lexical"),y=require("react"),z=require("@lexical/utils"),B=require("react/jsx-runtime"),C=Object.create(null);if(y)for(var D in y)C[D]=y[D];C.default=y;let E="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?y.useLayoutEffect:y.useEffect;
10
+ class F{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}let G=b=>{const a=document.getElementById("typeahead-menu");if(a){var c=a.getBoundingClientRect();c.top+c.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>c.top&&a.scrollIntoView({block:"center"});b.scrollIntoView({block:"nearest"})}};
11
+ function J(b){var a=q.$getSelection();if(!q.$isRangeSelection(a)||!a.isCollapsed())return null;var c=a.anchor;if("text"!==c.type)return null;a=c.getNode();if(!a.isSimpleText())return null;c=c.offset;let d=a.getTextContent().slice(0,c);var f=b.matchingString;b=b.replaceableString.length;for(let r=b;r<=f.length;r++)d.substr(-r)===f.substr(0,r)&&(b=r);b=c-b;if(0>b)return null;let n;0===b?[n]=a.splitText(c):[,n]=a.splitText(b,c);return n}
12
+ function K(b){let a=getComputedStyle(b),c="absolute"===a.position,d=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;b=b.parentElement;)if(a=getComputedStyle(b),(!c||"static"!==a.position)&&d.test(a.overflow+a.overflowY+a.overflowX))return b;return document.body}function L(b,a){b=b.getBoundingClientRect();a=a.getBoundingClientRect();return b.top>a.top&&b.top<a.bottom}
13
+ function M(b,a,c,d){let [f]=k.useLexicalComposerContext();y.useEffect(()=>{if(null!=a&&null!=b){let n=f.getRootElement(),r=null!=n?K(n):document.body,v=!1,p=L(a,r),e=function(){v||(window.requestAnimationFrame(function(){c();v=!1}),v=!0);const l=L(a,r);l!==p&&(p=l,null!=d&&d(l))},h=new ResizeObserver(c);window.addEventListener("resize",c);document.addEventListener("scroll",e,{capture:!0,passive:!0});h.observe(a);return()=>{h.unobserve(a);window.removeEventListener("resize",c);document.removeEventListener("scroll",
14
+ e,!0)}}},[a,f,d,c,b])}let N=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
15
+ function O({close:b,editor:a,anchorElementRef:c,resolution:d,options:f,menuRenderFn:n,onSelectOption:r,shouldSplitNodeWithQuery:v=!1,commandPriority:p=q.COMMAND_PRIORITY_LOW}){let [e,h]=y.useState(null);y.useEffect(()=>{h(0)},[d.match&&d.match.matchingString]);let l=y.useCallback(g=>{a.update(()=>{const m=null!=d.match&&v?J(d.match):null;r(g,m,b,d.match?d.match.matchingString:"")})},[a,v,d.match,r,b]),t=y.useCallback(g=>{const m=a.getRootElement();null!==m&&(m.setAttribute("aria-activedescendant",
16
+ "typeahead-item-"+g),h(g))},[a]);y.useEffect(()=>()=>{let g=a.getRootElement();null!==g&&g.removeAttribute("aria-activedescendant")},[a]);E(()=>{null===f?h(null):null===e&&t(0)},[f,e,t]);y.useEffect(()=>z.mergeRegister(a.registerCommand(N,({option:g})=>g.ref&&null!=g.ref.current?(G(g.ref.current),!0):!1,p)),[a,t,p]);y.useEffect(()=>z.mergeRegister(a.registerCommand(q.KEY_ARROW_DOWN_COMMAND,g=>{if(null!==f&&f.length&&null!==e){let m=e!==f.length-1?e+1:0;t(m);let w=f[m];null!=w.ref&&w.ref.current&&
17
+ a.dispatchCommand(N,{index:m,option:w});g.preventDefault();g.stopImmediatePropagation()}return!0},p),a.registerCommand(q.KEY_ARROW_UP_COMMAND,g=>{if(null!==f&&f.length&&null!==e){var m=0!==e?e-1:f.length-1;t(m);m=f[m];null!=m.ref&&m.ref.current&&G(m.ref.current);g.preventDefault();g.stopImmediatePropagation()}return!0},p),a.registerCommand(q.KEY_ESCAPE_COMMAND,g=>{g.preventDefault();g.stopImmediatePropagation();b();return!0},p),a.registerCommand(q.KEY_TAB_COMMAND,g=>{if(null===f||null===e||null==
18
+ f[e])return!1;g.preventDefault();g.stopImmediatePropagation();l(f[e]);return!0},p),a.registerCommand(q.KEY_ENTER_COMMAND,g=>{if(null===f||null===e||null==f[e])return!1;null!==g&&(g.preventDefault(),g.stopImmediatePropagation());l(f[e]);return!0},p)),[l,b,a,f,e,t,p]);let u=y.useMemo(()=>({options:f,selectOptionAndCleanUp:l,selectedIndex:e,setHighlightedIndex:h}),[l,e,f]);return n(c,u,d.match?d.match.matchingString:"")}
19
+ function P(b,a,c,d=document.body){let [f]=k.useLexicalComposerContext(),n=y.useRef(document.createElement("div")),r=y.useCallback(()=>{n.current.style.top=n.current.style.bottom;const p=f.getRootElement(),e=n.current;var h=e.firstChild;if(null!==p&&null!==b){const {left:t,top:u,width:g,height:m}=b.getRect();e.style.top=`${u+window.pageYOffset+n.current.offsetHeight+3}px`;e.style.left=`${t+window.pageXOffset}px`;e.style.height=`${m}px`;e.style.width=`${g}px`;if(null!==h){h.style.top=`${u}`;var l=h.getBoundingClientRect();
20
+ h=l.height;l=l.width;const w=p.getBoundingClientRect();t+l>w.right&&(e.style.left=`${w.right-l+window.pageXOffset}px`);(u+h>window.innerHeight||u+h>w.bottom)&&u-w.top>h+m&&(e.style.top=`${u-h+window.pageYOffset-m}px`)}e.isConnected||(null!=c&&(e.className=c),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("id","typeahead-menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute",d.append(e));n.current=e;p.setAttribute("aria-controls","typeahead-menu")}},
21
+ [f,b,c,d]);y.useEffect(()=>{let p=f.getRootElement();if(null!==b)return r(),()=>{null!==p&&p.removeAttribute("aria-controls");let e=n.current;null!==e&&e.isConnected&&e.remove()}},[f,r,b]);let v=y.useCallback(p=>{null!==b&&(p||a(null))},[b,a]);M(b,n.current,r,v);return n}function Q(b,a,c){var d=c.getSelection();if(null===d||!d.isCollapsed)return!1;c=d.anchorNode;d=d.anchorOffset;if(null==c||null==d)return!1;try{a.setStart(c,b),a.setEnd(c,d)}catch(f){return!1}return!0}
22
+ function R(b){let a=null;b.getEditorState().read(()=>{var c=q.$getSelection();if(q.$isRangeSelection(c)){var d=c.anchor;"text"!==d.type?a=null:(c=d.getNode(),c.isSimpleText()?(d=d.offset,a=c.getTextContent().slice(0,d)):a=null)}});return a}function S(b,a){return 0!==a?!1:b.getEditorState().read(()=>{var c=q.$getSelection();return q.$isRangeSelection(c)?(c=c.anchor.getNode().getPreviousSibling(),q.$isTextNode(c)&&c.isTextEntity()):!1})}function T(b){C.startTransition?C.startTransition(b):b()}
23
+ let U=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
24
+ exports.LexicalTypeaheadMenuPlugin=function({options:b,onQueryChange:a,onSelectOption:c,onOpen:d,onClose:f,menuRenderFn:n,triggerFn:r,anchorClassName:v,commandPriority:p=q.COMMAND_PRIORITY_LOW,parent:e}){let [h]=k.useLexicalComposerContext(),[l,t]=y.useState(null);v=P(l,t,v,e);let u=y.useCallback(()=>{t(null);null!=f&&null!==l&&f()},[f,l]),g=y.useCallback(m=>{t(m);null!=d&&null===l&&d(m)},[d,l]);y.useEffect(()=>{let m=h.registerUpdateListener(()=>{h.getEditorState().read(()=>{const w=h._window||window,
25
+ A=w.document.createRange(),H=q.$getSelection(),I=R(h);if(q.$isRangeSelection(H)&&H.isCollapsed()&&null!==I&&null!==A){var x=r(I,h);a(x?x.matchingString:null);null===x||S(h,x.leadOffset)||null===Q(x.leadOffset,A,w)?u():T(()=>g({getRect:()=>A.getBoundingClientRect(),match:x}))}else u()})});return()=>{m()}},[h,r,a,l,u,g]);return null===l||null===h?null:B.jsx(O,{close:u,resolution:l,editor:h,anchorElementRef:v,options:b,menuRenderFn:n,shouldSplitNodeWithQuery:!0,onSelectOption:c,commandPriority:p})};
26
+ exports.MenuOption=F;exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=U;exports.getScrollParent=function(b,a){let c=getComputedStyle(b),d="absolute"===c.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===c.position)return document.body;for(;b=b.parentElement;)if(c=getComputedStyle(b),(!d||"static"!==c.position)&&a.test(c.overflow+c.overflowY+c.overflowX))return b;return document.body};
27
+ exports.useBasicTypeaheadTriggerMatch=function(b,{minLength:a=1,maxLength:c=75}){return y.useCallback(d=>{d=(new RegExp("(^|\\s|\\()(["+b+"]((?:[^"+(b+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+c+"}))$")).exec(d);if(null!==d){let f=d[1],n=d[3];if(n.length>=a)return{leadOffset:d.index+f.length,matchingString:n,replaceableString:d[2]}}return null},[c,a,b])};exports.useDynamicPositioning=M
@@ -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 r,KEY_TAB_COMMAND as l,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as s,$getSelection as u,$isRangeSelection as c,$isTextNode as a}from"lexical";import*as d from"react";import{useLayoutEffect as m,useEffect as f,useState as p,useCallback as g,useMemo as h,useRef as w}from"react";import{mergeRegister as y}from"@lexical/utils";var C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?m:f;class b{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const v=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function E(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function x(e,n,o,r){const[l]=t();f((()=>{if(null!=n&&null!=e){const t=l.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=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}(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!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",u,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",u,!0)}}}),[n,l,r,o,e])}const S=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function R({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:w,onSelectOption:b,shouldSplitNodeWithQuery:E=!1,commandPriority:x=s}){const[R,O]=p(null),I=d.match&&d.match.matchingString;f((()=>{O(0)}),[I]);const T=g((n=>{e.update((()=>{const e=null!=d.match&&E?function(t){const e=u();if(!c(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const r=n.offset,l=o.getTextContent().slice(0,r),i=t.replaceableString.length,s=r-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.substr(-n)===e.substr(0,n)&&(o=n);return o}(l,t.matchingString,i);if(s<0)return null;let a;return 0===s?[a]=o.splitText(r):[,a]=o.splitText(s,r),a}(d.match):null;b(n,e,t,d.match?d.match.matchingString:"")}))}),[e,E,d.match,b,t]),A=g((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))}),[e]);f((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),C((()=>{null===m?O(null):null===R&&A(0)}),[m,R,A]),f((()=>y(e.registerCommand(S,(({option:t})=>!(!t.ref||null==t.ref.current)&&(v(t.ref.current),!0)),x))),[e,A,x]),f((()=>y(e.registerCommand(n,(t=>{const n=t;if(null!==m&&m.length&&null!==R){const t=R!==m.length-1?R+1:0;A(t);const o=m[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(S,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),x),e.registerCommand(o,(t=>{const e=t;if(null!==m&&m.length&&null!==R){const t=0!==R?R-1:m.length-1;A(t);const n=m[t];null!=n.ref&&n.ref.current&&v(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),x),e.registerCommand(r,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),x),e.registerCommand(l,(t=>{const e=t;return null!==m&&null!==R&&null!=m[R]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[R]),!0)}),x),e.registerCommand(i,(t=>null!==m&&null!==R&&null!=m[R]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[R]),!0)),x))),[T,t,e,m,R,A,x]);return w(a,h((()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:R,setHighlightedIndex:O})),[T,R,m]),d.match?d.match.matchingString:"")}const O="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function I(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=e?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}const T=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function A(t,{minLength:e=1,maxLength:n=75}){return g((o=>{const r=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+O+"\\s]")+"){0,"+n+"}))$").exec(o);if(null!==r){const t=r[1],n=r[3];if(n.length>=e)return{leadOffset:r.index+t.length,matchingString:n,replaceableString:r[2]}}return null}),[n,e,t])}function N({options:e,onQueryChange:n,onSelectOption:o,onOpen:r,onClose:l,menuRenderFn:i,triggerFn:m,anchorClassName:h,commandPriority:y=s,parent:C}){const[b]=t(),[v,E]=p(null),S=function(e,n,o,r=document.body){const[l]=t(),i=w(document.createElement("div")),s=g((()=>{i.current.style.top=i.current.style.bottom;const t=l.getRootElement(),n=i.current,s=n.firstChild;if(null!==t&&null!==e){const{left:l,top:u,width:c,height:a}=e.getRect(),d=i.current.offsetHeight;if(n.style.top=`${u+window.pageYOffset+d+3}px`,n.style.left=`${l+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==s){s.style.top=`${u}`;const e=s.getBoundingClientRect(),o=e.height,r=e.width,i=t.getBoundingClientRect();l+r>i.right&&(n.style.left=`${i.right-r+window.pageXOffset}px`),(u+o>window.innerHeight||u+o>i.bottom)&&u-i.top>o&&(n.style.top=u-o+window.pageYOffset-a+"px")}n.isConnected||(null!=o&&(n.className=o),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("id","typeahead-menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute",r.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[l,e,o,r]);f((()=>{const t=l.getRootElement();if(null!==e)return s(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[l,s,e]);const u=g((t=>{null!==e&&(t||n(null))}),[e,n]);return x(e,i.current,s,u),i}(v,E,h,C),O=g((()=>{E(null),null!=l&&null!==v&&l()}),[l,v]),I=g((t=>{E(t),null!=r&&null===v&&r(t)}),[r,v]);return f((()=>{const t=b.registerUpdateListener((()=>{b.getEditorState().read((()=>{const t=b._window||window,e=t.document.createRange(),o=u(),r=function(t){let e=null;return t.getEditorState().read((()=>{const t=u();c(t)&&(e=function(t){const e=t.anchor;if("text"!==e.type)return null;const n=e.getNode();if(!n.isSimpleText())return null;const o=e.offset;return n.getTextContent().slice(0,o)}(t))})),e}(b);if(!c(o)||!o.isCollapsed()||null===r||null===e)return void O();const l=m(r,b);if(n(l?l.matchingString:null),null!==l&&!function(t,e){return 0===e&&t.getEditorState().read((()=>{const t=u();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return a(e)&&e.isTextEntity()}return!1}))}(b,l.leadOffset)){const n=function(t,e,n){const o=n.getSelection();if(null===o||!o.isCollapsed)return!1;const r=o.anchorNode,l=t,i=o.anchorOffset;if(null==r||null==i)return!1;try{e.setStart(r,l),e.setEnd(r,i)}catch(t){return!1}return!0}(l.leadOffset,e,t);if(null!==n)return i=()=>I({getRect:()=>e.getBoundingClientRect(),match:l}),void(d.startTransition?d.startTransition(i):i())}var i;O()}))}));return()=>{t()}}),[b,m,n,v,O,I]),null===v||null===b?null:d.createElement(R,{close:O,resolution:v,editor:b,anchorElementRef:S,options:e,menuRenderFn:i,shouldSplitNodeWithQuery:!0,onSelectOption:o,commandPriority:y})}export{N as LexicalTypeaheadMenuPlugin,b as MenuOption,O as PUNCTUATION,T as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,I as getScrollParent,A as useBasicTypeaheadTriggerMatch,x as useDynamicPositioning};
8
+
9
+ import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,KEY_ARROW_DOWN_COMMAND as n,KEY_ARROW_UP_COMMAND as o,KEY_ESCAPE_COMMAND as r,KEY_TAB_COMMAND as l,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as s,$getSelection as u,$isRangeSelection as c,$isTextNode as a}from"lexical";import*as d from"react";import{useLayoutEffect as m,useEffect as f,useState as p,useCallback as g,useMemo as h,useRef as w}from"react";import{mergeRegister as y}from"@lexical/utils";import{jsx as C}from"react/jsx-runtime";const b="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?m:f;class v{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const x=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function E(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function S(e,n,o,r){const[l]=t();f((()=>{if(null!=n&&null!=e){const t=l.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,s=E(n,e);const u=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=E(n,e);t!==s&&(s=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",u,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",u,!0)}}}),[n,l,r,o,e])}const R=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:w,onSelectOption:C,shouldSplitNodeWithQuery:v=!1,commandPriority:E=s}){const[S,O]=p(null),I=d.match&&d.match.matchingString;f((()=>{O(0)}),[I]);const T=g((n=>{e.update((()=>{const e=null!=d.match&&v?function(t){const e=u();if(!c(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const r=n.offset,l=o.getTextContent().slice(0,r),i=t.replaceableString.length,s=r-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.substr(-n)===e.substr(0,n)&&(o=n);return o}(l,t.matchingString,i);if(s<0)return null;let a;return 0===s?[a]=o.splitText(r):[,a]=o.splitText(s,r),a}(d.match):null;C(n,e,t,d.match?d.match.matchingString:"")}))}),[e,v,d.match,C,t]),A=g((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))}),[e]);f((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),b((()=>{null===m?O(null):null===S&&A(0)}),[m,S,A]),f((()=>y(e.registerCommand(R,(({option:t})=>!(!t.ref||null==t.ref.current)&&(x(t.ref.current),!0)),E))),[e,A,E]),f((()=>y(e.registerCommand(n,(t=>{const n=t;if(null!==m&&m.length&&null!==S){const t=S!==m.length-1?S+1:0;A(t);const o=m[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(R,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),E),e.registerCommand(o,(t=>{const e=t;if(null!==m&&m.length&&null!==S){const t=0!==S?S-1:m.length-1;A(t);const n=m[t];null!=n.ref&&n.ref.current&&x(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),E),e.registerCommand(r,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),E),e.registerCommand(l,(t=>{const e=t;return null!==m&&null!==S&&null!=m[S]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[S]),!0)}),E),e.registerCommand(i,(t=>null!==m&&null!==S&&null!=m[S]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[S]),!0)),E))),[T,t,e,m,S,A,E]);return w(a,h((()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:S,setHighlightedIndex:O})),[T,S,m]),d.match?d.match.matchingString:"")}const I="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function T(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=e?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}const A=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function N(t,{minLength:e=1,maxLength:n=75}){return g((o=>{const r=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+I+"\\s]")+"){0,"+n+"}))$").exec(o);if(null!==r){const t=r[1],n=r[3];if(n.length>=e)return{leadOffset:r.index+t.length,matchingString:n,replaceableString:r[2]}}return null}),[n,e,t])}function P({options:e,onQueryChange:n,onSelectOption:o,onOpen:r,onClose:l,menuRenderFn:i,triggerFn:m,anchorClassName:h,commandPriority:y=s,parent:b}){const[v]=t(),[x,E]=p(null),R=function(e,n,o,r=document.body){const[l]=t(),i=w(document.createElement("div")),s=g((()=>{i.current.style.top=i.current.style.bottom;const t=l.getRootElement(),n=i.current,s=n.firstChild;if(null!==t&&null!==e){const{left:l,top:u,width:c,height:a}=e.getRect(),d=i.current.offsetHeight;if(n.style.top=`${u+window.pageYOffset+d+3}px`,n.style.left=`${l+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==s){s.style.top=`${u}`;const e=s.getBoundingClientRect(),o=e.height,r=e.width,i=t.getBoundingClientRect();l+r>i.right&&(n.style.left=`${i.right-r+window.pageXOffset}px`),(u+o>window.innerHeight||u+o>i.bottom)&&u-i.top>o+a&&(n.style.top=u-o+window.pageYOffset-a+"px")}n.isConnected||(null!=o&&(n.className=o),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("id","typeahead-menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute",r.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[l,e,o,r]);f((()=>{const t=l.getRootElement();if(null!==e)return s(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[l,s,e]);const u=g((t=>{null!==e&&(t||n(null))}),[e,n]);return S(e,i.current,s,u),i}(x,E,h,b),I=g((()=>{E(null),null!=l&&null!==x&&l()}),[l,x]),T=g((t=>{E(t),null!=r&&null===x&&r(t)}),[r,x]);return f((()=>{const t=v.registerUpdateListener((()=>{v.getEditorState().read((()=>{const t=v._window||window,e=t.document.createRange(),o=u(),r=function(t){let e=null;return t.getEditorState().read((()=>{const t=u();c(t)&&(e=function(t){const e=t.anchor;if("text"!==e.type)return null;const n=e.getNode();if(!n.isSimpleText())return null;const o=e.offset;return n.getTextContent().slice(0,o)}(t))})),e}(v);if(!c(o)||!o.isCollapsed()||null===r||null===e)return void I();const l=m(r,v);if(n(l?l.matchingString:null),null!==l&&!function(t,e){return 0===e&&t.getEditorState().read((()=>{const t=u();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return a(e)&&e.isTextEntity()}return!1}))}(v,l.leadOffset)){const n=function(t,e,n){const o=n.getSelection();if(null===o||!o.isCollapsed)return!1;const r=o.anchorNode,l=t,i=o.anchorOffset;if(null==r||null==i)return!1;try{e.setStart(r,l),e.setEnd(r,i)}catch(t){return!1}return!0}(l.leadOffset,e,t);if(null!==n)return i=()=>T({getRect:()=>e.getBoundingClientRect(),match:l}),void(d.startTransition?d.startTransition(i):i())}var i;I()}))}));return()=>{t()}}),[v,m,n,x,I,T]),null===x||null===v?null:C(O,{close:I,resolution:x,editor:v,anchorElementRef:R,options:e,menuRenderFn:i,shouldSplitNodeWithQuery:!0,onSelectOption:o,commandPriority:y})}export{P as LexicalTypeaheadMenuPlugin,v as MenuOption,I as PUNCTUATION,A as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,T as getScrollParent,N as useBasicTypeaheadTriggerMatch,S as useDynamicPositioning};
package/package.json CHANGED
@@ -8,27 +8,27 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.14.5",
11
+ "version": "0.16.0",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.14.5",
14
- "@lexical/code": "0.14.5",
15
- "@lexical/devtools-core": "0.14.5",
16
- "@lexical/dragon": "0.14.5",
17
- "@lexical/hashtag": "0.14.5",
18
- "@lexical/history": "0.14.5",
19
- "@lexical/link": "0.14.5",
20
- "@lexical/list": "0.14.5",
21
- "@lexical/mark": "0.14.5",
22
- "@lexical/markdown": "0.14.5",
23
- "@lexical/overflow": "0.14.5",
24
- "@lexical/plain-text": "0.14.5",
25
- "@lexical/rich-text": "0.14.5",
26
- "@lexical/selection": "0.14.5",
27
- "@lexical/table": "0.14.5",
28
- "@lexical/text": "0.14.5",
29
- "@lexical/utils": "0.14.5",
30
- "@lexical/yjs": "0.14.5",
31
- "lexical": "0.14.5",
13
+ "@lexical/clipboard": "0.16.0",
14
+ "@lexical/code": "0.16.0",
15
+ "@lexical/devtools-core": "0.16.0",
16
+ "@lexical/dragon": "0.16.0",
17
+ "@lexical/hashtag": "0.16.0",
18
+ "@lexical/history": "0.16.0",
19
+ "@lexical/link": "0.16.0",
20
+ "@lexical/list": "0.16.0",
21
+ "@lexical/mark": "0.16.0",
22
+ "@lexical/markdown": "0.16.0",
23
+ "@lexical/overflow": "0.16.0",
24
+ "@lexical/plain-text": "0.16.0",
25
+ "@lexical/rich-text": "0.16.0",
26
+ "@lexical/selection": "0.16.0",
27
+ "@lexical/table": "0.16.0",
28
+ "@lexical/text": "0.16.0",
29
+ "@lexical/utils": "0.16.0",
30
+ "@lexical/yjs": "0.16.0",
31
+ "lexical": "0.16.0",
32
32
  "react-error-boundary": "^3.1.4"
33
33
  },
34
34
  "peerDependencies": {
@@ -1001,6 +1001,36 @@
1001
1001
  "default": "./LexicalTableOfContents.js"
1002
1002
  }
1003
1003
  },
1004
+ "./LexicalTableOfContentsPlugin": {
1005
+ "import": {
1006
+ "types": "./LexicalTableOfContentsPlugin.d.ts",
1007
+ "development": "./LexicalTableOfContentsPlugin.dev.mjs",
1008
+ "production": "./LexicalTableOfContentsPlugin.prod.mjs",
1009
+ "node": "./LexicalTableOfContentsPlugin.node.mjs",
1010
+ "default": "./LexicalTableOfContentsPlugin.mjs"
1011
+ },
1012
+ "require": {
1013
+ "types": "./LexicalTableOfContentsPlugin.d.ts",
1014
+ "development": "./LexicalTableOfContentsPlugin.dev.js",
1015
+ "production": "./LexicalTableOfContentsPlugin.prod.js",
1016
+ "default": "./LexicalTableOfContentsPlugin.js"
1017
+ }
1018
+ },
1019
+ "./LexicalTableOfContentsPlugin.js": {
1020
+ "import": {
1021
+ "types": "./LexicalTableOfContentsPlugin.d.ts",
1022
+ "development": "./LexicalTableOfContentsPlugin.dev.mjs",
1023
+ "production": "./LexicalTableOfContentsPlugin.prod.mjs",
1024
+ "node": "./LexicalTableOfContentsPlugin.node.mjs",
1025
+ "default": "./LexicalTableOfContentsPlugin.mjs"
1026
+ },
1027
+ "require": {
1028
+ "types": "./LexicalTableOfContentsPlugin.d.ts",
1029
+ "development": "./LexicalTableOfContentsPlugin.dev.js",
1030
+ "production": "./LexicalTableOfContentsPlugin.prod.js",
1031
+ "default": "./LexicalTableOfContentsPlugin.js"
1032
+ }
1033
+ },
1004
1034
  "./LexicalTablePlugin": {
1005
1035
  "import": {
1006
1036
  "types": "./LexicalTablePlugin.d.ts",
@@ -12,5 +12,5 @@ type OptionalProps = {
12
12
  strlen?: (input: string) => number;
13
13
  };
14
14
  export declare function useCharacterLimit(editor: LexicalEditor, maxCharacters: number, optional?: OptionalProps): void;
15
- export declare function mergePrevious(overflowNode: OverflowNode): void;
15
+ export declare function $mergePrevious(overflowNode: OverflowNode): void;
16
16
  export {};
@@ -5,4 +5,14 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export default function useLexicalEditable(): boolean;
8
+ /**
9
+ * Get the current value for {@link LexicalEditor.isEditable}
10
+ * using {@link useLexicalSubscription}.
11
+ * You should prefer this over manually observing the value with
12
+ * {@link LexicalEditor.registerEditableListener},
13
+ * which is a bit tricky to do correctly, particularly when using
14
+ * React StrictMode (the default for development) or concurrency.
15
+ */
16
+ export declare function useLexicalEditable(): boolean;
17
+ /** @deprecated use the named export {@link useLexicalEditable} */
18
+ export default useLexicalEditable;
@@ -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,12 @@ 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
+
32
+
33
+ // This workaround is no longer necessary in React 19,
34
+ // but we currently support React >=17.x
35
+ // https://github.com/facebook/react/pull/26395
29
36
  const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
30
- var useLayoutEffect = useLayoutEffectImpl;
31
37
 
32
38
  /**
33
39
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -36,15 +42,17 @@ var useLayoutEffect = useLayoutEffectImpl;
36
42
  * LICENSE file in the root directory of this source tree.
37
43
  *
38
44
  */
45
+
39
46
  /**
40
47
  * Shortcut to Lexical subscriptions when values are used for render.
48
+ * @param subscription - The function to create the {@link LexicalSubscription}. This function's identity must be stable (e.g. defined at module scope or with useCallback).
41
49
  */
42
50
  function useLexicalSubscription(subscription) {
43
51
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
44
52
  const initializedSubscription = react.useMemo(() => subscription(editor), [editor, subscription]);
45
53
  const valueRef = react.useRef(initializedSubscription.initialValueFn());
46
54
  const [value, setValue] = react.useState(valueRef.current);
47
- useLayoutEffect(() => {
55
+ useLayoutEffectImpl(() => {
48
56
  const {
49
57
  initialValueFn,
50
58
  subscribe
@@ -69,6 +77,7 @@ function useLexicalSubscription(subscription) {
69
77
  * LICENSE file in the root directory of this source tree.
70
78
  *
71
79
  */
80
+
72
81
  function subscription(editor) {
73
82
  return {
74
83
  initialValueFn: () => editor.isEditable(),
@@ -77,8 +86,18 @@ function subscription(editor) {
77
86
  }
78
87
  };
79
88
  }
89
+
90
+ /**
91
+ * Get the current value for {@link LexicalEditor.isEditable}
92
+ * using {@link useLexicalSubscription}.
93
+ * You should prefer this over manually observing the value with
94
+ * {@link LexicalEditor.registerEditableListener},
95
+ * which is a bit tricky to do correctly, particularly when using
96
+ * React StrictMode (the default for development) or concurrency.
97
+ */
80
98
  function useLexicalEditable() {
81
99
  return useLexicalSubscription(subscription);
82
100
  }
83
101
 
84
- module.exports = useLexicalEditable;
102
+ exports.default = useLexicalEditable;
103
+ exports.useLexicalEditable = useLexicalEditable;
@@ -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, useMemo, useRef, useState } from 'react';
10
+ import { useLayoutEffect, useEffect, useMemo, useRef, useState } from 'react';
9
11
 
10
12
  /**
11
13
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -24,8 +26,12 @@ 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
+
31
+ // This workaround is no longer necessary in React 19,
32
+ // but we currently support React >=17.x
33
+ // https://github.com/facebook/react/pull/26395
34
+ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
29
35
 
30
36
  /**
31
37
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -34,15 +40,17 @@ var useLayoutEffect = useLayoutEffectImpl;
34
40
  * LICENSE file in the root directory of this source tree.
35
41
  *
36
42
  */
43
+
37
44
  /**
38
45
  * Shortcut to Lexical subscriptions when values are used for render.
46
+ * @param subscription - The function to create the {@link LexicalSubscription}. This function's identity must be stable (e.g. defined at module scope or with useCallback).
39
47
  */
40
48
  function useLexicalSubscription(subscription) {
41
49
  const [editor] = useLexicalComposerContext();
42
50
  const initializedSubscription = useMemo(() => subscription(editor), [editor, subscription]);
43
51
  const valueRef = useRef(initializedSubscription.initialValueFn());
44
52
  const [value, setValue] = useState(valueRef.current);
45
- useLayoutEffect(() => {
53
+ useLayoutEffectImpl(() => {
46
54
  const {
47
55
  initialValueFn,
48
56
  subscribe
@@ -67,6 +75,7 @@ function useLexicalSubscription(subscription) {
67
75
  * LICENSE file in the root directory of this source tree.
68
76
  *
69
77
  */
78
+
70
79
  function subscription(editor) {
71
80
  return {
72
81
  initialValueFn: () => editor.isEditable(),
@@ -75,8 +84,17 @@ function subscription(editor) {
75
84
  }
76
85
  };
77
86
  }
87
+
88
+ /**
89
+ * Get the current value for {@link LexicalEditor.isEditable}
90
+ * using {@link useLexicalSubscription}.
91
+ * You should prefer this over manually observing the value with
92
+ * {@link LexicalEditor.registerEditableListener},
93
+ * which is a bit tricky to do correctly, particularly when using
94
+ * React StrictMode (the default for development) or concurrency.
95
+ */
78
96
  function useLexicalEditable() {
79
97
  return useLexicalSubscription(subscription);
80
98
  }
81
99
 
82
- export { useLexicalEditable as default };
100
+ export { useLexicalEditable as default, useLexicalEditable };
@@ -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 useLexicalEditable = process.env.NODE_ENV === 'development' ? require('./useLexicalEditable.dev.js') : require('./useLexicalEditable.prod.js');
9
11
  module.exports = useLexicalEditable;
@@ -9,4 +9,7 @@
9
9
 
10
10
  import type {LexicalEditor} from 'lexical';
11
11
 
12
- declare export default function useLexicalEditable(): boolean;
12
+ declare export function useLexicalEditable(): boolean;
13
+
14
+ /** @deprecated use the named export {@link useLexicalEditable} */
15
+ declare export default typeof useLexicalEditable;
@@ -3,8 +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 * as modDev from './useLexicalEditable.dev.mjs';
8
10
  import * as modProd from './useLexicalEditable.prod.mjs';
9
11
  const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
- export default mod.default;
12
+ export default mod.default;
13
+ export const useLexicalEditable = mod.useLexicalEditable;
@@ -3,6 +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('./useLexicalEditable.dev.mjs') : import('./useLexicalEditable.prod.mjs'));
8
- export default mod.default;
10
+ export default mod.default;
11
+ export const useLexicalEditable = mod.useLexicalEditable;
@@ -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 b=require("@lexical/react/LexicalComposerContext"),k=require("react"),l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
8
- function m(a){let [c]=b.useLexicalComposerContext(),e=k.useMemo(()=>a(c),[c,a]),d=k.useRef(e.initialValueFn()),[n,g]=k.useState(d.current);l(()=>{let {initialValueFn:p,subscribe:q}=e,f=p();d.current!==f&&(d.current=f,g(f));return q(h=>{d.current=h;g(h)})},[e,a]);return n}function r(a){return{initialValueFn:()=>a.isEditable(),subscribe:c=>a.registerEditableListener(c)}}module.exports=function(){return m(r)}
8
+
9
+ 'use strict';var b=require("@lexical/react/LexicalComposerContext"),k=require("react");let l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
10
+ function m(a){let [c]=b.useLexicalComposerContext(),e=k.useMemo(()=>a(c),[c,a]),d=k.useRef(e.initialValueFn()),[p,g]=k.useState(d.current);l(()=>{let {initialValueFn:q,subscribe:r}=e,f=q();d.current!==f&&(d.current=f,g(f));return r(h=>{d.current=h;g(h)})},[e,a]);return p}function n(a){return{initialValueFn:()=>a.isEditable(),subscribe:c=>a.registerEditableListener(c)}}function t(){return m(n)}exports.default=t;exports.useLexicalEditable=t
@@ -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 n,useMemo as r,useRef as i,useState as o}from"react";var u="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:n;function c(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function a(){return function(t){const[n]=e(),c=r((()=>t(n)),[n,t]),a=i(c.initialValueFn()),[l,s]=o(a.current);return u((()=>{const{initialValueFn:e,subscribe:t}=c,n=e();return a.current!==n&&(a.current=n,s(n)),t((e=>{a.current=e,s(e)}))}),[c,t]),l}(c)}export{a as default};
8
+
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as n,useMemo as r,useRef as i,useState as o}from"react";const u="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:n;function c(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function a(){return function(t){const[n]=e(),c=r((()=>t(n)),[n,t]),a=i(c.initialValueFn()),[l,d]=o(a.current);return u((()=>{const{initialValueFn:e,subscribe:t}=c,n=e();return a.current!==n&&(a.current=n,d(n)),t((e=>{a.current=e,d(e)}))}),[c,t]),l}(c)}export{a as default,a as useLexicalEditable};
@@ -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 text = require('@lexical/text');
@@ -26,8 +28,12 @@ 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
+
32
+
33
+ // This workaround is no longer necessary in React 19,
34
+ // but we currently support React >=17.x
35
+ // https://github.com/facebook/react/pull/26395
29
36
  const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
30
- var useLayoutEffect = useLayoutEffectImpl;
31
37
 
32
38
  /**
33
39
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -36,9 +42,10 @@ var useLayoutEffect = useLayoutEffectImpl;
36
42
  * LICENSE file in the root directory of this source tree.
37
43
  *
38
44
  */
45
+
39
46
  function useLexicalIsTextContentEmpty(editor, trim) {
40
47
  const [isEmpty, setIsEmpty] = react.useState(editor.getEditorState().read(text.$isRootTextContentEmptyCurry(editor.isComposing(), trim)));
41
- useLayoutEffect(() => {
48
+ useLayoutEffectImpl(() => {
42
49
  return editor.registerUpdateListener(({
43
50
  editorState
44
51
  }) => {