@depup/lexical__react 0.41.0-depup.0 → 0.43.0-depup.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 (108) hide show
  1. package/LexicalAutoEmbedPlugin.d.ts +2 -2
  2. package/LexicalAutoEmbedPlugin.js.flow +4 -4
  3. package/LexicalAutoFocusPlugin.js.flow +1 -1
  4. package/LexicalBlockWithAlignableContents.js.flow +2 -2
  5. package/LexicalClearEditorPlugin.js.flow +1 -1
  6. package/LexicalComposer.js.flow +2 -2
  7. package/LexicalContentEditable.js.flow +6 -6
  8. package/LexicalDecoratorBlockNode.d.ts +2 -0
  9. package/LexicalDecoratorBlockNode.dev.js +7 -0
  10. package/LexicalDecoratorBlockNode.dev.mjs +7 -0
  11. package/LexicalDecoratorBlockNode.prod.js +1 -1
  12. package/LexicalDecoratorBlockNode.prod.mjs +1 -1
  13. package/LexicalDraggableBlockPlugin.dev.js +2 -4
  14. package/LexicalDraggableBlockPlugin.dev.mjs +2 -4
  15. package/LexicalDraggableBlockPlugin.js.flow +1 -1
  16. package/LexicalDraggableBlockPlugin.prod.js +1 -1
  17. package/LexicalDraggableBlockPlugin.prod.mjs +1 -1
  18. package/LexicalEditorRefPlugin.d.ts +1 -1
  19. package/LexicalEditorRefPlugin.dev.js +0 -1
  20. package/LexicalEditorRefPlugin.dev.mjs +0 -1
  21. package/LexicalEditorRefPlugin.js.flow +1 -1
  22. package/LexicalErrorBoundary.js.flow +1 -1
  23. package/LexicalExtensionComposer.d.ts +1 -1
  24. package/LexicalExtensionEditorComposer.d.ts +20 -0
  25. package/LexicalExtensionEditorComposer.dev.js +55 -0
  26. package/LexicalExtensionEditorComposer.dev.mjs +53 -0
  27. package/LexicalExtensionEditorComposer.js +11 -0
  28. package/LexicalExtensionEditorComposer.js.flow +27 -0
  29. package/{LexicalContextMenuPlugin.mjs → LexicalExtensionEditorComposer.mjs} +3 -4
  30. package/{LexicalContextMenuPlugin.node.mjs → LexicalExtensionEditorComposer.node.mjs} +2 -3
  31. package/LexicalExtensionEditorComposer.prod.js +9 -0
  32. package/LexicalExtensionEditorComposer.prod.mjs +9 -0
  33. package/LexicalHorizontalRulePlugin.d.ts +3 -0
  34. package/LexicalHorizontalRulePlugin.dev.js +4 -0
  35. package/LexicalHorizontalRulePlugin.dev.mjs +4 -0
  36. package/LexicalHorizontalRulePlugin.js.flow +1 -1
  37. package/LexicalLinkPlugin.js.flow +1 -1
  38. package/LexicalMarkdownShortcutPlugin.dev.js +4 -4
  39. package/LexicalMarkdownShortcutPlugin.dev.mjs +1 -1
  40. package/LexicalMarkdownShortcutPlugin.prod.js +1 -1
  41. package/LexicalMarkdownShortcutPlugin.prod.mjs +1 -1
  42. package/LexicalNestedComposer.js.flow +1 -1
  43. package/LexicalNodeContextMenuPlugin.dev.js +2 -4
  44. package/LexicalNodeContextMenuPlugin.dev.mjs +2 -4
  45. package/LexicalNodeContextMenuPlugin.prod.js +1 -1
  46. package/LexicalNodeContextMenuPlugin.prod.mjs +1 -1
  47. package/LexicalNodeEventPlugin.dev.js +2 -4
  48. package/LexicalNodeEventPlugin.dev.mjs +2 -4
  49. package/LexicalNodeEventPlugin.prod.js +1 -1
  50. package/LexicalNodeEventPlugin.prod.mjs +1 -1
  51. package/LexicalNodeMenuPlugin.d.ts +1 -1
  52. package/LexicalNodeMenuPlugin.dev.js +53 -2
  53. package/LexicalNodeMenuPlugin.dev.mjs +54 -3
  54. package/LexicalNodeMenuPlugin.js.flow +3 -2
  55. package/LexicalNodeMenuPlugin.prod.js +1 -1
  56. package/LexicalNodeMenuPlugin.prod.mjs +1 -1
  57. package/LexicalPlainTextPlugin.dev.js +0 -3
  58. package/LexicalPlainTextPlugin.dev.mjs +0 -3
  59. package/LexicalReactExtension.dev.js +1 -3
  60. package/LexicalReactExtension.dev.mjs +1 -3
  61. package/LexicalReactExtension.js.flow +1 -1
  62. package/LexicalReactPluginHostExtension.dev.mjs +1 -1
  63. package/LexicalReactPluginHostExtension.js.flow +3 -3
  64. package/LexicalReactPluginHostExtension.prod.mjs +1 -1
  65. package/LexicalRichTextPlugin.dev.js +0 -3
  66. package/LexicalRichTextPlugin.dev.mjs +0 -3
  67. package/LexicalSelectionAlwaysOnDisplay.d.ts +1 -1
  68. package/LexicalTabIndentationPlugin.js.flow +1 -1
  69. package/LexicalTablePlugin.d.ts +1 -7
  70. package/LexicalTablePlugin.dev.js +2 -5
  71. package/LexicalTablePlugin.dev.mjs +2 -5
  72. package/LexicalTablePlugin.js.flow +1 -1
  73. package/LexicalTablePlugin.prod.js +1 -1
  74. package/LexicalTablePlugin.prod.mjs +1 -1
  75. package/LexicalTypeaheadMenuPlugin.d.ts +1 -1
  76. package/LexicalTypeaheadMenuPlugin.dev.js +53 -2
  77. package/LexicalTypeaheadMenuPlugin.dev.mjs +54 -3
  78. package/LexicalTypeaheadMenuPlugin.js.flow +8 -7
  79. package/LexicalTypeaheadMenuPlugin.prod.js +1 -1
  80. package/LexicalTypeaheadMenuPlugin.prod.mjs +1 -1
  81. package/README.md +2 -2
  82. package/changes.json +1 -1
  83. package/package.json +80 -50
  84. package/shared/LexicalMenu.d.ts +5 -4
  85. package/useExtensionComponent.d.ts +2 -0
  86. package/useExtensionSignalValue.d.ts +61 -0
  87. package/useLexicalExtensionComponent.dev.js +8 -0
  88. package/useLexicalExtensionComponent.dev.mjs +8 -2
  89. package/useLexicalExtensionComponent.mjs +3 -1
  90. package/useLexicalExtensionComponent.node.mjs +3 -1
  91. package/useLexicalExtensionComponent.prod.js +1 -1
  92. package/useLexicalExtensionComponent.prod.mjs +1 -1
  93. package/useLexicalExtensionSignalValue.dev.js +84 -0
  94. package/useLexicalExtensionSignalValue.dev.mjs +81 -0
  95. package/useLexicalExtensionSignalValue.js +11 -0
  96. package/useLexicalExtensionSignalValue.js.flow +18 -0
  97. package/useLexicalExtensionSignalValue.mjs +13 -0
  98. package/useLexicalExtensionSignalValue.node.mjs +11 -0
  99. package/useLexicalExtensionSignalValue.prod.js +9 -0
  100. package/useLexicalExtensionSignalValue.prod.mjs +9 -0
  101. package/useLexicalTextEntity.js.flow +1 -1
  102. package/LexicalContextMenuPlugin.d.ts +0 -42
  103. package/LexicalContextMenuPlugin.dev.js +0 -526
  104. package/LexicalContextMenuPlugin.dev.mjs +0 -511
  105. package/LexicalContextMenuPlugin.js +0 -11
  106. package/LexicalContextMenuPlugin.js.flow +0 -13
  107. package/LexicalContextMenuPlugin.prod.js +0 -9
  108. package/LexicalContextMenuPlugin.prod.mjs +0 -9
