@payloadcms/richtext-lexical 4.0.0-canary.2 → 4.0.0-canary.4

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 (261) hide show
  1. package/dist/exports/client/Field-XH5C4HFU.js +2 -0
  2. package/dist/exports/client/Field-XH5C4HFU.js.map +7 -0
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/chunk-X3D4LZS7.js +2 -0
  5. package/dist/exports/client/chunk-X3D4LZS7.js.map +7 -0
  6. package/dist/exports/client/index.d.ts +0 -1
  7. package/dist/exports/client/index.d.ts.map +1 -1
  8. package/dist/exports/client/index.js +19 -20
  9. package/dist/exports/client/index.js.map +4 -4
  10. package/dist/features/blockquote/client/index.js +2 -2
  11. package/dist/features/blockquote/client/index.js.map +1 -1
  12. package/dist/features/blockquote/server/index.js +2 -2
  13. package/dist/features/blockquote/server/index.js.map +1 -1
  14. package/dist/features/blocks/client/component/index.css +2 -2
  15. package/dist/features/blocks/client/componentInline/index.css +8 -8
  16. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +1 -1
  17. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -1
  18. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -1
  19. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
  20. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +1 -1
  21. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -1
  22. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +5 -2
  23. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -1
  24. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +1 -2
  25. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -1
  26. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
  27. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.css +1 -1
  28. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.css +2 -4
  29. package/dist/features/blocks/premade/CodeBlock/Component/index.css +5 -5
  30. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +1 -1
  31. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -1
  32. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
  33. package/dist/features/converters/lexicalToMarkdown/index.d.ts.map +1 -1
  34. package/dist/features/converters/lexicalToMarkdown/index.js +1 -1
  35. package/dist/features/converters/lexicalToMarkdown/index.js.map +1 -1
  36. package/dist/features/converters/markdownToLexical/index.d.ts.map +1 -1
  37. package/dist/features/converters/markdownToLexical/index.js +5 -2
  38. package/dist/features/converters/markdownToLexical/index.js.map +1 -1
  39. package/dist/features/debug/jsxConverter/client/plugin/style.css +2 -2
  40. package/dist/features/experimental_table/client/index.js +2 -2
  41. package/dist/features/experimental_table/client/index.js.map +1 -1
  42. package/dist/features/experimental_table/markdownTransformer.d.ts +2 -2
  43. package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -1
  44. package/dist/features/experimental_table/markdownTransformer.js +6 -3
  45. package/dist/features/experimental_table/markdownTransformer.js.map +1 -1
  46. package/dist/features/experimental_table/server/index.js +2 -2
  47. package/dist/features/experimental_table/server/index.js.map +1 -1
  48. package/dist/features/format/bold/feature.client.js +1 -1
  49. package/dist/features/format/bold/feature.client.js.map +1 -1
  50. package/dist/features/format/bold/feature.server.d.ts.map +1 -1
  51. package/dist/features/format/bold/feature.server.js +1 -1
  52. package/dist/features/format/bold/feature.server.js.map +1 -1
  53. package/dist/features/format/inlineCode/feature.client.js +1 -1
  54. package/dist/features/format/inlineCode/feature.client.js.map +1 -1
  55. package/dist/features/format/inlineCode/feature.server.d.ts.map +1 -1
  56. package/dist/features/format/inlineCode/feature.server.js +1 -1
  57. package/dist/features/format/inlineCode/feature.server.js.map +1 -1
  58. package/dist/features/format/italic/feature.client.js +1 -1
  59. package/dist/features/format/italic/feature.client.js.map +1 -1
  60. package/dist/features/format/italic/feature.server.d.ts.map +1 -1
  61. package/dist/features/format/italic/feature.server.js +1 -1
  62. package/dist/features/format/italic/feature.server.js.map +1 -1
  63. package/dist/features/format/strikethrough/feature.client.js +1 -1
  64. package/dist/features/format/strikethrough/feature.client.js.map +1 -1
  65. package/dist/features/format/strikethrough/feature.server.d.ts.map +1 -1
  66. package/dist/features/format/strikethrough/feature.server.js +1 -1
  67. package/dist/features/format/strikethrough/feature.server.js.map +1 -1
  68. package/dist/features/heading/client/index.js +2 -2
  69. package/dist/features/heading/client/index.js.map +1 -1
  70. package/dist/features/heading/markdownTransformer.d.ts +2 -2
  71. package/dist/features/heading/markdownTransformer.d.ts.map +1 -1
  72. package/dist/features/heading/markdownTransformer.js +6 -19
  73. package/dist/features/heading/markdownTransformer.js.map +1 -1
  74. package/dist/features/heading/server/index.js +2 -2
  75. package/dist/features/heading/server/index.js.map +1 -1
  76. package/dist/features/horizontalRule/client/index.js +2 -2
  77. package/dist/features/horizontalRule/client/index.js.map +1 -1
  78. package/dist/features/horizontalRule/client/markdownTransformer.d.ts +2 -2
  79. package/dist/features/horizontalRule/client/markdownTransformer.d.ts.map +1 -1
  80. package/dist/features/horizontalRule/client/markdownTransformer.js +1 -1
  81. package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
  82. package/dist/features/horizontalRule/client/plugin/index.css +2 -2
  83. package/dist/features/horizontalRule/server/index.js +2 -2
  84. package/dist/features/horizontalRule/server/index.js.map +1 -1
  85. package/dist/features/horizontalRule/server/markdownTransformer.d.ts +2 -2
  86. package/dist/features/horizontalRule/server/markdownTransformer.d.ts.map +1 -1
  87. package/dist/features/horizontalRule/server/markdownTransformer.js +1 -1
  88. package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
  89. package/dist/features/link/client/index.js +2 -2
  90. package/dist/features/link/client/index.js.map +1 -1
  91. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +3 -3
  92. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  93. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +7 -11
  94. package/dist/features/link/markdownTransformer.d.ts +4 -4
  95. package/dist/features/link/markdownTransformer.d.ts.map +1 -1
  96. package/dist/features/link/markdownTransformer.js +2 -2
  97. package/dist/features/link/markdownTransformer.js.map +1 -1
  98. package/dist/features/link/markdownTransformer.spec.js +10 -10
  99. package/dist/features/link/markdownTransformer.spec.js.map +1 -1
  100. package/dist/features/link/server/index.js +2 -2
  101. package/dist/features/link/server/index.js.map +1 -1
  102. package/dist/features/lists/checklist/client/index.js +1 -1
  103. package/dist/features/lists/checklist/client/index.js.map +1 -1
  104. package/dist/features/lists/checklist/server/index.js +1 -1
  105. package/dist/features/lists/checklist/server/index.js.map +1 -1
  106. package/dist/features/lists/orderedList/client/index.js +1 -1
  107. package/dist/features/lists/orderedList/client/index.js.map +1 -1
  108. package/dist/features/lists/orderedList/server/index.js +1 -1
  109. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  110. package/dist/features/lists/unorderedList/client/index.js +1 -1
  111. package/dist/features/lists/unorderedList/client/index.js.map +1 -1
  112. package/dist/features/lists/unorderedList/server/index.js +1 -1
  113. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  114. package/dist/features/textState/feature.client.js +1 -1
  115. package/dist/features/textState/feature.client.js.map +1 -1
  116. package/dist/features/toolbars/fixed/client/Toolbar/index.css +2 -2
  117. package/dist/features/toolbars/inline/client/Toolbar/index.css +2 -13
  118. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +8 -12
  119. package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -1
  120. package/dist/features/toolbars/shared/useToolbarStates.js +3 -1
  121. package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -1
  122. package/dist/features/typesClient.d.ts +1 -1
  123. package/dist/features/typesClient.d.ts.map +1 -1
  124. package/dist/features/typesClient.js.map +1 -1
  125. package/dist/features/typesServer.d.ts +1 -1
  126. package/dist/features/typesServer.d.ts.map +1 -1
  127. package/dist/features/typesServer.js.map +1 -1
  128. package/dist/features/upload/client/component/index.css +9 -9
  129. package/dist/features/upload/client/plugin/index.js +5 -5
  130. package/dist/features/upload/client/plugin/index.js.map +1 -1
  131. package/dist/features/upload/server/index.js +2 -2
  132. package/dist/features/upload/server/index.js.map +1 -1
  133. package/dist/features/upload/server/markdownTransformer.d.ts +2 -2
  134. package/dist/features/upload/server/markdownTransformer.d.ts.map +1 -1
  135. package/dist/features/upload/server/markdownTransformer.js +1 -1
  136. package/dist/features/upload/server/markdownTransformer.js.map +1 -1
  137. package/dist/field/Diff/converters/unknown/index.css +1 -1
  138. package/dist/field/Field.js +1 -1
  139. package/dist/field/Field.js.map +1 -1
  140. package/dist/field/ViewSelector.css +1 -1
  141. package/dist/field/bundled.css +1 -1
  142. package/dist/field/index.css +5 -9
  143. package/dist/index.d.ts +2 -2
  144. package/dist/index.d.ts.map +1 -1
  145. package/dist/index.js +3 -3
  146. package/dist/index.js.map +1 -1
  147. package/dist/lexical/LexicalEditor.css +2 -2
  148. package/dist/lexical/plugins/DecoratorPlugin/index.css +1 -1
  149. package/dist/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  150. package/dist/lexical/plugins/MarkdownShortcut/index.js +1 -1
  151. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  152. package/dist/lexical/plugins/SlashMenu/index.css +1 -5
  153. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -1
  154. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +3 -3
  155. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +1 -1
  156. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  157. package/dist/lexical/theme/EditorTheme.css +18 -19
  158. package/dist/lexical/ui/ContentEditable.css +5 -5
  159. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts +17 -0
  160. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts.map +1 -0
  161. package/dist/lexical/utils/markdown/convertFromMarkdownString.js +27 -0
  162. package/dist/lexical/utils/markdown/convertFromMarkdownString.js.map +1 -0
  163. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js +88 -0
  164. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js.map +1 -0
  165. package/dist/lexical/utils/markdown/createBlockNode.d.ts +1 -1
  166. package/dist/lexical/utils/markdown/createBlockNode.d.ts.map +1 -1
  167. package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
  168. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts +25 -0
  169. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts.map +1 -0
  170. package/dist/lexical/utils/markdown/normalizeMarkdown.js +91 -0
  171. package/dist/lexical/utils/markdown/normalizeMarkdown.js.map +1 -0
  172. package/dist/lexical-proxy/@lexical-markdown.d.ts +1 -1
  173. package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
  174. package/dist/lexical-proxy/@lexical-markdown.js +1 -1
  175. package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
  176. package/dist/utilities/fieldsDrawer/index.css +0 -4
  177. package/package.json +21 -25
  178. package/dist/exports/client/Field-G5Z2HM5Y.js +0 -2
  179. package/dist/exports/client/Field-G5Z2HM5Y.js.map +0 -7
  180. package/dist/exports/client/chunk-LH634DPU.js +0 -12
  181. package/dist/exports/client/chunk-LH634DPU.js.map +0 -7
  182. package/dist/features/blockquote/markdownTransformer.d.ts +0 -3
  183. package/dist/features/blockquote/markdownTransformer.d.ts.map +0 -1
  184. package/dist/features/blockquote/markdownTransformer.js +0 -33
  185. package/dist/features/blockquote/markdownTransformer.js.map +0 -1
  186. package/dist/features/format/bold/markdownTransformers.d.ts +0 -6
  187. package/dist/features/format/bold/markdownTransformers.d.ts.map +0 -1
  188. package/dist/features/format/bold/markdownTransformers.js +0 -23
  189. package/dist/features/format/bold/markdownTransformers.js.map +0 -1
  190. package/dist/features/format/inlineCode/markdownTransformers.d.ts +0 -3
  191. package/dist/features/format/inlineCode/markdownTransformers.d.ts.map +0 -1
  192. package/dist/features/format/inlineCode/markdownTransformers.js +0 -6
  193. package/dist/features/format/inlineCode/markdownTransformers.js.map +0 -1
  194. package/dist/features/format/italic/markdownTransformers.d.ts +0 -4
  195. package/dist/features/format/italic/markdownTransformers.d.ts.map +0 -1
  196. package/dist/features/format/italic/markdownTransformers.js +0 -12
  197. package/dist/features/format/italic/markdownTransformers.js.map +0 -1
  198. package/dist/features/format/strikethrough/markdownTransformers.d.ts +0 -3
  199. package/dist/features/format/strikethrough/markdownTransformers.d.ts.map +0 -1
  200. package/dist/features/format/strikethrough/markdownTransformers.js +0 -6
  201. package/dist/features/format/strikethrough/markdownTransformers.js.map +0 -1
  202. package/dist/features/lists/checklist/markdownTransformers.d.ts +0 -3
  203. package/dist/features/lists/checklist/markdownTransformers.d.ts.map +0 -1
  204. package/dist/features/lists/checklist/markdownTransformers.js +0 -12
  205. package/dist/features/lists/checklist/markdownTransformers.js.map +0 -1
  206. package/dist/features/lists/orderedList/markdownTransformer.d.ts +0 -3
  207. package/dist/features/lists/orderedList/markdownTransformer.d.ts.map +0 -1
  208. package/dist/features/lists/orderedList/markdownTransformer.js +0 -12
  209. package/dist/features/lists/orderedList/markdownTransformer.js.map +0 -1
  210. package/dist/features/lists/shared/markdown.d.ts +0 -6
  211. package/dist/features/lists/shared/markdown.d.ts.map +0 -1
  212. package/dist/features/lists/shared/markdown.js +0 -57
  213. package/dist/features/lists/shared/markdown.js.map +0 -1
  214. package/dist/features/lists/unorderedList/markdownTransformer.d.ts +0 -3
  215. package/dist/features/lists/unorderedList/markdownTransformer.d.ts.map +0 -1
  216. package/dist/features/lists/unorderedList/markdownTransformer.js +0 -12
  217. package/dist/features/lists/unorderedList/markdownTransformer.js.map +0 -1
  218. package/dist/lexical/utils/guard.d.ts +0 -5
  219. package/dist/lexical/utils/guard.d.ts.map +0 -1
  220. package/dist/lexical/utils/guard.js +0 -9
  221. package/dist/lexical/utils/guard.js.map +0 -1
  222. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +0 -2
  223. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +0 -1
  224. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +0 -2
  225. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +0 -1
  226. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +0 -14
  227. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +0 -1
  228. package/dist/packages/@lexical/markdown/MarkdownExport.js +0 -213
  229. package/dist/packages/@lexical/markdown/MarkdownExport.js.map +0 -1
  230. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +0 -19
  231. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +0 -1
  232. package/dist/packages/@lexical/markdown/MarkdownImport.js +0 -198
  233. package/dist/packages/@lexical/markdown/MarkdownImport.js.map +0 -1
  234. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +0 -11
  235. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +0 -1
  236. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +0 -304
  237. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +0 -1
  238. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +0 -147
  239. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +0 -1
  240. package/dist/packages/@lexical/markdown/MarkdownTransformers.js +0 -268
  241. package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +0 -1
  242. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +0 -22
  243. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +0 -1
  244. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +0 -91
  245. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +0 -1
  246. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +0 -21
  247. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +0 -1
  248. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +0 -54
  249. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +0 -1
  250. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +0 -18
  251. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +0 -1
  252. package/dist/packages/@lexical/markdown/importTextTransformers.js +0 -54
  253. package/dist/packages/@lexical/markdown/importTextTransformers.js.map +0 -1
  254. package/dist/packages/@lexical/markdown/index.d.ts +0 -29
  255. package/dist/packages/@lexical/markdown/index.d.ts.map +0 -1
  256. package/dist/packages/@lexical/markdown/index.js +0 -39
  257. package/dist/packages/@lexical/markdown/index.js.map +0 -1
  258. package/dist/packages/@lexical/markdown/utils.d.ts +0 -34
  259. package/dist/packages/@lexical/markdown/utils.d.ts.map +0 -1
  260. package/dist/packages/@lexical/markdown/utils.js +0 -267
  261. package/dist/packages/@lexical/markdown/utils.js.map +0 -1
