@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
@@ -0,0 +1,18 @@
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 { EditorState, EditorThemeClasses, Klass, LexicalEditor, LexicalNode } from 'lexical';
9
+ export declare function useLexical(editorConfig: {
10
+ disableEvents?: boolean;
11
+ editorState?: EditorState;
12
+ namespace: string;
13
+ nodes?: ReadonlyArray<Klass<LexicalNode>>;
14
+ onError: (error: Error) => void;
15
+ parentEditor?: LexicalEditor;
16
+ readOnly?: boolean;
17
+ theme?: EditorThemeClasses;
18
+ }): [LexicalEditor, (arg0: null | HTMLElement) => void, boolean];
@@ -9,6 +9,7 @@
9
9
  var lexical = require('lexical');
10
10
  var react = require('react');
11
11
  var text = require('@lexical/text');
12
+ var utils = require('@lexical/utils');
12
13
 
13
14
  /**
14
15
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -36,18 +37,26 @@ var useLayoutEffect = useLayoutEffectImpl;
36
37
  * LICENSE file in the root directory of this source tree.
37
38
  *
38
39
  */
40
+
41
+ function canShowPlaceholderFromCurrentEditorState(editor) {
42
+ const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
43
+ return currentCanShowPlaceholder;
44
+ }
45
+
39
46
  function useCanShowPlaceholder(editor) {
40
- const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
47
+ const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
41
48
  useLayoutEffect(() => {
42
- let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
43
- setCanShowPlaceholder(currentCanShowPlaceholder);
44
- return editor.registerUpdateListener(({
45
- editorState
46
- }) => {
47
- const isComposing = editor.isComposing();
48
- currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
49
+ function resetCanShowPlaceholder() {
50
+ const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
49
51
  setCanShowPlaceholder(currentCanShowPlaceholder);
50
- });
52
+ }
53
+
54
+ resetCanShowPlaceholder();
55
+ return utils.mergeRegister(editor.registerUpdateListener(() => {
56
+ resetCanShowPlaceholder();
57
+ }), editor.registerReadOnlyListener(() => {
58
+ resetCanShowPlaceholder();
59
+ }));
51
60
  }, [editor]);
52
61
  return canShowPlaceholder;
53
62
  }
@@ -1,5 +1,8 @@
1
1
  /**
2
- * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
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.
3
6
  *
4
7
  * @flow strict
5
8
  * @format
@@ -4,6 +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
- 'use strict';var d=require("lexical"),f=require("react"),g=require("@lexical/text"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;
8
- function k(a){let [b,c]=f.useState(a.getEditorState().read(g.$canShowPlaceholderCurry(a.isComposing())));h(()=>{let e=a.getEditorState().read(g.$canShowPlaceholderCurry(a.isComposing()));c(e);return a.registerUpdateListener(({editorState:l})=>{let m=a.isComposing();e=l.read(g.$canShowPlaceholderCurry(m));c(e)})},[a]);return b}function n(a){let b=k(a);return[f.useCallback(c=>{a.setRootElement(c)},[a]),b]}
9
- exports.useLexical=function(a){let b=f.useMemo(()=>d.createEditor(a),[]),[c,e]=n(b);return[b,c,e]}
7
+ 'use strict';var c=require("lexical"),f=require("react"),g=require("@lexical/text"),h=require("@lexical/utils"),k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;function l(a){return a.getEditorState().read(g.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
8
+ function m(a){let [b,d]=f.useState(()=>l(a));k(()=>{function e(){let n=l(a);d(n)}e();return h.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerReadOnlyListener(()=>{e()}))},[a]);return b}function p(a){let b=m(a);return[f.useCallback(d=>{a.setRootElement(d)},[a]),b]}exports.useLexical=function(a){let b=f.useMemo(()=>c.createEditor(a),[]),[d,e]=p(b);return[b,d,e]}
@@ -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 useLexicalAutoFormatter(editor: LexicalEditor): void;
@@ -1,5 +1,8 @@
1
1
  /**
2
- * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
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.
3
6
  *
4
7
  * @flow strict
5
8
  * @format
@@ -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 useLexicalCanShowPlaceholder(editor: LexicalEditor): boolean;
@@ -7,6 +7,7 @@
7
7
  'use strict';
8
8
 
9
9
  var text = require('@lexical/text');
10
+ var utils = require('@lexical/utils');
10
11
  var react = require('react');
11
12
 
12
13
  /**
@@ -35,18 +36,26 @@ var useLayoutEffect = useLayoutEffectImpl;
35
36
  * LICENSE file in the root directory of this source tree.
36
37
  *
37
38
  */
