@lexical/react 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/DEPRECATED_useLexical.js.flow +0 -1
  2. package/DEPRECATED_useLexicalPlainText.d.ts +2 -2
  3. package/DEPRECATED_useLexicalPlainText.dev.js +4 -4
  4. package/DEPRECATED_useLexicalPlainText.js.flow +0 -1
  5. package/DEPRECATED_useLexicalPlainText.prod.js +2 -2
  6. package/DEPRECATED_useLexicalRichText.d.ts +2 -2
  7. package/DEPRECATED_useLexicalRichText.dev.js +4 -4
  8. package/DEPRECATED_useLexicalRichText.js.flow +0 -1
  9. package/DEPRECATED_useLexicalRichText.prod.js +2 -2
  10. package/LexicalAutoEmbedPlugin.d.ts +0 -2
  11. package/LexicalAutoEmbedPlugin.dev.js +0 -1
  12. package/LexicalAutoEmbedPlugin.prod.js +4 -4
  13. package/LexicalAutoLinkPlugin.dev.js +2 -1
  14. package/LexicalAutoLinkPlugin.prod.js +3 -3
  15. package/LexicalBlockWithAlignableContents.dev.js +1 -1
  16. package/LexicalBlockWithAlignableContents.prod.js +1 -1
  17. package/LexicalCollaborationPlugin.d.ts +5 -1
  18. package/LexicalCollaborationPlugin.dev.js +54 -16
  19. package/LexicalCollaborationPlugin.js.flow +1 -0
  20. package/LexicalCollaborationPlugin.prod.js +9 -9
  21. package/LexicalComposer.d.ts +1 -2
  22. package/LexicalComposer.dev.js +15 -1
  23. package/LexicalComposer.js.flow +14 -7
  24. package/LexicalComposer.prod.js +3 -3
  25. package/LexicalContentEditable.dev.js +1 -1
  26. package/LexicalContentEditable.prod.js +1 -1
  27. package/LexicalHorizontalRuleNode.d.ts +4 -2
  28. package/LexicalHorizontalRuleNode.dev.js +24 -2
  29. package/LexicalHorizontalRuleNode.js.flow +0 -1
  30. package/LexicalHorizontalRuleNode.prod.js +5 -5
  31. package/LexicalNestedComposer.d.ts +4 -2
  32. package/LexicalNestedComposer.dev.js +25 -3
  33. package/LexicalNestedComposer.js.flow +1 -0
  34. package/LexicalNestedComposer.prod.js +3 -3
  35. package/LexicalOnChangePlugin.d.ts +1 -2
  36. package/LexicalOnChangePlugin.dev.js +3 -9
  37. package/LexicalOnChangePlugin.js.flow +0 -2
  38. package/LexicalOnChangePlugin.prod.js +2 -2
  39. package/LexicalPlainTextPlugin.d.ts +1 -3
  40. package/LexicalPlainTextPlugin.dev.js +4 -29
  41. package/LexicalPlainTextPlugin.js.flow +0 -1
  42. package/LexicalPlainTextPlugin.prod.js +4 -4
  43. package/LexicalRichTextPlugin.d.ts +1 -3
  44. package/LexicalRichTextPlugin.dev.js +4 -29
  45. package/LexicalRichTextPlugin.js.flow +0 -1
  46. package/LexicalRichTextPlugin.prod.js +4 -4
  47. package/LexicalTableOfContents__EXPERIMENTAL.js.flow +1 -1
  48. package/LexicalTablePlugin.dev.js +1 -1
  49. package/LexicalTablePlugin.prod.js +1 -1
  50. package/LexicalTreeView.dev.js +4 -4
  51. package/LexicalTreeView.prod.js +4 -4
  52. package/LexicalTypeaheadMenuPlugin.d.ts +5 -2
  53. package/LexicalTypeaheadMenuPlugin.dev.js +13 -10
  54. package/LexicalTypeaheadMenuPlugin.prod.js +16 -16
  55. package/package.json +19 -19
  56. package/shared/usePlainTextSetup.d.ts +1 -2
  57. package/shared/useRichTextSetup.d.ts +1 -2
  58. package/shared/useYjsCollaboration.d.ts +4 -1
@@ -5,10 +5,12 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { EditorThemeClasses, LexicalEditor } from 'lexical';
8
+ import type { EditorThemeClasses, Klass, LexicalEditor, LexicalNode } from 'lexical';
9
9
  import { ReactNode } from 'react';
10
- export declare function LexicalNestedComposer({ initialEditor, children, initialTheme, }: {
10
+ export declare function LexicalNestedComposer({ initialEditor, children, initialNodes, initialTheme, skipCollabChecks, }: {
11
11
  children: ReactNode;
12
12
  initialEditor: LexicalEditor;
13
13
  initialTheme?: EditorThemeClasses;
14
+ initialNodes?: ReadonlyArray<Klass<LexicalNode>>;
15
+ skipCollabChecks?: true;
14
16
  }): JSX.Element;
@@ -20,7 +20,9 @@ var React = require('react');
20
20
  function LexicalNestedComposer({
21
21
  initialEditor,
22
22
  children,
23
- initialTheme
23
+ initialNodes,
24
+ initialTheme,
25
+ skipCollabChecks
24
26
  }) {
25
27
  const wasCollabPreviouslyReadyRef = React.useRef(false);
26
28
  const parentContext = React.useContext(LexicalComposerContext.LexicalComposerContext);
@@ -41,7 +43,27 @@ function LexicalNestedComposer({
41
43
  }
42
44
 
43
45
  initialEditor._parentEditor = parentEditor;
44
- initialEditor._nodes = parentEditor._nodes;
46
+
47
+ if (!initialNodes) {
48
+ const parentNodes = initialEditor._nodes = new Map(parentEditor._nodes);
49
+
50
+ for (const [type, entry] of parentNodes) {
51
+ initialEditor._nodes.set(type, {
52
+ klass: entry.klass,
53
+ transforms: new Set()
54
+ });
55
+ }
56
+ } else {
57
+ for (const klass of initialNodes) {
58
+ const type = klass.getType();
59
+
60
+ initialEditor._nodes.set(type, {
61
+ klass,
62
+ transforms: new Set()
63
+ });
64
+ }
65
+ }
66
+
45
67
  initialEditor._config.namespace = parentEditor._config.namespace;
46
68
  return [initialEditor, context];
47
69
  }, // We only do this for init
@@ -53,7 +75,7 @@ function LexicalNestedComposer({
53
75
  isCollabActive,
54
76
  yjsDocMap
55
77
  } = LexicalCollaborationContext.useCollaborationContext();
56
- const isCollabReady = wasCollabPreviouslyReadyRef.current || yjsDocMap.has(initialEditor.getKey());
78
+ const isCollabReady = skipCollabChecks || wasCollabPreviouslyReadyRef.current || yjsDocMap.has(initialEditor.getKey());
57
79
  React.useEffect(() => {
58
80
  if (isCollabReady) {
59
81
  wasCollabPreviouslyReadyRef.current = true;
@@ -13,4 +13,5 @@ declare export function LexicalNestedComposer({
13
13
  children: React$Node,
14
14
  initialEditor: LexicalEditor,
15
15
  initialTheme?: EditorThemeClasses,
16
+ initialNodes?: $ReadOnlyArray<Class<LexicalNode>>,
16
17
  }): React$Node;
@@ -4,6 +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 b=require("@lexical/react/LexicalCollaborationContext"),c=require("@lexical/react/LexicalComposerContext"),k=require("react");
8
- exports.LexicalNestedComposer=function({initialEditor:a,children:l,initialTheme:m}){let h=k.useRef(!1),d=k.useContext(c.LexicalComposerContext);if(null==d)throw Error("Minified Lexical error #9; visit https://lexical.dev/docs/error?code=9 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let q=k.useMemo(()=>{const [e,n]=d,f=m||n.getTheme()||void 0,p=c.createLexicalComposerContext(d,f);void 0!==f&&(a._config.theme=f);a._parentEditor=e;a._nodes=
9
- e._nodes;a._config.namespace=e._config.namespace;return[a,p]},[]),{isCollabActive:r,yjsDocMap:t}=b.useCollaborationContext(),g=h.current||t.has(a.getKey());k.useEffect(()=>{g&&(h.current=!0)},[g]);return k.createElement(c.LexicalComposerContext.Provider,{value:q},!r||g?l:null)}
7
+ 'use strict';var b=require("@lexical/react/LexicalCollaborationContext"),e=require("@lexical/react/LexicalComposerContext"),m=require("react");
8
+ exports.LexicalNestedComposer=function({initialEditor:a,children:n,initialNodes:k,initialTheme:p,skipCollabChecks:q}){let l=m.useRef(!1),f=m.useContext(e.LexicalComposerContext);if(null==f)throw Error("Minified Lexical error #9; visit https://lexical.dev/docs/error?code=9 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let w=m.useMemo(()=>{const [g,r]=f;var c=p||r.getTheme()||void 0;const t=e.createLexicalComposerContext(f,c);void 0!==
9
+ c&&(a._config.theme=c);a._parentEditor=g;if(k)for(var d of k)c=d.getType(),a._nodes.set(c,{klass:d,transforms:new Set});else{d=a._nodes=new Map(g._nodes);for(const [u,v]of d)a._nodes.set(u,{klass:v.klass,transforms:new Set})}a._config.namespace=g._config.namespace;return[a,t]},[]),{isCollabActive:x,yjsDocMap:y}=b.useCollaborationContext(),h=q||l.current||y.has(a.getKey());m.useEffect(()=>{h&&(l.current=!0)},[h]);return m.createElement(e.LexicalComposerContext.Provider,{value:w},!x||h?n:null)}
@@ -6,9 +6,8 @@
6
6
  *
7
7
  */
8
8
  import type { EditorState, LexicalEditor } from 'lexical';
9
- export declare function OnChangePlugin({ ignoreHistoryMergeTagChange, ignoreInitialChange, ignoreSelectionChange, onChange, }: {
9
+ export declare function OnChangePlugin({ ignoreHistoryMergeTagChange, ignoreSelectionChange, onChange, }: {
10
10
  ignoreHistoryMergeTagChange?: boolean;
11
- ignoreInitialChange?: boolean;
12
11
  ignoreSelectionChange?: boolean;
13
12
  onChange: (editorState: EditorState, editor: LexicalEditor) => void;
14
13
  }): null;
@@ -36,9 +36,7 @@ var useLayoutEffect = useLayoutEffectImpl;
36
36
  *
37
37
  */
38
38
  function OnChangePlugin({
39
- // TODO 0.5 flip to true
40
- ignoreHistoryMergeTagChange = false,
41
- ignoreInitialChange = true,
39
+ ignoreHistoryMergeTagChange = true,
42
40
  ignoreSelectionChange = false,
43
41
  onChange
44
42
  }) {
@@ -52,18 +50,14 @@ function OnChangePlugin({
52
50
  prevEditorState,
53
51
  tags
54
52
  }) => {
55
- if (ignoreSelectionChange && dirtyElements.size === 0 && dirtyLeaves.size === 0 || ignoreHistoryMergeTagChange && tags.has('history-merge')) {
56
- return;
57
- }
58
-
59
- if (ignoreInitialChange && prevEditorState.isEmpty()) {
53
+ if (ignoreSelectionChange && dirtyElements.size === 0 && dirtyLeaves.size === 0 || ignoreHistoryMergeTagChange && tags.has('history-merge') || prevEditorState.isEmpty()) {
60
54
  return;
61
55
  }
62
56
 
63
57
  onChange(editorState, editor);
64
58
  });
65
59
  }
66
- }, [editor, ignoreHistoryMergeTagChange, ignoreInitialChange, ignoreSelectionChange, onChange]);
60
+ }, [editor, ignoreHistoryMergeTagChange, ignoreSelectionChange, onChange]);
67
61
  return null;
68
62
  }
69
63
 
@@ -11,8 +11,6 @@ import type {EditorState, LexicalEditor} from 'lexical';
11
11
 
12
12
  declare export function OnChangePlugin({
13
13
  ignoreHistoryMergeTagChange?: boolean,
14
- // TODO 0.5 remove
15
- ignoreInitialChange?: boolean,
16
14
  ignoreSelectionChange?: boolean,
17
15
  onChange: (editorState: EditorState, editor: LexicalEditor) => void,
18
16
  }): null;
@@ -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 c=require("@lexical/react/LexicalComposerContext"),g=require("react"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;
8
- exports.OnChangePlugin=function({ignoreHistoryMergeTagChange:d=!1,ignoreInitialChange:e=!0,ignoreSelectionChange:f=!1,onChange:a}){let [b]=c.useLexicalComposerContext();h(()=>{if(a)return b.registerUpdateListener(({editorState:k,dirtyElements:l,dirtyLeaves:m,prevEditorState:n,tags:p})=>{f&&0===l.size&&0===m.size||d&&p.has("history-merge")||e&&n.isEmpty()||a(k,b)})},[b,d,e,f,a]);return null}
7
+ 'use strict';var c=require("@lexical/react/LexicalComposerContext"),f=require("react"),g="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;
8
+ exports.OnChangePlugin=function({ignoreHistoryMergeTagChange:d=!0,ignoreSelectionChange:e=!1,onChange:a}){let [b]=c.useLexicalComposerContext();g(()=>{if(a)return b.registerUpdateListener(({editorState:h,dirtyElements:k,dirtyLeaves:l,prevEditorState:m,tags:n})=>{e&&0===k.size&&0===l.size||d&&n.has("history-merge")||m.isEmpty()||a(h,b)})},[b,d,e,a]);return null}
@@ -5,9 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import { InitialEditorStateType } from '@lexical/plain-text';
9
- export declare function PlainTextPlugin({ contentEditable, placeholder, initialEditorState, }: {
8
+ export declare function PlainTextPlugin({ contentEditable, placeholder, }: {
10
9
  contentEditable: JSX.Element;
11
- initialEditorState?: InitialEditorStateType;
12
10
  placeholder: JSX.Element | string;
13
11
  }): JSX.Element;
@@ -14,25 +14,6 @@ var reactDom = require('react-dom');
14
14
  var dragon = require('@lexical/dragon');
15
15
  var plainText = require('@lexical/plain-text');
16
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
- }
35
-
36
17
  /**
37
18
  * Copyright (c) Meta Platforms, Inc. and affiliates.
38
19
  *
@@ -132,9 +113,9 @@ function useDecorators(editor) {
132
113
  * LICENSE file in the root directory of this source tree.
133
114
  *
134
115
  */
135
- function usePlainTextSetup(editor, initialEditorState) {
116
+ function usePlainTextSetup(editor) {
136
117
  useLayoutEffect(() => {
137
- return utils.mergeRegister(plainText.registerPlainText(editor, initialEditorState), dragon.registerDragonSupport(editor)); // We only do this for init
118
+ return utils.mergeRegister(plainText.registerPlainText(editor), dragon.registerDragonSupport(editor)); // We only do this for init
138
119
  // eslint-disable-next-line react-hooks/exhaustive-deps
139
120
  }, [editor]);
140
121
  }
@@ -146,20 +127,14 @@ function usePlainTextSetup(editor, initialEditorState) {
146
127
  * LICENSE file in the root directory of this source tree.
147
128
  *
148
129
  */
149
- const deprecatedInitialEditorStateWarning = warnOnlyOnce('`initialEditorState` on `PlainTextPlugin` is deprecated and will be removed soon. Use the `initialConfig.editorState` prop on the `LexicalComposer` instead.');
150
130
  function PlainTextPlugin({
151
131
  contentEditable,
152
- placeholder,
153
- initialEditorState
132
+ placeholder
154
133
  }) {
155
- if (deprecatedInitialEditorStateWarning && initialEditorState !== undefined) {
156
- deprecatedInitialEditorStateWarning();
157
- }
158
-
159
134
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
160
135
  const showPlaceholder = useCanShowPlaceholder(editor);
161
136
  const decorators = useDecorators(editor);
162
- usePlainTextSetup(editor, initialEditorState);
137
+ usePlainTextSetup(editor);
163
138
  return /*#__PURE__*/React.createElement(React.Fragment, null, contentEditable, showPlaceholder && placeholder, decorators);
164
139
  }
165
140
 
@@ -17,6 +17,5 @@ type InitialEditorStateType =
17
17
 
18
18
  declare export function PlainTextPlugin({
19
19
  contentEditable: React$Node,
20
- initialEditorState?: InitialEditorStateType,
21
20
  placeholder: React$Node,
22
21
  }): 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 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.isEditable()))}
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.registerEditableListener(()=>{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)}
7
+ 'use strict';var c=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.isEditable()))}
8
+ function u(a){let [e,d]=h.useState(()=>t(a));r(()=>{function b(){let f=t(a);d(f)}b();return m.mergeRegister(a.registerUpdateListener(()=>{b()}),a.registerEditableListener(()=>{b()}))},[a]);return e}
9
+ function v(a){let [e,d]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{n.flushSync(()=>{d(b)})}),[a]);h.useEffect(()=>{d(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],f=Object.keys(e);for(let k=0;k<f.length;k++){var g=f[k];let w=e[g];g=a.getElementByKey(g);null!==g&&b.push(n.createPortal(w,g))}return b},[e,a])}function x(a){r(()=>m.mergeRegister(q.registerPlainText(a),p.registerDragonSupport(a)),[a])}
10
+ exports.PlainTextPlugin=function({contentEditable:a,placeholder:e}){let [d]=c.useLexicalComposerContext(),b=u(d),f=v(d);x(d);return h.createElement(h.Fragment,null,a,b&&e,f)}
@@ -5,9 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import { InitialEditorStateType } from '@lexical/rich-text';
9
- export declare function RichTextPlugin({ contentEditable, placeholder, initialEditorState, }: Readonly<{
8
+ export declare function RichTextPlugin({ contentEditable, placeholder, }: Readonly<{
10
9
  contentEditable: JSX.Element;
11
- initialEditorState?: InitialEditorStateType;
12
10
  placeholder: JSX.Element | string;
13
11
  }>): JSX.Element;
@@ -14,25 +14,6 @@ var reactDom = require('react-dom');
14
14
  var dragon = require('@lexical/dragon');
15
15
  var richText = require('@lexical/rich-text');
16
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
- }
35
-
36
17
  /**
37
18
  * Copyright (c) Meta Platforms, Inc. and affiliates.
38
19
  *
@@ -132,9 +113,9 @@ function useDecorators(editor) {
132
113
  * LICENSE file in the root directory of this source tree.
133
114
  *
134
115
  */
135
- function useRichTextSetup(editor, initialEditorState) {
116
+ function useRichTextSetup(editor) {
136
117
  useLayoutEffect(() => {
137
- return utils.mergeRegister(richText.registerRichText(editor, initialEditorState), dragon.registerDragonSupport(editor)); // We only do this for init
118
+ return utils.mergeRegister(richText.registerRichText(editor), dragon.registerDragonSupport(editor)); // We only do this for init
138
119
  // eslint-disable-next-line react-hooks/exhaustive-deps
139
120
  }, [editor]);
140
121
  }
@@ -146,20 +127,14 @@ function useRichTextSetup(editor, initialEditorState) {
146
127
  * LICENSE file in the root directory of this source tree.
147
128
  *
148
129
  */
149
- const deprecatedInitialEditorStateWarning = warnOnlyOnce('`initialEditorState` on `RichTextPlugin` is deprecated and will be removed soon. Use the `initialConfig.editorState` prop on the `LexicalComposer` instead.');
150
130
  function RichTextPlugin({
151
131
  contentEditable,
152
- placeholder,
153
- initialEditorState
132
+ placeholder
154
133
  }) {
155
- if (deprecatedInitialEditorStateWarning && initialEditorState !== undefined) {
156
- deprecatedInitialEditorStateWarning();
157
- }
158
-
159
134
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
160
135
  const showPlaceholder = useCanShowPlaceholder(editor);
161
136
  const decorators = useDecorators(editor);
162
- useRichTextSetup(editor, initialEditorState);
137
+ useRichTextSetup(editor);
163
138
  return /*#__PURE__*/React.createElement(React.Fragment, null, contentEditable, showPlaceholder && placeholder, decorators);
164
139
  }
165
140
 
@@ -17,6 +17,5 @@ type InitialEditorStateType =
17
17
 
18
18
  declare export function RichTextPlugin({
19
19
  contentEditable: React$Node,
20
- initialEditorState?: InitialEditorStateType,
21
20
  placeholder: React$Node,
22
21
  }): 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 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.isEditable()))}
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.registerEditableListener(()=>{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)}
7
+ 'use strict';var c=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.isEditable()))}
8
+ function u(a){let [e,d]=h.useState(()=>t(a));r(()=>{function b(){let f=t(a);d(f)}b();return m.mergeRegister(a.registerUpdateListener(()=>{b()}),a.registerEditableListener(()=>{b()}))},[a]);return e}
9
+ function v(a){let [e,d]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{n.flushSync(()=>{d(b)})}),[a]);h.useEffect(()=>{d(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],f=Object.keys(e);for(let k=0;k<f.length;k++){var g=f[k];let w=e[g];g=a.getElementByKey(g);null!==g&&b.push(n.createPortal(w,g))}return b},[e,a])}function x(a){r(()=>m.mergeRegister(q.registerRichText(a),p.registerDragonSupport(a)),[a])}
10
+ exports.RichTextPlugin=function({contentEditable:a,placeholder:e}){let [d]=c.useLexicalComposerContext(),b=u(d),f=v(d);x(d);return h.createElement(h.Fragment,null,a,b&&e,f)}
@@ -10,7 +10,7 @@
10
10
  import type {HeadingTagType} from '@lexical/rich-text';
