@payloadcms/richtext-lexical 3.0.0-beta.96 → 3.0.0-beta.98

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 (235) hide show
  1. package/dist/cell/index.d.ts.map +1 -1
  2. package/dist/cell/index.js +20 -68
  3. package/dist/cell/index.js.map +1 -1
  4. package/dist/exports/client/Field-WN5O3VIW.js +2 -0
  5. package/dist/exports/client/Field-WN5O3VIW.js.map +7 -0
  6. package/dist/exports/client/{RelationshipComponent-EZORSGUZ.js → RelationshipComponent-Z5SZ5FFT.js} +2 -2
  7. package/dist/exports/client/bundled.css +1 -1
  8. package/dist/exports/client/{chunk-TD7O23AB.js → chunk-366OGJYE.js} +2 -2
  9. package/dist/exports/client/{chunk-TD7O23AB.js.map → chunk-366OGJYE.js.map} +1 -1
  10. package/dist/exports/client/{chunk-YL453UOS.js → chunk-7UTZDNYS.js} +2 -2
  11. package/dist/exports/client/{chunk-YL453UOS.js.map → chunk-7UTZDNYS.js.map} +1 -1
  12. package/dist/exports/client/chunk-GK7ZKYHL.js +2 -0
  13. package/dist/exports/client/chunk-GK7ZKYHL.js.map +7 -0
  14. package/dist/exports/client/{chunk-UJDWBQ2K.js → chunk-GTKNWSQW.js} +2 -2
  15. package/dist/exports/client/{chunk-UJDWBQ2K.js.map → chunk-GTKNWSQW.js.map} +1 -1
  16. package/dist/exports/client/{chunk-V2LKLT2F.js → chunk-PECDZEZY.js} +3 -3
  17. package/dist/exports/client/{chunk-V2LKLT2F.js.map → chunk-PECDZEZY.js.map} +3 -3
  18. package/dist/exports/client/{chunk-OLSILJA6.js → chunk-TXEIKM77.js} +2 -2
  19. package/dist/exports/client/chunk-TXEIKM77.js.map +7 -0
  20. package/dist/exports/client/{component-LLWMZU6K.js → component-GAX6BHKZ.js} +2 -2
  21. package/dist/exports/client/{component-7RAP75FW.js → component-LHFD5Z33.js} +2 -2
  22. package/dist/exports/client/{component-7RAP75FW.js.map → component-LHFD5Z33.js.map} +1 -1
  23. package/dist/exports/client/component-UJILB3MH.js +2 -0
  24. package/dist/exports/client/component-UJILB3MH.js.map +7 -0
  25. package/dist/exports/client/{componentInline-YSHGRL2J.js → componentInline-JLMSR7BP.js} +2 -2
  26. package/dist/exports/client/index.d.ts +2 -3
  27. package/dist/exports/client/index.d.ts.map +1 -1
  28. package/dist/exports/client/index.js +12 -12
  29. package/dist/exports/client/index.js.map +4 -4
  30. package/dist/features/align/client/index.d.ts +1 -4
  31. package/dist/features/align/client/index.d.ts.map +1 -1
  32. package/dist/features/blockquote/client/index.d.ts +1 -4
  33. package/dist/features/blockquote/client/index.d.ts.map +1 -1
  34. package/dist/features/blocks/client/component/index.js.map +1 -1
  35. package/dist/features/blocks/client/index.d.ts +1 -4
  36. package/dist/features/blocks/client/index.d.ts.map +1 -1
  37. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  38. package/dist/features/blocks/server/index.js +25 -25
  39. package/dist/features/blocks/server/index.js.map +1 -1
  40. package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -1
  41. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  42. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  43. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +1 -1
  44. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
  45. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  46. package/dist/features/converters/html/converter/index.d.ts +5 -5
  47. package/dist/features/converters/html/converter/index.d.ts.map +1 -1
  48. package/dist/features/converters/html/converter/index.js.map +1 -1
  49. package/dist/features/converters/html/converter/types.d.ts +1 -1
  50. package/dist/features/converters/html/converter/types.d.ts.map +1 -1
  51. package/dist/features/converters/html/converter/types.js.map +1 -1
  52. package/dist/features/debug/testRecorder/client/index.d.ts +1 -4
  53. package/dist/features/debug/testRecorder/client/index.d.ts.map +1 -1
  54. package/dist/features/debug/treeView/client/index.d.ts +1 -4
  55. package/dist/features/debug/treeView/client/index.d.ts.map +1 -1
  56. package/dist/features/experimental_table/client/index.d.ts +1 -1
  57. package/dist/features/experimental_table/client/index.d.ts.map +1 -1
  58. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +2 -2
  59. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  60. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  61. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts +1 -1
  62. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  63. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  64. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
  65. package/dist/features/experimental_table/client/utils/debounce.js +4 -4
  66. package/dist/features/experimental_table/client/utils/debounce.js.map +1 -1
  67. package/dist/features/experimental_table/client/utils/useDebounce.js.map +1 -1
  68. package/dist/features/format/bold/feature.client.d.ts +1 -4
  69. package/dist/features/format/bold/feature.client.d.ts.map +1 -1
  70. package/dist/features/format/inlineCode/feature.client.d.ts +1 -4
  71. package/dist/features/format/inlineCode/feature.client.d.ts.map +1 -1
  72. package/dist/features/format/italic/feature.client.d.ts +1 -4
  73. package/dist/features/format/italic/feature.client.d.ts.map +1 -1
  74. package/dist/features/format/strikethrough/feature.client.d.ts +1 -4
  75. package/dist/features/format/strikethrough/feature.client.d.ts.map +1 -1
  76. package/dist/features/format/subscript/feature.client.d.ts +1 -4
  77. package/dist/features/format/subscript/feature.client.d.ts.map +1 -1
  78. package/dist/features/format/superscript/feature.client.d.ts +1 -4
  79. package/dist/features/format/superscript/feature.client.d.ts.map +1 -1
  80. package/dist/features/format/underline/feature.client.d.ts +1 -4
  81. package/dist/features/format/underline/feature.client.d.ts.map +1 -1
  82. package/dist/features/heading/client/index.d.ts +1 -4
  83. package/dist/features/heading/client/index.d.ts.map +1 -1
  84. package/dist/features/horizontalRule/client/index.d.ts +1 -4
  85. package/dist/features/horizontalRule/client/index.d.ts.map +1 -1
  86. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
  87. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +1 -1
  88. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  89. package/dist/features/indent/client/index.d.ts +1 -4
  90. package/dist/features/indent/client/index.d.ts.map +1 -1
  91. package/dist/features/link/client/index.d.ts +1 -13
  92. package/dist/features/link/client/index.d.ts.map +1 -1
  93. package/dist/features/link/client/index.js +1 -1
  94. package/dist/features/link/client/index.js.map +1 -1
  95. package/dist/features/link/client/plugins/floatingLinkEditor/index.d.ts.map +1 -1
  96. package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
  97. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  98. package/dist/features/link/nodes/LinkNode.js +1 -1
  99. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  100. package/dist/features/lists/checklist/client/index.d.ts +1 -4
  101. package/dist/features/lists/checklist/client/index.d.ts.map +1 -1
  102. package/dist/features/lists/orderedList/client/index.d.ts +1 -4
  103. package/dist/features/lists/orderedList/client/index.d.ts.map +1 -1
  104. package/dist/features/lists/unorderedList/client/index.d.ts +1 -4
  105. package/dist/features/lists/unorderedList/client/index.d.ts.map +1 -1
  106. package/dist/features/migrations/lexicalPluginToLexical/feature.client.d.ts +1 -4
  107. package/dist/features/migrations/lexicalPluginToLexical/feature.client.d.ts.map +1 -1
  108. package/dist/features/migrations/slateToLexical/feature.client.d.ts +1 -4
  109. package/dist/features/migrations/slateToLexical/feature.client.d.ts.map +1 -1
  110. package/dist/features/migrations/slateToLexical/feature.client.js +1 -3
  111. package/dist/features/migrations/slateToLexical/feature.client.js.map +1 -1
  112. package/dist/features/paragraph/client/index.d.ts +1 -4
  113. package/dist/features/paragraph/client/index.d.ts.map +1 -1
  114. package/dist/features/relationship/client/index.d.ts +2 -17
  115. package/dist/features/relationship/client/index.d.ts.map +1 -1
  116. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
  117. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  118. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  119. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -1
  120. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  121. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  122. package/dist/features/toolbars/fixed/client/Toolbar/index.js +1 -1
  123. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  124. package/dist/features/toolbars/fixed/client/index.d.ts +1 -4
  125. package/dist/features/toolbars/fixed/client/index.d.ts.map +1 -1
  126. package/dist/features/toolbars/inline/client/Toolbar/index.js +1 -1
  127. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  128. package/dist/features/toolbars/inline/client/index.d.ts +1 -4
  129. package/dist/features/toolbars/inline/client/index.d.ts.map +1 -1
  130. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts +2 -2
  131. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  132. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +1 -1
  133. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  134. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts +2 -2
  135. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  136. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +6 -6
  137. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  138. package/dist/features/typesClient.d.ts +10 -11
  139. package/dist/features/typesClient.d.ts.map +1 -1
  140. package/dist/features/typesClient.js.map +1 -1
  141. package/dist/features/typesServer.d.ts +10 -10
  142. package/dist/features/typesServer.d.ts.map +1 -1
  143. package/dist/features/typesServer.js.map +1 -1
  144. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  145. package/dist/features/upload/client/component/index.js +17 -18
  146. package/dist/features/upload/client/component/index.js.map +1 -1
  147. package/dist/features/upload/client/feature.client.d.ts +1 -4
  148. package/dist/features/upload/client/feature.client.d.ts.map +1 -1
  149. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  150. package/dist/features/upload/client/nodes/UploadNode.js +1 -1
  151. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  152. package/dist/field/Field.js +1 -1
  153. package/dist/field/Field.js.map +1 -1
  154. package/dist/field/bundled.css +1 -1
  155. package/dist/field/index.d.ts.map +1 -1
  156. package/dist/field/index.js +63 -72
  157. package/dist/field/index.js.map +1 -1
  158. package/dist/index.d.ts +3 -3
  159. package/dist/index.d.ts.map +1 -1
  160. package/dist/index.js +3 -3
  161. package/dist/index.js.map +1 -1
  162. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  163. package/dist/lexical/LexicalEditor.js +5 -5
  164. package/dist/lexical/LexicalEditor.js.map +1 -1
  165. package/dist/lexical/LexicalProvider.js +1 -1
  166. package/dist/lexical/LexicalProvider.js.map +1 -1
  167. package/dist/lexical/config/client/EditorConfigProvider.d.ts +1 -1
  168. package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  169. package/dist/lexical/config/client/EditorConfigProvider.js +1 -1
  170. package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
  171. package/dist/lexical/config/client/loader.d.ts +1 -3
  172. package/dist/lexical/config/client/loader.d.ts.map +1 -1
  173. package/dist/lexical/config/client/loader.js +7 -19
  174. package/dist/lexical/config/client/loader.js.map +1 -1
  175. package/dist/lexical/config/client/sanitize.d.ts +1 -1
  176. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  177. package/dist/lexical/config/client/sanitize.js +2 -2
  178. package/dist/lexical/config/client/sanitize.js.map +1 -1
  179. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +3 -3
  180. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  181. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +2 -2
  182. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  183. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +1 -1
  184. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  185. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  186. package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
  187. package/dist/lexical/plugins/SlashMenu/index.js +1 -1
  188. package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
  189. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  190. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  191. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
  192. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +9 -7
  193. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
  194. package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js.map +1 -1
  195. package/dist/lexical/utils/nodeFormat.d.ts +2 -2
  196. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  197. package/dist/lexical/utils/nodeFormat.js.map +1 -1
  198. package/dist/lexical/utils/rect.d.ts.map +1 -1
  199. package/dist/lexical/utils/rect.js.map +1 -1
  200. package/dist/types.d.ts +3 -4
  201. package/dist/types.d.ts.map +1 -1
  202. package/dist/types.js.map +1 -1
  203. package/dist/utilities/createClientFeature.d.ts +3 -5
  204. package/dist/utilities/createClientFeature.d.ts.map +1 -1
  205. package/dist/utilities/createClientFeature.js +1 -4
  206. package/dist/utilities/createClientFeature.js.map +1 -1
  207. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  208. package/dist/utilities/generateComponentMap.d.ts.map +1 -1
  209. package/dist/utilities/generateComponentMap.js +10 -17
  210. package/dist/utilities/generateComponentMap.js.map +1 -1
  211. package/dist/validate/index.js +1 -1
  212. package/dist/validate/index.js.map +1 -1
  213. package/dist/validate/validateNodes.d.ts +2 -2
  214. package/dist/validate/validateNodes.d.ts.map +1 -1
  215. package/dist/validate/validateNodes.js +2 -2
  216. package/dist/validate/validateNodes.js.map +1 -1
  217. package/package.json +7 -7
  218. package/dist/exports/client/Field-E27BVLS5.js +0 -2
  219. package/dist/exports/client/Field-E27BVLS5.js.map +0 -7
  220. package/dist/exports/client/chunk-OLSILJA6.js.map +0 -7
  221. package/dist/exports/client/chunk-ZH3MUMBJ.js +0 -2
  222. package/dist/exports/client/chunk-ZH3MUMBJ.js.map +0 -7
  223. package/dist/exports/client/component-2YLEVOFH.js +0 -2
  224. package/dist/exports/client/component-2YLEVOFH.js.map +0 -7
  225. package/dist/features/createClientComponent.d.ts +0 -7
  226. package/dist/features/createClientComponent.d.ts.map +0 -1
  227. package/dist/features/createClientComponent.js +0 -13
  228. package/dist/features/createClientComponent.js.map +0 -1
  229. package/dist/features/createFeaturePropComponent.d.ts +0 -6
  230. package/dist/features/createFeaturePropComponent.d.ts.map +0 -1
  231. package/dist/features/createFeaturePropComponent.js +0 -19
  232. package/dist/features/createFeaturePropComponent.js.map +0 -1
  233. /package/dist/exports/client/{RelationshipComponent-EZORSGUZ.js.map → RelationshipComponent-Z5SZ5FFT.js.map} +0 -0
  234. /package/dist/exports/client/{component-LLWMZU6K.js.map → component-GAX6BHKZ.js.map} +0 -0
  235. /package/dist/exports/client/{componentInline-YSHGRL2J.js.map → componentInline-JLMSR7BP.js.map} +0 -0
