@payloadcms/richtext-lexical 4.0.0-internal.2fddfc0 → 4.0.0-internal.3aa3d85

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 (302) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/exports/client/Field-XH5C4HFU.js +2 -0
  3. package/dist/exports/client/Field-XH5C4HFU.js.map +7 -0
  4. package/dist/exports/client/bundled.css +1 -1
  5. package/dist/exports/client/chunk-X3D4LZS7.js +2 -0
  6. package/dist/exports/client/chunk-X3D4LZS7.js.map +7 -0
  7. package/dist/exports/client/index.d.ts +0 -2
  8. package/dist/exports/client/index.d.ts.map +1 -1
  9. package/dist/exports/client/index.js +24 -25
  10. package/dist/exports/client/index.js.map +4 -4
  11. package/dist/features/blockquote/client/index.js +2 -2
  12. package/dist/features/blockquote/client/index.js.map +1 -1
  13. package/dist/features/blockquote/server/index.js +2 -2
  14. package/dist/features/blockquote/server/index.js.map +1 -1
  15. package/dist/features/blocks/client/component/index.css +2 -2
  16. package/dist/features/blocks/client/componentInline/index.css +8 -8
  17. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +1 -1
  18. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -1
  19. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -1
  20. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
  21. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +1 -1
  22. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -1
  23. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +5 -2
  24. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -1
  25. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +1 -2
  26. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -1
  27. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
  28. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.css +1 -1
  29. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.css +2 -4
  30. package/dist/features/blocks/premade/CodeBlock/Component/index.css +5 -5
  31. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +1 -1
  32. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -1
  33. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
  34. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  35. package/dist/features/blocks/server/schema.js +3 -2
  36. package/dist/features/blocks/server/schema.js.map +1 -1
  37. package/dist/features/converters/lexicalToMarkdown/index.d.ts.map +1 -1
  38. package/dist/features/converters/lexicalToMarkdown/index.js +1 -1
  39. package/dist/features/converters/lexicalToMarkdown/index.js.map +1 -1
  40. package/dist/features/converters/markdownToLexical/index.d.ts.map +1 -1
  41. package/dist/features/converters/markdownToLexical/index.js +5 -2
  42. package/dist/features/converters/markdownToLexical/index.js.map +1 -1
  43. package/dist/features/debug/jsxConverter/client/plugin/style.css +2 -2
  44. package/dist/features/experimental_table/client/index.js +2 -2
  45. package/dist/features/experimental_table/client/index.js.map +1 -1
  46. package/dist/features/experimental_table/markdownTransformer.d.ts +2 -2
  47. package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -1
  48. package/dist/features/experimental_table/markdownTransformer.js +6 -3
  49. package/dist/features/experimental_table/markdownTransformer.js.map +1 -1
  50. package/dist/features/experimental_table/server/index.js +2 -2
  51. package/dist/features/experimental_table/server/index.js.map +1 -1
  52. package/dist/features/format/bold/feature.client.js +1 -1
  53. package/dist/features/format/bold/feature.client.js.map +1 -1
  54. package/dist/features/format/bold/feature.server.d.ts.map +1 -1
  55. package/dist/features/format/bold/feature.server.js +1 -1
  56. package/dist/features/format/bold/feature.server.js.map +1 -1
  57. package/dist/features/format/inlineCode/feature.client.js +1 -1
  58. package/dist/features/format/inlineCode/feature.client.js.map +1 -1
  59. package/dist/features/format/inlineCode/feature.server.d.ts.map +1 -1
  60. package/dist/features/format/inlineCode/feature.server.js +1 -1
  61. package/dist/features/format/inlineCode/feature.server.js.map +1 -1
  62. package/dist/features/format/italic/feature.client.js +1 -1
  63. package/dist/features/format/italic/feature.client.js.map +1 -1
  64. package/dist/features/format/italic/feature.server.d.ts.map +1 -1
  65. package/dist/features/format/italic/feature.server.js +1 -1
  66. package/dist/features/format/italic/feature.server.js.map +1 -1
  67. package/dist/features/format/strikethrough/feature.client.js +1 -1
  68. package/dist/features/format/strikethrough/feature.client.js.map +1 -1
  69. package/dist/features/format/strikethrough/feature.server.d.ts.map +1 -1
  70. package/dist/features/format/strikethrough/feature.server.js +1 -1
  71. package/dist/features/format/strikethrough/feature.server.js.map +1 -1
  72. package/dist/features/heading/client/index.js +2 -2
  73. package/dist/features/heading/client/index.js.map +1 -1
  74. package/dist/features/heading/markdownTransformer.d.ts +2 -2
  75. package/dist/features/heading/markdownTransformer.d.ts.map +1 -1
  76. package/dist/features/heading/markdownTransformer.js +6 -19
  77. package/dist/features/heading/markdownTransformer.js.map +1 -1
  78. package/dist/features/heading/server/index.js +2 -2
  79. package/dist/features/heading/server/index.js.map +1 -1
  80. package/dist/features/horizontalRule/client/index.js +2 -2
  81. package/dist/features/horizontalRule/client/index.js.map +1 -1
  82. package/dist/features/horizontalRule/client/markdownTransformer.d.ts +2 -2
  83. package/dist/features/horizontalRule/client/markdownTransformer.d.ts.map +1 -1
  84. package/dist/features/horizontalRule/client/markdownTransformer.js +1 -1
  85. package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
  86. package/dist/features/horizontalRule/client/plugin/index.css +2 -2
  87. package/dist/features/horizontalRule/server/index.js +2 -2
  88. package/dist/features/horizontalRule/server/index.js.map +1 -1
  89. package/dist/features/horizontalRule/server/markdownTransformer.d.ts +2 -2
  90. package/dist/features/horizontalRule/server/markdownTransformer.d.ts.map +1 -1
  91. package/dist/features/horizontalRule/server/markdownTransformer.js +1 -1
  92. package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
  93. package/dist/features/link/client/index.js +2 -2
  94. package/dist/features/link/client/index.js.map +1 -1
  95. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +3 -3
  96. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  97. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +7 -11
  98. package/dist/features/link/markdownTransformer.d.ts +4 -4
  99. package/dist/features/link/markdownTransformer.d.ts.map +1 -1
  100. package/dist/features/link/markdownTransformer.js +2 -2
  101. package/dist/features/link/markdownTransformer.js.map +1 -1
  102. package/dist/features/link/markdownTransformer.spec.js +10 -10
  103. package/dist/features/link/markdownTransformer.spec.js.map +1 -1
  104. package/dist/features/link/server/baseFields.js.map +1 -1
  105. package/dist/features/link/server/index.js +2 -2
  106. package/dist/features/link/server/index.js.map +1 -1
  107. package/dist/features/link/server/schema.d.ts.map +1 -1
  108. package/dist/features/link/server/schema.js +4 -2
  109. package/dist/features/link/server/schema.js.map +1 -1
  110. package/dist/features/lists/checklist/client/index.js +1 -1
  111. package/dist/features/lists/checklist/client/index.js.map +1 -1
  112. package/dist/features/lists/checklist/server/index.js +1 -1
  113. package/dist/features/lists/checklist/server/index.js.map +1 -1
  114. package/dist/features/lists/orderedList/client/index.js +1 -1
  115. package/dist/features/lists/orderedList/client/index.js.map +1 -1
  116. package/dist/features/lists/orderedList/server/index.js +1 -1
  117. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  118. package/dist/features/lists/unorderedList/client/index.js +1 -1
  119. package/dist/features/lists/unorderedList/client/index.js.map +1 -1
  120. package/dist/features/lists/unorderedList/server/index.js +1 -1
  121. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  122. package/dist/features/relationship/server/schema.d.ts +3 -3
  123. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  124. package/dist/features/relationship/server/schema.js +22 -5
  125. package/dist/features/relationship/server/schema.js.map +1 -1
  126. package/dist/features/textState/feature.client.js +1 -1
  127. package/dist/features/textState/feature.client.js.map +1 -1
  128. package/dist/features/toolbars/fixed/client/Toolbar/index.css +2 -2
  129. package/dist/features/toolbars/inline/client/Toolbar/index.css +2 -13
  130. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +8 -12
  131. package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -1
  132. package/dist/features/toolbars/shared/useToolbarStates.js +3 -1
  133. package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -1
  134. package/dist/features/typesClient.d.ts +1 -1
  135. package/dist/features/typesClient.d.ts.map +1 -1
  136. package/dist/features/typesClient.js.map +1 -1
  137. package/dist/features/typesServer.d.ts +2 -2
  138. package/dist/features/typesServer.d.ts.map +1 -1
  139. package/dist/features/typesServer.js.map +1 -1
  140. package/dist/features/upload/client/component/index.css +9 -9
  141. package/dist/features/upload/client/plugin/index.js +5 -5
  142. package/dist/features/upload/client/plugin/index.js.map +1 -1
  143. package/dist/features/upload/server/index.js +2 -2
  144. package/dist/features/upload/server/index.js.map +1 -1
  145. package/dist/features/upload/server/markdownTransformer.d.ts +2 -2
  146. package/dist/features/upload/server/markdownTransformer.d.ts.map +1 -1
  147. package/dist/features/upload/server/markdownTransformer.js +1 -1
  148. package/dist/features/upload/server/markdownTransformer.js.map +1 -1
  149. package/dist/features/upload/server/schema.d.ts +4 -4
  150. package/dist/features/upload/server/schema.d.ts.map +1 -1
  151. package/dist/features/upload/server/schema.js +26 -6
  152. package/dist/features/upload/server/schema.js.map +1 -1
  153. package/dist/field/Diff/converters/unknown/index.css +1 -1
  154. package/dist/field/Field.js +1 -1
  155. package/dist/field/Field.js.map +1 -1
  156. package/dist/field/ViewSelector.css +1 -1
  157. package/dist/field/bundled.css +1 -1
  158. package/dist/field/index.css +11 -11
  159. package/dist/index.d.ts +2 -2
  160. package/dist/index.d.ts.map +1 -1
  161. package/dist/index.js +7 -50
  162. package/dist/index.js.map +1 -1
  163. package/dist/lexical/LexicalEditor.css +2 -2
  164. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  165. package/dist/lexical/LexicalEditor.js +2 -36
  166. package/dist/lexical/LexicalEditor.js.map +1 -1
  167. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  168. package/dist/lexical/LexicalProvider.js +7 -22
  169. package/dist/lexical/LexicalProvider.js.map +1 -1
  170. package/dist/lexical/plugins/DecoratorPlugin/index.css +1 -1
  171. package/dist/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  172. package/dist/lexical/plugins/MarkdownShortcut/index.js +1 -1
  173. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  174. package/dist/lexical/plugins/SlashMenu/index.css +1 -5
  175. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -1
  176. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +3 -3
  177. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +1 -1
  178. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  179. package/dist/lexical/theme/EditorTheme.css +18 -19
  180. package/dist/lexical/ui/ContentEditable.css +5 -5
  181. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts +17 -0
  182. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts.map +1 -0
  183. package/dist/lexical/utils/markdown/convertFromMarkdownString.js +27 -0
  184. package/dist/lexical/utils/markdown/convertFromMarkdownString.js.map +1 -0
  185. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js +88 -0
  186. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js.map +1 -0
  187. package/dist/lexical/utils/markdown/createBlockNode.d.ts +1 -1
  188. package/dist/lexical/utils/markdown/createBlockNode.d.ts.map +1 -1
  189. package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
  190. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts +25 -0
  191. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts.map +1 -0
  192. package/dist/lexical/utils/markdown/normalizeMarkdown.js +91 -0
  193. package/dist/lexical/utils/markdown/normalizeMarkdown.js.map +1 -0
  194. package/dist/lexical-proxy/@lexical-markdown.d.ts +1 -1
  195. package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
  196. package/dist/lexical-proxy/@lexical-markdown.js +1 -1
  197. package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
  198. package/dist/types/schema.d.ts.map +1 -1
  199. package/dist/types/schema.js +12 -5
  200. package/dist/types/schema.js.map +1 -1
  201. package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
  202. package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
  203. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  204. package/dist/utilities/generateImportMap.js +3 -7
  205. package/dist/utilities/generateImportMap.js.map +1 -1
  206. package/package.json +22 -27
  207. package/dist/@types/assets.d.js +0 -2
  208. package/dist/@types/assets.d.js.map +0 -1
  209. package/dist/exports/client/Field-VW7ZGT6K.js +0 -2
  210. package/dist/exports/client/Field-VW7ZGT6K.js.map +0 -7
  211. package/dist/exports/client/chunk-4EIYXZ6H.js +0 -12
  212. package/dist/exports/client/chunk-4EIYXZ6H.js.map +0 -7
  213. package/dist/exports/server/rsc.browser.d.ts +0 -11
  214. package/dist/exports/server/rsc.browser.d.ts.map +0 -1
  215. package/dist/exports/server/rsc.browser.js +0 -10
  216. package/dist/exports/server/rsc.browser.js.map +0 -1
  217. package/dist/features/blockquote/markdownTransformer.d.ts +0 -3
  218. package/dist/features/blockquote/markdownTransformer.d.ts.map +0 -1
  219. package/dist/features/blockquote/markdownTransformer.js +0 -33
  220. package/dist/features/blockquote/markdownTransformer.js.map +0 -1
  221. package/dist/features/format/bold/markdownTransformers.d.ts +0 -6
  222. package/dist/features/format/bold/markdownTransformers.d.ts.map +0 -1
  223. package/dist/features/format/bold/markdownTransformers.js +0 -23
  224. package/dist/features/format/bold/markdownTransformers.js.map +0 -1
  225. package/dist/features/format/inlineCode/markdownTransformers.d.ts +0 -3
  226. package/dist/features/format/inlineCode/markdownTransformers.d.ts.map +0 -1
  227. package/dist/features/format/inlineCode/markdownTransformers.js +0 -6
  228. package/dist/features/format/inlineCode/markdownTransformers.js.map +0 -1
  229. package/dist/features/format/italic/markdownTransformers.d.ts +0 -4
  230. package/dist/features/format/italic/markdownTransformers.d.ts.map +0 -1
  231. package/dist/features/format/italic/markdownTransformers.js +0 -12
  232. package/dist/features/format/italic/markdownTransformers.js.map +0 -1
  233. package/dist/features/format/strikethrough/markdownTransformers.d.ts +0 -3
  234. package/dist/features/format/strikethrough/markdownTransformers.d.ts.map +0 -1
  235. package/dist/features/format/strikethrough/markdownTransformers.js +0 -6
  236. package/dist/features/format/strikethrough/markdownTransformers.js.map +0 -1
  237. package/dist/features/lists/checklist/markdownTransformers.d.ts +0 -3
  238. package/dist/features/lists/checklist/markdownTransformers.d.ts.map +0 -1
  239. package/dist/features/lists/checklist/markdownTransformers.js +0 -12
  240. package/dist/features/lists/checklist/markdownTransformers.js.map +0 -1
  241. package/dist/features/lists/orderedList/markdownTransformer.d.ts +0 -3
  242. package/dist/features/lists/orderedList/markdownTransformer.d.ts.map +0 -1
  243. package/dist/features/lists/orderedList/markdownTransformer.js +0 -12
  244. package/dist/features/lists/orderedList/markdownTransformer.js.map +0 -1
  245. package/dist/features/lists/shared/markdown.d.ts +0 -6
  246. package/dist/features/lists/shared/markdown.d.ts.map +0 -1
  247. package/dist/features/lists/shared/markdown.js +0 -57
  248. package/dist/features/lists/shared/markdown.js.map +0 -1
  249. package/dist/features/lists/unorderedList/markdownTransformer.d.ts +0 -3
  250. package/dist/features/lists/unorderedList/markdownTransformer.d.ts.map +0 -1
  251. package/dist/features/lists/unorderedList/markdownTransformer.js +0 -12
  252. package/dist/features/lists/unorderedList/markdownTransformer.js.map +0 -1
  253. package/dist/field/clientEntry.d.ts +0 -29
  254. package/dist/field/clientEntry.d.ts.map +0 -1
  255. package/dist/field/clientEntry.js +0 -86
  256. package/dist/field/clientEntry.js.map +0 -1
  257. package/dist/lexical/utils/guard.d.ts +0 -5
  258. package/dist/lexical/utils/guard.d.ts.map +0 -1
  259. package/dist/lexical/utils/guard.js +0 -9
  260. package/dist/lexical/utils/guard.js.map +0 -1
  261. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +0 -2
  262. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +0 -1
  263. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +0 -2
  264. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +0 -1
  265. package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js +0 -160
  266. package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js.map +0 -1
  267. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +0 -14
  268. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +0 -1
  269. package/dist/packages/@lexical/markdown/MarkdownExport.js +0 -220
  270. package/dist/packages/@lexical/markdown/MarkdownExport.js.map +0 -1
  271. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +0 -19
  272. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +0 -1
  273. package/dist/packages/@lexical/markdown/MarkdownImport.js +0 -199
  274. package/dist/packages/@lexical/markdown/MarkdownImport.js.map +0 -1
  275. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +0 -11
  276. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +0 -1
  277. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +0 -304
  278. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +0 -1
  279. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +0 -173
  280. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +0 -1
  281. package/dist/packages/@lexical/markdown/MarkdownTransformers.js +0 -352
  282. package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +0 -1
  283. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +0 -22
  284. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +0 -1
  285. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +0 -91
  286. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +0 -1
  287. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +0 -21
  288. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +0 -1
  289. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +0 -54
  290. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +0 -1
  291. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +0 -18
  292. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +0 -1
  293. package/dist/packages/@lexical/markdown/importTextTransformers.js +0 -54
  294. package/dist/packages/@lexical/markdown/importTextTransformers.js.map +0 -1
  295. package/dist/packages/@lexical/markdown/index.d.ts +0 -29
  296. package/dist/packages/@lexical/markdown/index.d.ts.map +0 -1
  297. package/dist/packages/@lexical/markdown/index.js +0 -39
  298. package/dist/packages/@lexical/markdown/index.js.map +0 -1
  299. package/dist/packages/@lexical/markdown/utils.d.ts +0 -34
  300. package/dist/packages/@lexical/markdown/utils.d.ts.map +0 -1
  301. package/dist/packages/@lexical/markdown/utils.js +0 -267
  302. package/dist/packages/@lexical/markdown/utils.js.map +0 -1