@@ -89,9 +89,7 @@ function buildEditorComponent(config, context) {
89
89
  const configDecorators = useMemo(() => rawConfigDecorators.map((decorator, i) => /*#__PURE__*/jsx(ErrorBoundary, {
90
90
  onError: e => {
91
91
  editor._onError(e);
92
- }
93
- // eslint-disable-next-line react/no-array-index-key -- no natural key
94
- ,
92
+ },
95
93
  children: /*#__PURE__*/jsx(Suspense, {
96
94
  fallback: null,
97
95
  children: decorator
@@ -46,7 +46,7 @@ export type ReactConfig = {
46
46
  contentEditable: React.Node | null;
47
47
  ErrorBoundary: ErrorBoundaryType;
48
48
  EditorChildrenComponent: EditorChildrenComponentType;
49
- decorators: $ReadOnlyArray<DecoratorComponentType>;
49
+ decorators: ReadonlyArray<DecoratorComponentType>;
50
50
  };
51
51
 
52
52
  export type ReactOutputs = {
@@ -10,7 +10,7 @@ import { untracked, signal, getExtensionDependencyFromEditor, effect } from '@le
10
10
  import { ReactExtension } from '@lexical/react/ReactExtension';
11
11
  import { ReactProviderExtension } from '@lexical/react/ReactProviderExtension';
12
12
  import { mergeRegister } from '@lexical/utils';
13
- import { createCommand, defineExtension, configExtension, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR } from 'lexical';
13
+ import { createCommand, defineExtension, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, configExtension } from 'lexical';
14
14
  import { useState, useEffect, Suspense } from 'react';
15
15
  import { createPortal } from 'react-dom';
16
16
  import { createRoot } from 'react-dom/client';
@@ -24,7 +24,7 @@ export type {DecoratorComponentProps};
24
24
 
25
25
  type Container = DocumentFragment | Element;
26
26
  // TODO: Not sure how to import RootType from react-dom/client
27
- type Root = mixed;
27
+ type Root = unknown;
28
28
 
29
29
  export interface HostMountCommandArg {
30
30
  root: Root;
@@ -37,7 +37,7 @@ export interface MountPluginCommandArg {
37
37
  }
38
38
 
39
39
  declare export function mountReactExtensionComponent<
40
- Extension: AnyLexicalExtension,
40
+ Extension extends AnyLexicalExtension,
41
41
  >(
42
42
  editor: LexicalEditor,
43
43
  opts: {
@@ -54,7 +54,7 @@ declare export function mountReactExtensionComponent<
54
54
  ): void;
55
55
 
56
56
  declare export function mountReactPluginComponent<
57
- P: {...} = {...},
57
+ P extends {...} = {...},
58
58
  >(
59
59
  editor: LexicalEditor,
60
60
  opts: {
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{untracked as e,signal as n,getExtensionDependencyFromEditor as t,effect as o}from"@lexical/extension";import{ReactExtension as r}from"@lexical/react/ReactExtension";import{ReactProviderExtension as i}from"@lexical/react/ReactProviderExtension";import{mergeRegister as l}from"@lexical/utils";import{createCommand as u,defineExtension as c,configExtension as a,COMMAND_PRIORITY_CRITICAL as s,COMMAND_PRIORITY_EDITOR as m}from"lexical";import{useState as p,useEffect as d,Suspense as f}from"react";import{createPortal as g}from"react-dom";import{createRoot as x}from"react-dom/client";import{jsx as h,Fragment as P}from"react/jsx-runtime";function v(e,n){const{props:o,extension:r,...i}=n,{Component:l}=t(e,r).output;C(e,{...i,element:o?h(l,{...o}):null})}function R(e,n){const{Component:t,props:o,...r}=n;C(e,{...r,element:o?h(t,{...o}):null})}function C(e,n){t(e,M).output.mountReactPlugin(n)}function _(e,n){t(e,M).output.mountReactPluginHost(n)}const E=u("REACT_PLUGIN_HOST_MOUNT_ROOT_COMMAND"),O=u("REACT_PLUGIN_HOST_MOUNT_PLUGIN_COMMAND");const M=c({build:(e,t,o)=>({mountReactPlugin:n=>{e.dispatchCommand(O,n)},mountReactPluginHost:n=>e.dispatchCommand(E,{root:x(n)}),mountedPluginsStore:n({plugins:new Map})}),dependencies:[i,a(r,{decorators:[function({context:[e]}){const{mountedPluginsStore:n}=t(e,M).output,{ErrorBoundary:i}=t(e,r).config,l=e._onError.bind(e),[{plugins:u},c]=p(()=>n.peek());d(()=>o(()=>c(n.value)),[n]);const a=[];for(const{key:e,element:n,domNode:t}of u.values()){if(!n)continue;const o=h(i,{onError:l,children:h(f,{fallback:null,children:n})},e);a.push(t?g(o,t,e):o)}return a.length>0?h(P,{children:a}):null}]})],name:"@lexical/react/ReactPluginHost",register(n,t,o){let i;const{mountedPluginsStore:u}=o.getOutput(),{Component:c}=o.getDependency(r).output;return l(()=>{i&&i.unmount(),e(()=>{u.value.plugins.clear()})},n.registerCommand(O,n=>(e(()=>{const{plugins:e}=u.value;e.set(n.key,n),u.value={plugins:e}}),!1),s),n.registerCommand(E,e=>(void 0!==i&&function(e,...n){const t=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of n)o.append("v",e);throw t.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(322),i=e.root,i.render(h(c,{contentEditable:null})),!0),m))}});export{O as REACT_PLUGIN_HOST_MOUNT_PLUGIN_COMMAND,E as REACT_PLUGIN_HOST_MOUNT_ROOT_COMMAND,M as ReactPluginHostExtension,v as mountReactExtensionComponent,R as mountReactPluginComponent,C as mountReactPluginElement,_ as mountReactPluginHost};
9
+ import{untracked as e,signal as n,getExtensionDependencyFromEditor as t,effect as o}from"@lexical/extension";import{ReactExtension as r}from"@lexical/react/ReactExtension";import{ReactProviderExtension as i}from"@lexical/react/ReactProviderExtension";import{mergeRegister as l}from"@lexical/utils";import{createCommand as u,defineExtension as c,COMMAND_PRIORITY_CRITICAL as a,COMMAND_PRIORITY_EDITOR as s,configExtension as m}from"lexical";import{useState as p,useEffect as d,Suspense as f}from"react";import{createPortal as g}from"react-dom";import{createRoot as x}from"react-dom/client";import{jsx as h,Fragment as P}from"react/jsx-runtime";function v(e,n){const{props:o,extension:r,...i}=n,{Component:l}=t(e,r).output;C(e,{...i,element:o?h(l,{...o}):null})}function R(e,n){const{Component:t,props:o,...r}=n;C(e,{...r,element:o?h(t,{...o}):null})}function C(e,n){t(e,M).output.mountReactPlugin(n)}function _(e,n){t(e,M).output.mountReactPluginHost(n)}const E=u("REACT_PLUGIN_HOST_MOUNT_ROOT_COMMAND"),O=u("REACT_PLUGIN_HOST_MOUNT_PLUGIN_COMMAND");const M=c({build:(e,t,o)=>({mountReactPlugin:n=>{e.dispatchCommand(O,n)},mountReactPluginHost:n=>e.dispatchCommand(E,{root:x(n)}),mountedPluginsStore:n({plugins:new Map})}),dependencies:[i,m(r,{decorators:[function({context:[e]}){const{mountedPluginsStore:n}=t(e,M).output,{ErrorBoundary:i}=t(e,r).config,l=e._onError.bind(e),[{plugins:u},c]=p(()=>n.peek());d(()=>o(()=>c(n.value)),[n]);const a=[];for(const{key:e,element:n,domNode:t}of u.values()){if(!n)continue;const o=h(i,{onError:l,children:h(f,{fallback:null,children:n})},e);a.push(t?g(o,t,e):o)}return a.length>0?h(P,{children:a}):null}]})],name:"@lexical/react/ReactPluginHost",register(n,t,o){let i;const{mountedPluginsStore:u}=o.getOutput(),{Component:c}=o.getDependency(r).output;return l(()=>{i&&i.unmount(),e(()=>{u.value.plugins.clear()})},n.registerCommand(O,n=>(e(()=>{const{plugins:e}=u.value;e.set(n.key,n),u.value={plugins:e}}),!1),a),n.registerCommand(E,e=>(void 0!==i&&function(e,...n){const t=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of n)o.append("v",e);throw t.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(322),i=e.root,i.render(h(c,{contentEditable:null})),!0),s))}});export{O as REACT_PLUGIN_HOST_MOUNT_PLUGIN_COMMAND,E as REACT_PLUGIN_HOST_MOUNT_ROOT_COMMAND,M as ReactPluginHostExtension,v as mountReactExtensionComponent,R as mountReactPluginComponent,C as mountReactPluginElement,_ as mountReactPluginHost};
@@ -183,9 +183,6 @@ function useCanShowPlaceholder(editor) {
183
183
  function useRichTextSetup(editor) {
184
184
  useLayoutEffectImpl(() => {
185
185
  return utils.mergeRegister(richText.registerRichText(editor), dragon.registerDragonSupport(editor));
186
-
187
- // We only do this for init
188
- // eslint-disable-next-line react-hooks/exhaustive-deps
189
186
  }, [editor]);
190
187
  }
191
188
 
@@ -181,9 +181,6 @@ function useCanShowPlaceholder(editor) {
181
181
  function useRichTextSetup(editor) {
182
182
  useLayoutEffectImpl(() => {
183
183
  return mergeRegister(registerRichText(editor), registerDragonSupport(editor));
184
-
185
- // We only do this for init
186
- // eslint-disable-next-line react-hooks/exhaustive-deps
187
184
  }, [editor]);
188
185
  }
189
186
 
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
  type Props = Readonly<{
9
- onReposition?: (node: Array<HTMLElement>) => void;
9
+ onReposition?: (node: readonly HTMLElement[]) => void;
10
10
  }>;
11
11
  export declare function SelectionAlwaysOnDisplay({ onReposition }: Props): null;
12
12
  export {};
@@ -14,7 +14,7 @@ declare export function registerTabIndentation(
14
14
  maxIndent?: number,
15
15
  ): () => void;
16
16
 
17
- type Props = $ReadOnly<{
17
+ type Props = Readonly<{
18
18
  maxIndent?: number,
19
19
  }>;
20
20
 
@@ -30,12 +30,6 @@ export interface TablePluginProps {
30
30
  * @experimental Nested tables are not officially supported.
31
31
  */
32
32
  hasNestedTables?: boolean;
33
- /**
34
- * When `true` (default `false`), nested tables will be resized to fit the width of the parent table cell.
35
- *
36
- * @experimental Nested tables are not officially supported.
37
- */
38
- hasFitNestedTables?: boolean;
39
33
  }
40
34
  /**
41
35
  * A plugin to enable all of the features of Lexical's TableNode.
@@ -43,4 +37,4 @@ export interface TablePluginProps {
43
37
  * @param props - See type for documentation
44
38
  * @returns An element to render in your LexicalComposer
45
39
  */
46
- export declare function TablePlugin({ hasCellMerge, hasCellBackgroundColor, hasTabHandler, hasHorizontalScroll, hasNestedTables, hasFitNestedTables, }: TablePluginProps): JSX.Element | null;
40
+ export declare function TablePlugin({ hasCellMerge, hasCellBackgroundColor, hasTabHandler, hasHorizontalScroll, hasNestedTables, }: TablePluginProps): JSX.Element | null;
@@ -32,8 +32,7 @@ function TablePlugin({
32
32
  hasCellBackgroundColor = true,
33
33
  hasTabHandler = true,
34
34
  hasHorizontalScroll = false,
35
- hasNestedTables = false,
36
- hasFitNestedTables = false
35
+ hasNestedTables = false
37
36
  }) {
38
37
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
39
38
  react.useEffect(() => {
@@ -46,11 +45,9 @@ function TablePlugin({
46
45
  }
47
46
  }, [editor, hasHorizontalScroll]);
48
47
  const hasNestedTablesSignal = usePropSignal(hasNestedTables);
49
- const hasFitNestedTablesSignal = usePropSignal(hasFitNestedTables);
50
48
  react.useEffect(() => table.registerTablePlugin(editor, {
51
- hasFitNestedTables: hasFitNestedTablesSignal,
52
49
  hasNestedTables: hasNestedTablesSignal
53
- }), [editor, hasNestedTablesSignal, hasFitNestedTablesSignal]);
50
+ }), [editor, hasNestedTablesSignal]);
54
51
  react.useEffect(() => table.registerTableSelectionObserver(editor, hasTabHandler), [editor, hasTabHandler]);
55
52
 
56
53
  // Unmerge cells when the feature isn't enabled
@@ -30,8 +30,7 @@ function TablePlugin({
30
30
  hasCellBackgroundColor = true,
31
31
  hasTabHandler = true,
32
32
  hasHorizontalScroll = false,
33
- hasNestedTables = false,
34
- hasFitNestedTables = false
33
+ hasNestedTables = false
35
34
  }) {
36
35
  const [editor] = useLexicalComposerContext();
37
36
  useEffect(() => {
@@ -44,11 +43,9 @@ function TablePlugin({
44
43
  }
45
44
  }, [editor, hasHorizontalScroll]);
46
45
  const hasNestedTablesSignal = usePropSignal(hasNestedTables);
47
- const hasFitNestedTablesSignal = usePropSignal(hasFitNestedTables);
48
46
  useEffect(() => registerTablePlugin(editor, {
49
- hasFitNestedTables: hasFitNestedTablesSignal,
50
47
  hasNestedTables: hasNestedTablesSignal
51
- }), [editor, hasNestedTablesSignal, hasFitNestedTablesSignal]);
48
+ }), [editor, hasNestedTablesSignal]);
52
49
  useEffect(() => registerTableSelectionObserver(editor, hasTabHandler), [editor, hasTabHandler]);
53
50
 
54
51
  // Unmerge cells when the feature isn't enabled
@@ -7,7 +7,7 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- type Props = $ReadOnly<{
10
+ type Props = Readonly<{
11
11
  hasCellMerge?: boolean,
12
12
  hasCellBackgroundColor?: boolean,
13
13
  hasTabHandler?: boolean,
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/extension"),r=require("@lexical/react/LexicalComposerContext"),l=require("@lexical/table"),s=require("react");function t(r){const[l]=s.useState(()=>e.signal(r));return l.peek()!==r&&(l.value=r),l}exports.TablePlugin=function({hasCellMerge:e=!0,hasCellBackgroundColor:a=!0,hasTabHandler:o=!0,hasHorizontalScroll:n=!1,hasNestedTables:i=!1,hasFitNestedTables:c=!1}){const[u]=r.useLexicalComposerContext();s.useEffect(()=>{l.$isScrollableTablesActive(u)!==n&&(l.setScrollableTablesActive(u,n),u.registerNodeTransform(l.TableNode,()=>{})())},[u,n]);const b=t(i),f=t(c);return s.useEffect(()=>l.registerTablePlugin(u,{hasFitNestedTables:f,hasNestedTables:b}),[u,b,f]),s.useEffect(()=>l.registerTableSelectionObserver(u,o),[u,o]),s.useEffect(()=>{if(!e)return l.registerTableCellUnmergeTransform(u)},[u,e]),s.useEffect(()=>{if(!a)return u.registerNodeTransform(l.TableCellNode,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})},[u,a,e]),null};
9
+ "use strict";var e=require("@lexical/extension"),r=require("@lexical/react/LexicalComposerContext"),l=require("@lexical/table"),s=require("react");exports.TablePlugin=function({hasCellMerge:t=!0,hasCellBackgroundColor:a=!0,hasTabHandler:o=!0,hasHorizontalScroll:n=!1,hasNestedTables:i=!1}){const[c]=r.useLexicalComposerContext();s.useEffect(()=>{l.$isScrollableTablesActive(c)!==n&&(l.setScrollableTablesActive(c,n),c.registerNodeTransform(l.TableNode,()=>{})())},[c,n]);const u=function(r){const[l]=s.useState(()=>e.signal(r));l.peek()!==r&&(l.value=r);return l}(i);return s.useEffect(()=>l.registerTablePlugin(c,{hasNestedTables:u}),[c,u]),s.useEffect(()=>l.registerTableSelectionObserver(c,o),[c,o]),s.useEffect(()=>{if(!t)return l.registerTableCellUnmergeTransform(c)},[c,t]),s.useEffect(()=>{if(!a)return c.registerNodeTransform(l.TableCellNode,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})},[c,a,t]),null};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{signal as e}from"@lexical/extension";import{useLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import{$isScrollableTablesActive as o,setScrollableTablesActive as t,TableNode as l,registerTablePlugin as a,registerTableSelectionObserver as s,registerTableCellUnmergeTransform as n,TableCellNode as i}from"@lexical/table";import{useEffect as c,useState as u}from"react";function m({hasCellMerge:e=!0,hasCellBackgroundColor:u=!0,hasTabHandler:m=!0,hasHorizontalScroll:f=!1,hasNestedTables:h=!1,hasFitNestedTables:g=!1}){const[p]=r();c(()=>{o(p)!==f&&(t(p,f),p.registerNodeTransform(l,()=>{})())},[p,f]);const x=d(h),C=d(g);return c(()=>a(p,{hasFitNestedTables:C,hasNestedTables:x}),[p,x,C]),c(()=>s(p,m),[p,m]),c(()=>{if(!e)return n(p)},[p,e]),c(()=>{if(!u)return p.registerNodeTransform(i,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})},[p,u,e]),null}function d(r){const[o]=u(()=>e(r));return o.peek()!==r&&(o.value=r),o}export{m as TablePlugin};
9
+ import{signal as e}from"@lexical/extension";import{useLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import{$isScrollableTablesActive as o,setScrollableTablesActive as l,TableNode as t,registerTablePlugin as a,registerTableSelectionObserver as n,registerTableCellUnmergeTransform as s,TableCellNode as i}from"@lexical/table";import{useEffect as c,useState as u}from"react";function m({hasCellMerge:m=!0,hasCellBackgroundColor:f=!0,hasTabHandler:d=!0,hasHorizontalScroll:g=!1,hasNestedTables:p=!1}){const[x]=r();c(()=>{o(x)!==g&&(l(x,g),x.registerNodeTransform(t,()=>{})())},[x,g]);const C=function(r){const[o]=u(()=>e(r));o.peek()!==r&&(o.value=r);return o}(p);return c(()=>a(x,{hasNestedTables:C}),[x,C]),c(()=>n(x,d),[x,d]),c(()=>{if(!m)return s(x)},[x,m]),c(()=>{if(!f)return x.registerNodeTransform(i,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})},[x,f,m]),null}export{m as TablePlugin};
@@ -26,8 +26,8 @@ export type TypeaheadMenuPluginProps<TOption extends MenuOption> = {
26
26
  onQueryChange: (matchingString: string | null) => void;
27
27
  onSelectOption: (option: TOption, textNodeContainingQuery: TextNode | null, closeMenu: () => void, matchingString: string) => void;
28
28
  options: Array<TOption>;
29
- menuRenderFn: MenuRenderFn<TOption>;
30
29
  triggerFn: TriggerFn;
30
+ menuRenderFn?: MenuRenderFn<TOption>;
31
31
  onOpen?: (resolution: MenuResolution) => void;
32
32
  onClose?: () => void;
33
33
  anchorClassName?: string;
@@ -12,6 +12,7 @@ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
12
12
  var lexical = require('lexical');
13
13
  var React = require('react');
14
14
  var utils = require('@lexical/utils');
15
+ var ReactDOM = require('react-dom');
15
16
  var jsxRuntime = require('react/jsx-runtime');
16
17
 
17
18
  /**
@@ -70,6 +71,8 @@ const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffec
70
71
  class MenuOption {
71
72
  key;
72
73
  ref;
74
+ icon;
75
+ title;
73
76
  constructor(key) {
74
77
  this.key = key;
75
78
  this.ref = {
@@ -219,13 +222,39 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
219
222
  }, [targetElement, editor, onVisibilityChange, onReposition, resolution]);
220
223
  }
221
224
  const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND$1 = lexical.createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND');
225
+ function MenuItem({
226
+ index,
227
+ isSelected,
228
+ onClick,
229
+ onMouseEnter,
230
+ option
231
+ }) {
232
+ let className = 'item';
233
+ if (isSelected) {
234
+ className += ' selected';
235
+ }
236
+ return /*#__PURE__*/jsxRuntime.jsxs("li", {
237
+ tabIndex: -1,
238
+ className: className,
239
+ ref: option.setRefElement,
240
+ role: "option",
241
+ "aria-selected": isSelected,
242
+ id: 'typeahead-item-' + index,
243
+ onMouseEnter: onMouseEnter,
244
+ onClick: onClick,
245
+ children: [option.icon, /*#__PURE__*/jsxRuntime.jsx("span", {
246
+ className: "text",
247
+ children: option.title
248
+ })]
249
+ }, option.key);
250
+ }
222
251
  function LexicalMenu({
223
252
  close,
224
253
  editor,
225
254
  anchorElementRef,
226
255
  resolution,
227
256
  options,
228
- menuRenderFn,
257
+ menuRenderFn: menuRenderFnProp,
229
258
  onSelectOption,
230
259
  shouldSplitNodeWithQuery = false,
231
260
  commandPriority = lexical.COMMAND_PRIORITY_LOW,
@@ -253,6 +282,25 @@ function LexicalMenu({
253
282
  setHighlightedIndex(index);
254
283
  }
255
284
  }, [editor]);
285
+ const defaultMenuRenderFn = React.useCallback(() => {
286
+ return anchorElementRef.current && options.length ? /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", {
287
+ className: "typeahead-popover mentions-menu",
288
+ children: /*#__PURE__*/jsxRuntime.jsx("ul", {
289
+ children: options.map((option, i) => /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
290
+ index: i,
291
+ isSelected: selectedIndex === i,
292
+ onClick: () => {
293
+ setHighlightedIndex(i);
294
+ selectOptionAndCleanUp(option);
295
+ },
296
+ onMouseEnter: () => {
297
+ setHighlightedIndex(i);
298
+ },
299
+ option: option
300
+ }, option.key))
301
+ })
302
+ }), anchorElementRef.current) : null;
303
+ }, [anchorElementRef, options, selectedIndex, selectOptionAndCleanUp, setHighlightedIndex]);
256
304
  React.useEffect(() => {
257
305
  return () => {
258
306
  const rootElem = editor.getRootElement();
@@ -354,7 +402,10 @@ function LexicalMenu({
354
402
  selectedIndex,
355
403
  setHighlightedIndex
356
404
  }), [selectOptionAndCleanUp, selectedIndex, options]);
357
- return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : '');
405
+ if (menuRenderFnProp != null) {
406
+ return menuRenderFnProp(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : '');
407
+ }
408
+ return defaultMenuRenderFn();
358
409
  }
359
410
  function setContainerDivAttributes(containerDiv, className) {
360
411
  if (className != null) {
@@ -10,7 +10,8 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
10
10
  import { createCommand, COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, $getSelection, $isRangeSelection, $isTextNode, getDOMSelection } from 'lexical';
11
11
  import React, { useLayoutEffect, useEffect, useRef, useCallback, useState, useMemo } from 'react';
12
12
  import { mergeRegister } from '@lexical/utils';
13
- import { jsx } from 'react/jsx-runtime';
13
+ import ReactDOM from 'react-dom';
14
+ import { jsx, jsxs } from 'react/jsx-runtime';
14
15
 
15
16
  /**
16
17
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -68,6 +69,8 @@ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
68
69
  class MenuOption {
69
70
  key;
70
71
  ref;
72
+ icon;
73
+ title;
71
74
  constructor(key) {
72
75
  this.key = key;
73
76
  this.ref = {
@@ -217,13 +220,39 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
217
220
  }, [targetElement, editor, onVisibilityChange, onReposition, resolution]);
218
221
  }
219
222
  const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND$1 = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND');
223
+ function MenuItem({
224
+ index,
225
+ isSelected,
226
+ onClick,
227
+ onMouseEnter,
228
+ option
229
+ }) {
230
+ let className = 'item';
231
+ if (isSelected) {
232
+ className += ' selected';
233
+ }
234
+ return /*#__PURE__*/jsxs("li", {
235
+ tabIndex: -1,
236
+ className: className,
237
+ ref: option.setRefElement,
238
+ role: "option",
239
+ "aria-selected": isSelected,
240
+ id: 'typeahead-item-' + index,
241
+ onMouseEnter: onMouseEnter,
242
+ onClick: onClick,
243
+ children: [option.icon, /*#__PURE__*/jsx("span", {
244
+ className: "text",
245
+ children: option.title
246
+ })]
247
+ }, option.key);
248
+ }
220
249
  function LexicalMenu({
221
250
  close,
222
251
  editor,
223
252
  anchorElementRef,
224
253
  resolution,
225
254
  options,
226
- menuRenderFn,
255
+ menuRenderFn: menuRenderFnProp,
227
256
  onSelectOption,
228
257
  shouldSplitNodeWithQuery = false,
229
258
  commandPriority = COMMAND_PRIORITY_LOW,
@@ -251,6 +280,25 @@ function LexicalMenu({
251
280
  setHighlightedIndex(index);
252
281
  }
253
282
  }, [editor]);
283
+ const defaultMenuRenderFn = useCallback(() => {
284
+ return anchorElementRef.current && options.length ? /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/jsx("div", {
285
+ className: "typeahead-popover mentions-menu",
286
+ children: /*#__PURE__*/jsx("ul", {
287
+ children: options.map((option, i) => /*#__PURE__*/jsx(MenuItem, {
288
+ index: i,
289
+ isSelected: selectedIndex === i,
290
+ onClick: () => {
291
+ setHighlightedIndex(i);
292
+ selectOptionAndCleanUp(option);
293
+ },
294
+ onMouseEnter: () => {
295
+ setHighlightedIndex(i);
296
+ },
297
+ option: option
298
+ }, option.key))
299
+ })
300
+ }), anchorElementRef.current) : null;
301
+ }, [anchorElementRef, options, selectedIndex, selectOptionAndCleanUp, setHighlightedIndex]);
254
302
  useEffect(() => {
255
303
  return () => {
256
304
  const rootElem = editor.getRootElement();
@@ -352,7 +400,10 @@ function LexicalMenu({
352
400
  selectedIndex,
353
401
  setHighlightedIndex
354
402
  }), [selectOptionAndCleanUp, selectedIndex, options]);
355
- return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : '');
403
+ if (menuRenderFnProp != null) {
404
+ return menuRenderFnProp(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : '');
405
+ }
406
+ return defaultMenuRenderFn();
356
407
  }
357
408
  function setContainerDivAttributes(containerDiv, className) {
358
409
  if (className != null) {
@@ -27,15 +27,11 @@ export const PUNCTUATION: string =
27
27
  declare export class MenuOption {
28
28
  key: string;
29
29
  ref: {current: HTMLElement | null};
30
+ title: string;
30
31
  constructor(key: string): void;
31
32
  setRefElement(element: HTMLElement | null): void;
32
33
  }
33
34
 
34
- declare export var SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{
35
- index: number,
36
- option: MenuOption,
37
- }>;
38
-
39
35
  export type MenuRenderFn<TOption> = (
40
36
  anchorElementRef: {current: HTMLElement | null},
41
37
  itemProps: {
@@ -45,7 +41,12 @@ export type MenuRenderFn<TOption> = (
45
41
  options: Array<TOption>,
46
42
  },
47
43
  matchingString: string,
48
- ) => React.Portal | React.MixedElement | null;
44
+ ) => React$Portal | React.MixedElement | null;
45
+
46
+ declare export var SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{
47
+ index: number,
48
+ option: MenuOption,
49
+ }>;
49
50
 
50
51
  declare export function getScrollParent(
51
52
  element: HTMLElement,
@@ -66,8 +67,8 @@ export type TypeaheadMenuPluginProps<TOption> = {
66
67
  matchingString: string,
67
68
  ) => void,
68
69
  options: Array<TOption>,
69
- menuRenderFn: MenuRenderFn<TOption>,
70
70
  triggerFn: TriggerFn,
71
+ menuRenderFn?: MenuRenderFn<TOption>,
71
72
  onOpen?: (resolution: MenuResolution) => void,
72
73
  onClose?: () => void,
73
74
  anchorClassName?: string,
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),o=require("@lexical/utils"),r=require("react/jsx-runtime");const l="startTransition";const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,s=i?n.useLayoutEffect:n.useEffect;const u=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function c(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function a(t,o,r,l){const[i]=e.useLexicalComposerContext();n.useEffect(()=>{if(null!=o&&null!=t){const e=i.getRootElement(),t=null!=e?function(e){let t=getComputedStyle(e);const n="absolute"===t.position,o=/(auto|scroll)/;if("fixed"===t.position)return document.body;for(let r=e;r=r.parentElement;)if(t=getComputedStyle(r),(!n||"static"!==t.position)&&o.test(t.overflow+t.overflowY+t.overflowX))return r;return document.body}(e):document.body;let n=!1,s=c(o,t);const u=function(){n||(window.requestAnimationFrame(function(){r(),n=!1}),n=!0);const e=c(o,t);e!==s&&(s=e,null!=l&&l(e))},a=new ResizeObserver(r);return window.addEventListener("resize",r),document.addEventListener("scroll",u,{capture:!0,passive:!0}),a.observe(o),()=>{a.unobserve(o),window.removeEventListener("resize",r),document.removeEventListener("scroll",u,!0)}}},[o,i,l,r,t])}const d=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function f({close:e,editor:r,anchorElementRef:l,resolution:i,options:c,menuRenderFn:a,onSelectOption:f,shouldSplitNodeWithQuery:m=!1,commandPriority:p=t.COMMAND_PRIORITY_LOW,preselectFirstItem:g=!0}){const[h,C]=n.useState(null),E=null!==h?Math.min(c.length-1,h):null,x=i.match&&i.match.matchingString;n.useEffect(()=>{g&&C(0)},[x,g]);const y=n.useCallback(n=>{r.update(()=>{const o=null!=i.match&&m?function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return null;const o=n.anchor;if("text"!==o.type)return null;const r=o.getNode();if(!r.isSimpleText())return null;const l=o.offset,i=r.getTextContent().slice(0,l),s=e.replaceableString.length,u=l-function(e,t,n){let o=n;for(let n=o;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(o=n);return o}(i,e.matchingString,s);if(u<0)return null;let c;return 0===u?[c]=r.splitText(l):[,c]=r.splitText(u,l),c}(i.match):null;f(n,o,e,i.match?i.match.matchingString:"")})},[r,m,i.match,f,e]),O=n.useCallback(e=>{const t=r.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),C(e))},[r]);n.useEffect(()=>()=>{const e=r.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[r]),s(()=>{null===c?C(null):null===E&&g&&O(0)},[c,E,O,g]),n.useEffect(()=>o.mergeRegister(r.registerCommand(d,({option:e})=>!(!e.ref||null==e.ref.current)&&(u(e.ref.current),!0),p)),[r,O,p]),n.useEffect(()=>o.mergeRegister(r.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>{const t=e;if(null!==c&&c.length){const e=null===E?0:E!==c.length-1?E+1:0;O(e);const n=c[e];if(!n)return O(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&r.dispatchCommand(d,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0},p),r.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>{const t=e;if(null!==c&&c.length){const e=null===E?c.length-1:0!==E?E-1:c.length-1;O(e);const n=c[e];if(!n)return O(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&u(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0},p),r.registerCommand(t.KEY_ESCAPE_COMMAND,t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0},p),r.registerCommand(t.KEY_TAB_COMMAND,e=>{const t=e;return null!==c&&null!==E&&null!=c[E]&&(t.preventDefault(),t.stopImmediatePropagation(),y(c[E]),!0)},p),r.registerCommand(t.KEY_ENTER_COMMAND,e=>null!==c&&null!==E&&null!=c[E]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),y(c[E]),!0),p)),[y,e,r,c,E,O,p]);return a(l,n.useMemo(()=>({options:c,selectOptionAndCleanUp:y,selectedIndex:E,setHighlightedIndex:C}),[y,E,c]),i.match?i.match.matchingString:"")}function m(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}const p="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";const g=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");exports.LexicalTypeaheadMenuPlugin=function({options:o,onQueryChange:s,onSelectOption:u,onOpen:c,onClose:d,menuRenderFn:p,triggerFn:g,anchorClassName:h,commandPriority:C=t.COMMAND_PRIORITY_LOW,parent:E,preselectFirstItem:x=!0,ignoreEntityBoundary:y=!1}){const[O]=e.useLexicalComposerContext(),[b,w]=n.useState(null),R=function(t,o,r,l=(i?document.body:void 0),s=!0){const[u]=e.useLexicalComposerContext(),c=i?document.createElement("div"):null,d=n.useRef(c),f=n.useCallback(()=>{if(null===d.current||void 0===l)return;d.current.style.top=d.current.style.bottom;const e=u.getRootElement(),n=d.current,o=n.firstChild;if(null!==e&&null!==t){const{left:i,top:u,width:c,height:a}=t.getRect(),f=d.current.offsetHeight;if(n.style.top=`${u+f+3+(s?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==o){o.style.top=`${u}`;const t=o.getBoundingClientRect(),r=t.height,l=t.width,c=e.getBoundingClientRect();i+l>c.right&&(n.style.left=`${c.right-l+window.pageXOffset}px`),(u+r>window.innerHeight||u+r>c.bottom)&&u-c.top>r+a&&(n.style.top=`${u-r-a+(s?window.pageYOffset:0)}px`)}n.isConnected||(m(n,r),l.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}},[u,t,s,r,l]);n.useEffect(()=>{const e=u.getRootElement();return null!==t&&f(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=d.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}},[u,f,t]);const p=n.useCallback(e=>{null!==t&&(e||o(null))},[t,o]);return a(t,d.current,f,p),null!=c&&c===d.current&&(m(c,r),null!=l&&l.append(c)),d}(b,w,h,E),v=n.useCallback(()=>{w(null),null!=d&&null!==b&&d()},[d,b]),S=n.useCallback(e=>{w(e),null!=c&&null===b&&c(e)},[c,b]);return n.useEffect(()=>{const e=O.registerUpdateListener(()=>{O.getEditorState().read(()=>{if(!O.isEditable())return void v();if(O.isComposing())return;const e=O._window||window,o=e.document.createRange(),r=t.$getSelection(),i=function(e){let n=null;return e.getEditorState().read(()=>{const e=t.$getSelection();t.$isRangeSelection(e)&&(n=function(e){const t=e.anchor;if("text"!==t.type)return null;const n=t.getNode();if(!n.isSimpleText())return null;const o=t.offset;return n.getTextContent().slice(0,o)}(e))}),n}(O);if(!t.$isRangeSelection(r)||!r.isCollapsed()||null===i||null===o)return void v();const u=g(i,O);if(s(u?u.matchingString:null),null!==u&&(y||!function(e,n){return 0===n&&e.getEditorState().read(()=>{const e=t.$getSelection();if(t.$isRangeSelection(e)){const n=e.anchor.getNode().getPreviousSibling();return t.$isTextNode(n)&&n.isTextEntity()}return!1})}(O,u.leadOffset))){const r=function(e,n,o){const r=t.getDOMSelection(o);if(null===r||!r.isCollapsed)return!1;const l=r.anchorNode,i=e,s=r.anchorOffset;if(null==l||null==s)return!1;try{n.setStart(l,i),n.setEnd(l,s)}catch(e){return!1}return!0}(u.leadOffset,o,e);if(null!==r)return c=()=>S({getRect:()=>o.getBoundingClientRect(),match:u}),void(l in n?n[l](c):c())}var c;v()})});return()=>{e()}},[O,g,s,b,v,S,y]),n.useEffect(()=>O.registerEditableListener(e=>{e||v()}),[O,v]),null===b||null===O||null===R.current?null:r.jsx(f,{close:v,resolution:b,editor:O,anchorElementRef:R,options:o,menuRenderFn:p,shouldSplitNodeWithQuery:!0,onSelectOption:u,commandPriority:C,preselectFirstItem:x})},exports.MenuOption=class{key;ref;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}},exports.PUNCTUATION=p,exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=g,exports.getScrollParent=function(e,t){let n=getComputedStyle(e);const o="absolute"===n.position,r=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body},exports.useBasicTypeaheadTriggerMatch=function(e,{minLength:t=1,maxLength:o=75,punctuation:r=p,allowWhitespace:l=!1}){return n.useCallback(n=>{const i=new RegExp("(^|\\s|\\()(["+e+"]((?:"+("[^"+e+r+(l?"":"\\s")+"]")+"){0,"+o+"}))$").exec(n);if(null!==i){const e=i[1],n=i[3];if(n.length>=t)return{leadOffset:i.index+e.length,matchingString:n,replaceableString:i[2]}}return null},[l,e,r,o,t])},exports.useDynamicPositioning=a;
9
+ "use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),n=require("react"),o=require("@lexical/utils"),l=require("react-dom"),r=require("react/jsx-runtime");const i="startTransition";const s="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,u=s?n.useLayoutEffect:n.useEffect;const c=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function a(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function d(t,o,l,r){const[i]=e.useLexicalComposerContext();n.useEffect(()=>{if(null!=o&&null!=t){const e=i.getRootElement(),t=null!=e?function(e){let t=getComputedStyle(e);const n="absolute"===t.position,o=/(auto|scroll)/;if("fixed"===t.position)return document.body;for(let l=e;l=l.parentElement;)if(t=getComputedStyle(l),(!n||"static"!==t.position)&&o.test(t.overflow+t.overflowY+t.overflowX))return l;return document.body}(e):document.body;let n=!1,s=a(o,t);const u=function(){n||(window.requestAnimationFrame(function(){l(),n=!1}),n=!0);const e=a(o,t);e!==s&&(s=e,null!=r&&r(e))},c=new ResizeObserver(l);return window.addEventListener("resize",l),document.addEventListener("scroll",u,{capture:!0,passive:!0}),c.observe(o),()=>{c.unobserve(o),window.removeEventListener("resize",l),document.removeEventListener("scroll",u,!0)}}},[o,i,r,l,t])}const m=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function f({index:e,isSelected:t,onClick:n,onMouseEnter:o,option:l}){let i="item";return t&&(i+=" selected"),r.jsxs("li",{tabIndex:-1,className:i,ref:l.setRefElement,role:"option","aria-selected":t,id:"typeahead-item-"+e,onMouseEnter:o,onClick:n,children:[l.icon,r.jsx("span",{className:"text",children:l.title})]},l.key)}function p({close:e,editor:i,anchorElementRef:s,resolution:a,options:d,menuRenderFn:p,onSelectOption:g,shouldSplitNodeWithQuery:h=!1,commandPriority:C=t.COMMAND_PRIORITY_LOW,preselectFirstItem:E=!0}){const[x,y]=n.useState(null),O=null!==x?Math.min(d.length-1,x):null,b=a.match&&a.match.matchingString;n.useEffect(()=>{E&&y(0)},[b,E]);const R=n.useCallback(n=>{i.update(()=>{const o=null!=a.match&&h?function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!n.isCollapsed())return null;const o=n.anchor;if("text"!==o.type)return null;const l=o.getNode();if(!l.isSimpleText())return null;const r=o.offset,i=l.getTextContent().slice(0,r),s=e.replaceableString.length,u=r-function(e,t,n){let o=n;for(let n=o;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(o=n);return o}(i,e.matchingString,s);if(u<0)return null;let c;return 0===u?[c]=l.splitText(r):[,c]=l.splitText(u,r),c}(a.match):null;g(n,o,e,a.match?a.match.matchingString:"")})},[i,h,a.match,g,e]),w=n.useCallback(e=>{const t=i.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),y(e))},[i]),v=n.useCallback(()=>s.current&&d.length?l.createPortal(r.jsx("div",{className:"typeahead-popover mentions-menu",children:r.jsx("ul",{children:d.map((e,t)=>r.jsx(f,{index:t,isSelected:O===t,onClick:()=>{y(t),R(e)},onMouseEnter:()=>{y(t)},option:e},e.key))})}),s.current):null,[s,d,O,R,y]);n.useEffect(()=>()=>{const e=i.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[i]),u(()=>{null===d?y(null):null===O&&E&&w(0)},[d,O,w,E]),n.useEffect(()=>o.mergeRegister(i.registerCommand(m,({option:e})=>!(!e.ref||null==e.ref.current)&&(c(e.ref.current),!0),C)),[i,w,C]),n.useEffect(()=>o.mergeRegister(i.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>{const t=e;if(null!==d&&d.length){const e=null===O?0:O!==d.length-1?O+1:0;w(e);const n=d[e];if(!n)return w(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&i.dispatchCommand(m,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0},C),i.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>{const t=e;if(null!==d&&d.length){const e=null===O?d.length-1:0!==O?O-1:d.length-1;w(e);const n=d[e];if(!n)return w(-1),t.preventDefault(),t.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&c(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0},C),i.registerCommand(t.KEY_ESCAPE_COMMAND,t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0},C),i.registerCommand(t.KEY_TAB_COMMAND,e=>{const t=e;return null!==d&&null!==O&&null!=d[O]&&(t.preventDefault(),t.stopImmediatePropagation(),R(d[O]),!0)},C),i.registerCommand(t.KEY_ENTER_COMMAND,e=>null!==d&&null!==O&&null!=d[O]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),R(d[O]),!0),C)),[R,e,i,d,O,w,C]);const S=n.useMemo(()=>({options:d,selectOptionAndCleanUp:R,selectedIndex:O,setHighlightedIndex:y}),[R,O,d]);return null!=p?p(s,S,a.match?a.match.matchingString:""):v()}function g(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}const h="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";const C=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");exports.LexicalTypeaheadMenuPlugin=function({options:o,onQueryChange:l,onSelectOption:u,onOpen:c,onClose:a,menuRenderFn:m,triggerFn:f,anchorClassName:h,commandPriority:C=t.COMMAND_PRIORITY_LOW,parent:E,preselectFirstItem:x=!0,ignoreEntityBoundary:y=!1}){const[O]=e.useLexicalComposerContext(),[b,R]=n.useState(null),w=function(t,o,l,r=(s?document.body:void 0),i=!0){const[u]=e.useLexicalComposerContext(),c=s?document.createElement("div"):null,a=n.useRef(c),m=n.useCallback(()=>{if(null===a.current||void 0===r)return;a.current.style.top=a.current.style.bottom;const e=u.getRootElement(),n=a.current,o=n.firstChild;if(null!==e&&null!==t){const{left:s,top:u,width:c,height:d}=t.getRect(),m=a.current.offsetHeight;if(n.style.top=`${u+m+3+(i?window.pageYOffset:0)}px`,n.style.left=`${s+window.pageXOffset}px`,n.style.height=`${d}px`,n.style.width=`${c}px`,null!==o){o.style.top=`${u}`;const t=o.getBoundingClientRect(),l=t.height,r=t.width,c=e.getBoundingClientRect();s+r>c.right&&(n.style.left=`${c.right-r+window.pageXOffset}px`),(u+l>window.innerHeight||u+l>c.bottom)&&u-c.top>l+d&&(n.style.top=`${u-l-d+(i?window.pageYOffset:0)}px`)}n.isConnected||(g(n,l),r.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}},[u,t,i,l,r]);n.useEffect(()=>{const e=u.getRootElement();return null!==t&&m(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=a.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}},[u,m,t]);const f=n.useCallback(e=>{null!==t&&(e||o(null))},[t,o]);return d(t,a.current,m,f),null!=c&&c===a.current&&(g(c,l),null!=r&&r.append(c)),a}(b,R,h,E),v=n.useCallback(()=>{R(null),null!=a&&null!==b&&a()},[a,b]),S=n.useCallback(e=>{R(e),null!=c&&null===b&&c(e)},[c,b]);return n.useEffect(()=>{const e=O.registerUpdateListener(()=>{O.getEditorState().read(()=>{if(!O.isEditable())return void v();if(O.isComposing())return;const e=O._window||window,o=e.document.createRange(),r=t.$getSelection(),s=function(e){let n=null;return e.getEditorState().read(()=>{const e=t.$getSelection();t.$isRangeSelection(e)&&(n=function(e){const t=e.anchor;if("text"!==t.type)return null;const n=t.getNode();if(!n.isSimpleText())return null;const o=t.offset;return n.getTextContent().slice(0,o)}(e))}),n}(O);if(!t.$isRangeSelection(r)||!r.isCollapsed()||null===s||null===o)return void v();const u=f(s,O);if(l(u?u.matchingString:null),null!==u&&(y||!function(e,n){return 0===n&&e.getEditorState().read(()=>{const e=t.$getSelection();if(t.$isRangeSelection(e)){const n=e.anchor.getNode().getPreviousSibling();return t.$isTextNode(n)&&n.isTextEntity()}return!1})}(O,u.leadOffset))){const l=function(e,n,o){const l=t.getDOMSelection(o);if(null===l||!l.isCollapsed)return!1;const r=l.anchorNode,i=e,s=l.anchorOffset;if(null==r||null==s)return!1;try{n.setStart(r,i),n.setEnd(r,s)}catch(e){return!1}return!0}(u.leadOffset,o,e);if(null!==l)return c=()=>S({getRect:()=>o.getBoundingClientRect(),match:u}),void(i in n?n[i](c):c())}var c;v()})});return()=>{e()}},[O,f,l,b,v,S,y]),n.useEffect(()=>O.registerEditableListener(e=>{e||v()}),[O,v]),null===b||null===O||null===w.current?null:r.jsx(p,{close:v,resolution:b,editor:O,anchorElementRef:w,options:o,menuRenderFn:m,shouldSplitNodeWithQuery:!0,onSelectOption:u,commandPriority:C,preselectFirstItem:x})},exports.MenuOption=class{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}},exports.PUNCTUATION=h,exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=C,exports.getScrollParent=function(e,t){let n=getComputedStyle(e);const o="absolute"===n.position,l=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body},exports.useBasicTypeaheadTriggerMatch=function(e,{minLength:t=1,maxLength:o=75,punctuation:l=h,allowWhitespace:r=!1}){return n.useCallback(n=>{const i=new RegExp("(^|\\s|\\()(["+e+"]((?:"+("[^"+e+l+(r?"":"\\s")+"]")+"){0,"+o+"}))$").exec(n);if(null!==i){const e=i[1],n=i[3];if(n.length>=t)return{leadOffset:i.index+e.length,matchingString:n,replaceableString:i[2]}}return null},[r,e,l,o,t])},exports.useDynamicPositioning=d;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,COMMAND_PRIORITY_LOW as n,KEY_ARROW_DOWN_COMMAND as o,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as l,KEY_TAB_COMMAND as i,KEY_ENTER_COMMAND as u,$getSelection as s,$isRangeSelection as c,$isTextNode as a,getDOMSelection as d}from"lexical";import m,{useLayoutEffect as f,useEffect as p,useRef as g,useCallback as h,useState as w,useMemo as y}from"react";import{mergeRegister as v}from"@lexical/utils";import{jsx as b}from"react/jsx-runtime";const C="startTransition";const E="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,x=E?f:p;class R{key;ref;constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const S=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function O(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function I(e,n,o,r){const[l]=t();p(()=>{if(null!=n&&null!=e){const t=l.getRootElement(),e=null!=t?function(t){let e=getComputedStyle(t);const n="absolute"===e.position,o=/(auto|scroll)/;if("fixed"===e.position)return document.body;for(let r=t;r=r.parentElement;)if(e=getComputedStyle(r),(!n||"static"!==e.position)&&o.test(e.overflow+e.overflowY+e.overflowX))return r;return document.body}(t):document.body;let i=!1,u=O(n,e);const s=function(){i||(window.requestAnimationFrame(function(){o(),i=!1}),i=!0);const t=O(n,e);t!==u&&(u=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}},[n,l,r,o,e])}const A=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function P({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:f,onSelectOption:g,shouldSplitNodeWithQuery:b=!1,commandPriority:C=n,preselectFirstItem:E=!0}){const[R,O]=w(null),I=null!==R?Math.min(m.length-1,R):null,P=d.match&&d.match.matchingString;p(()=>{E&&O(0)},[P,E]);const T=h(n=>{e.update(()=>{const e=null!=d.match&&b?function(t){const e=s();if(!c(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const r=n.offset,l=o.getTextContent().slice(0,r),i=t.replaceableString.length,u=r-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(l,t.matchingString,i);if(u<0)return null;let a;return 0===u?[a]=o.splitText(r):[,a]=o.splitText(u,r),a}(d.match):null;g(n,e,t,d.match?d.match.matchingString:"")})},[e,b,d.match,g,t]),N=h(t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))},[e]);p(()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")},[e]),x(()=>{null===m?O(null):null===I&&E&&N(0)},[m,I,N,E]),p(()=>v(e.registerCommand(A,({option:t})=>!(!t.ref||null==t.ref.current)&&(S(t.ref.current),!0),C)),[e,N,C]),p(()=>v(e.registerCommand(o,t=>{const n=t;if(null!==m&&m.length){const t=null===I?0:I!==m.length-1?I+1:0;N(t);const o=m[t];if(!o)return N(-1),n.preventDefault(),n.stopImmediatePropagation(),!0;o.ref&&o.ref.current&&e.dispatchCommand(A,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0},C),e.registerCommand(r,t=>{const e=t;if(null!==m&&m.length){const t=null===I?m.length-1:0!==I?I-1:m.length-1;N(t);const n=m[t];if(!n)return N(-1),e.preventDefault(),e.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&S(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0},C),e.registerCommand(l,e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0},C),e.registerCommand(i,t=>{const e=t;return null!==m&&null!==I&&null!=m[I]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[I]),!0)},C),e.registerCommand(u,t=>null!==m&&null!==I&&null!=m[I]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[I]),!0),C)),[T,t,e,m,I,N,C]);return f(a,y(()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:I,setHighlightedIndex:O}),[T,I,m]),d.match?d.match.matchingString:"")}function T(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}const N="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function L(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=e?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}const _=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function D(t,{minLength:e=1,maxLength:n=75,punctuation:o=N,allowWhitespace:r=!1}){return h(l=>{const i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+o+(r?"":"\\s")+"]")+"){0,"+n+"}))$").exec(l);if(null!==i){const t=i[1],n=i[3];if(n.length>=e)return{leadOffset:i.index+t.length,matchingString:n,replaceableString:i[2]}}return null},[r,t,o,n,e])}function $({options:e,onQueryChange:o,onSelectOption:r,onOpen:l,onClose:i,menuRenderFn:u,triggerFn:f,anchorClassName:y,commandPriority:v=n,parent:x,preselectFirstItem:R=!0,ignoreEntityBoundary:S=!1}){const[O]=t(),[A,N]=w(null),L=function(e,n,o,r=(E?document.body:void 0),l=!0){const[i]=t(),u=E?document.createElement("div"):null,s=g(u),c=h(()=>{if(null===s.current||void 0===r)return;s.current.style.top=s.current.style.bottom;const t=i.getRootElement(),n=s.current,u=n.firstChild;if(null!==t&&null!==e){const{left:i,top:c,width:a,height:d}=e.getRect(),m=s.current.offsetHeight;if(n.style.top=`${c+m+3+(l?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${d}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,r=e.width,s=t.getBoundingClientRect();i+r>s.right&&(n.style.left=`${s.right-r+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>s.bottom)&&c-s.top>o+d&&(n.style.top=`${c-o-d+(l?window.pageYOffset:0)}px`)}n.isConnected||(T(n,o),r.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}},[i,e,l,o,r]);p(()=>{const t=i.getRootElement();return null!==e&&c(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=s.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}},[i,c,e]);const a=h(t=>{null!==e&&(t||n(null))},[e,n]);return I(e,s.current,c,a),null!=u&&u===s.current&&(T(u,o),null!=r&&r.append(u)),s}(A,N,y,x),_=h(()=>{N(null),null!=i&&null!==A&&i()},[i,A]),D=h(t=>{N(t),null!=l&&null===A&&l(t)},[l,A]);return p(()=>{const t=O.registerUpdateListener(()=>{O.getEditorState().read(()=>{if(!O.isEditable())return void _();if(O.isComposing())return;const t=O._window||window,e=t.document.createRange(),n=s(),r=function(t){let e=null;return t.getEditorState().read(()=>{const t=s();c(t)&&(e=function(t){const e=t.anchor;if("text"!==e.type)return null;const n=e.getNode();if(!n.isSimpleText())return null;const o=e.offset;return n.getTextContent().slice(0,o)}(t))}),e}(O);if(!c(n)||!n.isCollapsed()||null===r||null===e)return void _();const l=f(r,O);if(o(l?l.matchingString:null),null!==l&&(S||!function(t,e){return 0===e&&t.getEditorState().read(()=>{const t=s();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return a(e)&&e.isTextEntity()}return!1})}(O,l.leadOffset))){const n=function(t,e,n){const o=d(n);if(null===o||!o.isCollapsed)return!1;const r=o.anchorNode,l=t,i=o.anchorOffset;if(null==r||null==i)return!1;try{e.setStart(r,l),e.setEnd(r,i)}catch(t){return!1}return!0}(l.leadOffset,e,t);if(null!==n)return i=()=>D({getRect:()=>e.getBoundingClientRect(),match:l}),void(C in m?m[C](i):i())}var i;_()})});return()=>{t()}},[O,f,o,A,_,D,S]),p(()=>O.registerEditableListener(t=>{t||_()}),[O,_]),null===A||null===O||null===L.current?null:b(P,{close:_,resolution:A,editor:O,anchorElementRef:L,options:e,menuRenderFn:u,shouldSplitNodeWithQuery:!0,onSelectOption:r,commandPriority:v,preselectFirstItem:R})}export{$ as LexicalTypeaheadMenuPlugin,R as MenuOption,N as PUNCTUATION,_ as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,L as getScrollParent,D as useBasicTypeaheadTriggerMatch,I as useDynamicPositioning};
9
+ import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,COMMAND_PRIORITY_LOW as n,KEY_ARROW_DOWN_COMMAND as o,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as l,KEY_TAB_COMMAND as i,KEY_ENTER_COMMAND as s,$getSelection as u,$isRangeSelection as c,$isTextNode as a,getDOMSelection as d}from"lexical";import m,{useLayoutEffect as p,useEffect as f,useRef as g,useCallback as h,useState as y,useMemo as w}from"react";import{mergeRegister as v}from"@lexical/utils";import C from"react-dom";import{jsx as E,jsxs as b}from"react/jsx-runtime";const x="startTransition";const S="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,R=S?p:f;class O{key;ref;icon;title;constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const I=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function N(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function A(e,n,o,r){const[l]=t();f(()=>{if(null!=n&&null!=e){const t=l.getRootElement(),e=null!=t?function(t){let e=getComputedStyle(t);const n="absolute"===e.position,o=/(auto|scroll)/;if("fixed"===e.position)return document.body;for(let r=t;r=r.parentElement;)if(e=getComputedStyle(r),(!n||"static"!==e.position)&&o.test(e.overflow+e.overflowY+e.overflowX))return r;return document.body}(t):document.body;let i=!1,s=N(n,e);const u=function(){i||(window.requestAnimationFrame(function(){o(),i=!1}),i=!0);const t=N(n,e);t!==s&&(s=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",u,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",u,!0)}}},[n,l,r,o,e])}const P=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function T({index:t,isSelected:e,onClick:n,onMouseEnter:o,option:r}){let l="item";return e&&(l+=" selected"),b("li",{tabIndex:-1,className:l,ref:r.setRefElement,role:"option","aria-selected":e,id:"typeahead-item-"+t,onMouseEnter:o,onClick:n,children:[r.icon,E("span",{className:"text",children:r.title})]},r.key)}function L({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:p,onSelectOption:g,shouldSplitNodeWithQuery:b=!1,commandPriority:x=n,preselectFirstItem:S=!0}){const[O,N]=y(null),A=null!==O?Math.min(m.length-1,O):null,L=d.match&&d.match.matchingString;f(()=>{S&&N(0)},[L,S]);const _=h(n=>{e.update(()=>{const e=null!=d.match&&b?function(t){const e=u();if(!c(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const r=n.offset,l=o.getTextContent().slice(0,r),i=t.replaceableString.length,s=r-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(l,t.matchingString,i);if(s<0)return null;let a;return 0===s?[a]=o.splitText(r):[,a]=o.splitText(s,r),a}(d.match):null;g(n,e,t,d.match?d.match.matchingString:"")})},[e,b,d.match,g,t]),k=h(t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),N(t))},[e]),D=h(()=>a.current&&m.length?C.createPortal(E("div",{className:"typeahead-popover mentions-menu",children:E("ul",{children:m.map((t,e)=>E(T,{index:e,isSelected:A===e,onClick:()=>{N(e),_(t)},onMouseEnter:()=>{N(e)},option:t},t.key))})}),a.current):null,[a,m,A,_,N]);f(()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")},[e]),R(()=>{null===m?N(null):null===A&&S&&k(0)},[m,A,k,S]),f(()=>v(e.registerCommand(P,({option:t})=>!(!t.ref||null==t.ref.current)&&(I(t.ref.current),!0),x)),[e,k,x]),f(()=>v(e.registerCommand(o,t=>{const n=t;if(null!==m&&m.length){const t=null===A?0:A!==m.length-1?A+1:0;k(t);const o=m[t];if(!o)return k(-1),n.preventDefault(),n.stopImmediatePropagation(),!0;o.ref&&o.ref.current&&e.dispatchCommand(P,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0},x),e.registerCommand(r,t=>{const e=t;if(null!==m&&m.length){const t=null===A?m.length-1:0!==A?A-1:m.length-1;k(t);const n=m[t];if(!n)return k(-1),e.preventDefault(),e.stopImmediatePropagation(),!0;n.ref&&n.ref.current&&I(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0},x),e.registerCommand(l,e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0},x),e.registerCommand(i,t=>{const e=t;return null!==m&&null!==A&&null!=m[A]&&(e.preventDefault(),e.stopImmediatePropagation(),_(m[A]),!0)},x),e.registerCommand(s,t=>null!==m&&null!==A&&null!=m[A]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),_(m[A]),!0),x)),[_,t,e,m,A,k,x]);const $=w(()=>({options:m,selectOptionAndCleanUp:_,selectedIndex:A,setHighlightedIndex:N}),[_,A,m]);return null!=p?p(a,$,d.match?d.match.matchingString:""):D()}function _(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}const k="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function D(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=e?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}const $=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function B(t,{minLength:e=1,maxLength:n=75,punctuation:o=k,allowWhitespace:r=!1}){return h(l=>{const i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+o+(r?"":"\\s")+"]")+"){0,"+n+"}))$").exec(l);if(null!==i){const t=i[1],n=i[3];if(n.length>=e)return{leadOffset:i.index+t.length,matchingString:n,replaceableString:i[2]}}return null},[r,t,o,n,e])}function F({options:e,onQueryChange:o,onSelectOption:r,onOpen:l,onClose:i,menuRenderFn:s,triggerFn:p,anchorClassName:w,commandPriority:v=n,parent:C,preselectFirstItem:b=!0,ignoreEntityBoundary:R=!1}){const[O]=t(),[I,N]=y(null),P=function(e,n,o,r=(S?document.body:void 0),l=!0){const[i]=t(),s=S?document.createElement("div"):null,u=g(s),c=h(()=>{if(null===u.current||void 0===r)return;u.current.style.top=u.current.style.bottom;const t=i.getRootElement(),n=u.current,s=n.firstChild;if(null!==t&&null!==e){const{left:i,top:c,width:a,height:d}=e.getRect(),m=u.current.offsetHeight;if(n.style.top=`${c+m+3+(l?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${d}px`,n.style.width=`${a}px`,null!==s){s.style.top=`${c}`;const e=s.getBoundingClientRect(),o=e.height,r=e.width,u=t.getBoundingClientRect();i+r>u.right&&(n.style.left=`${u.right-r+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>u.bottom)&&c-u.top>o+d&&(n.style.top=`${c-o-d+(l?window.pageYOffset:0)}px`)}n.isConnected||(_(n,o),r.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}},[i,e,l,o,r]);f(()=>{const t=i.getRootElement();return null!==e&&c(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=u.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}},[i,c,e]);const a=h(t=>{null!==e&&(t||n(null))},[e,n]);return A(e,u.current,c,a),null!=s&&s===u.current&&(_(s,o),null!=r&&r.append(s)),u}(I,N,w,C),T=h(()=>{N(null),null!=i&&null!==I&&i()},[i,I]),k=h(t=>{N(t),null!=l&&null===I&&l(t)},[l,I]);return f(()=>{const t=O.registerUpdateListener(()=>{O.getEditorState().read(()=>{if(!O.isEditable())return void T();if(O.isComposing())return;const t=O._window||window,e=t.document.createRange(),n=u(),r=function(t){let e=null;return t.getEditorState().read(()=>{const t=u();c(t)&&(e=function(t){const e=t.anchor;if("text"!==e.type)return null;const n=e.getNode();if(!n.isSimpleText())return null;const o=e.offset;return n.getTextContent().slice(0,o)}(t))}),e}(O);if(!c(n)||!n.isCollapsed()||null===r||null===e)return void T();const l=p(r,O);if(o(l?l.matchingString:null),null!==l&&(R||!function(t,e){return 0===e&&t.getEditorState().read(()=>{const t=u();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return a(e)&&e.isTextEntity()}return!1})}(O,l.leadOffset))){const n=function(t,e,n){const o=d(n);if(null===o||!o.isCollapsed)return!1;const r=o.anchorNode,l=t,i=o.anchorOffset;if(null==r||null==i)return!1;try{e.setStart(r,l),e.setEnd(r,i)}catch(t){return!1}return!0}(l.leadOffset,e,t);if(null!==n)return i=()=>k({getRect:()=>e.getBoundingClientRect(),match:l}),void(x in m?m[x](i):i())}var i;T()})});return()=>{t()}},[O,p,o,I,T,k,R]),f(()=>O.registerEditableListener(t=>{t||T()}),[O,T]),null===I||null===O||null===P.current?null:E(L,{close:T,resolution:I,editor:O,anchorElementRef:P,options:e,menuRenderFn:s,shouldSplitNodeWithQuery:!0,onSelectOption:r,commandPriority:v,preselectFirstItem:b})}export{F as LexicalTypeaheadMenuPlugin,O as MenuOption,k as PUNCTUATION,$ as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,D as getScrollParent,B as useBasicTypeaheadTriggerMatch,A as useDynamicPositioning};
package/README.md CHANGED
@@ -13,8 +13,8 @@ npm install @depup/lexical__react
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [@lexical/react](https://www.npmjs.com/package/@lexical/react) @ 0.41.0 |
17
- | Processed | 2026-03-18 |
16
+ | Original | [@lexical/react](https://www.npmjs.com/package/@lexical/react) @ 0.43.0 |
17
+ | Processed | 2026-04-09 |
18
18
  | Smoke test | failed |
19
19
  | Deps updated | 2 |
20
20
 
package/changes.json CHANGED
@@ -9,6 +9,6 @@
9
9
  "to": "^6.1.1"
10
10
  }
11
11
  },
12
- "timestamp": "2026-03-18T22:40:58.796Z",
12
+ "timestamp": "2026-04-09T20:22:32.773Z",
13
13
  "totalUpdated": 2
14
14
  }