39
+
40
+ function canShowPlaceholderFromCurrentEditorState(editor) {
41
+ const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
42
+ return currentCanShowPlaceholder;
43
+ }
44
+
38
45
  function useCanShowPlaceholder(editor) {
39
- const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
46
+ const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
40
47
  useLayoutEffect(() => {
41
- let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
42
- setCanShowPlaceholder(currentCanShowPlaceholder);
43
- return editor.registerUpdateListener(({
44
- editorState
45
- }) => {
46
- const isComposing = editor.isComposing();
47
- currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
48
+ function resetCanShowPlaceholder() {
49
+ const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
48
50
  setCanShowPlaceholder(currentCanShowPlaceholder);
49
- });
51
+ }
52
+
53
+ resetCanShowPlaceholder();
54
+ return utils.mergeRegister(editor.registerUpdateListener(() => {
55
+ resetCanShowPlaceholder();
56
+ }), editor.registerReadOnlyListener(() => {
57
+ resetCanShowPlaceholder();
58
+ }));
50
59
  }, [editor]);
51
60
  return canShowPlaceholder;
52
61
  }
@@ -1,5 +1,8 @@
1
1
  /**
2
- * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
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.
3
6
  *
4
7
  * @flow strict
5
8
  * @format
@@ -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
- 'use strict';var b=require("@lexical/text"),c=require("react"),f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?c.useLayoutEffect:c.useEffect;
8
- function g(a){let [h,e]=c.useState(a.getEditorState().read(b.$canShowPlaceholderCurry(a.isComposing())));f(()=>{let d=a.getEditorState().read(b.$canShowPlaceholderCurry(a.isComposing()));e(d);return a.registerUpdateListener(({editorState:k})=>{let l=a.isComposing();d=k.read(b.$canShowPlaceholderCurry(l));e(d)})},[a]);return h}exports.useLexicalCanShowPlaceholder=function(a){return g(a)}
7
+ 'use strict';var b=require("@lexical/text"),d=require("@lexical/utils"),e=require("react"),f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;function g(a){return a.getEditorState().read(b.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
8
+ function h(a){let [k,l]=e.useState(()=>g(a));f(()=>{function c(){let m=g(a);l(m)}c();return d.mergeRegister(a.registerUpdateListener(()=>{c()}),a.registerReadOnlyListener(()=>{c()}))},[a]);return k}exports.useLexicalCanShowPlaceholder=function(a){return h(a)}
@@ -0,0 +1,8 @@
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
+ export { mergePrevious, useCharacterLimit } from './shared/useCharacterLimit';
@@ -1,5 +1,8 @@
1
1
  /**
2
- * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
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.
3
6
  *
4
7
  * @flow strict
5
8
  * @format
@@ -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 useLexicalDecorators(editor: LexicalEditor): Array<JSX.Element>;
@@ -1,5 +1,8 @@
1
1
  /**
2
- * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
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.
3
6
  *
4
7
  * @flow strict
5
8
  * @format
@@ -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 useLexicalEditor(editor: LexicalEditor): [(rootElement: null | HTMLElement) => void, boolean];
@@ -8,6 +8,7 @@
8
8
 
9
9
  var react = require('react');
10
10
  var text = require('@lexical/text');
11
+ var utils = require('@lexical/utils');
11
12
 
12
13
  /**
13
14
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -35,18 +36,26 @@ var useLayoutEffect = useLayoutEffectImpl;
35
36
  * LICENSE file in the root directory of this source tree.
36
37
  *
37
38
  */
39
+
40
+ function canShowPlaceholderFromCurrentEditorState(editor) {
41
+ const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
42
+ return currentCanShowPlaceholder;
43
+ }
44
+
38
45
  function useCanShowPlaceholder(editor) {
39
- const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
46
+ const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
40
47
  useLayoutEffect(() => {
41
- let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
42
- setCanShowPlaceholder(currentCanShowPlaceholder);
43
- return editor.registerUpdateListener(({
44
- editorState
45
- }) => {
46
- const isComposing = editor.isComposing();
47
- currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
48
+ function resetCanShowPlaceholder() {
49
+ const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
48
50
  setCanShowPlaceholder(currentCanShowPlaceholder);
49
- });
51
+ }
52
+
53
+ resetCanShowPlaceholder();
54
+ return utils.mergeRegister(editor.registerUpdateListener(() => {
55
+ resetCanShowPlaceholder();
56
+ }), editor.registerReadOnlyListener(() => {
57
+ resetCanShowPlaceholder();
58
+ }));
50
59
  }, [editor]);
51
60
  return canShowPlaceholder;
52
61
  }
@@ -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
- 'use strict';var b=require("react"),d=require("@lexical/text"),g="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?b.useLayoutEffect:b.useEffect;
8
- function h(a){let [e,c]=b.useState(a.getEditorState().read(d.$canShowPlaceholderCurry(a.isComposing())));g(()=>{let f=a.getEditorState().read(d.$canShowPlaceholderCurry(a.isComposing()));c(f);return a.registerUpdateListener(({editorState:k})=>{let l=a.isComposing();f=k.read(d.$canShowPlaceholderCurry(l));c(f)})},[a]);return e}exports.useLexicalEditor=function(a){let e=h(a);return[b.useCallback(c=>{a.setRootElement(c)},[a]),e]}
7
+ 'use strict';var b=require("react"),f=require("@lexical/text"),g=require("@lexical/utils"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?b.useLayoutEffect:b.useEffect;function k(a){return a.getEditorState().read(f.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
8
+ function l(a){let [c,d]=b.useState(()=>k(a));h(()=>{function e(){let m=k(a);d(m)}e();return g.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerReadOnlyListener(()=>{e()}))},[a]);return c}exports.useLexicalEditor=function(a){let c=l(a);return[b.useCallback(d=>{a.setRootElement(d)},[a]),c]}
@@ -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 { InputEvents } from './shared/useEditorEvents';
9
+ import type { LexicalEditor } from 'lexical';
10
+ export declare function useLexicalEditorEvents(events: InputEvents, editor: LexicalEditor): void;
@@ -1,5 +1,8 @@
1
1
  /**
2
- * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
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.
3
6
  *
4
7
  * @flow strict
5
8
  * @format
@@ -0,0 +1,12 @@
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 { createEmptyHistoryState } from '@lexical/history';
11
+ export type { HistoryState };
12
+ export declare function useLexicalHistory(editor: LexicalEditor, externalHistoryState?: HistoryState, delay?: number): void;
@@ -1,5 +1,8 @@
1
1
  /**
2
- * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
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.
3
6
  *
4
7
  * @flow strict
5
8
  * @format
@@ -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 useLexicalList(editor: LexicalEditor): void;
@@ -1,5 +1,8 @@
1
1
  /**
2
- * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
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.
3
6
  *
4
7
  * @flow strict
5
8
  * @format
@@ -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 './DEPRECATED_useLexicalHistory';
9
+ import type { EditorState, LexicalEditor } from 'lexical';
10
+ export declare function useLexicalPlainText(editor: LexicalEditor, externalHistoryState?: HistoryState, initialEditorState?: null | string | EditorState | (() => void)): void;
@@ -1,5 +1,8 @@
1
1
  /**
2
- * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
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.
3
6
  *
4
7
  * @flow strict
5
8
  * @format
@@ -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 './DEPRECATED_useLexicalHistory';
9
+ import type { EditorState, LexicalEditor } from 'lexical';
10
+ export declare function useLexicalRichText(editor: LexicalEditor, externalHistoryState?: HistoryState, initialEditorState?: null | string | EditorState | (() => void)): void;
@@ -1,5 +1,8 @@
1
1
  /**
2
- * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
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.
3
6
  *
4
7
  * @flow strict
5
8
  * @format
@@ -5,5 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- export function AutoFocusPlugin(): null;
8
+ export declare function AutoFocusPlugin(): null;
@@ -27,7 +27,7 @@ function AutoFocusPlugin() {
27
27
  const activeElement = document.activeElement;
28
28
  const rootElement = editor.getRootElement();
29
29
 
30
- if (rootElement !== null || activeElement === null || !rootElement.contains(activeElement)) {
30
+ if (!rootElement.contains(activeElement) || rootElement !== null || activeElement === null) {
31
31
  // Note: preventScroll won't work in Webkit.
32
32
  rootElement.focus({
33
33
  preventScroll: true
@@ -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
- 'use strict';var d=require("@lexical/react/LexicalComposerContext"),e=require("react");exports.AutoFocusPlugin=function(){let [a]=d.useLexicalComposerContext();e.useEffect(()=>{a.focus(()=>{let c=document.activeElement,b=a.getRootElement();null===b&&null!==c&&b.contains(c)||b.focus({preventScroll:!0})})},[a]);return null}
7
+ 'use strict';var d=require("@lexical/react/LexicalComposerContext"),e=require("react");exports.AutoFocusPlugin=function(){let [a]=d.useLexicalComposerContext();e.useEffect(()=>{a.focus(()=>{let c=document.activeElement,b=a.getRootElement();b.contains(c)&&null===b&&null!==c||b.focus({preventScroll:!0})})},[a]);return null}
@@ -5,16 +5,16 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- type ChangeHandler = (url: string | null, prevUrl: string | null) => void;
10
- type LinkMatcherResult = {
11
- text: string;
12
- url: string;
13
- length: number;
14
- index: number;
8
+ declare type ChangeHandler = (url: string | null, prevUrl: string | null) => void;
9
+ declare type LinkMatcherResult = {
10
+ index: number;
11
+ length: number;
12
+ text: string;
13
+ url: string;
15
14
  };
16
- export type LinkMatcher = (text: string) => LinkMatcherResult | null;
17
- export function AutoLinkPlugin(props: {
18
- matchers: Array<LinkMatcher>;
19
- onChange?: ChangeHandler;
15
+ export declare type LinkMatcher = (text: string) => LinkMatcherResult | null;
16
+ export declare function AutoLinkPlugin({ matchers, onChange, }: {
17
+ matchers: Array<LinkMatcher>;
18
+ onChange?: ChangeHandler;
20
19
  }): JSX.Element | null;
20
+ export {};
@@ -5,8 +5,10 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- type Props = Readonly<{
10
- scrollRef: {current: HTMLElement | null};
8
+ declare type Props = Readonly<{
9
+ scrollRef: {
10
+ current: HTMLElement | null;
11
+ };
11
12
  }>;
12
- export function AutoScrollPlugin(props: Props): null;
13
+ export declare function AutoScrollPlugin({ scrollRef }: Props): JSX.Element | null;
14
+ export {};
@@ -5,12 +5,16 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {ElementFormatType, NodeKey} from 'lexical';
10
-
11
- type Props = Readonly<{
12
- children: JSX.Element | string | (JSX.Element | string)[];
13
- format: ElementFormatType | null;
14
- nodeKey: NodeKey;
8
+ import type { ElementFormatType, NodeKey } from 'lexical';
9
+ import { ReactNode } from 'react';
10
+ declare type Props = Readonly<{
11
+ children: ReactNode;
12
+ format: ElementFormatType | null | undefined;
13
+ nodeKey: NodeKey;
14
+ className: Readonly<{
15
+ base: string;
16
+ focus: string;
17
+ }>;
15
18
  }>;
16
- declare function BlockWithAlignableContents(arg0: Props): JSX.Element;
19
+ export declare function BlockWithAlignableContents({ children, format, nodeKey, className, }: Props): JSX.Element;
20
+ export {};
@@ -23,14 +23,14 @@ var React = require('react');
23
23
  function BlockWithAlignableContents({
24
24
  children,
25
25
  format,
26
- nodeKey
26
+ nodeKey,
27
+ className
27
28
  }) {
28
29
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
29
30
  const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
30
- const ref = React.useRef();
31
- const onDelete = React.useCallback(payload => {
31
+ const ref = React.useRef(null);
32
+ const onDelete = React.useCallback(event => {
32
33
  if (isSelected && lexical.$isNodeSelection(lexical.$getSelection())) {
33
- const event = payload;
34
34
  event.preventDefault();
35
35
  editor.update(() => {
36
36
  const node = lexical.$getNodeByKey(nodeKey);
@@ -89,10 +89,10 @@ function BlockWithAlignableContents({
89
89
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_DELETE_COMMAND, onDelete, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, onDelete, lexical.COMMAND_PRIORITY_LOW));
90
90
  }, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected]);
91
91
  return /*#__PURE__*/React.createElement("div", {
92
- className: `embed-block${isSelected ? ' focused' : ''}`,
92
+ className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
93
93
  ref: ref,
94
94
  style: {
95
- textAlign: format ? format : null
95
+ textAlign: format ? format : undefined
96
96
  }
97
97
  }, children);
98
98
  }
@@ -19,6 +19,10 @@ type Props = $ReadOnly<{
19
19
  children: React$Node,
20
20
  format: ?ElementFormatType,
21
21
  nodeKey: NodeKey,
22
+ className: $ReadOnly<{
23
+ base: string,
24
+ focus: string,
25
+ }>,
22
26
  }>;
23
27
 
24
28
  declare export function BlockWithAlignableContents(Props): 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
- 'use strict';var a=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/LexicalDecoratorBlockNode"),m=require("@lexical/react/useLexicalNodeSelection"),n=require("@lexical/utils"),t=require("lexical"),u=require("react");
8
- exports.BlockWithAlignableContents=function({children:v,format:p,nodeKey:g}){let [d]=a.useLexicalComposerContext(),[e,k,q]=m.useLexicalNodeSelection(g),r=u.useRef(),l=u.useCallback(b=>{e&&t.$isNodeSelection(t.$getSelection())&&(b.preventDefault(),d.update(()=>{const c=t.$getNodeByKey(g);t.$isDecoratorNode(c)&&c.isTopLevel()&&c.remove();k(!1)}));return!1},[d,e,g,k]);u.useEffect(()=>n.mergeRegister(d.registerCommand(t.FORMAT_ELEMENT_COMMAND,b=>{if(e){var c=t.$getSelection();if(t.$isNodeSelection(c)){var f=
9
- t.$getNodeByKey(g);h.$isDecoratorBlockNode(f)&&f.setFormat(b)}else if(t.$isRangeSelection(c)){c=c.getNodes();for(f of c)h.$isDecoratorBlockNode(f)?f.setFormat(b):n.$getNearestBlockElementAncestorOrThrow(f).setFormat(b)}return!0}return!1},t.COMMAND_PRIORITY_LOW),d.registerCommand(t.CLICK_COMMAND,b=>{b.preventDefault();return b.target===r.current?(b.shiftKey||q(),k(!e),!0):!1},t.COMMAND_PRIORITY_LOW),d.registerCommand(t.KEY_DELETE_COMMAND,l,t.COMMAND_PRIORITY_LOW),d.registerCommand(t.KEY_BACKSPACE_COMMAND,
10
- l,t.COMMAND_PRIORITY_LOW)),[q,d,e,g,l,k]);return u.createElement("div",{className:`embed-block${e?" focused":""}`,ref:r,style:{textAlign:p?p:null}},v)}
7
+ 'use strict';var a=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/LexicalDecoratorBlockNode"),m=require("@lexical/react/useLexicalNodeSelection"),n=require("@lexical/utils"),u=require("lexical"),v=require("react");
8
+ exports.BlockWithAlignableContents=function({children:w,format:p,nodeKey:g,className:q}){let [d]=a.useLexicalComposerContext(),[e,k,r]=m.useLexicalNodeSelection(g),t=v.useRef(null),l=v.useCallback(b=>{e&&u.$isNodeSelection(u.$getSelection())&&(b.preventDefault(),d.update(()=>{const c=u.$getNodeByKey(g);u.$isDecoratorNode(c)&&c.isTopLevel()&&c.remove();k(!1)}));return!1},[d,e,g,k]);v.useEffect(()=>n.mergeRegister(d.registerCommand(u.FORMAT_ELEMENT_COMMAND,b=>{if(e){var c=u.$getSelection();if(u.$isNodeSelection(c)){var f=
9
+ u.$getNodeByKey(g);h.$isDecoratorBlockNode(f)&&f.setFormat(b)}else if(u.$isRangeSelection(c)){c=c.getNodes();for(f of c)h.$isDecoratorBlockNode(f)?f.setFormat(b):n.$getNearestBlockElementAncestorOrThrow(f).setFormat(b)}return!0}return!1},u.COMMAND_PRIORITY_LOW),d.registerCommand(u.CLICK_COMMAND,b=>{b.preventDefault();return b.target===t.current?(b.shiftKey||r(),k(!e),!0):!1},u.COMMAND_PRIORITY_LOW),d.registerCommand(u.KEY_DELETE_COMMAND,l,u.COMMAND_PRIORITY_LOW),d.registerCommand(u.KEY_BACKSPACE_COMMAND,
10
+ l,u.COMMAND_PRIORITY_LOW)),[r,d,e,g,l,k]);return v.createElement("div",{className:[q.base,e?q.focus:null].filter(Boolean).join(" "),ref:t,style:{textAlign:p?p:void 0}},w)}
@@ -5,7 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- export function CharacterLimitPlugin(props: {
10
- charset: 'UTF-8' | 'UTF-16';
11
- }): JSX.Element | null;
8
+ export declare function CharacterLimitPlugin({ charset, }: {
9
+ charset: 'UTF-8' | 'UTF-16';
10
+ }): JSX.Element;
@@ -5,5 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- export function CheckListPlugin(): null;
8
+ export declare function CheckListPlugin(): null;
@@ -117,7 +117,7 @@ function handleCheckItemEvent(event, callback) {
117
117
 
118
118
  const firstChild = target.firstChild;
119
119
 
120
- if (firstChild != null && (firstChild.tagName === 'UL' || firstChild.tagName === 'OL')) {
120
+ if (firstChild != null && firstChild instanceof HTMLElement && (firstChild.tagName === 'UL' || firstChild.tagName === 'OL')) {
121
121
  return;
122
122
  }
123
123
 
@@ -137,15 +137,18 @@ function handleCheckItemEvent(event, callback) {
137
137
 
138
138
  function handleClick(event) {
139
139
  handleCheckItemEvent(event, () => {
140
- const editor = findEditor(event.target);
140
+ const domNode = event.target;
141
+ const editor = findEditor(domNode);
141
142
 
142
143
  if (editor != null && !editor.isReadOnly()) {
143
144
  editor.update(() => {
144
- const node = lexical.$getNearestNodeFromDOMNode(event.target);
145
+ if (event.target) {
146
+ const node = lexical.$getNearestNodeFromDOMNode(domNode);
145
147
 
146
- if (list.$isListItemNode(node)) {
147
- event.target.focus();
148
- node.toggleChecked();
148
+ if (list.$isListItemNode(node)) {
149
+ domNode.focus();
150
+ node.toggleChecked();
151
+ }
149
152
  }
150
153
  });
151
154
  }
@@ -163,7 +166,9 @@ function findEditor(target) {
163
166
  let node = target;
164
167
 
165
168
  while (node) {
169
+ // @ts-ignore internal field
166
170
  if (node.__lexicalEditor) {
171
+ // @ts-ignore internal field
167
172
  return node.__lexicalEditor;
168
173
  }
169
174