@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,14 +3,16 @@
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 { $isDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
9
11
  import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
10
12
  import { mergeRegister, $getNearestBlockElementAncestorOrThrow } from '@lexical/utils';
11
13
  import { $isNodeSelection, $getSelection, $getNodeByKey, $isDecoratorNode, FORMAT_ELEMENT_COMMAND, $isRangeSelection, COMMAND_PRIORITY_LOW, CLICK_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND } from 'lexical';
12
- import * as React from 'react';
13
14
  import { useRef, useCallback, useEffect } from 'react';
15
+ import { jsx } from 'react/jsx-runtime';
14
16
 
15
17
  /**
16
18
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -19,6 +21,7 @@ import { useRef, useCallback, useEffect } from 'react';
19
21
  * LICENSE file in the root directory of this source tree.
20
22
  *
21
23
  */
24
+
22
25
  function BlockWithAlignableContents({
23
26
  children,
24
27
  format,
@@ -28,7 +31,7 @@ function BlockWithAlignableContents({
28
31
  const [editor] = useLexicalComposerContext();
29
32
  const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
30
33
  const ref = useRef(null);
31
- const onDelete = useCallback(event => {
34
+ const $onDelete = useCallback(event => {
32
35
  if (isSelected && $isNodeSelection($getSelection())) {
33
36
  event.preventDefault();
34
37
  const node = $getNodeByKey(nodeKey);
@@ -72,15 +75,16 @@ function BlockWithAlignableContents({
72
75
  return true;
73
76
  }
74
77
  return false;
75
- }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW));
76
- }, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected]);
77
- return /*#__PURE__*/React.createElement("div", {
78
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW));
79
+ }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
80
+ return /*#__PURE__*/jsx("div", {
78
81
  className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
79
82
  ref: ref,
80
83
  style: {
81
84
  textAlign: format ? format : undefined
82
- }
83
- }, children);
85
+ },
86
+ children: children
87
+ });
84
88
  }
85
89
 
86
90
  export { BlockWithAlignableContents };
@@ -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 LexicalBlockWithAlignableContents = process.env.NODE_ENV === 'development' ? require('./LexicalBlockWithAlignableContents.dev.js') : require('./LexicalBlockWithAlignableContents.prod.js');
9
11
  module.exports = LexicalBlockWithAlignableContents;
@@ -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 './LexicalBlockWithAlignableContents.dev.mjs';
8
10
  import * as modProd from './LexicalBlockWithAlignableContents.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('./LexicalBlockWithAlignableContents.dev.mjs') : import('./LexicalBlockWithAlignableContents.prod.mjs'));
8
10
  export const BlockWithAlignableContents = mod.BlockWithAlignableContents;