@@ -11,12 +11,12 @@ import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin
11
11
  import { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical';
12
12
  import * as React from 'react';
13
13
  import { useEffect, useState } from 'react';
14
- import { EditorPlugin } from './EditorPlugin.js';
15
14
  import { useEditorConfigContext } from './config/client/EditorConfigProvider.js';
16
- import { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js';
17
- import { SlashMenuPlugin } from './plugins/SlashMenu/index.js';
15
+ import { EditorPlugin } from './EditorPlugin.js';
18
16
  import { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js';
19
17
  import { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js';
18
+ import { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js';
19
+ import { SlashMenuPlugin } from './plugins/SlashMenu/index.js';
20
20
  import { LexicalContentEditable } from './ui/ContentEditable.js';
21
21
  export const LexicalEditor = props => {
22
22
  const $ = _c(22);
@@ -159,7 +159,6 @@ export const LexicalEditor = props => {
159
159
  className: "editor-container",
160
160
  ref: editorContainerRef,
161
161
  children: [editorConfig.features.plugins.map(_temp2), _jsx(RichTextPlugin, {
162
- ErrorBoundary: LexicalErrorBoundary,
163
162
  contentEditable: _jsx("div", {
164
163
  className: "editor-scroller",
165
164
  children: _jsx("div", {
@@ -167,7 +166,8 @@ export const LexicalEditor = props => {
167
166
  ref: onRef,
168
167
  children: _jsx(LexicalContentEditable, {})
169
168
  })
170
- })
169
+ }),
170
+ ErrorBoundary: LexicalErrorBoundary
171
171
  }), _jsx(OnChangePlugin, {
172
172
  ignoreSelectionChange: true,
173
173
  onChange: t6
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","TabIndentationPlugin","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","EditorPlugin","useEditorConfigContext","MarkdownShortcutPlugin","SlashMenuPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","onChange","editorConfigContext","editor","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","isSmallWidthViewport","setIsSmallWidthViewport","t3","t4","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","t5","features","t6","editorState","editor_0","tags","has","size","t7","_jsxs","Fragment","children","isEditable","_jsx","anchorElem","plugins","map","plugin_1","plugin","position","desktopOnly","clientProps","key","_temp","className","ref","_temp2","ErrorBoundary","contentEditable","ignoreSelectionChange","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin.js'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement>\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n ErrorBoundary={LexicalErrorBoundary}\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable />\n </div>\n </div>\n }\n />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n\n <TabIndentationPlugin />\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAIpC,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,aAAA,GAITC,KAAA;EAAA,MAAAC,CAAA,GAAAtB,EAAA;EACF;IAAAuB,YAAA;IAAAC,kBAAA;IAAAC;EAAA,IAAuDJ,KAAA;EACvD,MAAAK,mBAAA,GAA4BZ,sBAAA;EAC5B,OAAAa,MAAA,IAAiB1B,yBAAA;EAEjB,OAAA2B,kBAAA,EAAAC,qBAAA,IAAoDjB,QAAA,KAAgC;EAAA,IAAAkB,EAAA;EA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AAU;EAAA;AAAA;AA5E3E,SAAAI,OAAAS,QAAA;EAAA,IAiFUjB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBN,IAAA,CAAA7D,YAAA;MAAAqE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAnFxE,SAAAU,OAAAI,QAAA;EAAA,IAsJUlB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBN,IAAA,CAAA7D,YAAA;MAAAqE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAxJxE,SAAAW,OAAAI,QAAA;EAAA,IA6JUnB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBN,IAAA,CAAA7D,YAAA;MAAAqE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AA/JxE,SAAAY,OAAAI,QAAA;EAAA,IAqKQpB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfN,IAAA,CAAA7D,YAAA;MAAAqE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","TabIndentationPlugin","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","MarkdownShortcutPlugin","SlashMenuPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","onChange","editorConfigContext","editor","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","isSmallWidthViewport","setIsSmallWidthViewport","t3","t4","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","t5","features","t6","editorState","editor_0","tags","has","size","t7","_jsxs","Fragment","children","isEditable","_jsx","anchorElem","plugins","map","plugin_1","plugin","position","desktopOnly","clientProps","key","_temp","className","ref","_temp2","contentEditable","ignoreSelectionChange","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin.js'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement>\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n\n <TabIndentationPlugin />\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAIpC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAE7B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,aAAA,GAITC,KAAA;EAAA,MAAAC,CAAA,GAAAtB,EAAA;EACF;IAAAuB,YAAA;IAAAC,kBAAA;IAAAC;EAAA,IAAuDJ,KAAA;EACvD,MAAAK,mBAAA,GAA4Bb,sBAAA;EAC5B,OAAAc,MAAA,IAAiB1B,yBAAA;EAEjB,OAAA2B,kBAAA,EAAAC,qBAAA,IAAoDjB,QAAA,KAAgC;EAAA,IAAAkB,EAAA;EAAA,IAAAR,CAAA,QAAAS,MAAA,CAAAC,GAAA;IACtEF,EAAA,GAAAG,mBAAA;MAAA,IACRA,mBAAA,SAAwB;QAC1BJ,qBAAA,CAAsBI,mB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AG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAnFxE,SAAAS,OAAAI,QAAA;EAAA,IAsJUjB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBN,IAAA,CAAA5D,YAAA;MAAAoE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAxJxE,SAAAU,OAAAI,QAAA;EAAA,IA6JUlB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBN,IAAA,CAAA5D,YAAA;MAAAoE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AA/JxE,SAAAW,OAAAI,QAAA;EAAA,IAqKQnB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfN,IAAA,CAAA5D,YAAA;MAAAoE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
@@ -4,8 +4,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import { LexicalComposer } from '@lexical/react/LexicalComposer.js';
5
5
  import * as React from 'react';
6
6
  import { useMemo } from 'react';
7
- import { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js';
8
7
  import { EditorConfigProvider, useEditorConfigContext } from './config/client/EditorConfigProvider.js';
8
+ import { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js';
9
9
  import { getEnabledNodes } from './nodes/index.js';
10
10
  const NestProviders = ({
11
11
  children,
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalProvider.js","names":["LexicalComposer","React","useMemo","LexicalEditor","LexicalEditorComponent","EditorConfigProvider","useEditorConfigContext","getEnabledNodes","NestProviders","children","providers","length","Component","_jsx","slice","LexicalProvider","props","editorConfig","field","onChange","path","readOnly","value","parentContext","editorContainerRef","useRef","processedValue","processed","features","hooks","load","forEach","hook","incomingEditorState","initialConfig","Error","JSON","stringify","Array","isArray","editable","editorState","undefined","namespace","lexical","nodes","onError","error","theme"],"sources":["../../src/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { EditorState, LexicalEditor, SerializedEditorState } from 'lexical'\n\nimport { LexicalComposer } from '@lexical/react/LexicalComposer.js'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport {\n EditorConfigProvider,\n useEditorConfigContext,\n} from './config/client/EditorConfigProvider.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n editorConfig: SanitizedClientEditorConfig\n field: LexicalRichTextFieldProps['field']\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n path: string\n readOnly: boolean\n value: SerializedEditorState\n}\n\nconst NestProviders = ({ children, providers }) => {\n if (!providers?.length) {\n return children\n }\n const Component = providers[0]\n if (providers.length > 1) {\n return (\n <Component>\n <NestProviders providers={providers.slice(1)}>{children}</NestProviders>\n </Component>\n )\n }\n return <Component>{children}</Component>\n}\n\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { editorConfig, field, onChange, path, readOnly, value } = props\n\n const parentContext = useEditorConfigContext()\n\n const editorContainerRef = React.useRef<HTMLDivElement>(null)\n\n const processedValue = useMemo(() => {\n let processed = value\n if (editorConfig?.features?.hooks?.load?.length) {\n editorConfig.features.hooks.load.forEach((hook) => {\n processed = hook({ incomingEditorState: processed })\n })\n }\n return processed\n }, [editorConfig, value])\n\n // useMemo for the initialConfig that depends on readOnly and processedValue\n const initialConfig = useMemo<InitialConfigType>(() => {\n if (processedValue && typeof processedValue !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(processedValue),\n )\n }\n\n if (processedValue && Array.isArray(processedValue) && !('root' in processedValue)) {\n throw new Error(\n 'You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/beta/lexical/migration#migration-via-migration-script-recommended',\n )\n }\n\n if (processedValue && 'jsonContent' in processedValue) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/beta/lexical/migration#migrating-from-payload-plugin-lexical',\n )\n }\n\n return {\n editable: readOnly !== true,\n editorState: processedValue != null ? JSON.stringify(processedValue) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: [...getEnabledNodes({ editorConfig })],\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n }, [editorConfig, processedValue, readOnly])\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={path}>\n <EditorConfigProvider\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n field={field}\n parentContext={parentContext}\n >\n <NestProviders providers={editorConfig.features.providers}>\n <LexicalEditorComponent\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n onChange={onChange}\n />\n </NestProviders>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,eAAe,QAAQ;AAChC,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AAKxB,SAASC,aAAA,IAAiBC,sBAAsB,QAAQ;AACxD,SACEC,oBAAoB,EACpBC,sBAAsB,QACjB;AACP,SAASC,eAAe,QAAQ;AAWhC,MAAMC,aAAA,GAAgBA,CAAC;EAAEC,QAAQ;EAAEC;AAAS,CAAE;EAC5C,IAAI,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ACR;IAEJ;IAEA,IAAIT,cAAA,IAAkB,iBAAiBA,cAAA,EAAgB;MACrD,MAAM,IAAIS,KAAA,CACR;IAEJ;IAEA,OAAO;MACLK,QAAA,EAAUnB,QAAA,KAAa;MACvBoB,WAAA,EAAaf,cAAA,IAAkB,OAAOU,IAAA,CAAKC,SAAS,CAACX,cAAA,IAAkBgB,SAAA;MACvEC,SAAA,EAAW1B,YAAA,CAAa2B,OAAO,CAACD,SAAS;MACzCE,KAAA,EAAO,C,GAAItC,eAAA,CAAgB;QAAEU;MAAa,GAAG;MAC7C6B,OAAA,EAAUC,KAAA;QACR,MAAMA,KAAA;MACR;MACAC,KAAA,EAAO/B,YAAA,CAAa2B,OAAO,CAACI;IAC9B;EACF,GAAG,CAAC/B,YAAA,EAAcS,cAAA,EAAgBL,QAAA,CAAS;EAE3C,IAAI,CAACa,aAAA,EAAe;IAClB,oBAAOrB,IAAA,CAAC;gBAAE;;EACZ;EAEA,oBACEA,IAAA,CAACb,eAAA;IAAgBkC,aAAA,EAAeA,aAAA;cAC9B,aAAArB,IAAA,CAACR,oBAAA;MACCY,YAAA,EAAcA,YAAA;MACdO,kBAAA,EAAoBA,kBAAA;MACpBN,KAAA,EAAOA,KAAA;MACPK,aAAA,EAAeA,aAAA;gBAEf,aAAAV,IAAA,CAACL,aAAA;QAAcE,SAAA,EAAWO,YAAA,CAAaW,QAAQ,CAAClB,SAAS;kBACvD,aAAAG,IAAA,CAACT,sBAAA;UACCa,YAAA,EAAcA,YAAA;UACdO,kBAAA,EAAoBA,kBAAA;UACpBL,QAAA,EAAUA;;;;KAXkCC,IAAA;AAiBxD","ignoreList":[]}
1
+ {"version":3,"file":"LexicalProvider.js","names":["LexicalComposer","React","useMemo","EditorConfigProvider","useEditorConfigContext","LexicalEditor","LexicalEditorComponent","getEnabledNodes","NestProviders","children","providers","length","Component","_jsx","slice","LexicalProvider","props","editorConfig","field","onChange","path","readOnly","value","parentContext","editorContainerRef","useRef","processedValue","processed","features","hooks","load","forEach","hook","incomingEditorState","initialConfig","Error","JSON","stringify","Array","isArray","editable","editorState","undefined","namespace","lexical","nodes","onError","error","theme"],"sources":["../../src/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { EditorState, LexicalEditor, SerializedEditorState } from 'lexical'\n\nimport { LexicalComposer } from '@lexical/react/LexicalComposer.js'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport {\n EditorConfigProvider,\n useEditorConfigContext,\n} from './config/client/EditorConfigProvider.js'\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n editorConfig: SanitizedClientEditorConfig\n field: LexicalRichTextFieldProps['field']\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n path: string\n readOnly: boolean\n value: SerializedEditorState\n}\n\nconst NestProviders = ({ children, providers }) => {\n if (!providers?.length) {\n return children\n }\n const Component = providers[0]\n if (providers.length > 1) {\n return (\n <Component>\n <NestProviders providers={providers.slice(1)}>{children}</NestProviders>\n </Component>\n )\n }\n return <Component>{children}</Component>\n}\n\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { editorConfig, field, onChange, path, readOnly, value } = props\n\n const parentContext = useEditorConfigContext()\n\n const editorContainerRef = React.useRef<HTMLDivElement>(null)\n\n const processedValue = useMemo(() => {\n let processed = value\n if (editorConfig?.features?.hooks?.load?.length) {\n editorConfig.features.hooks.load.forEach((hook) => {\n processed = hook({ incomingEditorState: processed })\n })\n }\n return processed\n }, [editorConfig, value])\n\n // useMemo for the initialConfig that depends on readOnly and processedValue\n const initialConfig = useMemo<InitialConfigType>(() => {\n if (processedValue && typeof processedValue !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(processedValue),\n )\n }\n\n if (processedValue && Array.isArray(processedValue) && !('root' in processedValue)) {\n throw new Error(\n 'You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/beta/lexical/migration#migration-via-migration-script-recommended',\n )\n }\n\n if (processedValue && 'jsonContent' in processedValue) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/beta/lexical/migration#migrating-from-payload-plugin-lexical',\n )\n }\n\n return {\n editable: readOnly !== true,\n editorState: processedValue != null ? JSON.stringify(processedValue) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: [...getEnabledNodes({ editorConfig })],\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n }, [editorConfig, processedValue, readOnly])\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={path}>\n <EditorConfigProvider\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n field={field}\n parentContext={parentContext}\n >\n <NestProviders providers={editorConfig.features.providers}>\n <LexicalEditorComponent\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n onChange={onChange}\n />\n </NestProviders>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,eAAe,QAAQ;AAChC,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AAKxB,SACEC,oBAAoB,EACpBC,sBAAsB,QACjB;AACP,SAASC,aAAA,IAAiBC,sBAAsB,QAAQ;AACxD,SAASC,eAAe,QAAQ;AAWhC,MAAMC,aAAA,GAAgBA,CAAC;EAAEC,QAAQ;EAAEC;AAAS,CAAE;EAC5C,IAAI,CAACA,SAAA,EAAWC,MAAA,EAAQ;IACtB,OAAOF,QAAA;EACT;EAC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;MACrD,MAAM,IAAIS,KAAA,CACR;IAEJ;IAEA,OAAO;MACLK,QAAA,EAAUnB,QAAA,KAAa;MACvBoB,WAAA,EAAaf,cAAA,IAAkB,OAAOU,IAAA,CAAKC,SAAS,CAACX,cAAA,IAAkBgB,SAAA;MACvEC,SAAA,EAAW1B,YAAA,CAAa2B,OAAO,CAACD,SAAS;MACzCE,KAAA,EAAO,C,GAAItC,eAAA,CAAgB;QAAEU;MAAa,GAAG;MAC7C6B,OAAA,EAAUC,KAAA;QACR,MAAMA,KAAA;MACR;MACAC,KAAA,EAAO/B,YAAA,CAAa2B,OAAO,CAACI;IAC9B;EACF,GAAG,CAAC/B,YAAA,EAAcS,cAAA,EAAgBL,QAAA,CAAS;EAE3C,IAAI,CAACa,aAAA,EAAe;IAClB,oBAAOrB,IAAA,CAAC;gBAAE;;EACZ;EAEA,oBACEA,IAAA,CAACb,eAAA;IAAgBkC,aAAA,EAAeA,aAAA;cAC9B,aAAArB,IAAA,CAACV,oBAAA;MACCc,YAAA,EAAcA,YAAA;MACdO,kBAAA,EAAoBA,kBAAA;MACpBN,KAAA,EAAOA,KAAA;MACPK,aAAA,EAAeA,aAAA;gBAEf,aAAAV,IAAA,CAACL,aAAA;QAAcE,SAAA,EAAWO,YAAA,CAAaW,QAAQ,CAAClB,SAAS;kBACvD,aAAAG,IAAA,CAACP,sBAAA;UACCW,YAAA,EAAcA,YAAA;UACdO,kBAAA,EAAoBA,kBAAA;UACpBL,QAAA,EAAUA;;;;KAXkCC,IAAA;AAiBxD","ignoreList":[]}
@@ -9,8 +9,8 @@ export interface EditorConfigContextType {
9
9
  editorConfig: SanitizedClientEditorConfig;
10
10
  editorContainerRef: React.RefObject<HTMLDivElement>;
11
11
  field: LexicalRichTextFieldProps['field'];
12
- focusEditor: (editorContext: EditorConfigContextType) => void;
13
12
  focusedEditor: EditorConfigContextType | null;
13
+ focusEditor: (editorContext: EditorConfigContextType) => void;
14
14
  parentEditor: EditorConfigContextType;
15
15
  registerChild: (uuid: string, editorContext: EditorConfigContextType) => void;
16
16
  unregisterChild?: (uuid: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"EditorConfigProvider.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/client/EditorConfigProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAI5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAO9D,MAAM,WAAW,uBAAuB;IAEtC,UAAU,EAAE,CAAC,aAAa,EAAE,uBAAuB,KAAK,IAAI,CAAA;IAC5D,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAA;IACtE,MAAM,EAAE,aAAa,CAAA;IACrB,YAAY,EAAE,2BAA2B,CAAA;IACzC,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IACnD,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAA;IAEzC,WAAW,EAAE,CAAC,aAAa,EAAE,uBAAuB,KAAK,IAAI,CAAA;IAC7D,aAAa,EAAE,uBAAuB,GAAG,IAAI,CAAA;IAC7C,YAAY,EAAE,uBAAuB,CAAA;IACrC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,uBAAuB,KAAK,IAAI,CAAA;IAC7E,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,IAAI,EAAE,MAAM,CAAA;CACb;AAQD,eAAO,MAAM,oBAAoB,0EAM9B;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,EAAE,2BAA2B,CAAA;IACzC,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAA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B;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,EAAE,2BAA2B,CAAA;IACzC,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IACnD,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAA;IACzC,aAAa,CAAC,EAAE,uBAAuB,CAAA;CACxC,KAAG,KAAK,CAAC,SA2ET,CAAA;AAED,eAAO,MAAM,sBAAsB,QAAO,uBAMzC,CAAA"}
@@ -37,6 +37,7 @@ export const EditorConfigProvider = ({
37
37
  editorConfig,
38
38
  editorContainerRef,
39
39
  field,
40
+ focusedEditor,
40
41
  focusEditor: editorContext_0 => {
41
42
  const editorUUID = editorContext_0.uuid;
42
43
  // Avoid recursion by checking if this editor is already focused in this cycle
@@ -55,7 +56,6 @@ export const EditorConfigProvider = ({
55
56
  });
56
57
  focusHistory.current.clear();
57
58
  },
58
- focusedEditor,
59
59
  parentEditor: parentContext,
60
60
  registerChild: (childUUID_0, childEditorContext) => {
61
61
  if (!childrenEditors.current.has(childUUID_0)) {
@@ -1 +1 @@
1
- {"version":3,"file":"EditorConfigProvider.js","names":["useLexicalComposerContext","React","createContext","useContext","useMemo","useRef","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","field","uuid","EditorConfigProvider","children","editorContainerRef","parentContext","editor","childrenEditors","Map","focusedEditor","setFocusedEditor","focusHistory","Set","editorContext","blurEditor","current","clear","focusEditor","editorUUID","has","add","forEach","childEditor","childUUID","parentEditor","registerChild","childEditorContext","newMap","set","unregisterChild","delete","_jsx","Provider","value","useEditorConfigContext","context","undefined","Error"],"sources":["../../../../src/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { LexicalEditor } from 'lexical'\nimport type { RichTextFieldClient } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport * as React from 'react'\nimport { createContext, useContext, useMemo, useRef, useState } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\n\nexport interface EditorConfigContextType {\n // Editor focus handling\n blurEditor: (editorContext: EditorConfigContextType) => void\n childrenEditors: React.RefObject<Map<string, EditorConfigContextType>>\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement>\n field: LexicalRichTextFieldProps['field']\n // Editor focus handling\n focusEditor: (editorContext: EditorConfigContextType) => void\n focusedEditor: EditorConfigContextType | null\n parentEditor: EditorConfigContextType\n registerChild: (uuid: string, editorContext: EditorConfigContextType) => void\n unregisterChild?: (uuid: string) => void\n uuid: string\n}\n\nconst Context: React.Context<EditorConfigContextType> = createContext({\n editorConfig: null,\n field: null,\n uuid: null,\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n editorContainerRef,\n field,\n parentContext,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement>\n field: LexicalRichTextFieldProps['field']\n parentContext?: EditorConfigContextType\n}): React.ReactNode => {\n const [editor] = useLexicalComposerContext()\n // State to store the UUID\n const [uuid] = useState(generateQuickGuid())\n\n const childrenEditors = useRef<Map<string, EditorConfigContextType>>(new Map())\n const [focusedEditor, setFocusedEditor] = useState<EditorConfigContextType | null>(null)\n const focusHistory = useRef<Set<string>>(new Set())\n\n const editorContext = useMemo(\n () =>\n ({\n blurEditor: (editorContext: EditorConfigContextType) => {\n //setFocusedEditor(null) // Clear focused editor\n focusHistory.current.clear() // Reset focus history when focus is lost\n },\n childrenEditors,\n editor,\n editorConfig,\n editorContainerRef,\n field,\n focusEditor: (editorContext: EditorConfigContextType) => {\n const editorUUID = editorContext.uuid\n\n // Avoid recursion by checking if this editor is already focused in this cycle\n if (focusHistory.current.has(editorUUID)) {\n return\n }\n\n // Add this editor to the history to prevent future recursions in this cycle\n focusHistory.current.add(editorUUID)\n setFocusedEditor(editorContext)\n\n // Propagate focus event to parent and children, ensuring they do not refocus this editor\n if (parentContext?.uuid) {\n parentContext.focusEditor(editorContext)\n }\n childrenEditors.current.forEach((childEditor, childUUID) => {\n childEditor.focusEditor(editorContext)\n })\n\n focusHistory.current.clear()\n },\n focusedEditor,\n parentEditor: parentContext,\n registerChild: (childUUID, childEditorContext) => {\n if (!childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.set(childUUID, childEditorContext)\n childrenEditors.current = newMap\n }\n },\n unregisterChild: (childUUID) => {\n if (childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.delete(childUUID)\n childrenEditors.current = newMap\n }\n },\n\n uuid,\n }) as EditorConfigContextType,\n [\n editor,\n childrenEditors,\n editorConfig,\n editorContainerRef,\n field,\n focusedEditor,\n parentContext,\n uuid,\n ],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): EditorConfigContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"mappings":"AAAA;;;AAKA,SAASA,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,MAAW;AACvB,SAASC,aAAa,EAAEC,UAAU,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAKrE;AACA,SAASC,kBAAA;EACP,OAAOC,IAAA,CAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG,MAAMH,IAAA,CAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG;AAC/F;AAmBA,MAAMC,OAAA,gBAAkDV,aAAA,CAAc;EACpEW,YAAA,EAAc;EACdC,KAAA,EAAO;EACPC,IAAA,EAAM;AACR;AAEA,OAAO,MAAMC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AC3C,MAAMI,MAAA,GAAS,IAAInB,GAAA,CAAID,eAAA,CAAgBQ,OAAO;QAC9CY,MAAA,CAAOC,GAAG,CAACL,WAAA,EAAWG,kBAAA;QACtBnB,eAAA,CAAgBQ,OAAO,GAAGY,MAAA;MAC5B;IACF;IACAE,eAAA,EAAkBN,WAAA;MAChB,IAAIhB,eAAA,CAAgBQ,OAAO,CAACI,GAAG,CAACI,WAAA,GAAY;QAC1C,MAAMI,QAAA,GAAS,IAAInB,GAAA,CAAID,eAAA,CAAgBQ,OAAO;QAC9CY,QAAA,CAAOG,MAAM,CAACP,WAAA;QACdhB,eAAA,CAAgBQ,OAAO,GAAGY,QAAA;MAC5B;IACF;IAEA1B;EACF,IACF,CACEK,MAAA,EACAC,eAAA,EACAR,YAAA,EACAK,kBAAA,EACAJ,KAAA,EACAS,aAAA,EACAJ,aAAA,EACAJ,IAAA,CACD;EAGH,oBAAO8B,IAAA,CAACjC,OAAA,CAAQkC,QAAQ;IAACC,KAAA,EAAOpB,eAAA;cAAgBV;;AAClD;AAEA,OAAO,MAAM+B,sBAAA,GAAyBA,CAAA;EACpC,MAAMC,OAAA,GAAU9C,UAAA,CAAWS,OAAA;EAC3B,IAAIqC,OAAA,KAAYC,SAAA,EAAW;IACzB,MAAM,IAAIC,KAAA,CAAM;EAClB;EACA,OAAOF,OAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"EditorConfigProvider.js","names":["useLexicalComposerContext","React","createContext","useContext","useMemo","useRef","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","field","uuid","EditorConfigProvider","children","editorContainerRef","parentContext","editor","childrenEditors","Map","focusedEditor","setFocusedEditor","focusHistory","Set","editorContext","blurEditor","current","clear","focusEditor","editorUUID","has","add","forEach","childEditor","childUUID","parentEditor","registerChild","childEditorContext","newMap","set","unregisterChild","delete","_jsx","Provider","value","useEditorConfigContext","context","undefined","Error"],"sources":["../../../../src/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport * as React from 'react'\nimport { createContext, useContext, useMemo, useRef, useState } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\n\nexport interface EditorConfigContextType {\n // Editor focus handling\n blurEditor: (editorContext: EditorConfigContextType) => void\n childrenEditors: React.RefObject<Map<string, EditorConfigContextType>>\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement>\n field: LexicalRichTextFieldProps['field']\n focusedEditor: EditorConfigContextType | null\n // Editor focus handling\n focusEditor: (editorContext: EditorConfigContextType) => void\n parentEditor: EditorConfigContextType\n registerChild: (uuid: string, editorContext: EditorConfigContextType) => void\n unregisterChild?: (uuid: string) => void\n uuid: string\n}\n\nconst Context: React.Context<EditorConfigContextType> = createContext({\n editorConfig: null,\n field: null,\n uuid: null,\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n editorContainerRef,\n field,\n parentContext,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement>\n field: LexicalRichTextFieldProps['field']\n parentContext?: EditorConfigContextType\n}): React.ReactNode => {\n const [editor] = useLexicalComposerContext()\n // State to store the UUID\n const [uuid] = useState(generateQuickGuid())\n\n const childrenEditors = useRef<Map<string, EditorConfigContextType>>(new Map())\n const [focusedEditor, setFocusedEditor] = useState<EditorConfigContextType | null>(null)\n const focusHistory = useRef<Set<string>>(new Set())\n\n const editorContext = useMemo(\n () =>\n ({\n blurEditor: (editorContext: EditorConfigContextType) => {\n //setFocusedEditor(null) // Clear focused editor\n focusHistory.current.clear() // Reset focus history when focus is lost\n },\n childrenEditors,\n editor,\n editorConfig,\n editorContainerRef,\n field,\n focusedEditor,\n focusEditor: (editorContext: EditorConfigContextType) => {\n const editorUUID = editorContext.uuid\n\n // Avoid recursion by checking if this editor is already focused in this cycle\n if (focusHistory.current.has(editorUUID)) {\n return\n }\n\n // Add this editor to the history to prevent future recursions in this cycle\n focusHistory.current.add(editorUUID)\n setFocusedEditor(editorContext)\n\n // Propagate focus event to parent and children, ensuring they do not refocus this editor\n if (parentContext?.uuid) {\n parentContext.focusEditor(editorContext)\n }\n childrenEditors.current.forEach((childEditor, childUUID) => {\n childEditor.focusEditor(editorContext)\n })\n\n focusHistory.current.clear()\n },\n parentEditor: parentContext,\n registerChild: (childUUID, childEditorContext) => {\n if (!childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.set(childUUID, childEditorContext)\n childrenEditors.current = newMap\n }\n },\n unregisterChild: (childUUID) => {\n if (childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.delete(childUUID)\n childrenEditors.current = newMap\n }\n },\n\n uuid,\n }) as EditorConfigContextType,\n [\n editor,\n childrenEditors,\n editorConfig,\n editorContainerRef,\n field,\n focusedEditor,\n parentContext,\n uuid,\n ],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): EditorConfigContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,MAAW;AACvB,SAASC,aAAa,EAAEC,UAAU,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAKrE;AACA,SAASC,kBAAA;EACP,OAAOC,IAAA,CAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG,MAAMH,IAAA,CAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC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A,EAAcnB,aAAA;IACdoB,aAAA,EAAeA,CAACF,WAAA,EAAWG,kBAAA;MACzB,IAAI,CAACnB,eAAA,CAAgBQ,OAAO,CAACI,GAAG,CAACI,WAAA,GAAY;QAC3C,MAAMI,MAAA,GAAS,IAAInB,GAAA,CAAID,eAAA,CAAgBQ,OAAO;QAC9CY,MAAA,CAAOC,GAAG,CAACL,WAAA,EAAWG,kBAAA;QACtBnB,eAAA,CAAgBQ,OAAO,GAAGY,MAAA;MAC5B;IACF;IACAE,eAAA,EAAkBN,WAAA;MAChB,IAAIhB,eAAA,CAAgBQ,OAAO,CAACI,GAAG,CAACI,WAAA,GAAY;QAC1C,MAAMI,QAAA,GAAS,IAAInB,GAAA,CAAID,eAAA,CAAgBQ,OAAO;QAC9CY,QAAA,CAAOG,MAAM,CAACP,WAAA;QACdhB,eAAA,CAAgBQ,OAAO,GAAGY,QAAA;MAC5B;IACF;IAEA1B;EACF,IACF,CACEK,MAAA,EACAC,eAAA,EACAR,YAAA,EACAK,kBAAA,EACAJ,KAAA,EACAS,aAAA,EACAJ,aAAA,EACAJ,IAAA,CACD;EAGH,oBAAO8B,IAAA,CAACjC,OAAA,CAAQkC,QAAQ;IAACC,KAAA,EAAOpB,eAAA;cAAgBV;;AAClD;AAEA,OAAO,MAAM+B,sBAAA,GAAyBA,CAAA;EACpC,MAAMC,OAAA,GAAU9C,UAAA,CAAWS,OAAA;EAC3B,IAAIqC,OAAA,KAAYC,SAAA,EAAW;IACzB,MAAM,IAAIC,KAAA,CAAM;EAClB;EACA,OAAOF,OAAA;AACT","ignoreList":[]}
@@ -4,9 +4,7 @@ import type { ClientEditorConfig } from '../types.js';
4
4
  * This function expects client functions to ALREADY be ordered & dependencies checked on the server
5
5
  * @param unSanitizedEditorConfig
6
6
  */
7
- export declare function loadClientFeatures({ clientFunctions, schemaPath, unSanitizedEditorConfig, }: {
8
- clientFunctions?: Record<string, any>;
9
- schemaPath: string;
7
+ export declare function loadClientFeatures({ unSanitizedEditorConfig, }: {
10
8
  unSanitizedEditorConfig: ClientEditorConfig;
11
9
  }): ResolvedClientFeatureMap;
12
10
  //# sourceMappingURL=loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/client/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,wBAAwB,EACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,eAAe,EACf,UAAU,EACV,uBAAuB,GACxB,EAAE;IACD,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,uBAAuB,EAAE,kBAAkB,CAAA;CAC5C,GAAG,wBAAwB,CAmE3B"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/client/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,wBAAwB,EACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,uBAAuB,GACxB,EAAE;IACD,uBAAuB,EAAE,kBAAkB,CAAA;CAC5C,GAAG,wBAAwB,CAiD3B"}
@@ -5,8 +5,6 @@
5
5
  * @param unSanitizedEditorConfig
6
6
  */
7
7
  export function loadClientFeatures({
8
- clientFunctions,
9
- schemaPath,
10
8
  unSanitizedEditorConfig
11
9
  }) {
12
10
  for (const featureProvider of unSanitizedEditorConfig.features) {
@@ -16,32 +14,22 @@ export function loadClientFeatures({
16
14
  }
17
15
  // sort unSanitizedEditorConfig.features by order
18
16
  unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.sort((a, b) => a.clientFeatureProps.order - b.clientFeatureProps.order);
19
- const featureProviderMap = new Map(unSanitizedEditorConfig.features.map(f => [f.clientFeatureProps.featureKey, f]));
17
+ const featureProviderMap = new Map();
18
+ for (const feature of unSanitizedEditorConfig.features) {
19
+ featureProviderMap.set(feature.clientFeatureProps.featureKey, feature);
20
+ }
20
21
  const resolvedFeatures = new Map();
21
22
  // Make sure all dependencies declared in the respective features exist
22
23
  let loaded = 0;
23
24
  for (const featureProvider of unSanitizedEditorConfig.features) {
24
- /**
25
- * Load relevant clientFunctions scoped to this feature and then pass them to the client feature
26
- */
27
- const relevantClientFunctions = {};
28
- Object.entries(clientFunctions).forEach(([key, plugin]) => {
29
- if (key.startsWith(`lexicalFeature.${schemaPath}.${featureProvider.clientFeatureProps.featureKey}.components.`)) {
30
- const featureComponentKey = key.split(`${schemaPath}.${featureProvider.clientFeatureProps.featureKey}.components.`)[1];
31
- relevantClientFunctions[featureComponentKey] = plugin;
32
- }
33
- });
34
25
  const feature = typeof featureProvider.feature === 'function' ? featureProvider.feature({
35
- clientFunctions: relevantClientFunctions,
36
26
  featureProviderMap,
37
27
  resolvedFeatures,
38
28
  unSanitizedEditorConfig
39
29
  }) : featureProvider.feature;
40
- resolvedFeatures.set(featureProvider.clientFeatureProps.featureKey, {
41
- ...feature,
42
- key: featureProvider.clientFeatureProps.featureKey,
43
- order: loaded
44
- });
30
+ feature.key = featureProvider.clientFeatureProps.featureKey;
31
+ feature.order = loaded;
32
+ resolvedFeatures.set(featureProvider.clientFeatureProps.featureKey, feature);
45
33
  loaded++;
46
34
  }
47
35
  return resolvedFeatures;
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","names":["loadClientFeatures","clientFunctions","schemaPath","unSanitizedEditorConfig","featureProvider","features","clientFeatureProps","featureKey","order","undefined","Error","sort","a","b","featureProviderMap","Map","map","f","resolvedFeatures","loaded","relevantClientFunctions","Object","entries","forEach","key","plugin","startsWith","featureComponentKey","split","feature","set"],"sources":["../../../../src/lexical/config/client/loader.ts"],"sourcesContent":["'use client'\n\nimport type {\n ClientFeatureProviderMap,\n FeatureProviderClient,\n ResolvedClientFeatureMap,\n} from '../../../features/typesClient.js'\nimport type { ClientEditorConfig } from '../types.js'\n\n/**\n * This function expects client functions to ALREADY be ordered & dependencies checked on the server\n * @param unSanitizedEditorConfig\n */\nexport function loadClientFeatures({\n clientFunctions,\n schemaPath,\n unSanitizedEditorConfig,\n}: {\n clientFunctions?: Record<string, any>\n schemaPath: string\n unSanitizedEditorConfig: ClientEditorConfig\n}): ResolvedClientFeatureMap {\n for (const featureProvider of unSanitizedEditorConfig.features) {\n if (\n !featureProvider?.clientFeatureProps?.featureKey ||\n featureProvider?.clientFeatureProps?.order === undefined ||\n featureProvider?.clientFeatureProps?.order === null\n ) {\n throw new Error(\n 'A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.',\n )\n }\n }\n\n // sort unSanitizedEditorConfig.features by order\n unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.sort(\n (a, b) => a.clientFeatureProps.order - b.clientFeatureProps.order,\n )\n\n const featureProviderMap: ClientFeatureProviderMap = new Map(\n unSanitizedEditorConfig.features.map(\n (f) =>\n [f.clientFeatureProps.featureKey, f] as [string, FeatureProviderClient<unknown, unknown>],\n ),\n )\n\n const resolvedFeatures: ResolvedClientFeatureMap = new Map()\n\n // Make sure all dependencies declared in the respective features exist\n let loaded = 0\n for (const featureProvider of unSanitizedEditorConfig.features) {\n /**\n * Load relevant clientFunctions scoped to this feature and then pass them to the client feature\n */\n const relevantClientFunctions: Record<string, any> = {}\n Object.entries(clientFunctions).forEach(([key, plugin]) => {\n if (\n key.startsWith(\n `lexicalFeature.${schemaPath}.${featureProvider.clientFeatureProps.featureKey}.components.`,\n )\n ) {\n const featureComponentKey = key.split(\n `${schemaPath}.${featureProvider.clientFeatureProps.featureKey}.components.`,\n )[1]\n relevantClientFunctions[featureComponentKey] = plugin\n }\n })\n\n const feature =\n typeof featureProvider.feature === 'function'\n ? featureProvider.feature({\n clientFunctions: relevantClientFunctions,\n featureProviderMap,\n resolvedFeatures,\n unSanitizedEditorConfig,\n })\n : featureProvider.feature\n\n resolvedFeatures.set(featureProvider.clientFeatureProps.featureKey, {\n ...feature,\n key: featureProvider.clientFeatureProps.featureKey,\n order: loaded,\n })\n\n loaded++\n }\n\n return resolvedFeatures\n}\n"],"mappings":"AAAA;;AASA;;;;AAIA,OAAO,SAASA,mBAAmB;EACjCC,eAAe;EACfC,UAAU;EACVC;AAAuB,CAKxB;EACC,KAAK,MAAMC,eAAA,IAAmBD,uBAAA,CAAwBE,QAAQ,EAAE;IAC9D,IACE,CAACD,eAAA,EAAiBE,kBAAA,EAAoBC,UAAA,IACtCH,eAAA,EAAiBE,kBAAA,EAAoBE,KAAA,KAAUC,SAAA,IAC/CL,eAAA,EAAiBE,kBAAA,EAAoBE,KAAA,KAAU,MAC/C;MACA,MAAM,IAAIE,KAAA,CACR;IAEJ;EACF;EAEA;EACAP,uBAAA,CAAwBE,QAAQ,GAAGF,uBAAA,CAAwBE,QAAQ,CAACM,IAAI,CACtE,CAACC,CAAA,EAAGC,CAAA,KAAMD,CAAA,CAAEN,kBAAkB,CAACE,KAAK,GAAGK,CAAA,CAAEP,kBAAkB,CAACE,KAAK;EAGnE,MAAMM,kBAAA,GAA+C,IAAIC,GAAA,CACvDZ,uBAAA,CAAwBE,QAAQ,CAACW,GAAG,CACjCC,CAAA,IACC,CAACA,CAAA,CAAEX,kBAAkB,CAACC,UAAU,EAAEU,CAAA,CAAE;EAI1C,MAAMC,gBAAA,GAA6C,IAAIH,GAAA;EAEvD;EACA,IAAII,MAAA,GAAS;EACb,KAAK,MAAMf,eAAA,IAAmBD,uBAAA,CAAwBE,QAAQ,EAAE;IAC9D;;;IAGA,MAAMe,uBAAA,GAA+C,CAAC;IACtDC,MAAA,CAAOC,OAAO,CAACrB,eAAA,EAAiBsB,OAAO,CAAC,CAAC,CAACC,GAAA,EAAKC,MAAA,CAAO;MACpD,IACED,GAAA,CAAIE,UAAU,CACZ,kBAAkBxB,UAAA,IAAcE,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,cAAc,GAE7F;QACA,MAAMoB,mBAAA,GAAsBH,GAAA,CAAII,KAAK,CACnC,GAAG1B,UAAA,IAAcE,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,cAAc,CAC7E,CAAC,EAAE;QACJa,uBAAuB,CAACO,mBAAA,CAAoB,GAAGF,MAAA;MACjD;IACF;IAEA,MAAMI,OAAA,GACJ,OAAOzB,eAAA,CAAgByB,OAAO,KAAK,aAC/BzB,eAAA,CAAgByB,OAAO,CAAC;MACtB5B,eAAA,EAAiBmB,uBAAA;MACjBN,kBAAA;MACAI,gBAAA;MACAf;IACF,KACAC,eAAA,CAAgByB,OAAO;IAE7BX,gBAAA,CAAiBY,GAAG,CAAC1B,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,EAAE;MAClE,GAAGsB,OAAO;MACVL,GAAA,EAAKpB,eAAA,CAAgBE,kBAAkB,CAACC,UAAU;MAClDC,KAAA,EAAOW;IACT;IAEAA,MAAA;EACF;EAEA,OAAOD,gBAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"loader.js","names":["loadClientFeatures","unSanitizedEditorConfig","featureProvider","features","clientFeatureProps","featureKey","order","undefined","Error","sort","a","b","featureProviderMap","Map","feature","set","resolvedFeatures","loaded","key"],"sources":["../../../../src/lexical/config/client/loader.ts"],"sourcesContent":["'use client'\n\nimport type {\n ClientFeatureProviderMap,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n} from '../../../features/typesClient.js'\nimport type { ClientEditorConfig } from '../types.js'\n\n/**\n * This function expects client functions to ALREADY be ordered & dependencies checked on the server\n * @param unSanitizedEditorConfig\n */\nexport function loadClientFeatures({\n unSanitizedEditorConfig,\n}: {\n unSanitizedEditorConfig: ClientEditorConfig\n}): ResolvedClientFeatureMap {\n for (const featureProvider of unSanitizedEditorConfig.features) {\n if (\n !featureProvider?.clientFeatureProps?.featureKey ||\n featureProvider?.clientFeatureProps?.order === undefined ||\n featureProvider?.clientFeatureProps?.order === null\n ) {\n throw new Error(\n 'A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.',\n )\n }\n }\n\n // sort unSanitizedEditorConfig.features by order\n unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.sort(\n (a, b) => a.clientFeatureProps.order - b.clientFeatureProps.order,\n )\n\n const featureProviderMap: ClientFeatureProviderMap = new Map()\n for (const feature of unSanitizedEditorConfig.features) {\n featureProviderMap.set(feature.clientFeatureProps.featureKey, feature)\n }\n\n const resolvedFeatures: ResolvedClientFeatureMap = new Map()\n\n // Make sure all dependencies declared in the respective features exist\n let loaded = 0\n for (const featureProvider of unSanitizedEditorConfig.features) {\n const feature: Partial<ResolvedClientFeature<any>> =\n typeof featureProvider.feature === 'function'\n ? featureProvider.feature({\n featureProviderMap,\n resolvedFeatures,\n unSanitizedEditorConfig,\n })\n : featureProvider.feature\n\n feature.key = featureProvider.clientFeatureProps.featureKey\n feature.order = loaded\n\n resolvedFeatures.set(\n featureProvider.clientFeatureProps.featureKey,\n feature as ResolvedClientFeature<any>,\n )\n\n loaded++\n }\n\n return resolvedFeatures\n}\n"],"mappings":"AAAA;;AASA;;;;AAIA,OAAO,SAASA,mBAAmB;EACjCC;AAAuB,CAGxB;EACC,KAAK,MAAMC,eAAA,IAAmBD,uBAAA,CAAwBE,QAAQ,EAAE;IAC9D,IACE,CAACD,eAAA,EAAiBE,kBAAA,EAAoBC,UAAA,IACtCH,eAAA,EAAiBE,kBAAA,EAAoBE,KAAA,KAAUC,SAAA,IAC/CL,eAAA,EAAiBE,kBAAA,EAAoBE,KAAA,KAAU,MAC/C;MACA,MAAM,IAAIE,KAAA,CACR;IAEJ;EACF;EAEA;EACAP,uBAAA,CAAwBE,QAAQ,GAAGF,uBAAA,CAAwBE,QAAQ,CAACM,IAAI,CACtE,CAACC,CAAA,EAAGC,CAAA,KAAMD,CAAA,CAAEN,kBAAkB,CAACE,KAAK,GAAGK,CAAA,CAAEP,kBAAkB,CAACE,KAAK;EAGnE,MAAMM,kBAAA,GAA+C,IAAIC,GAAA;EACzD,KAAK,MAAMC,OAAA,IAAWb,uBAAA,CAAwBE,QAAQ,EAAE;IACtDS,kBAAA,CAAmBG,GAAG,CAACD,OAAA,CAAQV,kBAAkB,CAACC,UAAU,EAAES,OAAA;EAChE;EAEA,MAAME,gBAAA,GAA6C,IAAIH,GAAA;EAEvD;EACA,IAAII,MAAA,GAAS;EACb,KAAK,MAAMf,eAAA,IAAmBD,uBAAA,CAAwBE,QAAQ,EAAE;IAC9D,MAAMW,OAAA,GACJ,OAAOZ,eAAA,CAAgBY,OAAO,KAAK,aAC/BZ,eAAA,CAAgBY,OAAO,CAAC;MACtBF,kBAAA;MACAI,gBAAA;MACAf;IACF,KACAC,eAAA,CAAgBY,OAAO;IAE7BA,OAAA,CAAQI,GAAG,GAAGhB,eAAA,CAAgBE,kBAAkB,CAACC,UAAU;IAC3DS,OAAA,CAAQR,KAAK,GAAGW,MAAA;IAEhBD,gBAAA,CAAiBD,GAAG,CAClBb,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,EAC7CS,OAAA;IAGFG,MAAA;EACF;EAEA,OAAOD,gBAAA;AACT","ignoreList":[]}
@@ -3,5 +3,5 @@ import type { ResolvedClientFeatureMap, SanitizedClientFeatures } from '../../..
3
3
  import type { LexicalFieldAdminProps } from '../../../types.js';
4
4
  import type { SanitizedClientEditorConfig } from '../types.js';
5
5
  export declare const sanitizeClientFeatures: (features: ResolvedClientFeatureMap) => SanitizedClientFeatures;
6
- export declare function sanitizeClientEditorConfig(lexical: LexicalEditorConfig, resolvedClientFeatureMap: ResolvedClientFeatureMap, admin?: LexicalFieldAdminProps): SanitizedClientEditorConfig;
6
+ export declare function sanitizeClientEditorConfig(resolvedClientFeatureMap: ResolvedClientFeatureMap, lexical?: LexicalEditorConfig, admin?: LexicalFieldAdminProps): SanitizedClientEditorConfig;
7
7
  //# sourceMappingURL=sanitize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/client/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,eAAO,MAAM,sBAAsB,aACvB,wBAAwB,KACjC,uBAsMF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mBAAmB,EAC5B,wBAAwB,EAAE,wBAAwB,EAClD,KAAK,CAAC,EAAE,sBAAsB,GAC7B,2BAA2B,CAO7B"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/client/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,eAAO,MAAM,sBAAsB,aACvB,wBAAwB,KACjC,uBAsMF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,wBAAwB,EAAE,wBAAwB,EAClD,OAAO,CAAC,EAAE,mBAAmB,EAC7B,KAAK,CAAC,EAAE,sBAAsB,GAC7B,2BAA2B,CAO7B"}
@@ -43,8 +43,8 @@ export const sanitizeClientFeatures = features => {
43
43
  if (feature.plugins?.length) {
44
44
  feature.plugins.forEach((plugin, i) => {
45
45
  sanitized.plugins.push({
46
- Component: plugin.Component,
47
46
  clientProps: feature.sanitizedClientFeatureProps,
47
+ Component: plugin.Component,
48
48
  key: feature.key + i,
49
49
  position: plugin.position
50
50
  });
@@ -169,7 +169,7 @@ export const sanitizeClientFeatures = features => {
169
169
  }
170
170
  return sanitized;
171
171
  };
172
- export function sanitizeClientEditorConfig(lexical, resolvedClientFeatureMap, admin) {
172
+ export function sanitizeClientEditorConfig(resolvedClientFeatureMap, lexical, admin) {
173
173
  return {
174
174
  admin,
175
175
  features: sanitizeClientFeatures(resolvedClientFeatureMap),
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.js","names":["sanitizeClientFeatures","features","sanitized","enabledFeatures","hooks","load","save","markdownTransformers","nodes","plugins","providers","slashMenu","dynamicGroups","groups","toolbarFixed","toolbarInline","size","forEach","feature","length","concat","plugin","i","push","Component","clientProps","sanitizedClientFeatureProps","key","position","group","foundGroup","find","sanitizedGroup","items","filter","optionGroup","sort","a","b","order","sanitizeClientEditorConfig","lexical","resolvedClientFeatureMap","admin","resolvedFeatureMap"],"sources":["../../../../src/lexical/config/client/sanitize.ts"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type {\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n} from '../../../features/typesClient.js'\nimport type { LexicalFieldAdminProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\nexport const sanitizeClientFeatures = (\n features: ResolvedClientFeatureMap,\n): SanitizedClientFeatures => {\n const sanitized: SanitizedClientFeatures = {\n enabledFeatures: [],\n hooks: {\n load: [],\n save: [],\n },\n markdownTransformers: [],\n nodes: [],\n plugins: [],\n providers: [],\n slashMenu: {\n dynamicGroups: [],\n groups: [],\n },\n toolbarFixed: {\n groups: [],\n },\n toolbarInline: {\n groups: [],\n },\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature.hooks) {\n if (feature.hooks?.load?.length) {\n sanitized.hooks.load = sanitized.hooks.load.concat(feature.hooks.load)\n }\n if (feature.hooks?.save?.length) {\n sanitized.hooks.save = sanitized.hooks.save.concat(feature.hooks.save)\n }\n }\n\n if (feature.providers?.length) {\n sanitized.providers = sanitized.providers.concat(feature.providers)\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\n }\n if (feature.plugins?.length) {\n feature.plugins.forEach((plugin, i) => {\n sanitized.plugins.push({\n Component: plugin.Component,\n clientProps: feature.sanitizedClientFeatureProps,\n key: feature.key + i,\n position: plugin.position,\n })\n })\n }\n\n if (feature.toolbarInline?.groups?.length) {\n for (const group of feature.toolbarInline.groups) {\n // 1. find the group with the same key or create new one\n let foundGroup = sanitized.toolbarInline.groups.find(\n (sanitizedGroup) => sanitizedGroup.key === group.key,\n )\n if (!foundGroup) {\n foundGroup = {\n ...group,\n items: [],\n }\n } else {\n sanitized.toolbarInline.groups = sanitized.toolbarInline.groups.filter(\n (sanitizedGroup) => sanitizedGroup.key !== group.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.items?.length) {\n foundGroup.items = foundGroup.items.concat(group.items)\n }\n sanitized.toolbarInline?.groups.push(foundGroup)\n }\n }\n\n if (feature.toolbarFixed?.groups?.length) {\n for (const group of feature.toolbarFixed.groups) {\n // 1. find the group with the same key or create new one\n let foundGroup = sanitized.toolbarFixed.groups.find(\n (sanitizedGroup) => sanitizedGroup.key === group.key,\n )\n if (!foundGroup) {\n foundGroup = {\n ...group,\n items: [],\n }\n } else {\n sanitized.toolbarFixed.groups = sanitized.toolbarFixed.groups.filter(\n (sanitizedGroup) => sanitizedGroup.key !== group.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.items?.length) {\n foundGroup.items = foundGroup.items.concat(group.items)\n }\n sanitized.toolbarFixed?.groups.push(foundGroup)\n }\n }\n\n if (feature.slashMenu?.groups) {\n if (feature.slashMenu.dynamicGroups?.length) {\n sanitized.slashMenu.dynamicGroups = sanitized.slashMenu.dynamicGroups.concat(\n feature.slashMenu.dynamicGroups,\n )\n }\n\n for (const optionGroup of feature.slashMenu.groups) {\n // 1. find the group with the same name or create new one\n let group = sanitized.slashMenu.groups.find((group) => group.key === optionGroup.key)\n if (!group) {\n group = {\n ...optionGroup,\n items: [],\n }\n } else {\n sanitized.slashMenu.groups = sanitized.slashMenu.groups.filter(\n (group) => group.key !== optionGroup.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (optionGroup?.items?.length) {\n group.items = group.items.concat(optionGroup.items)\n }\n sanitized.slashMenu.groups.push(group)\n }\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n sanitized.enabledFeatures.push(feature.key)\n })\n\n // Sort sanitized.toolbarInline.groups by order property\n sanitized.toolbarInline.groups.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n // Sort sanitized.toolbarFixed.groups by order property\n sanitized.toolbarFixed.groups.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n\n // Sort sanitized.toolbarInline.groups.[group].entries by order property\n for (const group of sanitized.toolbarInline.groups) {\n group.items.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n // Sort sanitized.toolbarFixed.groups.[group].entries by order property\n for (const group of sanitized.toolbarFixed.groups) {\n group.items.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n return sanitized\n}\n\nexport function sanitizeClientEditorConfig(\n lexical: LexicalEditorConfig,\n resolvedClientFeatureMap: ResolvedClientFeatureMap,\n admin?: LexicalFieldAdminProps,\n): SanitizedClientEditorConfig {\n return {\n admin,\n features: sanitizeClientFeatures(resolvedClientFeatureMap),\n lexical,\n resolvedFeatureMap: resolvedClientFeatureMap,\n }\n}\n"],"mappings":"AAAA;;AAWA,OAAO,MAAMA,sBAAA,GACXC,QAAA;EAEA,MAAMC,SAAA,GAAqC;IACzCC,eAAA,EAAiB,EAAE;IACnBC,KAAA,EAAO;MACLC,IAAA,EAAM,EAAE;MACRC,IAAA,EAAM;IACR;IACAC,oBAAA,EAAsB,EAAE;IACxBC,KAAA,EAAO,EAAE;IACTC,OAAA,EAAS,EAAE;IACXC,SAAA,EAAW,EAAE;IACbC,SAAA,EAAW;MACTC,aAAA,EAAe,EAAE;MACjBC,MAAA,EAAQ;IACV;IACAC,YAAA,EAAc;MACZD,MAAA,EAAQ;IACV;IACAE,aAAA,EAAe;MACbF,MAAA,EAAQ;IACV;EACF;EAEA,IAAI,CAACZ,QAAA,EAAUe,IAAA,EAAM;IACnB,OAAOd,SAAA;EACT;EAEAD,QAAA,CAASgB,OAAO,CAAEC,OAAA;IAChB,IAAIA,OAAA,CAAQd,KAAK,EAAE;MACjB,IAAIc,OAAA,CAAQd,KAAK,EAAEC,IAAA,EAAMc,MAAA,EAAQ;QAC/BjB,SAAA,CAAUE,KAAK,CAACC,IAAI,GAAGH,SAAA,CAAUE,KAAK,CAACC,IAAI,CAACe,MAAM,CAACF,OAAA,CAAQd,KAAK,CAACC,IAAI;MACvE;MACA,IAAIa,OAAA,CAAQd,KAAK,EAAEE,IAAA,EAAMa,MAAA,EAAQ;QAC/BjB,SAAA,CAAUE,KAAK,CAACE,IAAI,GAAGJ,SAAA,CAAUE,KAAK,CAACE,IAAI,CAACc,MAAM,CAACF,OAAA,CAAQd,KAAK,CAACE,IAAI;MACvE;IACF;IAEA,IAAIY,OAAA,CAAQR,SAAS,EAAES,MAAA,EAAQ;MAC7BjB,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EA,OAAOrC,SAAA;AACT;AAEA,OAAO,SAASsC,2BACdC,OAA4B,EAC5BC,wBAAkD,EAClDC,KAA8B;EAE9B,OAAO;IACLA,KAAA;IACA1C,QAAA,EAAUD,sBAAA,CAAuB0C,wBAAA;IACjCD,OAAA;IACAG,kBAAA,EAAoBF;EACtB;AACF","ignoreList":[]}
1
+ {"version":3,"file":"sanitize.js","names":["sanitizeClientFeatures","features","sanitized","enabledFeatures","hooks","load","save","markdownTransformers","nodes","plugins","providers","slashMenu","dynamicGroups","groups","toolbarFixed","toolbarInline","size","forEach","feature","length","concat","plugin","i","push","clientProps","sanitizedClientFeatureProps","Component","key","position","group","foundGroup","find","sanitizedGroup","items","filter","optionGroup","sort","a","b","order","sanitizeClientEditorConfig","resolvedClientFeatureMap","lexical","admin","resolvedFeatureMap"],"sources":["../../../../src/lexical/config/client/sanitize.ts"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type {\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n} from '../../../features/typesClient.js'\nimport type { LexicalFieldAdminProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\nexport const sanitizeClientFeatures = (\n features: ResolvedClientFeatureMap,\n): SanitizedClientFeatures => {\n const sanitized: SanitizedClientFeatures = {\n enabledFeatures: [],\n hooks: {\n load: [],\n save: [],\n },\n markdownTransformers: [],\n nodes: [],\n plugins: [],\n providers: [],\n slashMenu: {\n dynamicGroups: [],\n groups: [],\n },\n toolbarFixed: {\n groups: [],\n },\n toolbarInline: {\n groups: [],\n },\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature.hooks) {\n if (feature.hooks?.load?.length) {\n sanitized.hooks.load = sanitized.hooks.load.concat(feature.hooks.load)\n }\n if (feature.hooks?.save?.length) {\n sanitized.hooks.save = sanitized.hooks.save.concat(feature.hooks.save)\n }\n }\n\n if (feature.providers?.length) {\n sanitized.providers = sanitized.providers.concat(feature.providers)\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\n }\n if (feature.plugins?.length) {\n feature.plugins.forEach((plugin, i) => {\n sanitized.plugins.push({\n clientProps: feature.sanitizedClientFeatureProps,\n Component: plugin.Component,\n key: feature.key + i,\n position: plugin.position,\n })\n })\n }\n\n if (feature.toolbarInline?.groups?.length) {\n for (const group of feature.toolbarInline.groups) {\n // 1. find the group with the same key or create new one\n let foundGroup = sanitized.toolbarInline.groups.find(\n (sanitizedGroup) => sanitizedGroup.key === group.key,\n )\n if (!foundGroup) {\n foundGroup = {\n ...group,\n items: [],\n }\n } else {\n sanitized.toolbarInline.groups = sanitized.toolbarInline.groups.filter(\n (sanitizedGroup) => sanitizedGroup.key !== group.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.items?.length) {\n foundGroup.items = foundGroup.items.concat(group.items)\n }\n sanitized.toolbarInline?.groups.push(foundGroup)\n }\n }\n\n if (feature.toolbarFixed?.groups?.length) {\n for (const group of feature.toolbarFixed.groups) {\n // 1. find the group with the same key or create new one\n let foundGroup = sanitized.toolbarFixed.groups.find(\n (sanitizedGroup) => sanitizedGroup.key === group.key,\n )\n if (!foundGroup) {\n foundGroup = {\n ...group,\n items: [],\n }\n } else {\n sanitized.toolbarFixed.groups = sanitized.toolbarFixed.groups.filter(\n (sanitizedGroup) => sanitizedGroup.key !== group.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.items?.length) {\n foundGroup.items = foundGroup.items.concat(group.items)\n }\n sanitized.toolbarFixed?.groups.push(foundGroup)\n }\n }\n\n if (feature.slashMenu?.groups) {\n if (feature.slashMenu.dynamicGroups?.length) {\n sanitized.slashMenu.dynamicGroups = sanitized.slashMenu.dynamicGroups.concat(\n feature.slashMenu.dynamicGroups,\n )\n }\n\n for (const optionGroup of feature.slashMenu.groups) {\n // 1. find the group with the same name or create new one\n let group = sanitized.slashMenu.groups.find((group) => group.key === optionGroup.key)\n if (!group) {\n group = {\n ...optionGroup,\n items: [],\n }\n } else {\n sanitized.slashMenu.groups = sanitized.slashMenu.groups.filter(\n (group) => group.key !== optionGroup.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (optionGroup?.items?.length) {\n group.items = group.items.concat(optionGroup.items)\n }\n sanitized.slashMenu.groups.push(group)\n }\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n sanitized.enabledFeatures.push(feature.key)\n })\n\n // Sort sanitized.toolbarInline.groups by order property\n sanitized.toolbarInline.groups.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n // Sort sanitized.toolbarFixed.groups by order property\n sanitized.toolbarFixed.groups.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n\n // Sort sanitized.toolbarInline.groups.[group].entries by order property\n for (const group of sanitized.toolbarInline.groups) {\n group.items.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n // Sort sanitized.toolbarFixed.groups.[group].entries by order property\n for (const group of sanitized.toolbarFixed.groups) {\n group.items.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n return sanitized\n}\n\nexport function sanitizeClientEditorConfig(\n resolvedClientFeatureMap: ResolvedClientFeatureMap,\n lexical?: LexicalEditorConfig,\n admin?: LexicalFieldAdminProps,\n): SanitizedClientEditorConfig {\n return {\n admin,\n features: sanitizeClientFeatures(resolvedClientFeatureMap),\n lexical,\n resol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AAA;IACjCC,OAAA;IACAE,kBAAA,EAAoBH;EACtB;AACF","ignoreList":[]}
@@ -8,10 +8,10 @@ export type MenuResolution = {
8
8
  };
9
9
  export type MenuRenderFn = (anchorElementRef: RefObject<HTMLElement | null>, itemProps: {
10
10
  groups: Array<SlashMenuGroupInternal>;
11
- selectItemAndCleanUp: (selectedItem: SlashMenuItem) => void;
12
11
  selectedItemKey: null | string;
12
+ selectItemAndCleanUp: (selectedItem: SlashMenuItem) => void;
13
13
  setSelectedItemKey: (itemKey: string) => void;
14
- }, matchingString: null | string) => JSX.Element | ReactPortal | null;
14
+ }, matchingString: null | string) => JSX.Element | null | ReactPortal;
15
15
  export declare function getScrollParent(element: HTMLElement, includeHidden: boolean): HTMLBodyElement | HTMLElement;
16
16
  export declare function useDynamicPositioning(resolution: MenuResolution | null, targetElement: HTMLElement | null, onReposition: () => void, onVisibilityChange?: (isInView: boolean) => void): void;
17
17
  export declare const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{
@@ -24,7 +24,7 @@ export declare function LexicalMenu({ anchorElementRef, close, editor, groups, m
24
24
  editor: LexicalEditor;
25
25
  groups: Array<SlashMenuGroupInternal>;
26
26
  menuRenderFn: MenuRenderFn;
27
- onSelectItem: (item: SlashMenuItem, textNodeContainingQuery: TextNode | null, closeMenu: () => void, matchingString: string) => void;
27
+ onSelectItem: (item: SlashMenuItem, textNodeContainingQuery: null | TextNode, closeMenu: () => void, matchingString: string) => void;
28
28
  resolution: MenuResolution;
29
29
  shouldSplitNodeWithQuery?: boolean;
30
30
  }): JSX.Element | null;
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalMenu.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACtE,OAAO,KAAK,EAAE,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,EAAE,YAAY,CAAA;IAC1B,YAAY,EAAE,CACZ,IAAI,EAAE,aAAa,EACnB,uBAAuB,EAAE,IAAI,GAAG,QAAQ,EACxC,SAAS,EAAE,MAAM,IAAI,EACrB,cAAc,EAAE,MAAM,KACnB,IAAI,CAAA;IACT,UAAU,EAAE,cAAc,CAAA;IAC1B,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAgNrB;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,WAAW,EACvB,UAAU,EAAE,cAAc,GAAG,IAAI,EACjC,aAAa,EAAE,CAAC,CAAC,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,EACjD,SAAS,CAAC,EAAE,MAAM,GACjB,SAAS,CAAC,WAAW,CAAC,CA6FxB"}
@@ -3,7 +3,7 @@
3
3
  import { c as _c } from "react/compiler-runtime";
4
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
5
5
  import { mergeRegister } from '@lexical/utils';
6
- import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, createCommand } from 'lexical';
6
+ import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, createCommand, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND } from 'lexical';
7
7
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
8
8
  const baseClass = 'slash-menu-popup';
9
9
  const scrollIntoViewIfNeeded = target => {
@@ -295,8 +295,8 @@ export function LexicalMenu({
295
295
  }, [selectItemAndCleanUp, close, editor, groups, selectedItemKey, updateSelectedItem]);
296
296
  const listItemProps = useMemo(() => ({
297
297
  groups,
298
- selectItemAndCleanUp,
299
298
  selectedItemKey,
299
+ selectItemAndCleanUp,
300
300
  setSelectedItemKey
301
301
  }), [selectItemAndCleanUp, selectedItemKey, groups]);
302
302
  return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : '');