@lexical/react 0.13.1 → 0.14.1

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 (179) hide show
  1. package/LexicalAutoEmbedPlugin.dev.esm.js +131 -0
  2. package/LexicalAutoEmbedPlugin.esm.js +13 -0
  3. package/LexicalAutoEmbedPlugin.js +1 -1
  4. package/LexicalAutoEmbedPlugin.prod.esm.js +7 -0
  5. package/LexicalAutoFocusPlugin.dev.esm.js +42 -0
  6. package/LexicalAutoFocusPlugin.esm.js +10 -0
  7. package/LexicalAutoFocusPlugin.js +1 -1
  8. package/LexicalAutoFocusPlugin.prod.esm.js +7 -0
  9. package/LexicalAutoLinkPlugin.dev.esm.js +312 -0
  10. package/LexicalAutoLinkPlugin.dev.js +3 -1
  11. package/LexicalAutoLinkPlugin.esm.js +11 -0
  12. package/LexicalAutoLinkPlugin.js +1 -1
  13. package/LexicalAutoLinkPlugin.prod.esm.js +7 -0
  14. package/LexicalBlockWithAlignableContents.dev.esm.js +86 -0
  15. package/LexicalBlockWithAlignableContents.dev.js +1 -0
  16. package/LexicalBlockWithAlignableContents.esm.js +10 -0
  17. package/LexicalBlockWithAlignableContents.js +1 -1
  18. package/LexicalBlockWithAlignableContents.prod.esm.js +7 -0
  19. package/LexicalBlockWithAlignableContents.prod.js +1 -1
  20. package/LexicalCharacterLimitPlugin.d.ts +4 -1
  21. package/LexicalCharacterLimitPlugin.dev.esm.js +272 -0
  22. package/LexicalCharacterLimitPlugin.dev.js +12 -4
  23. package/LexicalCharacterLimitPlugin.esm.js +10 -0
  24. package/LexicalCharacterLimitPlugin.js +1 -1
  25. package/LexicalCharacterLimitPlugin.prod.esm.js +7 -0
  26. package/LexicalCharacterLimitPlugin.prod.js +9 -9
  27. package/LexicalCheckListPlugin.dev.esm.js +203 -0
  28. package/LexicalCheckListPlugin.esm.js +10 -0
  29. package/LexicalCheckListPlugin.js +1 -1
  30. package/LexicalCheckListPlugin.prod.esm.js +7 -0
  31. package/LexicalClearEditorPlugin.dev.esm.js +64 -0
  32. package/LexicalClearEditorPlugin.esm.js +10 -0
  33. package/LexicalClearEditorPlugin.js +1 -1
  34. package/LexicalClearEditorPlugin.prod.esm.js +7 -0
  35. package/LexicalClickableLinkPlugin.dev.esm.js +95 -0
  36. package/LexicalClickableLinkPlugin.esm.js +10 -0
  37. package/LexicalClickableLinkPlugin.js +1 -1
  38. package/LexicalClickableLinkPlugin.prod.esm.js +7 -0
  39. package/LexicalCollaborationContext.dev.esm.js +36 -0
  40. package/LexicalCollaborationContext.esm.js +11 -0
  41. package/LexicalCollaborationContext.js +1 -1
  42. package/LexicalCollaborationContext.prod.esm.js +7 -0
  43. package/LexicalCollaborationPlugin.dev.esm.js +308 -0
  44. package/LexicalCollaborationPlugin.esm.js +10 -0
  45. package/LexicalCollaborationPlugin.js +1 -1
  46. package/LexicalCollaborationPlugin.prod.esm.js +7 -0
  47. package/LexicalComposer.dev.esm.js +129 -0
  48. package/LexicalComposer.esm.js +10 -0
  49. package/LexicalComposer.js +1 -1
  50. package/LexicalComposer.prod.esm.js +7 -0
  51. package/LexicalComposerContext.dev.esm.js +42 -0
  52. package/LexicalComposerContext.esm.js +12 -0
  53. package/LexicalComposerContext.js +1 -1
  54. package/LexicalComposerContext.prod.esm.js +7 -0
  55. package/LexicalContentEditable.dev.esm.js +107 -0
  56. package/LexicalContentEditable.dev.js +5 -1
  57. package/LexicalContentEditable.esm.js +10 -0
  58. package/LexicalContentEditable.js +1 -1
  59. package/LexicalContentEditable.prod.esm.js +7 -0
  60. package/LexicalContentEditable.prod.js +3 -3
  61. package/LexicalContextMenuPlugin.dev.esm.js +455 -0
  62. package/LexicalContextMenuPlugin.dev.js +3 -1
  63. package/LexicalContextMenuPlugin.esm.js +11 -0
  64. package/LexicalContextMenuPlugin.js +1 -1
  65. package/LexicalContextMenuPlugin.prod.esm.js +7 -0
  66. package/LexicalDecoratorBlockNode.dev.esm.js +46 -0
  67. package/LexicalDecoratorBlockNode.esm.js +11 -0
  68. package/LexicalDecoratorBlockNode.js +1 -1
  69. package/LexicalDecoratorBlockNode.prod.esm.js +7 -0
  70. package/LexicalEditorRefPlugin.dev.esm.js +40 -0
  71. package/LexicalEditorRefPlugin.dev.js +10 -5
  72. package/LexicalEditorRefPlugin.esm.js +10 -0
  73. package/LexicalEditorRefPlugin.js +1 -1
  74. package/LexicalEditorRefPlugin.prod.esm.js +7 -0
  75. package/LexicalEditorRefPlugin.prod.js +1 -1
  76. package/LexicalErrorBoundary.dev.esm.js +157 -0
  77. package/LexicalErrorBoundary.esm.js +10 -0
  78. package/LexicalErrorBoundary.js +1 -1
  79. package/LexicalErrorBoundary.prod.esm.js +7 -0
  80. package/LexicalHashtagPlugin.dev.esm.js +163 -0
  81. package/LexicalHashtagPlugin.esm.js +10 -0
  82. package/LexicalHashtagPlugin.js +1 -1
  83. package/LexicalHashtagPlugin.prod.esm.js +7 -0
  84. package/LexicalHistoryPlugin.dev.esm.js +41 -0
  85. package/LexicalHistoryPlugin.esm.js +11 -0
  86. package/LexicalHistoryPlugin.js +1 -1
  87. package/LexicalHistoryPlugin.prod.esm.js +7 -0
  88. package/LexicalHorizontalRuleNode.dev.esm.js +118 -0
  89. package/LexicalHorizontalRuleNode.dev.js +1 -0
  90. package/LexicalHorizontalRuleNode.esm.js +13 -0
  91. package/LexicalHorizontalRuleNode.js +1 -1
  92. package/LexicalHorizontalRuleNode.prod.esm.js +7 -0
  93. package/LexicalHorizontalRuleNode.prod.js +1 -1
  94. package/LexicalHorizontalRulePlugin.dev.esm.js +39 -0
  95. package/LexicalHorizontalRulePlugin.esm.js +10 -0
  96. package/LexicalHorizontalRulePlugin.js +1 -1
  97. package/LexicalHorizontalRulePlugin.prod.esm.js +7 -0
  98. package/LexicalLinkPlugin.dev.esm.js +79 -0
  99. package/LexicalLinkPlugin.dev.js +6 -2
  100. package/LexicalLinkPlugin.esm.js +10 -0
  101. package/LexicalLinkPlugin.js +1 -1
  102. package/LexicalLinkPlugin.prod.esm.js +7 -0
  103. package/LexicalLinkPlugin.prod.js +1 -1
  104. package/LexicalListPlugin.dev.esm.js +59 -0
  105. package/LexicalListPlugin.esm.js +10 -0
  106. package/LexicalListPlugin.js +1 -1
  107. package/LexicalListPlugin.prod.esm.js +7 -0
  108. package/LexicalMarkdownShortcutPlugin.dev.esm.js +49 -0
  109. package/LexicalMarkdownShortcutPlugin.esm.js +11 -0
  110. package/LexicalMarkdownShortcutPlugin.js +1 -1
  111. package/LexicalMarkdownShortcutPlugin.prod.esm.js +7 -0
  112. package/LexicalNestedComposer.dev.esm.js +105 -0
  113. package/LexicalNestedComposer.esm.js +10 -0
  114. package/LexicalNestedComposer.js +1 -1
  115. package/LexicalNestedComposer.prod.esm.js +7 -0
  116. package/LexicalNodeEventPlugin.dev.esm.js +56 -0
  117. package/LexicalNodeEventPlugin.esm.js +10 -0
  118. package/LexicalNodeEventPlugin.js +1 -1
  119. package/LexicalNodeEventPlugin.prod.esm.js +7 -0
  120. package/LexicalNodeMenuPlugin.dev.esm.js +466 -0
  121. package/LexicalNodeMenuPlugin.dev.js +3 -1
  122. package/LexicalNodeMenuPlugin.esm.js +11 -0
  123. package/LexicalNodeMenuPlugin.js +1 -1
  124. package/LexicalNodeMenuPlugin.prod.esm.js +7 -0
  125. package/LexicalOnChangePlugin.dev.esm.js +62 -0
  126. package/LexicalOnChangePlugin.esm.js +10 -0
  127. package/LexicalOnChangePlugin.js +1 -1
  128. package/LexicalOnChangePlugin.prod.esm.js +7 -0
  129. package/LexicalPlainTextPlugin.dev.esm.js +161 -0
  130. package/LexicalPlainTextPlugin.esm.js +10 -0
  131. package/LexicalPlainTextPlugin.js +1 -1
  132. package/LexicalPlainTextPlugin.prod.esm.js +7 -0
  133. package/LexicalRichTextPlugin.dev.esm.js +161 -0
  134. package/LexicalRichTextPlugin.esm.js +10 -0
  135. package/LexicalRichTextPlugin.js +1 -1
  136. package/LexicalRichTextPlugin.prod.esm.js +7 -0
  137. package/LexicalTabIndentationPlugin.dev.esm.js +76 -0
  138. package/LexicalTabIndentationPlugin.esm.js +11 -0
  139. package/LexicalTabIndentationPlugin.js +1 -1
  140. package/LexicalTabIndentationPlugin.prod.esm.js +7 -0
  141. package/LexicalTableOfContents.dev.esm.js +157 -0
  142. package/LexicalTableOfContents.esm.js +10 -0
  143. package/LexicalTableOfContents.js +1 -1
  144. package/LexicalTableOfContents.prod.esm.js +7 -0
  145. package/LexicalTablePlugin.dev.esm.js +163 -0
  146. package/LexicalTablePlugin.esm.js +10 -0
  147. package/LexicalTablePlugin.js +1 -1
  148. package/LexicalTablePlugin.prod.esm.js +7 -0
  149. package/LexicalTreeView.dev.esm.js +483 -0
  150. package/LexicalTreeView.dev.js +3 -1
  151. package/LexicalTreeView.esm.js +10 -0
  152. package/LexicalTreeView.js +1 -1
  153. package/LexicalTreeView.prod.esm.js +7 -0
  154. package/LexicalTypeaheadMenuPlugin.dev.esm.js +569 -0
  155. package/LexicalTypeaheadMenuPlugin.dev.js +3 -1
  156. package/LexicalTypeaheadMenuPlugin.esm.js +16 -0
  157. package/LexicalTypeaheadMenuPlugin.js +1 -1
  158. package/LexicalTypeaheadMenuPlugin.prod.esm.js +7 -0
  159. package/package.json +583 -20
  160. package/useLexicalEditable.dev.esm.js +82 -0
  161. package/useLexicalEditable.esm.js +10 -0
  162. package/useLexicalEditable.js +1 -1
  163. package/useLexicalEditable.prod.esm.js +7 -0
  164. package/useLexicalIsTextContentEmpty.dev.esm.js +51 -0
  165. package/useLexicalIsTextContentEmpty.esm.js +10 -0
  166. package/useLexicalIsTextContentEmpty.js +1 -1
  167. package/useLexicalIsTextContentEmpty.prod.esm.js +7 -0
  168. package/useLexicalNodeSelection.dev.esm.js +69 -0
  169. package/useLexicalNodeSelection.esm.js +10 -0
  170. package/useLexicalNodeSelection.js +1 -1
  171. package/useLexicalNodeSelection.prod.esm.js +7 -0
  172. package/useLexicalSubscription.dev.esm.js +63 -0
  173. package/useLexicalSubscription.esm.js +10 -0
  174. package/useLexicalSubscription.js +1 -1
  175. package/useLexicalSubscription.prod.esm.js +7 -0
  176. package/useLexicalTextEntity.dev.esm.js +26 -0
  177. package/useLexicalTextEntity.esm.js +10 -0
  178. package/useLexicalTextEntity.js +1 -1
  179. package/useLexicalTextEntity.prod.esm.js +7 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
8
+ import { useLayoutEffect as useLayoutEffect$1, useEffect, useMemo, useRef, useState } from 'react';
9
+
10
+ /**
11
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
19
+
20
+ /**
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ *
26
+ */
27
+ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect$1 : useEffect;
28
+ var useLayoutEffect = useLayoutEffectImpl;
29
+
30
+ /**
31
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
32
+ *
33
+ * This source code is licensed under the MIT license found in the
34
+ * LICENSE file in the root directory of this source tree.
35
+ *
36
+ */
37
+ /**
38
+ * Shortcut to Lexical subscriptions when values are used for render.
39
+ */
40
+ function useLexicalSubscription(subscription) {
41
+ const [editor] = useLexicalComposerContext();
42
+ const initializedSubscription = useMemo(() => subscription(editor), [editor, subscription]);
43
+ const valueRef = useRef(initializedSubscription.initialValueFn());
44
+ const [value, setValue] = useState(valueRef.current);
45
+ useLayoutEffect(() => {
46
+ const {
47
+ initialValueFn,
48
+ subscribe
49
+ } = initializedSubscription;
50
+ const currentValue = initialValueFn();
51
+ if (valueRef.current !== currentValue) {
52
+ valueRef.current = currentValue;
53
+ setValue(currentValue);
54
+ }
55
+ return subscribe(newValue => {
56
+ valueRef.current = newValue;
57
+ setValue(newValue);
58
+ });
59
+ }, [initializedSubscription, subscription]);
60
+ return value;
61
+ }
62
+
63
+ /**
64
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
65
+ *
66
+ * This source code is licensed under the MIT license found in the
67
+ * LICENSE file in the root directory of this source tree.
68
+ *
69
+ */
70
+ function subscription(editor) {
71
+ return {
72
+ initialValueFn: () => editor.isEditable(),
73
+ subscribe: callback => {
74
+ return editor.registerEditableListener(callback);
75
+ }
76
+ };
77
+ }
78
+ function useLexicalEditable() {
79
+ return useLexicalSubscription(subscription);
80
+ }
81
+
82
+ export { useLexicalEditable as default };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import * as modDev from './useLexicalEditable.dev.esm.js';
8
+ import * as modProd from './useLexicalEditable.prod.esm.js';
9
+ const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
+ export default mod.default;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict'
8
- const useLexicalEditable = process.env.NODE_ENV === 'development' ? require('./useLexicalEditable.dev.js') : require('./useLexicalEditable.prod.js')
8
+ const useLexicalEditable = process.env.NODE_ENV === 'development' ? require('./useLexicalEditable.dev.js') : require('./useLexicalEditable.prod.js');
9
9
  module.exports = useLexicalEditable;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as n,useMemo as r,useRef as i,useState as o}from"react";var u="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:n;function c(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function a(){return function(t){const[n]=e(),c=r((()=>t(n)),[n,t]),a=i(c.initialValueFn()),[l,s]=o(a.current);return u((()=>{const{initialValueFn:e,subscribe:t}=c,n=e();return a.current!==n&&(a.current=n,s(n)),t((e=>{a.current=e,s(e)}))}),[c,t]),l}(c)}export{a as default};
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { $isRootTextContentEmptyCurry } from '@lexical/text';
8
+ import { useLayoutEffect as useLayoutEffect$1, useEffect, useState } from 'react';
9
+
10
+ /**
11
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
19
+
20
+ /**
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ *
26
+ */
27
+ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect$1 : useEffect;
28
+ var useLayoutEffect = useLayoutEffectImpl;
29
+
30
+ /**
31
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
32
+ *
33
+ * This source code is licensed under the MIT license found in the
34
+ * LICENSE file in the root directory of this source tree.
35
+ *
36
+ */
37
+ function useLexicalIsTextContentEmpty(editor, trim) {
38
+ const [isEmpty, setIsEmpty] = useState(editor.getEditorState().read($isRootTextContentEmptyCurry(editor.isComposing(), trim)));
39
+ useLayoutEffect(() => {
40
+ return editor.registerUpdateListener(({
41
+ editorState
42
+ }) => {
43
+ const isComposing = editor.isComposing();
44
+ const currentIsEmpty = editorState.read($isRootTextContentEmptyCurry(isComposing, trim));
45
+ setIsEmpty(currentIsEmpty);
46
+ });
47
+ }, [editor, trim]);
48
+ return isEmpty;
49
+ }
50
+
51
+ export { useLexicalIsTextContentEmpty };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import * as modDev from './useLexicalIsTextContentEmpty.dev.esm.js';
8
+ import * as modProd from './useLexicalIsTextContentEmpty.prod.esm.js';
9
+ const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
+ export const useLexicalIsTextContentEmpty = mod.useLexicalIsTextContentEmpty;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict'
8
- const useLexicalIsTextContentEmpty = process.env.NODE_ENV === 'development' ? require('./useLexicalIsTextContentEmpty.dev.js') : require('./useLexicalIsTextContentEmpty.prod.js')
8
+ const useLexicalIsTextContentEmpty = process.env.NODE_ENV === 'development' ? require('./useLexicalIsTextContentEmpty.dev.js') : require('./useLexicalIsTextContentEmpty.prod.js');
9
9
  module.exports = useLexicalIsTextContentEmpty;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import{$isRootTextContentEmptyCurry as e}from"@lexical/text";import{useLayoutEffect as t,useEffect as o,useState as i}from"react";var r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:o;function n(t,o){const[n,d]=i(t.getEditorState().read(e(t.isComposing(),o)));return r((()=>t.registerUpdateListener((({editorState:i})=>{const r=t.isComposing(),n=i.read(e(r,o));d(n)}))),[t,o]),n}export{n as useLexicalIsTextContentEmpty};
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
8
+ import { $getNodeByKey, $getSelection, $isNodeSelection, $createNodeSelection, $setSelection } from 'lexical';
9
+ import { useState, useEffect, useCallback } from 'react';
10
+
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ */
18
+ function isNodeSelected(editor, key) {
19
+ return editor.getEditorState().read(() => {
20
+ const node = $getNodeByKey(key);
21
+ if (node === null) {
22
+ return false;
23
+ }
24
+ return node.isSelected();
25
+ });
26
+ }
27
+ function useLexicalNodeSelection(key) {
28
+ const [editor] = useLexicalComposerContext();
29
+ const [isSelected, setIsSelected] = useState(() => isNodeSelected(editor, key));
30
+ useEffect(() => {
31
+ let isMounted = true;
32
+ const unregister = editor.registerUpdateListener(() => {
33
+ if (isMounted) {
34
+ setIsSelected(isNodeSelected(editor, key));
35
+ }
36
+ });
37
+ return () => {
38
+ isMounted = false;
39
+ unregister();
40
+ };
41
+ }, [editor, key]);
42
+ const setSelected = useCallback(selected => {
43
+ editor.update(() => {
44
+ let selection = $getSelection();
45
+ if (!$isNodeSelection(selection)) {
46
+ selection = $createNodeSelection();
47
+ $setSelection(selection);
48
+ }
49
+ if ($isNodeSelection(selection)) {
50
+ if (selected) {
51
+ selection.add(key);
52
+ } else {
53
+ selection.delete(key);
54
+ }
55
+ }
56
+ });
57
+ }, [editor, key]);
58
+ const clearSelected = useCallback(() => {
59
+ editor.update(() => {
60
+ const selection = $getSelection();
61
+ if ($isNodeSelection(selection)) {
62
+ selection.clear();
63
+ }
64
+ });
65
+ }, [editor]);
66
+ return [isSelected, setSelected, clearSelected];
67
+ }
68
+
69
+ export { useLexicalNodeSelection };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import * as modDev from './useLexicalNodeSelection.dev.esm.js';
8
+ import * as modProd from './useLexicalNodeSelection.prod.esm.js';
9
+ const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
+ export const useLexicalNodeSelection = mod.useLexicalNodeSelection;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict'
8
- const useLexicalNodeSelection = process.env.NODE_ENV === 'development' ? require('./useLexicalNodeSelection.dev.js') : require('./useLexicalNodeSelection.prod.js')
8
+ const useLexicalNodeSelection = process.env.NODE_ENV === 'development' ? require('./useLexicalNodeSelection.dev.js') : require('./useLexicalNodeSelection.prod.js');
9
9
  module.exports = useLexicalNodeSelection;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{$getNodeByKey as t,$getSelection as r,$isNodeSelection as o,$createNodeSelection as n,$setSelection as c}from"lexical";import{useState as a,useEffect as i,useCallback as l}from"react";function d(e,r){return e.getEditorState().read((()=>{const e=t(r);return null!==e&&e.isSelected()}))}function u(t){const[u]=e(),[p,s]=a((()=>d(u,t)));i((()=>{let e=!0;const r=u.registerUpdateListener((()=>{e&&s(d(u,t))}));return()=>{e=!1,r()}}),[u,t]);return[p,l((e=>{u.update((()=>{let a=r();o(a)||(a=n(),c(a)),o(a)&&(e?a.add(t):a.delete(t))}))}),[u,t]),l((()=>{u.update((()=>{const e=r();o(e)&&e.clear()}))}),[u])]}export{u as useLexicalNodeSelection};
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
8
+ import { useLayoutEffect as useLayoutEffect$1, useEffect, useMemo, useRef, useState } from 'react';
9
+
10
+ /**
11
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
19
+
20
+ /**
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ *
26
+ */
27
+ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect$1 : useEffect;
28
+ var useLayoutEffect = useLayoutEffectImpl;
29
+
30
+ /**
31
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
32
+ *
33
+ * This source code is licensed under the MIT license found in the
34
+ * LICENSE file in the root directory of this source tree.
35
+ *
36
+ */
37
+ /**
38
+ * Shortcut to Lexical subscriptions when values are used for render.
39
+ */
40
+ function useLexicalSubscription(subscription) {
41
+ const [editor] = useLexicalComposerContext();
42
+ const initializedSubscription = useMemo(() => subscription(editor), [editor, subscription]);
43
+ const valueRef = useRef(initializedSubscription.initialValueFn());
44
+ const [value, setValue] = useState(valueRef.current);
45
+ useLayoutEffect(() => {
46
+ const {
47
+ initialValueFn,
48
+ subscribe
49
+ } = initializedSubscription;
50
+ const currentValue = initialValueFn();
51
+ if (valueRef.current !== currentValue) {
52
+ valueRef.current = currentValue;
53
+ setValue(currentValue);
54
+ }
55
+ return subscribe(newValue => {
56
+ valueRef.current = newValue;
57
+ setValue(newValue);
58
+ });
59
+ }, [initializedSubscription, subscription]);
60
+ return value;
61
+ }
62
+
63
+ export { useLexicalSubscription as default };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import * as modDev from './useLexicalSubscription.dev.esm.js';
8
+ import * as modProd from './useLexicalSubscription.prod.esm.js';
9
+ const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
+ export default mod.default;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict'
8
- const useLexicalSubscription = process.env.NODE_ENV === 'development' ? require('./useLexicalSubscription.dev.js') : require('./useLexicalSubscription.prod.js')
8
+ const useLexicalSubscription = process.env.NODE_ENV === 'development' ? require('./useLexicalSubscription.dev.js') : require('./useLexicalSubscription.prod.js');
9
9
  module.exports = useLexicalSubscription;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as n,useMemo as r,useRef as o,useState as i}from"react";var c="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:n;function u(t){const[n]=e(),u=r((()=>t(n)),[n,t]),a=o(u.initialValueFn()),[d,l]=i(a.current);return c((()=>{const{initialValueFn:e,subscribe:t}=u,n=e();return a.current!==n&&(a.current=n,l(n)),t((e=>{a.current=e,l(e)}))}),[u,t]),d}export{u as default};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