@@ -3,8 +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 a=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/LexicalDecoratorBlockNode"),l=require("@lexical/react/useLexicalNodeSelection"),m=require("@lexical/utils"),u=require("lexical"),v=require("react");
8
- exports.BlockWithAlignableContents=function({children:w,format:n,nodeKey:e,className:p}){let [f]=a.useLexicalComposerContext(),[c,q,r]=l.useLexicalNodeSelection(e),t=v.useRef(null),k=v.useCallback(b=>c&&u.$isNodeSelection(u.$getSelection())&&(b.preventDefault(),b=u.$getNodeByKey(e),u.$isDecoratorNode(b))?(b.remove(),!0):!1,[c,e]);v.useEffect(()=>m.mergeRegister(f.registerCommand(u.FORMAT_ELEMENT_COMMAND,b=>{if(c){var g=u.$getSelection();if(u.$isNodeSelection(g)){var d=u.$getNodeByKey(e);h.$isDecoratorBlockNode(d)&&
9
- d.setFormat(b)}else if(u.$isRangeSelection(g)){g=g.getNodes();for(d of g)h.$isDecoratorBlockNode(d)?d.setFormat(b):m.$getNearestBlockElementAncestorOrThrow(d).setFormat(b)}return!0}return!1},u.COMMAND_PRIORITY_LOW),f.registerCommand(u.CLICK_COMMAND,b=>b.target===t.current?(b.preventDefault(),b.shiftKey||r(),q(!c),!0):!1,u.COMMAND_PRIORITY_LOW),f.registerCommand(u.KEY_DELETE_COMMAND,k,u.COMMAND_PRIORITY_LOW),f.registerCommand(u.KEY_BACKSPACE_COMMAND,k,u.COMMAND_PRIORITY_LOW)),[r,f,c,e,k,q]);return v.createElement("div",
10
- {className:[p.base,c?p.focus:null].filter(Boolean).join(" "),ref:t,style:{textAlign:n?n:void 0}},w)}
8
+
9
+ 'use strict';var a=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/LexicalDecoratorBlockNode"),l=require("@lexical/react/useLexicalNodeSelection"),m=require("@lexical/utils"),u=require("lexical"),v=require("react"),w=require("react/jsx-runtime");
10
+ exports.BlockWithAlignableContents=function({children:x,format:n,nodeKey:e,className:p}){let [f]=a.useLexicalComposerContext(),[c,q,r]=l.useLexicalNodeSelection(e),t=v.useRef(null),k=v.useCallback(b=>c&&u.$isNodeSelection(u.$getSelection())&&(b.preventDefault(),b=u.$getNodeByKey(e),u.$isDecoratorNode(b))?(b.remove(),!0):!1,[c,e]);v.useEffect(()=>m.mergeRegister(f.registerCommand(u.FORMAT_ELEMENT_COMMAND,b=>{if(c){var g=u.$getSelection();if(u.$isNodeSelection(g)){var d=u.$getNodeByKey(e);h.$isDecoratorBlockNode(d)&&
11
+ d.setFormat(b)}else if(u.$isRangeSelection(g)){g=g.getNodes();for(d of g)h.$isDecoratorBlockNode(d)?d.setFormat(b):m.$getNearestBlockElementAncestorOrThrow(d).setFormat(b)}return!0}return!1},u.COMMAND_PRIORITY_LOW),f.registerCommand(u.CLICK_COMMAND,b=>b.target===t.current?(b.preventDefault(),b.shiftKey||r(),q(!c),!0):!1,u.COMMAND_PRIORITY_LOW),f.registerCommand(u.KEY_DELETE_COMMAND,k,u.COMMAND_PRIORITY_LOW),f.registerCommand(u.KEY_BACKSPACE_COMMAND,k,u.COMMAND_PRIORITY_LOW)),[r,f,c,e,k,q]);return w.jsx("div",
12
+ {className:[p.base,c?p.focus:null].filter(Boolean).join(" "),ref:t,style:{textAlign:n?n:void 0},children:x})}
@@ -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{$isDecoratorBlockNode as r}from"@lexical/react/LexicalDecoratorBlockNode";import{useLexicalNodeSelection as t}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as o,$getNearestBlockElementAncestorOrThrow as i}from"@lexical/utils";import{$isNodeSelection as a,$getSelection as l,$getNodeByKey as m,$isDecoratorNode as n,FORMAT_ELEMENT_COMMAND as c,$isRangeSelection as s,COMMAND_PRIORITY_LOW as f,CLICK_COMMAND as u,KEY_DELETE_COMMAND as d,KEY_BACKSPACE_COMMAND as p}from"lexical";import*as x from"react";import{useRef as g,useCallback as C,useEffect as v}from"react";function N({children:N,format:y,nodeKey:D,className:F}){const[L]=e(),[h,B,K]=t(D),b=g(null),j=C((e=>{if(h&&a(l())){e.preventDefault();const r=m(D);if(n(r))return r.remove(),!0}return!1}),[h,D]);return v((()=>o(L.registerCommand(c,(e=>{if(h){const t=l();if(a(t)){const t=m(D);r(t)&&t.setFormat(e)}else if(s(t)){const o=t.getNodes();for(const t of o)if(r(t))t.setFormat(e);else{i(t).setFormat(e)}}return!0}return!1}),f),L.registerCommand(u,(e=>e.target===b.current&&(e.preventDefault(),e.shiftKey||K(),B(!h),!0)),f),L.registerCommand(d,j,f),L.registerCommand(p,j,f))),[K,L,h,D,j,B]),x.createElement("div",{className:[F.base,h?F.focus:null].filter(Boolean).join(" "),ref:b,style:{textAlign:y||void 0}},N)}export{N as BlockWithAlignableContents};
8
+
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{$isDecoratorBlockNode as r}from"@lexical/react/LexicalDecoratorBlockNode";import{useLexicalNodeSelection as t}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as o,$getNearestBlockElementAncestorOrThrow as i}from"@lexical/utils";import{$isNodeSelection as l,$getSelection as a,$getNodeByKey as m,$isDecoratorNode as n,FORMAT_ELEMENT_COMMAND as c,$isRangeSelection as s,COMMAND_PRIORITY_LOW as f,CLICK_COMMAND as u,KEY_DELETE_COMMAND as d,KEY_BACKSPACE_COMMAND as x}from"lexical";import{useRef as p,useCallback as g,useEffect as C}from"react";import{jsx as v}from"react/jsx-runtime";function N({children:N,format:h,nodeKey:y,className:D}){const[F]=e(),[L,j,B]=t(y),K=p(null),b=g((e=>{if(L&&l(a())){e.preventDefault();const r=m(y);if(n(r))return r.remove(),!0}return!1}),[L,y]);return C((()=>o(F.registerCommand(c,(e=>{if(L){const t=a();if(l(t)){const t=m(y);r(t)&&t.setFormat(e)}else if(s(t)){const o=t.getNodes();for(const t of o)if(r(t))t.setFormat(e);else{i(t).setFormat(e)}}return!0}return!1}),f),F.registerCommand(u,(e=>e.target===K.current&&(e.preventDefault(),e.shiftKey||B(),j(!L),!0)),f),F.registerCommand(d,b,f),F.registerCommand(x,b,f))),[B,F,L,y,b,j]),v("div",{className:[D.base,L?D.focus:null].filter(Boolean).join(" "),ref:K,style:{textAlign:h||void 0},children:N})}export{N as BlockWithAlignableContents};
@@ -3,15 +3,18 @@
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
- var React = require('react');
12
+ var react = require('react');
11
13
  var overflow = require('@lexical/overflow');
12
14
  var text = require('@lexical/text');
13
15
  var utils = require('@lexical/utils');
14
16
  var lexical = require('lexical');
17
+ var jsxRuntime = require('react/jsx-runtime');
15
18
 
16
19
  /**
17
20
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -20,6 +23,7 @@ var lexical = require('lexical');
20
23
  * LICENSE file in the root directory of this source tree.
21
24
  *
22
25
  */
26
+
23
27
  function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({})) {
24
28
  const {
25
29
  strlen = input => input.length,
@@ -28,14 +32,14 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
28
32
  return;
29
33
  }
30
34
  } = optional;
31
- React.useEffect(() => {
35
+ react.useEffect(() => {
32
36
  if (!editor.hasNodes([overflow.OverflowNode])) {
33
37
  {
34
38
  throw Error(`useCharacterLimit: OverflowNode not registered on editor`);
35
39
  }
36
40
  }
37
41
  }, [editor]);
38
- React.useEffect(() => {
42
+ react.useEffect(() => {
39
43
  let text$1 = editor.getEditorState().read(text.$rootTextContent);
40
44
  let lastComputedTextLength = 0;
41
45
  return utils.mergeRegister(editor.registerTextContentListener(currentText => {
@@ -66,7 +70,6 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
66
70
  }, [editor, maxCharacters, remainingCharacters, strlen]);
67
71
  }
68
72
  function findOffset(text, maxCharacters, strlen) {
69
- // @ts-ignore This is due to be added in a later version of TS
70
73
  const Segmenter = Intl.Segmenter;
71
74
  let offsetUtf16 = 0;
72
75
  let offset = 0;
@@ -156,14 +159,14 @@ function $wrapOverflowedNodes(offset) {
156
159
  if (previousSelection !== null) {
157
160
  lexical.$setSelection(previousSelection);
158
161
  }
159
- mergePrevious(overflowNode);
162
+ $mergePrevious(overflowNode);
160
163
  }
161
164
  }
162
165
  }
163
166
  }
164
167
  function $wrapNode(node) {
165
168
  const overflowNode = overflow.$createOverflowNode();
166
- node.insertBefore(overflowNode);
169
+ node.replace(overflowNode);
167
170
  overflowNode.append(node);
168
171
  return overflowNode;
169
172
  }
@@ -176,7 +179,7 @@ function $unwrapNode(node) {
176
179
  node.remove();
177
180
  return childrenLength > 0 ? children[childrenLength - 1] : null;
178
181
  }
179
- function mergePrevious(overflowNode) {
182
+ function $mergePrevious(overflowNode) {
180
183
  const previousNode = overflowNode.getPreviousSibling();
181
184
  if (!overflow.$isOverflowNode(previousNode)) {
182
185
  return;
@@ -218,6 +221,7 @@ function mergePrevious(overflowNode) {
218
221
  * LICENSE file in the root directory of this source tree.
219
222
  *
220
223
  */
224
+
221
225
  const CHARACTER_LIMIT = 5;
222
226
  let textEncoderInstance = null;
223
227
  function textEncoder() {
@@ -241,9 +245,10 @@ function utf8Length(text) {
241
245
  function DefaultRenderer({
242
246
  remainingCharacters
243
247
  }) {
244
- return /*#__PURE__*/React.createElement("span", {
245
- className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`
246
- }, remainingCharacters);
248
+ return /*#__PURE__*/jsxRuntime.jsx("span", {
249
+ className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`,
250
+ children: remainingCharacters
251
+ });
247
252
  }
248
253
  function CharacterLimitPlugin({
249
254
  charset = 'UTF-16',
@@ -251,8 +256,8 @@ function CharacterLimitPlugin({
251
256
  renderer = DefaultRenderer
252
257
  }) {
253
258
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
254
- const [remainingCharacters, setRemainingCharacters] = React.useState(maxLength);
255
- const characterLimitProps = React.useMemo(() => ({
259
+ const [remainingCharacters, setRemainingCharacters] = react.useState(maxLength);
260
+ const characterLimitProps = react.useMemo(() => ({
256
261
  remainingCharacters: setRemainingCharacters,
257
262
  strlen: text => {
258
263
  if (charset === 'UTF-8') {
@@ -3,14 +3,16 @@
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 * as React from 'react';
9
10
  import { useEffect, useState, useMemo } from 'react';
10
11
  import { OverflowNode, $isOverflowNode, $createOverflowNode } from '@lexical/overflow';
11
12
  import { $rootTextContent } from '@lexical/text';
12
13
  import { mergeRegister, $dfs } from '@lexical/utils';
13
14
  import { $getSelection, $isRangeSelection, $isTextNode, $isLeafNode, $setSelection } from 'lexical';
15
+ import { jsx } from 'react/jsx-runtime';
14
16
 
15
17
  /**
16
18
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -19,6 +21,7 @@ import { $getSelection, $isRangeSelection, $isTextNode, $isLeafNode, $setSelecti
19
21
  * LICENSE file in the root directory of this source tree.
20
22
  *
21
23
  */
24
+
22
25
  function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({})) {
23
26
  const {
24
27
  strlen = input => input.length,
@@ -65,7 +68,6 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
65
68
  }, [editor, maxCharacters, remainingCharacters, strlen]);
66
69
  }
67
70
  function findOffset(text, maxCharacters, strlen) {
68
- // @ts-ignore This is due to be added in a later version of TS
69
71
  const Segmenter = Intl.Segmenter;
70
72
  let offsetUtf16 = 0;
71
73
  let offset = 0;
@@ -155,14 +157,14 @@ function $wrapOverflowedNodes(offset) {
155
157
  if (previousSelection !== null) {
156
158
  $setSelection(previousSelection);
157
159
  }
158
- mergePrevious(overflowNode);
160
+ $mergePrevious(overflowNode);
159
161
  }
160
162
  }
161
163
  }
162
164
  }
163
165
  function $wrapNode(node) {
164
166
  const overflowNode = $createOverflowNode();
165
- node.insertBefore(overflowNode);
167
+ node.replace(overflowNode);
166
168
  overflowNode.append(node);
167
169
  return overflowNode;
168
170
  }
@@ -175,7 +177,7 @@ function $unwrapNode(node) {
175
177
  node.remove();
176
178
  return childrenLength > 0 ? children[childrenLength - 1] : null;
177
179
  }
178
- function mergePrevious(overflowNode) {
180
+ function $mergePrevious(overflowNode) {
179
181
  const previousNode = overflowNode.getPreviousSibling();
180
182
  if (!$isOverflowNode(previousNode)) {
181
183
  return;
@@ -217,6 +219,7 @@ function mergePrevious(overflowNode) {
217
219
  * LICENSE file in the root directory of this source tree.
218
220
  *
219
221
  */
222
+
220
223
  const CHARACTER_LIMIT = 5;
221
224
  let textEncoderInstance = null;
222
225
  function textEncoder() {
@@ -240,9 +243,10 @@ function utf8Length(text) {
240
243
  function DefaultRenderer({
241
244
  remainingCharacters
242
245
  }) {
243
- return /*#__PURE__*/React.createElement("span", {
244
- className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`
245
- }, remainingCharacters);
246
+ return /*#__PURE__*/jsx("span", {
247
+ className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`,
248
+ children: remainingCharacters
249
+ });
246
250
  }
247
251
  function CharacterLimitPlugin({
248
252
  charset = 'UTF-16',
@@ -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 LexicalCharacterLimitPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalCharacterLimitPlugin.dev.js') : require('./LexicalCharacterLimitPlugin.prod.js');
9
11
  module.exports = LexicalCharacterLimitPlugin;
@@ -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 './LexicalCharacterLimitPlugin.dev.mjs';
8
10
  import * as modProd from './LexicalCharacterLimitPlugin.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('./LexicalCharacterLimitPlugin.dev.mjs') : import('./LexicalCharacterLimitPlugin.prod.mjs'));
8
10
  export const CharacterLimitPlugin = mod.CharacterLimitPlugin;
@@ -3,13 +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
  */
7
- 'use strict';var p=require("@lexical/react/LexicalComposerContext"),v=require("react"),w=require("@lexical/overflow"),A=require("@lexical/text"),B=require("@lexical/utils"),D=require("lexical");
8
- function E(a){let c=new URLSearchParams;c.append("code",a);for(let h=1;h<arguments.length;h++)c.append("v",arguments[h]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${c} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
9
- function G(a,c,h=Object.freeze({})){let {strlen:f=l=>l.length,remainingCharacters:q=()=>{}}=h;v.useEffect(()=>{a.hasNodes([w.OverflowNode])||E(57)},[a]);v.useEffect(()=>{let l=a.getEditorState().read(A.$rootTextContent),m=0;return B.mergeRegister(a.registerTextContentListener(d=>{l=d}),a.registerUpdateListener(({dirtyLeaves:d,dirtyElements:r})=>{var x=a.isComposing();d=0<d.size||0<r.size;if(!x&&d){x=f(l);d=x>c||null!==m&&m>c;q(c-x);if(null===m||d){let t=H(l,c,f);a.update(()=>{let C=B.$dfs(),L=C.length,
10
- y=0;for(let z=0;z<L;z+=1){var {node:b}=C[z];if(w.$isOverflowNode(b)){var e=y;if(y+b.getTextContentSize()<=t){var g=b.getParent();e=b.getPreviousSibling();var k=b.getNextSibling();I(b);b=D.$getSelection();!D.$isRangeSelection(b)||b.anchor.getNode().isAttached()&&b.focus.getNode().isAttached()||(D.$isTextNode(e)?e.select():D.$isTextNode(k)?k.select():null!==g&&g.select())}else e<t&&(g=b.getFirstDescendant(),k=null!==g?g.getTextContentSize():0,e+=k,g=D.$isTextNode(g)&&g.isSimpleText(),e=e<=t,(g||e)&&
11
- I(b))}else if(D.$isLeafNode(b)&&(e=y,y+=b.getTextContentSize(),y>t&&!w.$isOverflowNode(b.getParent())&&(g=D.$getSelection(),e<t&&D.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(t-e),b=J(b)):b=J(b),null!==g&&D.$setSelection(g),e=b.getPreviousSibling(),w.$isOverflowNode(e)))){k=b.getFirstChild();var u=e.getChildren();g=u.length;if(null===k)b.append(...u);else for(var n=0;n<g;n++)k.insertBefore(u[n]);n=D.$getSelection();if(D.$isRangeSelection(n)){k=n.anchor;u=k.getNode();n=n.focus;let F=k.getNode();
12
- u.is(e)?k.set(b.getKey(),k.offset,"element"):u.is(b)&&k.set(b.getKey(),g+k.offset,"element");F.is(e)?n.set(b.getKey(),n.offset,"element"):F.is(b)&&n.set(b.getKey(),g+n.offset,"element")}e.remove()}}},{tag:"history-merge"})}m=x}}))},[a,c,q,f])}
13
- function H(a,c,h){var f=Intl.Segmenter;let q=0;var l=0;if("function"===typeof f){a=(new f).segment(a);for(var {segment:m}of a){l+=h(m);if(l>c)break;q+=m.length}}else for(m=Array.from(a),a=m.length,f=0;f<a;f++){let d=m[f];l+=h(d);if(l>c)break;q+=d.length}return q}function J(a){let c=w.$createOverflowNode();a.insertBefore(c);c.append(a);return c}function I(a){let c=a.getChildren(),h=c.length;for(let f=0;f<h;f++)a.insertBefore(c[f]);a.remove();return 0<h?c[h-1]:null}let K=null;
14
- function M({remainingCharacters:a}){return v.createElement("span",{className:`characters-limit ${0>a?"characters-limit-exceeded":""}`},a)}
15
- exports.CharacterLimitPlugin=function({charset:a="UTF-16",maxLength:c=5,renderer:h=M}){let [f]=p.useLexicalComposerContext(),[q,l]=v.useState(c),m=v.useMemo(()=>({remainingCharacters:l,strlen:d=>{if("UTF-8"===a){if(void 0===window.TextEncoder)var r=null;else null===K&&(K=new window.TextEncoder),r=K;null===r?(r=encodeURIComponent(d).match(/%[89ABab]/g),d=d.length+(r?r.length:0)):d=r.encode(d).length;return d}if("UTF-16"===a)return d.length;throw Error("Unrecognized charset");}}),[a]);G(f,c,m);return h({remainingCharacters:q})}
8
+
9
+ 'use strict';var p=require("@lexical/react/LexicalComposerContext"),v=require("react"),w=require("@lexical/overflow"),z=require("@lexical/text"),B=require("@lexical/utils"),C=require("lexical"),D=require("react/jsx-runtime"),F;
10
+ function G(a){let c=new URLSearchParams;c.append("code",a);for(let h=1;h<arguments.length;h++)c.append("v",arguments[h]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${c} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}F=G&&G.__esModule&&Object.prototype.hasOwnProperty.call(G,"default")?G["default"]:G;
11
+ function I(a,c,h=Object.freeze({})){let {strlen:f=l=>l.length,remainingCharacters:q=()=>{}}=h;v.useEffect(()=>{a.hasNodes([w.OverflowNode])||F(57)},[a]);v.useEffect(()=>{let l=a.getEditorState().read(z.$rootTextContent),m=0;return B.mergeRegister(a.registerTextContentListener(d=>{l=d}),a.registerUpdateListener(({dirtyLeaves:d,dirtyElements:r})=>{var x=a.isComposing();d=0<d.size||0<r.size;if(!x&&d){x=f(l);d=x>c||null!==m&&m>c;q(c-x);if(null===m||d){let t=J(l,c,f);a.update(()=>{let E=B.$dfs(),N=E.length,
12
+ y=0;for(let A=0;A<N;A+=1){var {node:b}=E[A];if(w.$isOverflowNode(b)){var e=y;if(y+b.getTextContentSize()<=t){var g=b.getParent();e=b.getPreviousSibling();var k=b.getNextSibling();K(b);b=C.$getSelection();!C.$isRangeSelection(b)||b.anchor.getNode().isAttached()&&b.focus.getNode().isAttached()||(C.$isTextNode(e)?e.select():C.$isTextNode(k)?k.select():null!==g&&g.select())}else e<t&&(g=b.getFirstDescendant(),k=null!==g?g.getTextContentSize():0,e+=k,g=C.$isTextNode(g)&&g.isSimpleText(),e=e<=t,(g||e)&&
13
+ K(b))}else if(C.$isLeafNode(b)&&(e=y,y+=b.getTextContentSize(),y>t&&!w.$isOverflowNode(b.getParent())&&(g=C.$getSelection(),e<t&&C.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(t-e),b=L(b)):b=L(b),null!==g&&C.$setSelection(g),e=b.getPreviousSibling(),w.$isOverflowNode(e)))){k=b.getFirstChild();var u=e.getChildren();g=u.length;if(null===k)b.append(...u);else for(var n=0;n<g;n++)k.insertBefore(u[n]);n=C.$getSelection();if(C.$isRangeSelection(n)){k=n.anchor;u=k.getNode();n=n.focus;let H=k.getNode();
14
+ u.is(e)?k.set(b.getKey(),k.offset,"element"):u.is(b)&&k.set(b.getKey(),g+k.offset,"element");H.is(e)?n.set(b.getKey(),n.offset,"element"):H.is(b)&&n.set(b.getKey(),g+n.offset,"element")}e.remove()}}},{tag:"history-merge"})}m=x}}))},[a,c,q,f])}
15
+ function J(a,c,h){var f=Intl.Segmenter;let q=0;var l=0;if("function"===typeof f){a=(new f).segment(a);for(var {segment:m}of a){l+=h(m);if(l>c)break;q+=m.length}}else for(m=Array.from(a),a=m.length,f=0;f<a;f++){let d=m[f];l+=h(d);if(l>c)break;q+=d.length}return q}function L(a){let c=w.$createOverflowNode();a.replace(c);c.append(a);return c}function K(a){let c=a.getChildren(),h=c.length;for(let f=0;f<h;f++)a.insertBefore(c[f]);a.remove();return 0<h?c[h-1]:null}let M=null;
16
+ function O({remainingCharacters:a}){return D.jsx("span",{className:`characters-limit ${0>a?"characters-limit-exceeded":""}`,children:a})}
17
+ exports.CharacterLimitPlugin=function({charset:a="UTF-16",maxLength:c=5,renderer:h=O}){let [f]=p.useLexicalComposerContext(),[q,l]=v.useState(c),m=v.useMemo(()=>({remainingCharacters:l,strlen:d=>{if("UTF-8"===a){if(void 0===window.TextEncoder)var r=null;else null===M&&(M=new window.TextEncoder),r=M;null===r?(r=encodeURIComponent(d).match(/%[89ABab]/g),d=d.length+(r?r.length:0)):d=r.encode(d).length;return d}if("UTF-16"===a)return d.length;throw Error("Unrecognized charset");}}),[a]);I(f,c,m);return h({remainingCharacters:q})}
@@ -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 t from"react";import{useEffect as n,useState as r,useMemo as o}from"react";import{OverflowNode as i,$isOverflowNode as s,$createOverflowNode as l}from"@lexical/overflow";import{$rootTextContent as c}from"@lexical/text";import{mergeRegister as a,$dfs as f}from"@lexical/utils";import{$getSelection as g,$isRangeSelection as m,$isTextNode as u,$isLeafNode as d,$setSelection as h}from"lexical";var p=function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)};function x(e,t,r=Object.freeze({})){const{strlen:o=(e=>e.length),remainingCharacters:l=(()=>{})}=r;n((()=>{e.hasNodes([i])||p(57)}),[e]),n((()=>{let n=e.getEditorState().read(c),r=0;return a(e.registerTextContentListener((e=>{n=e})),e.registerUpdateListener((({dirtyLeaves:i,dirtyElements:c})=>{const a=e.isComposing(),p=i.size>0||c.size>0;if(a||!p)return;const x=o(n),T=x>t||null!==r&&r>t;if(l(t-x),null===r||T){const r=function(e,t,n){const r=Intl.Segmenter;let o=0,i=0;if("function"==typeof r){const s=(new r).segment(e);for(const{segment:e}of s){const r=i+n(e);if(r>t)break;i=r,o+=e.length}}else{const r=Array.from(e),s=r.length;for(let e=0;e<s;e++){const s=r[e],l=i+n(s);if(l>t)break;i=l,o+=s.length}}return o}(n,t,o);e.update((()=>{!function(e){const t=f(),n=t.length;let r=0;for(let o=0;o<n;o+=1){const{node:n}=t[o];if(s(n)){const t=r;if(r+n.getTextContentSize()<=e){const e=n.getParent(),t=n.getPreviousSibling(),r=n.getNextSibling();v(n);const o=g();!m(o)||o.anchor.getNode().isAttached()&&o.focus.getNode().isAttached()||(u(t)?t.select():u(r)?r.select():null!==e&&e.select())}else if(t<e){const r=n.getFirstDescendant(),o=t+(null!==r?r.getTextContentSize():0);(u(r)&&r.isSimpleText()||o<=e)&&v(n)}}else if(d(n)){const t=r;if(r+=n.getTextContentSize(),r>e&&!s(n.getParent())){const r=g();let o;if(t<e&&u(n)&&n.isSimpleText()){const[,r]=n.splitText(e-t);o=C(r)}else o=C(n);null!==r&&h(r),w(o)}}}}(r)}),{tag:"history-merge"})}r=x})))}),[e,t,l,o])}function C(e){const t=l();return e.insertBefore(t),t.append(e),t}function v(e){const t=e.getChildren(),n=t.length;for(let r=0;r<n;r++)e.insertBefore(t[r]);return e.remove(),n>0?t[n-1]:null}function w(e){const t=e.getPreviousSibling();if(!s(t))return;const n=e.getFirstChild(),r=t.getChildren(),o=r.length;if(null===n)e.append(...r);else for(let e=0;e<o;e++)n.insertBefore(r[e]);const i=g();if(m(i)){const n=i.anchor,r=n.getNode(),s=i.focus,l=n.getNode();r.is(t)?n.set(e.getKey(),n.offset,"element"):r.is(e)&&n.set(e.getKey(),o+n.offset,"element"),l.is(t)?s.set(e.getKey(),s.offset,"element"):l.is(e)&&s.set(e.getKey(),o+s.offset,"element")}t.remove()}let T=null;function S(e){const t=void 0===window.TextEncoder?null:(null===T&&(T=new window.TextEncoder),T);if(null===t){const t=encodeURIComponent(e).match(/%[89ABab]/g);return e.length+(t?t.length:0)}return t.encode(e).length}function y({remainingCharacters:e}){return t.createElement("span",{className:"characters-limit "+(e<0?"characters-limit-exceeded":"")},e)}function b({charset:t="UTF-16",maxLength:n=5,renderer:i=y}){const[s]=e(),[l,c]=r(n);return x(s,n,o((()=>({remainingCharacters:c,strlen:e=>{if("UTF-8"===t)return S(e);if("UTF-16"===t)return e.length;throw new Error("Unrecognized charset")}})),[t])),i({remainingCharacters:l})}export{b as CharacterLimitPlugin};
8
+
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useEffect as t,useState as n,useMemo as r}from"react";import{OverflowNode as o,$isOverflowNode as i,$createOverflowNode as s}from"@lexical/overflow";import{$rootTextContent as l}from"@lexical/text";import{mergeRegister as c,$dfs as a}from"@lexical/utils";import{$getSelection as f,$isRangeSelection as g,$isTextNode as u,$isLeafNode as d,$setSelection as m}from"lexical";import{jsx as h}from"react/jsx-runtime";function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var x=p((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function C(e,n,r=Object.freeze({})){const{strlen:s=(e=>e.length),remainingCharacters:h=(()=>{})}=r;t((()=>{e.hasNodes([o])||x(57)}),[e]),t((()=>{let t=e.getEditorState().read(l),r=0;return c(e.registerTextContentListener((e=>{t=e})),e.registerUpdateListener((({dirtyLeaves:o,dirtyElements:l})=>{const c=e.isComposing(),p=o.size>0||l.size>0;if(c||!p)return;const x=s(t),C=x>n||null!==r&&r>n;if(h(n-x),null===r||C){const r=function(e,t,n){const r=Intl.Segmenter;let o=0,i=0;if("function"==typeof r){const s=(new r).segment(e);for(const{segment:e}of s){const r=i+n(e);if(r>t)break;i=r,o+=e.length}}else{const r=Array.from(e),s=r.length;for(let e=0;e<s;e++){const s=r[e],l=i+n(s);if(l>t)break;i=l,o+=s.length}}return o}(t,n,s);e.update((()=>{!function(e){const t=a(),n=t.length;let r=0;for(let o=0;o<n;o+=1){const{node:n}=t[o];if(i(n)){const t=r;if(r+n.getTextContentSize()<=e){const e=n.getParent(),t=n.getPreviousSibling(),r=n.getNextSibling();w(n);const o=f();!g(o)||o.anchor.getNode().isAttached()&&o.focus.getNode().isAttached()||(u(t)?t.select():u(r)?r.select():null!==e&&e.select())}else if(t<e){const r=n.getFirstDescendant(),o=t+(null!==r?r.getTextContentSize():0);(u(r)&&r.isSimpleText()||o<=e)&&w(n)}}else if(d(n)){const t=r;if(r+=n.getTextContentSize(),r>e&&!i(n.getParent())){const r=f();let o;if(t<e&&u(n)&&n.isSimpleText()){const[,r]=n.splitText(e-t);o=v(r)}else o=v(n);null!==r&&m(r),T(o)}}}}(r)}),{tag:"history-merge"})}r=x})))}),[e,n,h,s])}function v(e){const t=s();return e.replace(t),t.append(e),t}function w(e){const t=e.getChildren(),n=t.length;for(let r=0;r<n;r++)e.insertBefore(t[r]);return e.remove(),n>0?t[n-1]:null}function T(e){const t=e.getPreviousSibling();if(!i(t))return;const n=e.getFirstChild(),r=t.getChildren(),o=r.length;if(null===n)e.append(...r);else for(let e=0;e<o;e++)n.insertBefore(r[e]);const s=f();if(g(s)){const n=s.anchor,r=n.getNode(),i=s.focus,l=n.getNode();r.is(t)?n.set(e.getKey(),n.offset,"element"):r.is(e)&&n.set(e.getKey(),o+n.offset,"element"),l.is(t)?i.set(e.getKey(),i.offset,"element"):l.is(e)&&i.set(e.getKey(),o+i.offset,"element")}t.remove()}let y=null;function S(e){const t=void 0===window.TextEncoder?null:(null===y&&(y=new window.TextEncoder),y);if(null===t){const t=encodeURIComponent(e).match(/%[89ABab]/g);return e.length+(t?t.length:0)}return t.encode(e).length}function b({remainingCharacters:e}){return h("span",{className:"characters-limit "+(e<0?"characters-limit-exceeded":""),children:e})}function z({charset:t="UTF-16",maxLength:o=5,renderer:i=b}){const[s]=e(),[l,c]=n(o);return C(s,o,r((()=>({remainingCharacters:c,strlen:e=>{if("UTF-8"===t)return S(e);if("UTF-16"===t)return e.length;throw new Error("Unrecognized charset")}})),[t])),i({remainingCharacters:l})}export{z as CharacterLimitPlugin};
@@ -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 list = require('@lexical/list');
@@ -19,6 +21,7 @@ var react = require('react');
19
21
  * LICENSE file in the root directory of this source tree.
20
22
  *
21
23
  */
24
+
22
25
  function CheckListPlugin() {
23
26
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
24
27
  react.useEffect(() => {
@@ -130,12 +133,14 @@ function handleClick(event) {
130
133
  });
131
134
  }
132
135
  });
136
+ event.stopPropagation(); // Prevents potential parent-editor listeners from firing, causing the checkbox toggle to be undone
133
137
  }
134
138
  function handlePointerDown(event) {
135
139
  handleCheckItemEvent(event, () => {
136
140
  // Prevents caret moving when clicking on check mark
137
141
  event.preventDefault();
138
142
  });
143
+ event.stopPropagation();
139
144
  }
140
145
  function findEditor(target) {
141
146
  let node = target;
@@ -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 { INSERT_CHECK_LIST_COMMAND, insertList, $isListItemNode, $isListNode } from '@lexical/list';
8
10
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
9
11
  import { mergeRegister, $findMatchingParent, isHTMLElement, calculateZoomLevel } from '@lexical/utils';
@@ -17,6 +19,7 @@ import { useEffect } from 'react';
17
19
  * LICENSE file in the root directory of this source tree.
18
20
  *
19
21
  */
22
+
20
23
  function CheckListPlugin() {
21
24
  const [editor] = useLexicalComposerContext();
22
25
  useEffect(() => {
@@ -128,12 +131,14 @@ function handleClick(event) {
128
131
  });
129
132
  }
130
133
  });
134
+ event.stopPropagation(); // Prevents potential parent-editor listeners from firing, causing the checkbox toggle to be undone
131
135
  }
132
136
  function handlePointerDown(event) {
133
137
  handleCheckItemEvent(event, () => {
134
138
  // Prevents caret moving when clicking on check mark
135
139
  event.preventDefault();
136
140
  });
141
+ event.stopPropagation();
137
142
  }
138
143
  function findEditor(target) {
139
144
  let node = target;
@@ -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 LexicalCheckListPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalCheckListPlugin.dev.js') : require('./LexicalCheckListPlugin.prod.js');
9
11
  module.exports = LexicalCheckListPlugin;
@@ -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 './LexicalCheckListPlugin.dev.mjs';
8
10
  import * as modProd from './LexicalCheckListPlugin.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('./LexicalCheckListPlugin.dev.mjs') : import('./LexicalCheckListPlugin.prod.mjs'));
8
10
  export const CheckListPlugin = mod.CheckListPlugin;
@@ -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
  'use strict';var e=require("@lexical/list"),g=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/utils"),l=require("lexical"),m=require("react");function n(a,c){let b=a.target;if(null!==b&&k.isHTMLElement(b)){var d=b.firstChild;(null==d||!k.isHTMLElement(d)||"UL"!==d.tagName&&"OL"!==d.tagName)&&(d=b.parentNode)&&"check"===d.__lexicalListType&&(d=b.getBoundingClientRect(),a=a.pageX/k.calculateZoomLevel(b),("rtl"===b.dir?a<d.right&&a>d.right-20:a>d.left&&a<d.left+20)&&c())}}
8
- function p(a){n(a,()=>{let c=a.target,b=q(c);null!=b&&b.isEditable()&&b.update(()=>{if(a.target){let d=l.$getNearestNodeFromDOMNode(c);e.$isListItemNode(d)&&(c.focus(),d.toggleChecked())}})})}function r(a){n(a,()=>{a.preventDefault()})}function q(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function t(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}
9
- function u(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=c?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=c?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=c?a.getLastChild():a.getFirstChild()}return null}
10
+ function p(a){n(a,()=>{let c=a.target,b=q(c);null!=b&&b.isEditable()&&b.update(()=>{if(a.target){let d=l.$getNearestNodeFromDOMNode(c);e.$isListItemNode(d)&&(c.focus(),d.toggleChecked())}})});a.stopPropagation()}function r(a){n(a,()=>{a.preventDefault()});a.stopPropagation()}function q(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}
11
+ function t(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}function u(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=c?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=c?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=c?a.getLastChild():a.getFirstChild()}return null}
10
12
  function v(a,c,b){let d=t();null!=d&&c.update(()=>{var f=l.$getNearestNodeFromDOMNode(d);if(e.$isListItemNode(f)&&(f=u(f,b),null!=f)){f.selectStart();let h=c.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1}
11
13
  exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,c=>v(c,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,c=>v(c,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=t()){let c=a.getRootElement();null!=c&&c.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW),
12
14
  a.registerCommand(l.KEY_SPACE_COMMAND,c=>{let b=t();return null!=b&&a.isEditable()?(a.update(()=>{let d=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(d)&&(c.preventDefault(),d.toggleChecked())}),!0):!1},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,c=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:d}=b;if((b="element"===d.type)||0===d.offset){d=d.getNode();let f=k.$findMatchingParent(d,h=>l.$isElementNode(h)&&!h.isInline());
@@ -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{INSERT_CHECK_LIST_COMMAND as e,insertList as t,$isListItemNode as n,$isListNode as r}from"@lexical/list";import{useLexicalComposerContext as i}from"@lexical/react/LexicalComposerContext";import{mergeRegister as l,$findMatchingParent as o,isHTMLElement as c,calculateZoomLevel as u}from"@lexical/utils";import{COMMAND_PRIORITY_LOW as s,KEY_ARROW_DOWN_COMMAND as a,KEY_ARROW_UP_COMMAND as g,KEY_ESCAPE_COMMAND as f,KEY_SPACE_COMMAND as d,$getNearestNodeFromDOMNode as m,KEY_ARROW_LEFT_COMMAND as p,$getSelection as C,$isRangeSelection as h,$isElementNode as v}from"lexical";import{useEffect as E}from"react";function L(){const[c]=i();return E((()=>l(c.registerCommand(e,(()=>(t(c,"check"),!0)),s),c.registerCommand(a,(e=>N(e,c,!1)),s),c.registerCommand(g,(e=>N(e,c,!0)),s),c.registerCommand(f,(e=>{if(null!=y()){const e=c.getRootElement();return null!=e&&e.focus(),!0}return!1}),s),c.registerCommand(d,(e=>{const t=y();return!(null==t||!c.isEditable())&&(c.update((()=>{const r=m(t);n(r)&&(e.preventDefault(),r.toggleChecked())})),!0)}),s),c.registerCommand(p,(e=>c.getEditorState().read((()=>{const t=C();if(h(t)&&t.isCollapsed()){const{anchor:i}=t,l="element"===i.type;if(l||0===i.offset){const t=i.getNode(),u=o(t,(e=>v(e)&&!e.isInline()));if(n(u)){const n=u.getParent();if(r(n)&&"check"===n.getListType()&&(l||u.getFirstDescendant()===t)){const t=c.getElementByKey(u.__key);if(null!=t&&document.activeElement!==t)return t.focus(),e.preventDefault(),!0}}}}return!1}))),s),c.registerRootListener(((e,t)=>{null!==e&&(e.addEventListener("click",_),e.addEventListener("pointerdown",k)),null!==t&&(t.removeEventListener("click",_),t.removeEventListener("pointerdown",k))}))))),null}function x(e,t){const n=e.target;if(null===n||!c(n))return;const r=n.firstChild;if(null!=r&&c(r)&&("UL"===r.tagName||"OL"===r.tagName))return;const i=n.parentNode;if(!i||"check"!==i.__lexicalListType)return;const l=n.getBoundingClientRect(),o=e.pageX/u(n);("rtl"===n.dir?o<l.right&&o>l.right-20:o>l.left&&o<l.left+20)&&t()}function _(e){x(e,(()=>{const t=e.target,r=function(e){let t=e;for(;t;){if(t.__lexicalEditor)return t.__lexicalEditor;t=t.parentNode}return null}(t);null!=r&&r.isEditable()&&r.update((()=>{if(e.target){const e=m(t);n(e)&&(t.focus(),e.toggleChecked())}}))}))}function k(e){x(e,(()=>{e.preventDefault()}))}function y(){const e=document.activeElement;return null!=e&&"LI"===e.tagName&&null!=e.parentNode&&"check"===e.parentNode.__lexicalListType?e:null}function N(e,t,i){const l=y();return null!=l&&t.update((()=>{const o=m(l);if(!n(o))return;const c=function(e,t){let i=t?e.getPreviousSibling():e.getNextSibling(),l=e;for(;null==i&&n(l);)l=l.getParentOrThrow().getParent(),null!=l&&(i=t?l.getPreviousSibling():l.getNextSibling());for(;n(i);){const e=t?i.getLastChild():i.getFirstChild();if(!r(e))return i;i=t?e.getLastChild():e.getFirstChild()}return null}(o,i);if(null!=c){c.selectStart();const n=t.getElementByKey(c.__key);null!=n&&(e.preventDefault(),setTimeout((()=>{n.focus()}),0))}})),!1}export{L as CheckListPlugin};
8
+
9
+ import{INSERT_CHECK_LIST_COMMAND as e,insertList as t,$isListItemNode as n,$isListNode as r}from"@lexical/list";import{useLexicalComposerContext as i}from"@lexical/react/LexicalComposerContext";import{mergeRegister as l,$findMatchingParent as o,isHTMLElement as c,calculateZoomLevel as s}from"@lexical/utils";import{COMMAND_PRIORITY_LOW as u,KEY_ARROW_DOWN_COMMAND as a,KEY_ARROW_UP_COMMAND as g,KEY_ESCAPE_COMMAND as f,KEY_SPACE_COMMAND as d,$getNearestNodeFromDOMNode as m,KEY_ARROW_LEFT_COMMAND as p,$getSelection as C,$isRangeSelection as h,$isElementNode as v}from"lexical";import{useEffect as E}from"react";function L(){const[c]=i();return E((()=>l(c.registerCommand(e,(()=>(t(c,"check"),!0)),u),c.registerCommand(a,(e=>N(e,c,!1)),u),c.registerCommand(g,(e=>N(e,c,!0)),u),c.registerCommand(f,(e=>{if(null!=y()){const e=c.getRootElement();return null!=e&&e.focus(),!0}return!1}),u),c.registerCommand(d,(e=>{const t=y();return!(null==t||!c.isEditable())&&(c.update((()=>{const r=m(t);n(r)&&(e.preventDefault(),r.toggleChecked())})),!0)}),u),c.registerCommand(p,(e=>c.getEditorState().read((()=>{const t=C();if(h(t)&&t.isCollapsed()){const{anchor:i}=t,l="element"===i.type;if(l||0===i.offset){const t=i.getNode(),s=o(t,(e=>v(e)&&!e.isInline()));if(n(s)){const n=s.getParent();if(r(n)&&"check"===n.getListType()&&(l||s.getFirstDescendant()===t)){const t=c.getElementByKey(s.__key);if(null!=t&&document.activeElement!==t)return t.focus(),e.preventDefault(),!0}}}}return!1}))),u),c.registerRootListener(((e,t)=>{null!==e&&(e.addEventListener("click",_),e.addEventListener("pointerdown",k)),null!==t&&(t.removeEventListener("click",_),t.removeEventListener("pointerdown",k))}))))),null}function x(e,t){const n=e.target;if(null===n||!c(n))return;const r=n.firstChild;if(null!=r&&c(r)&&("UL"===r.tagName||"OL"===r.tagName))return;const i=n.parentNode;if(!i||"check"!==i.__lexicalListType)return;const l=n.getBoundingClientRect(),o=e.pageX/s(n);("rtl"===n.dir?o<l.right&&o>l.right-20:o>l.left&&o<l.left+20)&&t()}function _(e){x(e,(()=>{const t=e.target,r=function(e){let t=e;for(;t;){if(t.__lexicalEditor)return t.__lexicalEditor;t=t.parentNode}return null}(t);null!=r&&r.isEditable()&&r.update((()=>{if(e.target){const e=m(t);n(e)&&(t.focus(),e.toggleChecked())}}))})),e.stopPropagation()}function k(e){x(e,(()=>{e.preventDefault()})),e.stopPropagation()}function y(){const e=document.activeElement;return null!=e&&"LI"===e.tagName&&null!=e.parentNode&&"check"===e.parentNode.__lexicalListType?e:null}function N(e,t,i){const l=y();return null!=l&&t.update((()=>{const o=m(l);if(!n(o))return;const c=function(e,t){let i=t?e.getPreviousSibling():e.getNextSibling(),l=e;for(;null==i&&n(l);)l=l.getParentOrThrow().getParent(),null!=l&&(i=t?l.getPreviousSibling():l.getNextSibling());for(;n(i);){const e=t?i.getLastChild():i.getFirstChild();if(!r(e))return i;i=t?e.getLastChild():e.getFirstChild()}return null}(o,i);if(null!=c){c.selectStart();const n=t.getElementByKey(c.__key);null!=n&&(e.preventDefault(),setTimeout((()=>{n.focus()}),0))}})),!1}export{L as CheckListPlugin};
@@ -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');
@@ -27,8 +29,12 @@ 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
  */
32
+
33
+
34
+ // This workaround is no longer necessary in React 19,
35
+ // but we currently support React >=17.x
36
+ // https://github.com/facebook/react/pull/26395
30
37
  const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
31
- var useLayoutEffect = useLayoutEffectImpl;
32
38
 
33
39
  /**
34
40
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -37,11 +43,12 @@ var useLayoutEffect = useLayoutEffectImpl;
37
43
  * LICENSE file in the root directory of this source tree.
38
44
  *
39
45
  */
46
+
40
47
  function ClearEditorPlugin({
41
48
  onClear
42
49
  }) {
43
50
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
44
- useLayoutEffect(() => {
51
+ useLayoutEffectImpl(() => {
45
52
  return editor.registerCommand(lexical.CLEAR_EDITOR_COMMAND, payload => {
46
53
  editor.update(() => {
47
54
  if (onClear == null) {