@lexical/react 0.3.3 → 0.3.6

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 (85) hide show
  1. package/DEPRECATED_useLexical.d.ts +18 -0
  2. package/DEPRECATED_useLexical.dev.js +18 -9
  3. package/DEPRECATED_useLexical.js.flow +4 -1
  4. package/DEPRECATED_useLexical.prod.js +2 -3
  5. package/DEPRECATED_useLexicalAutoFormatter.d.ts +9 -0
  6. package/DEPRECATED_useLexicalAutoFormatter.js.flow +4 -1
  7. package/DEPRECATED_useLexicalCanShowPlaceholder.d.ts +9 -0
  8. package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +18 -9
  9. package/DEPRECATED_useLexicalCanShowPlaceholder.js.flow +4 -1
  10. package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +2 -2
  11. package/DEPRECATED_useLexicalCharacterLimit.d.ts +8 -0
  12. package/DEPRECATED_useLexicalCharacterLimit.js.flow +4 -1
  13. package/DEPRECATED_useLexicalDecorators.d.ts +9 -0
  14. package/DEPRECATED_useLexicalDecorators.js.flow +4 -1
  15. package/DEPRECATED_useLexicalEditor.d.ts +9 -0
  16. package/DEPRECATED_useLexicalEditor.dev.js +18 -9
  17. package/DEPRECATED_useLexicalEditor.prod.js +2 -2
  18. package/DEPRECATED_useLexicalEditorEvents.d.ts +10 -0
  19. package/DEPRECATED_useLexicalEditorEvents.js.flow +4 -1
  20. package/DEPRECATED_useLexicalHistory.d.ts +12 -0
  21. package/DEPRECATED_useLexicalHistory.js.flow +4 -1
  22. package/DEPRECATED_useLexicalList.d.ts +9 -0
  23. package/DEPRECATED_useLexicalList.js.flow +4 -1
  24. package/DEPRECATED_useLexicalPlainText.d.ts +10 -0
  25. package/DEPRECATED_useLexicalPlainText.js.flow +4 -1
  26. package/DEPRECATED_useLexicalRichText.d.ts +10 -0
  27. package/DEPRECATED_useLexicalRichText.js.flow +4 -1
  28. package/LexicalAutoFocusPlugin.d.ts +1 -2
  29. package/LexicalAutoFocusPlugin.dev.js +1 -1
  30. package/LexicalAutoFocusPlugin.prod.js +1 -1
  31. package/LexicalAutoLinkPlugin.d.ts +11 -11
  32. package/LexicalAutoScrollPlugin.d.ts +6 -4
  33. package/LexicalBlockWithAlignableContents.d.ts +12 -8
  34. package/LexicalBlockWithAlignableContents.dev.js +6 -6
  35. package/LexicalBlockWithAlignableContents.js.flow +4 -0
  36. package/LexicalBlockWithAlignableContents.prod.js +4 -4
  37. package/LexicalCharacterLimitPlugin.d.ts +3 -4
  38. package/LexicalCheckListPlugin.d.ts +1 -2
  39. package/LexicalCheckListPlugin.dev.js +11 -6
  40. package/LexicalCheckListPlugin.prod.js +7 -7
  41. package/LexicalClearEditorPlugin.d.ts +4 -4
  42. package/LexicalCollaborationPlugin.d.ts +17 -31
  43. package/LexicalComposer.d.ts +16 -15
  44. package/LexicalComposer.dev.js +39 -1
  45. package/LexicalComposer.js.flow +5 -0
  46. package/LexicalComposer.prod.js +3 -2
  47. package/LexicalComposerContext.d.ts +10 -15
  48. package/LexicalContentEditable.d.ts +24 -23
  49. package/LexicalContentEditable.dev.js +3 -3
  50. package/LexicalContentEditable.prod.js +1 -1
  51. package/LexicalDecoratorBlockNode.d.ts +13 -24
  52. package/LexicalDecoratorBlockNode.dev.js +1 -1
  53. package/LexicalDecoratorBlockNode.prod.js +1 -1
  54. package/LexicalHashtagPlugin.d.ts +1 -2
  55. package/LexicalHistoryPlugin.d.ts +6 -23
  56. package/LexicalHorizontalRuleNode.d.ts +19 -17
  57. package/LexicalLinkPlugin.d.ts +1 -2
  58. package/LexicalLinkPlugin.dev.js +1 -0
  59. package/LexicalListPlugin.d.ts +1 -2
  60. package/LexicalMarkdownShortcutPlugin.d.ts +4 -6
  61. package/LexicalNestedComposer.d.ts +7 -8
  62. package/LexicalOnChangePlugin.d.ts +5 -7
  63. package/LexicalPlainTextPlugin.d.ts +6 -9
  64. package/LexicalPlainTextPlugin.dev.js +43 -11
  65. package/LexicalPlainTextPlugin.prod.js +4 -4
  66. package/LexicalRichTextPlugin.d.ts +6 -9
  67. package/LexicalRichTextPlugin.dev.js +43 -11
  68. package/LexicalRichTextPlugin.prod.js +4 -4
  69. package/LexicalTablePlugin.d.ts +1 -2
  70. package/LexicalTablePlugin.dev.js +1 -1
  71. package/LexicalTablePlugin.prod.js +3 -3
  72. package/LexicalTreeView.d.ts +9 -11
  73. package/package.json +19 -22
  74. package/shared/useCanShowPlaceholder.d.ts +9 -0
  75. package/shared/useCharacterLimit.d.ts +16 -0
  76. package/shared/useDecorators.d.ts +9 -0
  77. package/shared/useEditorEvents.d.ts +10 -0
  78. package/shared/useHistory.d.ts +10 -0
  79. package/shared/useList.d.ts +9 -0
  80. package/shared/usePlainTextSetup.d.ts +10 -0
  81. package/shared/useRichTextSetup.d.ts +10 -0
  82. package/shared/useYjsCollaboration.d.ts +14 -0
  83. package/useLexicalIsTextContentEmpty.d.ts +2 -7
  84. package/useLexicalNodeSelection.d.ts +2 -6
  85. package/useLexicalTextEntity.d.ts +3 -13
