@payloadcms/richtext-lexical 4.0.0-internal.011fd46 → 4.0.0-internal.17c142b

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 (197) hide show
  1. package/dist/@types/assets.d.js +2 -0
  2. package/dist/@types/assets.d.js.map +1 -0
  3. package/dist/cell/rscEntry.d.ts.map +1 -1
  4. package/dist/cell/rscEntry.js +5 -5
  5. package/dist/cell/rscEntry.js.map +1 -1
  6. package/dist/exports/client/Field-VW7ZGT6K.js +2 -0
  7. package/dist/exports/client/Field-VW7ZGT6K.js.map +7 -0
  8. package/dist/exports/client/bundled.css +1 -1
  9. package/dist/exports/client/chunk-4EIYXZ6H.js +12 -0
  10. package/dist/exports/client/chunk-4EIYXZ6H.js.map +7 -0
  11. package/dist/exports/client/{chunk-CUFJGFNW.js → chunk-ESITTE3C.js} +2 -2
  12. package/dist/exports/client/{chunk-CUFJGFNW.js.map → chunk-ESITTE3C.js.map} +2 -2
  13. package/dist/exports/client/componentInline-H24N7GUG.js +2 -0
  14. package/dist/exports/client/index.d.ts +1 -0
  15. package/dist/exports/client/index.d.ts.map +1 -1
  16. package/dist/exports/client/index.js +25 -27
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/exports/server/rsc.browser.d.ts +11 -0
  19. package/dist/exports/server/rsc.browser.d.ts.map +1 -0
  20. package/dist/exports/server/rsc.browser.js +10 -0
  21. package/dist/exports/server/rsc.browser.js.map +1 -0
  22. package/dist/features/blockquote/markdownTransformer.d.ts +1 -1
  23. package/dist/features/blockquote/markdownTransformer.d.ts.map +1 -1
  24. package/dist/features/blockquote/markdownTransformer.js.map +1 -1
  25. package/dist/features/blocks/client/component/index.js.map +1 -1
  26. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  27. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +1 -1
  28. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -1
  29. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -1
  30. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
  31. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +1 -1
  32. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -1
  33. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +1 -1
  34. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -1
  35. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +2 -1
  36. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -1
  37. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
  38. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +1 -1
  39. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -1
  40. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
  41. package/dist/features/converters/lexicalToMarkdown/index.d.ts.map +1 -1
  42. package/dist/features/converters/lexicalToMarkdown/index.js +1 -1
  43. package/dist/features/converters/lexicalToMarkdown/index.js.map +1 -1
  44. package/dist/features/converters/markdownToLexical/index.js +1 -1
  45. package/dist/features/converters/markdownToLexical/index.js.map +1 -1
  46. package/dist/features/experimental_table/markdownTransformer.d.ts +1 -1
  47. package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -1
  48. package/dist/features/experimental_table/markdownTransformer.js +1 -1
  49. package/dist/features/experimental_table/markdownTransformer.js.map +1 -1
  50. package/dist/features/format/bold/markdownTransformers.d.ts +1 -1
  51. package/dist/features/format/bold/markdownTransformers.d.ts.map +1 -1
  52. package/dist/features/format/bold/markdownTransformers.js.map +1 -1
  53. package/dist/features/format/inlineCode/markdownTransformers.d.ts +1 -1
  54. package/dist/features/format/inlineCode/markdownTransformers.d.ts.map +1 -1
  55. package/dist/features/format/inlineCode/markdownTransformers.js.map +1 -1
  56. package/dist/features/format/italic/markdownTransformers.d.ts +1 -1
  57. package/dist/features/format/italic/markdownTransformers.d.ts.map +1 -1
  58. package/dist/features/format/italic/markdownTransformers.js.map +1 -1
  59. package/dist/features/format/strikethrough/markdownTransformers.d.ts +1 -1
  60. package/dist/features/format/strikethrough/markdownTransformers.d.ts.map +1 -1
  61. package/dist/features/format/strikethrough/markdownTransformers.js.map +1 -1
  62. package/dist/features/heading/markdownTransformer.d.ts +1 -1
  63. package/dist/features/heading/markdownTransformer.d.ts.map +1 -1
  64. package/dist/features/heading/markdownTransformer.js.map +1 -1
  65. package/dist/features/horizontalRule/client/markdownTransformer.d.ts +1 -1
  66. package/dist/features/horizontalRule/client/markdownTransformer.d.ts.map +1 -1
  67. package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
  68. package/dist/features/horizontalRule/server/markdownTransformer.d.ts +1 -1
  69. package/dist/features/horizontalRule/server/markdownTransformer.d.ts.map +1 -1
  70. package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
  71. package/dist/features/link/markdownTransformer.d.ts +1 -1
  72. package/dist/features/link/markdownTransformer.d.ts.map +1 -1
  73. package/dist/features/link/markdownTransformer.js.map +1 -1
  74. package/dist/features/link/markdownTransformer.spec.js +1 -1
  75. package/dist/features/link/markdownTransformer.spec.js.map +1 -1
  76. package/dist/features/lists/checklist/markdownTransformers.d.ts +1 -1
  77. package/dist/features/lists/checklist/markdownTransformers.d.ts.map +1 -1
  78. package/dist/features/lists/checklist/markdownTransformers.js.map +1 -1
  79. package/dist/features/lists/orderedList/markdownTransformer.d.ts +1 -1
  80. package/dist/features/lists/orderedList/markdownTransformer.d.ts.map +1 -1
  81. package/dist/features/lists/orderedList/markdownTransformer.js.map +1 -1
  82. package/dist/features/lists/shared/markdown.d.ts +1 -1
  83. package/dist/features/lists/shared/markdown.d.ts.map +1 -1
  84. package/dist/features/lists/shared/markdown.js.map +1 -1
  85. package/dist/features/lists/unorderedList/markdownTransformer.d.ts +1 -1
  86. package/dist/features/lists/unorderedList/markdownTransformer.d.ts.map +1 -1
  87. package/dist/features/lists/unorderedList/markdownTransformer.js.map +1 -1
  88. package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -1
  89. package/dist/features/toolbars/shared/useToolbarStates.js +1 -3
  90. package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -1
  91. package/dist/features/typesClient.d.ts +1 -1
  92. package/dist/features/typesClient.d.ts.map +1 -1
  93. package/dist/features/typesClient.js.map +1 -1
  94. package/dist/features/typesServer.d.ts +1 -1
  95. package/dist/features/typesServer.d.ts.map +1 -1
  96. package/dist/features/typesServer.js.map +1 -1
  97. package/dist/features/upload/server/markdownTransformer.d.ts +1 -1
  98. package/dist/features/upload/server/markdownTransformer.d.ts.map +1 -1
  99. package/dist/features/upload/server/markdownTransformer.js.map +1 -1
  100. package/dist/field/bundled.css +1 -1
  101. package/dist/field/clientEntry.d.ts +29 -0
  102. package/dist/field/clientEntry.d.ts.map +1 -0
  103. package/dist/field/clientEntry.js +86 -0
  104. package/dist/field/clientEntry.js.map +1 -0
  105. package/dist/field/index.css +9 -12
  106. package/dist/field/index.js +1 -1
  107. package/dist/field/index.js.map +1 -1
  108. package/dist/field/rscEntry.d.ts.map +1 -1
  109. package/dist/field/rscEntry.js +2 -0
  110. package/dist/field/rscEntry.js.map +1 -1
  111. package/dist/index.d.ts +2 -2
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +49 -6
  114. package/dist/index.js.map +1 -1
  115. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  116. package/dist/lexical/LexicalEditor.js +36 -2
  117. package/dist/lexical/LexicalEditor.js.map +1 -1
  118. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  119. package/dist/lexical/LexicalProvider.js +22 -7
  120. package/dist/lexical/LexicalProvider.js.map +1 -1
  121. package/dist/lexical/config/client/loader.d.ts.map +1 -1
  122. package/dist/lexical/config/client/loader.js +5 -1
  123. package/dist/lexical/config/client/loader.js.map +1 -1
  124. package/dist/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  125. package/dist/lexical/plugins/MarkdownShortcut/index.js +1 -1
  126. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  127. package/dist/lexical/utils/markdown/createBlockNode.d.ts +1 -1
  128. package/dist/lexical/utils/markdown/createBlockNode.d.ts.map +1 -1
  129. package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
  130. package/dist/lexical-proxy/@lexical-markdown.d.ts +1 -40
  131. package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
  132. package/dist/lexical-proxy/@lexical-markdown.js +1 -56
  133. package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
  134. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +2 -0
  135. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +1 -0
  136. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +2 -0
  137. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +1 -0
  138. package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js +160 -0
  139. package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js.map +1 -0
  140. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +14 -0
  141. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +1 -0
  142. package/dist/packages/@lexical/markdown/MarkdownExport.js +220 -0
  143. package/dist/packages/@lexical/markdown/MarkdownExport.js.map +1 -0
  144. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +19 -0
  145. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +1 -0
  146. package/dist/packages/@lexical/markdown/MarkdownImport.js +199 -0
  147. package/dist/packages/@lexical/markdown/MarkdownImport.js.map +1 -0
  148. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +11 -0
  149. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +1 -0
  150. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +304 -0
  151. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +1 -0
  152. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +173 -0
  153. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +1 -0
  154. package/dist/packages/@lexical/markdown/MarkdownTransformers.js +352 -0
  155. package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +1 -0
  156. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +22 -0
  157. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +1 -0
  158. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +91 -0
  159. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +1 -0
  160. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +21 -0
  161. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +1 -0
  162. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +54 -0
  163. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +1 -0
  164. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +18 -0
  165. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +1 -0
  166. package/dist/packages/@lexical/markdown/importTextTransformers.js +54 -0
  167. package/dist/packages/@lexical/markdown/importTextTransformers.js.map +1 -0
  168. package/dist/packages/@lexical/markdown/index.d.ts +29 -0
  169. package/dist/packages/@lexical/markdown/index.d.ts.map +1 -0
  170. package/dist/packages/@lexical/markdown/index.js +39 -0
  171. package/dist/packages/@lexical/markdown/index.js.map +1 -0
  172. package/dist/packages/@lexical/markdown/utils.d.ts +34 -0
  173. package/dist/packages/@lexical/markdown/utils.d.ts.map +1 -0
  174. package/dist/packages/@lexical/markdown/utils.js +267 -0
  175. package/dist/packages/@lexical/markdown/utils.js.map +1 -0
  176. package/dist/types/index.d.ts +2 -2
  177. package/dist/types/index.d.ts.map +1 -1
  178. package/dist/types/index.js.map +1 -1
  179. package/dist/utilities/buildInitialState.d.ts +2 -1
  180. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  181. package/dist/utilities/buildInitialState.js.map +1 -1
  182. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  183. package/dist/utilities/generateImportMap.js +7 -3
  184. package/dist/utilities/generateImportMap.js.map +1 -1
  185. package/package.json +26 -21
  186. package/dist/exports/client/Field-VQX3RNMF.js +0 -2
  187. package/dist/exports/client/Field-VQX3RNMF.js.map +0 -7
  188. package/dist/exports/client/chunk-X3D4LZS7.js +0 -2
  189. package/dist/exports/client/chunk-X3D4LZS7.js.map +0 -7
  190. package/dist/exports/client/componentInline-DV4EGOWU.js +0 -2
  191. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts +0 -28
  192. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts.map +0 -1
  193. package/dist/lexical/utils/markdown/normalizeMarkdown.js +0 -95
  194. package/dist/lexical/utils/markdown/normalizeMarkdown.js.map +0 -1
  195. package/dist/lexical-proxy/@lexical-markdown.spec.js +0 -89
  196. package/dist/lexical-proxy/@lexical-markdown.spec.js.map +0 -1
  197. /package/dist/exports/client/{componentInline-DV4EGOWU.js.map → componentInline-H24N7GUG.js.map} +0 -0