@@ -7,8 +7,8 @@
7
7
  outline: 0;
8
8
  padding-top: var(--spacer-2);
9
9
  padding-bottom: var(--spacer-2);
10
- padding-left: 0;
11
- padding-right: 0;
10
+ padding-inline-start: 0;
11
+ padding-inline-end: 0;
12
12
 
13
13
  &:focus-visible {
14
14
  outline: none !important;
@@ -37,7 +37,7 @@
37
37
  > .editor-scroller
38
38
  > .editor
39
39
  > .ContentEditable__root::before {
40
- border-left: 2px solid var(--color-border-danger);
40
+ border-inline-start: var(--stroke-width-medium) solid var(--color-border-danger);
41
41
  }
42
42
  }
43
43
 
@@ -47,7 +47,7 @@
47
47
  > .editor-scroller
48
48
  > .editor
49
49
  > .ContentEditable__root::before {
50
- border-left: 2px solid var(--color-border-danger);
50
+ border-inline-start: var(--stroke-width-medium) solid var(--color-border-danger);
51
51
  }
52
52
  }
53
53
  }
@@ -72,7 +72,7 @@
72
72
  > .editor-scroller
73
73
  > .editor
74
74
  > .ContentEditable__root::before {
75
- border-left: 2px solid var(--color-border-danger);
75
+ border-inline-start: var(--stroke-width-medium) solid var(--color-border-danger);
76
76
  }
77
77
  }
78
78
  }