8
+ import { registerLexicalTextEntity } from '@lexical/text';
9
+ import { mergeRegister } from '@lexical/utils';
10
+ import { useEffect } from 'react';
11
+
12
+ /**
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ */
19
+ function useLexicalTextEntity(getMatch, targetNode, createNode) {
20
+ const [editor] = useLexicalComposerContext();
21
+ useEffect(() => {
22
+ return mergeRegister(...registerLexicalTextEntity(editor, getMatch, targetNode, createNode));
23
+ }, [createNode, editor, getMatch, targetNode]);
24
+ }
25
+
26
+ export { useLexicalTextEntity };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import * as modDev from './useLexicalTextEntity.dev.esm.js';
8
+ import * as modProd from './useLexicalTextEntity.prod.esm.js';
9
+ const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
+ export const useLexicalTextEntity = mod.useLexicalTextEntity;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict'
8
- const useLexicalTextEntity = process.env.NODE_ENV === 'development' ? require('./useLexicalTextEntity.dev.js') : require('./useLexicalTextEntity.prod.js')
8
+ const useLexicalTextEntity = process.env.NODE_ENV === 'development' ? require('./useLexicalTextEntity.dev.js') : require('./useLexicalTextEntity.prod.js');
9
9
  module.exports = useLexicalTextEntity;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import{useLexicalComposerContext as o}from"@lexical/react/LexicalComposerContext";import{registerLexicalTextEntity as t}from"@lexical/text";import{mergeRegister as r}from"@lexical/utils";import{useEffect as e}from"react";function i(i,m,c){const[l]=o();e((()=>r(...t(l,i,m,c))),[c,l,i,m])}export{i as useLexicalTextEntity};