@lexical/react 0.2.7 → 0.3.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 (135) hide show
  1. package/DEPRECATED_useLexical.dev.js +55 -4
  2. package/DEPRECATED_useLexical.js.flow +23 -0
  3. package/DEPRECATED_useLexical.prod.js +3 -1
  4. package/DEPRECATED_useLexicalAutoFormatter.dev.js +1 -2
  5. package/DEPRECATED_useLexicalAutoFormatter.js.flow +12 -0
  6. package/DEPRECATED_useLexicalAutoFormatter.prod.js +1 -1
  7. package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +6 -8
  8. package/DEPRECATED_useLexicalCanShowPlaceholder.js.flow +12 -0
  9. package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +2 -1
  10. package/DEPRECATED_useLexicalCharacterLimit.dev.js +5 -3
  11. package/DEPRECATED_useLexicalCharacterLimit.js.flow +28 -0
  12. package/DEPRECATED_useLexicalCharacterLimit.prod.js +6 -6
  13. package/DEPRECATED_useLexicalDecorators.dev.js +7 -5
  14. package/DEPRECATED_useLexicalDecorators.js.flow +14 -0
  15. package/DEPRECATED_useLexicalDecorators.prod.js +2 -2
  16. package/DEPRECATED_useLexicalEditor.dev.js +55 -3
  17. package/DEPRECATED_useLexicalEditor.prod.js +2 -1
  18. package/DEPRECATED_useLexicalEditorEvents.dev.js +1 -5
  19. package/DEPRECATED_useLexicalEditorEvents.js.flow +19 -0
  20. package/DEPRECATED_useLexicalEditorEvents.prod.js +2 -2
  21. package/DEPRECATED_useLexicalHistory.dev.js +0 -2
  22. package/DEPRECATED_useLexicalHistory.js.flow +31 -0
  23. package/DEPRECATED_useLexicalHistory.prod.js +1 -1
  24. package/DEPRECATED_useLexicalList.dev.js +3 -5
  25. package/DEPRECATED_useLexicalList.js.flow +10 -0
  26. package/DEPRECATED_useLexicalList.prod.js +2 -2
  27. package/DEPRECATED_useLexicalPlainText.dev.js +1 -7
  28. package/DEPRECATED_useLexicalPlainText.js.flow +15 -0
  29. package/DEPRECATED_useLexicalPlainText.prod.js +2 -2
  30. package/DEPRECATED_useLexicalRichText.dev.js +1 -7
  31. package/DEPRECATED_useLexicalRichText.js.flow +15 -0
  32. package/DEPRECATED_useLexicalRichText.prod.js +2 -2
  33. package/LexicalAutoFocusPlugin.d.ts +1 -1
  34. package/LexicalAutoFocusPlugin.dev.js +17 -4
  35. package/LexicalAutoFocusPlugin.js.flow +1 -1
  36. package/LexicalAutoFocusPlugin.prod.js +1 -1
  37. package/LexicalAutoLinkPlugin.d.ts +1 -1
  38. package/LexicalAutoLinkPlugin.dev.js +4 -5
  39. package/LexicalAutoLinkPlugin.js.flow +2 -1
  40. package/LexicalAutoLinkPlugin.prod.js +5 -5
  41. package/LexicalAutoScrollPlugin.d.ts +2 -3
  42. package/LexicalAutoScrollPlugin.dev.js +2 -5
  43. package/LexicalAutoScrollPlugin.js.flow +1 -3
  44. package/LexicalAutoScrollPlugin.prod.js +2 -2
  45. package/LexicalBlockWithAlignableContents.d.ts +16 -0
  46. package/LexicalBlockWithAlignableContents.dev.js +7 -9
  47. package/LexicalBlockWithAlignableContents.prod.js +4 -4
  48. package/LexicalCharacterLimitPlugin.d.ts +1 -1
  49. package/LexicalCharacterLimitPlugin.dev.js +6 -5
  50. package/LexicalCharacterLimitPlugin.js.flow +1 -1
  51. package/LexicalCharacterLimitPlugin.prod.js +8 -8
  52. package/LexicalCheckListPlugin.d.ts +9 -0
  53. package/LexicalCheckListPlugin.dev.js +7 -15
  54. package/LexicalCheckListPlugin.js.flow +1 -1
  55. package/LexicalCheckListPlugin.prod.js +7 -7
  56. package/LexicalClearEditorPlugin.d.ts +2 -6
  57. package/LexicalClearEditorPlugin.dev.js +2 -5
  58. package/LexicalClearEditorPlugin.js.flow +1 -1
  59. package/LexicalClearEditorPlugin.prod.js +2 -2
  60. package/LexicalCollaborationPlugin.d.ts +3 -20
  61. package/LexicalCollaborationPlugin.dev.js +9 -5
  62. package/LexicalCollaborationPlugin.prod.js +9 -9
  63. package/LexicalComposer.d.ts +2 -2
  64. package/LexicalComposer.dev.js +1 -6
  65. package/LexicalComposer.js.flow +1 -1
  66. package/LexicalComposer.prod.js +2 -2
  67. package/LexicalComposerContext.dev.js +0 -1
  68. package/LexicalComposerContext.prod.js +1 -1
  69. package/LexicalContentEditable.d.ts +2 -5
  70. package/LexicalContentEditable.dev.js +5 -7
  71. package/LexicalContentEditable.js.flow +1 -3
  72. package/LexicalContentEditable.prod.js +3 -3
  73. package/LexicalDecoratorBlockNode.d.ts +32 -0
  74. package/LexicalDecoratorBlockNode.dev.js +8 -1
  75. package/LexicalDecoratorBlockNode.prod.js +1 -1
  76. package/LexicalHashtagPlugin.d.ts +1 -1
  77. package/LexicalHashtagPlugin.dev.js +2 -3
  78. package/LexicalHashtagPlugin.js.flow +1 -1
  79. package/LexicalHashtagPlugin.prod.js +3 -3
  80. package/LexicalHistoryPlugin.d.ts +1 -0
  81. package/LexicalHistoryPlugin.dev.js +0 -2
  82. package/LexicalHistoryPlugin.prod.js +1 -1
  83. package/LexicalHorizontalRuleNode.d.ts +1 -1
  84. package/LexicalHorizontalRuleNode.dev.js +11 -1
  85. package/LexicalHorizontalRuleNode.prod.js +3 -3
  86. package/LexicalLinkPlugin.d.ts +1 -1
  87. package/LexicalLinkPlugin.dev.js +3 -107
  88. package/LexicalLinkPlugin.js.flow +1 -1
  89. package/LexicalLinkPlugin.prod.js +1 -4
  90. package/LexicalListPlugin.d.ts +1 -1
  91. package/LexicalListPlugin.dev.js +9 -6
  92. package/LexicalListPlugin.js.flow +1 -1
  93. package/LexicalListPlugin.prod.js +3 -3
  94. package/LexicalMarkdownShortcutPlugin.d.ts +4 -2
  95. package/LexicalMarkdownShortcutPlugin.dev.js +7 -83
  96. package/LexicalMarkdownShortcutPlugin.js.flow +2 -2
  97. package/LexicalMarkdownShortcutPlugin.prod.js +2 -3
  98. package/LexicalNestedComposer.d.ts +2 -2
  99. package/LexicalNestedComposer.dev.js +1 -2
  100. package/LexicalNestedComposer.js.flow +1 -1
  101. package/LexicalNestedComposer.prod.js +3 -3
  102. package/LexicalOnChangePlugin.d.ts +2 -1
  103. package/LexicalOnChangePlugin.dev.js +1 -4
  104. package/LexicalOnChangePlugin.js.flow +1 -1
  105. package/LexicalOnChangePlugin.prod.js +2 -2
  106. package/LexicalPlainTextPlugin.d.ts +3 -2
  107. package/LexicalPlainTextPlugin.dev.js +12 -10
  108. package/LexicalPlainTextPlugin.js.flow +1 -1
  109. package/LexicalPlainTextPlugin.prod.js +4 -4
  110. package/LexicalRichTextPlugin.d.ts +3 -2
  111. package/LexicalRichTextPlugin.dev.js +12 -10
  112. package/LexicalRichTextPlugin.js.flow +1 -1
  113. package/LexicalRichTextPlugin.prod.js +4 -4
  114. package/LexicalTablePlugin.d.ts +1 -1
  115. package/LexicalTablePlugin.dev.js +7 -8
  116. package/LexicalTablePlugin.js.flow +1 -1
  117. package/LexicalTablePlugin.prod.js +4 -4
  118. package/LexicalTreeView.d.ts +2 -1
  119. package/LexicalTreeView.dev.js +4 -5
  120. package/LexicalTreeView.js.flow +1 -1
  121. package/LexicalTreeView.prod.js +11 -11
  122. package/README.md +10 -6
  123. package/package.json +19 -19
  124. package/useLexicalIsTextContentEmpty.d.ts +2 -1
  125. package/useLexicalIsTextContentEmpty.dev.js +2 -5
  126. package/useLexicalIsTextContentEmpty.js.flow +1 -1
  127. package/useLexicalIsTextContentEmpty.prod.js +1 -1
  128. package/useLexicalNodeSelection.d.ts +2 -1
  129. package/useLexicalNodeSelection.dev.js +1 -2
  130. package/useLexicalNodeSelection.js.flow +1 -1
  131. package/useLexicalNodeSelection.prod.js +2 -2
  132. package/useLexicalTextEntity.d.ts +2 -1
  133. package/useLexicalTextEntity.dev.js +1 -2
  134. package/useLexicalTextEntity.js.flow +1 -1
  135. package/useLexicalTextEntity.prod.js +1 -1
@@ -20,7 +20,6 @@ var utils = require('@lexical/utils');
20
20
  * This source code is licensed under the MIT license found in the
21
21
  * LICENSE file in the root directory of this source tree.
22
22
  *
23
- *
24
23
  */
25
24
  const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
26
25
 
@@ -30,7 +29,6 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
30
29
  * This source code is licensed under the MIT license found in the
31
30
  * LICENSE file in the root directory of this source tree.
32
31
  *
33
- *
34
32
  */
35
33
  const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
36
34
  var useLayoutEffect = useLayoutEffectImpl;
@@ -41,16 +39,17 @@ var useLayoutEffect = useLayoutEffectImpl;
41
39
  * This source code is licensed under the MIT license found in the
42
40
  * LICENSE file in the root directory of this source tree.
43
41
  *
44
- *
45
42
  */
46
- function useLexicalCanShowPlaceholder(editor) {
43
+ function useCanShowPlaceholder(editor) {
47
44
  const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
48
45
  useLayoutEffect(() => {
46
+ let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
47
+ setCanShowPlaceholder(currentCanShowPlaceholder);
49
48
  return editor.registerUpdateListener(({
50
49
  editorState
51
50
  }) => {
52
51
  const isComposing = editor.isComposing();
53
- const currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
52
+ currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
54
53
  setCanShowPlaceholder(currentCanShowPlaceholder);
55
54
  });
56
55
  }, [editor]);
@@ -63,7 +62,6 @@ function useLexicalCanShowPlaceholder(editor) {
63
62
  * This source code is licensed under the MIT license found in the
64
63
  * LICENSE file in the root directory of this source tree.
65
64
  *
66
- *
67
65
  */
68
66
  function useDecorators(editor) {
69
67
  const [decorators, setDecorators] = React.useState(() => editor.getDecorators()); // Subscribe to changes
@@ -74,6 +72,12 @@ function useDecorators(editor) {
74
72
  setDecorators(nextDecorators);
75
73
  });
76
74
  });
75
+ }, [editor]);
76
+ React.useEffect(() => {
77
+ // If the content editable mounts before the subscription is added, then
78
+ // nothing will be rendered on initial pass. We can get around that by
79
+ // ensuring that we set the value.
80
+ setDecorators(editor.getDecorators());
77
81
  }, [editor]); // Return decorators defined as React Portals
78
82
 