@@ -10,7 +10,7 @@ import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js';
10
10
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
11
11
  import { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical';
12
12
  import * as React from 'react';
13
- import { useEffect, useState } from 'react';
13
+ import { useCallback, useEffect, useState } from 'react';
14
14
  import { useEditorConfigContext } from './config/client/EditorConfigProvider.js';
15
15
  import './LexicalEditor.css';
16
16
  import { EditorPlugin } from './EditorPlugin.js';
@@ -26,6 +26,40 @@ import { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js';
26
26
  import { SlashMenuPlugin } from './plugins/SlashMenu/index.js';
27
27
  import { TextPlugin } from './plugins/TextPlugin/index.js';
28
28
  import { LexicalContentEditable } from './ui/ContentEditable.js';
29
+ /**
30
+ * Marks the Lexical root element with `data-lexical-editable` once the editor
31
+ * is mounted and interactive. Tests can query this attribute to confirm that
32
+ * React event handlers are attached and keyboard input will be processed.
33
+ */
34
+ function EditorReadyPlugin() {
35
+ const $ = _c(3);
36
+ const [editor] = useLexicalComposerContext();
37
+ let t0;
38
+ let t1;
39
+ if ($[0] !== editor) {
40
+ t0 = () => {
41
+ const root = editor.getRootElement();
42
+ if (root) {
43
+ root.dataset.lexicalEditable = String(editor.isEditable());
44
+ }
45
+ return editor.registerEditableListener(editable => {
46
+ const el = editor.getRootElement();
47
+ if (el) {
48
+ el.dataset.lexicalEditable = String(editable);
49
+ }
50
+ });
51
+ };
52
+ t1 = [editor];
53
+ $[0] = editor;
54
+ $[1] = t0;
55
+ $[2] = t1;
56
+ } else {
57
+ t0 = $[1];
58
+ t1 = $[2];
59
+ }
60
+ useEffect(t0, t1);
61
+ return null;
62
+ }
29
63
  export const LexicalEditor = props => {
30
64
  const $ = _c(13);
31
65
  const {
@@ -111,7 +145,7 @@ export const LexicalEditor = props => {
111
145
  })
112
146
  }),
113
147
  ErrorBoundary: LexicalErrorBoundary
114
- }), _jsx(NormalizeSelectionPlugin, {}), isEditable && _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(ClipboardPlugin, {}), _jsx(TextPlugin, {
148
+ }), _jsx(EditorReadyPlugin, {}), _jsx(NormalizeSelectionPlugin, {}), isEditable && _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(ClipboardPlugin, {}), _jsx(TextPlugin, {
115
149
  features: editorConfig.features
116
150
  }), _jsx(SelectAllPlugin, {}), _jsx(NodeViewOverridePlugin, {}), isEditable && _jsx(OnChangePlugin, {
117
151
  ignoreSelectionChange: true,
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","ClipboardPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NodeViewOverridePlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","rtl","editorConfigContext","editor","isEditable","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","_jsxs","Fragment","children","features","plugins","map","_temp","className","dir","undefined","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","editorState","editor_0","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","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 { useLexicalEditable } from '@lexical/react/useLexicalEditable'\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 './LexicalEditor.css'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport { ClipboardPlugin } from './plugins/ClipboardPlugin/index.js'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NodeViewOverridePlugin } from './plugins/NodeViewOverridePlugin/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange' | 'rtl'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange, rtl } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\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 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\" dir={rtl ? 'rtl' : undefined} 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 editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <ClipboardPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n <NodeViewOverridePlugin />\n {isEditable && (\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 )}\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && isEditable && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\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 {isEditable && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {isEditable && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\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,kBAAkB,QAAQ;AACnC,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAIpC,SAASC,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AyBA,MAAA,CAAAI,GAAU;EAAA;AAAA;AA3D3E,SAAAlB,OAAAwB,QAAA;EAAA,IAgEUV,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBd,IAAA,CAAA3D,YAAA;MAAA2E,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAlExE,SAAAG,OAAAI,QAAA;EAAA,IAgJUX,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBd,IAAA,CAAA3D,YAAA;MAAA2E,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAlJxE,SAAAI,OAAAI,QAAA;EAAA,IAuJUZ,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBd,IAAA,CAAA3D,YAAA;MAAA2E,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAzJxE,SAAAK,OAAAI,QAAA;EAAA,IA+JQb,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfd,IAAA,CAAA3D,YAAA;MAAA2E,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","useLexicalEditable","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useCallback","useEffect","useState","useEditorConfigContext","EditorPlugin","ClipboardPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NodeViewOverridePlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","EditorReadyPlugin","$","editor","t0","t1","root","getRootElement","dataset","lexicalEditable","String","isEditable","registerEditableListener","editable","el","LexicalEditor","props","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","rtl","editorConfigContext","floatingAnchorElem","setFloatingAnchorElem","Symbol","for","_floatingAnchorElem","onRef","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","_jsxs","Fragment","children","features","plugins","map","_temp","className","dir","undefined","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","editorState","editor_0","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","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 { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport './LexicalEditor.css'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport { ClipboardPlugin } from './plugins/ClipboardPlugin/index.js'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NodeViewOverridePlugin } from './plugins/NodeViewOverridePlugin/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\n/**\n * Marks the Lexical root element with `data-lexical-editable` once the editor\n * is mounted and interactive. Tests can query this attribute to confirm that\n * React event handlers are attached and keyboard input will be processed.\n */\nfunction EditorReadyPlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n const root = editor.getRootElement()\n if (root) {\n root.dataset.lexicalEditable = String(editor.isEditable())\n }\n return editor.registerEditableListener((editable) => {\n const el = editor.getRootElement()\n if (el) {\n el.dataset.lexicalEditable = String(editable)\n }\n })\n }, [editor])\n\n return null\n}\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange' | 'rtl'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange, rtl } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = useCallback((_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 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\" dir={rtl ? 'rtl' : undefined} 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 editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <EditorReadyPlugin />\n <NormalizeSelectionPlugin />\n {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <ClipboardPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n <NodeViewOverridePlugin />\n {isEditable && (\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 )}\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && isEditable && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\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 {isEditable && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {isEditable && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\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;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7B,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;IACtF,QAAQ,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,qBAAqB,CAAA;CAC7B,CAAA;AAwBD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA8F1D,CAAA"}
1
+ {"version":3,"file":"LexicalProvider.d.ts","sourceRoot":"","sources":["../../src/lexical/LexicalProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAIhF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAUpE,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,2BAA2B,CAAA;IACzC,UAAU,EAAE,yBAAyB,CAAA;IACrC,oBAAoB,EAAE,OAAO,CAAA;IAC7B,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;IACtF,QAAQ,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,qBAAqB,CAAA;CAC7B,CAAA;AAwBD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAgH1D,CAAA"}
@@ -47,7 +47,8 @@ export const LexicalProvider = props => {
47
47
  const parentContext = useEditorConfigContext();
48
48
  const editDepth = useEditDepth();
49
49
  const editorContainerRef = React.useRef(null);
50
- // useMemo for the initialConfig that depends on readOnly and value
50
+ // useMemo for the initialConfig. `readOnly` and `value` are intentionally excluded from deps
51
+ // to avoid full remounts on every save (which would destroy cursor position and undo history).
51
52
  const initialConfig = useMemo(() => {
52
53
  if (value && typeof value !== 'object') {
53
54
  throw new Error('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: ' + JSON.stringify(value));
@@ -76,16 +77,30 @@ export const LexicalProvider = props => {
76
77
  // Important: do not add readOnly and value to the dependencies array. This will cause the entire lexical editor to re-render if the document is saved, which will
77
78
  // cause the editor to lose focus.
78
79
  }, [editorConfig, views, currentView]);
79
- if (!initialConfig) {
80
+ // Track whether the editor has ever been editable. Once it transitions to editable,
81
+ // we never remount due to transient readOnly changes (e.g. during form save processing).
82
+ const hasBeenEditable = React.useRef(readOnly !== true);
83
+ if (readOnly !== true) {
84
+ hasBeenEditable.current = true;
85
+ }
86
+ // Compute the effective editable state for the config.
87
+ // Override the memoized config's editable value to reflect the current readOnly prop.
88
+ const effectiveConfig = useMemo(() => ({
89
+ ...initialConfig,
90
+ editable: readOnly !== true
91
+ }), [initialConfig, readOnly]);
92
+ if (!effectiveConfig) {
80
93
  return /*#__PURE__*/_jsx("p", {
81
94
  children: "Loading..."
82
95
  });
83
96
  }
84
- // We need to add initialConfig.editable to the key to force a re-render when the readOnly prop changes.
85
- // Without it, there were cases where lexical editors inside drawers turn readOnly initially - a few miliseconds later they turn editable, but the editor does not re-render and stays readOnly.
86
- // We also add currentView to force re-render when the view changes.
97
+ // Use `hasBeenEditable` to build the key: only force a remount when the editor has NEVER
98
+ // been editable and transitions to editable for the first time. After that, LexicalComposer
99
+ // stays mounted (preserving cursor/focus/undo) and we rely on Lexical's internal
100
+ // `editor.setEditable()` for transient readOnly changes during saves.
101
+ const editableKey = hasBeenEditable.current ? 'editable' : 'readonly';
87
102
  return /*#__PURE__*/_jsx(LexicalComposer, {
88
- initialConfig: initialConfig,
103
+ initialConfig: effectiveConfig,
89
104
  children: /*#__PURE__*/_jsx(EditorConfigProvider, {
90
105
  editorConfig: editorConfig,
91
106
  editorContainerRef: editorContainerRef,
@@ -105,6 +120,6 @@ export const LexicalProvider = props => {
105
120
  })
106
121
  })
107
122
  })
108
- }, composerKey + initialConfig.editable + currentView);
123
+ }, composerKey + editableKey + currentView);
109
124
  };