@@ -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":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAqBxD,eAAO,MAAM,oBAAoB,EAAE,CAAC,IAAI,EAAE;IACxC,YAAY,EAAE,2BAA2B,CAAA;CAC1C,KAAK,sBAAsB,CAAC,YAAY,CAsFxC,CAAA"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAqBxD,eAAO,MAAM,oBAAoB,EAAE,CAAC,IAAI,EAAE;IACxC,YAAY,EAAE,2BAA2B,CAAA;CAC1C,KAAK,sBAAsB,CAAC,YAAY,CA+FxC,CAAA"}
@@ -18,7 +18,8 @@ export const getFieldToJSONSchema = ({
18
18
  field,
19
19
  i18n,
20
20
  interfaceNameDefinitions,
21
- typeStringDefinitions
21
+ typeStringDefinitions,
22
+ variant = 'output'
22
23
  }) => {
23
24
  // Step 1: build the schema for every node type allowed in this field.
24
25
  typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING);
@@ -36,7 +37,8 @@ export const getFieldToJSONSchema = ({
36
37
  i18n,
37
38
  interfaceNameDefinitions,
38
39
  nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,
39
- typeStringDefinitions
40
+ typeStringDefinitions,
41
+ variant
40
42
  };
41
43
  const nodeSchemas = [
42
44
  // Add built-in node schemas
@@ -62,14 +64,19 @@ export const getFieldToJSONSchema = ({
62
64
  oneOf: nodeSchemas
63
65
  }) : nodeUnionJson;
64
66
  const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase();
65
- const nodeUnionName = `LexicalNodes_${hash}`;
67
+ // Distinguish an input node union from an output one with an `_Input` suffix - unless an
68
+ // identical output union already exists (a relationship-free editor whose input == output), in
69
+ // which case share it. The content hash means differing unions split and identical ones merge.
70
+ const sharesOutputUnion = variant === 'input' && interfaceNameDefinitions.has(`LexicalNodes_${hash}`);
71
+ const resolvedHash = variant === 'input' && !sharesOutputUnion ? `${hash}_Input` : hash;
72
+ const nodeUnionName = `LexicalNodes_${resolvedHash}`;
66
73
  // Replacing the hash resolves the union name and any feature-derived
67
74
  // sibling names in one pass.
68
- const replacePlaceholder = schemaString => JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash));
75
+ const replacePlaceholder = schemaString => JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, resolvedHash));
69
76
  // Resolve placeholders left in feature-registered definitions so Map keys
70
77
  // and `$ref` targets line up.
71
78
  for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {
72
- const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash);
79
+ const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, resolvedHash);
73
80
  const resolvedSchema = replacePlaceholder(JSON.stringify(schema));