@@ -0,0 +1,17 @@
1
+ import type { Transformer } from '@lexical/markdown';
2
+ import type { ElementNode } from 'lexical';
3
+ /**
4
+ * Payload's markdown import. Wraps `@lexical/markdown`'s `$convertFromMarkdownString`
5
+ * with Payload's `normalizeMarkdown` preprocessing (nested code fences + table-row
6
+ * whitespace handling).
7
+ *
8
+ * TODO: Remove this wrapper and the `normalizeMarkdown` import once
9
+ * https://github.com/facebook/lexical/pull/8734 is merged and we upgrade to a
10
+ * release that includes it. At that point callers can use `@lexical/markdown`'s
11
+ * `$convertFromMarkdownString` directly.
12
+ *
13
+ * @param shouldPreserveNewLines By setting this to true, new lines will be preserved between conversions.
14
+ * @param 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.
15
+ */
16
+ export declare function $convertFromMarkdownString(markdown: string, transformers?: Array<Transformer>, node?: ElementNode, shouldPreserveNewLines?: boolean, shouldMergeAdjacentLines?: boolean): void;
17
+ //# sourceMappingURL=convertFromMarkdownString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertFromMarkdownString.d.ts","sourceRoot":"","sources":["../../../../src/lexical/utils/markdown/convertFromMarkdownString.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAU1C;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,KAAK,CAAC,WAAW,CAAgB,EAC/C,IAAI,CAAC,EAAE,WAAW,EAClB,sBAAsB,UAAQ,EAC9B,wBAAwB,UAAQ,GAC/B,IAAI,CASN"}
@@ -0,0 +1,27 @@
1
+ import { $convertFromMarkdownString as $convertFromMarkdownStringUpstream,
2
+ // eslint-disable-next-line payload/no-conflicting-lexical-markdown-imports -- this wrapper intentionally uses upstream's default transformer set
3
+ TRANSFORMERS } from '@lexical/markdown';
4
+ import { normalizeMarkdown } from './normalizeMarkdown.js';
5
+ /**
6
+ * Payload's markdown import. Wraps `@lexical/markdown`'s `$convertFromMarkdownString`
7
+ * with Payload's `normalizeMarkdown` preprocessing (nested code fences + table-row
8
+ * whitespace handling).
9
+ *
10
+ * TODO: Remove this wrapper and the `normalizeMarkdown` import once
11
+ * https://github.com/facebook/lexical/pull/8734 is merged and we upgrade to a
12
+ * release that includes it. At that point callers can use `@lexical/markdown`'s
13
+ * `$convertFromMarkdownString` directly.
14
+ *
15
+ * @param shouldPreserveNewLines By setting this to true, new lines will be preserved between conversions.
16
+ * @param 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.
17
+ */
18
+ export function $convertFromMarkdownString(markdown, transformers = TRANSFORMERS, node, shouldPreserveNewLines = false, shouldMergeAdjacentLines = false) {
19
+ if (shouldPreserveNewLines) {
20
+ return $convertFromMarkdownStringUpstream(markdown, transformers, node, true);
21
+ }
22
+ // Passing shouldMergeAdjacentLines = false to upstream stops it from
23
+ // re-normalizing markdown that normalizeMarkdown has already normalized.
24
+ const sanitizedMarkdown = normalizeMarkdown(markdown, shouldMergeAdjacentLines);
25
+ return $convertFromMarkdownStringUpstream(sanitizedMarkdown, transformers, node, false, false);
26
+ }
27
+ //# sourceMappingURL=convertFromMarkdownString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertFromMarkdownString.js","names":["$convertFromMarkdownString","$convertFromMarkdownStringUpstream","TRANSFORMERS","normalizeMarkdown","markdown","transformers","node","shouldPreserveNewLines","shouldMergeAdjacentLines","sanitizedMarkdown"],"sources":["../../../../src/lexical/utils/markdown/convertFromMarkdownString.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport type { ElementNode } from 'lexical'\n\nimport {\n $convertFromMarkdownString as $convertFromMarkdownStringUpstream,\n // eslint-disable-next-line payload/no-conflicting-lexical-markdown-imports -- this wrapper intentionally uses upstream's default transformer set\n TRANSFORMERS,\n} from '@lexical/markdown'\n\nimport { normalizeMarkdown } from './normalizeMarkdown.js'\n\n/**\n * Payload's markdown import. Wraps `@lexical/markdown`'s `$convertFromMarkdownString`\n * with Payload's `normalizeMarkdown` preprocessing (nested code fences + table-row\n * whitespace handling).\n *\n * TODO: Remove this wrapper and the `normalizeMarkdown` import once\n * https://github.com/facebook/lexical/pull/8734 is merged and we upgrade to a\n * release that includes it. At that point callers can use `@lexical/markdown`'s\n * `$convertFromMarkdownString` directly.\n *\n * @param shouldPreserveNewLines By setting this to true, new lines will be preserved between conversions.\n * @param 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 */\nexport function $convertFromMarkdownString(\n markdown: string,\n transformers: Array<Transformer> = TRANSFORMERS,\n node?: ElementNode,\n shouldPreserveNewLines = false,\n shouldMergeAdjacentLines = false,\n): void {\n if (shouldPreserveNewLines) {\n return $convertFromMarkdownStringUpstream(markdown, transformers, node, true)\n }\n\n // Passing shouldMergeAdjacentLines = false to upstream stops it from\n // re-normalizing markdown that normalizeMarkdown has already normalized.\n const sanitizedMarkdown = normalizeMarkdown(markdown, shouldMergeAdjacentLines)\n return $convertFromMarkdownStringUpstream(sanitizedMarkdown, transformers, node, false, false)\n}\n"],"mappings":"AAGA,SACEA,0BAAA,IAA8BC,kCAAkC;AAEhE;AAAAC,YAAY,QACP;AAEP,SAASC,iBAAiB,QAAQ;AAElC;;;;;;;;;;;;;AAaA,OAAO,SAASH,2BACdI,QAAgB,EAChBC,YAAA,GAAmCH,YAAY,EAC/CI,IAAkB,EAClBC,sBAAA,GAAyB,KAAK,EAC9BC,wBAAA,GAA2B,KAAK;EAEhC,IAAID,sBAAA,EAAwB;IAC1B,OAAON,kCAAA,CAAmCG,QAAA,EAAUC,YAAA,EAAcC,IAAA,EAAM;EAC1E;EAEA;EACA;EACA,MAAMG,iBAAA,GAAoBN,iBAAA,CAAkBC,QAAA,EAAUI,wBAAA;EACtD,OAAOP,kCAAA,CAAmCQ,iBAAA,EAAmBJ,YAAA,EAAcC,IAAA,EAAM,OAAO;AAC1F","ignoreList":[]}
@@ -0,0 +1,88 @@
1
+ import { createHeadlessEditor } from '@lexical/headless';
2
+ import { LinkNode } from '@lexical/link';
3
+ import { ListItemNode, ListNode } from '@lexical/list';
4
+ import { $convertToMarkdownString } from '@lexical/markdown';
5
+ import { HeadingNode, QuoteNode } from '@lexical/rich-text';
6
+ import { $getRoot, $isElementNode, $isLineBreakNode } from 'lexical';
7
+ import { describe, expect, it } from 'vitest';
8
+ import { $convertFromMarkdownString } from './convertFromMarkdownString.js';
9
+ function createEditor() {
10
+ return createHeadlessEditor({
11
+ nodes: [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode]
12
+ });
13
+ }
14
+ // Payload's editor imports markdown with shouldMergeAdjacentLines = true, so the
15
+ // specs exercise that path: hard line breaks must survive even when adjacent lines
16
+ // are merged, while soft wraps collapse to a single space.
17
+ function importMarkdown(markdown) {
18
+ const editor = createEditor();
19
+ editor.update(() => $convertFromMarkdownString(markdown, undefined, undefined, false, true), {
20
+ discrete: true
21
+ });
22
+ let result = {
23
+ hasLineBreak: false,
24
+ textContent: ''
25
+ };
26
+ editor.getEditorState().read(() => {
27
+ const firstChild = $getRoot().getFirstChild();
28
+ if (!$isElementNode(firstChild)) {
29
+ throw new Error('Expected an element block');
30
+ }
31
+ result = {
32
+ hasLineBreak: firstChild.getChildren().some(child => $isLineBreakNode(child)),
33
+ textContent: firstChild.getTextContent()
34
+ };
35
+ });
36
+ return result;
37
+ }
38
+ function roundTrip(markdown) {
39
+ const editor = createEditor();
40
+ editor.update(() => $convertFromMarkdownString(markdown, undefined, undefined, false, true), {
41
+ discrete: true
42
+ });
43
+ let output = '';
44
+ editor.getEditorState().read(() => {
45
+ output = $convertToMarkdownString();
46
+ });
47
+ return output;
48
+ }
49
+ describe('markdown hard line break import', () => {
50
+ it('should import a trailing-space hard break as a line break node with the marker stripped', () => {
51
+ const {
52
+ hasLineBreak,
53
+ textContent
54
+ } = importMarkdown(['foo ', 'bar'].join('\n'));
55
+ expect(hasLineBreak).toBe(true);
56
+ expect(textContent).toBe('foo\nbar');
57
+ });
58
+ it('should import a backslash hard break as a line break node with the marker stripped', () => {
59
+ const {
60
+ hasLineBreak,
61
+ textContent
62
+ } = importMarkdown('foo\\\nbar');
63
+ expect(hasLineBreak).toBe(true);
64
+ expect(textContent).toBe('foo\nbar');
65
+ });
66
+ });
67
+ describe('markdown hard line break round trip', () => {
68
+ it('should round trip a trailing-space hard break', () => {
69
+ const md = ['foo ', 'bar'].join('\n');
70
+ expect(roundTrip(md)).toBe(md);
71
+ });
72
+ it('should round trip a backslash hard break', () => {
73
+ const md = 'foo\\\nbar';
74
+ expect(roundTrip(md)).toBe(md);
75
+ });
76
+ it('should not introduce a hard break for a soft wrap', () => {
77
+ expect(roundTrip(['foo', 'bar'].join('\n'))).toBe('foo bar');
78
+ });
79
+ it('should round trip a hard break after formatted text', () => {
80
+ const md = '**foo** \nbar';
81
+ expect(roundTrip(md)).toBe(md);
82
+ });
83
+ it('should round trip a hard break after a link', () => {
84
+ const md = '[foo](https://payloadcms.com) \nbar';
85
+ expect(roundTrip(md)).toBe(md);
86
+ });
87
+ });
88
+ //# sourceMappingURL=convertFromMarkdownString.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertFromMarkdownString.spec.js","names":["createHeadlessEditor","LinkNode","ListItemNode","ListNode","$convertToMarkdownString","HeadingNode","QuoteNode","$getRoot","$isElementNode","$isLineBreakNode","describe","expect","it","$convertFromMarkdownString","createEditor","nodes","importMarkdown","markdown","editor","update","undefined","discrete","result","hasLineBreak","textContent","getEditorState","read","firstChild","getFirstChild","Error","getChildren","some","child","getTextContent","roundTrip","output","join","toBe","md"],"sources":["../../../../src/lexical/utils/markdown/convertFromMarkdownString.spec.ts"],"sourcesContent":["import { createHeadlessEditor } from '@lexical/headless'\nimport { LinkNode } from '@lexical/link'\nimport { ListItemNode, ListNode } from '@lexical/list'\nimport { $convertToMarkdownString } from '@lexical/markdown'\nimport { HeadingNode, QuoteNode } from '@lexical/rich-text'\nimport { $getRoot, $isElementNode, $isLineBreakNode } from 'lexical'\nimport { describe, expect, it } from 'vitest'\n\nimport { $convertFromMarkdownString } from './convertFromMarkdownString.js'\n\nfunction createEditor() {\n return createHeadlessEditor({\n nodes: [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode],\n })\n}\n\n// Payload's editor imports markdown with shouldMergeAdjacentLines = true, so the\n// specs exercise that path: hard line breaks must survive even when adjacent lines\n// are merged, while soft wraps collapse to a single space.\nfunction importMarkdown(markdown: string): { hasLineBreak: boolean; textContent: string } {\n const editor = createEditor()\n editor.update(() => $convertFromMarkdownString(markdown, undefined, undefined, false, true), {\n discrete: true,\n })\n let result = { hasLineBreak: false, textContent: '' }\n editor.getEditorState().read(() => {\n const firstChild = $getRoot().getFirstChild()\n if (!$isElementNode(firstChild)) {\n throw new Error('Expected an element block')\n }\n result = {\n hasLineBreak: firstChild.getChildren().some((child) => $isLineBreakNode(child)),\n textContent: firstChild.getTextContent(),\n }\n })\n return result\n}\n\nfunction roundTrip(markdown: string): string {\n const editor = createEditor()\n editor.update(() => $convertFromMarkdownString(markdown, undefined, undefined, false, true), {\n discrete: true,\n })\n let output = ''\n editor.getEditorState().read(() => {\n output = $convertToMarkdownString()\n })\n return output\n}\n\ndescribe('markdown hard line break import', () => {\n it('should import a trailing-space hard break as a line break node with the marker stripped', () => {\n const { hasLineBreak, textContent } = importMarkdown(['foo ', 'bar'].join('\\n'))\n\n expect(hasLineBreak).toBe(true)\n expect(textContent).toBe('foo\\nbar')\n })\n\n it('should import a backslash hard break as a line break node with the marker stripped', () => {\n const { hasLineBreak, textContent } = importMarkdown('foo\\\\\\nbar')\n\n expect(hasLineBreak).toBe(true)\n expect(textContent).toBe('foo\\nbar')\n })\n})\n\ndescribe('markdown hard line break round trip', () => {\n it('should round trip a trailing-space hard break', () => {\n const md = ['foo ', 'bar'].join('\\n')\n expect(roundTrip(md)).toBe(md)\n })\n\n it('should round trip a backslash hard break', () => {\n const md = 'foo\\\\\\nbar'\n expect(roundTrip(md)).toBe(md)\n })\n\n it('should not introduce a hard break for a soft wrap', () => {\n expect(roundTrip(['foo', 'bar'].join('\\n'))).toBe('foo bar')\n })\n\n it('should round trip a hard break after formatted text', () => {\n const md = '**foo** \\nbar'\n expect(roundTrip(md)).toBe(md)\n })\n\n it('should round trip a hard break after a link', () => {\n const md = '[foo](https://payloadcms.com) \\nbar'\n expect(roundTrip(md)).toBe(md)\n })\n})\n"],"mappings":"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","ignoreList":[]}
@@ -1,4 +1,4 @@
1
+ import type { ElementTransformer } from '@lexical/markdown';
1
2
  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,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
