@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,12 +3,27 @@
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');
10
12
  var React = require('react');
11
13
 
14
+ function _interopNamespaceDefault(e) {
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ for (var k in e) {
18
+ n[k] = e[k];
19
+ }
20
+ }
21
+ n.default = e;
22
+ return n;
23
+ }
24
+
25
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
26
+
12
27
  function _extends() {
13
28
  _extends = Object.assign ? Object.assign.bind() : function (target) {
14
29
  for (var i = 1; i < arguments.length; i++) {
@@ -41,8 +56,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
41
56
  * LICENSE file in the root directory of this source tree.
42
57
  *
43
58
  */
59
+
44
60
  const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
45
- var useLayoutEffect = useLayoutEffectImpl;
46
61
 
47
62
  function ContentEditable({
48
63
  ariaActiveDescendant,
@@ -74,13 +89,13 @@ function ContentEditable({
74
89
  editor.setRootElement(rootElement);
75
90
  }
76
91
  }, [editor]);
77
- useLayoutEffect(() => {
92
+ useLayoutEffectImpl(() => {
78
93
  setEditable(editor.isEditable());
79
94
  return editor.registerEditableListener(currentIsEditable => {
80
95
  setEditable(currentIsEditable);
81
96
  });
82
97
  }, [editor]);
83
- return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
98
+ return /*#__PURE__*/React__namespace.createElement("div", _extends({}, rest, {
84
99
  "aria-activedescendant": !isEditable ? undefined : ariaActiveDescendant,
85
100
  "aria-autocomplete": !isEditable ? 'none' : ariaAutoComplete,
86
101
  "aria-controls": !isEditable ? undefined : ariaControls,
@@ -3,10 +3,12 @@
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 * as React from 'react';
9
- import { useLayoutEffect as useLayoutEffect$1, useEffect, useState, useCallback } from 'react';
11
+ import { useLayoutEffect, useEffect, useState, useCallback } from 'react';
10
12
 
11
13
  function _extends() {
12
14
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -40,8 +42,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
40
42
  * LICENSE file in the root directory of this source tree.
41
43
  *
42
44
  */
43
- const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect$1 : useEffect;
44
- var useLayoutEffect = useLayoutEffectImpl;
45
+
46
+ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
45
47
 
46
48
  function ContentEditable({
47
49
  ariaActiveDescendant,
@@ -73,7 +75,7 @@ function ContentEditable({
73
75
  editor.setRootElement(rootElement);
74
76
  }
75
77
  }, [editor]);
76
- useLayoutEffect(() => {
78
+ useLayoutEffectImpl(() => {
77
79
  setEditable(editor.isEditable());
78
80
  return editor.registerEditableListener(currentIsEditable => {
79
81
  setEditable(currentIsEditable);
@@ -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 LexicalContentEditable = process.env.NODE_ENV === 'development' ? require('./LexicalContentEditable.dev.js') : require('./LexicalContentEditable.prod.js');
9
11
  module.exports = LexicalContentEditable;
@@ -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 './LexicalContentEditable.dev.mjs';
8
10
  import * as modProd from './LexicalContentEditable.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('./LexicalContentEditable.dev.mjs') : import('./LexicalContentEditable.prod.mjs'));
8
10
  export const ContentEditable = mod.ContentEditable;
@@ -3,7 +3,10 @@
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/LexicalComposerContext"),k=require("react");function n(){n=Object.assign?Object.assign.bind():function(h){for(var e=1;e<arguments.length;e++){var f=arguments[e],b;for(b in f)Object.prototype.hasOwnProperty.call(f,b)&&(h[b]=f[b])}return h};return n.apply(this,arguments)}var p="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
8
- exports.ContentEditable=function({ariaActiveDescendant:h,ariaAutoComplete:e,ariaControls:f,ariaDescribedBy:b,ariaExpanded:q,ariaLabel:r,ariaLabelledBy:t,ariaMultiline:u,ariaOwns:v,ariaRequired:w,autoCapitalize:x,className:y,id:z,role:l="textbox",spellCheck:A=!0,style:B,tabIndex:C,"data-testid":D,...E}){let [g]=d.useLexicalComposerContext(),[a,m]=k.useState(!1),F=k.useCallback(c=>{c&&c.ownerDocument&&c.ownerDocument.defaultView&&g.setRootElement(c)},[g]);p(()=>{m(g.isEditable());return g.registerEditableListener(c=>
9
- {m(c)})},[g]);return k.createElement("div",n({},E,{"aria-activedescendant":a?h:void 0,"aria-autocomplete":a?e:"none","aria-controls":a?f:void 0,"aria-describedby":b,"aria-expanded":a?"combobox"===l?!!q:void 0:void 0,"aria-label":r,"aria-labelledby":t,"aria-multiline":u,"aria-owns":a?v:void 0,"aria-readonly":a?void 0:!0,"aria-required":w,autoCapitalize:x,className:y,contentEditable:a,"data-testid":D,id:z,ref:F,role:l,spellCheck:A,style:B,tabIndex:C}))}
8
+
9
+ 'use strict';var a=require("@lexical/react/LexicalComposerContext"),k=require("react"),l=Object.create(null);if(k)for(var m in k)l[m]=k[m];l.default=k;function q(){q=Object.assign?Object.assign.bind():function(h){for(var e=1;e<arguments.length;e++){var f=arguments[e],c;for(c in f)Object.prototype.hasOwnProperty.call(f,c)&&(h[c]=f[c])}return h};return q.apply(this,arguments)}
10
+ let r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
11
+ exports.ContentEditable=function({ariaActiveDescendant:h,ariaAutoComplete:e,ariaControls:f,ariaDescribedBy:c,ariaExpanded:t,ariaLabel:u,ariaLabelledBy:v,ariaMultiline:w,ariaOwns:x,ariaRequired:y,autoCapitalize:z,className:A,id:B,role:n="textbox",spellCheck:C=!0,style:D,tabIndex:E,"data-testid":F,...G}){let [g]=a.useLexicalComposerContext(),[b,p]=k.useState(!1),H=k.useCallback(d=>{d&&d.ownerDocument&&d.ownerDocument.defaultView&&g.setRootElement(d)},[g]);r(()=>{p(g.isEditable());return g.registerEditableListener(d=>
12
+ {p(d)})},[g]);return l.createElement("div",q({},G,{"aria-activedescendant":b?h:void 0,"aria-autocomplete":b?e:"none","aria-controls":b?f:void 0,"aria-describedby":c,"aria-expanded":b?"combobox"===n?!!t:void 0:void 0,"aria-label":u,"aria-labelledby":v,"aria-multiline":w,"aria-owns":b?x:void 0,"aria-readonly":b?void 0:!0,"aria-required":y,autoCapitalize:z,className:A,contentEditable:b,"data-testid":F,id:B,ref:H,role:n,spellCheck:C,style:D,tabIndex:E}))}
@@ -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*as a from"react";import{useLayoutEffect as t,useEffect as i,useState as r,useCallback as o}from"react";function n(){return n=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},n.apply(this,arguments)}var d="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:i;function l({ariaActiveDescendant:t,ariaAutoComplete:i,ariaControls:l,ariaDescribedBy:c,ariaExpanded:s,ariaLabel:u,ariaLabelledBy:b,ariaMultiline:m,ariaOwns:p,ariaRequired:f,autoCapitalize:v,className:w,id:y,role:x="textbox",spellCheck:C=!0,style:E,tabIndex:h,"data-testid":L,...O}){const[g]=e(),[D,j]=r(!1),k=o((e=>{e&&e.ownerDocument&&e.ownerDocument.defaultView&&g.setRootElement(e)}),[g]);return d((()=>(j(g.isEditable()),g.registerEditableListener((e=>{j(e)})))),[g]),a.createElement("div",n({},O,{"aria-activedescendant":D?t:void 0,"aria-autocomplete":D?i:"none","aria-controls":D?l:void 0,"aria-describedby":c,"aria-expanded":D&&"combobox"===x?!!s:void 0,"aria-label":u,"aria-labelledby":b,"aria-multiline":m,"aria-owns":D?p:void 0,"aria-readonly":!D||void 0,"aria-required":f,autoCapitalize:v,className:w,contentEditable:D,"data-testid":L,id:y,ref:k,role:x,spellCheck:C,style:E,tabIndex:h}))}export{l as ContentEditable};
8
+
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import*as a from"react";import{useLayoutEffect as t,useEffect as i,useState as r,useCallback as o}from"react";function n(){return n=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},n.apply(this,arguments)}const d="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:i;function l({ariaActiveDescendant:t,ariaAutoComplete:i,ariaControls:l,ariaDescribedBy:c,ariaExpanded:s,ariaLabel:b,ariaLabelledBy:m,ariaMultiline:u,ariaOwns:p,ariaRequired:v,autoCapitalize:f,className:w,id:x,role:y="textbox",spellCheck:C=!0,style:E,tabIndex:h,"data-testid":O,...g}){const[D]=e(),[L,j]=r(!1),k=o((e=>{e&&e.ownerDocument&&e.ownerDocument.defaultView&&D.setRootElement(e)}),[D]);return d((()=>(j(D.isEditable()),D.registerEditableListener((e=>{j(e)})))),[D]),a.createElement("div",n({},g,{"aria-activedescendant":L?t:void 0,"aria-autocomplete":L?i:"none","aria-controls":L?l:void 0,"aria-describedby":c,"aria-expanded":L&&"combobox"===y?!!s:void 0,"aria-label":b,"aria-labelledby":m,"aria-multiline":u,"aria-owns":L?p:void 0,"aria-readonly":!L||void 0,"aria-required":v,autoCapitalize:f,className:w,contentEditable:L,"data-testid":O,id:x,ref:k,role:y,spellCheck:C,style:E,tabIndex:h}))}export{l as ContentEditable};
@@ -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 utils = require('@lexical/utils');
11
13
  var lexical = require('lexical');
12
14
  var React = require('react');
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,6 +404,7 @@ 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
  const PRE_PORTAL_DIV_SIZE = 1;
392
409
  function LexicalContextMenuPlugin({
393
410
  options,
@@ -402,7 +419,7 @@ function LexicalContextMenuPlugin({
402
419
  }) {
403
420
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
404
421
  const [resolution, setResolution] = React.useState(null);
405
- const menuRef = React.useRef(null);
422
+ const menuRef = React__namespace.useRef(null);
406
423
  const anchorElementRef = useMenuAnchorRef(resolution, setResolution, anchorClassName, parent);
407
424
  const closeNodeMenu = React.useCallback(() => {
408
425
  setResolution(null);
@@ -442,7 +459,7 @@ function LexicalContextMenuPlugin({
442
459
  document.addEventListener('click', handleClick);
443
460
  return () => document.removeEventListener('click', handleClick);
444
461
  }, [editor, handleClick]);
445
- return resolution === null || editor === null ? null : /*#__PURE__*/React.createElement(LexicalMenu, {
462
+ return resolution === null || editor === null ? null : /*#__PURE__*/React__namespace.createElement(LexicalMenu, {
446
463
  close: closeNodeMenu,
447
464
  resolution: resolution,
448
465
  editor: editor,
@@ -3,12 +3,14 @@
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 { mergeRegister, calculateZoomLevel } from '@lexical/utils';
9
11
  import { createCommand, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection, $isRangeSelection } from 'lexical';
10
12
  import * as React from 'react';
11
- import { useLayoutEffect as useLayoutEffect$1, useEffect, useState, useCallback, useMemo, useRef } from 'react';
13
+ import { useLayoutEffect, useEffect, useState, useCallback, useMemo, useRef } from 'react';
12
14
 
13
15
  /**
14
16
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -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
  const PRE_PORTAL_DIV_SIZE = 1;
391
395
  function LexicalContextMenuPlugin({
392
396
  options,
@@ -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 LexicalContextMenuPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalContextMenuPlugin.dev.js') : require('./LexicalContextMenuPlugin.prod.js');
9
11
  module.exports = LexicalContextMenuPlugin;
@@ -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
+ * LexicalContextMenuPlugin
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 './LexicalContextMenuPlugin.dev.mjs';
8
10
  import * as modProd from './LexicalContextMenuPlugin.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('./LexicalContextMenuPlugin.dev.mjs') : import('./LexicalContextMenuPlugin.prod.mjs'));
8
10
  export const LexicalContextMenuPlugin = mod.LexicalContextMenuPlugin;
9
11
  export const MenuOption = mod.MenuOption;
@@ -3,20 +3,22 @@
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 h=require("@lexical/react/LexicalComposerContext"),w=require("@lexical/utils"),z=require("lexical"),A=require("react"),B="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?A.useLayoutEffect:A.useEffect;class C{constructor(c){this.key=c;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(c){this.ref={current:c}}}
8
- let D=c=>{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"});c.scrollIntoView({block:"nearest"})}};
9
- function E(c){var a=z.$getSelection();if(!z.$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 k=a.getTextContent().slice(0,d);var e=c.matchingString;c=c.replaceableString.length;for(let n=c;n<=e.length;n++)k.substr(-n)===e.substr(0,n)&&(c=n);c=d-c;if(0>c)return null;let p;0===c?[p]=a.splitText(d):[,p]=a.splitText(c,d);return p}
10
- function F(c,a){let d=getComputedStyle(c),k="absolute"===d.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===d.position)return document.body;for(;c=c.parentElement;)if(d=getComputedStyle(c),(!k||"static"!==d.position)&&a.test(d.overflow+d.overflowY+d.overflowX))return c;return document.body}function G(c,a){c=c.getBoundingClientRect();a=a.getBoundingClientRect();return c.top>a.top&&c.top<a.bottom}
11
- function H(c,a,d,k){let [e]=h.useLexicalComposerContext();A.useEffect(()=>{if(null!=a&&null!=c){let p=e.getRootElement(),n=null!=p?F(p,!1):document.body,x=!1,l=G(a,n),b=function(){x||(window.requestAnimationFrame(function(){d();x=!1}),x=!0);const q=G(a,n);q!==l&&(l=q,null!=k&&k(q))},g=new ResizeObserver(d);window.addEventListener("resize",d);document.addEventListener("scroll",b,{capture:!0,passive:!0});g.observe(a);return()=>{g.unobserve(a);window.removeEventListener("resize",d);document.removeEventListener("scroll",
12
- b,!0)}}},[a,e,k,d,c])}let I=z.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
13
- function J({close:c,editor:a,anchorElementRef:d,resolution:k,options:e,menuRenderFn:p,onSelectOption:n,shouldSplitNodeWithQuery:x=!1,commandPriority:l=z.COMMAND_PRIORITY_LOW}){let [b,g]=A.useState(null);A.useEffect(()=>{g(0)},[k.match&&k.match.matchingString]);let q=A.useCallback(f=>{a.update(()=>{const m=null!=k.match&&x?E(k.match):null;n(f,m,c,k.match?k.match.matchingString:"")})},[a,x,k.match,n,c]),t=A.useCallback(f=>{const m=a.getRootElement();null!==m&&(m.setAttribute("aria-activedescendant",
14
- "typeahead-item-"+f),g(f))},[a]);A.useEffect(()=>()=>{let f=a.getRootElement();null!==f&&f.removeAttribute("aria-activedescendant")},[a]);B(()=>{null===e?g(null):null===b&&t(0)},[e,b,t]);A.useEffect(()=>w.mergeRegister(a.registerCommand(I,({option:f})=>f.ref&&null!=f.ref.current?(D(f.ref.current),!0):!1,l)),[a,t,l]);A.useEffect(()=>w.mergeRegister(a.registerCommand(z.KEY_ARROW_DOWN_COMMAND,f=>{if(null!==e&&e.length&&null!==b){let m=b!==e.length-1?b+1:0;t(m);let u=e[m];null!=u.ref&&u.ref.current&&
15
- a.dispatchCommand(I,{index:m,option:u});f.preventDefault();f.stopImmediatePropagation()}return!0},l),a.registerCommand(z.KEY_ARROW_UP_COMMAND,f=>{if(null!==e&&e.length&&null!==b){var m=0!==b?b-1:e.length-1;t(m);m=e[m];null!=m.ref&&m.ref.current&&D(m.ref.current);f.preventDefault();f.stopImmediatePropagation()}return!0},l),a.registerCommand(z.KEY_ESCAPE_COMMAND,f=>{f.preventDefault();f.stopImmediatePropagation();c();return!0},l),a.registerCommand(z.KEY_TAB_COMMAND,f=>{if(null===e||null===b||null==
16
- e[b])return!1;f.preventDefault();f.stopImmediatePropagation();q(e[b]);return!0},l),a.registerCommand(z.KEY_ENTER_COMMAND,f=>{if(null===e||null===b||null==e[b])return!1;null!==f&&(f.preventDefault(),f.stopImmediatePropagation());q(e[b]);return!0},l)),[q,c,a,e,b,t,l]);let v=A.useMemo(()=>({options:e,selectOptionAndCleanUp:q,selectedIndex:b,setHighlightedIndex:g}),[q,b,e]);return p(d,v,k.match?k.match.matchingString:"")}
17
- function K(c,a,d,k=document.body){let [e]=h.useLexicalComposerContext(),p=A.useRef(document.createElement("div")),n=A.useCallback(()=>{p.current.style.top=p.current.style.bottom;const l=e.getRootElement(),b=p.current;var g=b.firstChild;if(null!==l&&null!==c){const {left:t,top:v,width:f,height:m}=c.getRect();b.style.top=`${v+window.pageYOffset+p.current.offsetHeight+3}px`;b.style.left=`${t+window.pageXOffset}px`;b.style.height=`${m}px`;b.style.width=`${f}px`;if(null!==g){g.style.top=`${v}`;var q=g.getBoundingClientRect();
18
- g=q.height;q=q.width;const u=l.getBoundingClientRect();t+q>u.right&&(b.style.left=`${u.right-q+window.pageXOffset}px`);(v+g>window.innerHeight||v+g>u.bottom)&&v-u.top>g&&(b.style.top=`${v-g+window.pageYOffset-m}px`)}b.isConnected||(null!=d&&(b.className=d),b.setAttribute("aria-label","Typeahead menu"),b.setAttribute("id","typeahead-menu"),b.setAttribute("role","listbox"),b.style.display="block",b.style.position="absolute",k.append(b));p.current=b;l.setAttribute("aria-controls","typeahead-menu")}},
19
- [e,c,d,k]);A.useEffect(()=>{let l=e.getRootElement();if(null!==c)return n(),()=>{null!==l&&l.removeAttribute("aria-controls");let b=p.current;null!==b&&b.isConnected&&b.remove()}},[e,n,c]);let x=A.useCallback(l=>{null!==c&&(l||a(null))},[c,a]);H(c,p.current,n,x);return p}
20
- exports.LexicalContextMenuPlugin=function({options:c,onWillOpen:a,onClose:d,onOpen:k,onSelectOption:e,menuRenderFn:p,anchorClassName:n,commandPriority:x=z.COMMAND_PRIORITY_LOW,parent:l}){let [b]=h.useLexicalComposerContext(),[g,q]=A.useState(null),t=A.useRef(null);n=K(g,q,n,l);let v=A.useCallback(()=>{q(null);null!=d&&null!==g&&d()},[d,g]),f=A.useCallback(r=>{q(r);null!=k&&null===g&&k(r)},[k,g]),m=A.useCallback(r=>{r.preventDefault();null!=a&&a(r);const y=w.calculateZoomLevel(r.target);f({getRect:()=>
21
- new DOMRect(r.clientX/y,r.clientY/y,1,1)})},[f,a]),u=A.useCallback(r=>{null===g||null==t.current||null==r.target||t.current.contains(r.target)||v()},[v,g]);A.useEffect(()=>{let r=b.getRootElement();if(r)return r.addEventListener("contextmenu",m),()=>r.removeEventListener("contextmenu",m)},[b,m]);A.useEffect(()=>{document.addEventListener("click",u);return()=>document.removeEventListener("click",u)},[b,u]);return null===g||null===b?null:A.createElement(J,{close:v,resolution:g,editor:b,anchorElementRef:n,
22
- options:c,menuRenderFn:(r,y)=>p(r,y,{setMenuRef:L=>{t.current=L}}),onSelectOption:e,commandPriority:x})};exports.MenuOption=C
8
+
9
+ 'use strict';var g=require("@lexical/react/LexicalComposerContext"),w=require("@lexical/utils"),y=require("lexical"),A=require("react"),B=Object.create(null);if(A)for(var C in A)B[C]=A[C];B.default=A;let D="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?A.useLayoutEffect:A.useEffect;class E{constructor(c){this.key=c;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(c){this.ref={current:c}}}
10
+ let F=c=>{const a=document.getElementById("typeahead-menu");if(a){var f=a.getBoundingClientRect();f.top+f.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>f.top&&a.scrollIntoView({block:"center"});c.scrollIntoView({block:"nearest"})}};
11
+ function G(c){var a=y.$getSelection();if(!y.$isRangeSelection(a)||!a.isCollapsed())return null;var f=a.anchor;if("text"!==f.type)return null;a=f.getNode();if(!a.isSimpleText())return null;f=f.offset;let k=a.getTextContent().slice(0,f);var d=c.matchingString;c=c.replaceableString.length;for(let n=c;n<=d.length;n++)k.substr(-n)===d.substr(0,n)&&(c=n);c=f-c;if(0>c)return null;let p;0===c?[p]=a.splitText(f):[,p]=a.splitText(c,f);return p}
12
+ function H(c){let a=getComputedStyle(c),f="absolute"===a.position,k=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;c=c.parentElement;)if(a=getComputedStyle(c),(!f||"static"!==a.position)&&k.test(a.overflow+a.overflowY+a.overflowX))return c;return document.body}function I(c,a){c=c.getBoundingClientRect();a=a.getBoundingClientRect();return c.top>a.top&&c.top<a.bottom}
13
+ function J(c,a,f,k){let [d]=g.useLexicalComposerContext();A.useEffect(()=>{if(null!=a&&null!=c){let p=d.getRootElement(),n=null!=p?H(p):document.body,x=!1,m=I(a,n),b=function(){x||(window.requestAnimationFrame(function(){f();x=!1}),x=!0);const q=I(a,n);q!==m&&(m=q,null!=k&&k(q))},h=new ResizeObserver(f);window.addEventListener("resize",f);document.addEventListener("scroll",b,{capture:!0,passive:!0});h.observe(a);return()=>{h.unobserve(a);window.removeEventListener("resize",f);document.removeEventListener("scroll",
14
+ b,!0)}}},[a,d,k,f,c])}let K=y.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
15
+ function L({close:c,editor:a,anchorElementRef:f,resolution:k,options:d,menuRenderFn:p,onSelectOption:n,shouldSplitNodeWithQuery:x=!1,commandPriority:m=y.COMMAND_PRIORITY_LOW}){let [b,h]=A.useState(null);A.useEffect(()=>{h(0)},[k.match&&k.match.matchingString]);let q=A.useCallback(e=>{a.update(()=>{const l=null!=k.match&&x?G(k.match):null;n(e,l,c,k.match?k.match.matchingString:"")})},[a,x,k.match,n,c]),t=A.useCallback(e=>{const l=a.getRootElement();null!==l&&(l.setAttribute("aria-activedescendant",
16
+ "typeahead-item-"+e),h(e))},[a]);A.useEffect(()=>()=>{let e=a.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[a]);D(()=>{null===d?h(null):null===b&&t(0)},[d,b,t]);A.useEffect(()=>w.mergeRegister(a.registerCommand(K,({option:e})=>e.ref&&null!=e.ref.current?(F(e.ref.current),!0):!1,m)),[a,t,m]);A.useEffect(()=>w.mergeRegister(a.registerCommand(y.KEY_ARROW_DOWN_COMMAND,e=>{if(null!==d&&d.length&&null!==b){let l=b!==d.length-1?b+1:0;t(l);let u=d[l];null!=u.ref&&u.ref.current&&
17
+ a.dispatchCommand(K,{index:l,option:u});e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(y.KEY_ARROW_UP_COMMAND,e=>{if(null!==d&&d.length&&null!==b){var l=0!==b?b-1:d.length-1;t(l);l=d[l];null!=l.ref&&l.ref.current&&F(l.ref.current);e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(y.KEY_ESCAPE_COMMAND,e=>{e.preventDefault();e.stopImmediatePropagation();c();return!0},m),a.registerCommand(y.KEY_TAB_COMMAND,e=>{if(null===d||null===b||null==
18
+ d[b])return!1;e.preventDefault();e.stopImmediatePropagation();q(d[b]);return!0},m),a.registerCommand(y.KEY_ENTER_COMMAND,e=>{if(null===d||null===b||null==d[b])return!1;null!==e&&(e.preventDefault(),e.stopImmediatePropagation());q(d[b]);return!0},m)),[q,c,a,d,b,t,m]);let v=A.useMemo(()=>({options:d,selectOptionAndCleanUp:q,selectedIndex:b,setHighlightedIndex:h}),[q,b,d]);return p(f,v,k.match?k.match.matchingString:"")}
19
+ function M(c,a,f,k=document.body){let [d]=g.useLexicalComposerContext(),p=A.useRef(document.createElement("div")),n=A.useCallback(()=>{p.current.style.top=p.current.style.bottom;const m=d.getRootElement(),b=p.current;var h=b.firstChild;if(null!==m&&null!==c){const {left:t,top:v,width:e,height:l}=c.getRect();b.style.top=`${v+window.pageYOffset+p.current.offsetHeight+3}px`;b.style.left=`${t+window.pageXOffset}px`;b.style.height=`${l}px`;b.style.width=`${e}px`;if(null!==h){h.style.top=`${v}`;var q=h.getBoundingClientRect();
20
+ h=q.height;q=q.width;const u=m.getBoundingClientRect();t+q>u.right&&(b.style.left=`${u.right-q+window.pageXOffset}px`);(v+h>window.innerHeight||v+h>u.bottom)&&v-u.top>h+l&&(b.style.top=`${v-h+window.pageYOffset-l}px`)}b.isConnected||(null!=f&&(b.className=f),b.setAttribute("aria-label","Typeahead menu"),b.setAttribute("id","typeahead-menu"),b.setAttribute("role","listbox"),b.style.display="block",b.style.position="absolute",k.append(b));p.current=b;m.setAttribute("aria-controls","typeahead-menu")}},
21
+ [d,c,f,k]);A.useEffect(()=>{let m=d.getRootElement();if(null!==c)return n(),()=>{null!==m&&m.removeAttribute("aria-controls");let b=p.current;null!==b&&b.isConnected&&b.remove()}},[d,n,c]);let x=A.useCallback(m=>{null!==c&&(m||a(null))},[c,a]);J(c,p.current,n,x);return p}
22
+ exports.LexicalContextMenuPlugin=function({options:c,onWillOpen:a,onClose:f,onOpen:k,onSelectOption:d,menuRenderFn:p,anchorClassName:n,commandPriority:x=y.COMMAND_PRIORITY_LOW,parent:m}){let [b]=g.useLexicalComposerContext(),[h,q]=A.useState(null),t=B.useRef(null);n=M(h,q,n,m);let v=A.useCallback(()=>{q(null);null!=f&&null!==h&&f()},[f,h]),e=A.useCallback(r=>{q(r);null!=k&&null===h&&k(r)},[k,h]),l=A.useCallback(r=>{r.preventDefault();null!=a&&a(r);const z=w.calculateZoomLevel(r.target);e({getRect:()=>
23
+ new DOMRect(r.clientX/z,r.clientY/z,1,1)})},[e,a]),u=A.useCallback(r=>{null===h||null==t.current||null==r.target||t.current.contains(r.target)||v()},[v,h]);A.useEffect(()=>{let r=b.getRootElement();if(r)return r.addEventListener("contextmenu",l),()=>r.removeEventListener("contextmenu",l)},[b,l]);A.useEffect(()=>{document.addEventListener("click",u);return()=>document.removeEventListener("click",u)},[b,u]);return null===h||null===b?null:B.createElement(L,{close:v,resolution:h,editor:b,anchorElementRef:n,
24
+ options:c,menuRenderFn:(r,z)=>p(r,z,{setMenuRef:N=>{t.current=N}}),onSelectOption:d,commandPriority:x})};exports.MenuOption=E
@@ -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{mergeRegister as e,calculateZoomLevel as n}from"@lexical/utils";import{createCommand as o,KEY_ARROW_DOWN_COMMAND as l,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as i,KEY_TAB_COMMAND as u,KEY_ENTER_COMMAND as c,COMMAND_PRIORITY_LOW as s,$getSelection as a,$isRangeSelection as m}from"lexical";import*as d from"react";import{useLayoutEffect as p,useEffect as f,useState as g,useCallback as h,useMemo as w,useRef as v}from"react";var y="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?p:f;class b{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const E=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function C(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function R(e,n,o,l){const[r]=t();f((()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,l=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,u=C(n,e);const c=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=C(n,e);t!==u&&(u=t,null!=l&&l(t))},s=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",c,{capture:!0,passive:!0}),s.observe(n),()=>{s.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",c,!0)}}}),[n,r,l,o,e])}const x=o("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:n,anchorElementRef:o,resolution:d,options:p,menuRenderFn:v,onSelectOption:b,shouldSplitNodeWithQuery:C=!1,commandPriority:R=s}){const[O,I]=g(null),S=d.match&&d.match.matchingString;f((()=>{I(0)}),[S]);const A=h((e=>{n.update((()=>{const n=null!=d.match&&C?function(t){const e=a();if(!m(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,u=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.substr(-n)===e.substr(0,n)&&(o=n);return o}(r,t.matchingString,i);if(u<0)return null;let c;return 0===u?[c]=o.splitText(l):[,c]=o.splitText(u,l),c}(d.match):null;b(e,n,t,d.match?d.match.matchingString:"")}))}),[n,C,d.match,b,t]),L=h((t=>{const e=n.getRootElement();null!==e&&(e.setAttribute("aria-activedescendant","typeahead-item-"+t),I(t))}),[n]);f((()=>()=>{const t=n.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[n]),y((()=>{null===p?I(null):null===O&&L(0)}),[p,O,L]),f((()=>e(n.registerCommand(x,(({option:t})=>!(!t.ref||null==t.ref.current)&&(E(t.ref.current),!0)),R))),[n,L,R]),f((()=>e(n.registerCommand(l,(t=>{const e=t;if(null!==p&&p.length&&null!==O){const t=O!==p.length-1?O+1:0;L(t);const o=p[t];null!=o.ref&&o.ref.current&&n.dispatchCommand(x,{index:t,option:o}),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(r,(t=>{const e=t;if(null!==p&&p.length&&null!==O){const t=0!==O?O-1:p.length-1;L(t);const n=p[t];null!=n.ref&&n.ref.current&&E(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(i,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),R),n.registerCommand(u,(t=>{const e=t;return null!==p&&null!==O&&null!=p[O]&&(e.preventDefault(),e.stopImmediatePropagation(),A(p[O]),!0)}),R),n.registerCommand(c,(t=>null!==p&&null!==O&&null!=p[O]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(p[O]),!0)),R))),[A,t,n,p,O,L,R]);return v(o,w((()=>({options:p,selectOptionAndCleanUp:A,selectedIndex:O,setHighlightedIndex:I})),[A,O,p]),d.match?d.match.matchingString:"")}function I({options:e,onWillOpen:o,onClose:l,onOpen:r,onSelectOption:i,menuRenderFn:u,anchorClassName:c,commandPriority:a=s,parent:m}){const[p]=t(),[w,y]=g(null),b=d.useRef(null),E=function(e,n,o,l=document.body){const[r]=t(),i=v(document.createElement("div")),u=h((()=>{i.current.style.top=i.current.style.bottom;const t=r.getRootElement(),n=i.current,u=n.firstChild;if(null!==t&&null!==e){const{left:r,top:c,width:s,height:a}=e.getRect(),m=i.current.offsetHeight;if(n.style.top=`${c+window.pageYOffset+m+3}px`,n.style.left=`${r+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${s}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,l=e.width,i=t.getBoundingClientRect();r+l>i.right&&(n.style.left=`${i.right-l+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>i.bottom)&&c-i.top>o&&(n.style.top=c-o+window.pageYOffset-a+"px")}n.isConnected||(null!=o&&(n.className=o),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("id","typeahead-menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute",l.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[r,e,o,l]);f((()=>{const t=r.getRootElement();if(null!==e)return u(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[r,u,e]);const c=h((t=>{null!==e&&(t||n(null))}),[e,n]);return R(e,i.current,u,c),i}(w,y,c,m),C=h((()=>{y(null),null!=l&&null!==w&&l()}),[l,w]),x=h((t=>{y(t),null!=r&&null===w&&r(t)}),[r,w]),I=h((t=>{t.preventDefault(),null!=o&&o(t);const e=n(t.target);x({getRect:()=>new DOMRect(t.clientX/e,t.clientY/e,1,1)})}),[x,o]),S=h((t=>{null===w||null==b.current||null==t.target||b.current.contains(t.target)||C()}),[C,w]);return f((()=>{const t=p.getRootElement();if(t)return t.addEventListener("contextmenu",I),()=>t.removeEventListener("contextmenu",I)}),[p,I]),f((()=>(document.addEventListener("click",S),()=>document.removeEventListener("click",S))),[p,S]),null===w||null===p?null:d.createElement(O,{close:C,resolution:w,editor:p,anchorElementRef:E,options:e,menuRenderFn:(t,e)=>u(t,e,{setMenuRef:t=>{b.current=t}}),onSelectOption:i,commandPriority:a})}export{I as LexicalContextMenuPlugin,b as MenuOption};
8
+
9
+ import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{mergeRegister as e,calculateZoomLevel as n}from"@lexical/utils";import{createCommand as o,KEY_ARROW_DOWN_COMMAND as l,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as i,KEY_TAB_COMMAND as u,KEY_ENTER_COMMAND as c,COMMAND_PRIORITY_LOW as s,$getSelection as a,$isRangeSelection as m}from"lexical";import*as d from"react";import{useLayoutEffect as p,useEffect as f,useState as g,useCallback as h,useMemo as w,useRef as v}from"react";const y="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?p:f;class b{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const E=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function C(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function R(e,n,o,l){const[r]=t();f((()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,u=C(n,e);const c=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=C(n,e);t!==u&&(u=t,null!=l&&l(t))},s=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",c,{capture:!0,passive:!0}),s.observe(n),()=>{s.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",c,!0)}}}),[n,r,l,o,e])}const x=o("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:n,anchorElementRef:o,resolution:d,options:p,menuRenderFn:v,onSelectOption:b,shouldSplitNodeWithQuery:C=!1,commandPriority:R=s}){const[O,I]=g(null),S=d.match&&d.match.matchingString;f((()=>{I(0)}),[S]);const A=h((e=>{n.update((()=>{const n=null!=d.match&&C?function(t){const e=a();if(!m(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,u=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.substr(-n)===e.substr(0,n)&&(o=n);return o}(r,t.matchingString,i);if(u<0)return null;let c;return 0===u?[c]=o.splitText(l):[,c]=o.splitText(u,l),c}(d.match):null;b(e,n,t,d.match?d.match.matchingString:"")}))}),[n,C,d.match,b,t]),L=h((t=>{const e=n.getRootElement();null!==e&&(e.setAttribute("aria-activedescendant","typeahead-item-"+t),I(t))}),[n]);f((()=>()=>{const t=n.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[n]),y((()=>{null===p?I(null):null===O&&L(0)}),[p,O,L]),f((()=>e(n.registerCommand(x,(({option:t})=>!(!t.ref||null==t.ref.current)&&(E(t.ref.current),!0)),R))),[n,L,R]),f((()=>e(n.registerCommand(l,(t=>{const e=t;if(null!==p&&p.length&&null!==O){const t=O!==p.length-1?O+1:0;L(t);const o=p[t];null!=o.ref&&o.ref.current&&n.dispatchCommand(x,{index:t,option:o}),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(r,(t=>{const e=t;if(null!==p&&p.length&&null!==O){const t=0!==O?O-1:p.length-1;L(t);const n=p[t];null!=n.ref&&n.ref.current&&E(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(i,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),R),n.registerCommand(u,(t=>{const e=t;return null!==p&&null!==O&&null!=p[O]&&(e.preventDefault(),e.stopImmediatePropagation(),A(p[O]),!0)}),R),n.registerCommand(c,(t=>null!==p&&null!==O&&null!=p[O]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(p[O]),!0)),R))),[A,t,n,p,O,L,R]);return v(o,w((()=>({options:p,selectOptionAndCleanUp:A,selectedIndex:O,setHighlightedIndex:I})),[A,O,p]),d.match?d.match.matchingString:"")}function I({options:e,onWillOpen:o,onClose:l,onOpen:r,onSelectOption:i,menuRenderFn:u,anchorClassName:c,commandPriority:a=s,parent:m}){const[p]=t(),[w,y]=g(null),b=d.useRef(null),E=function(e,n,o,l=document.body){const[r]=t(),i=v(document.createElement("div")),u=h((()=>{i.current.style.top=i.current.style.bottom;const t=r.getRootElement(),n=i.current,u=n.firstChild;if(null!==t&&null!==e){const{left:r,top:c,width:s,height:a}=e.getRect(),m=i.current.offsetHeight;if(n.style.top=`${c+window.pageYOffset+m+3}px`,n.style.left=`${r+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${s}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,l=e.width,i=t.getBoundingClientRect();r+l>i.right&&(n.style.left=`${i.right-l+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>i.bottom)&&c-i.top>o+a&&(n.style.top=c-o+window.pageYOffset-a+"px")}n.isConnected||(null!=o&&(n.className=o),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("id","typeahead-menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute",l.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[r,e,o,l]);f((()=>{const t=r.getRootElement();if(null!==e)return u(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[r,u,e]);const c=h((t=>{null!==e&&(t||n(null))}),[e,n]);return R(e,i.current,u,c),i}(w,y,c,m),C=h((()=>{y(null),null!=l&&null!==w&&l()}),[l,w]),x=h((t=>{y(t),null!=r&&null===w&&r(t)}),[r,w]),I=h((t=>{t.preventDefault(),null!=o&&o(t);const e=n(t.target);x({getRect:()=>new DOMRect(t.clientX/e,t.clientY/e,1,1)})}),[x,o]),S=h((t=>{null===w||null==b.current||null==t.target||b.current.contains(t.target)||C()}),[C,w]);return f((()=>{const t=p.getRootElement();if(t)return t.addEventListener("contextmenu",I),()=>t.removeEventListener("contextmenu",I)}),[p,I]),f((()=>(document.addEventListener("click",S),()=>document.removeEventListener("click",S))),[p,S]),null===w||null===p?null:d.createElement(O,{close:C,resolution:w,editor:p,anchorElementRef:E,options:e,menuRenderFn:(t,e)=>u(t,e,{setMenuRef:t=>{b.current=t}}),onSelectOption:i,commandPriority:a})}export{I as LexicalContextMenuPlugin,b as MenuOption};
@@ -15,6 +15,7 @@ export declare class DecoratorBlockNode extends DecoratorNode<JSX.Element> {
15
15
  __format: ElementFormatType;
16
16
  constructor(format?: ElementFormatType, key?: NodeKey);
17
17
  exportJSON(): SerializedDecoratorBlockNode;
18
+ canIndent(): false;
18
19
  createDOM(): HTMLElement;
19
20
  updateDOM(): false;
20
21
  setFormat(format: ElementFormatType): void;
@@ -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 lexical = require('lexical');
@@ -15,6 +17,7 @@ var lexical = require('lexical');
15
17
  * LICENSE file in the root directory of this source tree.
16
18
  *
17
19
  */
20
+
18
21
  class DecoratorBlockNode extends lexical.DecoratorNode {
19
22
  constructor(format, key) {
20
23
  super(key);
@@ -27,6 +30,9 @@ class DecoratorBlockNode extends lexical.DecoratorNode {
27
30
  version: 1
28
31
  };
29
32
  }
33
+ canIndent() {
34
+ return false;
35
+ }
30
36
  createDOM() {
31
37
  return document.createElement('div');
32
38
  }
@@ -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 { DecoratorNode } from 'lexical';
8
10
 
9
11
  /**
@@ -13,6 +15,7 @@ import { DecoratorNode } from 'lexical';
13
15
  * LICENSE file in the root directory of this source tree.
14
16
  *
15
17
  */
18
+
16
19
  class DecoratorBlockNode extends DecoratorNode {
17
20
  constructor(format, key) {
18
21
  super(key);
@@ -25,6 +28,9 @@ class DecoratorBlockNode extends DecoratorNode {
25
28
  version: 1
26
29
  };
27
30
  }
31
+ canIndent() {
32
+ return false;
33
+ }
28
34
  createDOM() {
29
35
  return document.createElement('div');
30
36
  }
@@ -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 LexicalDecoratorBlockNode = process.env.NODE_ENV === 'development' ? require('./LexicalDecoratorBlockNode.dev.js') : require('./LexicalDecoratorBlockNode.prod.js');
9
11
  module.exports = LexicalDecoratorBlockNode;
@@ -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 './LexicalDecoratorBlockNode.dev.mjs';
8
10
  import * as modProd from './LexicalDecoratorBlockNode.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('./LexicalDecoratorBlockNode.dev.mjs') : import('./LexicalDecoratorBlockNode.prod.mjs'));
8
10
  export const $isDecoratorBlockNode = mod.$isDecoratorBlockNode;
9
11
  export const DecoratorBlockNode = mod.DecoratorBlockNode;
@@ -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
- 'use strict';var b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}isInline(){return!1}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=c
8
+
9
+ 'use strict';var b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}canIndent(){return!1}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}isInline(){return!1}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=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{DecoratorNode as t}from"lexical";class r extends t{constructor(t,r){super(r),this.__format=t||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(t){this.getWritable().__format=t}isInline(){return!1}}function e(t){return t instanceof r}export{e as $isDecoratorBlockNode,r as DecoratorBlockNode};
8
+
9
+ import{DecoratorNode as t}from"lexical";class r extends t{constructor(t,r){super(r),this.__format=t||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}canIndent(){return!1}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(t){this.getWritable().__format=t}isInline(){return!1}}function e(t){return t instanceof r}export{e as $isDecoratorBlockNode,r as DecoratorBlockNode};