110
125
  //# sourceMappingURL=LexicalProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalProvider.js","names":["LexicalComposer","useEditDepth","React","useMemo","useRichTextView","EditorConfigProvider","useEditorConfigContext","LexicalEditor","LexicalEditorComponent","getEnabledNodes","NestProviders","children","providers","length","Component","_jsx","slice","LexicalProvider","props","composerKey","editorConfig","fieldProps","isSmallWidthViewport","onChange","readOnly","rtl","value","currentView","views","parentContext","editDepth","editorContainerRef","useRef","initialConfig","Error","JSON","stringify","Array","isArray","nodeViews","nodes","editable","editorState","undefined","namespace","lexical","onError","error","theme","features"],"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 { useEditDepth } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../types/index.js'\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { useRichTextView } from '../field/RichTextViewProvider.js'\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 composerKey: string\n editorConfig: SanitizedClientEditorConfig\n fieldProps: LexicalRichTextFieldProps\n isSmallWidthViewport: boolean\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n readOnly: boolean\n rtl?: boolean\n value: SerializedEditorState\n}\n\nconst NestProviders = ({\n children,\n providers,\n}: {\n children: React.ReactNode\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n providers: any[]\n}) => {\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 {\n composerKey,\n editorConfig,\n fieldProps,\n isSmallWidthViewport,\n onChange,\n readOnly,\n rtl,\n value,\n } = props\n\n const { currentView, views } = useRichTextView()\n\n const parentContext = useEditorConfigContext()\n\n const editDepth = useEditDepth()\n\n const editorContainerRef = React.useRef<HTMLDivElement>(null)\n\n // useMemo for the initialConfig that depends on readOnly and value\n const initialConfig = useMemo<InitialConfigType>(() => {\n if (value && typeof value !== '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(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\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/lexical/migration#migration-via-migration-script-recommended',\n )\n }\n\n if (value && 'jsonContent' in value) {\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/lexical/migration#migrating-from-payload-plugin-lexical',\n )\n }\n\n // Use the 'default' view if available, otherwise undefined\n const nodeViews = views?.[currentView]?.nodes\n\n return {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: getEnabledNodes({\n editorConfig,\n nodeViews,\n }),\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n // Important: do not add readOnly and value to the dependencies array. This will cause the entire lexical editor to re-render if the document is saved, which will\n // cause the editor to lose focus.\n }, [editorConfig, views, currentView])\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n // We need to add initialConfig.editable to the key to force a re-render when the readOnly prop changes.\n // Without it, there were cases where lexical editors inside drawers turn readOnly initially - a few miliseconds later they turn editable, but the editor does not re-render and stays readOnly.\n // We also add currentView to force re-render when the view changes.\n return (\n <LexicalComposer\n initialConfig={initialConfig}\n key={composerKey + initialConfig.editable + currentView}\n >\n <EditorConfigProvider\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n fieldProps={fieldProps}\n /**\n * Parent editor is not truly the parent editor, if the current editor is part of a drawer and the parent editor is the main editor.\n */\n parentContext={parentContext?.editDepth === editDepth ? parentContext : undefined}\n >\n <NestProviders providers={editorConfig.features.providers}>\n <LexicalEditorComponent\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n isSmallWidthViewport={isSmallWidthViewport}\n onChange={onChange}\n rtl={rtl}\n />\n </NestProviders>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAC7B,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AAKxB,SAASC,eAAe,QAAQ;AAChC,SACEC,oBAAoB,EACpBC,sBAAsB,QACjB;AACP,SAASC,aAAA,IAAiBC,sBAAsB,QAAQ;AACxD,SAASC,eAAe,QAAQ;AAahC,MAAMC,aAAA,GAAgBA,CAAC;EACrBC,QAAQ;EACRC;AAAS,CAKV;EACC,IAAI,CAACA,SAAA,EAAWC,MAAA,EAAQ;IACtB,OAAOF,QAAA;EACT;EACA,MAAMG,SAAA,GAAYF,SAAS,CAAC,EAAE;EAC9B,IAAIA,SAAA,CAAUC,MAAM,GAAG,GAAG;IACxB,oBACEE,IAAA,CAACD,SAAA;gBACC,aAAAC,IAAA,CAACL,aAAA;QAAcE,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AAO5B,YAAA,CAAayB,OAAO,CAACG;IAC9B;IACA;IACA;EACF,GAAG,CAAC5B,YAAA,EAAcQ,KAAA,EAAOD,WAAA,CAAY;EAErC,IAAI,CAACM,aAAA,EAAe;IAClB,oBAAOlB,IAAA,CAAC;gBAAE;;EACZ;EAEA;EACA;EACA;EACA,oBACEA,IAAA,CAACf,eAAA;IACCiC,aAAA,EAAeA,aAAA;cAGf,aAAAlB,IAAA,CAACV,oBAAA;MACCe,YAAA,EAAcA,YAAA;MACdW,kBAAA,EAAoBA,kBAAA;MACpBV,UAAA,EAAYA,UAAA;MACZ;;;MAGAQ,aAAA,EAAeA,aAAA,EAAeC,SAAA,KAAcA,SAAA,GAAYD,aAAA,GAAgBc,SAAA;gBAExE,aAAA5B,IAAA,CAACL,aAAA;QAAcE,SAAA,EAAWQ,YAAA,CAAa6B,QAAQ,CAACrC,SAAS;kBACvD,aAAAG,IAAA,CAACP,sBAAA;UACCY,YAAA,EAAcA,YAAA;UACdW,kBAAA,EAAoBA,kBAAA;UACpBT,oBAAA,EAAsBA,oBAAA;UACtBC,QAAA,EAAUA,QAAA;UACVE,GAAA,EAAKA;;;;KAjBNN,WAAA,GAAcc,aAAA,CAAcQ,QAAQ,GAAGd,WAAA;AAuBlD","ignoreList":[]}