@@ -9,10 +9,29 @@
9
9
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
10
  var React = require('react');
11
11
  var text = require('@lexical/text');
12
+ var utils = require('@lexical/utils');
12
13
  var reactDom = require('react-dom');
13
14
  var dragon = require('@lexical/dragon');
14
15
  var plainText = require('@lexical/plain-text');
15
- var utils = require('@lexical/utils');
16
+
17
+ /**
18
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
19
+ *
20
+ * This source code is licensed under the MIT license found in the
21
+ * LICENSE file in the root directory of this source tree.
22
+ *
23
+ */
24
+ function warnOnlyOnce(message) {
25
+
26
+ let run = false;
27
+ return () => {
28
+ if (!run) {
29
+ console.warn(message);
30
+ }
31
+
32
+ run = true;
33
+ };
34
+ }
16
35
 
17
36
  /**
18
37
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -40,18 +59,26 @@ var useLayoutEffect = useLayoutEffectImpl;
40
59
  * LICENSE file in the root directory of this source tree.
41
60
  *
42
61
  */
62
+
63
+ function canShowPlaceholderFromCurrentEditorState(editor) {
64
+ const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
65
+ return currentCanShowPlaceholder;
66
+ }
67
+
43
68
  function useCanShowPlaceholder(editor) {
44
- const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
69
+ const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
45
70
  useLayoutEffect(() => {
46
- let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
47
- setCanShowPlaceholder(currentCanShowPlaceholder);
48
- return editor.registerUpdateListener(({
49
- editorState
50
- }) => {
51
- const isComposing = editor.isComposing();
52
- currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
71
+ function resetCanShowPlaceholder() {
72
+ const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
53
73
  setCanShowPlaceholder(currentCanShowPlaceholder);
54
- });
74
+ }
75
+
76
+ resetCanShowPlaceholder();
77
+ return utils.mergeRegister(editor.registerUpdateListener(() => {
78
+ resetCanShowPlaceholder();
79
+ }), editor.registerReadOnlyListener(() => {
80
+ resetCanShowPlaceholder();
81
+ }));
55
82
  }, [editor]);
56
83
  return canShowPlaceholder;
57
84
  }
