@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
@@ -5,10 +5,10 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict';var e=require("@lexical/list"),g=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/utils"),l=require("lexical"),m=require("react");let n=0;function p(){0===n++&&(document.addEventListener("click",q),document.addEventListener("pointerdown",r));return()=>{0===--n&&(document.removeEventListener("click",q),document.removeEventListener("pointerdown",r))}}
8
- function t(a,c){let b=a.target;if(b instanceof HTMLElement){var d=b.firstChild;(null==d||"UL"!==d.tagName&&"OL"!==d.tagName)&&(d=b.parentNode)&&"check"===d.__lexicalListType&&(a=a.pageX,d=b.getBoundingClientRect(),("rtl"===b.dir?a<d.right&&a>d.right-20:a>d.left&&a<d.left+20)&&c())}}function q(a){t(a,()=>{let c=u(a.target);null==c||c.isReadOnly()||c.update(()=>{let b=l.$getNearestNodeFromDOMNode(a.target);e.$isListItemNode(b)&&(a.target.focus(),b.toggleChecked())})})}
9
- function r(a){t(a,()=>{a.preventDefault()})}function u(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function v(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}
10
- function w(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=c?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=c?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=c?a.getLastChild():a.getFirstChild()}return null}
11
- function x(a,c,b){let d=v();null!=d&&c.update(()=>{var f=l.$getNearestNodeFromDOMNode(d);if(e.$isListItemNode(f)&&(f=w(f,b),null!=f)){f.selectStart();let h=c.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1}
12
- exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,c=>x(c,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,c=>x(c,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=v()){let c=a.getRootElement();null!=c&&c.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW),
13
- a.registerCommand(l.KEY_SPACE_COMMAND,c=>{let b=v();return null==b||a.isReadOnly()?!1:(a.update(()=>{let d=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(d)&&(c.preventDefault(),d.toggleChecked())}),!0)},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,c=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:d}=b;if((b="element"===d.type)||0===d.offset){d=d.getNode();let f=k.$findMatchingParent(d,h=>l.$isElementNode(h)&&!h.isInline());
14
- if(e.$isListItemNode(f)&&(b||f.getFirstDescendant()===d)&&(b=a.getElementByKey(f.__key),null!=b&&document.activeElement!==b))return b.focus(),c.preventDefault(),!0}}return!1}),l.COMMAND_PRIORITY_LOW),p()));return null}
8
+ function t(a,d){let b=a.target;if(b instanceof HTMLElement){var c=b.firstChild;null!=c&&c instanceof HTMLElement&&("UL"===c.tagName||"OL"===c.tagName)||(c=b.parentNode)&&"check"===c.__lexicalListType&&(a=a.pageX,c=b.getBoundingClientRect(),("rtl"===b.dir?a<c.right&&a>c.right-20:a>c.left&&a<c.left+20)&&d())}}
9
+ function q(a){t(a,()=>{let d=a.target,b=u(d);null==b||b.isReadOnly()||b.update(()=>{if(a.target){let c=l.$getNearestNodeFromDOMNode(d);e.$isListItemNode(c)&&(d.focus(),c.toggleChecked())}})})}function r(a){t(a,()=>{a.preventDefault()})}function u(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function v(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}
10
+ function w(a,d){let b=d?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=d?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=d?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=d?a.getLastChild():a.getFirstChild()}return null}
11
+ function x(a,d,b){let c=v();null!=c&&d.update(()=>{var f=l.$getNearestNodeFromDOMNode(c);if(e.$isListItemNode(f)&&(f=w(f,b),null!=f)){f.selectStart();let h=d.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1}
12
+ exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,d=>x(d,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,d=>x(d,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=v()){let d=a.getRootElement();null!=d&&d.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW),
13
+ a.registerCommand(l.KEY_SPACE_COMMAND,d=>{let b=v();return null==b||a.isReadOnly()?!1:(a.update(()=>{let c=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(c)&&(d.preventDefault(),c.toggleChecked())}),!0)},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,d=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:c}=b;if((b="element"===c.type)||0===c.offset){c=c.getNode();let f=k.$findMatchingParent(c,h=>l.$isElementNode(h)&&!h.isInline());
14
+ if(e.$isListItemNode(f)&&(b||f.getFirstDescendant()===c)&&(b=a.getElementByKey(f.__key),null!=b&&document.activeElement!==b))return b.focus(),d.preventDefault(),!0}}return!1}),l.COMMAND_PRIORITY_LOW),p()));return null}
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- type Props = Readonly<{
10
- onClear?: () => void;
8
+ declare type Props = Readonly<{
9
+ onClear?: () => void;
11
10
  }>;
12
- export function ClearEditorPlugin(arg0: Props): JSX.Element | null;
11
+ export declare function ClearEditorPlugin({ onClear }: Props): JSX.Element | null;
12
+ export {};
@@ -5,35 +5,21 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {Provider} from '@lexical/yjs';
10
- import type {Doc, RelativePosition} from 'yjs';
11
-
12
- export type UserState = {
13
- anchorPos: null | RelativePosition;
14
- focusPos: null | RelativePosition;
15
- name: string;
16
- color: string;
17
- focusing: boolean;
8
+ /// <reference types="react" />
9
+ import type { Doc } from 'yjs';
10
+ import { WebsocketProvider } from 'y-websocket';
11
+ declare type CollaborationContextType = {
12
+ clientID: number;
13
+ color: string;
14
+ name: string;
15
+ yjsDocMap: Map<string, Doc>;
18
16
  };
19
- export type ProviderAwareness = {
20
- getLocalState: () => UserState;
21
- setLocalState: (arg0: UserState) => void;
22
- getStates: () => Array<UserState>;
23
- on: (type: 'update', cb: () => void) => void;
24
- off: (type: 'update', cb: () => void) => void;
25
- };
26
- type CollaborationContextType = {
27
- clientID: number;
28
- color: string;
29
- name: string;
30
- yjsDocMap: Map<string, Doc>;
31
- };
32
- export function CollaborationPlugin(arg0: {
33
- id: string;
34
- providerFactory(id: string, yjsDocMap: Map<string, Doc>): Provider;
35
- shouldBootstrap: boolean;
36
- username?: string;
37
- }): JSX.Element | null;
38
- export declare var CollaborationContext: React.Context<CollaborationContextType>;
39
- export function useCollaborationContext(): CollaborationContextType;
17
+ export declare function CollaborationPlugin({ id, providerFactory, shouldBootstrap, username, }: {
18
+ id: string;
19
+ providerFactory: (id: string, yjsDocMap: Map<string, Doc>) => WebsocketProvider;
20
+ shouldBootstrap: boolean;
21
+ username?: string;
22
+ }): JSX.Element;
23
+ export declare const CollaborationContext: React.Context<CollaborationContextType>;
24
+ export declare function useCollaborationContext(username?: string): CollaborationContextType;
25
+ export {};
@@ -5,19 +5,20 @@
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 {EditorThemeClasses, LexicalEditor, LexicalNode} from 'lexical';
11
-
12
- type Props = {
13
- initialConfig: {
14
- namespace: string;
15
- editor__DEPRECATED?: LexicalEditor | null;
16
- readOnly?: boolean;
17
- nodes?: Array<Class<LexicalNode>>;
18
- theme?: EditorThemeClasses;
19
- onError: (error: Error, editor: LexicalEditor) => void;
20
- };
21
- children: JSX.Element | JSX.Element[] | null;
8
+ import type { Klass } from 'lexical';
9
+ import { EditorState, EditorThemeClasses, LexicalEditor, LexicalNode } from 'lexical';
10
+ export declare type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void);
11
+ declare type Props = {
12
+ children: JSX.Element | string | (JSX.Element | string)[];
13
+ initialConfig: Readonly<{
14
+ editor__DEPRECATED?: LexicalEditor | null;
15
+ namespace: string;
16
+ nodes?: ReadonlyArray<Klass<LexicalNode>>;
17
+ onError: (error: Error, editor: LexicalEditor) => void;
18
+ readOnly?: boolean;
19
+ theme?: EditorThemeClasses;
20
+ editorState?: InitialEditorStateType;
21
+ }>;
22
22
  };
23
- export function LexicalComposer(arg0: Props): JSX.Element | null;
23
+ export declare function LexicalComposer({ initialConfig, children }: Props): JSX.Element;
24
+ export {};
@@ -36,6 +36,9 @@ var useLayoutEffect = useLayoutEffectImpl;
36
36
  * LICENSE file in the root directory of this source tree.
37
37
  *
38
38
  */
39
+ const HISTORY_MERGE_OPTIONS = {
40
+ tag: 'history-merge'
41
+ };
39
42
  function LexicalComposer({
40
43
  initialConfig,
41
44
  children
@@ -46,7 +49,8 @@ function LexicalComposer({
46
49
  namespace,
47
50
  editor__DEPRECATED: initialEditor,
48
51
  nodes,
49
- onError
52
+ onError,
53
+ editorState: initialEditorState
50
54
  } = initialConfig;
51
55
  const context = LexicalComposerContext.createLexicalComposerContext(null, theme);
52
56
  let editor = initialEditor || null;
@@ -59,6 +63,7 @@ function LexicalComposer({
59
63
  readOnly: true,
60
64
  theme
61
65
  });
66
+ initializeEditor(newEditor, initialEditorState);
62
67
  editor = newEditor;
63
68
  }
64
69
 
@@ -77,4 +82,37 @@ function LexicalComposer({
77
82
  }, children);
78
83
  }
79
84
 
85
+ function initializeEditor(editor, initialEditorState) {
86
+ if (initialEditorState === null) {
87
+ return;
88
+ } else if (initialEditorState === undefined) ; else if (initialEditorState !== null) {
89
+ switch (typeof initialEditorState) {
90
+ case 'string':
91
+ {
92
+ const parsedEditorState = editor.parseEditorState(initialEditorState);
93
+ editor.setEditorState(parsedEditorState, HISTORY_MERGE_OPTIONS);
94
+ break;
95
+ }
96
+
97
+ case 'object':
98
+ {
99
+ editor.setEditorState(initialEditorState, HISTORY_MERGE_OPTIONS);
100
+ break;
101
+ }
102
+
103
+ case 'function':
104
+ {
105
+ editor.update(() => {
106
+ const root = lexical.$getRoot();
107
+
108
+ if (root.isEmpty()) {
109
+ initialEditorState(editor);
110
+ }
111
+ }, HISTORY_MERGE_OPTIONS);
112
+ break;
113
+ }
114
+ }
115
+ }
116
+ }
117
+
80
118
  exports.LexicalComposer = LexicalComposer;
@@ -8,6 +8,8 @@
8
8
  */
9
9
 
10
10
  import type {EditorThemeClasses, LexicalEditor, LexicalNode} from 'lexical';
11
+ import type {InitialEditorStateType as InitialEditorStatePlainTextType} from '@lexical/plain-text';
12
+ import type {InitialEditorStateType as InitialEditorStateRichTextType} from '@lexical/rich-text';
11
13
 
12
14
  type Props = {
13
15
  initialConfig: $ReadOnly<{
@@ -16,6 +18,9 @@ type Props = {
16
18
  namespace: string,
17
19
  nodes?: $ReadOnlyArray<Class<LexicalNode>>,
18
20
  theme?: EditorThemeClasses,
21
+ editorState?:
22
+ | InitialEditorStateRichTextType
23
+ | InitialEditorStatePlainTextType,
19
24
  onError: (error: Error, editor: LexicalEditor) => void,
20
25
  }>,
21
26
  children: React$Node,
@@ -4,5 +4,6 @@
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"),e=require("lexical"),k=require("react"),l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
8
- exports.LexicalComposer=function({initialConfig:f,children:m}){let h=k.useMemo(()=>{const {theme:b,namespace:c,editor__DEPRECATED:n,nodes:p,onError:q}=f,r=a.createLexicalComposerContext(null,b);let d=n||null;if(null===d){const g=e.createEditor({namespace:c,nodes:p,onError:t=>q(t,g),readOnly:!0,theme:b});d=g}return[d,r]},[]);l(()=>{let b=f.readOnly,[c]=h;c.setReadOnly(b||!1)},[]);return k.createElement(a.LexicalComposerContext.Provider,{value:h},m)}
7
+ 'use strict';var c=require("@lexical/react/LexicalComposerContext"),f=require("lexical"),l=require("react"),m="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?l.useLayoutEffect:l.useEffect;let n={tag:"history-merge"};
8
+ function p(b,a){if(null!==a&&void 0!==a&&null!==a)switch(typeof a){case "string":let d=b.parseEditorState(a);b.setEditorState(d,n);break;case "object":b.setEditorState(a,n);break;case "function":b.update(()=>{f.$getRoot().isEmpty()&&a(b)},n)}}
9
+ exports.LexicalComposer=function({initialConfig:b,children:a}){let d=l.useMemo(()=>{const {theme:e,namespace:g,editor__DEPRECATED:q,nodes:r,onError:t,editorState:u}=b,v=c.createLexicalComposerContext(null,e);let h=q||null;if(null===h){const k=f.createEditor({namespace:g,nodes:r,onError:w=>t(w,k),readOnly:!0,theme:e});p(k,u);h=k}return[h,v]},[]);m(()=>{let e=b.readOnly,[g]=d;g.setReadOnly(e||!1)},[]);return l.createElement(c.LexicalComposerContext.Provider,{value:d},a)}
@@ -5,20 +5,15 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {EditorThemeClasses, LexicalEditor} from 'lexical';
10
- export type LexicalComposerContextType = {
11
- getTheme: () => EditorThemeClasses | null | undefined;
8
+ /// <reference types="react" />
9
+ import type { EditorThemeClasses, LexicalEditor } from 'lexical';
10
+ export declare type LexicalComposerContextType = {
11
+ getTheme: () => EditorThemeClasses | null | undefined;
12
12
  };
13
- export type LexicalComposerContextWithEditor = [
14
- LexicalEditor,
15
- LexicalComposerContextType,
13
+ export declare type LexicalComposerContextWithEditor = [
14
+ LexicalEditor,
15
+ LexicalComposerContextType
16
16
  ];
17
- export declare var LexicalComposerContext: React.Context<
18
- LexicalComposerContextWithEditor | null | undefined
19
- >;
20
- export function createLexicalComposerContext(
21
- parent: LexicalComposerContextWithEditor | null | undefined,
22
- theme: EditorThemeClasses | null | undefined,
23
- ): LexicalComposerContextType;
24
- export function useLexicalComposerContext(): LexicalComposerContextWithEditor;
17
+ export declare const LexicalComposerContext: React.Context<LexicalComposerContextWithEditor | null | undefined>;
18
+ export declare function createLexicalComposerContext(parent: LexicalComposerContextWithEditor | null | undefined, theme: EditorThemeClasses | null | undefined): LexicalComposerContextType;
19
+ export declare function useLexicalComposerContext(): LexicalComposerContextWithEditor;
@@ -5,27 +5,28 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- export type Props = Readonly<{
10
- ariaActiveDescendantID?: string;
11
- ariaAutoComplete?: string;
12
- ariaControls?: string;
13
- ariaDescribedBy?: string;
14
- ariaExpanded?: boolean;
15
- ariaLabel?: string;
16
- ariaLabelledBy?: string;
17
- ariaMultiline?: boolean;
18
- ariaOwneeID?: string;
19
- ariaRequired?: string;
20
- autoCapitalize?: boolean;
21
- autoComplete?: boolean;
22
- autoCorrect?: boolean;
23
- className?: string;
24
- readOnly?: boolean;
25
- role?: string;
26
- style?: StyleSheetList;
27
- spellCheck?: boolean;
28
- tabIndex?: number;
29
- testid?: string;
8
+ import { CSSProperties } from 'react';
9
+ export declare type Props = Readonly<{
10
+ ariaActiveDescendantID?: string;
11
+ ariaAutoComplete?: string;
12
+ ariaControls?: string;
13
+ ariaDescribedBy?: string;
14
+ ariaExpanded?: boolean;
15
+ ariaLabel?: string;
16
+ ariaLabelledBy?: string;
17
+ ariaMultiline?: boolean;
18
+ ariaOwneeID?: string;
19
+ ariaRequired?: string;
20
+ autoCapitalize?: boolean;
21
+ autoComplete?: boolean;
22
+ autoCorrect?: boolean;
23
+ className?: string;
24
+ id?: string;
25
+ readOnly?: boolean;
26
+ role?: string;
27
+ spellCheck?: boolean;
28
+ style?: CSSProperties;
29
+ tabIndex?: number;
30
+ testid?: string;
30
31
  }>;
31
- export function ContentEditable(props: Props): JSX.Element | null;
32
+ export declare function ContentEditable({ ariaActiveDescendantID, ariaAutoComplete, ariaControls, ariaDescribedBy, ariaExpanded, ariaLabel, ariaLabelledBy, ariaMultiline, ariaOwneeID, ariaRequired, autoCapitalize, autoComplete, autoCorrect, className, id, role, spellCheck, style, tabIndex, testid, }: Props): JSX.Element;
@@ -79,16 +79,16 @@ function ContentEditable({
79
79
  "aria-multiline": ariaMultiline,
80
80
  "aria-owns": isReadOnly ? null : ariaOwneeID,
81
81
  "aria-required": ariaRequired,
82
- autoCapitalize: autoCapitalize !== undefined ? String(autoCapitalize) : null // @ts-ignore This is a valid attribute
82
+ autoCapitalize: autoCapitalize !== undefined ? String(autoCapitalize) : undefined // @ts-ignore This is a valid attribute
83
83
  ,
84
84
  autoComplete: autoComplete,
85
- autoCorrect: autoCorrect !== undefined ? String(autoCorrect) : null,
85
+ autoCorrect: autoCorrect !== undefined ? String(autoCorrect) : undefined,
86
86
  className: className,
87
87
  contentEditable: !isReadOnly,
88
88
  "data-testid": testid,
89
89
  id: id,
90
90
  ref: ref,
91
- role: isReadOnly ? null : role,
91
+ role: isReadOnly ? undefined : role,
92
92
  spellCheck: spellCheck,
93
93
  style: style,
94
94
  tabIndex: tabIndex
@@ -6,4 +6,4 @@
6
6
  */
7
7
  'use strict';var b=require("@lexical/react/LexicalComposerContext"),k=require("react"),l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
8
8
  exports.ContentEditable=function({ariaActiveDescendantID:m,ariaAutoComplete:n,ariaControls:p,ariaDescribedBy:q,ariaExpanded:r,ariaLabel:t,ariaLabelledBy:u,ariaMultiline:v,ariaOwneeID:w,ariaRequired:x,autoCapitalize:e,autoComplete:y,autoCorrect:f,className:z,id:A,role:g="textbox",spellCheck:B=!0,style:C,tabIndex:D,testid:E}){let [c]=b.useLexicalComposerContext(),[a,h]=k.useState(!0),F=k.useCallback(d=>{c.setRootElement(d)},[c]);l(()=>{h(c.isReadOnly());return c.registerReadOnlyListener(d=>{h(d)})},
9
- [c]);return k.createElement("div",{"aria-activedescendant":a?null:m,"aria-autocomplete":a?null:n,"aria-controls":a?null:p,"aria-describedby":q,"aria-expanded":a?null:"combobox"===g?!!r:null,"aria-label":t,"aria-labelledby":u,"aria-multiline":v,"aria-owns":a?null:w,"aria-required":x,autoCapitalize:void 0!==e?String(e):null,autoComplete:y,autoCorrect:void 0!==f?String(f):null,className:z,contentEditable:!a,"data-testid":E,id:A,ref:F,role:a?null:g,spellCheck:B,style:C,tabIndex:D})}
9
+ [c]);return k.createElement("div",{"aria-activedescendant":a?null:m,"aria-autocomplete":a?null:n,"aria-controls":a?null:p,"aria-describedby":q,"aria-expanded":a?null:"combobox"===g?!!r:null,"aria-label":t,"aria-labelledby":u,"aria-multiline":v,"aria-owns":a?null:w,"aria-required":x,autoCapitalize:void 0!==e?String(e):void 0,autoComplete:y,autoCorrect:void 0!==f?String(f):void 0,className:z,contentEditable:!a,"data-testid":E,id:A,ref:F,role:a?void 0:g,spellCheck:B,style:C,tabIndex:D})}
@@ -5,28 +5,17 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {
10
- ElementFormatType,
11
- LexicalNode,
12
- NodeKey,
13
- SerializedLexicalNode,
14
- } from 'lexical';
15
-
16
- import {DecoratorNode} from 'lexical';
17
-
18
- export type SerializedDecoratorBlockNode = SerializedLexicalNode & {
19
- format: ElementFormatType;
20
- };
21
-
22
- declare class DecoratorBlockNode<T> extends DecoratorNode<T> {
23
- __format: ElementFormatType;
24
- constructor(format?: ElementFormatType | null, key?: NodeKey);
25
- createDOM(): HTMLElement;
26
- setFormat(format: ElementFormatType): void;
27
- exportJSON(): SerializedDecoratorBlockNode;
8
+ import type { ElementFormatType, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
9
+ import { DecoratorNode } from 'lexical';
10
+ export declare type SerializedDecoratorBlockNode = Spread<{
11
+ format: ElementFormatType;
12
+ }, SerializedLexicalNode>;
13
+ export declare class DecoratorBlockNode extends DecoratorNode<JSX.Element> {
14
+ __format: ElementFormatType;
15
+ constructor(format?: ElementFormatType, key?: NodeKey);
16
+ exportJSON(): SerializedDecoratorBlockNode;
17
+ createDOM(): HTMLElement;
18
+ updateDOM(): false;
19
+ setFormat(format: ElementFormatType): void;
28
20
  }
29
-
30
- declare function $isDecoratorBlockNode<T>(
31
- node: LexicalNode,
32
- ): node is DecoratorBlockNode<T>;
21
+ export declare function $isDecoratorBlockNode(node: LexicalNode | null | undefined): node is DecoratorBlockNode;
@@ -18,7 +18,7 @@ var lexical = require('lexical');
18
18
  class DecoratorBlockNode extends lexical.DecoratorNode {
19
19
  constructor(format, key) {
20
20
  super(key);
21
- this.__format = format;
21
+ this.__format = format || '';
22
22
  }
23
23
 
24
24
  exportJSON() {
@@ -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 b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=c
7
+ 'use strict';var b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=c
@@ -5,5 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- export function HashtagPlugin(): JSX.Element | null;
8
+ export declare function HashtagPlugin(): JSX.Element | null;
@@ -5,26 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {
10
- EditorState,
11
- GridSelection,
12
- LexicalEditor,
13
- NodeSelection,
14
- RangeSelection,
15
- } from 'lexical';
16
-
17
- export type HistoryStateEntry = {
18
- editor: LexicalEditor;
19
- editorState: EditorState;
20
- undoSelection?: RangeSelection | NodeSelection | GridSelection | null;
21
- };
22
- export type HistoryState = {
23
- current: null | HistoryStateEntry;
24
- redoStack: Array<HistoryStateEntry>;
25
- undoStack: Array<HistoryStateEntry>;
26
- };
27
- export function HistoryPlugin(arg0: {
28
- externalHistoryState?: HistoryState;
29
- }): JSX.Element | null;
30
- export function createEmptyHistoryState(): HistoryState;
8
+ import type { HistoryState } from '@lexical/history';
9
+ export { createEmptyHistoryState } from '@lexical/history';
10
+ export type { HistoryState };
11
+ export declare function HistoryPlugin({ externalHistoryState, }: {
12
+ externalHistoryState?: HistoryState;
13
+ }): null;
@@ -5,21 +5,23 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {LexicalNode, LexicalCommand} from 'lexical';
10
- import {DecoratorNode} from 'lexical';
11
-
12
- export declare class HorizontalRuleNode extends DecoratorNode<JSX.Element | null> {
13
- static getType(): string;
14
- static clone(node: HorizontalRuleNode): HorizontalRuleNode;
15
- createDOM(): HTMLElement;
16
- getTextContent(): '\n';
17
- isTopLevel(): true;
18
- updateDOM(): false;
19
- decorate(): JSX.Element | null;
8
+ import type { LexicalCommand, LexicalNode, SerializedLexicalNode } from 'lexical';
9
+ import { DecoratorNode } from 'lexical';
10
+ export declare type SerializedHorizontalRuleNode = SerializedLexicalNode & {
11
+ type: 'horizontalrule';
12
+ version: 1;
13
+ };
14
+ export declare const INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
15
+ export declare class HorizontalRuleNode extends DecoratorNode<JSX.Element> {
16
+ static getType(): string;
17
+ static clone(node: HorizontalRuleNode): HorizontalRuleNode;
18
+ static importJSON(serializedNode: SerializedHorizontalRuleNode): HorizontalRuleNode;
19
+ exportJSON(): SerializedLexicalNode;
20
+ createDOM(): HTMLElement;
21
+ getTextContent(): '\n';
22
+ isTopLevel(): true;
23
+ updateDOM(): false;
24
+ decorate(): JSX.Element;
20
25
  }
21
- export function $createHorizontalRuleNode(): HorizontalRuleNode;
22
- export function $isHorizontalRuleNode(
23
- node: LexicalNode | null | undefined,
24
- ): node is HorizontalRuleNode;
25
- export var INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
26
+ export declare function $createHorizontalRuleNode(): HorizontalRuleNode;
27
+ export declare function $isHorizontalRuleNode(node: LexicalNode | null | undefined): node is HorizontalRuleNode;
@@ -5,5 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- export function LinkPlugin(): null;
8
+ export declare function LinkPlugin(): null;
@@ -16,6 +16,7 @@ var react = require('react');
16
16
  *
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
  */
20
21
  function LinkPlugin() {
21
22
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
@@ -5,5 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- export function ListPlugin(): null;
8
+ export declare function ListPlugin(): null;
@@ -5,9 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {Transformer} from '@lexical/markdown';
10
-
11
- export function MarkdownShortcutPlugin(arg0: {
12
- transformers?: Array<Transformer>;
13
- }): JSX.Element | null;
8
+ import type { Transformer } from '@lexical/markdown';
9
+ export declare function MarkdownShortcutPlugin({ transformers, }: Readonly<{
10
+ transformers?: Array<Transformer>;
11
+ }>): null;
@@ -5,11 +5,10 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {LexicalEditor, EditorThemeClasses} from 'lexical';
10
-
11
- export function LexicalNestedComposer(arg0: {
12
- initialEditor: LexicalEditor;
13
- initialTheme?: EditorThemeClasses;
14
- children: JSX.Element | (JSX.Element | string | null)[] | null;
15
- }): JSX.Element | null;
8
+ import type { EditorThemeClasses, LexicalEditor } from 'lexical';
9
+ import { ReactNode } from 'react';
10
+ export declare function LexicalNestedComposer({ initialEditor, children, initialTheme, }: {
11
+ children: ReactNode;
12
+ initialEditor: LexicalEditor;
13
+ initialTheme?: EditorThemeClasses;
14
+ }): JSX.Element;
@@ -5,11 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
- import type {EditorState, LexicalEditor} from 'lexical';
10
-
11
- export function OnChangePlugin(arg0: {
12
- ignoreInitialChange?: boolean;
13
- ignoreSelectionChange?: boolean;
14
- onChange: (editorState: EditorState, editor: LexicalEditor) => void;
8
+ import type { EditorState, LexicalEditor } from 'lexical';
9
+ export declare function OnChangePlugin({ ignoreInitialChange, ignoreSelectionChange, onChange, }: {
10
+ ignoreInitialChange?: boolean;
11
+ ignoreSelectionChange?: boolean;
12
+ onChange: (editorState: EditorState, editor: LexicalEditor) => void;
15
13
  }): null;
@@ -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/plain-text';
10
- import type {EditorState, LexicalEditor} from 'lexical';
11
-
12
- export function PlainTextPlugin(arg0: {
13
- contentEditable: JSX.Element | null;
14
- initialEditorState?: InitialEditorStateType;
15
- placeholder: JSX.Element | string | null;
16
- }): JSX.Element | null;
8
+ import { InitialEditorStateType } from '@lexical/plain-text';
9
+ export declare function PlainTextPlugin({ contentEditable, placeholder, initialEditorState, }: {
10
+ contentEditable: JSX.Element;
11
+ initialEditorState?: InitialEditorStateType;
12
+ placeholder: JSX.Element | string;
13
+ }): JSX.Element;