+ {"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 +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 { 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
+ {"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":[]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Payload-specific markdown normalization, run by `$convertFromMarkdownString`
3
+ * before delegating the import to `@lexical/markdown`. Handles nested code
4
+ * fences and preserves table-row whitespace.
5
+ *
6
+ * TODO: Remove this file once https://github.com/facebook/lexical/pull/8734 is
7
+ * merged and we upgrade to a release that includes it. That PR fixes the nested
8
+ * code fence handling upstream, so `$convertFromMarkdownString` can call
9
+ * `@lexical/markdown` directly instead of pre-normalizing here.
10
+ */
11
+ /**
12
+ * Represents a CommonMark hard line break marker: either a trailing backslash
13
+ * or two-or-more trailing spaces.
14
+ *
15
+ * See https://spec.commonmark.org/0.31.2/#hard-line-breaks
16
+ */
17
+ export type MarkdownHardLineBreak = string;
18
+ /**
19
+ * Detects a CommonMark hard line break marker at the end of a raw line.
20
+ *
21
+ * @returns a tuple of `[textWithoutMarker, marker]` when a marker is found, otherwise null.
22
+ */
23
+ export declare function parseMarkdownHardLineBreak(line: string): [string, MarkdownHardLineBreak] | null;
24
+ export declare function normalizeMarkdown(input: string, shouldMergeAdjacentLines: boolean): string;
25
+ //# sourceMappingURL=normalizeMarkdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeMarkdown.d.ts","sourceRoot":"","sources":["../../../../src/lexical/utils/markdown/normalizeMarkdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAoBH;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAA;AAE1C;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAAG,IAAI,CAO/F;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,wBAAwB,EAAE,OAAO,GAAG,MAAM,CAgF1F"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Payload-specific markdown normalization, run by `$convertFromMarkdownString`
3
+ * before delegating the import to `@lexical/markdown`. Handles nested code
4
+ * fences and preserves table-row whitespace.
5
+ *
6
+ * TODO: Remove this file once https://github.com/facebook/lexical/pull/8734 is
7
+ * merged and we upgrade to a release that includes it. That PR fixes the nested
8
+ * code fence handling upstream, so `$convertFromMarkdownString` can call
9
+ * `@lexical/markdown` directly instead of pre-normalizing here.
10
+ */ // These regexes are only used with `.test()` here, so their capturing groups
11
+ // are unused in this module.
12
+ /* eslint-disable regexp/no-unused-capturing-group */const EMPTY_OR_WHITESPACE_ONLY = /^[\t ]*$/;
13
+ const ORDERED_LIST_REGEX = /^(\s*)(\d+)\.\s/;
14
+ const UNORDERED_LIST_REGEX = /^(\s*)[-*+]\s/;
15
+ const CHECK_LIST_REGEX = /^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i;
16
+ const HEADING_REGEX = /^(#{1,6})\s/;
17
+ const QUOTE_REGEX = /^>\s/;
18
+ const CODE_START_REGEX = /^[ \t]*(\\`\\`\\`|```)(\w+)?/;
19
+ const CODE_END_REGEX = /[ \t]*(\\`\\`\\`|```)$/;
20
+ const CODE_SINGLE_LINE_REGEX = /^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/;
21
+ const TABLE_ROW_REG_EXP = /^\|(.+)\|\s?$/;
22
+ const TABLE_ROW_DIVIDER_REG_EXP = /^(\| ?:?-*:? ?)+\|\s?$/;
23
+ const TAG_START_REGEX = /^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i;
24
+ const TAG_END_REGEX = /^[ \t]*<\/[a-z_][\w-]*\s*>/i;
25
+ /**
26
+ * Detects a CommonMark hard line break marker at the end of a raw line.
27
+ *
28
+ * @returns a tuple of `[textWithoutMarker, marker]` when a marker is found, otherwise null.
29
+ */
30
+ export function parseMarkdownHardLineBreak(line) {
31
+ if (line.endsWith('\\')) {
32
+ return [line.slice(0, -1), '\\'];
33
+ }
34
+ const spaces = line.match(/^(.*?\S)( {2,})$/);
35
+ return spaces ? [spaces[1], spaces[2]] : null;
36
+ }
37
+ export function normalizeMarkdown(input, shouldMergeAdjacentLines) {
38
+ const lines = input.split('\n');
39
+ let inCodeBlock = false;
40
+ const sanitizedLines = [];
41
+ let nestedDeepCodeBlock = 0;
42
+ for (let i = 0; i < lines.length; i++) {
43
+ const line = lines[i];
44
+ const lastLine = sanitizedLines[sanitizedLines.length - 1];
45
+ // A hard line break marker on the current line only matters if another line follows it.
46
+ const hardLineBreak = i < lines.length - 1 ? parseMarkdownHardLineBreak(line) : null;
47
+ const lastLineHasHardLineBreak = lastLine !== undefined && parseMarkdownHardLineBreak(lastLine) !== null;
48
+ // Code blocks of ```single line``` don't toggle the inCodeBlock flag
49
+ if (CODE_SINGLE_LINE_REGEX.test(line)) {
50
+ sanitizedLines.push(line);
51
+ continue;
52
+ }
53
+ if (CODE_END_REGEX.test(line)) {
54
+ if (nestedDeepCodeBlock === 0) {
55
+ inCodeBlock = true;
56
+ }
57
+ if (nestedDeepCodeBlock === 1) {
58
+ inCodeBlock = false;
59
+ }
60
+ if (nestedDeepCodeBlock > 0) {
61
+ nestedDeepCodeBlock--;
62
+ }
63
+ sanitizedLines.push(line);
64
+ continue;
65
+ }
66
+ // Toggle inCodeBlock state when encountering start or end of a code block
67
+ if (CODE_START_REGEX.test(line)) {
68
+ inCodeBlock = true;
69
+ nestedDeepCodeBlock++;
70
+ sanitizedLines.push(line);
71
+ continue;
72
+ }
73
+ // If we are inside a code block, keep the line unchanged
74
+ if (inCodeBlock) {
75
+ sanitizedLines.push(line);
76
+ continue;
77
+ }
78
+ // In markdown the concept of "empty paragraphs" does not exist.
79
+ // Blocks must be separated by an empty line. Non-empty adjacent lines must be merged.
80
+ if (EMPTY_OR_WHITESPACE_ONLY.test(line) || EMPTY_OR_WHITESPACE_ONLY.test(lastLine) || !lastLine || HEADING_REGEX.test(lastLine) || HEADING_REGEX.test(line) || QUOTE_REGEX.test(line) || ORDERED_LIST_REGEX.test(line) || UNORDERED_LIST_REGEX.test(line) || CHECK_LIST_REGEX.test(line) || TABLE_ROW_REG_EXP.test(line) || TABLE_ROW_DIVIDER_REG_EXP.test(line) ||
81
+ // Don't merge the next line into a line that ends with a hard line break marker.
82
+ lastLineHasHardLineBreak || !shouldMergeAdjacentLines || TAG_START_REGEX.test(line) || TAG_END_REGEX.test(line) || TAG_START_REGEX.test(lastLine) || TAG_END_REGEX.test(lastLine) || CODE_END_REGEX.test(lastLine)) {
83
+ sanitizedLines.push(line);
84
+ } else {
85
+ // Preserve a trailing hard line break marker on the merged line so it survives import.
86
+ sanitizedLines[sanitizedLines.length - 1] = lastLine + ' ' + (hardLineBreak === null ? line.trim() : line.trimStart());
87
+ }
88
+ }
89
+ return sanitizedLines.join('\n');
90
+ }
91
+ //# sourceMappingURL=normalizeMarkdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeMarkdown.js","names":["EMPTY_OR_WHITESPACE_ONLY","ORDERED_LIST_REGEX","UNORDERED_LIST_REGEX","CHECK_LIST_REGEX","HEADING_REGEX","QUOTE_REGEX","CODE_START_REGEX","CODE_END_REGEX","CODE_SINGLE_LINE_REGEX","TABLE_ROW_REG_EXP","TABLE_ROW_DIVIDER_REG_EXP","TAG_START_REGEX","TAG_END_REGEX","parseMarkdownHardLineBreak","line","endsWith","slice","spaces","match","normalizeMarkdown","input","shouldMergeAdjacentLines","lines","split","inCodeBlock","sanitizedLines","nestedDeepCodeBlock","i","length","lastLine","hardLineBreak","lastLineHasHardLineBreak","undefined","test","push","trim","trimStart","join"],"sources":["../../../../src/lexical/utils/markdown/normalizeMarkdown.ts"],"sourcesContent":["/**\n * Payload-specific markdown normalization, run by `$convertFromMarkdownString`\n * before delegating the import to `@lexical/markdown`. Handles nested code\n * fences and preserves table-row whitespace.\n *\n * TODO: Remove this file once https://github.com/facebook/lexical/pull/8734 is\n * merged and we upgrade to a release that includes it. That PR fixes the nested\n * code fence handling upstream, so `$convertFromMarkdownString` can call\n * `@lexical/markdown` directly instead of pre-normalizing here.\n */\n\n// These regexes are only used with `.test()` here, so their capturing groups\n// are unused in this module.\n/* eslint-disable regexp/no-unused-capturing-group */\n\nconst EMPTY_OR_WHITESPACE_ONLY = /^[\\t ]*$/\nconst ORDERED_LIST_REGEX = /^(\\s*)(\\d+)\\.\\s/\nconst UNORDERED_LIST_REGEX = /^(\\s*)[-*+]\\s/\nconst CHECK_LIST_REGEX = /^(\\s*)(?:-\\s)?\\s?(\\[(\\s|x)?\\])\\s/i\nconst HEADING_REGEX = /^(#{1,6})\\s/\nconst QUOTE_REGEX = /^>\\s/\nconst CODE_START_REGEX = /^[ \\t]*(\\\\`\\\\`\\\\`|```)(\\w+)?/\nconst CODE_END_REGEX = /[ \\t]*(\\\\`\\\\`\\\\`|```)$/\nconst CODE_SINGLE_LINE_REGEX = /^[ \\t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/\nconst TABLE_ROW_REG_EXP = /^\\|(.+)\\|\\s?$/\nconst TABLE_ROW_DIVIDER_REG_EXP = /^(\\| ?:?-*:? ?)+\\|\\s?$/\nconst TAG_START_REGEX = /^[ \\t]*<[a-z_][\\w-]*(?:\\s[^<>]*)?\\/?>/i\nconst TAG_END_REGEX = /^[ \\t]*<\\/[a-z_][\\w-]*\\s*>/i\n\n/**\n * Represents a CommonMark hard line break marker: either a trailing backslash\n * or two-or-more trailing spaces.\n *\n * See https://spec.commonmark.org/0.31.2/#hard-line-breaks\n */\nexport type MarkdownHardLineBreak = string\n\n/**\n * Detects a CommonMark hard line break marker at the end of a raw line.\n *\n * @returns a tuple of `[textWithoutMarker, marker]` when a marker is found, otherwise null.\n */\nexport function parseMarkdownHardLineBreak(line: string): [string, MarkdownHardLineBreak] | null {\n if (line.endsWith('\\\\')) {\n return [line.slice(0, -1), '\\\\']\n }\n\n const spaces = line.match(/^(.*?\\S)( {2,})$/)\n return spaces ? [spaces[1]!, spaces[2]!] : null\n}\n\nexport function normalizeMarkdown(input: string, shouldMergeAdjacentLines: boolean): string {\n const lines = input.split('\\n')\n let inCodeBlock = false\n const sanitizedLines: string[] = []\n let nestedDeepCodeBlock = 0\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!\n const lastLine = sanitizedLines[sanitizedLines.length - 1]\n // A hard line break marker on the current line only matters if another line follows it.\n const hardLineBreak = i < lines.length - 1 ? parseMarkdownHardLineBreak(line) : null\n const lastLineHasHardLineBreak =\n lastLine !== undefined && parseMarkdownHardLineBreak(lastLine) !== null\n\n // Code blocks of ```single line``` don't toggle the inCodeBlock flag\n if (CODE_SINGLE_LINE_REGEX.test(line)) {\n sanitizedLines.push(line)\n continue\n }\n\n if (CODE_END_REGEX.test(line)) {\n if (nestedDeepCodeBlock === 0) {\n inCodeBlock = true\n }\n if (nestedDeepCodeBlock === 1) {\n inCodeBlock = false\n }\n if (nestedDeepCodeBlock > 0) {\n nestedDeepCodeBlock--\n }\n sanitizedLines.push(line)\n continue\n }\n\n // Toggle inCodeBlock state when encountering start or end of a code block\n if (CODE_START_REGEX.test(line)) {\n inCodeBlock = true\n nestedDeepCodeBlock++\n sanitizedLines.push(line)\n continue\n }\n\n // If we are inside a code block, keep the line unchanged\n if (inCodeBlock) {\n sanitizedLines.push(line)\n continue\n }\n\n // In markdown the concept of \"empty paragraphs\" does not exist.\n // Blocks must be separated by an empty line. Non-empty adjacent lines must be merged.\n if (\n EMPTY_OR_WHITESPACE_ONLY.test(line) ||\n EMPTY_OR_WHITESPACE_ONLY.test(lastLine!) ||\n !lastLine ||\n HEADING_REGEX.test(lastLine) ||\n HEADING_REGEX.test(line) ||\n QUOTE_REGEX.test(line) ||\n ORDERED_LIST_REGEX.test(line) ||\n UNORDERED_LIST_REGEX.test(line) ||\n CHECK_LIST_REGEX.test(line) ||\n TABLE_ROW_REG_EXP.test(line) ||\n TABLE_ROW_DIVIDER_REG_EXP.test(line) ||\n // Don't merge the next line into a line that ends with a hard line break marker.\n lastLineHasHardLineBreak ||\n !shouldMergeAdjacentLines ||\n TAG_START_REGEX.test(line) ||\n TAG_END_REGEX.test(line) ||\n TAG_START_REGEX.test(lastLine) ||\n TAG_END_REGEX.test(lastLine) ||\n CODE_END_REGEX.test(lastLine)\n ) {\n sanitizedLines.push(line)\n } else {\n // Preserve a trailing hard line break marker on the merged line so it survives import.\n sanitizedLines[sanitizedLines.length - 1] =\n lastLine + ' ' + (hardLineBreak === null ? line.trim() : line.trimStart())\n }\n }\n\n return sanitizedLines.join('\\n')\n}\n"],"mappings":"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","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- export * from '../packages/@lexical/markdown/index.js';
1
+ export * from '@lexical/markdown';
2
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,cAAc,wCAAwC,CAAA"}
1
+ {"version":3,"file":"@lexical-markdown.d.ts","sourceRoot":"","sources":["../../src/lexical-proxy/@lexical-markdown.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
@@ -1,2 +1,2 @@
1
- export * from '../packages/@lexical/markdown/index.js';
1
+ export * from '@lexical/markdown';
2
2
  //# sourceMappingURL=@lexical-markdown.js.map
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"@lexical-markdown.js","names":[],"sources":["../../src/lexical-proxy/@lexical-markdown.ts"],"sourcesContent":["export * from '@lexical/markdown'\n"],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -9,8 +9,4 @@
9
9
  padding: var(--spacer-3);
10
10
  }
11
11
  }
12
-
13
- .fields-drawer .radio-group .field-description {
14
- margin-top: var(--spacer-2);
15
- }
16
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "4.0.0-canary.2",
3
+ "version": "4.0.0-canary.4",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -178,11 +178,6 @@
178
178
  "types": "./dist/lexical-proxy/@lexical-react/LexicalContentEditable.d.ts",
179
179
  "default": "./dist/lexical-proxy/@lexical-react/LexicalContentEditable.js"
180
180
  },
181
- "./lexical/react/LexicalContextMenuPlugin": {
182
- "import": "./dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js",
183
- "types": "./dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts",
184
- "default": "./dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js"
185
- },
186
181
  "./lexical/react/LexicalNodeContextMenuPlugin": {
187
182
  "import": "./dist/lexical-proxy/@lexical-react/LexicalNodeContextMenuPlugin.js",
188
183
  "types": "./dist/lexical-proxy/@lexical-react/LexicalNodeContextMenuPlugin.d.ts",
@@ -348,24 +343,25 @@
348
343
  ]
349
344
  },
350
345
  "dependencies": {
351
- "@lexical/clipboard": "0.41.0",
352
- "@lexical/headless": "0.41.0",
353
- "@lexical/html": "0.41.0",
354
- "@lexical/link": "0.41.0",
355
- "@lexical/list": "0.41.0",
356
- "@lexical/mark": "0.41.0",
357
- "@lexical/react": "0.41.0",
358
- "@lexical/rich-text": "0.41.0",
359
- "@lexical/selection": "0.41.0",
360
- "@lexical/table": "0.41.0",
361
- "@lexical/utils": "0.41.0",
346
+ "@lexical/clipboard": "0.45.0",
347
+ "@lexical/headless": "0.45.0",
348
+ "@lexical/html": "0.45.0",
349
+ "@lexical/link": "0.45.0",
350
+ "@lexical/list": "0.45.0",
351
+ "@lexical/mark": "0.45.0",
352
+ "@lexical/markdown": "0.45.0",
353
+ "@lexical/react": "0.45.0",
354
+ "@lexical/rich-text": "0.45.0",
355
+ "@lexical/selection": "0.45.0",
356
+ "@lexical/table": "0.45.0",
357
+ "@lexical/utils": "0.45.0",
362
358
  "acorn": "8.16.0",
363
359
  "bson-objectid": "2.0.4",
364
360
  "csstype": "3.2.3",
365
361
  "dequal": "2.0.3",
366
362
  "escape-html": "1.0.3",
367
363
  "jsox": "1.2.125",
368
- "lexical": "0.41.0",
364
+ "lexical": "0.45.0",
369
365
  "mdast-util-from-markdown": "2.0.3",
370
366
  "mdast-util-mdx-jsx": "3.2.0",
371
367
  "micromark-extension-mdx-jsx": "3.0.2",
@@ -373,8 +369,8 @@
373
369
  "react-error-boundary": "6.1.1",
374
370
  "ts-essentials": "10.0.3",
375
371
  "uuid": "14.0.0",
376
- "@payloadcms/translations": "4.0.0-canary.2",
377
- "@payloadcms/ui": "4.0.0-canary.2"
372
+ "@payloadcms/translations": "4.0.0-canary.4",
373
+ "@payloadcms/ui": "4.0.0-canary.4"
378
374
  },
379
375
  "devDependencies": {
380
376
  "@babel/cli": "7.27.2",
@@ -382,7 +378,7 @@
382
378
  "@babel/preset-env": "7.27.2",
383
379
  "@babel/preset-react": "7.27.1",
384
380
  "@babel/preset-typescript": "7.27.1",
385
- "@lexical/eslint-plugin": "0.41.0",
381
+ "@lexical/eslint-plugin": "0.45.0",
386
382
  "@types/escape-html": "1.0.4",
387
383
  "@types/json-schema": "7.0.15",
388
384
  "@types/node": "24.12.3",
@@ -393,16 +389,16 @@
393
389
  "esbuild": "0.27.1",
394
390
  "esbuild-sass-plugin": "3.3.1",
395
391
  "swc-plugin-transform-remove-imports": "8.3.0",
396
- "payload": "4.0.0-canary.2",
397
- "@payloadcms/eslint-config": "3.28.0"
392
+ "@payloadcms/eslint-config": "3.28.0",
393
+ "payload": "4.0.0-canary.4"
398
394
  },
399
395
  "peerDependencies": {
400
396
  "@faceless-ui/modal": "3.0.0",
401
397
  "@faceless-ui/scroll-info": "2.0.0",
402
398
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
403
399
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
404
- "@payloadcms/next": "4.0.0-canary.2",
405
- "payload": "4.0.0-canary.2"
400
+ "@payloadcms/next": "4.0.0-canary.4",
401
+ "payload": "4.0.0-canary.4"
406
402
  },
407
403
  "engines": {
408
404
  "node": ">=24.15.0"
@@ -1,2 +0,0 @@
1
- "use client";import{a as Be,e as Oe,g as $,h as K,j as Ie,k as Fe,l as $e,m as Ke,n as Se,o as Pe,p as je}from"./chunk-LH634DPU.js";import{a as Ae,b as P}from"./chunk-RJ5MAOKZ.js";import{jsx as L,jsxs as le}from"react/jsx-runtime";import{BulkUploadProvider as Zr,FieldDescription as en,FieldError as tn,FieldLabel as on,isFieldRTL as rn,RenderCustomComponent as At,useConfig as nn,useEditDepth as sn,useEffectEvent as ln,useField as an,useLocale as cn}from"@payloadcms/ui";import{mergeFieldStyles as un}from"@payloadcms/ui/shared";import{dequal as dn}from"dequal/lite";import Bt,{useCallback as Ot,useEffect as It,useMemo as fn,useState as Ft}from"react";import{ErrorBoundary as mn}from"react-error-boundary";import"./bundled.css";import{jsx as j}from"react/jsx-runtime";import{LexicalComposer as Vr}from"@lexical/react/LexicalComposer.js";import{useEditDepth as Wr}from"@payloadcms/ui";import*as _t from"react";import{useMemo as Yr}from"react";import{c as vr}from"react/compiler-runtime";import{jsx as C,jsxs as ie}from"react/jsx-runtime";import{useLexicalComposerContext as _r}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as kr}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Lr}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Dr}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Mr}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as Ar}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as Br,COMMAND_PRIORITY_LOW as Rt,FOCUS_COMMAND as Or}from"lexical";import*as Q from"react";import{useEffect as Ir,useState as Fr}from"react";import{jsx as ze}from"react/jsx-runtime";import"react";var z=({anchorElem:e,clientProps:t,plugin:o})=>o.position==="floatingAnchorElem"&&e?o.Component&&ze(o.Component,{anchorElem:e,clientProps:t}):o.Component&&ze(o.Component,{clientProps:t});import{c as zt}from"react/compiler-runtime";import{copyToClipboard as He}from"@lexical/clipboard";import{useLexicalComposerContext as Ht}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as Vt}from"@lexical/utils";import Ve from"bson-objectid";import{$getSelection as Wt,$isNodeSelection as Yt,COMMAND_PRIORITY_LOW as Gt,COPY_COMMAND as Ut}from"lexical";import{useEffect as Jt}from"react";var Te=e=>{if("fields"in e&&typeof e.fields=="object"&&e.fields!==null&&"id"in e.fields?e.fields.id=new Ve.default().toHexString():"id"in e&&(e.id=new Ve.default().toHexString()),e.children)for(let t of e.children)Te(t)};function We(){let e=zt(3),[t]=Ht(),o,r;return e[0]!==t?(o=()=>t.registerCommand(Ut,n=>{let c=Wt();if(Yt(c)){let s=c.getNodes()[0]?.exportJSON(),u=JSON.parse(JSON.stringify(s));Te(u);let d={namespace:t._config.namespace,nodes:[u]},m=JSON.stringify(d);return He(t,null,{"application/x-lexical-editor":m,"text/plain":""}).catch(qt),!0}return He(t,Vt(n,ClipboardEvent)?n:null).then(()=>{if(!(n instanceof ClipboardEvent)||!n.clipboardData)throw new Error("No clipboard event");let l=n.clipboardData.getData("application/x-lexical-editor");if(!l)return!0;let s=JSON.parse(l);for(let d of s.nodes)Te(d);let u=JSON.stringify(s);n.clipboardData.setData("application/x-lexical-editor",u)}).catch(l=>{throw n instanceof ClipboardEvent&&n.clipboardData?.setData("application/x-lexical-editor",""),l}),!0},Gt),r=[t],e[0]=t,e[1]=o,e[2]=r):(o=e[1],r=e[2]),Jt(o,r),null}function qt(e){throw e}import{c as Qt}from"react/compiler-runtime";import{useLexicalComposerContext as Xt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as fe,mergeRegister as Zt}from"@lexical/utils";import{$createNodeSelection as eo,$getEditor as te,$getNearestNodeFromDOMNode as to,$getSelection as me,$isDecoratorNode as H,$isElementNode as Re,$isLineBreakNode as oo,$isNodeSelection as pe,$isRangeSelection as Ye,$isRootOrShadowRoot as ro,$isTextNode as no,$setSelection as Ge,CLICK_COMMAND as io,COMMAND_PRIORITY_LOW as Y,KEY_ARROW_DOWN_COMMAND as so,KEY_ARROW_UP_COMMAND as lo,KEY_BACKSPACE_COMMAND as ao,KEY_DELETE_COMMAND as co,SELECTION_CHANGE_COMMAND as uo}from"lexical";import{useEffect as fo}from"react";function Ue(){let e=Qt(3),[t]=Xt(),o=Eo,r,n;return e[0]!==t?(r=()=>Zt(t.registerCommand(io,xo,Y),t.registerCommand(co,o,Y),t.registerCommand(ao,o,Y),t.registerCommand(uo,yo,Y),t.registerCommand(lo,go,Y),t.registerCommand(so,mo,Y)),n=[t],e[0]=t,e[1]=r,e[2]=n):(r=e[1],n=e[2]),fo(r,n),null}function mo(e){let t=me();if(pe(t)){e.preventDefault();let l=t.getNodes()[0]?.getNextSibling();if(H(l)){let d=te().getElementByKey(l.getKey());return d&&oe({element:d,node:l}),!0}if(!Re(l))return!0;let s=l.getFirstDescendant()??l;return s&&(fe(s,ge)?.selectEnd(),e.preventDefault()),!0}if(!Ye(t))return!1;let r=(t.isBackward()?t.anchor:t.focus).getNode(),n=fe(r,po),c=n?.getNextSibling();if(!n||c!==Je(n))return!1;if(H(c)){let l=te().getElementByKey(c.getKey());if(l)return oe({element:l,node:c}),e.preventDefault(),!0}return!1}function po(e){return Je(e)!==null}function go(e){let t=me();if(pe(t)){let l=t.getNodes()[0]?.getPreviousSibling();if(H(l)){let d=te().getElementByKey(l.getKey());return d?(oe({element:d,node:l}),e.preventDefault(),!0):!1}if(!Re(l))return!1;let s=l.getLastDescendant()??l;return s?(fe(s,ge)?.selectStart(),e.preventDefault(),!0):!1}if(!Ye(t))return!1;let r=(t.isBackward()?t.anchor:t.focus).getNode(),n=fe(r,ho),c=n?.getPreviousSibling();if(!n||c!==qe(n))return!1;if(H(c)){let l=te().getElementByKey(c.getKey());if(l)return oe({element:l,node:c}),e.preventDefault(),!0}return!1}function ho(e){return qe(e)!==null}function yo(){let e=No();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),e?(e.element?.classList.add("decorator-selected"),!0):!1}function xo(e){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let t=bo(e);if(!t)return!0;let{target:o}=e;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Ge(null):oe(t),!0}function Eo(e){let t=me();return pe(t)?(e.preventDefault(),t.getNodes().forEach(Co),!0):!1}function Co(e){e.remove()}function bo(e){if(!(e.target instanceof HTMLElement))return;let t=e.target.closest('[data-lexical-decorator="true"]');if(!(t instanceof HTMLElement))return;let o=to(t);return H(o)?{element:t,node:o}:void 0}function No(){let e=me();if(!pe(e))return;let t=e.getNodes();if(t.length!==1)return;let o=t[0];return H(o)?{decorator:o,element:te().getElementByKey(o.getKey())}:void 0}function oe({element:e,node:t}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=eo();o.add(t.getKey()),Ge(o),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.classList.add("decorator-selected")}function ge(e){if(H(e)&&!e.isInline())return!0;if(!Re(e)||ro(e))return!1;let t=e.getFirstChild(),o=t===null||oo(t)||no(t)||t.isInline();return!e.isInline()&&e.canBeEmpty()!==!1&&o}function Je(e){let t=e.getNextSibling();for(;t!==null;){if(ge(t))return t;t=t.getNextSibling()}return null}function qe(e){let t=e.getPreviousSibling();for(;t!==null;){if(ge(t))return t;t=t.getPreviousSibling()}return null}import{jsx as ve}from"react/jsx-runtime";import{useLexicalComposerContext as vo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as _o,isHTMLElement as ko}from"lexical";import*as et from"react";import{useCallback as Lo,useEffect as Ze,useRef as Do,useState as Mo}from"react";import{createPortal as Ao}from"react-dom";var G=(e,t,o,r,n=50,c=25)=>{let l=0;if(e&&!e.contains(r)){let{bottom:s,left:u,right:d,top:m}=e.getBoundingClientRect(),a=m+window.scrollY,i=s+window.scrollY;if(o<a-c||o>i+c||t<u-n||t>d+n)return-1;(t<u||t>d)&&(l=t<u?t-u:t-d)}return l};import{$getNodeByKey as ye}from"lexical";function U(e){let t=e.getBoundingClientRect(),o=getComputedStyle(e).getPropertyValue("transform");if(!o||o==="none")return t;let r=o.split(",").pop();return t.y=t.y-Number(r?.replace(")","")),t}function he(e){let t=(u,d)=>u?parseFloat(window.getComputedStyle(u)[d]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(e),n=t(e.previousElementSibling,"marginBottom"),c=t(e.nextElementSibling,"marginTop"),l=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:l}}import{$getRoot as wo}from"lexical";function V(e){return e.getEditorState().read(()=>wo().getChildrenKeys())}var So=1,Po=-1,Qe=0,B={props:null,result:null};function To(e,t,o=20){let r=e.x-t.x,n=e.y-t.y;return r*r+n*n<=o*o}function J(e){let{anchorElem:t,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:l,y:s},startIndex:u=0,useEdgeAsDefault:d=!1}=e;if(o>0&&B.props&&B.result&&B.props.fuzzy===e.fuzzy&&B.props.horizontalOffset===e.horizontalOffset&&B.props.useEdgeAsDefault===e.useEdgeAsDefault&&To(B.props.point,e.point,o))return B.result;let m=t.getBoundingClientRect(),a=V(r),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(d){let p=r.getElementByKey(a[0]),g=r.getElementByKey(a[a.length-1]);if(p&&g){let[f,E]=[U(p),U(g)];if(s<f.top?(i.blockElem=p,i.distance=f.top-s,i.blockNode=ye(a[0]),i.foundAtIndex=0):s>E.bottom&&(i.distance=s-E.bottom,i.blockNode=ye(a[a.length-1]),i.blockElem=g,i.foundAtIndex=a.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let x=u,y=Qe;for(;x>=0&&x<a.length;){let p=a[x],g=r.getElementByKey(p);if(g===null)break;let f=new K(l+c,s),E=Ke.fromDOMRect(U(g)),{marginBottom:h,marginTop:b}=he(g),_=E.generateNewRect({bottom:E.bottom+h,left:m.left,right:m.right,top:E.top-b}),{distance:w,isOnBottomSide:v,isOnTopSide:D}=_.distanceFromPoint(f);if(w===0){i.blockElem=g,i.blockNode=ye(p),i.foundAtIndex=x,i.distance=w,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!n&&!e.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else n&&w<i.distance&&(i.blockElem=g,i.blockNode=ye(p),i.distance=w,i.foundAtIndex=x);y===Qe&&(D?y=Po:v?y=So:y=1/0),x+=y}}),B.props=e,B.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function xe(e,t){return!!e.closest(`.${t}`)}var Ro=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Xe(e){if(!e||Ro.includes(e.tagName)||e.offsetHeight===0||e.offsetWidth===0)return!1;let t=window.getComputedStyle(e);return!(t.display==="table-cell"||t.position==="absolute"||t.visibility==="hidden"||t.opacity==="0")}function Ee(e,t,o,r=0){if(!e){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}let n=e.getBoundingClientRect(),c=window.getComputedStyle(e),l=t.getBoundingClientRect(),s=o.getBoundingClientRect(),u;if(["LexicalEditorTheme__block","LexicalEditorTheme__upload","LexicalEditorTheme__relationship"].some(a=>e.classList.contains(a)||e.firstElementChild?.classList.contains(a)))u=n.top+8-s.top;else{let a=Xe(e)?parseInt(c.lineHeight,10):0;u=n.top+(a-l.height)/2-s.top}let m=r;t.style.opacity="1",t.style.transform=`translate(${m}px, ${u}px)`}var Bo="add-block-menu",Ce=1/0;function Oo(e){return e===0?1/0:Ce>=0&&Ce<e?Ce:Math.floor(e/2)}function Io(e,t,o){let r=t.parentElement,{editorConfig:n}=P(),c=n?.admin?.hideGutter?-24:12,l=Do(null),[s,u]=Mo(null);Ze(()=>{function m(a){let i=a.target;if(!ko(i))return;let x=G(r,a.pageX,a.pageY,i);if(x===-1){u(null);return}if(xe(i,Bo))return;let y=V(e),{blockElem:p,blockNode:g,foundAtIndex:f}=J({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-x,point:new K(a.x,a.y),returnEmptyParagraphs:!0,startIndex:Oo(y.length),useEdgeAsDefault:!1});Ce=f,p&&g&&(s?.node!==g||s?.elem!==p)&&u({elem:p,node:g})}return document?.addEventListener("mousemove",m),()=>{document?.removeEventListener("mousemove",m)}},[r,t,e,s]),Ze(()=>{l.current&&s?.node&&Ee(s?.elem,l.current,t,c)},[t,s,c]);let d=Lo(m=>{let a=s;a?.node&&(e.update(()=>{let i=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(i=!1),!i){let x=_o();a?.node.insertAfter(x),setTimeout(()=>{a={elem:e.getElementByKey(x.getKey()),node:x},u(a)},0)}}),setTimeout(()=>{e.update(()=>{e.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{e.dispatchCommand(Fe,{node:a?.node})},2),m.stopPropagation(),m.preventDefault())},[e,s]);return Ao(ve(et.Fragment,{children:ve("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:m=>{d(m)},ref:l,type:"button",children:ve("div",{className:o?"icon":""})})}),t)}function tt(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[r]=vo();return Io(r,o,r._editable)}import{jsx as be,jsxs as $o}from"react/jsx-runtime";import{useLexicalComposerContext as Ko}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as nt}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as it,$getNodeByKey as jo,isHTMLElement as _e}from"lexical";import*as ut from"react";import{useEffect as ke,useRef as re,useState as st}from"react";import{createPortal as zo}from"react-dom";var ot=0,Fo=-24;var W=0;function rt(e,t,o,r,n,c,l,s,u,d=!1){let{height:m,top:a}=r.getBoundingClientRect(),{top:i,width:x}=l.getBoundingClientRect(),{marginBottom:y,marginTop:p}=he(r),g=a,f=c>=a+m/2+window.scrollY,E=!1;if(n?.elem)if(r!==n?.elem)(f&&n?.elem&&n?.elem===r.nextElementSibling||!f&&n?.elem&&n?.elem===r.previousElementSibling)&&(W++,W<200&&(E=!0));else{W++;let w=n?.boundingBox?.y,v=r.getBoundingClientRect().y;(f===n?.isBelow&&w===v||W<200)&&(E=!1)}if(E)return{isBelow:f,willStayInSamePosition:E};d?g+=m/2:f?g+=m+y/2:g-=p/2;let h=0;d||(f?h=-ot:h=ot);let b=g-i+h,_=Fo-t;return o.style.width=`calc(${x}px - ${e} - var(--spacer-5))`,o.style.opacity=".8",o.style.transform=`translate(${_}px, calc(${b}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?f?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),W=0,{isBelow:f,willStayInSamePosition:E}}var Ho="draggable-block-menu",lt="application/x-lexical-drag-block",ne=1/0;function at(e){return e===0?1/0:ne>=0&&ne<e?ne:Math.floor(e/2)}function Vo(e,t){let{transform:o}=t.style;e.setDragImage(t,0,0),setTimeout(()=>{t.style.transform=o})}function ct(e,t){e&&(e.style.opacity="0"),t&&(t.style.opacity="",t.style.marginBottom="",t.style.marginTop="")}function Wo(e,t,o){let r=t.parentElement,n=re(null),c=re(null),l=re(null),s=re(!1),u=re([]),[d,m]=st(null),[a,i]=st(null),{editorConfig:x}=P(),y=x?.admin?.hideGutter?-44:-8;ke(()=>{function f(E){let h=E.target;if(!_e(h))return;let b=G(r,E.pageX,E.pageY,h);if(b===-1){m(null);return}if(xe(h,Ho))return;let _=V(e),{blockElem:w,foundAtIndex:v,isFoundNodeEmptyParagraph:D}=J({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-b,point:new K(E.x,E.y),startIndex:at(_.length),useEdgeAsDefault:!1,verbose:!1});ne=v,!(!w&&!D)&&d!==w&&m(w)}return document?.addEventListener("mousemove",f),()=>{document?.removeEventListener("mousemove",f)}},[r,t,e,d]),ke(()=>{n.current&&Ee(d,n.current,t,y)},[t,d,y]),ke(()=>{function f(h){if(!s.current)return!1;let[b]=nt(h);if(b)return!1;let{pageY:_,target:w}=h;if(!_e(w))return!1;let v=G(r,h.pageX,h.pageY,w,100,50),D=V(e),{blockElem:S,foundAtIndex:I,isFoundNodeEmptyParagraph:R}=J({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-v,point:new K(h.x,h.y),startIndex:at(D.length),useEdgeAsDefault:!0,verbose:!0});ne=I;let F=c.current;if(S===null||F===null)return!1;if(h.preventDefault(),h.dataTransfer.dropEffect="move",d!==S){let{isBelow:k,willStayInSamePosition:M}=rt(x?.admin?.hideGutter?"0px":"var(--spacer-5)",y+(x?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),F,S,a,_,t,h,l,R);M||i({boundingBox:S.getBoundingClientRect(),elem:S,isBelow:k})}else a?.elem&&(ct(F,a.elem),i({boundingBox:S.getBoundingClientRect(),elem:S,isBelow:!1}));return!0}function E(h){if(!s.current)return!1;let[b]=nt(h);if(b)return!1;let{dataTransfer:_,pageY:w,target:v}=h,D=_?.getData(lt)||"";return e.update(()=>{let S=jo(D);if(!S||!_e(v))return!1;let I=G(r,h.pageX,h.pageY,v,100,50),{blockElem:R,isFoundNodeEmptyParagraph:F}=J({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-I,point:new K(h.x,h.y),useEdgeAsDefault:!0});if(!R)return!1;let k=it(R);if(!k)return!1;if(k===S)return!0;let{height:M,top:ae}=U(R),Ne=w>=ae+M/2+window.scrollY;F?(k.insertBefore(S),k.remove()):Ne?k.insertAfter(S):k.insertBefore(S),d!==null&&m(null),document.querySelectorAll(".lexical-block-highlighter").forEach(T=>{T.remove()});let we=e.getElementByKey(S.getKey()),ce=setTimeout(()=>{let T=we?.getBoundingClientRect();if(!T)return;let N=document.createElement("div");N.className="lexical-block-highlighter",N.style.backgroundColor="var(--theme-elevation-1000",N.style.transition="opacity 0.5s ease-in-out",N.style.zIndex="1",N.style.pointerEvents="none",N.style.boxSizing="border-box",N.style.borderRadius="4px",N.style.position="absolute",document.body.appendChild(N),N.style.opacity="0.1",N.style.height=`${T.height+8}px`,N.style.width=`${T.width+8}px`,N.style.top=`${T.top+window.scrollY-4}px`,N.style.left=`${T.left-4}px`;let ue=setTimeout(()=>{N.style.opacity="0";let de=setTimeout(()=>{N.remove()},500);u.current.push(de)},1e3);u.current.push(ue)},120);u.current.push(ce)}),!0}return document.addEventListener("dragover",f),document.addEventListener("drop",E),()=>{document.removeEventListener("dragover",f),document.removeEventListener("drop",E),u.current.forEach(clearTimeout),u.current=[]}},[r,y,t,e,a,d,x?.admin?.hideGutter]);function p(f){let E=f.dataTransfer;if(!E||!d)return;Vo(E,d),E.effectAllowed="move";let h="";e.update(()=>{let b=it(d);b&&(h=b.getKey())}),s.current=!0,E.setData(lt,h)}function g(){s.current=!1,a?.elem&&ct(c.current,a?.elem)}return zo($o(ut.Fragment,{children:[be("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:g,onDragStart:p,ref:n,type:"button",children:be("div",{className:o?"icon":""})}),be("div",{className:"draggable-block-target-line",ref:c}),be("div",{className:"debug-highlight",ref:l})]}),t)}function dt(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[r]=Ko();return Wo(r,o,r._editable)}import{c as Yo}from"react/compiler-runtime";import{jsx as Le}from"react/jsx-runtime";import{useLexicalComposerContext as Go}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Uo,$getRoot as Jo}from"lexical";import"react";var ft="insert-paragraph-at-end",mt=()=>{let e=Yo(2),[t]=Go(),{editorConfig:o}=P();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;return e[0]!==t?(r=Le("div",{"aria-label":"Insert Paragraph",className:ft,onClick:()=>{t.update(qo)},role:"button",tabIndex:0,children:Le("div",{className:`${ft}-inside`,children:Le("span",{children:"+"})})}),e[0]=t,e[1]=r):r=e[1],r};function qo(){let e=Uo();Jo().append(e),e.select()}import{c as Qo}from"react/compiler-runtime";import{useLexicalComposerContext as Xo}from"@lexical/react/LexicalComposerContext";import*as pt from"react";var gt=()=>{let e=Qo(4),{editorConfig:t}=P(),[o]=Xo(),r,n;return e[0]!==o||e[1]!==t.features.markdownTransformers?(r=()=>Be(o,t.features.markdownTransformers??[]),n=[o,t.features.markdownTransformers],e[0]=o,e[1]=t.features.markdownTransformers,e[2]=r,e[3]=n):(r=e[2],n=e[3]),pt.useEffect(r,n),null};import{c as Zo}from"react/compiler-runtime";import{useLexicalComposerContext as er}from"@lexical/react/LexicalComposerContext.js";import{useEffect as tr}from"react";function ht(){let e=Zo(5),[t]=er(),{currentView:o,views:r}=$(),n,c;return e[0]!==o||e[1]!==t||e[2]!==r?(n=()=>{r&&(o==="default"?r.default?Se(t,r.default?.nodes):Pe(t):r[o]&&(Pe(t),Se(t,r[o]?.nodes)))},c=[t,r,o],e[0]=o,e[1]=t,e[2]=r,e[3]=n,e[4]=c):(n=e[3],c=e[4]),tr(n,c),null}import{useLexicalComposerContext as or}from"@lexical/react/LexicalComposerContext";import{$getSelection as rr,$isRangeSelection as nr,RootNode as ir}from"lexical";import{useEffect as sr}from"react";function yt(){let[e]=or();return sr(()=>e.registerNodeTransform(ir,t=>{let o=rr();if(nr(o)){let r=o.anchor.getNode(),n=o.focus.getNode();(!r.isAttached()||!n.isAttached())&&(t.selectEnd(),console.warn("updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node."))}return!1}),[e]),null}import{useLexicalComposerContext as lr}from"@lexical/react/LexicalComposerContext";import{$getSelection as ar,COMMAND_PRIORITY_LOW as cr,SELECT_ALL_COMMAND as ur}from"lexical";import{useEffect as dr}from"react";function xt(){let[e]=lr();return dr(()=>e.registerCommand(ur,()=>{if(ar())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},cr),[e]),null}import{jsx as q,jsxs as Ct}from"react/jsx-runtime";import{useLexicalComposerContext as mr}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as bt}from"@payloadcms/ui";import{useCallback as pr,useMemo as gr,useState as hr}from"react";import"react";import*as Nt from"react-dom";import{c as fr}from"react/compiler-runtime";import"react";function Et(e,t){let o=fr(4),{maxLength:r,minLength:n}=t,c=r===void 0?75:r,l=n===void 0?1:n,s;return o[0]!==c||o[1]!==l||o[2]!==e?(s=u=>{let{query:d}=u,m="[^"+e+Ie+"\\s]",i=new RegExp("(^|\\s|\\()(["+e+"]((?:"+m+"){0,"+c+"}))$").exec(d);if(i!==null){let x=i[1],y=i[3];if(y.length>=l)return{leadOffset:i.index+x.length,matchingString:y,replaceableString:i[2]}}return null},o[0]=c,o[1]=l,o[2]=e,o[3]=s):s=o[3],s}var O="slash-menu-popup";function yr({isSelected:e,item:t,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:l}}=P(),{i18n:s}=bt(),u=`${O}__item ${O}__item-${t.key}`;e&&(u+=` ${O}__item--selected`);let d=t.key;return t.label&&(d=typeof t.label=="function"?t.label({featureClientSchemaMap:c,i18n:s,schemaPath:l}):t.label),d.length>25&&(d=d.substring(0,25)+"..."),Ct("button",{"aria-selected":e,className:u,id:O+"__item-"+t.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[t?.Icon&&q(t.Icon,{}),q("span",{className:`${O}__item-text`,children:d})]},t.key)}function wt({anchorElem:e=document.body}){let[t]=mr(),[o,r]=hr(null),{editorConfig:n}=P(),{i18n:c}=bt(),{fieldProps:{featureClientSchemaMap:l,schemaPath:s}}=P(),u=Et("/",{minLength:0}),d=pr(()=>{let a=[];for(let i of n.features.slashMenu.dynamicGroups)if(o){let x=i({editor:t,queryString:o});a=a.concat(x)}return a},[t,o,n?.features]),m=gr(()=>{let a=[];for(let i of n?.features.slashMenu.groups??[])a.push(i);if(o){let i=o.toLowerCase().replace(/[\s\-_]/g,"");a=a.map(y=>{let p=y.items.filter(g=>{let f=g.key;return g.label&&(f=typeof g.label=="function"?g.label({featureClientSchemaMap:l,i18n:c,schemaPath:s}):g.label),new RegExp(o,"gi").exec(f)||f.toLowerCase().replace(/[\s\-_]/g,"").includes(i)?!0:g.keywords!=null?g.keywords.some(h=>new RegExp(o,"gi").exec(h)?!0:h.toLowerCase().replace(/[\s\-_]/g,"").includes(i)):!1});return p.length?{...y,items:p}:null}),a=a.filter(y=>y!=null);let x=d();for(let y of x){let p=a.find(g=>g.key===y.key);p?a=a.filter(g=>g.key!==y.key):p={...y,items:[]},p?.items?.length&&(p.items=p.items.concat(p.items)),a.push(p)}}return a},[o,n?.features.slashMenu.groups,d,l,c,s]);return q($e,{anchorElem:e,groups:m,menuRenderFn:(a,{selectedItemKey:i,selectItemAndCleanUp:x,setSelectedItemKey:y})=>a.current&&m.length?Nt.createPortal(q("div",{className:O,"data-theme":"dark",children:m.map(p=>{let g=p.key;return p.label&&l&&(g=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:c,schemaPath:s}):p.label),Ct("div",{className:`${O}__group ${O}__group-${p.key}`,children:[q("div",{className:`${O}__group-title`,children:g}),p.items.map((f,E)=>q(yr,{index:E,isSelected:i===f.key,item:f,onClick:()=>{y(f.key),x(f)},onMouseEnter:()=>{y(f.key)},ref:h=>{f.ref={current:h}}},f.key))]},p.key)})}),a.current):null,onQueryChange:r,triggerFn:u})}import{c as xr}from"react/compiler-runtime";import{useLexicalComposerContext as Er}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Cr,TextNode as br}from"lexical";import{useEffect as Nr}from"react";function St(e){let t=xr(6),{features:o}=e,[r]=Er(),n;t[0]!==r||t[1]!==o.enabledFormats?(n=()=>{let l=wr(o.enabledFormats);if(l.length!==0)return r.registerNodeTransform(br,s=>{l.forEach(u=>{s.hasFormat(u)&&s.toggleFormat(u)})})},t[0]=r,t[1]=o.enabledFormats,t[2]=n):n=t[2];let c;return t[3]!==r||t[4]!==o?(c=[r,o],t[3]=r,t[4]=o,t[5]=c):c=t[5],Nr(n,c),null}function wr(e){let t=Object.keys(Cr),o=new Set(e);return t.filter(r=>!o.has(r))}import{c as Sr}from"react/compiler-runtime";import{jsx as Pt}from"react/jsx-runtime";import{useLexicalComposerContext as Pr}from"@lexical/react/LexicalComposerContext";import{ContentEditable as Tr}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Rr}from"@payloadcms/ui";import"react";function Tt(e){let t=Sr(5),{className:o,editorConfig:r}=e,{t:n}=Rr(),[,c]=Pr(),{getTheme:l}=c,s;if(t[0]!==o||t[1]!==r?.admin?.placeholder||t[2]!==l||t[3]!==n){let u=l();s=Pt(Tr,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Pt("p",{className:u?.placeholder,children:r?.admin?.placeholder??n("lexical:general:placeholder")})}),t[0]=o,t[1]=r?.admin?.placeholder,t[2]=l,t[3]=n,t[4]=s}else s=t[4];return s}var vt=e=>{let t=vr(13),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c,rtl:l}=e,s=P(),[u]=_r(),d=Ar(),[m,a]=Fr(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=f=>{f!==null&&a(f)},t[0]=i):i=t[0];let x=i,y,p;t[1]!==u||t[2]!==s?(y=()=>{if(!s?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}s?.parentEditor?.uuid&&s.parentEditor?.registerChild(s.uuid,s);let f=()=>{s.focusEditor(s)},E=()=>{s.blurEditor(s)},h=u.registerCommand(Or,()=>(f(),!0),Rt),b=u.registerCommand(Br,()=>(E(),!0),Rt);return()=>{h(),b(),s.parentEditor?.unregisterChild?.(s.uuid)}},p=[u,s],t[1]=u,t[2]=s,t[3]=y,t[4]=p):(y=t[3],p=t[4]),Ir(y,p);let g;return t[5]!==o||t[6]!==r||t[7]!==m||t[8]!==d||t[9]!==n||t[10]!==c||t[11]!==l?(g=ie(Q.Fragment,{children:[o.features.plugins?.map($r),ie("div",{className:"editor-container",dir:l?"rtl":void 0,ref:r,children:[o.features.plugins?.map(Kr),C(Mr,{contentEditable:C("div",{className:"editor-scroller",children:C("div",{className:"editor",ref:x,children:C(Tt,{editorConfig:o})})}),ErrorBoundary:kr}),C(yt,{}),d&&C(mt,{}),C(Ue,{}),C(We,{}),C(St,{features:o.features}),C(xt,{}),C(ht,{}),d&&C(Dr,{ignoreSelectionChange:!0,onChange:(f,E,h)=>{(!h.has("focus")||h.size>1)&&c?.(f,E,h)}}),m&&ie(Q.Fragment,{children:[!n&&d&&ie(Q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:C(dt,{anchorElem:m}),o.admin?.hideAddBlockButton?null:C(tt,{anchorElem:m})]}),o.features.plugins?.map(f=>{if(f.position==="floatingAnchorElem"&&!(f.desktopOnly===!0&&n))return C(z,{anchorElem:m,clientProps:f.clientProps,plugin:f},f.key)}),d&&C(Q.Fragment,{children:C(wt,{anchorElem:m})})]}),d&&ie(Q.Fragment,{children:[C(Lr,{}),o?.features?.markdownTransformers?.length>0&&C(gt,{})]}),o.features.plugins?.map(jr),o.features.plugins?.map(zr)]}),o.features.plugins?.map(Hr)]}),t[5]=o,t[6]=r,t[7]=m,t[8]=d,t[9]=n,t[10]=c,t[11]=l,t[12]=g):g=t[12],g};function $r(e){if(e.position==="aboveContainer")return C(z,{clientProps:e.clientProps,plugin:e},e.key)}function Kr(e){if(e.position==="top")return C(z,{clientProps:e.clientProps,plugin:e},e.key)}function jr(e){if(e.position==="normal")return C(z,{clientProps:e.clientProps,plugin:e},e.key)}function zr(e){if(e.position==="bottom")return C(z,{clientProps:e.clientProps,plugin:e},e.key)}function Hr(e){if(e.position==="belowContainer")return C(z,{clientProps:e.clientProps,plugin:e},e.key)}var kt=({children:e,providers:t})=>{if(!t?.length)return e;let o=t[0];return t.length>1?j(o,{children:j(kt,{providers:t.slice(1),children:e})}):j(o,{children:e})},Lt=e=>{let{composerKey:t,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:l,rtl:s,value:u}=e,{currentView:d,views:m}=$(),a=P(),i=Wr(),x=_t.useRef(null),y=Yr(()=>{if(u&&typeof u!="object")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(u));if(u&&Array.isArray(u)&&!("root"in u))throw new Error("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");if(u&&"jsonContent"in u)throw new Error("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");let p=m?.[d]?.nodes;return{editable:l!==!0,editorState:u!=null?JSON.stringify(u):void 0,namespace:o.lexical.namespace,nodes:je({editorConfig:o,nodeViews:p}),onError:g=>{throw g},theme:o.lexical.theme}},[o,m,d]);return y?j(Vr,{initialConfig:y,children:j(Ae,{editorConfig:o,editorContainerRef:x,fieldProps:r,parentContext:a?.editDepth===i?a:void 0,children:j(kt,{providers:o.features.providers,children:j(vt,{editorConfig:o,editorContainerRef:x,isSmallWidthViewport:n,onChange:c,rtl:s})})})},t+y.editable+d):j("p",{children:"Loading..."})};import{c as Gr}from"react/compiler-runtime";import{jsx as X,jsxs as Ur}from"react/jsx-runtime";import{ChevronIcon as Jr,Popup as qr,PopupList as Dt}from"@payloadcms/ui";import"react";function Mt(){let e=Gr(5),{currentView:t,setCurrentView:o,views:r}=$();if(!r||Object.keys(r).length===0)return null;let n,c;if(e[0]!==t||e[1]!==o||e[2]!==r){c=Symbol.for("react.early_return_sentinel");e:{let l=Object.keys(r);if(!l.some(Xr)){c=null;break e}let u=["default",...l.filter(Qr)],d=t.charAt(0).toUpperCase()+t.slice(1);n=X("div",{className:"lexical-view-selector",children:X(qr,{button:Ur("button",{className:"lexical-view-selector__button",type:"button",children:[X("span",{className:"lexical-view-selector__label",children:d}),X(Jr,{className:"lexical-view-selector__icon"})]}),buttonType:"custom",horizontalAlign:"left",render:m=>{let{close:a}=m;return X(Dt.ButtonGroup,{children:u.map(i=>{let x=i.charAt(0).toUpperCase()+i.slice(1);return X(Dt.Button,{active:i===t,disabled:i===t,onClick:()=>{o?.(i),a()},children:x},i)})})},size:"large"})})}e[0]=t,e[1]=o,e[2]=r,e[3]=n,e[4]=c}else n=e[3],c=e[4];return c!==Symbol.for("react.early_return_sentinel")?c:n}function Qr(e){return e!=="default"}function Xr(e){return e!=="default"}var se="rich-text-lexical",pn=e=>{let{editorConfig:t,field:o,field:{admin:{className:r,description:n,readOnly:c}={},label:l,localized:s,required:u},path:d,readOnly:m,schemaPath:a,validate:i}=e,x=m||c,y=cn(),{config:{localization:p}}=nn(),g=rn({fieldLocalized:s,locale:y,localizationConfig:p||void 0}),f=sn(),{isControlledByParent:E}=$(),h=Ot((A,ee)=>typeof i=="function"?i(A,{...ee,required:u}):!0,[i,u]),{customComponents:{AfterInput:b,BeforeInput:_,Description:w,Error:v,Label:D}={},disabled:S,initialValue:I,path:R,setValue:F,showError:k,value:M}=an({potentiallyStalePath:d,validate:h}),ae=x||S,[Z,Ne]=Ft(!1),[De,we]=Ft(),ce=Bt.useRef(I),T=Bt.useRef(M);It(()=>{let A=()=>{let ee=window.matchMedia("(max-width: 768px)").matches;ee!==Z&&Ne(ee)};return A(),window.addEventListener("resize",A),()=>{window.removeEventListener("resize",A)}},[Z]);let N=["field-type",se,r,k&&"error",ae&&`${se}--read-only`,t?.admin?.hideGutter!==!0&&!Z?`${se}--show-gutter`:null].filter(Boolean).join(" "),ue=`${R}.${f}`,de=Oe(),$t=Ot(A=>{de(()=>{let Me=A.toJSON();T.current=Me,F(Me)})},[F,de]),Kt=fn(()=>un(o),[o]),jt=ln(A=>{T.current!==M&&!dn(T.current!=null?JSON.parse(JSON.stringify(T.current)):T.current,M)&&(ce.current=A,T.current=M,we(new Date))});return It(()=>{Object.is(I,ce.current)||jt(I)},[I]),le("div",{className:N,"data-field-path":R,"data-field-schemapath":a,"data-lexical-view":t?.view,style:Kt,children:[le("div",{className:`${se}__label-row`,children:[D||L(on,{label:l,localized:s,path:R,required:u}),!E&&L(Mt,{})]}),le("div",{className:`${se}__wrap`,children:[L(At,{CustomComponent:v,Fallback:L(tn,{path:R,showError:k})}),le(mn,{fallbackRender:gn,onReset:()=>{},children:[_,L(Zr,{drawerSlugPrefix:`lexical-${R}`,children:L(Lt,{composerKey:ue,editorConfig:t,fieldProps:e,isSmallWidthViewport:Z,onChange:$t,readOnly:ae,rtl:g,value:M},JSON.stringify({path:R,rerenderProviderKey:De}))}),b]}),L(At,{CustomComponent:w,Fallback:L(en,{description:n,path:R})})]})]},ue)};function gn({error:e}){return le("div",{className:"errorBoundary",role:"alert",children:[L("p",{children:"Something went wrong:"}),L("pre",{style:{color:"red"},children:e instanceof Error?e.message:String(e)})]})}var Pl=pn;export{Pl as RichText};
2
- //# sourceMappingURL=Field-G5Z2HM5Y.js.map