@@ -119,15 +146,20 @@ function usePlainTextSetup(editor, initialEditorState) {
119
146
  * LICENSE file in the root directory of this source tree.
120
147
  *
121
148
  */
149
+ const deprecatedInitialEditorStateWarning = warnOnlyOnce('`initialEditorState` on `PlainTextPlugin` is deprecated and will be removed soon. Use the `initialConfig.editorState` prop on the `LexicalComposer` instead.');
122
150
  function PlainTextPlugin({
123
151
  contentEditable,
124
152
  placeholder,
125
153
  initialEditorState
126
154
  }) {
155
+ if (deprecatedInitialEditorStateWarning && initialEditorState !== undefined) {
156
+ deprecatedInitialEditorStateWarning();
157
+ }
158
+
127
159
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
128
160
  const showPlaceholder = useCanShowPlaceholder(editor);
129
- usePlainTextSetup(editor, initialEditorState);
130
161
  const decorators = useDecorators(editor);
162
+ usePlainTextSetup(editor, initialEditorState);
131
163
  return /*#__PURE__*/React.createElement(React.Fragment, null, contentEditable, showPlaceholder && placeholder, decorators);
132
164
  }
133
165
 
@@ -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
- '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
+ 'use strict';var d=require("@lexical/react/LexicalComposerContext"),h=require("react"),l=require("@lexical/text"),m=require("@lexical/utils"),n=require("react-dom"),p=require("@lexical/dragon"),q=require("@lexical/plain-text"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;function t(a){return a.getEditorState().read(l.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
8
+ function u(a){let [c,f]=h.useState(()=>t(a));r(()=>{function b(){let g=t(a);f(g)}b();return m.mergeRegister(a.registerUpdateListener(()=>{b()}),a.registerReadOnlyListener(()=>{b()}))},[a]);return c}
9
+ function v(a){let [c,f]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{n.flushSync(()=>{f(b)})}),[a]);h.useEffect(()=>{f(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],g=Object.keys(c);for(let k=0;k<g.length;k++){var e=g[k];let w=c[e];e=a.getElementByKey(e);null!==e&&b.push(n.createPortal(w,e))}return b},[c,a])}function x(a,c){r(()=>m.mergeRegister(q.registerPlainText(a,c),p.registerDragonSupport(a)),[a])}
10
+ exports.PlainTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:f}){let [b]=d.useLexicalComposerContext(),g=u(b),e=v(b);x(b,f);return h.createElement(h.Fragment,null,a,g&&c,e)}
@@ -5,12 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import {InitialEditorStateType} from '@lexical/rich-text';
10
- import type {EditorState, LexicalEditor} from 'lexical';
11
-
12
- export function RichTextPlugin(arg0: {
13
- contentEditable: JSX.Element | null;
14
- initialEditorState?: InitialEditorStateType;
15
- placeholder: JSX.Element | string | null;
16
- }): JSX.Element | null;
8
+ import { InitialEditorStateType } from '@lexical/rich-text';
9
+ export declare function RichTextPlugin({ contentEditable, placeholder, initialEditorState, }: Readonly<{
10
+ contentEditable: JSX.Element;
11
+ initialEditorState?: InitialEditorStateType;
12
+ placeholder: JSX.Element | string;
13
+ }>): JSX.Element;
@@ -9,10 +9,29 @@
9
9
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
10
  var React = require('react');
11
11
  var text = require('@lexical/text');
12
+ var utils = require('@lexical/utils');
12
13
  var reactDom = require('react-dom');
13
14
  var dragon = require('@lexical/dragon');
14
15
  var richText = require('@lexical/rich-text');
15
- var utils = require('@lexical/utils');
16
+
17
+ /**
18
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
19
+ *
20
+ * This source code is licensed under the MIT license found in the
21
+ * LICENSE file in the root directory of this source tree.
22
+ *
23
+ */
24
+ function warnOnlyOnce(message) {
25
+
26
+ let run = false;
27
+ return () => {
28
+ if (!run) {
29
+ console.warn(message);
30
+ }
31
+
32
+ run = true;
33
+ };
34
+ }
16
35
 
17
36
  /**
18
37
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -40,18 +59,26 @@ var useLayoutEffect = useLayoutEffectImpl;
40
59
  * LICENSE file in the root directory of this source tree.
41
60
  *
42
61
  */