1
+ {"version":3,"file":"LexicalProvider.js","names":["LexicalComposer","useEditDepth","React","useMemo","useRichTextView","EditorConfigProvider","useEditorConfigContext","LexicalEditor","LexicalEditorComponent","getEnabledNodes","NestProviders","children","providers","length","Component","_jsx","slice","LexicalProvider","props","composerKey","editorConfig","fieldProps","isSmallWidthViewport","onChange","readOnly","rtl","value","currentView","views","parentContext","editDepth","editorContainerRef","useRef","initialConfig","Error","JSON","stringify","Array","isArray","nodeViews","nodes","editable","editorState","undefined","namespace","lexical","onError","error","theme","hasBeenEditable","current","effectiveConfig","editableKey","features"],"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 { useEditDepth } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../types/index.js'\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { useRichTextView } from '../field/RichTextViewProvider.js'\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 composerKey: string\n editorConfig: SanitizedClientEditorConfig\n fieldProps: LexicalRichTextFieldProps\n isSmallWidthViewport: boolean\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n readOnly: boolean\n rtl?: boolean\n value: SerializedEditorState\n}\n\nconst NestProviders = ({\n children,\n providers,\n}: {\n children: React.ReactNode\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n providers: any[]\n}) => {\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 {\n composerKey,\n editorConfig,\n fieldProps,\n isSmallWidthViewport,\n onChange,\n readOnly,\n rtl,\n value,\n } = props\n\n const { currentView, views } = useRichTextView()\n\n const parentContext = useEditorConfigContext()\n\n const editDepth = useEditDepth()\n\n const editorContainerRef = React.useRef<HTMLDivElement>(null)\n\n // useMemo for the initialConfig. `readOnly` and `value` are intentionally excluded from deps\n // to avoid full remounts on every save (which would destroy cursor position and undo history).\n const initialConfig = useMemo<InitialConfigType>(() => {\n if (value && typeof value !== '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(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\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/lexical/migration#migration-via-migration-script-recommended',\n )\n }\n\n if (value && 'jsonContent' in value) {\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/lexical/migration#migrating-from-payload-plugin-lexical',\n )\n }\n\n // Use the 'default' view if available, otherwise undefined\n const nodeViews = views?.[currentView]?.nodes\n\n return {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: getEnabledNodes({\n editorConfig,\n nodeViews,\n }),\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n // Important: do not add readOnly and value to the dependencies array. This will cause the entire lexical editor to re-render if the document is saved, which will\n // cause the editor to lose focus.\n }, [editorConfig, views, currentView])\n\n // Track whether the editor has ever been editable. Once it transitions to editable,\n // we never remount due to transient readOnly changes (e.g. during form save processing).\n const hasBeenEditable = React.useRef(readOnly !== true)\n if (readOnly !== true) {\n hasBeenEditable.current = true\n }\n\n // Compute the effective editable state for the config.\n // Override the memoized config's editable value to reflect the current readOnly prop.\n const effectiveConfig = useMemo<InitialConfigType>(\n () => ({\n ...initialConfig,\n editable: readOnly !== true,\n }),\n\n [initialConfig, readOnly],\n )\n\n if (!effectiveConfig) {\n return <p>Loading...</p>\n }\n\n // Use `hasBeenEditable` to build the key: only force a remount when the editor has NEVER\n // been editable and transitions to editable for the first time. After that, LexicalComposer\n // stays mounted (preserving cursor/focus/undo) and we rely on Lexical's internal\n // `editor.setEditable()` for transient readOnly changes during saves.\n const editableKey = hasBeenEditable.current ? 'editable' : 'readonly'\n return (\n <LexicalComposer initialConfig={effectiveConfig} key={composerKey + editableKey + currentView}>\n <EditorConfigProvider\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n fieldProps={fieldProps}\n /**\n * Parent editor is not truly the parent editor, if the current editor is part of a drawer and the parent editor is the main editor.\n */\n parentContext={parentContext?.editDepth === editDepth ? parentContext : undefined}\n >\n <NestProviders providers={editorConfig.features.providers}>\n <LexicalEditorComponent\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n isSmallWidthViewport={isSmallWidthViewport}\n onChange={onChange}\n rtl={rtl}\n />\n </NestProviders>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAC7B,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AAKxB,SAASC,eAAe,QAAQ;AAChC,SACEC,oBAAoB,EACpBC,sBAAsB,QACjB;AACP,SAASC,aAAA,IAAiBC,sBAAsB,QAAQ;AACxD,SAASC,eAAe,QAAQ;AAahC,MAAMC,aAAA,GAAgBA,CAAC;EACrBC,QAAQ;EACRC;AAAS,CAKV;EACC,IAAI,CAACA,SAAA,EAAWC,MAAA,EAAQ;IACtB,OAAOF,QAAA;EACT;EACA,MAAMG,SAAA,GAAYF,SAAS,CAAC,EAAE;EAC9B,IAAIA,SAAA,CAAUC,MAAM,GAAG,GAAG;IACxB,oBACEE,IAAA,CAACD,SAAA;gBACC,aAAAC,IAAA,CAACL,aAAA;QAAcE,SAAA,EAAWA,SAAA,CAAUI,KAAK,CAAC;kBAAKL;;;EAGrD;EACA,oBAAOI,IAAA,CAACD,SAAA;cAAWH;;AACrB;AAEA,OAAO,MAAMM,eAAA,GAAmDC,KAAA;EAC9D,MAAM;IACJC,WAAW;IACXC,YAAY;IACZC,UAAU;IACVC,oBAAoB;IACpBC,QAAQ;IACRC,QAAQ;IACRC,GAAG;IACHC;EAAK,CACN,GAAGR,KAAA;EAEJ,MAAM;IAAES,WAAW;IAAEC;EAAK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,OAAO;IACL,GAAG8B,aAAa;IAChBQ,QAAA,EAAUjB,QAAA,KAAa;EACzB,IAEA,CAACS,aAAA,EAAeT,QAAA,CAAS;EAG3B,IAAI,CAAC2B,eAAA,EAAiB;IACpB,oBAAOpC,IAAA,CAAC;gBAAE;;EACZ;EAEA;EACA;EACA;EACA;EACA,MAAMqC,WAAA,GAAcH,eAAA,CAAgBC,OAAO,GAAG,aAAa;EAC3D,oBACEnC,IAAA,CAACf,eAAA;IAAgBiC,aAAA,EAAekB,eAAA;cAC9B,aAAApC,IAAA,CAACV,oBAAA;MACCe,YAAA,EAAcA,YAAA;MACdW,kBAAA,EAAoBA,kBAAA;MACpBV,UAAA,EAAYA,UAAA;MACZ;;;MAGAQ,aAAA,EAAeA,aAAA,EAAeC,SAAA,KAAcA,SAAA,GAAYD,aAAA,GAAgBc,SAAA;gBAExE,aAAA5B,IAAA,CAACL,aAAA;QAAcE,SAAA,EAAWQ,YAAA,CAAaiC,QAAQ,CAACzC,SAAS;kBACvD,aAAAG,IAAA,CAACP,sBAAA;UACCY,YAAA,EAAcA,YAAA;UACdW,kBAAA,EAAoBA,kBAAA;UACpBT,oBAAA,EAAsBA,oBAAA;UACtBC,QAAA,EAAUA,QAAA;UACVE,GAAA,EAAKA;;;;KAhByCN,WAAA,GAAciC,WAAA,GAAczB,WAAA;AAsBtF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/client/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAEhE,OAAO,KAAK,EAGV,wBAAwB,EACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,EACL,UAAU,EACV,uBAAuB,GACxB,EAAE;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3C,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,KAAK,CAAC,EAAE,mBAAmB,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,uBAAuB,EAAE,kBAAkB,CAAA;CAC5C,GAAG,wBAAwB,CAoD3B"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/client/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAEhE,OAAO,KAAK,EAGV,wBAAwB,EACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,EACL,UAAU,EACV,uBAAuB,GACxB,EAAE;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3C,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,KAAK,CAAC,EAAE,mBAAmB,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,uBAAuB,EAAE,kBAAkB,CAAA;CAC5C,GAAG,wBAAwB,CA0D3B"}
@@ -13,12 +13,16 @@ export function loadClientFeatures({
13
13
  unSanitizedEditorConfig
14
14
  }) {
15
15
  const featureProviderMap = new Map();
16
+ const validFeatures = [];
16
17
  for (const featureProvider of unSanitizedEditorConfig.features) {
17
18
  if (!featureProvider?.clientFeatureProps?.featureKey || featureProvider?.clientFeatureProps?.order === undefined || featureProvider?.clientFeatureProps?.order === null) {
18
- throw new Error('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.');
19
+ console.warn('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. Skipping feature.');
20
+ continue;
19
21
  }
20
22
  featureProviderMap.set(featureProvider.clientFeatureProps.featureKey, featureProvider);
23
+ validFeatures.push(featureProvider);
21
24
  }
25
+ unSanitizedEditorConfig.features = validFeatures;
22
26
  // sort unSanitizedEditorConfig.features by order
23
27
  unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.sort((a, b) => a.clientFeatureProps.order - b.clientFeatureProps.order);
24
28
  const resolvedFeatures = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","names":["loadClientFeatures","config","featureClientImportMap","featureClientSchemaMap","field","schemaPath","unSanitizedEditorConfig","featureProviderMap","Map","featureProvider","features","clientFeatureProps","featureKey","order","undefined","Error","set","sort","a","b","resolvedFeatures","loaded","feature","key"],"sources":["../../../../src/lexical/config/client/loader.ts"],"sourcesContent":["'use client'\n\nimport type { ClientConfig, RichTextFieldClient } from 'payload'\n\nimport type {\n ClientFeatureProviderMap,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n} from '../../../features/typesClient.js'\nimport type { FeatureClientSchemaMap } from '../../../types/index.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 config,\n featureClientImportMap,\n featureClientSchemaMap,\n field,\n schemaPath,\n unSanitizedEditorConfig,\n}: {\n config: ClientConfig\n featureClientImportMap: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n field?: RichTextFieldClient\n schemaPath: string\n unSanitizedEditorConfig: ClientEditorConfig\n}): ResolvedClientFeatureMap {\n const featureProviderMap: ClientFeatureProviderMap = new Map()\n\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 featureProviderMap.set(featureProvider.clientFeatureProps.featureKey, featureProvider)\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 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 config,\n featureClientImportMap,\n featureClientSchemaMap,\n featureProviderMap,\n field,\n resolvedFeatures,\n schemaPath,\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;;AAYA;;;;AAIA,OAAO,SAASA,mBAAmB;EACjCC,MAAM;EACNC,sBAAsB;EACtBC,sBAAsB;EACtBC,KAAK;EACLC,UAAU;EACVC;AAAuB,CAQxB;EACC,MAAMC,kBAAA,GAA+C,IAAIC,GAAA;EAEzD,KAAK,MAAMC,eAAA,IAAmBH,uBAAA,CAAwBI,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;IACAR,kBAAA,CAAmBS,GAAG,CAACP,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,EAAEH,eAAA;EACxE;EAEA;EACAH,uBAAA,CAAwBI,QAAQ,GAAGJ,uBAAA,CAAwBI,QAAQ,CAACO,IAAI,CACtE,CAACC,CAAA,EAAGC,CAAA,KAAMD,CAAA,CAAEP,kBAAkB,CAACE,KAAK,GAAGM,CAAA,CAAER,kBAAkB,CAACE,KAAK;EAGnE,MAAMO,gBAAA,GAA6C,IAAIZ,GAAA;EAEvD;EACA,IAAIa,MAAA,GAAS;EACb,KAAK,MAAMZ,eAAA,IAAmBH,uBAAA,CAAwBI,QAAQ,EAAE;IAC9D,MAAMY,OAAA,GACJ,OAAOb,eAAA,CAAgBa,OAAO,KAAK,aAC/Bb,eAAA,CAAgBa,OAAO,CAAC;MACtBrB,MAAA;MACAC,sBAAA;MACAC,sBAAA;MACAI,kBAAA;MACAH,KAAA;MACAgB,gBAAA;MACAf,UAAA;MACAC;IACF,KACAG,eAAA,CAAgBa,OAAO;IAE7BA,OAAA,CAAQC,GAAG,GAAGd,eAAA,CAAgBE,kBAAkB,CAACC,UAAU;IAC3DU,OAAA,CAAQT,KAAK,GAAGQ,MAAA;IAEhBD,gBAAA,CAAiBJ,GAAG,CAClBP,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,EAC7CU,OAAA;IAGFD,MAAA;EACF;EAEA,OAAOD,gBAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"loader.js","names":["loadClientFeatures","config","featureClientImportMap","featureClientSchemaMap","field","schemaPath","unSanitizedEditorConfig","featureProviderMap","Map","validFeatures","featureProvider","features","clientFeatureProps","featureKey","order","undefined","console","warn","set","push","sort","a","b","resolvedFeatures","loaded","feature","key"],"sources":["../../../../src/lexical/config/client/loader.ts"],"sourcesContent":["'use client'\n\nimport type { ClientConfig, RichTextFieldClient } from 'payload'\n\nimport type {\n ClientFeatureProviderMap,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n} from '../../../features/typesClient.js'\nimport type { FeatureClientSchemaMap } from '../../../types/index.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 config,\n featureClientImportMap,\n featureClientSchemaMap,\n field,\n schemaPath,\n unSanitizedEditorConfig,\n}: {\n config: ClientConfig\n featureClientImportMap: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n field?: RichTextFieldClient\n schemaPath: string\n unSanitizedEditorConfig: ClientEditorConfig\n}): ResolvedClientFeatureMap {\n const featureProviderMap: ClientFeatureProviderMap = new Map()\n\n const validFeatures: typeof unSanitizedEditorConfig.features = []\n\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 console.warn(\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. Skipping feature.',\n )\n continue\n }\n featureProviderMap.set(featureProvider.clientFeatureProps.featureKey, featureProvider)\n validFeatures.push(featureProvider)\n }\n\n unSanitizedEditorConfig.features = validFeatures\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 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 config,\n featureClientImportMap,\n featureClientSchemaMap,\n featureProviderMap,\n field,\n resolvedFeatures,\n schemaPath,\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;;AAYA;;;;AAIA,OAAO,SAASA,mBAAmB;EACjCC,MAAM;EACNC,sBAAsB;EACtBC,sBAAsB;EACtBC,KAAK;EACLC,UAAU;EACVC;AAAuB,CAQxB;EACC,MAAMC,kBAAA,GAA+C,IAAIC,GAAA;EAEzD,MAAMC,aAAA,GAAyD,EAAE;EAEjE,KAAK,MAAMC,eAAA,IAAmBJ,uBAAA,CAAwBK,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;MACAE,OAAA,CAAQC,IAAI,CACV;MAEF;IACF;IACAV,kBAAA,CAAmBW,GAAG,CAACR,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,EAAEH,eAAA;IACtED,aAAA,CAAcU,IAAI,CAACT,eAAA;EACrB;EAEAJ,uBAAA,CAAwBK,QAAQ,GAAGF,aAAA;EAEnC;EACAH,uBAAA,CAAwBK,QAAQ,GAAGL,uBAAA,CAAwBK,QAAQ,CAACS,IAAI,CACtE,CAACC,CAAA,EAAGC,CAAA,KAAMD,CAAA,CAAET,kBAAkB,CAACE,KAAK,GAAGQ,CAAA,CAAEV,kBAAkB,CAACE,KAAK;EAGnE,MAAMS,gBAAA,GAA6C,IAAIf,GAAA;EAEvD;EACA,IAAIgB,MAAA,GAAS;EACb,KAAK,MAAMd,eAAA,IAAmBJ,uBAAA,CAAwBK,QAAQ,EAAE;IAC9D,MAAMc,OAAA,GACJ,OAAOf,eAAA,CAAgBe,OAAO,KAAK,aAC/Bf,eAAA,CAAgBe,OAAO,CAAC;MACtBxB,MAAA;MACAC,sBAAA;MACAC,sBAAA;MACAI,kBAAA;MACAH,KAAA;MACAmB,gBAAA;MACAlB,UAAA;MACAC;IACF,KACAI,eAAA,CAAgBe,OAAO;IAE7BA,OAAA,CAAQC,GAAG,GAAGhB,eAAA,CAAgBE,kBAAkB,CAACC,UAAU;IAC3DY,OAAA,CAAQX,KAAK,GAAGU,MAAA;IAEhBD,gBAAA,CAAiBL,GAAG,CAClBR,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,EAC7CY,OAAA;IAGFD,MAAA;EACF;EAEA,OAAOD,gBAAA;AACT","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/MarkdownShortcut/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAS1C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/MarkdownShortcut/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAS1C,CAAA"}
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
 
3
3
  import { c as _c } from "react/compiler-runtime";
4
- import { registerMarkdownShortcuts } from '@lexical/markdown';
5
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
6
5
  import * as React from 'react';
6
+ import { registerMarkdownShortcuts } from '../../../packages/@lexical/markdown/MarkdownShortcuts.js';
7
7
  import { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js';
8
8
  export const MarkdownShortcutPlugin = () => {
9
9
  const $ = _c(4);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","registerMarkdownShortcuts","useLexicalComposerContext","React","useEditorConfigContext","MarkdownShortcutPlugin","$","editorConfig","editor","t0","t1","features","markdownTransformers","useEffect"],"sources":["../../../../src/lexical/plugins/MarkdownShortcut/index.tsx"],"sourcesContent":["'use client'\n\nimport { registerMarkdownShortcuts } from '@lexical/markdown'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport * as React from 'react'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\n\nexport const MarkdownShortcutPlugin: React.FC = () => {\n const { editorConfig } = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n React.useEffect(() => {\n return registerMarkdownShortcuts(editor, editorConfig.features.markdownTransformers ?? [])\n }, [editor, editorConfig.features.markdownTransformers])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,MAAW;AAEvB,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,sBAAA,GAAmCA,CAAA;EAAA,MAAAC,CAAA,GAAAN,EAAA;EAC9C;IAAAO;EAAA,IAAyBH,sBAAA;EACzB,OAAAI,MAAA,IAAiBN,yBAAA;EAAA,IAAAO,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAJ,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAEDH,EAAA,GAAAA,CAAA,KACPR,yBAAA,CAA0BO,MAAA,EAAQD,YAAA,CAAAI,QAAA,CAAAC,oBAAA,MAAgD;IACxFF,EAAA,IAACF,MAAA,EAAQD,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAA2CN,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAC,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAAAN,CAAA,MAAAG,EAAA;IAAAH,CAAA,MAAAI,EAAA;EAAA;IAAAD,EAAA,GAAAH,CAAA;IAAAI,EAAA,GAAAJ,CAAA;EAAA;EAFvDH,KAAA,CAAAU,SAAA,CAAgBJ,EAEhB,EAAGC,EAAoD;EAAA;AAAA,CAGzD","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","React","registerMarkdownShortcuts","useEditorConfigContext","MarkdownShortcutPlugin","$","editorConfig","editor","t0","t1","features","markdownTransformers","useEffect"],"sources":["../../../../src/lexical/plugins/MarkdownShortcut/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport * as React from 'react'\n\nimport { registerMarkdownShortcuts } from '../../../packages/@lexical/markdown/MarkdownShortcuts.js'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\n\nexport const MarkdownShortcutPlugin: React.FC = () => {\n const { editorConfig } = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n React.useEffect(() => {\n return registerMarkdownShortcuts(editor, editorConfig.features.markdownTransformers ?? [])\n }, [editor, editorConfig.features.markdownTransformers])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,MAAW;AAEvB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,sBAAA,GAAmCA,CAAA;EAAA,MAAAC,CAAA,GAAAN,EAAA;EAC9C;IAAAO;EAAA,IAAyBH,sBAAA;EACzB,OAAAI,MAAA,IAAiBP,yBAAA;EAAA,IAAAQ,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAJ,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAEDH,EAAA,GAAAA,CAAA,KACPN,yBAAA,CAA0BK,MAAA,EAAQD,YAAA,CAAAI,QAAA,CAAAC,oBAAA,MAAgD;IACxFF,EAAA,IAACF,MAAA,EAAQD,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAA2CN,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAC,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAAAN,CAAA,MAAAG,EAAA;IAAAH,CAAA,MAAAI,EAAA;EAAA;IAAAD,EAAA,GAAAH,CAAA;IAAAI,EAAA,GAAAJ,CAAA;EAAA;EAFvDJ,KAAA,CAAAW,SAAA,CAAgBJ,EAEhB,EAAGC,EAAoD;EAAA;AAAA,CAGzD","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ElementTransformer } from '@lexical/markdown';
2
1
  import type { ElementNode } from 'lexical';
2
+ import type { ElementTransformer } from '../../../packages/@lexical/markdown/MarkdownTransformers.js';
3
3
  export declare const createBlockNode: (createNode: (match: Array<string>) => ElementNode) => ElementTransformer["replace"];
4
4
  //# sourceMappingURL=createBlockNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createBlockNode.d.ts","sourceRoot":"","sources":["../../../../src/lexical/utils/markdown/createBlockNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,eAAe,GAC1B,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,WAAW,KAChD,kBAAkB,CAAC,SAAS,CAS9B,CAAA"}
1
+ {"version":3,"file":"createBlockNode.d.ts","sourceRoot":"","sources":["../../../../src/lexical/utils/markdown/createBlockNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAA;AAErG,eAAO,MAAM,eAAe,GAC1B,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,WAAW,KAChD,kBAAkB,CAAC,SAAS,CAS9B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"createBlockNode.js","names":["createBlockNode","createNode","parentNode","children","match","node","append","replace","select"],"sources":["../../../../src/lexical/utils/markdown/createBlockNode.ts"],"sourcesContent":["import type { ElementTransformer } from '@lexical/markdown'\nimport type { ElementNode } from 'lexical'\n\nexport const createBlockNode = (\n createNode: (match: Array<string>) => ElementNode,\n): ElementTransformer['replace'] => {\n return (parentNode, children, match) => {\n const node = createNode(match)\n if (node) {\n node.append(...children)\n parentNode.replace(node)\n node.select(0, 0)\n }\n }\n}\n"],"mappings":"AAGA,OAAO,MAAMA,eAAA,GACXC,UAAA;EAEA,OAAO,CAACC,UAAA,EAAYC,QAAA,EAAUC,KAAA;IAC5B,MAAMC,IAAA,GAAOJ,UAAA,CAAWG,KAAA;IACxB,IAAIC,IAAA,EAAM;MACRA,IAAA,CAAKC,MAAM,IAAIH,QAAA;MACfD,UAAA,CAAWK,OAAO,CAACF,IAAA;MACnBA,IAAA,CAAKG,MAAM,CAAC,GAAG;IACjB;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"createBlockNode.js","names":["createBlockNode","createNode","parentNode","children","match","node","append","replace","select"],"sources":["../../../../src/lexical/utils/markdown/createBlockNode.ts"],"sourcesContent":["import type { ElementNode } from 'lexical'\n\nimport type { ElementTransformer } from '../../../packages/@lexical/markdown/MarkdownTransformers.js'\n\nexport const createBlockNode = (\n createNode: (match: Array<string>) => ElementNode,\n): ElementTransformer['replace'] => {\n return (parentNode, children, match) => {\n const node = createNode(match)\n if (node) {\n node.append(...children)\n parentNode.replace(node)\n node.select(0, 0)\n }\n }\n}\n"],"mappings":"AAIA,OAAO,MAAMA,eAAA,GACXC,UAAA;EAEA,OAAO,CAACC,UAAA,EAAYC,QAAA,EAAUC,KAAA;IAC5B,MAAMC,IAAA,GAAOJ,UAAA,CAAWG,KAAA;IACxB,IAAIC,IAAA,EAAM;MACRA,IAAA,CAAKC,MAAM,IAAIH,QAAA;MACfD,UAAA,CAAWK,OAAO,CAACF,IAAA;MACnBA,IAAA,CAAKG,MAAM,CAAC,GAAG;IACjB;EACF;AACF","ignoreList":[]}
@@ -1,41 +1,2 @@
1
- /**
2
- * Payload's markdown entrypoint.
3
- *
4
- * Previously Payload vendored a full copy of `@lexical/markdown` (it could not
5
- * depend on the published package because, prior to lexical 0.42, importing it
6
- * transitively pulled in `@lexical/code` and its `prismjs` dependency, which
7
- * broke type generation). Since lexical 0.42 the markdown package depends on
8
- * `@lexical/code-core` (no prism), so the vendored copy is no longer needed.
9
- *
10
- * This module re-exports the upstream package and only keeps the Payload
11
- * specific behaviors that the fork added on top of it:
12
- * - `$convertFromMarkdownString` merges adjacent lines by default
13
- * (`shouldMergeAdjacentLines = true`), whereas upstream defaults to `false`.
14
- * - The default transformer set excludes the upstream `CODE` and `LINK`
15
- * transformers, since Payload provides those as features with its own node
16
- * types.
17
- * - Markdown is normalized with Payload's own `normalizeMarkdown` (handles
18
- * nested code fences and preserves table-row whitespace) instead of the
19
- * upstream normalizer, which is not exported and lacks those behaviors.
20
- */
21
- import type { ElementNode } from 'lexical';
22
- import { type ElementTransformer, type MultilineElementTransformer, type TextFormatTransformer, type TextMatchTransformer, type Transformer } from '@lexical/markdown';
23
- declare const ELEMENT_TRANSFORMERS: Array<ElementTransformer>;
24
- declare const MULTILINE_ELEMENT_TRANSFORMERS: Array<MultilineElementTransformer>;
25
- declare const TEXT_FORMAT_TRANSFORMERS: Array<TextFormatTransformer>;
26
- declare const TEXT_MATCH_TRANSFORMERS: Array<TextMatchTransformer>;
27
- declare const TRANSFORMERS: Array<Transformer>;
28
- /**
29
- * Renders markdown from a string. The selection is moved to the start after the operation.
30
- *
31
- * @param {boolean} [shouldPreserveNewLines] By setting this to true, new lines will be preserved between conversions
32
- * @param {boolean} [shouldMergeAdjacentLines] By setting this to true, adjacent non empty lines will be merged according to commonmark spec: https://spec.commonmark.org/0.24/#example-177. Not applicable if shouldPreserveNewLines = true.
33
- */
34
- declare function $convertFromMarkdownString(markdown: string, transformers?: Array<Transformer>, node?: ElementNode, shouldPreserveNewLines?: boolean, shouldMergeAdjacentLines?: boolean): void;
35
- /**
36
- * Renders string from markdown. The selection is moved to the start after the operation.
37
- */
38
- declare function $convertToMarkdownString(transformers?: Array<Transformer>, node?: ElementNode, shouldPreserveNewLines?: boolean): string;
39
- export { BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, CHECK_LIST, type ElementTransformer, HEADING, HIGHLIGHT, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, type MultilineElementTransformer, ORDERED_LIST, QUOTE, registerMarkdownShortcuts, STRIKETHROUGH, type TextFormatTransformer, type TextMatchTransformer, type Transformer, UNORDERED_LIST, } from '@lexical/markdown';
40
- export { $convertFromMarkdownString, $convertToMarkdownString, ELEMENT_TRANSFORMERS, MULTILINE_ELEMENT_TRANSFORMERS, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, TRANSFORMERS, };
1
+ export * from '../packages/@lexical/markdown/index.js';
41
2
  //# sourceMappingURL=@lexical-markdown.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"@lexical-markdown.d.ts","sourceRoot":"","sources":["../../src/lexical-proxy/@lexical-markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,EAOL,KAAK,kBAAkB,EAMvB,KAAK,2BAA2B,EAIhC,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAEjB,MAAM,mBAAmB,CAAA;AAI1B,QAAA,MAAM,oBAAoB,EAAE,KAAK,CAAC,kBAAkB,CAKnD,CAAA;AAED,QAAA,MAAM,8BAA8B,EAAE,KAAK,CAAC,2BAA2B,CAAM,CAAA;AAM7E,QAAA,MAAM,wBAAwB,EAAE,KAAK,CAAC,qBAAqB,CAU1D,CAAA;AAED,QAAA,MAAM,uBAAuB,EAAE,KAAK,CAAC,oBAAoB,CAAM,CAAA;AAE/D,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,WAAW,CAKpC,CAAA;AAED;;;;;GAKG;AACH,iBAAS,0BAA0B,CACjC,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,KAAK,CAAC,WAAW,CAAgB,EAC/C,IAAI,CAAC,EAAE,WAAW,EAClB,sBAAsB,UAAQ,EAC9B,wBAAwB,UAAO,GAC9B,IAAI,CAYN;AAED;;GAEG;AACH,iBAAS,wBAAwB,CAC/B,YAAY,GAAE,KAAK,CAAC,WAAW,CAAgB,EAC/C,IAAI,CAAC,EAAE,WAAW,EAClB,sBAAsB,GAAE,OAAe,GACtC,MAAM,CAER;AAED,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,eAAe,EACf,UAAU,EACV,KAAK,kBAAkB,EACvB,OAAO,EACP,SAAS,EACT,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,KAAK,2BAA2B,EAChC,YAAY,EACZ,KAAK,EACL,yBAAyB,EACzB,aAAa,EACb,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,cAAc,GACf,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,EACpB,8BAA8B,EAC9B,wBAAwB,EACxB,uBAAuB,EACvB,YAAY,GACb,CAAA"}
1
+ {"version":3,"file":"@lexical-markdown.d.ts","sourceRoot":"","sources":["../../src/lexical-proxy/@lexical-markdown.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAA"}
@@ -1,57 +1,2 @@
1
- /**
2
- * Payload's markdown entrypoint.
3
- *
4
- * Previously Payload vendored a full copy of `@lexical/markdown` (it could not
5
- * depend on the published package because, prior to lexical 0.42, importing it
6
- * transitively pulled in `@lexical/code` and its `prismjs` dependency, which
7
- * broke type generation). Since lexical 0.42 the markdown package depends on
8
- * `@lexical/code-core` (no prism), so the vendored copy is no longer needed.
9
- *
10
- * This module re-exports the upstream package and only keeps the Payload
11
- * specific behaviors that the fork added on top of it:
12
- * - `$convertFromMarkdownString` merges adjacent lines by default
13
- * (`shouldMergeAdjacentLines = true`), whereas upstream defaults to `false`.
14
- * - The default transformer set excludes the upstream `CODE` and `LINK`
15
- * transformers, since Payload provides those as features with its own node
16
- * types.
17
- * - Markdown is normalized with Payload's own `normalizeMarkdown` (handles
18
- * nested code fences and preserves table-row whitespace) instead of the
19
- * upstream normalizer, which is not exported and lacks those behaviors.
20
- */import { $convertFromMarkdownString as $convertFromMarkdownStringUpstream, $convertToMarkdownString as $convertToMarkdownStringUpstream, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, HEADING, HIGHLIGHT, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, ORDERED_LIST, QUOTE, STRIKETHROUGH, UNORDERED_LIST } from '@lexical/markdown';
21
- import { normalizeMarkdown } from '../lexical/utils/markdown/normalizeMarkdown.js';
22
- const ELEMENT_TRANSFORMERS = [HEADING, QUOTE, UNORDERED_LIST, ORDERED_LIST];
23
- const MULTILINE_ELEMENT_TRANSFORMERS = [];
24
- // Order of text format transformers matters:
25
- //
26
- // - code should go first as it prevents any transformations inside
27
- // - then longer tags match (e.g. ** or __ should go before * or _)
28
- const TEXT_FORMAT_TRANSFORMERS = [INLINE_CODE, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, HIGHLIGHT, ITALIC_STAR, ITALIC_UNDERSCORE, STRIKETHROUGH];
29
- const TEXT_MATCH_TRANSFORMERS = [];
30
- const TRANSFORMERS = [...ELEMENT_TRANSFORMERS, ...MULTILINE_ELEMENT_TRANSFORMERS, ...TEXT_FORMAT_TRANSFORMERS, ...TEXT_MATCH_TRANSFORMERS];
31
- /**
32
- * Renders markdown from a string. The selection is moved to the start after the operation.
33
- *
34
- * @param {boolean} [shouldPreserveNewLines] By setting this to true, new lines will be preserved between conversions
35
- * @param {boolean} [shouldMergeAdjacentLines] By setting this to true, adjacent non empty lines will be merged according to commonmark spec: https://spec.commonmark.org/0.24/#example-177. Not applicable if shouldPreserveNewLines = true.
36
- */
37
- function $convertFromMarkdownString(markdown, transformers = TRANSFORMERS, node, shouldPreserveNewLines = false, shouldMergeAdjacentLines = true) {
38
- if (shouldPreserveNewLines) {
39
- return $convertFromMarkdownStringUpstream(markdown, transformers, node, true);
40
- }
41
- // Normalize with Payload's normalizer, then let upstream import the result.
42
- // Passing shouldMergeAdjacentLines = false stops upstream's internal
43
- // normalizer from re-merging the already normalized markdown; for non empty
44
- // lines it preserves trailing whitespace and hard line breaks, so the only
45
- // observable difference is that whitespace-only lines collapse to empty.
46
- const sanitizedMarkdown = normalizeMarkdown(markdown, shouldMergeAdjacentLines);
47
- return $convertFromMarkdownStringUpstream(sanitizedMarkdown, transformers, node, false, false);
48
- }
49
- /**
50
- * Renders string from markdown. The selection is moved to the start after the operation.
51
- */
52
- function $convertToMarkdownString(transformers = TRANSFORMERS, node, shouldPreserveNewLines = false) {
53
- return $convertToMarkdownStringUpstream(transformers, node, shouldPreserveNewLines);
54
- }
55
- export { BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, CHECK_LIST, HEADING, HIGHLIGHT, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, ORDERED_LIST, QUOTE, registerMarkdownShortcuts, STRIKETHROUGH, UNORDERED_LIST } from '@lexical/markdown';
56
- export { $convertFromMarkdownString, $convertToMarkdownString, ELEMENT_TRANSFORMERS, MULTILINE_ELEMENT_TRANSFORMERS, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, TRANSFORMERS };
1
+ export * from '../packages/@lexical/markdown/index.js';
57
2
  //# sourceMappingURL=@lexical-markdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"@lexical-markdown.js","names":["$convertFromMarkdownString","$convertFromMarkdownStringUpstream","$convertToMarkdownString","$convertToMarkdownStringUpstream","BOLD_ITALIC_STAR","BOLD_ITALIC_UNDERSCORE","BOLD_STAR","BOLD_UNDERSCORE","HEADING","HIGHLIGHT","INLINE_CODE","ITALIC_STAR","ITALIC_UNDERSCORE","ORDERED_LIST","QUOTE","STRIKETHROUGH","UNORDERED_LIST","normalizeMarkdown","ELEMENT_TRANSFORMERS","MULTILINE_ELEMENT_TRANSFORMERS","TEXT_FORMAT_TRANSFORMERS","TEXT_MATCH_TRANSFORMERS","TRANSFORMERS","markdown","transformers","node","shouldPreserveNewLines","shouldMergeAdjacentLines","sanitizedMarkdown","CHECK_LIST","registerMarkdownShortcuts"],"sources":["../../src/lexical-proxy/@lexical-markdown.ts"],"sourcesContent":["/**\n * Payload's markdown entrypoint.\n *\n * Previously Payload vendored a full copy of `@lexical/markdown` (it could not\n * depend on the published package because, prior to lexical 0.42, importing it\n * transitively pulled in `@lexical/code` and its `prismjs` dependency, which\n * broke type generation). Since lexical 0.42 the markdown package depends on\n * `@lexical/code-core` (no prism), so the vendored copy is no longer needed.\n *\n * This module re-exports the upstream package and only keeps the Payload\n * specific behaviors that the fork added on top of it:\n * - `$convertFromMarkdownString` merges adjacent lines by default\n * (`shouldMergeAdjacentLines = true`), whereas upstream defaults to `false`.\n * - The default transformer set excludes the upstream `CODE` and `LINK`\n * transformers, since Payload provides those as features with its own node\n * types.\n * - Markdown is normalized with Payload's own `normalizeMarkdown` (handles\n * nested code fences and preserves table-row whitespace) instead of the\n * upstream normalizer, which is not exported and lacks those behaviors.\n */\nimport type { ElementNode } from 'lexical'\n\nimport {\n $convertFromMarkdownString as $convertFromMarkdownStringUpstream,\n $convertToMarkdownString as $convertToMarkdownStringUpstream,\n BOLD_ITALIC_STAR,\n BOLD_ITALIC_UNDERSCORE,\n BOLD_STAR,\n BOLD_UNDERSCORE,\n type ElementTransformer,\n HEADING,\n HIGHLIGHT,\n INLINE_CODE,\n ITALIC_STAR,\n ITALIC_UNDERSCORE,\n type MultilineElementTransformer,\n ORDERED_LIST,\n QUOTE,\n STRIKETHROUGH,\n type TextFormatTransformer,\n type TextMatchTransformer,\n type Transformer,\n UNORDERED_LIST,\n} from '@lexical/markdown'\n\nimport { normalizeMarkdown } from '../lexical/utils/markdown/normalizeMarkdown.js'\n\nconst ELEMENT_TRANSFORMERS: Array<ElementTransformer> = [\n HEADING,\n QUOTE,\n UNORDERED_LIST,\n ORDERED_LIST,\n]\n\nconst MULTILINE_ELEMENT_TRANSFORMERS: Array<MultilineElementTransformer> = []\n\n// Order of text format transformers matters:\n//\n// - code should go first as it prevents any transformations inside\n// - then longer tags match (e.g. ** or __ should go before * or _)\nconst TEXT_FORMAT_TRANSFORMERS: Array<TextFormatTransformer> = [\n INLINE_CODE,\n BOLD_ITALIC_STAR,\n BOLD_ITALIC_UNDERSCORE,\n BOLD_STAR,\n BOLD_UNDERSCORE,\n HIGHLIGHT,\n ITALIC_STAR,\n ITALIC_UNDERSCORE,\n STRIKETHROUGH,\n]\n\nconst TEXT_MATCH_TRANSFORMERS: Array<TextMatchTransformer> = []\n\nconst TRANSFORMERS: Array<Transformer> = [\n ...ELEMENT_TRANSFORMERS,\n ...MULTILINE_ELEMENT_TRANSFORMERS,\n ...TEXT_FORMAT_TRANSFORMERS,\n ...TEXT_MATCH_TRANSFORMERS,\n]\n\n/**\n * Renders markdown from a string. The selection is moved to the start after the operation.\n *\n * @param {boolean} [shouldPreserveNewLines] By setting this to true, new lines will be preserved between conversions\n * @param {boolean} [shouldMergeAdjacentLines] By setting this to true, adjacent non empty lines will be merged according to commonmark spec: https://spec.commonmark.org/0.24/#example-177. Not applicable if shouldPreserveNewLines = true.\n */\nfunction $convertFromMarkdownString(\n markdown: string,\n transformers: Array<Transformer> = TRANSFORMERS,\n node?: ElementNode,\n shouldPreserveNewLines = false,\n shouldMergeAdjacentLines = true,\n): void {\n if (shouldPreserveNewLines) {\n return $convertFromMarkdownStringUpstream(markdown, transformers, node, true)\n }\n\n // Normalize with Payload's normalizer, then let upstream import the result.\n // Passing shouldMergeAdjacentLines = false stops upstream's internal\n // normalizer from re-merging the already normalized markdown; for non empty\n // lines it preserves trailing whitespace and hard line breaks, so the only\n // observable difference is that whitespace-only lines collapse to empty.\n const sanitizedMarkdown = normalizeMarkdown(markdown, shouldMergeAdjacentLines)\n return $convertFromMarkdownStringUpstream(sanitizedMarkdown, transformers, node, false, false)\n}\n\n/**\n * Renders string from markdown. The selection is moved to the start after the operation.\n */\nfunction $convertToMarkdownString(\n transformers: Array<Transformer> = TRANSFORMERS,\n node?: ElementNode,\n shouldPreserveNewLines: boolean = false,\n): string {\n return $convertToMarkdownStringUpstream(transformers, node, shouldPreserveNewLines)\n}\n\nexport {\n BOLD_ITALIC_STAR,\n BOLD_ITALIC_UNDERSCORE,\n BOLD_STAR,\n BOLD_UNDERSCORE,\n CHECK_LIST,\n type ElementTransformer,\n HEADING,\n HIGHLIGHT,\n INLINE_CODE,\n ITALIC_STAR,\n ITALIC_UNDERSCORE,\n type MultilineElementTransformer,\n ORDERED_LIST,\n QUOTE,\n registerMarkdownShortcuts,\n STRIKETHROUGH,\n type TextFormatTransformer,\n type TextMatchTransformer,\n type Transformer,\n UNORDERED_LIST,\n} from '@lexical/markdown'\n\nexport {\n $convertFromMarkdownString,\n $convertToMarkdownString,\n ELEMENT_TRANSFORMERS,\n MULTILINE_ELEMENT_TRANSFORMERS,\n TEXT_FORMAT_TRANSFORMERS,\n TEXT_MATCH_TRANSFORMERS,\n TRANSFORMERS,\n}\n"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAsBA,SACEA,0BAAA,IAA8BC,kCAAkC,EAChEC,wBAAA,IAA4BC,gCAAgC,EAC5DC,gBAAgB,EAChBC,sBAAsB,EACtBC,SAAS,EACTC,eAAe,EAEfC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,iBAAiB,EAEjBC,YAAY,EACZ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K,EACLgB,yBAAyB,EACzBf,aAAa,EAIbC,cAAc,QACT;AAEP,SACEhB,0BAA0B,EAC1BE,wBAAwB,EACxBgB,oBAAoB,EACpBC,8BAA8B,EAC9BC,wBAAwB,EACxBC,uBAAuB,EACvBC,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"@lexical-markdown.js","names":[],"sources":["../../src/lexical-proxy/@lexical-markdown.ts"],"sourcesContent":["export * from '../packages/@lexical/markdown/index.js'\n"],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from '@lexical/react/LexicalContextMenuPlugin';
2
+ //# sourceMappingURL=LexicalContextMenuPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LexicalContextMenuPlugin.d.ts","sourceRoot":"","sources":["../../../src/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.tsx"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from '@lexical/react/LexicalContextMenuPlugin';
2
+ //# sourceMappingURL=LexicalContextMenuPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LexicalContextMenuPlugin.js","names":[],"sources":["../../../src/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.tsx"],"sourcesContent":["export * from '@lexical/react/LexicalContextMenuPlugin'\n"],"mappings":"AAAA,cAAc","ignoreList":[]}