79
83
  return React.useMemo(() => {
@@ -100,7 +104,6 @@ function useDecorators(editor) {
100
104
  * This source code is licensed under the MIT license found in the
101
105
  * LICENSE file in the root directory of this source tree.
102
106
  *
103
- *
104
107
  */
105
108
  function usePlainTextSetup(editor, initialEditorState) {
106
109
  useLayoutEffect(() => {
@@ -115,7 +118,6 @@ function usePlainTextSetup(editor, initialEditorState) {
115
118
  * This source code is licensed under the MIT license found in the
116
119
  * LICENSE file in the root directory of this source tree.
117
120
  *
118
- *
119
121
  */
120
122
  function PlainTextPlugin({
121
123
  contentEditable,
@@ -123,10 +125,10 @@ function PlainTextPlugin({
123
125
  initialEditorState
124
126
  }) {
125
127
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
126
- const showPlaceholder = useLexicalCanShowPlaceholder(editor);
128
+ const showPlaceholder = useCanShowPlaceholder(editor);
127
129
  usePlainTextSetup(editor, initialEditorState);
128
130
  const decorators = useDecorators(editor);
129
131
  return /*#__PURE__*/React.createElement(React.Fragment, null, contentEditable, showPlaceholder && placeholder, decorators);
130
132
  }
131
133
 
132
- module.exports = PlainTextPlugin;
134
+ exports.PlainTextPlugin = PlainTextPlugin;
@@ -11,7 +11,7 @@ import type {EditorState} from 'lexical';
11
11
 
12
12
  type InitialEditorStateType = null | string | EditorState | (() => void);
13
13
 
14
- declare export default function PlainTextPlugin({
14
+ declare export function PlainTextPlugin({
15
15
  contentEditable: React$Node,
16
16
  initialEditorState?: InitialEditorStateType,
17
17
  placeholder: React$Node,
@@ -4,7 +4,7 @@
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
- var d=require("@lexical/react/LexicalComposerContext"),h=require("react"),l=require("@lexical/text"),m=require("react-dom"),n=require("@lexical/dragon"),p=require("@lexical/plain-text"),q=require("@lexical/utils"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
8
- function t(a){const [c,e]=h.useState(a.getEditorState().read(l.$canShowPlaceholderCurry(a.isComposing())));r(()=>a.registerUpdateListener(({editorState:b})=>{const f=a.isComposing();b=b.read(l.$canShowPlaceholderCurry(f));e(b)}),[a]);return c}
9
- function u(a){const [c,e]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{m.flushSync(()=>{e(b)})}),[a]);return h.useMemo(()=>{const b=[],f=Object.keys(c);for(let k=0;k<f.length;k++){var g=f[k];const v=c[g];g=a.getElementByKey(g);null!==g&&b.push(m.createPortal(v,g))}return b},[c,a])}function w(a,c){r(()=>q.mergeRegister(p.registerPlainText(a,c),n.registerDragonSupport(a)),[a])}
10
- module.exports=function({contentEditable:a,placeholder:c,initialEditorState:e}){const [b]=d.useLexicalComposerContext(),f=t(b);w(b,e);e=u(b);return h.createElement(h.Fragment,null,a,f&&c,e)};
7
+ 'use strict';var e=require("@lexical/react/LexicalComposerContext"),h=require("react"),k=require("@lexical/text"),m=require("react-dom"),n=require("@lexical/dragon"),p=require("@lexical/plain-text"),q=require("@lexical/utils"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
8
+ function t(a){let [c,d]=h.useState(a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing())));r(()=>{let b=a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing()));d(b);return a.registerUpdateListener(({editorState:g})=>{let f=a.isComposing();b=g.read(k.$canShowPlaceholderCurry(f));d(b)})},[a]);return c}
9
+ function u(a){let [c,d]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{m.flushSync(()=>{d(b)})}),[a]);h.useEffect(()=>{d(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],g=Object.keys(c);for(let l=0;l<g.length;l++){var f=g[l];let v=c[f];f=a.getElementByKey(f);null!==f&&b.push(m.createPortal(v,f))}return b},[c,a])}function w(a,c){r(()=>q.mergeRegister(p.registerPlainText(a,c),n.registerDragonSupport(a)),[a])}
10
+ exports.PlainTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:d}){let [b]=e.useLexicalComposerContext(),g=t(b);w(b,d);d=u(b);return h.createElement(h.Fragment,null,a,g&&c,d)}
@@ -7,9 +7,10 @@
7
7
  */
8
8
 
9
9
  import type {EditorState} from 'lexical';
10
+
10
11
  type InitialEditorStateType = null | string | EditorState | (() => void);
11
- export default function RichTextPlugin(arg0: {
12
+ export function RichTextPlugin(arg0: {
12
13
  contentEditable: JSX.Element | null;
13
14
  initialEditorState?: InitialEditorStateType;
14
- placeholder: JSX.Element | null;
15
+ placeholder: JSX.Element | string | null;
15
16
  }): JSX.Element | null;
@@ -20,7 +20,6 @@ var utils = require('@lexical/utils');
20
20
  * This source code is licensed under the MIT license found in the
21
21
  * LICENSE file in the root directory of this source tree.
22
22
  *
23
- *
24
23
  */
25
24
  const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
26
25
 
@@ -30,7 +29,6 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
30
29
  * This source code is licensed under the MIT license found in the
31
30
  * LICENSE file in the root directory of this source tree.
32
31
  *
33
- *
34
32
  */
35
33
  const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
36
34
  var useLayoutEffect = useLayoutEffectImpl;
@@ -41,16 +39,17 @@ var useLayoutEffect = useLayoutEffectImpl;
41
39
  * This source code is licensed under the MIT license found in the
42
40
  * LICENSE file in the root directory of this source tree.
43
41
  *
44
- *
45
42
  */
46
- function useLexicalCanShowPlaceholder(editor) {
43
+ function useCanShowPlaceholder(editor) {
47
44
  const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
48
45
  useLayoutEffect(() => {
46
+ let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
47
+ setCanShowPlaceholder(currentCanShowPlaceholder);
49
48
  return editor.registerUpdateListener(({
50
49
  editorState
51
50
  }) => {
52
51
  const isComposing = editor.isComposing();
53
- const currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
52
+ currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
54
53
  setCanShowPlaceholder(currentCanShowPlaceholder);
55
54
  });
56
55
  }, [editor]);
@@ -63,7 +62,6 @@ function useLexicalCanShowPlaceholder(editor) {
63
62
  * This source code is licensed under the MIT license found in the
64
63
  * LICENSE file in the root directory of this source tree.
65
64
  *
66
- *
67
65
  */
68
66
  function useDecorators(editor) {
69
67
  const [decorators, setDecorators] = React.useState(() => editor.getDecorators()); // Subscribe to changes
@@ -74,6 +72,12 @@ function useDecorators(editor) {
74
72
  setDecorators(nextDecorators);
75
73
  });
76
74
  });
75
+ }, [editor]);
76
+ React.useEffect(() => {
77
+ // If the content editable mounts before the subscription is added, then
78
+ // nothing will be rendered on initial pass. We can get around that by
79
+ // ensuring that we set the value.
80
+ setDecorators(editor.getDecorators());
77
81
  }, [editor]); // Return decorators defined as React Portals
78
82
 
79
83
  return React.useMemo(() => {
@@ -100,7 +104,6 @@ function useDecorators(editor) {
100
104
  * This source code is licensed under the MIT license found in the
101
105
  * LICENSE file in the root directory of this source tree.
102
106
  *
103
- *
104
107
  */
105
108
  function useRichTextSetup(editor, initialEditorState) {
106
109
  useLayoutEffect(() => {
@@ -115,7 +118,6 @@ function useRichTextSetup(editor, initialEditorState) {
115
118
  * This source code is licensed under the MIT license found in the
116
119
  * LICENSE file in the root directory of this source tree.
117
120
  *
118
- *
119
121
  */
120
122
  function RichTextPlugin({
121
123
  contentEditable,
@@ -123,10 +125,10 @@ function RichTextPlugin({
123
125
  initialEditorState
124
126
  }) {
125
127
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
126
- const showPlaceholder = useLexicalCanShowPlaceholder(editor);
128
+ const showPlaceholder = useCanShowPlaceholder(editor);
127
129
  useRichTextSetup(editor, initialEditorState);
128
130
  const decorators = useDecorators(editor);
129
131
  return /*#__PURE__*/React.createElement(React.Fragment, null, contentEditable, showPlaceholder && placeholder, decorators);
130
132
  }
131
133
 
132
- module.exports = RichTextPlugin;
134
+ exports.RichTextPlugin = RichTextPlugin;
@@ -11,7 +11,7 @@ import type {EditorState} from 'lexical';
11
11
 
12
12
  type InitialEditorStateType = null | string | EditorState | (() => void);
13
13
 
14
- declare export default function RichTextPlugin({
14
+ declare export function RichTextPlugin({
15
15
  contentEditable: React$Node,
16
16
  initialEditorState?: InitialEditorStateType,
17
17
  placeholder: React$Node,
@@ -4,7 +4,7 @@
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
- var d=require("@lexical/react/LexicalComposerContext"),h=require("react"),l=require("@lexical/text"),m=require("react-dom"),n=require("@lexical/dragon"),p=require("@lexical/rich-text"),q=require("@lexical/utils"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
8
- function t(a){const [c,e]=h.useState(a.getEditorState().read(l.$canShowPlaceholderCurry(a.isComposing())));r(()=>a.registerUpdateListener(({editorState:b})=>{const f=a.isComposing();b=b.read(l.$canShowPlaceholderCurry(f));e(b)}),[a]);return c}
9
- function u(a){const [c,e]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{m.flushSync(()=>{e(b)})}),[a]);return h.useMemo(()=>{const b=[],f=Object.keys(c);for(let k=0;k<f.length;k++){var g=f[k];const v=c[g];g=a.getElementByKey(g);null!==g&&b.push(m.createPortal(v,g))}return b},[c,a])}function w(a,c){r(()=>q.mergeRegister(p.registerRichText(a,c),n.registerDragonSupport(a)),[a])}
10
- module.exports=function({contentEditable:a,placeholder:c,initialEditorState:e}){const [b]=d.useLexicalComposerContext(),f=t(b);w(b,e);e=u(b);return h.createElement(h.Fragment,null,a,f&&c,e)};
7
+ 'use strict';var e=require("@lexical/react/LexicalComposerContext"),h=require("react"),k=require("@lexical/text"),m=require("react-dom"),n=require("@lexical/dragon"),p=require("@lexical/rich-text"),q=require("@lexical/utils"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
8
+ function t(a){let [c,d]=h.useState(a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing())));r(()=>{let b=a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing()));d(b);return a.registerUpdateListener(({editorState:g})=>{let f=a.isComposing();b=g.read(k.$canShowPlaceholderCurry(f));d(b)})},[a]);return c}
9
+ function u(a){let [c,d]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{m.flushSync(()=>{d(b)})}),[a]);h.useEffect(()=>{d(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],g=Object.keys(c);for(let l=0;l<g.length;l++){var f=g[l];let v=c[f];f=a.getElementByKey(f);null!==f&&b.push(m.createPortal(v,f))}return b},[c,a])}function w(a,c){r(()=>q.mergeRegister(p.registerRichText(a,c),n.registerDragonSupport(a)),[a])}
10
+ exports.RichTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:d}){let [b]=e.useLexicalComposerContext(),g=t(b);w(b,d);d=u(b);return h.createElement(h.Fragment,null,a,g&&c,d)}
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- export default function LexicalTablePlugin(): null;
9
+ export function TablePlugin(): null;
@@ -17,7 +17,6 @@ var react = require('react');
17
17
  * This source code is licensed under the MIT license found in the
18
18
  * LICENSE file in the root directory of this source tree.
19
19
  *
20
- *
21
20
  */
22
21
  function TablePlugin() {
23
22
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
@@ -28,11 +27,11 @@ function TablePlugin() {
28
27
  }
29
28
  }
30
29
 
31
- return editor.registerCommand(table.INSERT_TABLE_COMMAND, payload => {
32
- const {
33
- columns,
34
- rows
35
- } = payload;
30
+ return editor.registerCommand(table.INSERT_TABLE_COMMAND, ({
31
+ columns,
32
+ rows,
33
+ includeHeaders
34
+ }) => {
36
35
  const selection = lexical.$getSelection();
37
36
 
38
37
  if (!lexical.$isRangeSelection(selection)) {
@@ -43,7 +42,7 @@ function TablePlugin() {
43
42
  const focusNode = focus.getNode();
44
43
 
45
44
  if (focusNode !== null) {
46
- const tableNode = table.$createTableNodeWithDimensions(Number(rows), Number(columns));
45
+ const tableNode = table.$createTableNodeWithDimensions(Number(rows), Number(columns), includeHeaders);
47
46
 
48
47
  if (lexical.$isRootNode(focusNode)) {
49
48
  const target = focusNode.getChildAtIndex(focus.offset);
@@ -96,4 +95,4 @@ function TablePlugin() {
96
95
  return null;
97
96
  }
98
97
 
99
- module.exports = TablePlugin;
98
+ exports.TablePlugin = TablePlugin;
@@ -7,4 +7,4 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- declare export default function LexicalTablePlugin(): null;
10
+ declare export function TablePlugin(): null;
@@ -4,7 +4,7 @@
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
- var e=require("@lexical/react/LexicalComposerContext"),f=require("@lexical/table"),k=require("lexical"),m=require("react");
8
- module.exports=function(){const [c]=e.useLexicalComposerContext();m.useEffect(()=>{if(!c.hasNodes([f.TableNode,f.TableCellNode,f.TableRowNode]))throw Error("Minified Lexical error #7; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return c.registerCommand(f.INSERT_TABLE_COMMAND,a=>{const {columns:h,rows:g}=a;a=k.$getSelection();if(!k.$isRangeSelection(a))return!0;var d=a.focus;a=d.getNode();if(null!==a){const b=f.$createTableNodeWithDimensions(Number(g),
9
- Number(h));k.$isRootNode(a)?(d=a.getChildAtIndex(d.offset),null!==d?d.insertBefore(b):a.append(b),b.insertBefore(k.$createParagraphNode())):a.getTopLevelElementOrThrow().insertAfter(b);b.insertAfter(k.$createParagraphNode());b.getFirstChildOrThrow().getFirstChildOrThrow().select()}return!0},k.COMMAND_PRIORITY_EDITOR)},[c]);m.useEffect(()=>{const a=new Map;return c.registerMutationListener(f.TableNode,h=>{for(const [g,d]of h)"created"===d?c.update(()=>{var b=c.getElementByKey(g);const l=k.$getNodeByKey(g);
10
- b&&l&&(b=f.applyTableHandlers(l,b,c),a.set(g,b))}):"destroyed"===d&&(h=a.get(g))&&(h.removeListeners(),a.delete(g))})},[c]);return null};
7
+ 'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("@lexical/table"),k=require("lexical"),m=require("react");
8
+ exports.TablePlugin=function(){let [c]=e.useLexicalComposerContext();m.useEffect(()=>{if(!c.hasNodes([f.TableNode,f.TableCellNode,f.TableRowNode]))throw Error("Minified Lexical error #10; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return c.registerCommand(f.INSERT_TABLE_COMMAND,({columns:a,rows:d,includeHeaders:g})=>{var b=k.$getSelection();if(!k.$isRangeSelection(b))return!0;let h=b.focus;b=h.getNode();null!==b&&
9
+ (a=f.$createTableNodeWithDimensions(Number(d),Number(a),g),k.$isRootNode(b)?(d=b.getChildAtIndex(h.offset),null!==d?d.insertBefore(a):b.append(a),a.insertBefore(k.$createParagraphNode())):b.getTopLevelElementOrThrow().insertAfter(a),a.insertAfter(k.$createParagraphNode()),a.getFirstChildOrThrow().getFirstChildOrThrow().select());return!0},k.COMMAND_PRIORITY_EDITOR)},[c]);m.useEffect(()=>{let a=new Map;return c.registerMutationListener(f.TableNode,d=>{for(let [g,b]of d)"created"===b?c.update(()=>{var h=
10
+ c.getElementByKey(g);let l=k.$getNodeByKey(g);h&&l&&(h=f.applyTableHandlers(l,h,c),a.set(g,h))}):"destroyed"===b&&(d=a.get(g))&&(d.removeListeners(),a.delete(g))})},[c]);return null}
@@ -7,7 +7,8 @@
7
7
  */
8
8
 
9
9
  import type {LexicalEditor} from 'lexical';
10
- export default function TreeView(props: {
10
+
11
+ export function TreeView(props: {
11
12
  timeTravelPanelClassName: string;
12
13
  timeTravelPanelSliderClassName: string;
13
14
  timeTravelPanelButtonClassName: string;
@@ -16,7 +16,6 @@ var React = require('react');
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
18
  *
19
- *
20
19
  */
21
20
  const NON_SINGLE_WIDTH_CHARS_REPLACEMENT = Object.freeze({
22
21
  '\t': '\\t',
@@ -101,10 +100,10 @@ function TreeView({
101
100
  const element = treeElementRef.current;
102
101
 
103
102
  if (element !== null) {
104
- // $FlowExpectedError[prop-missing] Internal field
103
+ // @ts-ignore Internal field
105
104
  element.__lexicalEditor = editor;
106
105
  return () => {
107
- // $FlowExpectedError[prop-missing] Internal field
106
+ // @ts-ignore Internal field
108
107
  element.__lexicalEditor = null;
109
108
  };
110
109
  }
@@ -309,7 +308,7 @@ function printSelectedCharsLine({
309
308
 
310
309
  const selectionLastIndent = indent[indent.length - 1] === SYMBOLS.hasNextSibling ? SYMBOLS.ancestorHasNextSibling : SYMBOLS.ancestorIsLastChild;
311
310
  const indentionChars = [...indent.slice(0, indent.length - 1), selectionLastIndent];
312
- const unselectedChars = Array(start).fill(' ');
311
+ const unselectedChars = Array(start + 1).fill(' ');
313
312
  const selectedChars = Array(end - start).fill(SYMBOLS.selectedChar);
314
313
  const paddingLength = typeDisplay.length + 3; // 2 for the spaces around + 1 for the double quote.
315
314
 
@@ -347,4 +346,4 @@ function $getSelectionStartEnd(node, selection) {
347
346
  return [start + numNonSingleWidthCharBeforeSelection, end + numNonSingleWidthCharBeforeSelection + numNonSingleWidthCharInSelection];
348
347
  }
349
348
 
350
- module.exports = TreeView;
349
+ exports.TreeView = TreeView;
@@ -9,7 +9,7 @@
9
9
 
10
10
  import type {LexicalEditor} from 'lexical';
11
11
 
12
- declare export default function TreeView(props: {
12
+ declare export function TreeView(props: {
13
13
  timeTravelPanelClassName: string,
14
14
  timeTravelPanelSliderClassName: string,
15
15
  timeTravelPanelButtonClassName: string,
@@ -4,17 +4,17 @@
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
- var l=require("@lexical/mark"),p=require("lexical"),r=require("react");const D=Object.freeze({"\t":"\\t","\n":"\\n"}),E=new RegExp(Object.keys(D).join("|"),"g"),F=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"\u251c",isLastChild:"\u2514",selectedChar:"^",selectedLine:">"});
8
- function G(a){let b="";const c=H(a),e=a.anchor;a=a.focus;const d=e.offset,f=a.offset;b=b+`: range ${""!==c?`{ ${c} }`:""}`+`\n \u251c anchor { key: ${e.key}, offset: ${null===d?"null":d}, type: ${e.type} }`;return b+=`\n \u2514 focus { key: ${a.key}, offset: ${null===f?"null":f}, type: ${a.type} }`}
9
- function J(a){let b=" root\n";a=a.read(()=>{const c=p.$getSelection();K(p.$getRoot(),(e,d)=>{const f=`(${e.getKey()})`,g=e.getType()||"",m=e.isSelected(),v=l.$isMarkNode(e)?` id: [ ${e.getIDs().join(", ")} ] `:"";var u=b,q=m?F.selectedLine:" ",w=d.join(" ");if(p.$isTextNode(e)){var k=e.getTextContent(!0);const t=0===k.length?"(empty)":`"${L(k)}"`;k=[H(e),M(e),N(e)].filter(Boolean).join(", ");k=[t,0!==k.length?`{ ${k} }`:null].filter(Boolean).join(" ").trim()}else k="";b=u+`${q} ${w} ${f} ${g} ${v} ${k}\n`;
7
+ 'use strict';var l=require("@lexical/mark"),p=require("lexical"),r=require("react");let D=Object.freeze({"\t":"\\t","\n":"\\n"}),E=new RegExp(Object.keys(D).join("|"),"g"),F=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"\u251c",isLastChild:"\u2514",selectedChar:"^",selectedLine:">"});
8
+ function G(a){let b="",c=H(a),e=a.anchor;a=a.focus;let d=e.offset,f=a.offset;b=b+`: range ${""!==c?`{ ${c} }`:""}`+`\n \u251c anchor { key: ${e.key}, offset: ${null===d?"null":d}, type: ${e.type} }`;return b+=`\n \u2514 focus { key: ${a.key}, offset: ${null===f?"null":f}, type: ${a.type} }`}
9
+ function J(a){let b=" root\n";a=a.read(()=>{const c=p.$getSelection();K(p.$getRoot(),(e,d)=>{const f=`(${e.getKey()})`,g=e.getType()||"",m=e.isSelected(),v=l.$isMarkNode(e)?` id: [ ${e.getIDs().join(", ")} ] `:"";var u=b,q=m?F.selectedLine:" ",w=d.join(" ");if(p.$isTextNode(e)){var k=e.getTextContent(!0);let t=0===k.length?"(empty)":`"${L(k)}"`;k=[H(e),M(e),N(e)].filter(Boolean).join(", ");k=[t,0!==k.length?`{ ${k} }`:null].filter(Boolean).join(" ").trim()}else k="";b=u+`${q} ${w} ${f} ${g} ${v} ${k}\n`;
10
10
  b+=O({indent:d,isSelected:m,node:e,nodeKeyDisplay:f,selection:c,typeDisplay:g})});return null===c?": null":p.$isRangeSelection(c)?G(c):p.$isGridSelection(c)?`: grid\n \u2514 { grid: ${c.gridKey}, anchorCell: ${c.anchor.key}, focusCell: ${c.focus.key} }`:`: node\n \u2514 [${Array.from(c._nodes).join(", ")}]`});return b+"\n selection"+a}
11
- function K(a,b,c=[]){a=a.getChildren();const e=a.length;a.forEach((d,f)=>{b(d,c.concat(f===e-1?F.isLastChild:F.hasNextSibling));p.$isElementNode(d)&&K(d,b,c.concat(f===e-1?F.ancestorIsLastChild:F.ancestorHasNextSibling))})}function L(a){return Object.entries(D).reduce((b,[c,e])=>b.replace(new RegExp(c,"g"),String(e)),a)}
12
- const P=[a=>a.hasFormat("bold")&&"Bold",a=>a.hasFormat("code")&&"Code",a=>a.hasFormat("italic")&&"Italic",a=>a.hasFormat("strikethrough")&&"Strikethrough",a=>a.hasFormat("subscript")&&"Subscript",a=>a.hasFormat("superscript")&&"Superscript",a=>a.hasFormat("underline")&&"Underline"],Q=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],R=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented",a=>a.isInert()&&"Inert"];
11
+ function K(a,b,c=[]){a=a.getChildren();let e=a.length;a.forEach((d,f)=>{b(d,c.concat(f===e-1?F.isLastChild:F.hasNextSibling));p.$isElementNode(d)&&K(d,b,c.concat(f===e-1?F.ancestorIsLastChild:F.ancestorHasNextSibling))})}function L(a){return Object.entries(D).reduce((b,[c,e])=>b.replace(new RegExp(c,"g"),String(e)),a)}
12
+ let P=[a=>a.hasFormat("bold")&&"Bold",a=>a.hasFormat("code")&&"Code",a=>a.hasFormat("italic")&&"Italic",a=>a.hasFormat("strikethrough")&&"Strikethrough",a=>a.hasFormat("subscript")&&"Subscript",a=>a.hasFormat("superscript")&&"Superscript",a=>a.hasFormat("underline")&&"Underline"],Q=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],R=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented",a=>a.isInert()&&"Inert"];
13
13
  function M(a){let b=Q.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="detail: "+b);return b}function N(a){let b=R.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="mode: "+b);return b}function H(a){let b=P.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b}
14
- function O({indent:a,isSelected:b,node:c,nodeKeyDisplay:e,selection:d,typeDisplay:f}){if(!p.$isTextNode(c)||!p.$isRangeSelection(d)||!b||p.$isElementNode(c))return"";b=d.anchor;var g=d.focus;if(""===c.getTextContent()||b.getNode()===d.focus.getNode()&&b.offset===g.offset)return"";g=d.anchor;const m=d.focus,v=c.getTextContent(!0),u=v.length;b=d=-1;if("text"===g.type&&"text"===m.type){const k=g.getNode(),t=m.getNode();k===t&&c===k&&g.offset!==m.offset?[d,b]=g.offset<m.offset?[g.offset,m.offset]:[m.offset,
15
- g.offset]:c===k?[d,b]=k.isBefore(t)?[g.offset,u]:[0,g.offset]:c===t?[d,b]=t.isBefore(k)?[m.offset,u]:[0,m.offset]:[d,b]=[0,u]}c=(v.slice(0,d).match(E)||[]).length;g=(v.slice(d,b).match(E)||[]).length;const [q,w]=[d+c,b+c+g];if(q===w)return"";c=a[a.length-1]===F.hasNextSibling?F.ancestorHasNextSibling:F.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(q).fill(" ");d=Array(w-q).fill(F.selectedChar);e=Array(e.length+(f.length+3)).fill(" ");return[F.selectedLine,a.join(" "),[...e,...c,...d].join("")].join(" ")+
14
+ function O({indent:a,isSelected:b,node:c,nodeKeyDisplay:e,selection:d,typeDisplay:f}){if(!p.$isTextNode(c)||!p.$isRangeSelection(d)||!b||p.$isElementNode(c))return"";b=d.anchor;var g=d.focus;if(""===c.getTextContent()||b.getNode()===d.focus.getNode()&&b.offset===g.offset)return"";g=d.anchor;let m=d.focus,v=c.getTextContent(!0),u=v.length;b=d=-1;if("text"===g.type&&"text"===m.type){let k=g.getNode(),t=m.getNode();k===t&&c===k&&g.offset!==m.offset?[d,b]=g.offset<m.offset?[g.offset,m.offset]:[m.offset,
15
+ g.offset]:c===k?[d,b]=k.isBefore(t)?[g.offset,u]:[0,g.offset]:c===t?[d,b]=t.isBefore(k)?[m.offset,u]:[0,m.offset]:[d,b]=[0,u]}c=(v.slice(0,d).match(E)||[]).length;g=(v.slice(d,b).match(E)||[]).length;let [q,w]=[d+c,b+c+g];if(q===w)return"";c=a[a.length-1]===F.hasNextSibling?F.ancestorHasNextSibling:F.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(q+1).fill(" ");d=Array(w-q).fill(F.selectedChar);e=Array(e.length+(f.length+3)).fill(" ");return[F.selectedLine,a.join(" "),[...e,...c,...d].join("")].join(" ")+
16
16
  "\n"}
17
- module.exports=function({timeTravelButtonClassName:a,timeTravelPanelSliderClassName:b,timeTravelPanelButtonClassName:c,viewClassName:e,timeTravelPanelClassName:d,editor:f}){const [g,m]=r.useState([]),[v,u]=r.useState(""),[q,w]=r.useState(!1),k=r.useRef(0),t=r.useRef(null),B=r.useRef(null),[z,C]=r.useState(!1);r.useEffect(()=>{u(J(f.getEditorState()));return f.registerUpdateListener(({editorState:h})=>{const n=f._compositionKey,x=J(f.getEditorState());u([x,null!==n&&`Composition key: ${n}`].filter(Boolean).join("\n\n"));q||
18
- m(A=>[...A,[Date.now(),h]])})},[q,f]);const y=g.length;r.useEffect(()=>{if(z){let h;const n=()=>{const x=k.current;x===y-1?C(!1):h=setTimeout(()=>{k.current++;const A=k.current,I=B.current;null!==I&&(I.value=String(A));f.setEditorState(g[A][1]);n()},g[x+1][0]-g[x][0])};n();return()=>{window.clearTimeout(h)}}},[g,z,f,y]);r.useEffect(()=>{const h=t.current;if(null!==h)return h.__lexicalEditor=f,()=>{h.__lexicalEditor=null}},[f]);return r.createElement("div",{className:e},!q&&2<y&&r.createElement("button",
19
- {onClick:()=>{const h=f.getRootElement();null!==h&&(h.contentEditable="false",k.current=y-1,w(!0))},className:a},"Time Travel"),r.createElement("pre",{ref:t},v),q&&r.createElement("div",{className:d},r.createElement("button",{className:c,onClick:()=>{C(!z)}},z?"Pause":"Play"),r.createElement("input",{className:b,ref:B,onChange:h=>{h=Number(h.target.value);const n=g[h];n&&(k.current=h,f.setEditorState(n[1]))},type:"range",min:"1",max:y-1}),r.createElement("button",{className:c,onClick:()=>{var h=f.getRootElement();
20
- if(null!==h){h.contentEditable="true";h=g.length-1;f.setEditorState(g[h][1]);const n=B.current;null!==n&&(n.value=String(h));w(!1);C(!1)}}},"Exit")))};
17
+ exports.TreeView=function({timeTravelButtonClassName:a,timeTravelPanelSliderClassName:b,timeTravelPanelButtonClassName:c,viewClassName:e,timeTravelPanelClassName:d,editor:f}){let [g,m]=r.useState([]),[v,u]=r.useState(""),[q,w]=r.useState(!1),k=r.useRef(0),t=r.useRef(null),B=r.useRef(null),[z,C]=r.useState(!1);r.useEffect(()=>{u(J(f.getEditorState()));return f.registerUpdateListener(({editorState:h})=>{let n=f._compositionKey,x=J(f.getEditorState());u([x,null!==n&&`Composition key: ${n}`].filter(Boolean).join("\n\n"));q||
18
+ m(A=>[...A,[Date.now(),h]])})},[q,f]);let y=g.length;r.useEffect(()=>{if(z){let h,n=()=>{const x=k.current;x===y-1?C(!1):h=setTimeout(()=>{k.current++;const A=k.current,I=B.current;null!==I&&(I.value=String(A));f.setEditorState(g[A][1]);n()},g[x+1][0]-g[x][0])};n();return()=>{window.clearTimeout(h)}}},[g,z,f,y]);r.useEffect(()=>{let h=t.current;if(null!==h)return h.__lexicalEditor=f,()=>{h.__lexicalEditor=null}},[f]);return r.createElement("div",{className:e},!q&&2<y&&r.createElement("button",{onClick:()=>
19
+ {let h=f.getRootElement();null!==h&&(h.contentEditable="false",k.current=y-1,w(!0))},className:a},"Time Travel"),r.createElement("pre",{ref:t},v),q&&r.createElement("div",{className:d},r.createElement("button",{className:c,onClick:()=>{C(!z)}},z?"Pause":"Play"),r.createElement("input",{className:b,ref:B,onChange:h=>{h=Number(h.target.value);let n=g[h];n&&(k.current=h,f.setEditorState(n[1]))},type:"range",min:"1",max:y-1}),r.createElement("button",{className:c,onClick:()=>{var h=f.getRootElement();
20
+ if(null!==h){h.contentEditable="true";h=g.length-1;f.setEditorState(g[h][1]);let n=B.current;null!==n&&(n.value=String(h));w(!1);C(!1)}}},"Exit")))}
package/README.md CHANGED
@@ -16,11 +16,11 @@ Below is an example of a basic plain text editor using `lexical` and `@lexical/r
16
16
  import {$getRoot, $getSelection} from 'lexical';
17
17
  import {useEffect} from 'react';
18
18
 
19
- import LexicalComposer from '@lexical/react/LexicalComposer';
20
- import LexicalPlainTextPlugin from '@lexical/react/LexicalPlainTextPlugin';
21
- import LexicalContentEditable from '@lexical/react/LexicalContentEditable';
19
+ import {LexicalComposer} from '@lexical/react/LexicalComposer';
20
+ import {LexicalPlainTextPlugin} from '@lexical/react/LexicalPlainTextPlugin';
21
+ import {LexicalContentEditable} from '@lexical/react/LexicalContentEditable';
22
22
  import {HistoryPlugin} from '@lexical/react/LexicalHistoryPlugin';
23
- import LexicalOnChangePlugin from '@lexical/react/LexicalOnChangePlugin';
23
+ import {LexicalOnChangePlugin} from '@lexical/react/LexicalOnChangePlugin';
24
24
  import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
25
25
 
26
26
  const theme = {
@@ -47,7 +47,9 @@ function onChange(editorState) {
47
47
  function MyCustomAutoFocusPlugin() {
48
48
  const [editor] = useLexicalComposerContext();
49
49
 
50
- useEffect(() => {
50
+
51
+
52
+ useEffect(() => {
51
53
  // Focus the editor when the effect fires!
52
54
  editor.focus();
53
55
  }, [editor]);
@@ -68,7 +70,9 @@ function Editor() {
68
70
  onError,
69
71
  };
70
72
 
71
- return (
73
+
74
+
75
+ return (
72
76
  <LexicalComposer initialConfig={initialConfig}>
73
77
  <LexicalPlainTextPlugin
74
78
  contentEditable={<LexicalContentEditable />}
package/package.json CHANGED
@@ -8,28 +8,28 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.2.7",
11
+ "version": "0.3.0",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.2.7",
14
- "@lexical/list": "0.2.7",
15
- "@lexical/table": "0.2.7",
16
- "@lexical/yjs": "0.2.7",
17
- "@lexical/hashtag": "0.2.7",
18
- "@lexical/selection": "0.2.7",
19
- "@lexical/utils": "0.2.7",
20
- "@lexical/dragon": "0.2.7",
21
- "@lexical/plain-text": "0.2.7",
22
- "@lexical/rich-text": "0.2.7",
23
- "@lexical/code": "0.2.7",
24
- "@lexical/text": "0.2.7",
25
- "@lexical/link": "0.2.7",
26
- "@lexical/overflow": "0.2.7",
27
- "@lexical/history": "0.2.7",
28
- "@lexical/markdown": "0.2.7",
29
- "@lexical/mark": "0.2.7"
13
+ "@lexical/clipboard": "0.3.0",
14
+ "@lexical/list": "0.3.0",
15
+ "@lexical/table": "0.3.0",
16
+ "@lexical/yjs": "0.3.0",
17
+ "@lexical/hashtag": "0.3.0",
18
+ "@lexical/selection": "0.3.0",
19
+ "@lexical/utils": "0.3.0",
20
+ "@lexical/dragon": "0.3.0",
21
+ "@lexical/plain-text": "0.3.0",
22
+ "@lexical/rich-text": "0.3.0",
23
+ "@lexical/code": "0.3.0",
24
+ "@lexical/text": "0.3.0",
25
+ "@lexical/link": "0.3.0",
26
+ "@lexical/overflow": "0.3.0",
27
+ "@lexical/history": "0.3.0",
28
+ "@lexical/markdown": "0.3.0",
29
+ "@lexical/mark": "0.3.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "lexical": "0.2.7",
32
+ "lexical": "0.3.0",
33
33
  "react": ">=17.x",
34
34
  "react-dom": ">=17.x"
35
35
  },
@@ -7,7 +7,8 @@
7
7
  */
8
8
 
9
9
  import type {LexicalEditor} from 'lexical';
10
- export default function useLexicalIsTextContentEmpty(
10
+
11
+ export function useLexicalIsTextContentEmpty(
11
12
  editor: LexicalEditor,
12
13
  trim?: boolean,
13
14
  ): boolean;
@@ -15,7 +15,6 @@ var react = require('react');
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
17
  *
18
- *
19
18
  */
20
19
  const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
21
20
 
@@ -25,18 +24,16 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
25
24
  * This source code is licensed under the MIT license found in the
26
25
  * LICENSE file in the root directory of this source tree.
27
26
  *
28
- *
29
27
  */
30
28
  const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
31
29
  var useLayoutEffect = useLayoutEffectImpl;
32
30
 
33
31
  /**
34
- * Copyright (c) Facebook, Inc. and its affiliates.
32
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
35
33
  *
36
34
  * This source code is licensed under the MIT license found in the
37
35
  * LICENSE file in the root directory of this source tree.
38
36
  *
39
- *
40
37
  */
41
38
  function useLexicalIsTextContentEmpty(editor, trim) {
42
39
  const [isEmpty, setIsEmpty] = react.useState(editor.getEditorState().read(text.$isRootTextContentEmptyCurry(editor.isComposing(), trim)));
@@ -52,4 +49,4 @@ function useLexicalIsTextContentEmpty(editor, trim) {
52
49
  return isEmpty;
53
50
  }
54
51
 
55
- module.exports = useLexicalIsTextContentEmpty;
52
+ exports.useLexicalIsTextContentEmpty = useLexicalIsTextContentEmpty;
@@ -9,7 +9,7 @@
9
9
 
10
10
  import type {LexicalEditor} from 'lexical';
11
11
 
12
- declare export default function useLexicalIsTextContentEmpty(
12
+ declare export function useLexicalIsTextContentEmpty(
13
13
  editor: LexicalEditor,
14
14
  trim?: boolean,
15
15
  ): boolean;
@@ -4,4 +4,4 @@
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
- var b=require("@lexical/text"),e=require("react"),f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;module.exports=function(a,c){const [g,h]=e.useState(a.getEditorState().read(b.$isRootTextContentEmptyCurry(a.isComposing(),c)));f(()=>a.registerUpdateListener(({editorState:d})=>{const k=a.isComposing();d=d.read(b.$isRootTextContentEmptyCurry(k,c));h(d)}),[a,c]);return g};
7
+ 'use strict';var b=require("@lexical/text"),e=require("react"),f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;exports.useLexicalIsTextContentEmpty=function(a,c){let [g,h]=e.useState(a.getEditorState().read(b.$isRootTextContentEmptyCurry(a.isComposing(),c)));f(()=>a.registerUpdateListener(({editorState:d})=>{let k=a.isComposing();d=d.read(b.$isRootTextContentEmptyCurry(k,c));h(d)}),[a,c]);return g}
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  import type {NodeKey} from 'lexical';
10
- export default function useLexicalNodeSelection(
10
+
11
+ export function useLexicalNodeSelection(
11
12
  key: NodeKey,
12
13
  ): [boolean, (arg0: boolean) => void, () => void];
@@ -16,7 +16,6 @@ var react = require('react');
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
18
  *
19
- *
20
19
  */
21
20
 
22
21
  function isNodeSelected(editor, key) {
@@ -67,4 +66,4 @@ function useLexicalNodeSelection(key) {
67
66
  return [isSelected, setSelected, clearSelected];
68
67
  }
69
68
 
70
- module.exports = useLexicalNodeSelection;
69
+ exports.useLexicalNodeSelection = useLexicalNodeSelection;
@@ -9,6 +9,6 @@
9
9
 
10
10
  import type {NodeKey} from 'lexical';
11
11
 
12
- declare export default function useLexicalNodeSelection(
12
+ declare export function useLexicalNodeSelection(
13
13
  key: NodeKey,
14
14
  ): [boolean, (boolean) => void, () => void];
@@ -4,5 +4,5 @@
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
- var c=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),h=require("react");function k(b,a){return b.getEditorState().read(()=>{const f=e.$getNodeByKey(a);return null===f?!1:f.isSelected()})}
8
- module.exports=function(b){const [a]=c.useLexicalComposerContext(),[f,l]=h.useState(()=>k(a,b));h.useEffect(()=>a.registerUpdateListener(()=>{l(k(a,b))}),[a,b]);const m=h.useCallback(g=>{a.update(()=>{let d=e.$getSelection();e.$isNodeSelection(d)||(d=e.$createNodeSelection(),e.$setSelection(d));g?d.add(b):d.delete(b)})},[a,b]),n=h.useCallback(()=>{a.update(()=>{const g=e.$getSelection();e.$isNodeSelection(g)&&g.clear()})},[a]);return[f,m,n]};
7
+ 'use strict';var c=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),h=require("react");function k(b,a){return b.getEditorState().read(()=>{let f=e.$getNodeByKey(a);return null===f?!1:f.isSelected()})}
8
+ exports.useLexicalNodeSelection=function(b){let [a]=c.useLexicalComposerContext(),[f,l]=h.useState(()=>k(a,b));h.useEffect(()=>a.registerUpdateListener(()=>{l(k(a,b))}),[a,b]);let m=h.useCallback(g=>{a.update(()=>{let d=e.$getSelection();e.$isNodeSelection(d)||(d=e.$createNodeSelection(),e.$setSelection(d));g?d.add(b):d.delete(b)})},[a,b]),n=h.useCallback(()=>{a.update(()=>{const g=e.$getSelection();e.$isNodeSelection(g)&&g.clear()})},[a]);return[f,m,n]}
@@ -8,11 +8,12 @@
8
8
 
9
9
  import {Class} from 'utility-types';
10
10
  import type {TextNode} from 'lexical';
11
+
11
12
  export type EntityMatch = {
12
13
  end: number;
13
14
  start: number;
14
15
  };
15
- export default function useLexicalTextEntity<N extends TextNode>(
16
+ export function useLexicalTextEntity<N extends TextNode>(
16
17
  getMatch: (text: string) => null | EntityMatch,
17
18
  targetNode: Class<N>,
18
19
  createNode: (textNode: TextNode) => N,