62
+
63
+ function canShowPlaceholderFromCurrentEditorState(editor) {
64
+ const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
65
+ return currentCanShowPlaceholder;
66
+ }
67
+
43
68
  function useCanShowPlaceholder(editor) {
44
- const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
69
+ const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
45
70
  useLayoutEffect(() => {
46
- let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
47
- setCanShowPlaceholder(currentCanShowPlaceholder);
48
- return editor.registerUpdateListener(({
49
- editorState
50
- }) => {
51
- const isComposing = editor.isComposing();
52
- currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
71
+ function resetCanShowPlaceholder() {
72
+ const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
53
73
  setCanShowPlaceholder(currentCanShowPlaceholder);
54
- });
74
+ }
75
+
76
+ resetCanShowPlaceholder();
77
+ return utils.mergeRegister(editor.registerUpdateListener(() => {
78
+ resetCanShowPlaceholder();
79
+ }), editor.registerReadOnlyListener(() => {
80
+ resetCanShowPlaceholder();
81
+ }));
55
82
  }, [editor]);
56
83
  return canShowPlaceholder;
57
84
  }
@@ -119,15 +146,20 @@ function useRichTextSetup(editor, initialEditorState) {
119
146
  * LICENSE file in the root directory of this source tree.
120
147
  *
121
148
  */
149
+ const deprecatedInitialEditorStateWarning = warnOnlyOnce('`initialEditorState` on `RichTextPlugin` is deprecated and will be removed soon. Use the `initialConfig.editorState` prop on the `LexicalComposer` instead.');
122
150
  function RichTextPlugin({
123
151
  contentEditable,
124
152
  placeholder,
125
153
  initialEditorState
126
154
  }) {
155
+ if (deprecatedInitialEditorStateWarning && initialEditorState !== undefined) {
156
+ deprecatedInitialEditorStateWarning();
157
+ }
158
+
127
159
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
128
160
  const showPlaceholder = useCanShowPlaceholder(editor);
129
- useRichTextSetup(editor, initialEditorState);
130
161
  const decorators = useDecorators(editor);
162
+ useRichTextSetup(editor, initialEditorState);
131
163
  return /*#__PURE__*/React.createElement(React.Fragment, null, contentEditable, showPlaceholder && placeholder, decorators);
132
164
  }
133
165
 
@@ -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
- '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)}
7
+ 'use strict';var d=require("@lexical/react/LexicalComposerContext"),h=require("react"),l=require("@lexical/text"),m=require("@lexical/utils"),n=require("react-dom"),p=require("@lexical/dragon"),q=require("@lexical/rich-text"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;function t(a){return a.getEditorState().read(l.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
8
+ function u(a){let [c,f]=h.useState(()=>t(a));r(()=>{function b(){let g=t(a);f(g)}b();return m.mergeRegister(a.registerUpdateListener(()=>{b()}),a.registerReadOnlyListener(()=>{b()}))},[a]);return c}
9
+ function v(a){let [c,f]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{n.flushSync(()=>{f(b)})}),[a]);h.useEffect(()=>{f(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],g=Object.keys(c);for(let k=0;k<g.length;k++){var e=g[k];let w=c[e];e=a.getElementByKey(e);null!==e&&b.push(n.createPortal(w,e))}return b},[c,a])}function x(a,c){r(()=>m.mergeRegister(q.registerRichText(a,c),p.registerDragonSupport(a)),[a])}
10
+ exports.RichTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:f}){let [b]=d.useLexicalComposerContext(),g=u(b),e=v(b);x(b,f);return h.createElement(h.Fragment,null,a,g&&c,e)}
@@ -5,5 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- export function TablePlugin(): null;
8
+ export declare function TablePlugin(): JSX.Element | null;
@@ -84,7 +84,7 @@ function TablePlugin() {
84
84
  } else if (mutation === 'destroyed') {
85
85
  const tableSelection = tableSelections.get(nodeKey);
86
86
 
87
- if (tableSelection) {
87
+ if (tableSelection !== undefined) {
88
88
  tableSelection.removeListeners();
89
89
  tableSelections.delete(nodeKey);
90
90
  }
@@ -5,6 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
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}
8
+ exports.TablePlugin=function(){let [d]=e.useLexicalComposerContext();m.useEffect(()=>{if(!d.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 d.registerCommand(f.INSERT_TABLE_COMMAND,({columns:a,rows:c,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(c),Number(a),g),k.$isRootNode(b)?(c=b.getChildAtIndex(h.offset),null!==c?c.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)},[d]);m.useEffect(()=>{let a=new Map;return d.registerMutationListener(f.TableNode,c=>{for(let [g,b]of c)"created"===b?d.update(()=>{var h=
10
+ d.getElementByKey(g);let l=k.$getNodeByKey(g);h&&l&&(h=f.applyTableHandlers(l,h,d),a.set(g,h))}):"destroyed"===b&&(c=a.get(g),void 0!==c&&(c.removeListeners(),a.delete(g)))})},[d]);return null}
@@ -5,14 +5,12 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {LexicalEditor} from 'lexical';
10
-
11
- export function TreeView(props: {
12
- timeTravelPanelClassName: string;
13
- timeTravelPanelSliderClassName: string;
14
- timeTravelPanelButtonClassName: string;
15
- timeTravelButtonClassName: string;
16
- viewClassName: string;
17
- editor: LexicalEditor;
18
- }): JSX.Element | null;
8
+ import type { LexicalEditor } from 'lexical';
9
+ export declare function TreeView({ timeTravelButtonClassName, timeTravelPanelSliderClassName, timeTravelPanelButtonClassName, viewClassName, timeTravelPanelClassName, editor, }: {
10
+ editor: LexicalEditor;
11
+ timeTravelButtonClassName: string;
12
+ timeTravelPanelButtonClassName: string;
13
+ timeTravelPanelClassName: string;
14
+ timeTravelPanelSliderClassName: string;
15
+ viewClassName: string;
16
+ }): JSX.Element;
package/package.json CHANGED
@@ -8,28 +8,28 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.3.3",
11
+ "version": "0.3.6",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.3.3",
14
- "@lexical/code": "0.3.3",
15
- "@lexical/dragon": "0.3.3",
16
- "@lexical/hashtag": "0.3.3",
17
- "@lexical/history": "0.3.3",
18
- "@lexical/link": "0.3.3",
19
- "@lexical/list": "0.3.3",
20
- "@lexical/mark": "0.3.3",
21
- "@lexical/markdown": "0.3.3",
22
- "@lexical/overflow": "0.3.3",
23
- "@lexical/plain-text": "0.3.3",
24
- "@lexical/rich-text": "0.3.3",
25
- "@lexical/selection": "0.3.3",
26
- "@lexical/table": "0.3.3",
27
- "@lexical/text": "0.3.3",
28
- "@lexical/utils": "0.3.3",
29
- "@lexical/yjs": "0.3.3"
13
+ "@lexical/clipboard": "0.3.6",
14
+ "@lexical/code": "0.3.6",
15
+ "@lexical/dragon": "0.3.6",
16
+ "@lexical/hashtag": "0.3.6",
17
+ "@lexical/history": "0.3.6",
18
+ "@lexical/link": "0.3.6",
19
+ "@lexical/list": "0.3.6",
20
+ "@lexical/mark": "0.3.6",
21
+ "@lexical/markdown": "0.3.6",
22
+ "@lexical/overflow": "0.3.6",
23
+ "@lexical/plain-text": "0.3.6",
24
+ "@lexical/rich-text": "0.3.6",
25
+ "@lexical/selection": "0.3.6",
26
+ "@lexical/table": "0.3.6",
27
+ "@lexical/text": "0.3.6",
28
+ "@lexical/utils": "0.3.6",
29
+ "@lexical/yjs": "0.3.6"
30
30
  },
31
31
  "peerDependencies": {
32
- "lexical": "0.3.3",
32
+ "lexical": "0.3.6",
33
33
  "react": ">=17.x",
34
34
  "react-dom": ">=17.x"
35
35
  },
@@ -37,8 +37,5 @@
37
37
  "type": "git",
38
38
  "url": "https://github.com/facebook/lexical",
39
39
  "directory": "packages/lexical-react"
40
- },
41
- "devDependencies": {
42
- "utility-types": "^3.10.0"
43
40
  }
44
41
  }
@@ -0,0 +1,9 @@
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
+ */
8
+ import type { LexicalEditor } from 'lexical';
9
+ export declare function useCanShowPlaceholder(editor: LexicalEditor): boolean;
@@ -0,0 +1,16 @@
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
+ */
8
+ import type { LexicalEditor } from 'lexical';
9
+ import { OverflowNode } from '@lexical/overflow';
10
+ declare type OptionalProps = {
11
+ remainingCharacters?: (characters: number) => void;
12
+ strlen?: (input: string) => number;
13
+ };
14
+ export declare function useCharacterLimit(editor: LexicalEditor, maxCharacters: number, optional?: OptionalProps): void;
15
+ export declare function mergePrevious(overflowNode: OverflowNode): void;
16
+ export {};
@@ -0,0 +1,9 @@
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
+ */
8
+ import type { LexicalEditor } from 'lexical';
9
+ export declare function useDecorators(editor: LexicalEditor): Array<JSX.Element>;
@@ -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
+ */
8
+ import type { EventHandler, LexicalEditor } from 'lexical';
9
+ export declare type InputEvents = Array<[string, EventHandler]>;
10
+ export declare function useEditorEvents(events: InputEvents, editor: LexicalEditor): void;
@@ -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
+ */
8
+ import type { HistoryState } from '@lexical/history';
9
+ import type { LexicalEditor } from 'lexical';
10
+ export declare function useHistory(editor: LexicalEditor, externalHistoryState?: HistoryState, delay?: number): void;
@@ -0,0 +1,9 @@
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
+ */
8
+ import type { LexicalEditor } from 'lexical';
9
+ export declare function useList(editor: LexicalEditor): void;
@@ -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
+ */
8
+ import type { LexicalEditor } from 'lexical';
9
+ import { InitialEditorStateType } from '@lexical/plain-text';
10
+ export declare function usePlainTextSetup(editor: LexicalEditor, initialEditorState?: InitialEditorStateType): void;
@@ -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
+ */
8
+ import type { InitialEditorStateType } from '@lexical/rich-text';
9
+ import type { LexicalEditor } from 'lexical';
10
+ export declare function useRichTextSetup(editor: LexicalEditor, initialEditorState?: InitialEditorStateType): void;
@@ -0,0 +1,14 @@
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
+ */
8
+ import type { Binding } from '@lexical/yjs';
9
+ import type { LexicalEditor } from 'lexical';
10
+ import type { Doc } from 'yjs';
11
+ import { WebsocketProvider } from 'y-websocket';
12
+ export declare function useYjsCollaboration(editor: LexicalEditor, id: string, provider: WebsocketProvider, docMap: Map<string, Doc>, name: string, color: string, shouldBootstrap: boolean): [JSX.Element, Binding];
13
+ export declare function useYjsFocusTracking(editor: LexicalEditor, provider: WebsocketProvider, name: string, color: string): void;
14
+ export declare function useYjsHistory(editor: LexicalEditor, binding: Binding): () => void;
@@ -5,10 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {LexicalEditor} from 'lexical';
10
-
11
- export function useLexicalIsTextContentEmpty(
12
- editor: LexicalEditor,
13
- trim?: boolean,
14
- ): boolean;
8
+ import type { LexicalEditor } from 'lexical';
9
+ export declare function useLexicalIsTextContentEmpty(editor: LexicalEditor, trim?: boolean): boolean;
@@ -5,9 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {NodeKey} from 'lexical';
10
-
11
- export function useLexicalNodeSelection(
12
- key: NodeKey,
13
- ): [boolean, (arg0: boolean) => void, () => void];
8
+ import type { NodeKey } from 'lexical';
9
+ export declare function useLexicalNodeSelection(key: NodeKey): [boolean, (arg0: boolean) => void, () => void];
@@ -5,16 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import {Class} from 'utility-types';
10
- import type {TextNode} from 'lexical';
11
-
12
- export type EntityMatch = {
13
- end: number;
14
- start: number;
15
- };
16
- export function useLexicalTextEntity<N extends TextNode>(
17
- getMatch: (text: string) => null | EntityMatch,
18
- targetNode: Class<N>,
19
- createNode: (textNode: TextNode) => N,
20
- ): void;
8
+ import type { EntityMatch } from '@lexical/text';
9
+ import type { Klass, TextNode } from 'lexical';
10
+ export declare function useLexicalTextEntity<T extends TextNode>(getMatch: (text: string) => null | EntityMatch, targetNode: Klass<T>, createNode: (textNode: TextNode) => T): void;