74
81
  if (newKey !== oldKey) {
75
82
  interfaceNameDefinitions.delete(oldKey);
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":["createHash","CORE_LEXICAL_TYPE_STRING","lineBreakNodeJSONSchema","paragraphNodeJSONSchema","rootNodeJSONSchema","tabNodeJSONSchema","textNodeJSONSchema","elementNodeSchema","NODE_UNION_HASH_PLACEHOLDER","NODE_UNION_NAME_PLACEHOLDER","getFieldToJSONSchema","editorConfig","collectionIDFieldTypes","config","field","i18n","interfaceNameDefinitions","typeStringDefinitions","add","nodeJsonSchemaArgs","args","nodeUnionRef","$ref","nodeUnionName","nodeSchemas","features","nodes","filter","node","jsonSchema","map","rootSchemaWithPlaceholder","nodeUnionJson","JSON","stringify","oneOf","pendingDefinitions","entries","key","includes","sort","a","b","hashInput","length","definitions","hash","update","digest","slice","toUpperCase","replacePlaceholder","schemaString","parse","replaceAll","oldKey","schema","newKey","resolvedSchema","delete","set"],"sources":["../../src/types/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { createHash } from 'crypto'\n\nimport type { JSONSchemaArgs } from '../features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextAdapter } from './index.js'\n\nimport {\n CORE_LEXICAL_TYPE_STRING,\n lineBreakNodeJSONSchema,\n paragraphNodeJSONSchema,\n rootNodeJSONSchema,\n tabNodeJSONSchema,\n textNodeJSONSchema,\n} from './builtInNodes.js'\nimport { elementNodeSchema } from './jsonSchemaHelpers.js'\n\n/**\n * The node-union name is a hash of its own schema (so identical editors dedupe).\n * Since the schema references the union name, we use a placeholder during build\n * and substitute the real hash once everything's assembled. Features can derive\n * sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.\n */\nconst NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__'\nconst NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`\n\nexport const getFieldToJSONSchema: (args: {\n editorConfig: SanitizedServerEditorConfig\n}) => LexicalRichTextAdapter['jsonSchema'] = ({ editorConfig }) => {\n return ({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n typeStringDefinitions,\n }) => {\n // Step 1: build the schema for every node type allowed in this field.\n\n typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING)\n\n const nodeJsonSchemaArgs: JSONSchemaArgs = {\n collectionIDFieldTypes,\n config,\n // Each element node needs its children typed using the union node type recursively\n elementNodeSchema: (args) =>\n elementNodeSchema({\n ...args,\n nodeUnionRef: {\n $ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`,\n },\n }),\n field,\n i18n,\n interfaceNameDefinitions,\n nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,\n typeStringDefinitions,\n }\n\n const nodeSchemas: JSONSchema4[] = [\n // Add built-in node schemas\n textNodeJSONSchema(nodeJsonSchemaArgs),\n tabNodeJSONSchema(nodeJsonSchemaArgs),\n lineBreakNodeJSONSchema(nodeJsonSchemaArgs),\n paragraphNodeJSONSchema(nodeJsonSchemaArgs),\n // Add feature node schemas\n ...editorConfig.features.nodes\n .filter((node) => node.jsonSchema)\n .map((node) => node.jsonSchema!(nodeJsonSchemaArgs)),\n ]\n const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs)\n\n // Step 2: get the final node union name, then replace the placeholder\n // in both the union members and the root node.\n //\n // See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.\n const nodeUnionJson = JSON.stringify({ oneOf: nodeSchemas })\n\n // Features can register per-editor definitions during node-schema build (e.g. a link node's\n // custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node\n // union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same\n // nodes but different feature config (e.g. different custom link fields) would otherwise hash\n // identically and overwrite each other's definition. To avoid that, include that content into the hash too.\n const pendingDefinitions = [...interfaceNameDefinitions.entries()]\n .filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER))\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n\n const hashInput = pendingDefinitions.length\n ? JSON.stringify({ definitions: pendingDefinitions, oneOf: nodeSchemas })\n : nodeUnionJson\n\n const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase()\n const nodeUnionName = `LexicalNodes_${hash}`\n\n // Replacing the hash resolves the union name and any feature-derived\n // sibling names in one pass.\n const replacePlaceholder = (schemaString: string) =>\n JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash)) as JSONSchema4\n\n // Resolve placeholders left in feature-registered definitions so Map keys\n // and `$ref` targets line up.\n for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {\n const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash)\n const resolvedSchema = replacePlaceholder(JSON.stringify(schema))\n if (newKey !== oldKey) {\n interfaceNameDefinitions.delete(oldKey)\n }\n interfaceNameDefinitions.set(newKey, resolvedSchema)\n }\n\n interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson))\n\n return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder))\n }\n}\n"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"file":"schema.js","names":["createHash","CORE_LEXICAL_TYPE_STRING","lineBreakNodeJSONSchema","paragraphNodeJSONSchema","rootNodeJSONSchema","tabNodeJSONSchema","textNodeJSONSchema","elementNodeSchema","NODE_UNION_HASH_PLACEHOLDER","NODE_UNION_NAME_PLACEHOLDER","getFieldToJSONSchema","editorConfig","collectionIDFieldTypes","config","field","i18n","interfaceNameDefinitions","typeStringDefinitions","variant","add","nodeJsonSchemaArgs","args","nodeUnionRef","$ref","nodeUnionName","nodeSchemas","features","nodes","filter","node","jsonSchema","map","rootSchemaWithPlaceholder","nodeUnionJson","JSON","stringify","oneOf","pendingDefinitions","entries","key","includes","sort","a","b","hashInput","length","definitions","hash","update","digest","slice","toUpperCase","sharesOutputUnion","has","resolvedHash","replacePlaceholder","schemaString","parse","replaceAll","oldKey","schema","newKey","resolvedSchema","delete","set"],"sources":["../../src/types/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { createHash } from 'crypto'\n\nimport type { JSONSchemaArgs } from '../features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextAdapter } from './index.js'\n\nimport {\n CORE_LEXICAL_TYPE_STRING,\n lineBreakNodeJSONSchema,\n paragraphNodeJSONSchema,\n rootNodeJSONSchema,\n tabNodeJSONSchema,\n textNodeJSONSchema,\n} from './builtInNodes.js'\nimport { elementNodeSchema } from './jsonSchemaHelpers.js'\n\n/**\n * The node-union name is a hash of its own schema (so identical editors dedupe).\n * Since the schema references the union name, we use a placeholder during build\n * and substitute the real hash once everything's assembled. Features can derive\n * sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.\n */\nconst NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__'\nconst NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`\n\nexport const getFieldToJSONSchema: (args: {\n editorConfig: SanitizedServerEditorConfig\n}) => LexicalRichTextAdapter['jsonSchema'] = ({ editorConfig }) => {\n return ({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n typeStringDefinitions,\n variant = 'output',\n }) => {\n // Step 1: build the schema for every node type allowed in this field.\n\n typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING)\n\n const nodeJsonSchemaArgs: JSONSchemaArgs = {\n collectionIDFieldTypes,\n config,\n // Each element node needs its children typed using the union node type recursively\n elementNodeSchema: (args) =>\n elementNodeSchema({\n ...args,\n nodeUnionRef: {\n $ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`,\n },\n }),\n field,\n i18n,\n interfaceNameDefinitions,\n nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,\n typeStringDefinitions,\n variant,\n }\n\n const nodeSchemas: JSONSchema4[] = [\n // Add built-in node schemas\n textNodeJSONSchema(nodeJsonSchemaArgs),\n tabNodeJSONSchema(nodeJsonSchemaArgs),\n lineBreakNodeJSONSchema(nodeJsonSchemaArgs),\n paragraphNodeJSONSchema(nodeJsonSchemaArgs),\n // Add feature node schemas\n ...editorConfig.features.nodes\n .filter((node) => node.jsonSchema)\n .map((node) => node.jsonSchema!(nodeJsonSchemaArgs)),\n ]\n const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs)\n\n // Step 2: get the final node union name, then replace the placeholder\n // in both the union members and the root node.\n //\n // See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.\n const nodeUnionJson = JSON.stringify({ oneOf: nodeSchemas })\n\n // Features can register per-editor definitions during node-schema build (e.g. a link node's\n // custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node\n // union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same\n // nodes but different feature config (e.g. different custom link fields) would otherwise hash\n // identically and overwrite each other's definition. To avoid that, include that content into the hash too.\n const pendingDefinitions = [...interfaceNameDefinitions.entries()]\n .filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER))\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n\n const hashInput = pendingDefinitions.length\n ? JSON.stringify({ definitions: pendingDefinitions, oneOf: nodeSchemas })\n : nodeUnionJson\n\n const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase()\n\n // Distinguish an input node union from an output one with an `_Input` suffix - unless an\n // identical output union already exists (a relationship-free editor whose input == output), in\n // which case share it. The content hash means differing unions split and identical ones merge.\n const sharesOutputUnion =\n variant === 'input' && interfaceNameDefinitions.has(`LexicalNodes_${hash}`)\n const resolvedHash = variant === 'input' && !sharesOutputUnion ? `${hash}_Input` : hash\n const nodeUnionName = `LexicalNodes_${resolvedHash}`\n\n // Replacing the hash resolves the union name and any feature-derived\n // sibling names in one pass.\n const replacePlaceholder = (schemaString: string) =>\n JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, resolvedHash)) as JSONSchema4\n\n // Resolve placeholders left in feature-registered definitions so Map keys\n // and `$ref` targets line up.\n for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {\n const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, resolvedHash)\n const resolvedSchema = replacePlaceholder(JSON.stringify(schema))\n if (newKey !== oldKey) {\n interfaceNameDefinitions.delete(oldKey)\n }\n interfaceNameDefinitions.set(newKey, resolvedSchema)\n }\n\n interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson))\n\n return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder))\n }\n}\n"],"mappings":"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","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAIhE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,CAgGzF"}
1
+ {"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAQ,MAAM,SAAS,CAAA;AAI3D;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,CAgGzF"}
@@ -1 +1 @@
1
- {"version":3,"file":"applyBaseFilterToFields.js","names":["combineWhereConstraints","applyBaseFilterToFields","fields","config","map","field","type","relationshipField","originalFilterOptions","filterOptions","args","relationTo","req","user","originalResult","admin","collections","find","slug","hidden","baseFilter","baseListFilter","baseFilterResult","limit","page","sort","tabs","tab","blocks","block"],"sources":["../../src/utilities/applyBaseFilterToFields.ts"],"sourcesContent":["import type { Field, SanitizedConfig, TypedUser } from 'payload'\n\nimport { combineWhereConstraints } from 'payload/shared'\n\n/**\n * Recursively applies baseFilter from collection config to relationship fields\n * within blocks. This ensures that relationship drawers in blocks respect\n * collection-level filters like multi-tenant filtering.\n *\n * Based on the fix from PR #13229 for LinkFeature\n */\nexport function applyBaseFilterToFields(fields: Field[], config: SanitizedConfig): Field[] {\n return fields.map((field) => {\n // Handle relationship fields\n if (field.type === 'relationship') {\n const relationshipField = field\n\n // Store the original filterOptions\n const originalFilterOptions = relationshipField.filterOptions\n\n // Create new filterOptions that includes baseFilter\n relationshipField.filterOptions = async (args) => {\n const { relationTo, req, user } = args\n\n // Call original filterOptions if it exists\n const originalResult =\n typeof originalFilterOptions === 'function'\n ? await originalFilterOptions(args)\n : (originalFilterOptions ?? true)\n\n // If original filter returns false, respect that\n if (originalResult === false) {\n return false\n }\n\n // Get the collection's admin config\n const admin = config.collections.find(({ slug }) => slug === relationTo)?.admin\n\n // Check if collection is hidden\n const hidden = admin?.hidden\n if (typeof hidden === 'function' && hidden({ user } as { user: TypedUser })) {\n return false\n }\n\n // Apply baseFilter (with backwards compatibility for baseListFilter)\n const baseFilter = admin?.baseFilter ?? admin?.baseListFilter\n const baseFilterResult = await baseFilter?.({\n limit: 0,\n page: 1,\n req,\n sort: 'id',\n })\n\n // If no baseFilter, return original result\n if (!baseFilterResult) {\n return originalResult\n }\n\n // If original result is true, just return the baseFilter\n if (originalResult === true) {\n return baseFilterResult\n }\n\n // Combine original and baseFilter results\n return combineWhereConstraints([originalResult, baseFilterResult], 'and')\n }\n\n return relationshipField\n }\n\n // Recursively process nested fields\n if ('fields' in field && field.fields) {\n return {\n ...field,\n fields: applyBaseFilterToFields(field.fields, config),\n }\n }\n\n // Handle tabs\n if (field.type === 'tabs' && 'tabs' in field) {\n return {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: applyBaseFilterToFields(tab.fields, config),\n })),\n }\n }\n\n // Handle blocks\n if (field.type === 'blocks') {\n return {\n ...field,\n blocks: field.blocks.map((block) => {\n if (typeof block === 'string') {\n return block\n }\n return {\n ...block,\n fields: applyBaseFilterToFields(block.fields, config),\n }\n }),\n }\n }\n\n return field\n })\n}\n"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ;AAExC;;;;;;;AAOA,OAAO,SAASC,wBAAwBC,MAAe,EAAEC,MAAuB;EAC9E,OAAOD,MAAA,CAAOE,GAAG,CAAEC,KAAA;IACjB;IACA,IAAIA,KAAA,CAAMC,IAAI,KAAK,gBAAgB;MACjC,MAAMC,iBAAA,GAAoBF,KAAA;MAE1B;MACA,MAAMG,qBAAA,GAAwBD,iBAAA,CAAkBE,aAAa;MAE7D;MACAF,iBAAA,CAAkBE,aAAa,GAAG,MAAOC,IAAA;QACvC,MAAM;UAAEC,UAAU;UAAEC,GAAG;UAAEC;QAAI,CAAE,GAAGH,IAAA;QAElC;QACA,MAAMI,cAAA,GACJ,OAAON,qBAAA,KAA0B,aAC7B,MAAMA,qBAAA,CAAsBE,IAAA,IAC3BF,qBAAA,IAAyB;QAEhC;QACA,IAAIM,cAAA,KAAmB,OAAO;UAC5B,OAAO;QACT;QAEA;QACA,MAAMC,KAAA,GAAQZ,MAAA,CAAOa,WAAW,CAACC,IAAI,CAAC,CAAC;UAAEC;QAAI,CAAE,KAAKA,IAAA,KAASP,UAAA,GAAaI,KAAA;QAE1E;QACA,MAAMI,MAAA,GAASJ,KAAA,EAAOI,MAAA;QACtB,IAAI,OAAOA,MAAA,KAAW,cAAcA,MAAA,CAAO;UAAEN;QAAK,IAA2B;UAC3E,OAAO;QACT;QAEA;QACA,MAAMO,UAAA,GAAaL,KAAA,EAAOK,UAAA,IAAcL,KAAA,EAAOM,cAAA;QAC/C,MAAMC,gBAAA,GAAmB,MAAMF,UAAA,GAAa;UAC1CG,KAAA,EAAO;UACPC,IAAA,EAAM;UACNZ,GAAA;UACAa,IAAA,EAAM;QACR;QAEA;QACA,IAAI,CAACH,gBAAA,EAAkB;UACrB,OAAOR,cAAA;QACT;QAEA;QACA,IAAIA,cAAA,KAAmB,MAAM;UAC3B,OAAOQ,gBAAA;QACT;QAEA;QACA,OAAOtB,uBAAA,CAAwB,CAACc,cAAA,EAAgBQ,gBAAA,CAAiB,EAAE;MACrE;MAEA,OAAOf,iBAAA;IACT;IAEA;IACA,IAAI,YAAYF,KAAA,IAASA,KAAA,CAAMH,MAAM,EAAE;MACrC,OAAO;QACL,GAAGG,KAAK;QACRH,MAAA,EAAQD,uBAAA,CAAwBI,KAAA,CAAMH,MAAM,EAAEC,MAAA;MAChD;IACF;IAEA;IACA,IAAIE,KAAA,CAAMC,IAAI,KAAK,UAAU,UAAUD,KAAA,EAAO;MAC5C,OAAO;QACL,GAAGA,KAAK;QACRqB,IAAA,EAAMrB,KAAA,CAAMqB,IAAI,CAACtB,GAAG,CAAEuB,GAAA,KAAS;UAC7B,GAAGA,GAAG;UACNzB,MAAA,EAAQD,uBAAA,CAAwB0B,GAAA,CAAIzB,MAAM,EAAEC,MAAA;QAC9C;MACF;IACF;IAEA;IACA,IAAIE,KAAA,CAAMC,IAAI,KAAK,UAAU;MAC3B,OAAO;QACL,GAAGD,KAAK;QACRuB,MAAA,EAAQvB,KAAA,CAAMuB,MAAM,CAACxB,GAAG,CAAEyB,KAAA;UACxB,IAAI,OAAOA,KAAA,KAAU,UAAU;YAC7B,OAAOA,KAAA;UACT;UACA,OAAO;YACL,GAAGA,KAAK;YACR3B,MAAA,EAAQD,uBAAA,CAAwB4B,KAAA,CAAM3B,MAAM,EAAEC,MAAA;UAChD;QACF;MACF;IACF;IAEA,OAAOE,KAAA;EACT;AACF","ignoreList":[]}
1
+ {"version":3,"file":"applyBaseFilterToFields.js","names":["combineWhereConstraints","applyBaseFilterToFields","fields","config","map","field","type","relationshipField","originalFilterOptions","filterOptions","args","relationTo","req","user","originalResult","admin","collections","find","slug","hidden","baseFilter","baseListFilter","baseFilterResult","limit","page","sort","tabs","tab","blocks","block"],"sources":["../../src/utilities/applyBaseFilterToFields.ts"],"sourcesContent":["import type { Field, SanitizedConfig, User } from 'payload'\n\nimport { combineWhereConstraints } from 'payload/shared'\n\n/**\n * Recursively applies baseFilter from collection config to relationship fields\n * within blocks. This ensures that relationship drawers in blocks respect\n * collection-level filters like multi-tenant filtering.\n *\n * Based on the fix from PR #13229 for LinkFeature\n */\nexport function applyBaseFilterToFields(fields: Field[], config: SanitizedConfig): Field[] {\n return fields.map((field) => {\n // Handle relationship fields\n if (field.type === 'relationship') {\n const relationshipField = field\n\n // Store the original filterOptions\n const originalFilterOptions = relationshipField.filterOptions\n\n // Create new filterOptions that includes baseFilter\n relationshipField.filterOptions = async (args) => {\n const { relationTo, req, user } = args\n\n // Call original filterOptions if it exists\n const originalResult =\n typeof originalFilterOptions === 'function'\n ? await originalFilterOptions(args)\n : (originalFilterOptions ?? true)\n\n // If original filter returns false, respect that\n if (originalResult === false) {\n return false\n }\n\n // Get the collection's admin config\n const admin = config.collections.find(({ slug }) => slug === relationTo)?.admin\n\n // Check if collection is hidden\n const hidden = admin?.hidden\n if (typeof hidden === 'function' && hidden({ user } as { user: User })) {\n return false\n }\n\n // Apply baseFilter (with backwards compatibility for baseListFilter)\n const baseFilter = admin?.baseFilter ?? admin?.baseListFilter\n const baseFilterResult = await baseFilter?.({\n limit: 0,\n page: 1,\n req,\n sort: 'id',\n })\n\n // If no baseFilter, return original result\n if (!baseFilterResult) {\n return originalResult\n }\n\n // If original result is true, just return the baseFilter\n if (originalResult === true) {\n return baseFilterResult\n }\n\n // Combine original and baseFilter results\n return combineWhereConstraints([originalResult, baseFilterResult], 'and')\n }\n\n return relationshipField\n }\n\n // Recursively process nested fields\n if ('fields' in field && field.fields) {\n return {\n ...field,\n fields: applyBaseFilterToFields(field.fields, config),\n }\n }\n\n // Handle tabs\n if (field.type === 'tabs' && 'tabs' in field) {\n return {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: applyBaseFilterToFields(tab.fields, config),\n })),\n }\n }\n\n // Handle blocks\n if (field.type === 'blocks') {\n return {\n ...field,\n blocks: field.blocks.map((block) => {\n if (typeof block === 'string') {\n return block\n }\n return {\n ...block,\n fields: applyBaseFilterToFields(block.fields, config),\n }\n }),\n }\n }\n\n return field\n })\n}\n"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ;AAExC;;;;;;;AAOA,OAAO,SAASC,wBAAwBC,MAAe,EAAEC,MAAuB;EAC9E,OAAOD,MAAA,CAAOE,GAAG,CAAEC,KAAA;IACjB;IACA,IAAIA,KAAA,CAAMC,IAAI,KAAK,gBAAgB;MACjC,MAAMC,iBAAA,GAAoBF,KAAA;MAE1B;MACA,MAAMG,qBAAA,GAAwBD,iBAAA,CAAkBE,aAAa;MAE7D;MACAF,iBAAA,CAAkBE,aAAa,GAAG,MAAOC,IAAA;QACvC,MAAM;UAAEC,UAAU;UAAEC,GAAG;UAAEC;QAAI,CAAE,GAAGH,IAAA;QAElC;QACA,MAAMI,cAAA,GACJ,OAAON,qBAAA,KAA0B,aAC7B,MAAMA,qBAAA,CAAsBE,IAAA,IAC3BF,qBAAA,IAAyB;QAEhC;QACA,IAAIM,cAAA,KAAmB,OAAO;UAC5B,OAAO;QACT;QAEA;QACA,MAAMC,KAAA,GAAQZ,MAAA,CAAOa,WAAW,CAACC,IAAI,CAAC,CAAC;UAAEC;QAAI,CAAE,KAAKA,IAAA,KAASP,UAAA,GAAaI,KAAA;QAE1E;QACA,MAAMI,MAAA,GAASJ,KAAA,EAAOI,MAAA;QACtB,IAAI,OAAOA,MAAA,KAAW,cAAcA,MAAA,CAAO;UAAEN;QAAK,IAAsB;UACtE,OAAO;QACT;QAEA;QACA,MAAMO,UAAA,GAAaL,KAAA,EAAOK,UAAA,IAAcL,KAAA,EAAOM,cAAA;QAC/C,MAAMC,gBAAA,GAAmB,MAAMF,UAAA,GAAa;UAC1CG,KAAA,EAAO;UACPC,IAAA,EAAM;UACNZ,GAAA;UACAa,IAAA,EAAM;QACR;QAEA;QACA,IAAI,CAACH,gBAAA,EAAkB;UACrB,OAAOR,cAAA;QACT;QAEA;QACA,IAAIA,cAAA,KAAmB,MAAM;UAC3B,OAAOQ,gBAAA;QACT;QAEA;QACA,OAAOtB,uBAAA,CAAwB,CAACc,cAAA,EAAgBQ,gBAAA,CAAiB,EAAE;MACrE;MAEA,OAAOf,iBAAA;IACT;IAEA;IACA,IAAI,YAAYF,KAAA,IAASA,KAAA,CAAMH,MAAM,EAAE;MACrC,OAAO;QACL,GAAGG,KAAK;QACRH,MAAA,EAAQD,uBAAA,CAAwBI,KAAA,CAAMH,MAAM,EAAEC,MAAA;MAChD;IACF;IAEA;IACA,IAAIE,KAAA,CAAMC,IAAI,KAAK,UAAU,UAAUD,KAAA,EAAO;MAC5C,OAAO;QACL,GAAGA,KAAK;QACRqB,IAAA,EAAMrB,KAAA,CAAMqB,IAAI,CAACtB,GAAG,CAAEuB,GAAA,KAAS;UAC7B,GAAGA,GAAG;UACNzB,MAAA,EAAQD,uBAAA,CAAwB0B,GAAA,CAAIzB,MAAM,EAAEC,MAAA;QAC9C;MACF;IACF;IAEA;IACA,IAAIE,KAAA,CAAMC,IAAI,KAAK,UAAU;MAC3B,OAAO;QACL,GAAGD,KAAK;QACRuB,MAAA,EAAQvB,KAAA,CAAMuB,MAAM,CAACxB,GAAG,CAAEyB,KAAA;UACxB,IAAI,OAAOA,KAAA,KAAU,UAAU;YAC7B,OAAOA,KAAA;UACT;UACA,OAAO;YACL,GAAGA,KAAK;YACR3B,MAAA,EAAQD,uBAAA,CAAwB4B,KAAA,CAAM3B,MAAM,EAAEC,MAAA;UAChD;QACF;MACF;IACF;IAEA,OAAOE,KAAA;EACT;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAK9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,eAAO,MAAM,oBAAoB,GAC9B,MAAM;IACL,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;IACtC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,CAoDtC,CAAA"}
1
+ {"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,eAAO,MAAM,oBAAoB,GAC9B,MAAM;IACL,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;IACtC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,CAiDtC,CAAA"}
@@ -1,5 +1,4 @@
1
1
  import { genImportMapIterateFields } from 'payload';
2
- import { isRSCEnabled } from 'payload/shared';
3
2
  export const getGenerateImportMap = args => ({
4
3
  addToImportMap,
5
4
  baseDir,
@@ -7,12 +6,9 @@ export const getGenerateImportMap = args => ({
7
6
  importMap,
8
7
  imports
9
8
  }) => {
10
- if (isRSCEnabled()) {
11
- addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell');
12
- addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField');
13
- addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent');
14
- }
15
- addToImportMap('@payloadcms/richtext-lexical/client#ClientEntryLexicalField');
9
+ addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell');
10
+ addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField');
11
+ addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent');
16
12
  addToImportMap(args.lexicalEditorArgs?.views);
17
13
  for (const resolvedFeature of args.resolvedFeatureMap.values()) {
18
14
  if ('componentImports' in resolvedFeature) {
@@ -1 +1 @@
1
- {"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","isRSCEnabled","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","lexicalEditorArgs","views","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","Object","ClientFeature","nodes","length","node","getSubFields","subFields","fields"],"sources":["../../src/utilities/generateImportMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { genImportMapIterateFields } from 'payload'\nimport { isRSCEnabled } from 'payload/shared'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { LexicalEditorProps } from '../types/index.js'\n\nexport const getGenerateImportMap =\n (args: {\n lexicalEditorArgs?: LexicalEditorProps\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateImportMap'] =>\n ({ addToImportMap, baseDir, config, importMap, imports }) => {\n if (isRSCEnabled()) {\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell')\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField')\n addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent')\n }\n addToImportMap('@payloadcms/richtext-lexical/client#ClientEntryLexicalField')\n\n addToImportMap(args.lexicalEditorArgs?.views)\n\n for (const resolvedFeature of args.resolvedFeatureMap.values()) {\n if ('componentImports' in resolvedFeature) {\n if (typeof resolvedFeature.componentImports === 'function') {\n resolvedFeature.componentImports({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n } else if (Array.isArray(resolvedFeature.componentImports)) {\n addToImportMap(resolvedFeature.componentImports)\n } else if (typeof resolvedFeature.componentImports === 'object') {\n addToImportMap(Object.values(resolvedFeature.componentImports))\n }\n }\n\n addToImportMap(resolvedFeature.ClientFeature)\n\n /*\n * Now run for all possible sub-fields\n */\n if (resolvedFeature.nodes?.length) {\n for (const node of resolvedFeature.nodes) {\n if (typeof node?.getSubFields !== 'function') {\n continue\n }\n const subFields = node.getSubFields({})\n if (subFields?.length) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: subFields,\n importMap,\n imports,\n })\n }\n }\n }\n }\n }\n"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,YAAY,QAAQ;AAK7B,OAAO,MAAMC,oBAAA,GACVC,IAAA,IAID,CAAC;EAAEC,cAAc;EAAEC,OAAO;EAAEC,MAAM;EAAEC,SAAS;EAAEC;AAAO,CAAE;EACtD,IAAIP,YAAA,IAAgB;IAClBG,cAAA,CAAe;IACfA,cAAA,CAAe;IACfA,cAAA,CAAe;EACjB;EACAA,cAAA,CAAe;EAEfA,cAAA,CAAeD,IAAA,CAAKM,iBAAiB,EAAEC,KAAA;EAEvC,KAAK,MAAMC,eAAA,IAAmBR,IAAA,CAAKS,kBAAkB,CAACC,MAAM,IAAI;IAC9D,IAAI,sBAAsBF,eAAA,EAAiB;MACzC,IAAI,OAAOA,eAAA,CAAgBG,gBAAgB,KAAK,YAAY;QAC1DH,eAAA,CAAgBG,gBAAgB,CAAC;UAC/BV,cAAA;UACAC,OAAA;UACAC,MAAA;UACAC,SAAA;UACAC;QACF;MACF,OAAO,IAAIO,KAAA,CAAMC,OAAO,CAACL,eAAA,CAAgBG,gBAAgB,GAAG;QAC1DV,cAAA,CAAeO,eAAA,CAAgBG,gBAAgB;MACjD,OAAO,IAAI,OAAOH,eAAA,CAAgBG,gBAAgB,KAAK,UAAU;QAC/DV,cAAA,CAAea,MAAA,CAAOJ,MAAM,CAACF,eAAA,CAAgBG,gBAAgB;MAC/D;IACF;IAEAV,cAAA,CAAeO,eAAA,CAAgBO,aAAa;IAE5C;;;IAGA,IAAIP,eAAA,CAAgBQ,KAAK,EAAEC,MAAA,EAAQ;MACjC,KAAK,MAAMC,IAAA,IAAQV,eAAA,CAAgBQ,KAAK,EAAE;QACxC,IAAI,OAAOE,IAAA,EAAMC,YAAA,KAAiB,YAAY;UAC5C;QACF;QACA,MAAMC,SAAA,GAAYF,IAAA,CAAKC,YAAY,CAAC,CAAC;QACrC,IAAIC,SAAA,EAAWH,MAAA,EAAQ;UACrBpB,yBAAA,CAA0B;YACxBI,cAAA;YACAC,OAAA;YACAC,MAAA;YACAkB,MAAA,EAAQD,SAAA;YACRhB,SAAA;YACAC;UACF;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","lexicalEditorArgs","views","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","Object","ClientFeature","nodes","length","node","getSubFields","subFields","fields"],"sources":["../../src/utilities/generateImportMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { genImportMapIterateFields } from 'payload'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { LexicalEditorProps } from '../types/index.js'\n\nexport const getGenerateImportMap =\n (args: {\n lexicalEditorArgs?: LexicalEditorProps\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateImportMap'] =>\n ({ addToImportMap, baseDir, config, importMap, imports }) => {\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell')\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField')\n addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent')\n\n addToImportMap(args.lexicalEditorArgs?.views)\n\n for (const resolvedFeature of args.resolvedFeatureMap.values()) {\n if ('componentImports' in resolvedFeature) {\n if (typeof resolvedFeature.componentImports === 'function') {\n resolvedFeature.componentImports({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n } else if (Array.isArray(resolvedFeature.componentImports)) {\n addToImportMap(resolvedFeature.componentImports)\n } else if (typeof resolvedFeature.componentImports === 'object') {\n addToImportMap(Object.values(resolvedFeature.componentImports))\n }\n }\n\n addToImportMap(resolvedFeature.ClientFeature)\n\n /*\n * Now run for all possible sub-fields\n */\n if (resolvedFeature.nodes?.length) {\n for (const node of resolvedFeature.nodes) {\n if (typeof node?.getSubFields !== 'function') {\n continue\n }\n const subFields = node.getSubFields({})\n if (subFields?.length) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: subFields,\n importMap,\n imports,\n })\n }\n }\n }\n }\n }\n"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ;AAK1C,OAAO,MAAMC,oBAAA,GACVC,IAAA,IAID,CAAC;EAAEC,cAAc;EAAEC,OAAO;EAAEC,MAAM;EAAEC,SAAS;EAAEC;AAAO,CAAE;EACtDJ,cAAA,CAAe;EACfA,cAAA,CAAe;EACfA,cAAA,CAAe;EAEfA,cAAA,CAAeD,IAAA,CAAKM,iBAAiB,EAAEC,KAAA;EAEvC,KAAK,MAAMC,eAAA,IAAmBR,IAAA,CAAKS,kBAAkB,CAACC,MAAM,IAAI;IAC9D,IAAI,sBAAsBF,eAAA,EAAiB;MACzC,IAAI,OAAOA,eAAA,CAAgBG,gBAAgB,KAAK,YAAY;QAC1DH,eAAA,CAAgBG,gBAAgB,CAAC;UAC/BV,cAAA;UACAC,OAAA;UACAC,MAAA;UACAC,SAAA;UACAC;QACF;MACF,OAAO,IAAIO,KAAA,CAAMC,OAAO,CAACL,eAAA,CAAgBG,gBAAgB,GAAG;QAC1DV,cAAA,CAAeO,eAAA,CAAgBG,gBAAgB;MACjD,OAAO,IAAI,OAAOH,eAAA,CAAgBG,gBAAgB,KAAK,UAAU;QAC/DV,cAAA,CAAea,MAAA,CAAOJ,MAAM,CAACF,eAAA,CAAgBG,gBAAgB;MAC/D;IACF;IAEAV,cAAA,CAAeO,eAAA,CAAgBO,aAAa;IAE5C;;;IAGA,IAAIP,eAAA,CAAgBQ,KAAK,EAAEC,MAAA,EAAQ;MACjC,KAAK,MAAMC,IAAA,IAAQV,eAAA,CAAgBQ,KAAK,EAAE;QACxC,IAAI,OAAOE,IAAA,EAAMC,YAAA,KAAiB,YAAY;UAC5C;QACF;QACA,MAAMC,SAAA,GAAYF,IAAA,CAAKC,YAAY,CAAC,CAAC;QACrC,IAAIC,SAAA,EAAWH,MAAA,EAAQ;UACrBnB,yBAAA,CAA0B;YACxBG,cAAA;YACAC,OAAA;YACAC,MAAA;YACAkB,MAAA,EAAQD,SAAA;YACRhB,SAAA;YACAC;UACF;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "4.0.0-internal.2fddfc0",
3
+ "version": "4.0.0-internal.3aa3d85",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -60,7 +60,6 @@
60
60
  },
61
61
  "./rsc": {
62
62
  "types": "./dist/exports/server/rsc.d.ts",
63
- "browser": "./dist/exports/server/rsc.browser.js",
64
63
  "import": "./dist/exports/server/rsc.js",
65
64
  "default": "./dist/exports/server/rsc.js"
66
65
  },
@@ -179,11 +178,6 @@
179
178
  "types": "./dist/lexical-proxy/@lexical-react/LexicalContentEditable.d.ts",
180
179
  "default": "./dist/lexical-proxy/@lexical-react/LexicalContentEditable.js"
181
180
  },
182
- "./lexical/react/LexicalContextMenuPlugin": {
183
- "import": "./dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js",
184
- "types": "./dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts",
185
- "default": "./dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js"
186
- },
187
181
  "./lexical/react/LexicalNodeContextMenuPlugin": {
188
182
  "import": "./dist/lexical-proxy/@lexical-react/LexicalNodeContextMenuPlugin.js",
189
183
  "types": "./dist/lexical-proxy/@lexical-react/LexicalNodeContextMenuPlugin.d.ts",
@@ -349,24 +343,25 @@
349
343
  ]
350
344
  },
351
345
  "dependencies": {
352
- "@lexical/clipboard": "0.41.0",
353
- "@lexical/headless": "0.41.0",
354
- "@lexical/html": "0.41.0",
355
- "@lexical/link": "0.41.0",
356
- "@lexical/list": "0.41.0",
357
- "@lexical/mark": "0.41.0",
358
- "@lexical/react": "0.41.0",
359
- "@lexical/rich-text": "0.41.0",
360
- "@lexical/selection": "0.41.0",
361
- "@lexical/table": "0.41.0",
362
- "@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",
363
358
  "acorn": "8.16.0",
364
359
  "bson-objectid": "2.0.4",
365
360
  "csstype": "3.2.3",
366
361
  "dequal": "2.0.3",
367
362
  "escape-html": "1.0.3",
368
363
  "jsox": "1.2.125",
369
- "lexical": "0.41.0",
364
+ "lexical": "0.45.0",
370
365
  "mdast-util-from-markdown": "2.0.3",
371
366
  "mdast-util-mdx-jsx": "3.2.0",
372
367
  "micromark-extension-mdx-jsx": "3.0.2",
@@ -374,8 +369,8 @@
374
369
  "react-error-boundary": "6.1.1",
375
370
  "ts-essentials": "10.0.3",
376
371
  "uuid": "14.0.0",
377
- "@payloadcms/translations": "4.0.0-internal.2fddfc0",
378
- "@payloadcms/ui": "4.0.0-internal.2fddfc0"
372
+ "@payloadcms/translations": "4.0.0-internal.3aa3d85",
373
+ "@payloadcms/ui": "4.0.0-internal.3aa3d85"
379
374
  },
380
375
  "devDependencies": {
381
376
  "@babel/cli": "7.27.2",
@@ -383,7 +378,7 @@
383
378
  "@babel/preset-env": "7.27.2",
384
379
  "@babel/preset-react": "7.27.1",
385
380
  "@babel/preset-typescript": "7.27.1",
386
- "@lexical/eslint-plugin": "0.41.0",
381
+ "@lexical/eslint-plugin": "0.45.0",
387
382
  "@types/escape-html": "1.0.4",
388
383
  "@types/json-schema": "7.0.15",
389
384
  "@types/node": "24.12.3",
@@ -394,16 +389,16 @@
394
389
  "esbuild": "0.27.1",
395
390
  "esbuild-sass-plugin": "3.3.1",
396
391
  "swc-plugin-transform-remove-imports": "8.3.0",
397
- "@payloadcms/eslint-config": "3.28.0",
398
- "payload": "4.0.0-internal.2fddfc0"
392
+ "payload": "4.0.0-internal.3aa3d85",
393
+ "@payloadcms/eslint-config": "3.28.0"
399
394
  },
400
395
  "peerDependencies": {
401
- "@faceless-ui/modal": "3.0.0",
396
+ "@faceless-ui/modal": "3.0.1-canary.0",
402
397
  "@faceless-ui/scroll-info": "2.0.0",
403
398
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
404
399
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
405
- "@payloadcms/next": "4.0.0-internal.2fddfc0",
406
- "payload": "4.0.0-internal.2fddfc0"
400
+ "@payloadcms/next": "4.0.0-internal.3aa3d85",
401
+ "payload": "4.0.0-internal.3aa3d85"
407
402
  },
408
403
  "engines": {
409
404
  "node": ">=24.15.0"
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=assets.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assets.d.js","names":[],"sources":["../../src/@types/assets.d.ts"],"sourcesContent":[null],"mappings":"","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- "use client";import{a as Oe,e as Ie,g as $,h as K,j as Fe,k as $e,l as Ke,m as je,n as Se,o as Pe,p as ze}from"./chunk-4EIYXZ6H.js";import{a as Be,b as P}from"./chunk-RJ5MAOKZ.js";import{jsx as L,jsxs as le}from"react/jsx-runtime";import{BulkUploadProvider as tr,FieldDescription as or,FieldError as nr,FieldLabel as rr,isFieldRTL as ir,RenderCustomComponent as Ft,useConfig as sr,useEditDepth as lr,useEffectEvent as ar,useField as cr,useLocale as ur}from"@payloadcms/ui";import{mergeFieldStyles as dr}from"@payloadcms/ui/shared";import{dequal as fr}from"dequal/lite";import $t,{useCallback as Kt,useEffect as jt,useMemo as mr,useState as zt}from"react";import{ErrorBoundary as pr}from"react-error-boundary";import"./bundled.css";import{jsx as j}from"react/jsx-runtime";import{LexicalComposer as Gn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as Un}from"@payloadcms/ui";import*as De from"react";import{useMemo as Mt}from"react";import{c as kt}from"react/compiler-runtime";import{jsx as b,jsxs as ie}from"react/jsx-runtime";import{useLexicalComposerContext as _t}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Mn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as An}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Bn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as On}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as In}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as Fn,COMMAND_PRIORITY_LOW as vt,FOCUS_COMMAND as $n}from"lexical";import*as Q from"react";import{useEffect as Lt,useState as Kn}from"react";import{jsx as He}from"react/jsx-runtime";import"react";var z=({anchorElem:e,clientProps:t,plugin:o})=>o.position==="floatingAnchorElem"&&e?o.Component&&He(o.Component,{anchorElem:e,clientProps:t}):o.Component&&He(o.Component,{clientProps:t});import{c as Yt}from"react/compiler-runtime";import{copyToClipboard as Ve}from"@lexical/clipboard";import{useLexicalComposerContext as Gt}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as Ut}from"@lexical/utils";import We from"bson-objectid";import{$getSelection as Jt,$isNodeSelection as qt,COMMAND_PRIORITY_LOW as Qt,COPY_COMMAND as Xt}from"lexical";import{useEffect as Zt}from"react";var Re=e=>{if("fields"in e&&typeof e.fields=="object"&&e.fields!==null&&"id"in e.fields?e.fields.id=new We.default().toHexString():"id"in e&&(e.id=new We.default().toHexString()),e.children)for(let t of e.children)Re(t)};function Ye(){let e=Yt(3),[t]=Gt(),o,n;return e[0]!==t?(o=()=>t.registerCommand(Xt,r=>{let c=Jt();if(qt(c)){let l=c.getNodes()[0]?.exportJSON(),u=JSON.parse(JSON.stringify(l));Re(u);let d={namespace:t._config.namespace,nodes:[u]},m=JSON.stringify(d);return Ve(t,null,{"application/x-lexical-editor":m,"text/plain":""}).catch(eo),!0}return Ve(t,Ut(r,ClipboardEvent)?r:null).then(()=>{if(!(r instanceof ClipboardEvent)||!r.clipboardData)throw new Error("No clipboard event");let i=r.clipboardData.getData("application/x-lexical-editor");if(!i)return!0;let l=JSON.parse(i);for(let d of l.nodes)Re(d);let u=JSON.stringify(l);r.clipboardData.setData("application/x-lexical-editor",u)}).catch(i=>{throw r instanceof ClipboardEvent&&r.clipboardData?.setData("application/x-lexical-editor",""),i}),!0},Qt),n=[t],e[0]=t,e[1]=o,e[2]=n):(o=e[1],n=e[2]),Zt(o,n),null}function eo(e){throw e}import{c as to}from"react/compiler-runtime";import{useLexicalComposerContext as oo}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as fe,mergeRegister as no}from"@lexical/utils";import{$createNodeSelection as ro,$getEditor as te,$getNearestNodeFromDOMNode as io,$getSelection as me,$isDecoratorNode as H,$isElementNode as Te,$isLineBreakNode as so,$isNodeSelection as pe,$isRangeSelection as Ge,$isRootOrShadowRoot as lo,$isTextNode as ao,$setSelection as Ue,CLICK_COMMAND as co,COMMAND_PRIORITY_LOW as Y,KEY_ARROW_DOWN_COMMAND as uo,KEY_ARROW_UP_COMMAND as fo,KEY_BACKSPACE_COMMAND as mo,KEY_DELETE_COMMAND as po,SELECTION_CHANGE_COMMAND as go}from"lexical";import{useEffect as ho}from"react";function Je(){let e=to(3),[t]=oo(),o=wo,n,r;return e[0]!==t?(n=()=>no(t.registerCommand(co,No,Y),t.registerCommand(po,o,Y),t.registerCommand(mo,o,Y),t.registerCommand(go,Co,Y),t.registerCommand(fo,Eo,Y),t.registerCommand(uo,yo,Y)),r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),ho(n,r),null}function yo(e){let t=me();if(pe(t)){e.preventDefault();let i=t.getNodes()[0]?.getNextSibling();if(H(i)){let d=te().getElementByKey(i.getKey());return d&&oe({element:d,node:i}),!0}if(!Te(i))return!0;let l=i.getFirstDescendant()??i;return l&&(fe(l,ge)?.selectEnd(),e.preventDefault()),!0}if(!Ge(t))return!1;let n=(t.isBackward()?t.anchor:t.focus).getNode(),r=fe(n,xo),c=r?.getNextSibling();if(!r||c!==qe(r))return!1;if(H(c)){let i=te().getElementByKey(c.getKey());if(i)return oe({element:i,node:c}),e.preventDefault(),!0}return!1}function xo(e){return qe(e)!==null}function Eo(e){let t=me();if(pe(t)){let i=t.getNodes()[0]?.getPreviousSibling();if(H(i)){let d=te().getElementByKey(i.getKey());return d?(oe({element:d,node:i}),e.preventDefault(),!0):!1}if(!Te(i))return!1;let l=i.getLastDescendant()??i;return l?(fe(l,ge)?.selectStart(),e.preventDefault(),!0):!1}if(!Ge(t))return!1;let n=(t.isBackward()?t.anchor:t.focus).getNode(),r=fe(n,bo),c=r?.getPreviousSibling();if(!r||c!==Qe(r))return!1;if(H(c)){let i=te().getElementByKey(c.getKey());if(i)return oe({element:i,node:c}),e.preventDefault(),!0}return!1}function bo(e){return Qe(e)!==null}function Co(){let e=Ro();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),e?(e.element?.classList.add("decorator-selected"),!0):!1}function No(e){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let t=Po(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"]')?Ue(null):oe(t),!0}function wo(e){let t=me();return pe(t)?(e.preventDefault(),t.getNodes().forEach(So),!0):!1}function So(e){e.remove()}function Po(e){if(!(e.target instanceof HTMLElement))return;let t=e.target.closest('[data-lexical-decorator="true"]');if(!(t instanceof HTMLElement))return;let o=io(t);return H(o)?{element:t,node:o}:void 0}function Ro(){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=ro();o.add(t.getKey()),Ue(o),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.classList.add("decorator-selected")}function ge(e){if(H(e)&&!e.isInline())return!0;if(!Te(e)||lo(e))return!1;let t=e.getFirstChild(),o=t===null||so(t)||ao(t)||t.isInline();return!e.isInline()&&e.canBeEmpty()!==!1&&o}function qe(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 Do}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Mo,isHTMLElement as Ao}from"lexical";import*as tt from"react";import{useCallback as Bo,useEffect as et,useRef as Oo,useState as Io}from"react";import{createPortal as Fo}from"react-dom";var G=(e,t,o,n,r=50,c=25)=>{let i=0;if(e&&!e.contains(n)){let{bottom:l,left:u,right:d,top:m}=e.getBoundingClientRect(),a=m+window.scrollY,s=l+window.scrollY;if(o<a-c||o>s+c||t<u-r||t>d+r)return-1;(t<u||t>d)&&(i=t<u?t-u:t-d)}return i};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 n=o.split(",").pop();return t.y=t.y-Number(n?.replace(")","")),t}function he(e){let t=(u,d)=>u?parseFloat(window.getComputedStyle(u)[d]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(e),r=t(e.previousElementSibling,"marginBottom"),c=t(e.nextElementSibling,"marginTop"),i=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as To}from"lexical";function V(e){return e.getEditorState().read(()=>To().getChildrenKeys())}var vo=1,ko=-1,Xe=0,B={props:null,result:null};function _o(e,t,o=20){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=o*o}function J(e){let{anchorElem:t,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:c=0,point:{x:i,y:l},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&&_o(B.props.point,e.point,o))return B.result;let m=t.getBoundingClientRect(),a=V(n),s={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(d){let p=n.getElementByKey(a[0]),g=n.getElementByKey(a[a.length-1]);if(p&&g){let[f,x]=[U(p),U(g)];if(l<f.top?(s.blockElem=p,s.distance=f.top-l,s.blockNode=ye(a[0]),s.foundAtIndex=0):l>x.bottom&&(s.distance=l-x.bottom,s.blockNode=ye(a[a.length-1]),s.blockElem=g,s.foundAtIndex=a.length-1),s?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let E=u,y=Xe;for(;E>=0&&E<a.length;){let p=a[E],g=n.getElementByKey(p);if(g===null)break;let f=new K(i+c,l),x=je.fromDOMRect(U(g)),{marginBottom:h,marginTop:C}=he(g),k=x.generateNewRect({bottom:x.bottom+h,left:m.left,right:m.right,top:x.top-C}),{distance:w,isOnBottomSide:v,isOnTopSide:D}=k.distanceFromPoint(f);if(w===0){s.blockElem=g,s.blockNode=ye(p),s.foundAtIndex=E,s.distance=w,s.blockNode&&s.blockNode.getType()==="paragraph"&&s.blockNode.getTextContent()===""&&(!r&&!e.returnEmptyParagraphs&&(s.blockElem=null,s.blockNode=null),s.isFoundNodeEmptyParagraph=!0);break}else r&&w<s.distance&&(s.blockElem=g,s.blockNode=ye(p),s.distance=w,s.foundAtIndex=E);y===Xe&&(D?y=ko:v?y=vo:y=1/0),E+=y}}),B.props=e,B.result={blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph},{blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph}}function xe(e,t){return!!e.closest(`.${t}`)}var Lo=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ze(e){if(!e||Lo.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,n=0){if(!e){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}let r=e.getBoundingClientRect(),c=window.getComputedStyle(e),i=t.getBoundingClientRect(),l=o.getBoundingClientRect(),u;if(["LexicalEditorTheme__block","LexicalEditorTheme__upload","LexicalEditorTheme__relationship"].some(a=>e.classList.contains(a)||e.firstElementChild?.classList.contains(a)))u=r.top+8-l.top;else{let a=Ze(e)?parseInt(c.lineHeight,10):0;u=r.top+(a-i.height)/2-l.top}let m=n;t.style.opacity="1",t.style.transform=`translate(${m}px, ${u}px)`}var $o="add-block-menu",be=1/0;function Ko(e){return e===0?1/0:be>=0&&be<e?be:Math.floor(e/2)}function jo(e,t,o){let n=t.parentElement,{editorConfig:r}=P(),c=r?.admin?.hideGutter?-24:12,i=Oo(null),[l,u]=Io(null);et(()=>{function m(a){let s=a.target;if(!Ao(s))return;let E=G(n,a.pageX,a.pageY,s);if(E===-1){u(null);return}if(xe(s,$o))return;let y=V(e),{blockElem:p,blockNode:g,foundAtIndex:f}=J({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-E,point:new K(a.x,a.y),returnEmptyParagraphs:!0,startIndex:Ko(y.length),useEdgeAsDefault:!1});be=f,p&&g&&(l?.node!==g||l?.elem!==p)&&u({elem:p,node:g})}return document?.addEventListener("mousemove",m),()=>{document?.removeEventListener("mousemove",m)}},[n,t,e,l]),et(()=>{i.current&&l?.node&&Ee(l?.elem,i.current,t,c)},[t,l,c]);let d=Bo(m=>{let a=l;a?.node&&(e.update(()=>{let s=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(s=!1),!s){let E=Mo();a?.node.insertAfter(E),setTimeout(()=>{a={elem:e.getElementByKey(E.getKey()),node:E},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($e,{node:a?.node})},2),m.stopPropagation(),m.preventDefault())},[e,l]);return Fo(ve(tt.Fragment,{children:ve("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:m=>{d(m)},ref:i,type:"button",children:ve("div",{className:o?"icon":""})})}),t)}function ot(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[n]=Do();return jo(n,o,n._editable)}import{jsx as Ce,jsxs as Ho}from"react/jsx-runtime";import{useLexicalComposerContext as Vo}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as it}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as st,$getNodeByKey as Wo,isHTMLElement as ke}from"lexical";import*as dt from"react";import{useEffect as _e,useRef as ne,useState as lt}from"react";import{createPortal as Yo}from"react-dom";var nt=0,zo=-24;var W=0;function rt(e,t,o,n,r,c,i,l,u,d=!1){let{height:m,top:a}=n.getBoundingClientRect(),{top:s,width:E}=i.getBoundingClientRect(),{marginBottom:y,marginTop:p}=he(n),g=a,f=c>=a+m/2+window.scrollY,x=!1;if(r?.elem)if(n!==r?.elem)(f&&r?.elem&&r?.elem===n.nextElementSibling||!f&&r?.elem&&r?.elem===n.previousElementSibling)&&(W++,W<200&&(x=!0));else{W++;let w=r?.boundingBox?.y,v=n.getBoundingClientRect().y;(f===r?.isBelow&&w===v||W<200)&&(x=!1)}if(x)return{isBelow:f,willStayInSamePosition:x};d?g+=m/2:f?g+=m+y/2:g-=p/2;let h=0;d||(f?h=-nt:h=nt);let C=g-s+h,k=zo-t;return o.style.width=`calc(${E}px - ${e} - var(--spacer-5))`,o.style.opacity=".8",o.style.transform=`translate(${k}px, calc(${C}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?f?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),W=0,{isBelow:f,willStayInSamePosition:x}}var Go="draggable-block-menu",at="application/x-lexical-drag-block",re=1/0;function ct(e){return e===0?1/0:re>=0&&re<e?re:Math.floor(e/2)}function Uo(e,t){let{transform:o}=t.style;e.setDragImage(t,0,0),setTimeout(()=>{t.style.transform=o})}function ut(e,t){e&&(e.style.opacity="0"),t&&(t.style.opacity="",t.style.marginBottom="",t.style.marginTop="")}function Jo(e,t,o){let n=t.parentElement,r=ne(null),c=ne(null),i=ne(null),l=ne(!1),u=ne([]),[d,m]=lt(null),[a,s]=lt(null),{editorConfig:E}=P(),y=E?.admin?.hideGutter?-44:-8;_e(()=>{function f(x){let h=x.target;if(!ke(h))return;let C=G(n,x.pageX,x.pageY,h);if(C===-1){m(null);return}if(xe(h,Go))return;let k=V(e),{blockElem:w,foundAtIndex:v,isFoundNodeEmptyParagraph:D}=J({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-C,point:new K(x.x,x.y),startIndex:ct(k.length),useEdgeAsDefault:!1,verbose:!1});re=v,!(!w&&!D)&&d!==w&&m(w)}return document?.addEventListener("mousemove",f),()=>{document?.removeEventListener("mousemove",f)}},[n,t,e,d]),_e(()=>{r.current&&Ee(d,r.current,t,y)},[t,d,y]),_e(()=>{function f(h){if(!l.current)return!1;let[C]=it(h);if(C)return!1;let{pageY:k,target:w}=h;if(!ke(w))return!1;let v=G(n,h.pageX,h.pageY,w,100,50),D=V(e),{blockElem:S,foundAtIndex:I,isFoundNodeEmptyParagraph:T}=J({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-v,point:new K(h.x,h.y),startIndex:ct(D.length),useEdgeAsDefault:!0,verbose:!0});re=I;let F=c.current;if(S===null||F===null)return!1;if(h.preventDefault(),h.dataTransfer.dropEffect="move",d!==S){let{isBelow:_,willStayInSamePosition:M}=rt(E?.admin?.hideGutter?"0px":"var(--spacer-5)",y+(E?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),F,S,a,k,t,h,i,T);M||s({boundingBox:S.getBoundingClientRect(),elem:S,isBelow:_})}else a?.elem&&(ut(F,a.elem),s({boundingBox:S.getBoundingClientRect(),elem:S,isBelow:!1}));return!0}function x(h){if(!l.current)return!1;let[C]=it(h);if(C)return!1;let{dataTransfer:k,pageY:w,target:v}=h,D=k?.getData(at)||"";return e.update(()=>{let S=Wo(D);if(!S||!ke(v))return!1;let I=G(n,h.pageX,h.pageY,v,100,50),{blockElem:T,isFoundNodeEmptyParagraph:F}=J({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-I,point:new K(h.x,h.y),useEdgeAsDefault:!0});if(!T)return!1;let _=st(T);if(!_)return!1;if(_===S)return!0;let{height:M,top:ae}=U(T),Ne=w>=ae+M/2+window.scrollY;F?(_.insertBefore(S),_.remove()):Ne?_.insertAfter(S):_.insertBefore(S),d!==null&&m(null),document.querySelectorAll(".lexical-block-highlighter").forEach(R=>{R.remove()});let we=e.getElementByKey(S.getKey()),ce=setTimeout(()=>{let R=we?.getBoundingClientRect();if(!R)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=`${R.height+8}px`,N.style.width=`${R.width+8}px`,N.style.top=`${R.top+window.scrollY-4}px`,N.style.left=`${R.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",x),()=>{document.removeEventListener("dragover",f),document.removeEventListener("drop",x),u.current.forEach(clearTimeout),u.current=[]}},[n,y,t,e,a,d,E?.admin?.hideGutter]);function p(f){let x=f.dataTransfer;if(!x||!d)return;Uo(x,d),x.effectAllowed="move";let h="";e.update(()=>{let C=st(d);C&&(h=C.getKey())}),l.current=!0,x.setData(at,h)}function g(){l.current=!1,a?.elem&&ut(c.current,a?.elem)}return Yo(Ho(dt.Fragment,{children:[Ce("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:g,onDragStart:p,ref:r,type:"button",children:Ce("div",{className:o?"icon":""})}),Ce("div",{className:"draggable-block-target-line",ref:c}),Ce("div",{className:"debug-highlight",ref:i})]}),t)}function ft(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[n]=Vo();return Jo(n,o,n._editable)}import{c as qo}from"react/compiler-runtime";import{jsx as Le}from"react/jsx-runtime";import{useLexicalComposerContext as Qo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Xo,$getRoot as Zo}from"lexical";import"react";var mt="insert-paragraph-at-end",pt=()=>{let e=qo(2),[t]=Qo(),{editorConfig:o}=P();if(o?.admin?.hideInsertParagraphAtEnd)return null;let n;return e[0]!==t?(n=Le("div",{"aria-label":"Insert Paragraph",className:mt,onClick:()=>{t.update(en)},role:"button",tabIndex:0,children:Le("div",{className:`${mt}-inside`,children:Le("span",{children:"+"})})}),e[0]=t,e[1]=n):n=e[1],n};function en(){let e=Xo();Zo().append(e),e.select()}import{c as tn}from"react/compiler-runtime";import{useLexicalComposerContext as on}from"@lexical/react/LexicalComposerContext";import*as gt from"react";var ht=()=>{let e=tn(4),{editorConfig:t}=P(),[o]=on(),n,r;return e[0]!==o||e[1]!==t.features.markdownTransformers?(n=()=>Oe(o,t.features.markdownTransformers??[]),r=[o,t.features.markdownTransformers],e[0]=o,e[1]=t.features.markdownTransformers,e[2]=n,e[3]=r):(n=e[2],r=e[3]),gt.useEffect(n,r),null};import{c as nn}from"react/compiler-runtime";import{useLexicalComposerContext as rn}from"@lexical/react/LexicalComposerContext.js";import{useEffect as sn}from"react";function yt(){let e=nn(5),[t]=rn(),{currentView:o,views:n}=$(),r,c;return e[0]!==o||e[1]!==t||e[2]!==n?(r=()=>{n&&(o==="default"?n.default?Se(t,n.default?.nodes):Pe(t):n[o]&&(Pe(t),Se(t,n[o]?.nodes)))},c=[t,n,o],e[0]=o,e[1]=t,e[2]=n,e[3]=r,e[4]=c):(r=e[3],c=e[4]),sn(r,c),null}import{useLexicalComposerContext as ln}from"@lexical/react/LexicalComposerContext";import{$getSelection as an,$isRangeSelection as cn,RootNode as un}from"lexical";import{useEffect as dn}from"react";function xt(){let[e]=ln();return dn(()=>e.registerNodeTransform(un,t=>{let o=an();if(cn(o)){let n=o.anchor.getNode(),r=o.focus.getNode();(!n.isAttached()||!r.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 fn}from"@lexical/react/LexicalComposerContext";import{$getSelection as mn,COMMAND_PRIORITY_LOW as pn,SELECT_ALL_COMMAND as gn}from"lexical";import{useEffect as hn}from"react";function Et(){let[e]=fn();return hn(()=>e.registerCommand(gn,()=>{if(mn())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},pn),[e]),null}import{jsx as q,jsxs as Ct}from"react/jsx-runtime";import{useLexicalComposerContext as xn}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as Nt}from"@payloadcms/ui";import{useCallback as En,useMemo as bn,useState as Cn}from"react";import"react";import*as wt from"react-dom";import{c as yn}from"react/compiler-runtime";import"react";function bt(e,t){let o=yn(4),{maxLength:n,minLength:r}=t,c=n===void 0?75:n,i=r===void 0?1:r,l;return o[0]!==c||o[1]!==i||o[2]!==e?(l=u=>{let{query:d}=u,m="[^"+e+Fe+"\\s]",s=new RegExp("(^|\\s|\\()(["+e+"]((?:"+m+"){0,"+c+"}))$").exec(d);if(s!==null){let E=s[1],y=s[3];if(y.length>=i)return{leadOffset:s.index+E.length,matchingString:y,replaceableString:s[2]}}return null},o[0]=c,o[1]=i,o[2]=e,o[3]=l):l=o[3],l}var O="slash-menu-popup";function Nn({isSelected:e,item:t,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=P(),{i18n:l}=Nt(),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:l,schemaPath:i}):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:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[t?.Icon&&q(t.Icon,{}),q("span",{className:`${O}__item-text`,children:d})]},t.key)}function St({anchorElem:e=document.body}){let[t]=xn(),[o,n]=Cn(null),{editorConfig:r}=P(),{i18n:c}=Nt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:l}}=P(),u=bt("/",{minLength:0}),d=En(()=>{let a=[];for(let s of r.features.slashMenu.dynamicGroups)if(o){let E=s({editor:t,queryString:o});a=a.concat(E)}return a},[t,o,r?.features]),m=bn(()=>{let a=[];for(let s of r?.features.slashMenu.groups??[])a.push(s);if(o){let s=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:i,i18n:c,schemaPath:l}):g.label),new RegExp(o,"gi").exec(f)||f.toLowerCase().replace(/[\s\-_]/g,"").includes(s)?!0:g.keywords!=null?g.keywords.some(h=>new RegExp(o,"gi").exec(h)?!0:h.toLowerCase().replace(/[\s\-_]/g,"").includes(s)):!1});return p.length?{...y,items:p}:null}),a=a.filter(y=>y!=null);let E=d();for(let y of E){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,r?.features.slashMenu.groups,d,i,c,l]);return q(Ke,{anchorElem:e,groups:m,menuRenderFn:(a,{selectedItemKey:s,selectItemAndCleanUp:E,setSelectedItemKey:y})=>a.current&&m.length?wt.createPortal(q("div",{className:O,"data-theme":"dark",children:m.map(p=>{let g=p.key;return p.label&&i&&(g=typeof p.label=="function"?p.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):p.label),Ct("div",{className:`${O}__group ${O}__group-${p.key}`,children:[q("div",{className:`${O}__group-title`,children:g}),p.items.map((f,x)=>q(Nn,{index:x,isSelected:s===f.key,item:f,onClick:()=>{y(f.key),E(f)},onMouseEnter:()=>{y(f.key)},ref:h=>{f.ref={current:h}}},f.key))]},p.key)})}),a.current):null,onQueryChange:n,triggerFn:u})}import{c as wn}from"react/compiler-runtime";import{useLexicalComposerContext as Sn}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Pn,TextNode as Rn}from"lexical";import{useEffect as Tn}from"react";function Pt(e){let t=wn(6),{features:o}=e,[n]=Sn(),r;t[0]!==n||t[1]!==o.enabledFormats?(r=()=>{let i=vn(o.enabledFormats);if(i.length!==0)return n.registerNodeTransform(Rn,l=>{i.forEach(u=>{l.hasFormat(u)&&l.toggleFormat(u)})})},t[0]=n,t[1]=o.enabledFormats,t[2]=r):r=t[2];let c;return t[3]!==n||t[4]!==o?(c=[n,o],t[3]=n,t[4]=o,t[5]=c):c=t[5],Tn(r,c),null}function vn(e){let t=Object.keys(Pn),o=new Set(e);return t.filter(n=>!o.has(n))}import{c as kn}from"react/compiler-runtime";import{jsx as Rt}from"react/jsx-runtime";import{useLexicalComposerContext as _n}from"@lexical/react/LexicalComposerContext";import{ContentEditable as Ln}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Dn}from"@payloadcms/ui";import"react";function Tt(e){let t=kn(5),{className:o,editorConfig:n}=e,{t:r}=Dn(),[,c]=_n(),{getTheme:i}=c,l;if(t[0]!==o||t[1]!==n?.admin?.placeholder||t[2]!==i||t[3]!==r){let u=i();l=Rt(Ln,{"aria-placeholder":r("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Rt("p",{className:u?.placeholder,children:n?.admin?.placeholder??r("lexical:general:placeholder")})}),t[0]=o,t[1]=n?.admin?.placeholder,t[2]=i,t[3]=r,t[4]=l}else l=t[4];return l}function jn(){let e=kt(3),[t]=_t(),o,n;return e[0]!==t?(o=()=>{let r=t.getRootElement();return r&&(r.dataset.lexicalEditable=String(t.isEditable())),t.registerEditableListener(c=>{let i=t.getRootElement();i&&(i.dataset.lexicalEditable=String(c))})},n=[t],e[0]=t,e[1]=o,e[2]=n):(o=e[1],n=e[2]),Lt(o,n),null}var Dt=e=>{let t=kt(13),{editorConfig:o,editorContainerRef:n,isSmallWidthViewport:r,onChange:c,rtl:i}=e,l=P(),[u]=_t(),d=In(),[m,a]=Kn(null),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=f=>{f!==null&&a(f)},t[0]=s):s=t[0];let E=s,y,p;t[1]!==u||t[2]!==l?(y=()=>{if(!l?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}l?.parentEditor?.uuid&&l.parentEditor?.registerChild(l.uuid,l);let f=()=>{l.focusEditor(l)},x=()=>{l.blurEditor(l)},h=u.registerCommand($n,()=>(f(),!0),vt),C=u.registerCommand(Fn,()=>(x(),!0),vt);return()=>{h(),C(),l.parentEditor?.unregisterChild?.(l.uuid)}},p=[u,l],t[1]=u,t[2]=l,t[3]=y,t[4]=p):(y=t[3],p=t[4]),Lt(y,p);let g;return t[5]!==o||t[6]!==n||t[7]!==m||t[8]!==d||t[9]!==r||t[10]!==c||t[11]!==i?(g=ie(Q.Fragment,{children:[o.features.plugins?.map(zn),ie("div",{className:"editor-container",dir:i?"rtl":void 0,ref:n,children:[o.features.plugins?.map(Hn),b(On,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:E,children:b(Tt,{editorConfig:o})})}),ErrorBoundary:Mn}),b(jn,{}),b(xt,{}),d&&b(pt,{}),b(Je,{}),b(Ye,{}),b(Pt,{features:o.features}),b(Et,{}),b(yt,{}),d&&b(Bn,{ignoreSelectionChange:!0,onChange:(f,x,h)=>{(!h.has("focus")||h.size>1)&&c?.(f,x,h)}}),m&&ie(Q.Fragment,{children:[!r&&d&&ie(Q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:b(ft,{anchorElem:m}),o.admin?.hideAddBlockButton?null:b(ot,{anchorElem:m})]}),o.features.plugins?.map(f=>{if(f.position==="floatingAnchorElem"&&!(f.desktopOnly===!0&&r))return b(z,{anchorElem:m,clientProps:f.clientProps,plugin:f},f.key)}),d&&b(Q.Fragment,{children:b(St,{anchorElem:m})})]}),d&&ie(Q.Fragment,{children:[b(An,{}),o?.features?.markdownTransformers?.length>0&&b(ht,{})]}),o.features.plugins?.map(Vn),o.features.plugins?.map(Wn)]}),o.features.plugins?.map(Yn)]}),t[5]=o,t[6]=n,t[7]=m,t[8]=d,t[9]=r,t[10]=c,t[11]=i,t[12]=g):g=t[12],g};function zn(e){if(e.position==="aboveContainer")return b(z,{clientProps:e.clientProps,plugin:e},e.key)}function Hn(e){if(e.position==="top")return b(z,{clientProps:e.clientProps,plugin:e},e.key)}function Vn(e){if(e.position==="normal")return b(z,{clientProps:e.clientProps,plugin:e},e.key)}function Wn(e){if(e.position==="bottom")return b(z,{clientProps:e.clientProps,plugin:e},e.key)}function Yn(e){if(e.position==="belowContainer")return b(z,{clientProps:e.clientProps,plugin:e},e.key)}var At=({children:e,providers:t})=>{if(!t?.length)return e;let o=t[0];return t.length>1?j(o,{children:j(At,{providers:t.slice(1),children:e})}):j(o,{children:e})},Bt=e=>{let{composerKey:t,editorConfig:o,fieldProps:n,isSmallWidthViewport:r,onChange:c,readOnly:i,rtl:l,value:u}=e,{currentView:d,views:m}=$(),a=P(),s=Un(),E=De.useRef(null),y=Mt(()=>{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 x=m?.[d]?.nodes;return{editable:i!==!0,editorState:u!=null?JSON.stringify(u):void 0,namespace:o.lexical.namespace,nodes:ze({editorConfig:o,nodeViews:x}),onError:h=>{throw h},theme:o.lexical.theme}},[o,m,d]),p=De.useRef(i!==!0);i!==!0&&(p.current=!0);let g=Mt(()=>({...y,editable:i!==!0}),[y,i]);if(!g)return j("p",{children:"Loading..."});let f=p.current?"editable":"readonly";return j(Gn,{initialConfig:g,children:j(Be,{editorConfig:o,editorContainerRef:E,fieldProps:n,parentContext:a?.editDepth===s?a:void 0,children:j(At,{providers:o.features.providers,children:j(Dt,{editorConfig:o,editorContainerRef:E,isSmallWidthViewport:r,onChange:c,rtl:l})})})},t+f+d)};import{c as Jn}from"react/compiler-runtime";import{jsx as X,jsxs as qn}from"react/jsx-runtime";import{ChevronIcon as Qn,Popup as Xn,PopupList as Ot}from"@payloadcms/ui";import"react";function It(){let e=Jn(5),{currentView:t,setCurrentView:o,views:n}=$();if(!n||Object.keys(n).length===0)return null;let r,c;if(e[0]!==t||e[1]!==o||e[2]!==n){c=Symbol.for("react.early_return_sentinel");e:{let i=Object.keys(n);if(!i.some(er)){c=null;break e}let u=["default",...i.filter(Zn)],d=t.charAt(0).toUpperCase()+t.slice(1);r=X("div",{className:"lexical-view-selector",children:X(Xn,{button:qn("button",{className:"lexical-view-selector__button",type:"button",children:[X("span",{className:"lexical-view-selector__label",children:d}),X(Qn,{className:"lexical-view-selector__icon"})]}),buttonType:"custom",horizontalAlign:"left",render:m=>{let{close:a}=m;return X(Ot.ButtonGroup,{children:u.map(s=>{let E=s.charAt(0).toUpperCase()+s.slice(1);return X(Ot.Button,{active:s===t,disabled:s===t,onClick:()=>{o?.(s),a()},children:E},s)})})},size:"large"})})}e[0]=t,e[1]=o,e[2]=n,e[3]=r,e[4]=c}else r=e[3],c=e[4];return c!==Symbol.for("react.early_return_sentinel")?c:r}function Zn(e){return e!=="default"}function er(e){return e!=="default"}var se="rich-text-lexical",gr=e=>{let{editorConfig:t,field:o,field:{admin:{className:n,description:r,readOnly:c}={},label:i,localized:l,required:u},path:d,readOnly:m,schemaPath:a,validate:s}=e,E=m||c,y=ur(),{config:{localization:p}}=sr(),g=ir({fieldLocalized:l,locale:y,localizationConfig:p||void 0}),f=lr(),{isControlledByParent:x}=$(),h=Kt((A,ee)=>typeof s=="function"?s(A,{...ee,required:u}):!0,[s,u]),{customComponents:{AfterInput:C,BeforeInput:k,Description:w,Error:v,Label:D}={},disabled:S,initialValue:I,path:T,setValue:F,showError:_,value:M}=cr({potentiallyStalePath:d,validate:h}),ae=E||S,[Z,Ne]=zt(!1),[Me,we]=zt(),ce=$t.useRef(I),R=$t.useRef(M);jt(()=>{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,n,_&&"error",ae&&`${se}--read-only`,t?.admin?.hideGutter!==!0&&!Z?`${se}--show-gutter`:null].filter(Boolean).join(" "),ue=`${T}.${f}`,de=Ie(),Ht=Kt(A=>{de(()=>{let Ae=A.toJSON();R.current=Ae,F(Ae)})},[F,de]),Vt=mr(()=>dr(o),[o]),Wt=ar(A=>{R.current!==M&&!fr(R.current!=null?JSON.parse(JSON.stringify(R.current)):R.current,M)&&(ce.current=A,R.current=M,we(new Date))});return jt(()=>{Object.is(I,ce.current)||Wt(I)},[I]),le("div",{className:N,"data-field-path":T,"data-field-schemapath":a,"data-lexical-view":t?.view,style:Vt,children:[le("div",{className:`${se}__label-row`,children:[D||L(rr,{label:i,localized:l,path:T,required:u}),!x&&L(It,{})]}),le("div",{className:`${se}__wrap`,children:[L(Ft,{CustomComponent:v,Fallback:L(nr,{path:T,showError:_})}),le(pr,{fallbackRender:hr,onReset:()=>{},children:[k,L(tr,{drawerSlugPrefix:`lexical-${T}`,children:L(Bt,{composerKey:ue,editorConfig:t,fieldProps:e,isSmallWidthViewport:Z,onChange:Ht,readOnly:ae,rtl:g,value:M},JSON.stringify({path:T,rerenderProviderKey:Me}))}),C]}),L(Ft,{CustomComponent:w,Fallback:L(or,{description:r,path:T})})]})]},ue)};function hr({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 Tl=gr;export{Tl as RichText};
2
- //# sourceMappingURL=Field-VW7ZGT6K.js.map