@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,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 { CLEAR_EDITOR_COMMAND, $getRoot, $getSelection, $createParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical';
9
- import { useLayoutEffect as useLayoutEffect$1, useEffect } from 'react';
11
+ import { useLayoutEffect, useEffect } from 'react';
10
12
 
11
13
  /**
12
14
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -25,8 +27,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
25
27
  * LICENSE file in the root directory of this source tree.
26
28
  *
27
29
  */
28
- const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect$1 : useEffect;
29
- var useLayoutEffect = useLayoutEffectImpl;
30
+
31
+
32
+ // This workaround is no longer necessary in React 19,
33
+ // but we currently support React >=17.x
34
+ // https://github.com/facebook/react/pull/26395
35
+ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
30
36
 
31
37
  /**
32
38
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -35,11 +41,12 @@ var useLayoutEffect = useLayoutEffectImpl;
35
41
  * LICENSE file in the root directory of this source tree.
36
42
  *
37
43
  */
44
+
38
45
  function ClearEditorPlugin({
39
46
  onClear
40
47
  }) {
41
48
  const [editor] = useLexicalComposerContext();
42
- useLayoutEffect(() => {
49
+ useLayoutEffectImpl(() => {
43
50
  return editor.registerCommand(CLEAR_EDITOR_COMMAND, payload => {
44
51
  editor.update(() => {
45
52
  if (onClear == null) {
@@ -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 LexicalClearEditorPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalClearEditorPlugin.dev.js') : require('./LexicalClearEditorPlugin.prod.js');
9
11
  module.exports = LexicalClearEditorPlugin;
@@ -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 './LexicalClearEditorPlugin.dev.mjs';
8
10
  import * as modProd from './LexicalClearEditorPlugin.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('./LexicalClearEditorPlugin.dev.mjs') : import('./LexicalClearEditorPlugin.prod.mjs'));
8
10
  export const ClearEditorPlugin = mod.ClearEditorPlugin;
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- 'use strict';var a=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),h=require("react"),k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
8
+
9
+ 'use strict';var a=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),h=require("react");let k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
8
10
  exports.ClearEditorPlugin=function({onClear:b}){let [c]=a.useLexicalComposerContext();k(()=>c.registerCommand(e.CLEAR_EDITOR_COMMAND,()=>{c.update(()=>{if(null==b){let f=e.$getRoot(),d=e.$getSelection(),g=e.$createParagraphNode();f.clear();f.append(g);null!==d&&g.select();e.$isRangeSelection(d)&&(d.format=0)}else b()});return!0},e.COMMAND_PRIORITY_EDITOR),[c,b]);return null}
@@ -3,5 +3,7 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{CLEAR_EDITOR_COMMAND as o,$getRoot as t,$getSelection as n,$createParagraphNode as r,$isRangeSelection as l,COMMAND_PRIORITY_EDITOR as a}from"lexical";import{useLayoutEffect as i,useEffect as c}from"react";var m="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?i:c;function d({onClear:i}){const[c]=e();return m((()=>c.registerCommand(o,(e=>(c.update((()=>{if(null==i){const e=t(),o=n(),a=r();e.clear(),e.append(a),null!==o&&a.select(),l(o)&&(o.format=0)}else i()})),!0)),a)),[c,i]),null}export{d as ClearEditorPlugin};
8
+
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{CLEAR_EDITOR_COMMAND as o,$getRoot as t,$getSelection as n,$createParagraphNode as r,$isRangeSelection as l,COMMAND_PRIORITY_EDITOR as i}from"lexical";import{useLayoutEffect as c,useEffect as m}from"react";const a="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?c:m;function d({onClear:c}){const[m]=e();return a((()=>m.registerCommand(o,(e=>(m.update((()=>{if(null==c){const e=t(),o=n(),i=r();e.clear(),e.append(i),null!==o&&i.select(),l(o)&&(o.format=0)}else c()})),!0)),i)),[m,c]),null}export{d as ClearEditorPlugin};
@@ -5,7 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export default function LexicalClickableLinkPlugin({ newTab, disabled, }: {
8
+ export declare function ClickableLinkPlugin({ newTab, disabled, }: {
9
9
  newTab?: boolean;
10
10
  disabled?: boolean;
11
11
  }): null;
12
+ /** @deprecated use the named export {@link ClickableLinkPlugin} */
13
+ export default ClickableLinkPlugin;
@@ -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 link = require('@lexical/link');
@@ -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 findMatchingDOM(startNode, predicate) {
23
26
  let node = startNode;
24
27
  while (node != null) {
@@ -29,17 +32,13 @@ function findMatchingDOM(startNode, predicate) {
29
32
  }
30
33
  return null;
31
34
  }
32
- function LexicalClickableLinkPlugin({
35
+ function ClickableLinkPlugin({
33
36
  newTab = true,
34
37
  disabled = false
35
38
  }) {
36
39
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
37
40
  react.useEffect(() => {
38
41
  const onClick = event => {
39
- if (disabled) {
40
- event.preventDefault();
41
- return;
42
- }
43
42
  const target = event.target;
44
43
  if (!(target instanceof Node)) {
45
44
  return;
@@ -54,14 +53,16 @@ function LexicalClickableLinkPlugin({
54
53
  const clickedNode = lexical.$getNearestNodeFromDOMNode(target);
55
54
  if (clickedNode !== null) {
56
55
  const maybeLinkNode = utils.$findMatchingParent(clickedNode, lexical.$isElementNode);
57
- if (link.$isLinkNode(maybeLinkNode)) {
58
- url = maybeLinkNode.sanitizeUrl(maybeLinkNode.getURL());
59
- urlTarget = maybeLinkNode.getTarget();
60
- } else {
61
- const a = findMatchingDOM(target, utils.isHTMLAnchorElement);
62
- if (a !== null) {
63
- url = a.href;
64
- urlTarget = a.target;
56
+ if (!disabled) {
57
+ if (link.$isLinkNode(maybeLinkNode)) {
58
+ url = maybeLinkNode.sanitizeUrl(maybeLinkNode.getURL());
59
+ urlTarget = maybeLinkNode.getTarget();
60
+ } else {
61
+ const a = findMatchingDOM(target, utils.isHTMLAnchorElement);
62
+ if (a !== null) {
63
+ url = a.href;
64
+ urlTarget = a.target;
65
+ }
65
66
  }
66
67
  }
67
68
  }
@@ -81,7 +82,7 @@ function LexicalClickableLinkPlugin({
81
82
  event.preventDefault();
82
83
  };
83
84
  const onMouseUp = event => {
84
- if (!disabled && event.button === 1) {
85
+ if (event.button === 1) {
85
86
  onClick(event);
86
87
  }
87
88
  };
@@ -99,4 +100,5 @@ function LexicalClickableLinkPlugin({
99
100
  return null;
100
101
  }
101
102
 
102
- module.exports = LexicalClickableLinkPlugin;
103
+ exports.ClickableLinkPlugin = ClickableLinkPlugin;
104
+ exports.default = ClickableLinkPlugin;
@@ -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 { $isLinkNode } from '@lexical/link';
8
10
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
9
11
  import { $findMatchingParent, isHTMLAnchorElement } 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 findMatchingDOM(startNode, predicate) {
21
24
  let node = startNode;
22
25
  while (node != null) {
@@ -27,17 +30,13 @@ function findMatchingDOM(startNode, predicate) {
27
30
  }
28
31
  return null;
29
32
  }
30
- function LexicalClickableLinkPlugin({
33
+ function ClickableLinkPlugin({
31
34
  newTab = true,
32
35
  disabled = false
33
36
  }) {
34
37
  const [editor] = useLexicalComposerContext();
35
38
  useEffect(() => {
36
39
  const onClick = event => {
37
- if (disabled) {
38
- event.preventDefault();
39
- return;
40
- }
41
40
  const target = event.target;
42
41
  if (!(target instanceof Node)) {
43
42
  return;
@@ -52,14 +51,16 @@ function LexicalClickableLinkPlugin({
52
51
  const clickedNode = $getNearestNodeFromDOMNode(target);
53
52
  if (clickedNode !== null) {
54
53
  const maybeLinkNode = $findMatchingParent(clickedNode, $isElementNode);
55
- if ($isLinkNode(maybeLinkNode)) {
56
- url = maybeLinkNode.sanitizeUrl(maybeLinkNode.getURL());
57
- urlTarget = maybeLinkNode.getTarget();
58
- } else {
59
- const a = findMatchingDOM(target, isHTMLAnchorElement);
60
- if (a !== null) {
61
- url = a.href;
62
- urlTarget = a.target;
54
+ if (!disabled) {
55
+ if ($isLinkNode(maybeLinkNode)) {
56
+ url = maybeLinkNode.sanitizeUrl(maybeLinkNode.getURL());
57
+ urlTarget = maybeLinkNode.getTarget();
58
+ } else {
59
+ const a = findMatchingDOM(target, isHTMLAnchorElement);
60
+ if (a !== null) {
61
+ url = a.href;
62
+ urlTarget = a.target;
63
+ }
63
64
  }
64
65
  }
65
66
  }
@@ -79,7 +80,7 @@ function LexicalClickableLinkPlugin({
79
80
  event.preventDefault();
80
81
  };
81
82
  const onMouseUp = event => {
82
- if (!disabled && event.button === 1) {
83
+ if (event.button === 1) {
83
84
  onClick(event);
84
85
  }
85
86
  };
@@ -97,4 +98,4 @@ function LexicalClickableLinkPlugin({
97
98
  return null;
98
99
  }
99
100
 
100
- export { LexicalClickableLinkPlugin as default };
101
+ export { ClickableLinkPlugin, ClickableLinkPlugin as default };
@@ -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 LexicalClickableLinkPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalClickableLinkPlugin.dev.js') : require('./LexicalClickableLinkPlugin.prod.js');
9
11
  module.exports = LexicalClickableLinkPlugin;
@@ -7,6 +7,8 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- declare export function MLCClickableLinkPlugin({
10
+ declare export function ClickableLinkPlugin({
11
11
  newTab?: boolean,
12
12
  }): null;
13
+
14
+ declare export default typeof ClickableLinkPlugin;
@@ -3,8 +3,11 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import * as modDev from './LexicalClickableLinkPlugin.dev.mjs';
8
10
  import * as modProd from './LexicalClickableLinkPlugin.prod.mjs';
9
11
  const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
12
+ export const ClickableLinkPlugin = mod.ClickableLinkPlugin;
10
13
  export default mod.default;
@@ -3,6 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalClickableLinkPlugin.dev.mjs') : import('./LexicalClickableLinkPlugin.prod.mjs'));
10
+ export const ClickableLinkPlugin = mod.ClickableLinkPlugin;
8
11
  export default mod.default;
@@ -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 e=require("@lexical/link"),n=require("@lexical/react/LexicalComposerContext"),r=require("@lexical/utils"),t=require("lexical"),u=require("react");
8
- module.exports=function({newTab:p=!0,disabled:h=!1}){let [k]=n.useLexicalComposerContext();u.useEffect(()=>{let m=a=>{if(h)a.preventDefault();else{var c=a.target;if(c instanceof Node){var d=t.getNearestEditorFromDOMNode(c);if(null!==d){var f=null,l=null;d.update(()=>{var b=t.$getNearestNodeFromDOMNode(c);if(null!==b)if(b=r.$findMatchingParent(b,t.$isElementNode),e.$isLinkNode(b))f=b.sanitizeUrl(b.getURL()),l=b.getTarget();else{a:{b=r.isHTMLAnchorElement;let g=c;for(;null!=g;){if(b(g)){b=g;break a}g=
9
- g.parentNode}b=null}null!==b&&(f=b.href,l=b.target)}});if(null!==f&&""!==f){d=k.getEditorState().read(t.$getSelection);if(!t.$isRangeSelection(d)||d.isCollapsed())d="auxclick"===a.type&&1===a.button,window.open(f,p||d||a.metaKey||a.ctrlKey||"_blank"===l?"_blank":"_self");a.preventDefault()}}}}},q=a=>{h||1!==a.button||m(a)};return k.registerRootListener((a,c)=>{null!==c&&(c.removeEventListener("click",m),c.removeEventListener("mouseup",q));null!==a&&(a.addEventListener("click",m),a.addEventListener("mouseup",
10
- q))})},[k,p,h]);return null}
8
+
9
+ 'use strict';var e=require("@lexical/link"),m=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),t=require("lexical"),u=require("react");
10
+ function v({newTab:p=!0,disabled:q=!1}){let [h]=m.useLexicalComposerContext();u.useEffect(()=>{let l=b=>{const c=b.target;if(c instanceof Node){var d=t.getNearestEditorFromDOMNode(c);if(null!==d){var f=null,k=null;d.update(()=>{var a=t.$getNearestNodeFromDOMNode(c);if(null!==a&&(a=n.$findMatchingParent(a,t.$isElementNode),!q))if(e.$isLinkNode(a))f=a.sanitizeUrl(a.getURL()),k=a.getTarget();else{a:{a=n.isHTMLAnchorElement;let g=c;for(;null!=g;){if(a(g)){a=g;break a}g=g.parentNode}a=null}null!==a&&(f=
11
+ a.href,k=a.target)}});if(null!==f&&""!==f){d=h.getEditorState().read(t.$getSelection);if(!t.$isRangeSelection(d)||d.isCollapsed())d="auxclick"===b.type&&1===b.button,window.open(f,p||d||b.metaKey||b.ctrlKey||"_blank"===k?"_blank":"_self");b.preventDefault()}}}},r=b=>{1===b.button&&l(b)};return h.registerRootListener((b,c)=>{null!==c&&(c.removeEventListener("click",l),c.removeEventListener("mouseup",r));null!==b&&(b.addEventListener("click",l),b.addEventListener("mouseup",r))})},[h,p,q]);return null}
12
+ exports.ClickableLinkPlugin=v;exports.default=v
@@ -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{$isLinkNode as e}from"@lexical/link";import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as n,isHTMLAnchorElement as r}from"@lexical/utils";import{getNearestEditorFromDOMNode as l,$getNearestNodeFromDOMNode as o,$isElementNode as i,$getSelection as u,$isRangeSelection as a}from"lexical";import{useEffect as s}from"react";function c({newTab:c=!0,disabled:f=!1}){const[p]=t();return s((()=>{const t=t=>{if(f)return void t.preventDefault();const s=t.target;if(!(s instanceof Node))return;const d=l(s);if(null===d)return;let m=null,v=null;if(d.update((()=>{const t=o(s);if(null!==t){const l=n(t,i);if(e(l))m=l.sanitizeUrl(l.getURL()),v=l.getTarget();else{const e=function(e,t){let n=e;for(;null!=n;){if(t(n))return n;n=n.parentNode}return null}(s,r);null!==e&&(m=e.href,v=e.target)}}})),null===m||""===m)return;const x=p.getEditorState().read(u);if(a(x)&&!x.isCollapsed())return void t.preventDefault();const g="auxclick"===t.type&&1===t.button;window.open(m,c||g||t.metaKey||t.ctrlKey||"_blank"===v?"_blank":"_self"),t.preventDefault()},s=e=>{f||1!==e.button||t(e)};return p.registerRootListener(((e,n)=>{null!==n&&(n.removeEventListener("click",t),n.removeEventListener("mouseup",s)),null!==e&&(e.addEventListener("click",t),e.addEventListener("mouseup",s))}))}),[p,c,f]),null}export{c as default};
8
+
9
+ import{$isLinkNode as e}from"@lexical/link";import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as n,isHTMLAnchorElement as r}from"@lexical/utils";import{getNearestEditorFromDOMNode as l,$getNearestNodeFromDOMNode as o,$isElementNode as i,$getSelection as u,$isRangeSelection as a}from"lexical";import{useEffect as s}from"react";function c({newTab:c=!0,disabled:f=!1}){const[m]=t();return s((()=>{const t=t=>{const s=t.target;if(!(s instanceof Node))return;const p=l(s);if(null===p)return;let d=null,v=null;if(p.update((()=>{const t=o(s);if(null!==t){const l=n(t,i);if(!f)if(e(l))d=l.sanitizeUrl(l.getURL()),v=l.getTarget();else{const e=function(e,t){let n=e;for(;null!=n;){if(t(n))return n;n=n.parentNode}return null}(s,r);null!==e&&(d=e.href,v=e.target)}}})),null===d||""===d)return;const x=m.getEditorState().read(u);if(a(x)&&!x.isCollapsed())return void t.preventDefault();const g="auxclick"===t.type&&1===t.button;window.open(d,c||g||t.metaKey||t.ctrlKey||"_blank"===v?"_blank":"_self"),t.preventDefault()},s=e=>{1===e.button&&t(e)};return m.registerRootListener(((e,n)=>{null!==n&&(n.removeEventListener("click",t),n.removeEventListener("mouseup",s)),null!==e&&(e.addEventListener("click",t),e.addEventListener("mouseup",s))}))}),[m,c,f]),null}export{c as ClickableLinkPlugin,c as default};
@@ -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 react = require('react');
@@ -15,6 +17,7 @@ var react = require('react');
15
17
  * LICENSE file in the root directory of this source tree.
16
18
  *
17
19
  */
20
+
18
21
  const entries = [['Cat', 'rgb(125, 50, 0)'], ['Dog', 'rgb(100, 0, 0)'], ['Rabbit', 'rgb(150, 0, 0)'], ['Frog', 'rgb(200, 0, 0)'], ['Fox', 'rgb(200, 75, 0)'], ['Hedgehog', 'rgb(0, 75, 0)'], ['Pigeon', 'rgb(0, 125, 0)'], ['Squirrel', 'rgb(75, 100, 0)'], ['Bear', 'rgb(125, 100, 0)'], ['Tiger', 'rgb(0, 0, 150)'], ['Leopard', 'rgb(0, 0, 200)'], ['Zebra', 'rgb(0, 0, 250)'], ['Wolf', 'rgb(0, 100, 150)'], ['Owl', 'rgb(0, 100, 100)'], ['Gull', 'rgb(100, 0, 100)'], ['Squid', 'rgb(150, 0, 150)']];
19
22
  const randomEntry = entries[Math.floor(Math.random() * entries.length)];
20
23
  const CollaborationContext = /*#__PURE__*/react.createContext({
@@ -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 { createContext, useContext } from 'react';
8
10
 
9
11
  /**
@@ -13,6 +15,7 @@ import { createContext, useContext } from 'react';
13
15
  * LICENSE file in the root directory of this source tree.
14
16
  *
15
17
  */
18
+
16
19
  const entries = [['Cat', 'rgb(125, 50, 0)'], ['Dog', 'rgb(100, 0, 0)'], ['Rabbit', 'rgb(150, 0, 0)'], ['Frog', 'rgb(200, 0, 0)'], ['Fox', 'rgb(200, 75, 0)'], ['Hedgehog', 'rgb(0, 75, 0)'], ['Pigeon', 'rgb(0, 125, 0)'], ['Squirrel', 'rgb(75, 100, 0)'], ['Bear', 'rgb(125, 100, 0)'], ['Tiger', 'rgb(0, 0, 150)'], ['Leopard', 'rgb(0, 0, 200)'], ['Zebra', 'rgb(0, 0, 250)'], ['Wolf', 'rgb(0, 100, 150)'], ['Owl', 'rgb(0, 100, 100)'], ['Gull', 'rgb(100, 0, 100)'], ['Squid', 'rgb(150, 0, 150)']];
17
20
  const randomEntry = entries[Math.floor(Math.random() * entries.length)];
18
21
  const CollaborationContext = /*#__PURE__*/createContext({
@@ -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 LexicalCollaborationContext = process.env.NODE_ENV === 'development' ? require('./LexicalCollaborationContext.dev.js') : require('./LexicalCollaborationContext.prod.js');
9
11
  module.exports = LexicalCollaborationContext;
@@ -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 './LexicalCollaborationContext.dev.mjs';
8
10
  import * as modProd from './LexicalCollaborationContext.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('./LexicalCollaborationContext.dev.mjs') : import('./LexicalCollaborationContext.prod.mjs'));
8
10
  export const CollaborationContext = mod.CollaborationContext;
9
11
  export const useCollaborationContext = mod.useCollaborationContext;
@@ -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';var b=require("react");
8
10
  let c=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],d=c[Math.floor(Math.random()*c.length)],e=b.createContext({clientID:0,
9
11
  color:d[1],isCollabActive:!1,name:d[0],yjsDocMap:new Map});exports.CollaborationContext=e;exports.useCollaborationContext=function(f,g){let a=b.useContext(e);null!=f&&(a.name=f);null!=g&&(a.color=g);return a}
@@ -3,5 +3,7 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import{createContext as r,useContext as g}from"react";const o=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],b=o[Math.floor(Math.random()*o.length)],e=r({clientID:0,color:b[1],isCollabActive:!1,name:b[0],yjsDocMap:new Map});function l(r,o){const b=g(e);return null!=r&&(b.name=r),null!=o&&(b.color=o),b}export{e as CollaborationContext,l as useCollaborationContext};
@@ -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 LexicalCollaborationContext = require('@lexical/react/LexicalCollaborationContext');
@@ -14,6 +16,20 @@ var yjs = require('@lexical/yjs');
14
16
  var lexical = require('lexical');
15
17
  var reactDom = require('react-dom');
16
18
  var yjs$1 = require('yjs');
19
+ var jsxRuntime = require('react/jsx-runtime');
20
+
21
+ function _interopNamespaceDefault(e) {
22
+ var n = Object.create(null);
23
+ if (e) {
24
+ for (var k in e) {
25
+ n[k] = e[k];
26
+ }
27
+ }
28
+ n.default = e;
29
+ return n;
30
+ }
31
+
32
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
17
33
 
18
34
  /**
19
35
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -22,6 +38,7 @@ var yjs$1 = require('yjs');
22
38
  * LICENSE file in the root directory of this source tree.
23
39
  *
24
40
  */
41
+
25
42
  function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBootstrap, cursorsContainerRef, initialEditorState, excludedProperties, awarenessData) {
26
43
  const isReloadingDoc = React.useRef(false);
27
44
  const [doc, setDoc] = React.useState(docMap.get(id));
@@ -107,7 +124,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
107
124
  const ref = element => {
108
125
  binding.cursorsContainer = element;
109
126
  };
110
- return /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React.createElement("div", {
127
+ return /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/jsxRuntime.jsx("div", {
111
128
  ref: ref
112
129
  }), cursorsContainerRef && cursorsContainerRef.current || document.body);
113
130
  }, [binding, cursorsContainerRef]);
@@ -163,7 +180,7 @@ function useYjsHistory(editor, binding) {
163
180
  }, [undoManager]);
164
181
 
165
182
  // Exposing undo and redo states
166
- React.useEffect(() => {
183
+ React__namespace.useEffect(() => {
167
184
  const updateUndoRedoStates = () => {
168
185
  editor.dispatchCommand(lexical.CAN_UNDO_COMMAND, undoManager.undoStack.length > 0);
169
186
  editor.dispatchCommand(lexical.CAN_REDO_COMMAND, undoManager.redoStack.length > 0);
@@ -270,6 +287,7 @@ function clearEditorSkipCollab(editor, binding) {
270
287
  * LICENSE file in the root directory of this source tree.
271
288
  *
272
289
  */
290
+
273
291
  function CollaborationPlugin({
274
292
  id,
275
293
  providerFactory,
@@ -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 { useCollaborationContext } from '@lexical/react/LexicalCollaborationContext';
8
10
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
9
11
  import * as React from 'react';
@@ -13,6 +15,7 @@ import { createBinding, initLocalState, syncLexicalUpdateToYjs, TOGGLE_CONNECT_C
13
15
  import { COMMAND_PRIORITY_EDITOR, FOCUS_COMMAND, BLUR_COMMAND, UNDO_COMMAND, REDO_COMMAND, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $getRoot, $createParagraphNode, $getSelection } from 'lexical';
14
16
  import { createPortal } from 'react-dom';
15
17
  import { UndoManager } from 'yjs';
18
+ import { jsx } from 'react/jsx-runtime';
16
19
 
17
20
  /**
18
21
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -21,6 +24,7 @@ import { UndoManager } from 'yjs';
21
24
  * LICENSE file in the root directory of this source tree.
22
25
  *
23
26
  */
27
+
24
28
  function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBootstrap, cursorsContainerRef, initialEditorState, excludedProperties, awarenessData) {
25
29
  const isReloadingDoc = useRef(false);
26
30
  const [doc, setDoc] = useState(docMap.get(id));
@@ -106,7 +110,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
106
110
  const ref = element => {
107
111
  binding.cursorsContainer = element;
108
112
  };
109
- return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", {
113
+ return /*#__PURE__*/createPortal( /*#__PURE__*/jsx("div", {
110
114
  ref: ref
111
115
  }), cursorsContainerRef && cursorsContainerRef.current || document.body);
112
116
  }, [binding, cursorsContainerRef]);
@@ -269,6 +273,7 @@ function clearEditorSkipCollab(editor, binding) {
269
273
  * LICENSE file in the root directory of this source tree.
270
274
  *
271
275
  */
276
+
272
277
  function CollaborationPlugin({
273
278
  id,
274
279
  providerFactory,
@@ -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 LexicalCollaborationPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalCollaborationPlugin.dev.js') : require('./LexicalCollaborationPlugin.prod.js');
9
11
  module.exports = LexicalCollaborationPlugin;
@@ -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 './LexicalCollaborationPlugin.dev.mjs';
8
10
  import * as modProd from './LexicalCollaborationPlugin.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('./LexicalCollaborationPlugin.dev.mjs') : import('./LexicalCollaborationPlugin.prod.mjs'));
8
10
  export const CollaborationPlugin = mod.CollaborationPlugin;
@@ -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
  */
7
- 'use strict';var f=require("@lexical/react/LexicalCollaborationContext"),g=require("@lexical/react/LexicalComposerContext"),k=require("react"),B=require("@lexical/utils"),J=require("@lexical/yjs"),K=require("lexical"),L=require("react-dom"),M=require("yjs");
8
- function N(b,c,a,d,e,z,A,v,w,n,t){let q=k.useRef(!1),[x,r]=k.useState(d.get(c)),h=k.useMemo(()=>J.createBinding(b,a,c,x,d,n),[b,a,c,d,x,n]),p=k.useCallback(()=>{a.connect()},[a]),y=k.useCallback(()=>{try{a.disconnect()}catch(m){}},[a]);k.useEffect(()=>{let {root:m}=h,{awareness:C}=a,D=({status:l})=>{b.dispatchCommand(J.CONNECTED_COMMAND,"connected"===l)},E=l=>{A&&l&&m.isEmpty()&&0===m._xmlText._length&&!1===q.current&&O(b,w);q.current=!1},F=()=>{J.syncCursorPositions(h,a)},G=(l,u)=>{u=u.origin;u!==
9
- h&&J.syncYjsChangesToLexical(h,a,l,u instanceof M.UndoManager)};J.initLocalState(a,e,z,document.activeElement===b.getRootElement(),t||{});let H=l=>{P(b,h);r(l);d.set(c,l);q.current=!0};a.on("reload",H);a.on("status",D);a.on("sync",E);C.on("update",F);m.getSharedType().observeDeep(G);let T=b.registerUpdateListener(({prevEditorState:l,editorState:u,dirtyLeaves:Q,dirtyElements:R,normalizedNodes:S,tags:I})=>{!1===I.has("skip-collab")&&J.syncLexicalUpdateToYjs(h,a,l,u,R,Q,S,I)});p();return()=>{!1===q.current&&
10
- y();a.off("sync",E);a.off("status",D);a.off("reload",H);C.off("update",F);m.getSharedType().unobserveDeep(G);d.delete(c);T()}},[h,z,p,y,d,b,c,w,e,a,A,t]);let U=k.useMemo(()=>L.createPortal(k.createElement("div",{ref:m=>{h.cursorsContainer=m}}),v&&v.current||document.body),[h,v]);k.useEffect(()=>b.registerCommand(J.TOGGLE_CONNECT_COMMAND,m=>{void 0!==p&&void 0!==y&&(m?(console.log("Collaboration connected!"),p()):(console.log("Collaboration disconnected!"),y()));return!0},K.COMMAND_PRIORITY_EDITOR),
11
- [p,y,b]);return[U,h]}function V(b,c,a,d,e){k.useEffect(()=>B.mergeRegister(b.registerCommand(K.FOCUS_COMMAND,()=>{J.setLocalStateFocus(c,a,d,!0,e||{});return!1},K.COMMAND_PRIORITY_EDITOR),b.registerCommand(K.BLUR_COMMAND,()=>{J.setLocalStateFocus(c,a,d,!1,e||{});return!1},K.COMMAND_PRIORITY_EDITOR)),[d,b,a,c,e])}
12
- function W(b,c){let a=k.useMemo(()=>J.createUndoManager(c,c.root.getSharedType()),[c]);k.useEffect(()=>B.mergeRegister(b.registerCommand(K.UNDO_COMMAND,()=>{a.undo();return!0},K.COMMAND_PRIORITY_EDITOR),b.registerCommand(K.REDO_COMMAND,()=>{a.redo();return!0},K.COMMAND_PRIORITY_EDITOR)));let d=k.useCallback(()=>{a.clear()},[a]);k.useEffect(()=>{let e=()=>{b.dispatchCommand(K.CAN_UNDO_COMMAND,0<a.undoStack.length);b.dispatchCommand(K.CAN_REDO_COMMAND,0<a.redoStack.length)};a.on("stack-item-added",
13
- e);a.on("stack-item-popped",e);a.on("stack-cleared",e);return()=>{a.off("stack-item-added",e);a.off("stack-item-popped",e);a.off("stack-cleared",e)}},[b,a]);return d}
14
- function O(b,c){b.update(()=>{var a=K.$getRoot();if(a.isEmpty())if(c)switch(typeof c){case "string":var d=b.parseEditorState(c);b.setEditorState(d,{tag:"history-merge"});break;case "object":b.setEditorState(c,{tag:"history-merge"});break;case "function":b.update(()=>{K.$getRoot().isEmpty()&&c(b)},{tag:"history-merge"})}else d=K.$createParagraphNode(),a.append(d),{activeElement:a}=document,(null!==K.$getSelection()||null!==a&&a===b.getRootElement())&&d.select()},{tag:"history-merge"})}
15
- function P(b,c){b.update(()=>{let d=K.$getRoot();d.clear();d.select()},{tag:"skip-collab"});if(null!=c.cursors&&(b=c.cursors,null!=b&&(c=c.cursorsContainer,null!=c))){b=Array.from(b.values());for(let d=0;d<b.length;d++){var a=b[d].selection;if(a&&null!=a.selections){a=a.selections;for(let e=0;e<a.length;e++)c.removeChild(a[d])}}}}
16
- exports.CollaborationPlugin=function({id:b,providerFactory:c,shouldBootstrap:a,username:d,cursorColor:e,cursorsContainerRef:z,initialEditorState:A,excludedProperties:v,awarenessData:w}){let n=f.useCollaborationContext(d,e),{yjsDocMap:t,name:q,color:x}=n,[r]=g.useLexicalComposerContext();k.useEffect(()=>{n.isCollabActive=!0;return()=>{null==r._parentEditor&&(n.isCollabActive=!1)}},[n,r]);d=k.useMemo(()=>c(b,t),[b,c,t]);let [h,p]=N(r,b,d,t,q,x,a,z,A,v,w);n.clientID=p.clientID;W(r,p);V(r,d,q,x,w);return h}
8
+
9
+ 'use strict';var e=require("@lexical/react/LexicalCollaborationContext"),g=require("@lexical/react/LexicalComposerContext"),k=require("react"),B=require("@lexical/utils"),C=require("@lexical/yjs"),D=require("lexical"),L=require("react-dom"),M=require("yjs"),N=require("react/jsx-runtime"),O=Object.create(null);if(k)for(var P in k)O[P]=k[P];O.default=k;
10
+ function Q(b,c,a,d,f,z,A,v,w,n,t){let q=k.useRef(!1),[x,r]=k.useState(d.get(c)),h=k.useMemo(()=>C.createBinding(b,a,c,x,d,n),[b,a,c,d,x,n]),p=k.useCallback(()=>{a.connect()},[a]),y=k.useCallback(()=>{try{a.disconnect()}catch(m){}},[a]);k.useEffect(()=>{let {root:m}=h,{awareness:E}=a,F=({status:l})=>{b.dispatchCommand(C.CONNECTED_COMMAND,"connected"===l)},G=l=>{A&&l&&m.isEmpty()&&0===m._xmlText._length&&!1===q.current&&R(b,w);q.current=!1},H=()=>{C.syncCursorPositions(h,a)},I=(l,u)=>{u=u.origin;u!==
11
+ h&&C.syncYjsChangesToLexical(h,a,l,u instanceof M.UndoManager)};C.initLocalState(a,f,z,document.activeElement===b.getRootElement(),t||{});let J=l=>{S(b,h);r(l);d.set(c,l);q.current=!0};a.on("reload",J);a.on("status",F);a.on("sync",G);E.on("update",H);m.getSharedType().observeDeep(I);let W=b.registerUpdateListener(({prevEditorState:l,editorState:u,dirtyLeaves:T,dirtyElements:U,normalizedNodes:V,tags:K})=>{!1===K.has("skip-collab")&&C.syncLexicalUpdateToYjs(h,a,l,u,U,T,V,K)});p();return()=>{!1===q.current&&
12
+ y();a.off("sync",G);a.off("status",F);a.off("reload",J);E.off("update",H);m.getSharedType().unobserveDeep(I);d.delete(c);W()}},[h,z,p,y,d,b,c,w,f,a,A,t]);let X=k.useMemo(()=>L.createPortal(N.jsx("div",{ref:m=>{h.cursorsContainer=m}}),v&&v.current||document.body),[h,v]);k.useEffect(()=>b.registerCommand(C.TOGGLE_CONNECT_COMMAND,m=>{void 0!==p&&void 0!==y&&(m?(console.log("Collaboration connected!"),p()):(console.log("Collaboration disconnected!"),y()));return!0},D.COMMAND_PRIORITY_EDITOR),[p,y,b]);
13
+ return[X,h]}function Y(b,c,a,d,f){k.useEffect(()=>B.mergeRegister(b.registerCommand(D.FOCUS_COMMAND,()=>{C.setLocalStateFocus(c,a,d,!0,f||{});return!1},D.COMMAND_PRIORITY_EDITOR),b.registerCommand(D.BLUR_COMMAND,()=>{C.setLocalStateFocus(c,a,d,!1,f||{});return!1},D.COMMAND_PRIORITY_EDITOR)),[d,b,a,c,f])}
14
+ function Z(b,c){let a=k.useMemo(()=>C.createUndoManager(c,c.root.getSharedType()),[c]);k.useEffect(()=>B.mergeRegister(b.registerCommand(D.UNDO_COMMAND,()=>{a.undo();return!0},D.COMMAND_PRIORITY_EDITOR),b.registerCommand(D.REDO_COMMAND,()=>{a.redo();return!0},D.COMMAND_PRIORITY_EDITOR)));let d=k.useCallback(()=>{a.clear()},[a]);O.useEffect(()=>{let f=()=>{b.dispatchCommand(D.CAN_UNDO_COMMAND,0<a.undoStack.length);b.dispatchCommand(D.CAN_REDO_COMMAND,0<a.redoStack.length)};a.on("stack-item-added",
15
+ f);a.on("stack-item-popped",f);a.on("stack-cleared",f);return()=>{a.off("stack-item-added",f);a.off("stack-item-popped",f);a.off("stack-cleared",f)}},[b,a]);return d}
16
+ function R(b,c){b.update(()=>{var a=D.$getRoot();if(a.isEmpty())if(c)switch(typeof c){case "string":var d=b.parseEditorState(c);b.setEditorState(d,{tag:"history-merge"});break;case "object":b.setEditorState(c,{tag:"history-merge"});break;case "function":b.update(()=>{D.$getRoot().isEmpty()&&c(b)},{tag:"history-merge"})}else d=D.$createParagraphNode(),a.append(d),{activeElement:a}=document,(null!==D.$getSelection()||null!==a&&a===b.getRootElement())&&d.select()},{tag:"history-merge"})}
17
+ function S(b,c){b.update(()=>{let d=D.$getRoot();d.clear();d.select()},{tag:"skip-collab"});if(null!=c.cursors&&(b=c.cursors,null!=b&&(c=c.cursorsContainer,null!=c))){b=Array.from(b.values());for(let d=0;d<b.length;d++){var a=b[d].selection;if(a&&null!=a.selections){a=a.selections;for(let f=0;f<a.length;f++)c.removeChild(a[d])}}}}
18
+ exports.CollaborationPlugin=function({id:b,providerFactory:c,shouldBootstrap:a,username:d,cursorColor:f,cursorsContainerRef:z,initialEditorState:A,excludedProperties:v,awarenessData:w}){let n=e.useCollaborationContext(d,f),{yjsDocMap:t,name:q,color:x}=n,[r]=g.useLexicalComposerContext();k.useEffect(()=>{n.isCollabActive=!0;return()=>{null==r._parentEditor&&(n.isCollabActive=!1)}},[n,r]);d=k.useMemo(()=>c(b,t),[b,c,t]);let [h,p]=Q(r,b,d,t,q,x,a,z,A,v,w);n.clientID=p.clientID;Z(r,p);Y(r,d,q,x,w);return h}