11
11
  import type {NodeKey} from 'lexical';
12
12
 
13
- declare export function LexicalTableOfContentsPlugin({
13
+ declare export default function LexicalTableOfContentsPlugin({
14
14
  children: (
15
15
  tableOfContents: Array<[NodeKey, string, HeadingTagType]>,
16
16
  ) => React$Node,
@@ -44,7 +44,7 @@ function TablePlugin() {
44
44
  if (focusNode !== null) {
45
45
  const tableNode = table.$createTableNodeWithDimensions(Number(rows), Number(columns), includeHeaders);
46
46
 
47
- if (lexical.$isRootNode(focusNode)) {
47
+ if (lexical.$isRootOrShadowRoot(focusNode)) {
48
48
  const target = focusNode.getChildAtIndex(focus.offset);
49
49
 
50
50
  if (target !== null) {
@@ -6,5 +6,5 @@
6
6
  */
7
7
  'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("@lexical/table"),k=require("lexical"),m=require("react");
8
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; visit https://lexical.dev/docs/error?code=10 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;
9
- b=h.getNode();null!==b&&(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"===
9
+ b=h.getNode();null!==b&&(a=f.$createTableNodeWithDimensions(Number(c),Number(a),g),k.$isRootOrShadowRoot(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"===
10
10
  b?d.update(()=>{var h=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}
@@ -213,7 +213,7 @@ function generateContent(editorState) {
213
213
  typeDisplay
214
214
  });
215
215
  });
216
- return selection === null ? ': null' : lexical.$isRangeSelection(selection) ? printRangeSelection(selection) : lexical.$isGridSelection(selection) ? printGridSelection(selection) : printObjectSelection(selection);
216
+ return selection === null ? ': null' : lexical.$isRangeSelection(selection) ? printRangeSelection(selection) : lexical.DEPRECATED_$isGridSelection(selection) ? printGridSelection(selection) : printObjectSelection(selection);
217
217
  });
218
218
  return res + '\n selection' + selectionString;
219
219
  }
@@ -237,7 +237,7 @@ function normalize(text) {
237
237
 
238
238
  function printNode(node) {
239
239
  if (lexical.$isTextNode(node)) {
240
- const text = node.getTextContent(true);
240
+ const text = node.getTextContent();
241
241
  const title = text.length === 0 ? '(empty)' : `"${normalize(text)}"`;
242
242
  const properties = printAllTextNodeProperties(node);
243
243
  return [title, properties.length !== 0 ? `{ ${properties} }` : null].filter(Boolean).join(' ').trim();
@@ -253,7 +253,7 @@ function printNode(node) {
253
253
 
254
254
  const FORMAT_PREDICATES = [node => node.hasFormat('bold') && 'Bold', node => node.hasFormat('code') && 'Code', node => node.hasFormat('italic') && 'Italic', node => node.hasFormat('strikethrough') && 'Strikethrough', node => node.hasFormat('subscript') && 'Subscript', node => node.hasFormat('superscript') && 'Superscript', node => node.hasFormat('underline') && 'Underline'];
255
255
  const DETAIL_PREDICATES = [node => node.isDirectionless() && 'Directionless', node => node.isUnmergeable() && 'Unmergeable'];
256
- const MODE_PREDICATES = [node => node.isToken() && 'Token', node => node.isSegmented() && 'Segmented', node => node.isInert() && 'Inert'];
256
+ const MODE_PREDICATES = [node => node.isToken() && 'Token', node => node.isSegmented() && 'Segmented'];
257
257
 
258
258
  function printAllTextNodeProperties(node) {
259
259
  return [printFormatProperties(node), printDetailProperties(node), printModeProperties(node)].filter(Boolean).join(', ');
@@ -353,7 +353,7 @@ function printSelectedCharsLine({
353
353
  function $getSelectionStartEnd(node, selection) {
354
354
  const anchor = selection.anchor;
355
355
  const focus = selection.focus;
356
- const textContent = node.getTextContent(true);
356
+ const textContent = node.getTextContent();
357
357
  const textLength = textContent.length;
358
358
  let start = -1;
359
359
  let end = -1; // Only one node is being selected.
@@ -6,12 +6,12 @@
6
6
  */
7
7
  'use strict';var l=require("@lexical/link"),q=require("@lexical/mark"),t=require("lexical"),D=require("react");let E=Object.freeze({"\t":"\\t","\n":"\\n"}),F=new RegExp(Object.keys(E).join("|"),"g"),G=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"\u251c",isLastChild:"\u2514",selectedChar:"^",selectedLine:">"});
8
8
  function H(a){let b="",c=I(a),d=a.anchor;a=a.focus;let e=d.offset,g=a.offset;b=b+`: range ${""!==c?`{ ${c} }`:""}`+`\n \u251c anchor { key: ${d.key}, offset: ${null===e?"null":e}, type: ${d.type} }`;return b+=`\n \u2514 focus { key: ${a.key}, offset: ${null===g?"null":g}, type: ${a.type} }`}
9
- function K(a){let b=" root\n";a=a.read(()=>{const c=t.$getSelection();L(t.$getRoot(),(d,e)=>{const g=`(${d.getKey()})`,h=d.getType()||"",n=d.isSelected(),w=q.$isMarkNode(d)?` id: [ ${d.getIDs().join(", ")} ] `:"";var v=b,r=n?G.selectedLine:" ",x=e.join(" ");if(t.$isTextNode(d)){var f=d.getTextContent(!0);var m=0===f.length?"(empty)":`"${M(f)}"`;f=[I(d),N(d),O(d)].filter(Boolean).join(", ");f=[m,0!==f.length?`{ ${f} }`:null].filter(Boolean).join(" ").trim()}else if(l.$isLinkNode(d)){f=d.getURL();f=
10
- 0===f.length?"(empty)":`"${M(f)}"`;m=d.getTarget();null!=m&&(m="target: "+m);var y=Boolean;let u=d.getRel();null!=u&&(u="rel: "+u);m=[m,u].filter(y).join(", ");f=[f,0!==m.length?`{ ${m} }`:null].filter(Boolean).join(" ").trim()}else f="";b=v+`${r} ${x} ${g} ${h} ${w} ${f}\n`;b+=P({indent:e,isSelected:n,node:d,nodeKeyDisplay:g,selection:c,typeDisplay:h})});return null===c?": null":t.$isRangeSelection(c)?H(c):t.$isGridSelection(c)?`: grid\n \u2514 { grid: ${c.gridKey}, anchorCell: ${c.anchor.key}, focusCell: ${c.focus.key} }`:
9
+ function K(a){let b=" root\n";a=a.read(()=>{const c=t.$getSelection();L(t.$getRoot(),(d,e)=>{const g=`(${d.getKey()})`,h=d.getType()||"",n=d.isSelected(),w=q.$isMarkNode(d)?` id: [ ${d.getIDs().join(", ")} ] `:"";var v=b,r=n?G.selectedLine:" ",x=e.join(" ");if(t.$isTextNode(d)){var f=d.getTextContent();var m=0===f.length?"(empty)":`"${M(f)}"`;f=[I(d),N(d),O(d)].filter(Boolean).join(", ");f=[m,0!==f.length?`{ ${f} }`:null].filter(Boolean).join(" ").trim()}else if(l.$isLinkNode(d)){f=d.getURL();f=0===
10
+ f.length?"(empty)":`"${M(f)}"`;m=d.getTarget();null!=m&&(m="target: "+m);var y=Boolean;let u=d.getRel();null!=u&&(u="rel: "+u);m=[m,u].filter(y).join(", ");f=[f,0!==m.length?`{ ${m} }`:null].filter(Boolean).join(" ").trim()}else f="";b=v+`${r} ${x} ${g} ${h} ${w} ${f}\n`;b+=P({indent:e,isSelected:n,node:d,nodeKeyDisplay:g,selection:c,typeDisplay:h})});return null===c?": null":t.$isRangeSelection(c)?H(c):t.DEPRECATED_$isGridSelection(c)?`: grid\n \u2514 { grid: ${c.gridKey}, anchorCell: ${c.anchor.key}, focusCell: ${c.focus.key} }`:
11
11
  `: node\n \u2514 [${Array.from(c._nodes).join(", ")}]`});return b+"\n selection"+a}function L(a,b,c=[]){a=a.getChildren();let d=a.length;a.forEach((e,g)=>{b(e,c.concat(g===d-1?G.isLastChild:G.hasNextSibling));t.$isElementNode(e)&&L(e,b,c.concat(g===d-1?G.ancestorIsLastChild:G.ancestorHasNextSibling))})}function M(a){return Object.entries(E).reduce((b,[c,d])=>b.replace(new RegExp(c,"g"),String(d)),a)}
12
- let Q=[a=>a.hasFormat("bold")&&"Bold",a=>a.hasFormat("code")&&"Code",a=>a.hasFormat("italic")&&"Italic",a=>a.hasFormat("strikethrough")&&"Strikethrough",a=>a.hasFormat("subscript")&&"Subscript",a=>a.hasFormat("superscript")&&"Superscript",a=>a.hasFormat("underline")&&"Underline"],R=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],S=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented",a=>a.isInert()&&"Inert"];
12
+ let Q=[a=>a.hasFormat("bold")&&"Bold",a=>a.hasFormat("code")&&"Code",a=>a.hasFormat("italic")&&"Italic",a=>a.hasFormat("strikethrough")&&"Strikethrough",a=>a.hasFormat("subscript")&&"Subscript",a=>a.hasFormat("superscript")&&"Superscript",a=>a.hasFormat("underline")&&"Underline"],R=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],S=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented"];
13
13
  function N(a){let b=R.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="detail: "+b);return b}function O(a){let b=S.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="mode: "+b);return b}function I(a){let b=Q.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b}
14
- function P({indent:a,isSelected:b,node:c,nodeKeyDisplay:d,selection:e,typeDisplay:g}){if(!t.$isTextNode(c)||!t.$isRangeSelection(e)||!b||t.$isElementNode(c))return"";b=e.anchor;var h=e.focus;if(""===c.getTextContent()||b.getNode()===e.focus.getNode()&&b.offset===h.offset)return"";h=e.anchor;let n=e.focus,w=c.getTextContent(!0),v=w.length;b=e=-1;if("text"===h.type&&"text"===n.type){let f=h.getNode(),m=n.getNode();f===m&&c===f&&h.offset!==n.offset?[e,b]=h.offset<n.offset?[h.offset,n.offset]:[n.offset,
14
+ function P({indent:a,isSelected:b,node:c,nodeKeyDisplay:d,selection:e,typeDisplay:g}){if(!t.$isTextNode(c)||!t.$isRangeSelection(e)||!b||t.$isElementNode(c))return"";b=e.anchor;var h=e.focus;if(""===c.getTextContent()||b.getNode()===e.focus.getNode()&&b.offset===h.offset)return"";h=e.anchor;let n=e.focus,w=c.getTextContent(),v=w.length;b=e=-1;if("text"===h.type&&"text"===n.type){let f=h.getNode(),m=n.getNode();f===m&&c===f&&h.offset!==n.offset?[e,b]=h.offset<n.offset?[h.offset,n.offset]:[n.offset,
15
15
  h.offset]:c===f?[e,b]=f.isBefore(m)?[h.offset,v]:[0,h.offset]:c===m?[e,b]=m.isBefore(f)?[n.offset,v]:[0,n.offset]:[e,b]=[0,v]}c=(w.slice(0,e).match(F)||[]).length;h=(w.slice(e,b).match(F)||[]).length;let [r,x]=[e+c,b+c+h];if(r===x)return"";c=a[a.length-1]===G.hasNextSibling?G.ancestorHasNextSibling:G.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(r+1).fill(" ");e=Array(x-r).fill(G.selectedChar);d=Array(d.length+(g.length+3)).fill(" ");return[G.selectedLine,a.join(" "),[...d,...c,...e].join("")].join(" ")+
16
16
  "\n"}
17
17
  exports.TreeView=function({timeTravelButtonClassName:a,timeTravelPanelSliderClassName:b,timeTravelPanelButtonClassName:c,viewClassName:d,timeTravelPanelClassName:e,editor:g}){let [h,n]=D.useState([]),[w,v]=D.useState(""),[r,x]=D.useState(!1),f=D.useRef(0),m=D.useRef(null),y=D.useRef(null),[u,C]=D.useState(!1);D.useEffect(()=>{v(K(g.getEditorState()));return g.registerUpdateListener(({editorState:k})=>{let p=g._compositionKey,z=K(g.getEditorState());v([z,null!==p&&`Composition key: ${p}`].filter(Boolean).join("\n\n"));r||
@@ -14,6 +14,7 @@ export declare type QueryMatch = {
14
14
  };
15
15
  export declare type Resolution = {
16
16
  match: QueryMatch;
17
+ position: 'start' | 'end';
17
18
  getRect: () => ClientRect;
18
19
  };
19
20
  export declare const PUNCTUATION = "\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
@@ -38,15 +39,17 @@ export declare type TypeaheadMenuPluginArgs<TOption extends TypeaheadOption> = {
38
39
  options: Array<TOption>;
39
40
  menuRenderFn: MenuRenderFn<TOption>;
40
41
  triggerFn: TriggerFn;
42
+ position?: 'start' | 'end';
41
43
  };
42
44
  export declare type TriggerFn = (text: string, editor: LexicalEditor) => QueryMatch | null;
43
- export declare function LexicalTypeaheadMenuPlugin<TOption extends TypeaheadOption>({ options, onQueryChange, onSelectOption, menuRenderFn, triggerFn, }: TypeaheadMenuPluginArgs<TOption>): JSX.Element | null;
45
+ export declare function LexicalTypeaheadMenuPlugin<TOption extends TypeaheadOption>({ options, onQueryChange, onSelectOption, menuRenderFn, triggerFn, position, }: TypeaheadMenuPluginArgs<TOption>): JSX.Element | null;
44
46
  declare type NodeMenuPluginArgs<TOption extends TypeaheadOption> = {
45
47
  onSelectOption: (option: TOption, textNodeContainingQuery: TextNode | null, closeMenu: () => void, matchingString: string) => void;
46
48
  options: Array<TOption>;
47
49
  nodeKey: NodeKey | null;
48
50
  onClose: () => void;
51
+ position?: 'start' | 'end';
49
52
  menuRenderFn: MenuRenderFn<TOption>;
50
53
  };
51
- export declare function LexicalNodeMenuPlugin<TOption extends TypeaheadOption>({ options, nodeKey, onClose, onSelectOption, menuRenderFn, }: NodeMenuPluginArgs<TOption>): JSX.Element | null;
54
+ export declare function LexicalNodeMenuPlugin<TOption extends TypeaheadOption>({ options, nodeKey, position, onClose, onSelectOption, menuRenderFn, }: NodeMenuPluginArgs<TOption>): JSX.Element | null;
52
55
  export {};
@@ -228,7 +228,7 @@ function LexicalPopoverMenu({
228
228
  React.useEffect(() => {
229
229
  setHighlightedIndex(0);
230
230
  }, [resolution.match.matchingString]);
231
- const selectOptionAndCleanUp = React.useCallback(async selectedEntry => {
231
+ const selectOptionAndCleanUp = React.useCallback(selectedEntry => {
232
232
  editor.update(() => {
233
233
  const textNodeContainingQuery = splitNodeContainingQuery(editor, resolution.match);
234
234
  onSelectOption(selectedEntry, textNodeContainingQuery, close, resolution.match.matchingString);
@@ -374,10 +374,11 @@ function useAnchorElementRef(resolution) {
374
374
  const {
375
375
  left,
376
376
  top,
377
+ width,
377
378
  height
378
379
  } = resolution.getRect();
379
380
  containerDiv.style.top = `${top + height + 5 + window.pageYOffset}px`;
380
- containerDiv.style.left = `${left + window.pageXOffset}px`;
381
+ containerDiv.style.left = `${left + (resolution.position === 'start' ? 0 : width) + window.pageXOffset}px`;
381
382
  containerDiv.style.display = 'block';
382
383
  containerDiv.style.position = 'absolute';
383
384
 
@@ -410,14 +411,14 @@ function LexicalTypeaheadMenuPlugin({
410
411
  onQueryChange,
411
412
  onSelectOption,
412
413
  menuRenderFn,
413
- triggerFn
414
+ triggerFn,
415
+ position = 'start'
414
416
  }) {
415
417
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
416
418
  const [resolution, setResolution] = React.useState(null);
417
419
  const anchorElementRef = useAnchorElementRef(resolution);
418
420
  React.useEffect(() => {
419
421
  let activeRange = document.createRange();
420
- let previousText = null;
421
422
 
422
423
  const updateListener = () => {
423
424
  editor.getEditorState().read(() => {
@@ -425,12 +426,11 @@ function LexicalTypeaheadMenuPlugin({
425
426
  const selection = lexical.$getSelection();
426
427
  const text = getQueryTextForSearch(editor);
427
428
 
428
- if (!lexical.$isRangeSelection(selection) || !selection.isCollapsed() || text === previousText || text === null || range === null) {
429
+ if (!lexical.$isRangeSelection(selection) || !selection.isCollapsed() || text === null || range === null) {
429
430
  setResolution(null);
430
431
  return;
431
432
  }
432
433
 
433
- previousText = text;
434
434
  const match = triggerFn(text, editor);
435
435
  onQueryChange(match ? match.matchingString : null);
436
436
 
@@ -440,7 +440,8 @@ function LexicalTypeaheadMenuPlugin({
440
440
  if (isRangePositioned !== null) {
441
441
  startTransition(() => setResolution({
442
442
  getRect: () => range.getBoundingClientRect(),
443
- match
443
+ match,
444
+ position
444
445
  }));
445
446
  return;
446
447
  }
@@ -455,7 +456,7 @@ function LexicalTypeaheadMenuPlugin({
455
456
  activeRange = null;
456
457
  removeUpdateListener();
457
458
  };
458
- }, [editor, triggerFn, onQueryChange, resolution]);
459
+ }, [editor, triggerFn, onQueryChange, resolution, position]);
459
460
  const closeTypeahead = React.useCallback(() => {
460
461
  setResolution(null);
461
462
  }, []);
@@ -472,6 +473,7 @@ function LexicalTypeaheadMenuPlugin({
472
473
  function LexicalNodeMenuPlugin({
473
474
  options,
474
475
  nodeKey,
476
+ position = 'end',
475
477
  onClose,
476
478
  onSelectOption,
477
479
  menuRenderFn
@@ -493,14 +495,15 @@ function LexicalNodeMenuPlugin({
493
495
  leadOffset: text.length,
494
496
  matchingString: text,
495
497
  replaceableString: text
496
- }
498
+ },
499
+ position
497
500
  }));
498
501
  }
499
502
  });
500
503
  } else if (nodeKey == null && resolution != null) {
501
504
  setResolution(null);
502
505
  }
503
- }, [editor, nodeKey, resolution]);
506
+ }, [editor, nodeKey, position, resolution]);
504
507
  return resolution === null || editor === null ? null : /*#__PURE__*/React.createElement(LexicalPopoverMenu, {
505
508
  close: onClose,
506
509
  resolution: resolution,