@payloadcms/richtext-lexical 4.0.0-internal.1f9ae9a → 4.0.0-internal.21664f3

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 (573) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/cell/rscEntry.d.ts.map +1 -1
  3. package/dist/cell/rscEntry.js +5 -5
  4. package/dist/cell/rscEntry.js.map +1 -1
  5. package/dist/exports/client/Field-QGSHF22S.js +2 -0
  6. package/dist/exports/client/Field-QGSHF22S.js.map +7 -0
  7. package/dist/exports/client/{RelationshipComponent-RZL743CS.js → RelationshipComponent-YCPAKOL7.js} +1 -1
  8. package/dist/exports/client/RelationshipComponent-YCPAKOL7.js.map +7 -0
  9. package/dist/exports/client/bundled.css +1 -1
  10. package/dist/exports/client/chunk-5VIL27GI.js +2 -0
  11. package/dist/exports/client/chunk-5VIL27GI.js.map +7 -0
  12. package/dist/exports/client/chunk-ESITTE3C.js +2 -0
  13. package/dist/exports/client/chunk-ESITTE3C.js.map +7 -0
  14. package/dist/exports/client/chunk-UD4DQ4AK.js +2 -0
  15. package/dist/exports/client/chunk-UD4DQ4AK.js.map +7 -0
  16. package/dist/exports/client/chunk-X3D4LZS7.js +2 -0
  17. package/dist/exports/client/chunk-X3D4LZS7.js.map +7 -0
  18. package/dist/exports/client/{component-CVM4OESA.js → component-PHZQBOJE.js} +2 -2
  19. package/dist/exports/client/component-PHZQBOJE.js.map +7 -0
  20. package/dist/exports/client/componentInline-H24N7GUG.js +2 -0
  21. package/dist/exports/client/index.d.ts +0 -1
  22. package/dist/exports/client/index.d.ts.map +1 -1
  23. package/dist/exports/client/index.js +20 -21
  24. package/dist/exports/client/index.js.map +4 -4
  25. package/dist/features/align/client/toolbarAlignGroup.d.ts.map +1 -1
  26. package/dist/features/blockquote/client/index.js +2 -2
  27. package/dist/features/blockquote/client/index.js.map +1 -1
  28. package/dist/features/blockquote/server/index.d.ts +1 -4
  29. package/dist/features/blockquote/server/index.d.ts.map +1 -1
  30. package/dist/features/blockquote/server/index.js +4 -2
  31. package/dist/features/blockquote/server/index.js.map +1 -1
  32. package/dist/features/blockquote/server/schema.d.ts +8 -0
  33. package/dist/features/blockquote/server/schema.d.ts.map +1 -0
  34. package/dist/features/blockquote/server/schema.js +15 -0
  35. package/dist/features/blockquote/server/schema.js.map +1 -0
  36. package/dist/features/blocks/client/component/index.css +2 -2
  37. package/dist/features/blocks/client/component/index.d.ts +2 -1
  38. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  39. package/dist/features/blocks/client/component/index.js +16 -8
  40. package/dist/features/blocks/client/component/index.js.map +1 -1
  41. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -1
  42. package/dist/features/blocks/client/componentInline/index.css +8 -8
  43. package/dist/features/blocks/client/componentInline/index.d.ts +2 -1
  44. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  45. package/dist/features/blocks/client/componentInline/index.js +15 -7
  46. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  47. package/dist/features/blocks/client/getBlockImageComponent.d.ts +1 -1
  48. package/dist/features/blocks/client/index.d.ts.map +1 -1
  49. package/dist/features/blocks/client/index.js +4 -2
  50. package/dist/features/blocks/client/index.js.map +1 -1
  51. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +1 -1
  52. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -1
  53. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -1
  54. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
  55. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +1 -1
  56. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -1
  57. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +5 -2
  58. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -1
  59. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +1 -2
  60. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -1
  61. package/dist/features/blocks/client/markdown/markdownTransformer.js +4 -4
  62. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
  63. package/dist/features/blocks/client/nodes/BlocksNode.d.ts +1 -1
  64. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  65. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  66. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +1 -1
  67. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
  68. package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
  69. package/dist/features/blocks/client/plugin/index.d.ts +1 -1
  70. package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
  71. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  72. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -1
  73. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +1 -0
  74. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  75. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.css +1 -1
  76. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.css +2 -4
  77. package/dist/features/blocks/premade/CodeBlock/Component/index.css +5 -5
  78. package/dist/features/blocks/server/graphQLPopulationPromise.d.ts +1 -2
  79. package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
  80. package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
  81. package/dist/features/blocks/server/index.d.ts +1 -0
  82. package/dist/features/blocks/server/index.d.ts.map +1 -1
  83. package/dist/features/blocks/server/index.js +24 -72
  84. package/dist/features/blocks/server/index.js.map +1 -1
  85. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +1 -1
  86. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -1
  87. package/dist/features/blocks/server/markdown/markdownTransformer.js +4 -4
  88. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
  89. package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -18
  90. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  91. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  92. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +2 -10
  93. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
  94. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  95. package/dist/features/blocks/server/schema.d.ts +45 -0
  96. package/dist/features/blocks/server/schema.d.ts.map +1 -0
  97. package/dist/features/blocks/server/schema.js +140 -0
  98. package/dist/features/blocks/server/schema.js.map +1 -0
  99. package/dist/features/blocks/server/validate.d.ts +1 -2
  100. package/dist/features/blocks/server/validate.d.ts.map +1 -1
  101. package/dist/features/blocks/server/validate.js.map +1 -1
  102. package/dist/features/converters/htmlToLexical/index.d.ts.map +1 -1
  103. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  104. package/dist/features/converters/lexicalToHtml/async/types.d.ts +14 -15
  105. package/dist/features/converters/lexicalToHtml/async/types.d.ts.map +1 -1
  106. package/dist/features/converters/lexicalToHtml/async/types.js.map +1 -1
  107. package/dist/features/converters/lexicalToHtml/shared/cssColors.d.ts.map +1 -1
  108. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  109. package/dist/features/converters/lexicalToHtml/sync/types.d.ts +14 -15
  110. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  111. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  112. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +4 -2
  113. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  114. package/dist/features/converters/lexicalToJSX/Component/index.js +5 -4
  115. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  116. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  117. package/dist/features/converters/lexicalToJSX/converter/types.d.ts +12 -14
  118. package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
  119. package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
  120. package/dist/features/converters/lexicalToMarkdown/index.d.ts.map +1 -1
  121. package/dist/features/converters/lexicalToMarkdown/index.js +1 -1
  122. package/dist/features/converters/lexicalToMarkdown/index.js.map +1 -1
  123. package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts +12 -14
  124. package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts.map +1 -1
  125. package/dist/features/converters/lexicalToPlaintext/sync/types.js.map +1 -1
  126. package/dist/features/converters/markdownToLexical/index.d.ts.map +1 -1
  127. package/dist/features/converters/markdownToLexical/index.js +5 -2
  128. package/dist/features/converters/markdownToLexical/index.js.map +1 -1
  129. package/dist/features/debug/jsxConverter/client/plugin/style.css +2 -2
  130. package/dist/features/experimental_table/client/index.js +2 -2
  131. package/dist/features/experimental_table/client/index.js.map +1 -1
  132. package/dist/features/experimental_table/client/utils/debounce.d.ts.map +1 -1
  133. package/dist/features/experimental_table/markdownTransformer.d.ts +2 -2
  134. package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -1
  135. package/dist/features/experimental_table/markdownTransformer.js +6 -3
  136. package/dist/features/experimental_table/markdownTransformer.js.map +1 -1
  137. package/dist/features/experimental_table/server/index.d.ts +1 -6
  138. package/dist/features/experimental_table/server/index.d.ts.map +1 -1
  139. package/dist/features/experimental_table/server/index.js +6 -2
  140. package/dist/features/experimental_table/server/index.js.map +1 -1
  141. package/dist/features/experimental_table/server/schema.d.ts +27 -0
  142. package/dist/features/experimental_table/server/schema.d.ts.map +1 -0
  143. package/dist/features/experimental_table/server/schema.js +107 -0
  144. package/dist/features/experimental_table/server/schema.js.map +1 -0
  145. package/dist/features/format/bold/feature.client.js +1 -1
  146. package/dist/features/format/bold/feature.client.js.map +1 -1
  147. package/dist/features/format/bold/feature.server.d.ts.map +1 -1
  148. package/dist/features/format/bold/feature.server.js +1 -1
  149. package/dist/features/format/bold/feature.server.js.map +1 -1
  150. package/dist/features/format/inlineCode/feature.client.js +1 -1
  151. package/dist/features/format/inlineCode/feature.client.js.map +1 -1
  152. package/dist/features/format/inlineCode/feature.server.d.ts.map +1 -1
  153. package/dist/features/format/inlineCode/feature.server.js +1 -1
  154. package/dist/features/format/inlineCode/feature.server.js.map +1 -1
  155. package/dist/features/format/italic/feature.client.js +1 -1
  156. package/dist/features/format/italic/feature.client.js.map +1 -1
  157. package/dist/features/format/italic/feature.server.d.ts.map +1 -1
  158. package/dist/features/format/italic/feature.server.js +1 -1
  159. package/dist/features/format/italic/feature.server.js.map +1 -1
  160. package/dist/features/format/shared/toolbarFormatGroup.d.ts.map +1 -1
  161. package/dist/features/format/strikethrough/feature.client.js +1 -1
  162. package/dist/features/format/strikethrough/feature.client.js.map +1 -1
  163. package/dist/features/format/strikethrough/feature.server.d.ts.map +1 -1
  164. package/dist/features/format/strikethrough/feature.server.js +1 -1
  165. package/dist/features/format/strikethrough/feature.server.js.map +1 -1
  166. package/dist/features/heading/client/index.js +2 -2
  167. package/dist/features/heading/client/index.js.map +1 -1
  168. package/dist/features/heading/markdownTransformer.d.ts +2 -2
  169. package/dist/features/heading/markdownTransformer.d.ts.map +1 -1
  170. package/dist/features/heading/markdownTransformer.js +6 -19
  171. package/dist/features/heading/markdownTransformer.js.map +1 -1
  172. package/dist/features/heading/server/index.d.ts +2 -4
  173. package/dist/features/heading/server/index.d.ts.map +1 -1
  174. package/dist/features/heading/server/index.js +4 -2
  175. package/dist/features/heading/server/index.js.map +1 -1
  176. package/dist/features/heading/server/schema.d.ts +10 -0
  177. package/dist/features/heading/server/schema.d.ts.map +1 -0
  178. package/dist/features/heading/server/schema.js +37 -0
  179. package/dist/features/heading/server/schema.js.map +1 -0
  180. package/dist/features/horizontalRule/client/index.js +2 -2
  181. package/dist/features/horizontalRule/client/index.js.map +1 -1
  182. package/dist/features/horizontalRule/client/markdownTransformer.d.ts +2 -2
  183. package/dist/features/horizontalRule/client/markdownTransformer.d.ts.map +1 -1
  184. package/dist/features/horizontalRule/client/markdownTransformer.js +1 -1
  185. package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
  186. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +1 -1
  187. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  188. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  189. package/dist/features/horizontalRule/client/plugin/index.css +2 -2
  190. package/dist/features/horizontalRule/server/index.d.ts +1 -0
  191. package/dist/features/horizontalRule/server/index.d.ts.map +1 -1
  192. package/dist/features/horizontalRule/server/index.js +4 -2
  193. package/dist/features/horizontalRule/server/index.js.map +1 -1
  194. package/dist/features/horizontalRule/server/markdownTransformer.d.ts +2 -2
  195. package/dist/features/horizontalRule/server/markdownTransformer.d.ts.map +1 -1
  196. package/dist/features/horizontalRule/server/markdownTransformer.js +1 -1
  197. package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
  198. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +1 -5
  199. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
  200. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  201. package/dist/features/horizontalRule/server/schema.d.ts +7 -0
  202. package/dist/features/horizontalRule/server/schema.d.ts.map +1 -0
  203. package/dist/features/horizontalRule/server/schema.js +25 -0
  204. package/dist/features/horizontalRule/server/schema.js.map +1 -0
  205. package/dist/features/indent/client/toolbarIndentGroup.d.ts.map +1 -1
  206. package/dist/features/link/client/index.d.ts.map +1 -1
  207. package/dist/features/link/client/index.js +2 -2
  208. package/dist/features/link/client/index.js.map +1 -1
  209. package/dist/features/link/client/plugins/autoLink/index.d.ts +1 -1
  210. package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
  211. package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
  212. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +3 -3
  213. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  214. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +7 -11
  215. package/dist/features/link/client/plugins/floatingLinkEditor/types.d.ts +1 -1
  216. package/dist/features/link/client/plugins/floatingLinkEditor/types.d.ts.map +1 -1
  217. package/dist/features/link/client/plugins/floatingLinkEditor/types.js.map +1 -1
  218. package/dist/features/link/client/plugins/link/index.js.map +1 -1
  219. package/dist/features/link/markdownTransformer.d.ts +5 -5
  220. package/dist/features/link/markdownTransformer.d.ts.map +1 -1
  221. package/dist/features/link/markdownTransformer.js +2 -2
  222. package/dist/features/link/markdownTransformer.js.map +1 -1
  223. package/dist/features/link/markdownTransformer.spec.js +10 -10
  224. package/dist/features/link/markdownTransformer.spec.js.map +1 -1
  225. package/dist/features/link/nodes/AutoLinkNode.d.ts +3 -3
  226. package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  227. package/dist/features/link/nodes/AutoLinkNode.js +2 -1
  228. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  229. package/dist/features/link/nodes/LinkNode.d.ts +3 -3
  230. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  231. package/dist/features/link/nodes/LinkNode.js +2 -1
  232. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  233. package/dist/features/link/server/baseFields.d.ts.map +1 -1
  234. package/dist/features/link/server/baseFields.js.map +1 -1
  235. package/dist/features/link/server/graphQLPopulationPromise.d.ts +1 -1
  236. package/dist/features/link/server/graphQLPopulationPromise.d.ts.map +1 -1
  237. package/dist/features/link/server/graphQLPopulationPromise.js.map +1 -1
  238. package/dist/features/link/server/index.d.ts +2 -1
  239. package/dist/features/link/server/index.d.ts.map +1 -1
  240. package/dist/features/link/server/index.js +5 -2
  241. package/dist/features/link/server/index.js.map +1 -1
  242. package/dist/features/link/server/schema.d.ts +32 -0
  243. package/dist/features/link/server/schema.d.ts.map +1 -0
  244. package/dist/features/link/server/schema.js +171 -0
  245. package/dist/features/link/server/schema.js.map +1 -0
  246. package/dist/features/link/server/validate.d.ts +1 -1
  247. package/dist/features/link/server/validate.d.ts.map +1 -1
  248. package/dist/features/link/server/validate.js.map +1 -1
  249. package/dist/features/lists/checklist/client/index.js +1 -1
  250. package/dist/features/lists/checklist/client/index.js.map +1 -1
  251. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  252. package/dist/features/lists/checklist/server/index.js +4 -1
  253. package/dist/features/lists/checklist/server/index.js.map +1 -1
  254. package/dist/features/lists/orderedList/client/index.js +1 -1
  255. package/dist/features/lists/orderedList/client/index.js.map +1 -1
  256. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  257. package/dist/features/lists/orderedList/server/index.js +4 -1
  258. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  259. package/dist/features/lists/plugin/index.d.ts +0 -9
  260. package/dist/features/lists/plugin/index.d.ts.map +1 -1
  261. package/dist/features/lists/plugin/index.js.map +1 -1
  262. package/dist/features/lists/shared/schema.d.ts +18 -0
  263. package/dist/features/lists/shared/schema.d.ts.map +1 -0
  264. package/dist/features/lists/shared/schema.js +62 -0
  265. package/dist/features/lists/shared/schema.js.map +1 -0
  266. package/dist/features/lists/unorderedList/client/index.js +1 -1
  267. package/dist/features/lists/unorderedList/client/index.js.map +1 -1
  268. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  269. package/dist/features/lists/unorderedList/server/index.js +4 -1
  270. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  271. package/dist/features/relationship/client/components/RelationshipComponent.d.ts +1 -1
  272. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  273. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  274. package/dist/features/relationship/client/drawer/index.d.ts.map +1 -1
  275. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
  276. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  277. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  278. package/dist/features/relationship/client/plugins/index.d.ts +1 -1
  279. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  280. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  281. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  282. package/dist/features/relationship/client/utils/useEnabledRelationships.js +9 -40
  283. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  284. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +1 -1
  285. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  286. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  287. package/dist/features/relationship/server/index.d.ts +1 -0
  288. package/dist/features/relationship/server/index.d.ts.map +1 -1
  289. package/dist/features/relationship/server/index.js +2 -0
  290. package/dist/features/relationship/server/index.js.map +1 -1
  291. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -10
  292. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  293. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  294. package/dist/features/relationship/server/schema.d.ts +28 -0
  295. package/dist/features/relationship/server/schema.d.ts.map +1 -0
  296. package/dist/features/relationship/server/schema.js +97 -0
  297. package/dist/features/relationship/server/schema.js.map +1 -0
  298. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +23 -0
  299. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -0
  300. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +34 -0
  301. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -0
  302. package/dist/features/shared/toolbar/addDropdownGroup.d.ts.map +1 -1
  303. package/dist/features/shared/toolbar/featureButtonsGroup.d.ts.map +1 -1
  304. package/dist/features/shared/toolbar/textDropdownGroup.d.ts.map +1 -1
  305. package/dist/features/textState/feature.client.js +1 -1
  306. package/dist/features/textState/feature.client.js.map +1 -1
  307. package/dist/features/toolbars/fixed/client/Toolbar/index.css +2 -2
  308. package/dist/features/toolbars/inline/client/Toolbar/index.css +2 -13
  309. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  310. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +8 -12
  311. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  312. package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -1
  313. package/dist/features/toolbars/shared/useToolbarStates.js +3 -1
  314. package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -1
  315. package/dist/features/typesClient.d.ts +1 -1
  316. package/dist/features/typesClient.d.ts.map +1 -1
  317. package/dist/features/typesClient.js.map +1 -1
  318. package/dist/features/typesServer.d.ts +18 -41
  319. package/dist/features/typesServer.d.ts.map +1 -1
  320. package/dist/features/typesServer.js.map +1 -1
  321. package/dist/features/upload/client/component/index.css +11 -11
  322. package/dist/features/upload/client/component/index.d.ts +1 -1
  323. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  324. package/dist/features/upload/client/component/index.js.map +1 -1
  325. package/dist/features/upload/client/drawer/index.d.ts.map +1 -1
  326. package/dist/features/upload/client/nodes/UploadNode.d.ts +1 -1
  327. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  328. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  329. package/dist/features/upload/client/plugin/index.d.ts +1 -1
  330. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  331. package/dist/features/upload/client/plugin/index.js +5 -5
  332. package/dist/features/upload/client/plugin/index.js.map +1 -1
  333. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +1 -1
  334. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  335. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  336. package/dist/features/upload/server/index.d.ts +1 -0
  337. package/dist/features/upload/server/index.d.ts.map +1 -1
  338. package/dist/features/upload/server/index.js +5 -4
  339. package/dist/features/upload/server/index.js.map +1 -1
  340. package/dist/features/upload/server/markdownTransformer.d.ts +2 -2
  341. package/dist/features/upload/server/markdownTransformer.d.ts.map +1 -1
  342. package/dist/features/upload/server/markdownTransformer.js +1 -1
  343. package/dist/features/upload/server/markdownTransformer.js.map +1 -1
  344. package/dist/features/upload/server/nodes/UploadNode.d.ts +1 -55
  345. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  346. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  347. package/dist/features/upload/server/nodes/conversions.d.ts.map +1 -1
  348. package/dist/features/upload/server/nodes/conversions.js.map +1 -1
  349. package/dist/features/upload/server/schema.d.ts +52 -0
  350. package/dist/features/upload/server/schema.d.ts.map +1 -0
  351. package/dist/features/upload/server/schema.js +149 -0
  352. package/dist/features/upload/server/schema.js.map +1 -0
  353. package/dist/features/upload/server/validate.d.ts +1 -1
  354. package/dist/features/upload/server/validate.d.ts.map +1 -1
  355. package/dist/features/upload/server/validate.js.map +1 -1
  356. package/dist/field/Diff/converters/unknown/index.css +1 -1
  357. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  358. package/dist/field/Field.d.ts.map +1 -1
  359. package/dist/field/Field.js +18 -15
  360. package/dist/field/Field.js.map +1 -1
  361. package/dist/field/ViewSelector.css +1 -1
  362. package/dist/field/bundled.css +1 -1
  363. package/dist/field/index.css +5 -5
  364. package/dist/field/index.js +1 -1
  365. package/dist/field/index.js.map +1 -1
  366. package/dist/field/rscEntry.d.ts.map +1 -1
  367. package/dist/field/rscEntry.js +2 -0
  368. package/dist/field/rscEntry.js.map +1 -1
  369. package/dist/index.d.ts +10 -7
  370. package/dist/index.d.ts.map +1 -1
  371. package/dist/index.js +3 -3
  372. package/dist/index.js.map +1 -1
  373. package/dist/lexical/LexicalEditor.css +4 -2
  374. package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  375. package/dist/lexical/config/client/loader.d.ts.map +1 -1
  376. package/dist/lexical/config/client/loader.js +5 -1
  377. package/dist/lexical/config/client/loader.js.map +1 -1
  378. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  379. package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
  380. package/dist/lexical/config/server/sanitize.js +9 -11
  381. package/dist/lexical/config/server/sanitize.js.map +1 -1
  382. package/dist/lexical/plugins/DecoratorPlugin/index.css +1 -1
  383. package/dist/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  384. package/dist/lexical/plugins/MarkdownShortcut/index.js +1 -1
  385. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  386. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -1
  387. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +21 -0
  388. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
  389. package/dist/lexical/plugins/SlashMenu/index.css +1 -5
  390. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -1
  391. package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts.map +1 -1
  392. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +4 -3
  393. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +1 -1
  394. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  395. package/dist/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.d.ts.map +1 -1
  396. package/dist/lexical/theme/EditorTheme.css +18 -19
  397. package/dist/lexical/ui/ContentEditable.css +9 -5
  398. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts +17 -0
  399. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts.map +1 -0
  400. package/dist/lexical/utils/markdown/convertFromMarkdownString.js +27 -0
  401. package/dist/lexical/utils/markdown/convertFromMarkdownString.js.map +1 -0
  402. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js +88 -0
  403. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js.map +1 -0
  404. package/dist/lexical/utils/markdown/createBlockNode.d.ts +2 -2
  405. package/dist/lexical/utils/markdown/createBlockNode.d.ts.map +1 -1
  406. package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
  407. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts +25 -0
  408. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts.map +1 -0
  409. package/dist/lexical/utils/markdown/normalizeMarkdown.js +91 -0
  410. package/dist/lexical/utils/markdown/normalizeMarkdown.js.map +1 -0
  411. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  412. package/dist/lexical/utils/point.d.ts.map +1 -1
  413. package/dist/lexical/utils/rect.d.ts.map +1 -1
  414. package/dist/lexical-proxy/@lexical-markdown.d.ts +1 -1
  415. package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
  416. package/dist/lexical-proxy/@lexical-markdown.js +1 -1
  417. package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
  418. package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts.map +1 -1
  419. package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.d.ts.map +1 -1
  420. package/dist/types/builtInNodes.d.ts +14 -0
  421. package/dist/types/builtInNodes.d.ts.map +1 -0
  422. package/dist/types/builtInNodes.js +203 -0
  423. package/dist/types/builtInNodes.js.map +1 -0
  424. package/dist/types/index.d.ts +16 -17
  425. package/dist/types/index.d.ts.map +1 -1
  426. package/dist/types/index.js.map +1 -1
  427. package/dist/types/jsonSchemaHelpers.d.ts +30 -0
  428. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -0
  429. package/dist/types/jsonSchemaHelpers.js +58 -0
  430. package/dist/types/jsonSchemaHelpers.js.map +1 -0
  431. package/dist/types/nodeTypes.d.ts +115 -61
  432. package/dist/types/nodeTypes.d.ts.map +1 -1
  433. package/dist/types/nodeTypes.js +3 -2
  434. package/dist/types/nodeTypes.js.map +1 -1
  435. package/dist/types/schema.d.ts.map +1 -1
  436. package/dist/types/schema.js +74 -65
  437. package/dist/types/schema.js.map +1 -1
  438. package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
  439. package/dist/utilities/applyBaseFilterToFields.js +1 -2
  440. package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
  441. package/dist/utilities/buildEditorState.d.ts +17 -3
  442. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  443. package/dist/utilities/buildEditorState.js +8 -0
  444. package/dist/utilities/buildEditorState.js.map +1 -1
  445. package/dist/utilities/buildInitialState.d.ts +2 -1
  446. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  447. package/dist/utilities/buildInitialState.js.map +1 -1
  448. package/dist/utilities/editorConfigFactory.d.ts.map +1 -1
  449. package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
  450. package/dist/utilities/fieldsDrawer/Drawer.js +19 -10
  451. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  452. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts +4 -1
  453. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  454. package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -7
  455. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  456. package/dist/utilities/fieldsDrawer/index.css +12 -0
  457. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts +29 -0
  458. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts.map +1 -0
  459. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js +97 -0
  460. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -0
  461. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.d.ts.map +1 -1
  462. package/dist/utilities/fieldsDrawer/useLexicalDrawer.d.ts.map +1 -1
  463. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.d.ts.map +1 -1
  464. package/dist/utilities/generateImportMap.d.ts +1 -1
  465. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  466. package/dist/utilities/generateSchemaMap.d.ts +1 -1
  467. package/dist/utilities/generateSchemaMap.d.ts.map +1 -1
  468. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts.map +1 -1
  469. package/dist/utilities/recurseNodeTree.d.ts.map +1 -1
  470. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
  471. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +1 -1
  472. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
  473. package/dist/utilities/useLexicalFeature.d.ts.map +1 -1
  474. package/dist/validate/index.d.ts.map +1 -1
  475. package/package.json +22 -26
  476. package/dist/exports/client/Field-G5Z2HM5Y.js +0 -2
  477. package/dist/exports/client/Field-G5Z2HM5Y.js.map +0 -7
  478. package/dist/exports/client/RelationshipComponent-RZL743CS.js.map +0 -7
  479. package/dist/exports/client/chunk-6QWQ7JV4.js +0 -2
  480. package/dist/exports/client/chunk-6QWQ7JV4.js.map +0 -7
  481. package/dist/exports/client/chunk-FEJXFRL7.js +0 -2
  482. package/dist/exports/client/chunk-FEJXFRL7.js.map +0 -7
  483. package/dist/exports/client/chunk-INBEEENE.js +0 -2
  484. package/dist/exports/client/chunk-INBEEENE.js.map +0 -7
  485. package/dist/exports/client/chunk-LH634DPU.js +0 -12
  486. package/dist/exports/client/chunk-LH634DPU.js.map +0 -7
  487. package/dist/exports/client/component-CVM4OESA.js.map +0 -7
  488. package/dist/exports/client/componentInline-JJZ2NKW2.js +0 -2
  489. package/dist/features/blockquote/markdownTransformer.d.ts +0 -3
  490. package/dist/features/blockquote/markdownTransformer.d.ts.map +0 -1
  491. package/dist/features/blockquote/markdownTransformer.js +0 -33
  492. package/dist/features/blockquote/markdownTransformer.js.map +0 -1
  493. package/dist/features/format/bold/markdownTransformers.d.ts +0 -6
  494. package/dist/features/format/bold/markdownTransformers.d.ts.map +0 -1
  495. package/dist/features/format/bold/markdownTransformers.js +0 -23
  496. package/dist/features/format/bold/markdownTransformers.js.map +0 -1
  497. package/dist/features/format/inlineCode/markdownTransformers.d.ts +0 -3
  498. package/dist/features/format/inlineCode/markdownTransformers.d.ts.map +0 -1
  499. package/dist/features/format/inlineCode/markdownTransformers.js +0 -6
  500. package/dist/features/format/inlineCode/markdownTransformers.js.map +0 -1
  501. package/dist/features/format/italic/markdownTransformers.d.ts +0 -4
  502. package/dist/features/format/italic/markdownTransformers.d.ts.map +0 -1
  503. package/dist/features/format/italic/markdownTransformers.js +0 -12
  504. package/dist/features/format/italic/markdownTransformers.js.map +0 -1
  505. package/dist/features/format/strikethrough/markdownTransformers.d.ts +0 -3
  506. package/dist/features/format/strikethrough/markdownTransformers.d.ts.map +0 -1
  507. package/dist/features/format/strikethrough/markdownTransformers.js +0 -6
  508. package/dist/features/format/strikethrough/markdownTransformers.js.map +0 -1
  509. package/dist/features/link/nodes/types.d.ts +0 -27
  510. package/dist/features/link/nodes/types.d.ts.map +0 -1
  511. package/dist/features/link/nodes/types.js +0 -2
  512. package/dist/features/link/nodes/types.js.map +0 -1
  513. package/dist/features/lists/checklist/markdownTransformers.d.ts +0 -3
  514. package/dist/features/lists/checklist/markdownTransformers.d.ts.map +0 -1
  515. package/dist/features/lists/checklist/markdownTransformers.js +0 -12
  516. package/dist/features/lists/checklist/markdownTransformers.js.map +0 -1
  517. package/dist/features/lists/orderedList/markdownTransformer.d.ts +0 -3
  518. package/dist/features/lists/orderedList/markdownTransformer.d.ts.map +0 -1
  519. package/dist/features/lists/orderedList/markdownTransformer.js +0 -12
  520. package/dist/features/lists/orderedList/markdownTransformer.js.map +0 -1
  521. package/dist/features/lists/shared/markdown.d.ts +0 -6
  522. package/dist/features/lists/shared/markdown.d.ts.map +0 -1
  523. package/dist/features/lists/shared/markdown.js +0 -57
  524. package/dist/features/lists/shared/markdown.js.map +0 -1
  525. package/dist/features/lists/unorderedList/markdownTransformer.d.ts +0 -3
  526. package/dist/features/lists/unorderedList/markdownTransformer.d.ts.map +0 -1
  527. package/dist/features/lists/unorderedList/markdownTransformer.js +0 -12
  528. package/dist/features/lists/unorderedList/markdownTransformer.js.map +0 -1
  529. package/dist/lexical/utils/guard.d.ts +0 -5
  530. package/dist/lexical/utils/guard.d.ts.map +0 -1
  531. package/dist/lexical/utils/guard.js +0 -9
  532. package/dist/lexical/utils/guard.js.map +0 -1
  533. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +0 -2
  534. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +0 -1
  535. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +0 -2
  536. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +0 -1
  537. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +0 -14
  538. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +0 -1
  539. package/dist/packages/@lexical/markdown/MarkdownExport.js +0 -213
  540. package/dist/packages/@lexical/markdown/MarkdownExport.js.map +0 -1
  541. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +0 -19
  542. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +0 -1
  543. package/dist/packages/@lexical/markdown/MarkdownImport.js +0 -198
  544. package/dist/packages/@lexical/markdown/MarkdownImport.js.map +0 -1
  545. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +0 -11
  546. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +0 -1
  547. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +0 -304
  548. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +0 -1
  549. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +0 -147
  550. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +0 -1
  551. package/dist/packages/@lexical/markdown/MarkdownTransformers.js +0 -268
  552. package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +0 -1
  553. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +0 -22
  554. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +0 -1
  555. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +0 -91
  556. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +0 -1
  557. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +0 -21
  558. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +0 -1
  559. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +0 -54
  560. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +0 -1
  561. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +0 -18
  562. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +0 -1
  563. package/dist/packages/@lexical/markdown/importTextTransformers.js +0 -54
  564. package/dist/packages/@lexical/markdown/importTextTransformers.js.map +0 -1
  565. package/dist/packages/@lexical/markdown/index.d.ts +0 -29
  566. package/dist/packages/@lexical/markdown/index.d.ts.map +0 -1
  567. package/dist/packages/@lexical/markdown/index.js +0 -39
  568. package/dist/packages/@lexical/markdown/index.js.map +0 -1
  569. package/dist/packages/@lexical/markdown/utils.d.ts +0 -34
  570. package/dist/packages/@lexical/markdown/utils.d.ts.map +0 -1
  571. package/dist/packages/@lexical/markdown/utils.js +0 -267
  572. package/dist/packages/@lexical/markdown/utils.js.map +0 -1
  573. /package/dist/exports/client/{componentInline-JJZ2NKW2.js.map → componentInline-H24N7GUG.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD,eAAO,MAAM,oBAAoB,EAAE,CAAC,IAAI,EAAE;IACxC,YAAY,EAAE,2BAA2B,CAAA;CAC1C,KAAK,sBAAsB,CAAC,YAAY,CAgFxC,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"}
@@ -1,4 +1,14 @@
1
- import { withNullableJSONSchemaType } from 'payload';
1
+ import { createHash } from 'crypto';
2
+ import { CORE_LEXICAL_TYPE_STRING, lineBreakNodeJSONSchema, paragraphNodeJSONSchema, rootNodeJSONSchema, tabNodeJSONSchema, textNodeJSONSchema } from './builtInNodes.js';
3
+ import { elementNodeSchema } from './jsonSchemaHelpers.js';
4
+ /**
5
+ * The node-union name is a hash of its own schema (so identical editors dedupe).
6
+ * Since the schema references the union name, we use a placeholder during build
7
+ * and substitute the real hash once everything's assembled. Features can derive
8
+ * sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.
9
+ */
10
+ const NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__';
11
+ const NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`;
2
12
  export const getFieldToJSONSchema = ({
3
13
  editorConfig
4
14
  }) => {
@@ -8,74 +18,73 @@ export const getFieldToJSONSchema = ({
8
18
  field,
9
19
  i18n,
10
20
  interfaceNameDefinitions,
11
- isRequired
21
+ typeStringDefinitions,
22
+ variant = 'output'
12
23
  }) => {
13
- let jsonSchema = {
14
- // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.
15
- // In the future, we should
16
- // 1) allow recursive children
17
- // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.
18
- type: withNullableJSONSchemaType('object', isRequired),
19
- properties: {
20
- root: {
21
- type: 'object',
22
- additionalProperties: false,
23
- properties: {
24
- type: {
25
- type: 'string'
26
- },
27
- children: {
28
- type: 'array',
29
- items: {
30
- type: 'object',
31
- additionalProperties: true,
32
- properties: {
33
- type: {
34
- type: 'string',
35
- tsType: 'any'
36
- },
37
- version: {
38
- type: 'integer'
39
- }
40
- },
41
- required: ['type', 'version']
42
- }
43
- },
44
- direction: {
45
- oneOf: [{
46
- enum: ['ltr', 'rtl']
47
- }, {
48
- type: 'null'
49
- }]
50
- },
51
- format: {
52
- type: 'string',
53
- enum: ['left', 'start', 'center', 'right', 'end', 'justify', '']
54
- },
55
- indent: {
56
- type: 'integer'
57
- },
58
- version: {
59
- type: 'integer'
60
- }
61
- },
62
- required: ['children', 'direction', 'format', 'indent', 'type', 'version']
24
+ // Step 1: build the schema for every node type allowed in this field.
25
+ typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING);
26
+ const nodeJsonSchemaArgs = {
27
+ collectionIDFieldTypes,
28
+ config,
29
+ // Each element node needs its children typed using the union node type recursively
30
+ elementNodeSchema: args => elementNodeSchema({
31
+ ...args,
32
+ nodeUnionRef: {
33
+ $ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`
63
34
  }
64
- },
65
- required: ['root']
35
+ }),
36
+ field,
37
+ i18n,
38
+ interfaceNameDefinitions,
39
+ nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,
40
+ typeStringDefinitions,
41
+ variant
66
42
  };
67
- for (const modifyJSONSchema of editorConfig.features.generatedTypes.modifyJSONSchemas) {
68
- jsonSchema = modifyJSONSchema({
69
- collectionIDFieldTypes,
70
- config,
71
- currentSchema: jsonSchema,
72
- field,
73
- i18n,
74
- interfaceNameDefinitions,
75
- isRequired
76
- });
43
+ const nodeSchemas = [
44
+ // Add built-in node schemas
45
+ textNodeJSONSchema(nodeJsonSchemaArgs), tabNodeJSONSchema(nodeJsonSchemaArgs), lineBreakNodeJSONSchema(nodeJsonSchemaArgs), paragraphNodeJSONSchema(nodeJsonSchemaArgs),
46
+ // Add feature node schemas
47
+ ...editorConfig.features.nodes.filter(node => node.jsonSchema).map(node => node.jsonSchema(nodeJsonSchemaArgs))];
48
+ const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs);
49
+ // Step 2: get the final node union name, then replace the placeholder
50
+ // in both the union members and the root node.
51
+ //
52
+ // See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.
53
+ const nodeUnionJson = JSON.stringify({
54
+ oneOf: nodeSchemas
55
+ });
56
+ // Features can register per-editor definitions during node-schema build (e.g. a link node's
57
+ // custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node
58
+ // union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same
59
+ // nodes but different feature config (e.g. different custom link fields) would otherwise hash
60
+ // identically and overwrite each other's definition. To avoid that, include that content into the hash too.
61
+ const pendingDefinitions = [...interfaceNameDefinitions.entries()].filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER)).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
62
+ const hashInput = pendingDefinitions.length ? JSON.stringify({
63
+ definitions: pendingDefinitions,
64
+ oneOf: nodeSchemas
65
+ }) : nodeUnionJson;
66
+ const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase();
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}`;
73
+ // Replacing the hash resolves the union name and any feature-derived
74
+ // sibling names in one pass.
75
+ const replacePlaceholder = schemaString => JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, resolvedHash));
76
+ // Resolve placeholders left in feature-registered definitions so Map keys
77
+ // and `$ref` targets line up.
78
+ for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {
79
+ const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, resolvedHash);
80
+ const resolvedSchema = replacePlaceholder(JSON.stringify(schema));
81
+ if (newKey !== oldKey) {
82
+ interfaceNameDefinitions.delete(oldKey);
83
+ }
84
+ interfaceNameDefinitions.set(newKey, resolvedSchema);
77
85
  }
78
- return jsonSchema;
86
+ interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson));
87
+ return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder));
79
88
  };
80
89
  };
81
90
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":["withNullableJSONSchemaType","getFieldToJSONSchema","editorConfig","collectionIDFieldTypes","config","field","i18n","interfaceNameDefinitions","isRequired","jsonSchema","type","properties","root","additionalProperties","children","items","tsType","version","required","direction","oneOf","enum","format","indent","modifyJSONSchema","features","generatedTypes","modifyJSONSchemas","currentSchema"],"sources":["../../src/types/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { withNullableJSONSchemaType } from 'payload'\n\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextAdapter } from './index.js'\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 isRequired,\n }) => {\n let jsonSchema: JSONSchema4 = {\n // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.\n // In the future, we should\n // 1) allow recursive children\n // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.\n type: withNullableJSONSchemaType('object', isRequired),\n properties: {\n root: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: {\n type: 'string',\n },\n children: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: true,\n properties: {\n type: {\n type: 'string',\n tsType: 'any',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['type', 'version'],\n },\n },\n direction: {\n oneOf: [\n {\n enum: ['ltr', 'rtl'],\n },\n {\n type: 'null',\n },\n ],\n },\n format: {\n type: 'string',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''], // ElementFormatType, since the root node is an element\n },\n indent: {\n type: 'integer',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version'],\n },\n },\n required: ['root'],\n }\n for (const modifyJSONSchema of editorConfig.features.generatedTypes.modifyJSONSchemas) {\n jsonSchema = modifyJSONSchema({\n collectionIDFieldTypes,\n config,\n currentSchema: jsonSchema,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n })\n }\n\n return jsonSchema\n }\n}\n"],"mappings":"AAEA,SAASA,0BAA0B,QAAQ;AAK3C,OAAO,MAAMC,oBAAA,GAEgCA,CAAC;EAAEC;AAAY,CAAE;EAC5D,OAAO,CAAC;IACNC,sBAAsB;IACtBC,MAAM;IACNC,KAAK;IACLC,IAAI;IACJC,wBAAwB;IACxBC;EAAU,CACX;IACC,IAAIC,UAAA,GAA0B;MAC5B;MACA;MACA;MACA;MACAC,IAAA,EAAMV,0BAAA,CAA2B,UAAUQ,UAAA;MAC3CG,UAAA,EAAY;QACVC,IAAA,EAAM;UACJF,IAAA,EAAM;UACNG,oBAAA,EAAsB;UACtBF,UAAA,EAAY;YACVD,IAAA,EAAM;cACJA,IAAA,EAAM;YACR;YACAI,QAAA,EAAU;cACRJ,IAAA,EAAM;cACNK,KAAA,EAAO;gBACLL,IAAA,EAAM;gBACNG,oBAAA,EAAsB;gBACtBF,UAAA,EAAY;kBACVD,IAAA,EAAM;oBACJA,IAAA,EAAM;oBACNM,MAAA,EAAQ;kBACV;kBACAC,OAAA,EAAS;oBACPP,IAAA,EAAM;kBACR;gBACF;gBACAQ,QAAA,EAAU,CAAC,QAAQ;cACrB;YACF;YACAC,SAAA,EAAW;cACTC,KAAA,EAAO,CACL;gBACEC,IAAA,EAAM,CAAC,OAAO;cAChB,GACA;gBACEX,IAAA,EAAM;cACR;YAEJ;YACAY,MAAA,EAAQ;cACNZ,IAAA,EAAM;cACNW,IAAA,EAAM,CAAC,QAAQ,SAAS,UAAU,SAAS,OAAO,WAAW;YAC/D;YACAE,MAAA,EAAQ;cACNb,IAAA,EAAM;YACR;YACAO,OAAA,EAAS;cACPP,IAAA,EAAM;YACR;UACF;UACAQ,QAAA,EAAU,CAAC,YAAY,aAAa,UAAU,UAAU,QAAQ;QAClE;MACF;MACAA,QAAA,EAAU,CAAC;IACb;IACA,KAAK,MAAMM,gBAAA,IAAoBtB,YAAA,CAAauB,QAAQ,CAACC,cAAc,CAACC,iBAAiB,EAAE;MACrFlB,UAAA,GAAae,gBAAA,CAAiB;QAC5BrB,sBAAA;QACAC,MAAA;QACAwB,aAAA,EAAenB,UAAA;QACfJ,KAAA;QACAC,IAAA;QACAC,wBAAA;QACAC;MACF;IACF;IAEA,OAAOC,UAAA;EACT;AACF","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":"AAEA,SAASA,UAAU,QAAQ;AAM3B,SACEC,wBAAwB,EACxBC,uBAAuB,EACvBC,uBAAuB,EACvBC,kBAAkB,EAClBC,iBAAiB,EACjBC,kBAAkB,QACb;AACP,SAASC,iBAAiB,QAAQ;AAElC;;;;;;AAMA,MAAMC,2BAAA,GAA8B;AACpC,MAAMC,2BAAA,GAA8B,gBAAgBD,2BAAA,EAA6B;AAEjF,OAAO,MAAME,oBAAA,GAEgCA,CAAC;EAAEC;AAAY,CAAE;EAC5D,OAAO,CAAC;IACNC,sBAAsB;IACtBC,MAAM;IACNC,KAAK;IACLC,IAAI;IACJC,wBAAwB;IACxBC,qBAAqB;IACrBC,OAAA,GAAU;EAAQ,CACnB;IACC;IAEAD,qBAAA,CAAsBE,GAAG,CAAClB,wBAAA;IAE1B,MAAMmB,kBAAA,GAAqC;MACzCR,sBAAA;MACAC,MAAA;MACA;MACAN,iBAAA,EAAoBc,IAAA,IAClBd,iBAAA,CAAkB;QAChB,GAAGc,IAAI;QACPC,YAAA,EAAc;UACZC,IAAA,EAAM,WAAWd,2B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AA,KAAY,WAAWF,wBAAA,CAAyBqC,GAAG,CAAC,gBAAgBN,IAAA,EAAM;IAC5E,MAAMO,YAAA,GAAepC,OAAA,KAAY,WAAW,CAACkC,iBAAA,GAAoB,GAAGL,IAAA,QAAY,GAAGA,IAAA;IACnF,MAAMvB,aAAA,GAAgB,gBAAgB8B,YAAA,EAAc;IAEpD;IACA;IACA,MAAMC,kBAAA,GAAsBC,YAAA,IAC1BtB,IAAA,CAAKuB,KAAK,CAACD,YAAA,CAAaE,UAAU,CAAClD,2BAAA,EAA6B8C,YAAA;IAElE;IACA;IACA,KAAK,MAAM,CAACK,MAAA,EAAQC,MAAA,CAAO,IAAI,C,GAAI5C,wBAAA,CAAyBsB,OAAO,GAAG,EAAE;MACtE,MAAMuB,MAAA,GAASF,MAAA,CAAOD,UAAU,CAAClD,2BAAA,EAA6B8C,YAAA;MAC9D,MAAMQ,cAAA,GAAiBP,kBAAA,CAAmBrB,IAAA,CAAKC,SAAS,CAACyB,MAAA;MACzD,IAAIC,MAAA,KAAWF,MAAA,EAAQ;QACrB3C,wBAAA,CAAyB+C,MAAM,CAACJ,MAAA;MAClC;MACA3C,wBAAA,CAAyBgD,GAAG,CAACH,MAAA,EAAQC,cAAA;IACvC;IAEA9C,wBAAA,CAAyBgD,GAAG,CAACxC,aAAA,EAAe+B,kBAAA,CAAmBtB,aAAA;IAE/D,OAAOsB,kBAAA,CAAmBrB,IAAA,CAAKC,SAAS,CAACH,yBAAA;EAC3C;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAIvE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,CAiGzF"}
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"}
@@ -77,10 +77,9 @@ export function applyBaseFilterToFields(fields, config) {
77
77
  }
78
78
  // Handle blocks
79
79
  if (field.type === 'blocks') {
80
- const blocks = field.blockReferences ?? field.blocks ?? [];
81
80
  return {
82
81
  ...field,
83
- blocks: blocks.map(block => {
82
+ blocks: field.blocks.map(block => {
84
83
  if (typeof block === 'string') {
85
84
  return block;
86
85
  }
@@ -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","blockReferences","block"],"sources":["../../src/utilities/applyBaseFilterToFields.ts"],"sourcesContent":["import type { Block, 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 const blocks = (field.blockReferences ?? field.blocks ?? []) as Block[]\n return {\n ...field,\n blocks: 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,CAAk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D,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,MAAMsB,MAAA,GAAUvB,KAAA,CAAMwB,eAAe,IAAIxB,KAAA,CAAMuB,MAAM,IAAI,EAAE;MAC3D,OAAO;QACL,GAAGvB,KAAK;QACRuB,MAAA,EAAQA,MAAA,CAAOxB,GAAG,CAAE0B,KAAA;UAClB,IAAI,OAAOA,KAAA,KAAU,UAAU;YAC7B,OAAOA,KAAA;UACT;UACA,OAAO;YACL,GAAGA,KAAK;YACR5B,MAAA,EAAQD,uBAAA,CAAwB6B,KAAA,CAAM5B,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,KA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,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,5 +1,10 @@
1
1
  import type { SerializedLexicalNode } from 'lexical';
2
2
  import type { DefaultNodeTypes, TypedEditorState } from '../types/nodeTypes.js';
3
+ /**
4
+ * The node union to build with. Accepts either a node union directly (e.g. `DefaultNodeTypes`) or a
5
+ * generated `richText` field type (e.g. `Post['richText']`), whose nodes are extracted automatically.
6
+ */
7
+ type BuildNodes<T> = NonNullable<T> extends TypedEditorState<infer TNode extends SerializedLexicalNode> ? TNode : Extract<NonNullable<T>, SerializedLexicalNode>;
3
8
  /**
4
9
  * Helper to build lexical editor state JSON from text and/or nodes.
5
10
  *
@@ -36,11 +41,19 @@ import type { DefaultNodeTypes, TypedEditorState } from '../types/nodeTypes.js';
36
41
  * ],
37
42
  * })
38
43
  * ```
44
+ *
45
+ * @example
46
+ *
47
+ * passing a generated `richText` field type — the result is exactly that field's type:
48
+ *
49
+ * ```ts
50
+ * post.richText = buildEditorState<Post['richText']>({ text: 'Hello world' })
51
+ * ```
39
52
  */
40
- export declare function buildEditorState<T extends SerializedLexicalNode>({ nodes, text, }: {
41
- nodes?: TypedEditorState<T>['root']['children'];
53
+ export declare function buildEditorState<T extends null | SerializedLexicalNode | TypedEditorState<SerializedLexicalNode> | undefined = DefaultNodeTypes>({ nodes, text, }: {
54
+ nodes?: TypedEditorState<BuildNodes<T>>['root']['children'];
42
55
  text?: string;
43
- }): TypedEditorState<T>;
56
+ }): TypedEditorState<BuildNodes<T>>;
44
57
  /**
45
58
  *
46
59
  * Alias for `buildEditorState<DefaultNodeTypes>`
@@ -49,4 +62,5 @@ export declare function buildEditorState<T extends SerializedLexicalNode>({ node
49
62
  * @internal
50
63
  */
51
64
  export declare const buildDefaultEditorState: typeof buildEditorState<DefaultNodeTypes>;
65
+ export {};
52
66
  //# sourceMappingURL=buildEditorState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,qBAAqB,EAAE,EAChE,KAAK,EACL,IAAI,GACL,EAAE;IACD,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAuDtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,gBAAgB,CAAC,gBAAgB,CAC1C,CAAA"}
1
+ {"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B;;;GAGG;AACH,KAAK,UAAU,CAAC,CAAC,IACf,WAAW,CAAC,CAAC,CAAC,SAAS,gBAAgB,CAAC,MAAM,KAAK,SAAS,qBAAqB,CAAC,GAC9E,KAAK,GACL,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,SACG,IAAI,GACJ,qBAAqB,GACrB,gBAAgB,CAAC,qBAAqB,CAAC,GACvC,SAAS,GAAG,gBAAgB,EAChC,EACA,KAAK,EACL,IAAI,GACL,EAAE;IACD,KAAK,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAuDlC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,gBAAgB,CAAC,gBAAgB,CAC1C,CAAA"}
@@ -34,6 +34,14 @@
34
34
  * ],
35
35
  * })
36
36
  * ```
37
+ *
38
+ * @example
39
+ *
40
+ * passing a generated `richText` field type — the result is exactly that field's type:
41
+ *
42
+ * ```ts
43
+ * post.richText = buildEditorState<Post['richText']>({ text: 'Hello world' })
44
+ * ```
37
45
  */export function buildEditorState({
38
46
  nodes,
39
47
  text
@@ -1 +1 @@
1
- {"version":3,"file":"buildEditorState.js","names":["buildEditorState","nodes","text","editorJSON","root","type","children","direction","format","indent","version","push","detail","mode","style","textFormat","textStyle","length","buildDefaultEditorState"],"sources":["../../src/utilities/buildEditorState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n DefaultTypedEditorState,\n TypedEditorState,\n} from '../types/nodeTypes.js'\n\n/**\n * Helper to build lexical editor state JSON from text and/or nodes.\n *\n * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.\n * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.\n * @returns The constructed editor state JSON.\n *\n * @example\n *\n * just passing text:\n *\n * ```ts\n * const editorState = buildEditorState<DefaultNodeTypes>({ text: 'Hello world' }) // result typed as DefaultTypedEditorState\n * ```\n *\n * @example\n *\n * passing nodes:\n *\n * ```ts\n * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)\n * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes\n * nodes: [\n * {\n * type: 'block',\n * fields: {\n * id: 'id',\n * blockName: 'Cool block',\n * blockType: 'myBlock',\n * },\n * format: 'left',\n * version: 1,\n * }\n * ],\n * })\n * ```\n */\nexport function buildEditorState<T extends SerializedLexicalNode>({\n nodes,\n text,\n}: {\n nodes?: TypedEditorState<T>['root']['children']\n text?: string\n}): TypedEditorState<T> {\n const editorJSON: DefaultTypedEditorState = {\n root: {\n type: 'root',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n version: 1,\n },\n }\n\n if (text) {\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [\n {\n type: 'text',\n detail: 0,\n format: 0,\n mode: 'normal',\n style: '',\n text,\n version: 1,\n },\n ],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n if (nodes?.length) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n editorJSON.root.children.push(...(nodes as any))\n }\n\n if (editorJSON.root.children.length === 0) {\n // An error will be thrown if the root node has no children\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n return editorJSON as TypedEditorState<T>\n}\n\n/**\n *\n * Alias for `buildEditorState<DefaultNodeTypes>`\n *\n * @experimental this API may change or be removed in a minor release\n * @internal\n */\nexport const buildDefaultEditorState: typeof buildEditorState<DefaultNodeTypes> =\n buildEditorState<DefaultNodeTypes>\n"],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCA,OAAO,SAASA,iBAAkD;EAChEC,KAAK;EACLC;AAAI,CAIL;EACC,MAAMC,UAAA,GAAsC;IAC1CC,IAAA,EAAM;MACJC,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRC,OAAA,EAAS;IACX;EACF;EAEA,IAAIR,IAAA,EAAM;IACRC,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,CACR;QACED,IAAA,EAAM;QACNO,MAAA,EAAQ;QACRJ,MAAA,EAAQ;QACRK,IAAA,EAAM;QACNC,KAAA,EAAO;QACPZ,IAAA;QACAQ,OAAA,EAAS;MACX,EACD;MACDH,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,IAAIT,KAAA,EAAOgB,MAAA,EAAQ;IACjB;IACAd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,IAAKV,KAAA;EACpC;EAEA,IAAIE,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACW,MAAM,KAAK,GAAG;IACzC;IACAd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,OAAOP,UAAA;AACT;AAEA;;;;;;;AAOA,OAAO,MAAMe,uBAAA,GACXlB,gBAAA","ignoreList":[]}
1
+ {"version":3,"file":"buildEditorState.js","names":["buildEditorState","nodes","text","editorJSON","root","type","children","direction","format","indent","version","push","detail","mode","style","textFormat","textStyle","length","buildDefaultEditorState"],"sources":["../../src/utilities/buildEditorState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n DefaultTypedEditorState,\n TypedEditorState,\n} from '../types/nodeTypes.js'\n\n/**\n * The node union to build with. Accepts either a node union directly (e.g. `DefaultNodeTypes`) or a\n * generated `richText` field type (e.g. `Post['richText']`), whose nodes are extracted automatically.\n */\ntype BuildNodes<T> =\n NonNullable<T> extends TypedEditorState<infer TNode extends SerializedLexicalNode>\n ? TNode\n : Extract<NonNullable<T>, SerializedLexicalNode>\n\n/**\n * Helper to build lexical editor state JSON from text and/or nodes.\n *\n * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.\n * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.\n * @returns The constructed editor state JSON.\n *\n * @example\n *\n * just passing text:\n *\n * ```ts\n * const editorState = buildEditorState<DefaultNodeTypes>({ text: 'Hello world' }) // result typed as DefaultTypedEditorState\n * ```\n *\n * @example\n *\n * passing nodes:\n *\n * ```ts\n * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)\n * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes\n * nodes: [\n * {\n * type: 'block',\n * fields: {\n * id: 'id',\n * blockName: 'Cool block',\n * blockType: 'myBlock',\n * },\n * format: 'left',\n * version: 1,\n * }\n * ],\n * })\n * ```\n *\n * @example\n *\n * passing a generated `richText` field type — the result is exactly that field's type:\n *\n * ```ts\n * post.richText = buildEditorState<Post['richText']>({ text: 'Hello world' })\n * ```\n */\nexport function buildEditorState<\n T extends\n | null\n | SerializedLexicalNode\n | TypedEditorState<SerializedLexicalNode>\n | undefined = DefaultNodeTypes,\n>({\n nodes,\n text,\n}: {\n nodes?: TypedEditorState<BuildNodes<T>>['root']['children']\n text?: string\n}): TypedEditorState<BuildNodes<T>> {\n const editorJSON: DefaultTypedEditorState = {\n root: {\n type: 'root',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n version: 1,\n },\n }\n\n if (text) {\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [\n {\n type: 'text',\n detail: 0,\n format: 0,\n mode: 'normal',\n style: '',\n text,\n version: 1,\n },\n ],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n if (nodes?.length) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n editorJSON.root.children.push(...(nodes as any))\n }\n\n if (editorJSON.root.children.length === 0) {\n // An error will be thrown if the root node has no children\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n return editorJSON as TypedEditorState<BuildNodes<T>>\n}\n\n/**\n *\n * Alias for `buildEditorState<DefaultNodeTypes>`\n *\n * @experimental this API may change or be removed in a minor release\n * @internal\n */\nexport const buildDefaultEditorState: typeof buildEditorState<DefaultNodeTypes> =\n buildEditorState<DefaultNodeTypes>\n"],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CA,OAAO,SAASA,iBAMd;EACAC,KAAK;EACLC;AAAI,CAIL;EACC,MAAMC,UAAA,GAAsC;IAC1CC,IAAA,EAAM;MACJC,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRC,OAAA,EAAS;IACX;EACF;EAEA,IAAIR,IAAA,EAAM;IACRC,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,CACR;QACED,IAAA,EAAM;QACNO,MAAA,EAAQ;QACRJ,MAAA,EAAQ;QACRK,IAAA,EAAM;QACNC,KAAA,EAAO;QACPZ,IAAA;QACAQ,OAAA,EAAS;MACX,EACD;MACDH,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,IAAIT,KAAA,EAAOgB,MAAA,EAAQ;IACjB;IACAd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,IAAKV,KAAA;EACpC;EAEA,IAAIE,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACW,MAAM,KAAK,GAAG;IACzC;IACAd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,OAAOP,UAAA;AACT;AAEA;;;;;;;AAOA,OAAO,MAAMe,uBAAA,GACXlB,gBAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { SerializedLexicalNode } from 'lexical';
2
- import type { ClientFieldSchemaMap, DocumentPreferences, FieldSchemaMap, FormState, Operation, PayloadRequest, RichTextField, SanitizedFieldPermissions } from 'payload';
2
+ import type { ClientFieldSchemaMap, ComponentRenderer, DocumentPreferences, FieldSchemaMap, FormState, Operation, PayloadRequest, RichTextField, SanitizedFieldPermissions } from 'payload';
3
3
  export type InitialLexicalFormState = {
4
4
  [nodeID: string]: {
5
5
  [key: string]: any;
@@ -19,6 +19,7 @@ type Props = {
19
19
  operation: Operation;
20
20
  permissions?: SanitizedFieldPermissions;
21
21
  preferences: DocumentPreferences;
22
+ renderComponent: ComponentRenderer;
22
23
  renderFieldFn: any;
23
24
  req: PayloadRequest;
24
25
  };
@@ -1 +1 @@
1
- {"version":3,"file":"buildInitialState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildInitialState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,SAAS,CAAC,EAAE,SAAS,CAAA;KACtB,CAAA;CACF,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE;QACP,oBAAoB,EAAE,oBAAoB,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,YAAY,CAAC,EAAE,GAAG,CAAA;QAClB,KAAK,EAAE,aAAa,CAAA;QACpB,cAAc,EAAE,cAAc,CAAA;QAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACpB,sBAAsB,EAAE,MAAM,CAAA;QAC9B,SAAS,EAAE,SAAS,CAAA;QACpB,WAAW,CAAC,EAAE,yBAAyB,CAAA;QACvC,WAAW,EAAE,mBAAmB,CAAA;QAChC,aAAa,EAAE,GAAG,CAAA;QAClB,GAAG,EAAE,cAAc,CAAA;KACpB,CAAA;IACD,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,QAAQ,EAAE,qBAAqB,EAAE,CAAA;CAClC,CAAA;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,YAAY,EAAE,oBAAoB,EAClC,QAAQ,GACT,EAAE,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA4D1C"}
1
+ {"version":3,"file":"buildInitialState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildInitialState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,SAAS,CAAC,EAAE,SAAS,CAAA;KACtB,CAAA;CACF,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE;QACP,oBAAoB,EAAE,oBAAoB,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,YAAY,CAAC,EAAE,GAAG,CAAA;QAClB,KAAK,EAAE,aAAa,CAAA;QACpB,cAAc,EAAE,cAAc,CAAA;QAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACpB,sBAAsB,EAAE,MAAM,CAAA;QAC9B,SAAS,EAAE,SAAS,CAAA;QACpB,WAAW,CAAC,EAAE,yBAAyB,CAAA;QACvC,WAAW,EAAE,mBAAmB,CAAA;QAChC,eAAe,EAAE,iBAAiB,CAAA;QAClC,aAAa,EAAE,GAAG,CAAA;QAClB,GAAG,EAAE,cAAc,CAAA;KACpB,CAAA;IACD,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,QAAQ,EAAE,qBAAqB,EAAE,CAAA;CAClC,CAAA;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,YAAY,EAAE,oBAAoB,EAClC,QAAQ,GACT,EAAE,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA4D1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildInitialState.js","names":["fieldSchemasToFormState","buildInitialState","context","initialState","initialStateFromArgs","nodeData","node","children","type","blockNode","id","fields","schemaFieldsPath","lexicalFieldSchemaPath","blockType","formStateResult","clientFieldSchemaMap","collectionSlug","data","documentData","fieldSchemaMap","get","initialBlockData","operation","permissions","preferences","readOnly","disabled","renderAllFields","renderFieldFn","req","schemaPath","formState","currentFieldPreferences","field","name","collapsedArray","collapsed","Array","isArray","includes"],"sources":["../../src/utilities/buildInitialState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type {\n ClientFieldSchemaMap,\n DocumentPreferences,\n FieldSchemaMap,\n FormState,\n Operation,\n PayloadRequest,\n RichTextField,\n SanitizedFieldPermissions,\n} from 'payload'\n\nimport { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\n\nimport type { SerializedBlockNode } from '../types/nodeTypes.js'\n\nexport type InitialLexicalFormState = {\n [nodeID: string]: {\n [key: string]: any\n formState?: FormState\n }\n}\n\ntype Props = {\n context: {\n clientFieldSchemaMap: ClientFieldSchemaMap\n collectionSlug: string\n disabled?: boolean\n documentData?: any\n field: RichTextField\n fieldSchemaMap: FieldSchemaMap\n id?: number | string\n lexicalFieldSchemaPath: string\n operation: Operation\n permissions?: SanitizedFieldPermissions\n preferences: DocumentPreferences\n renderFieldFn: any\n req: PayloadRequest\n }\n initialState?: InitialLexicalFormState\n nodeData: SerializedLexicalNode[]\n}\n\nexport async function buildInitialState({\n context,\n initialState: initialStateFromArgs,\n nodeData,\n}: Props): Promise<InitialLexicalFormState> {\n let initialState: InitialLexicalFormState = initialStateFromArgs ?? {}\n for (const node of nodeData) {\n if ('children' in node) {\n initialState = await buildInitialState({\n context,\n initialState,\n nodeData: node.children as SerializedLexicalNode[],\n })\n }\n\n if (node.type === 'block' || node.type === 'inlineBlock') {\n const blockNode = node as SerializedBlockNode\n const id = blockNode?.fields?.id\n if (!id) {\n continue\n }\n\n const schemaFieldsPath =\n node.type === 'block'\n ? `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockNode.fields.blockType}.fields`\n : `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockNode.fields.blockType}.fields`\n\n // Build form state for the block\n\n const formStateResult = await fieldSchemasToFormState({\n id: context.id,\n clientFieldSchemaMap: context.clientFieldSchemaMap,\n collectionSlug: context.collectionSlug,\n data: blockNode.fields,\n documentData: context.documentData,\n fields: (context.fieldSchemaMap.get(schemaFieldsPath) as any)?.fields,\n fieldSchemaMap: context.fieldSchemaMap,\n initialBlockData: blockNode.fields,\n operation: context.operation as any, // TODO: Type\n permissions: true,\n preferences: context.preferences,\n readOnly: context.disabled,\n renderAllFields: true, // If this function runs, the parent lexical field is being re-rendered => thus we can assume all its sub-fields need to be re-rendered\n renderFieldFn: context.renderFieldFn,\n req: context.req,\n schemaPath: schemaFieldsPath,\n })\n\n if (!initialState[id]) {\n initialState[id] = {}\n }\n\n initialState[id].formState = formStateResult\n\n if (node.type === 'block') {\n const currentFieldPreferences = context.preferences?.fields?.[context.field.name]\n const collapsedArray = currentFieldPreferences?.collapsed\n if (Array.isArray(collapsedArray) && collapsedArray.includes(id)) {\n initialState[id].collapsed = true\n }\n }\n }\n }\n return initialState\n}\n"],"mappings":"AAYA,SAASA,uBAAuB,QAAQ;AA+BxC,OAAO,eAAeC,kBAAkB;EACtCC,OAAO;EACPC,YAAA,EAAcC,oBAAoB;EAClCC;AAAQ,CACF;E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AC1BC,eAAA,EAAiB;QACjBC,aAAA,EAAe3B,OAAA,CAAQ2B,aAAa;QACpCC,GAAA,EAAK5B,OAAA,CAAQ4B,GAAG;QAChBC,UAAA,EAAYnB;MACd;MAEA,IAAI,CAACT,YAAY,CAACO,EAAA,CAAG,EAAE;QACrBP,YAAY,CAACO,EAAA,CAAG,GAAG,CAAC;MACtB;MAEAP,YAAY,CAACO,EAAA,CAAG,CAACsB,SAAS,GAAGjB,eAAA;MAE7B,IAAIT,IAAA,CAAKE,IAAI,KAAK,SAAS;QACzB,MAAMyB,uBAAA,GAA0B/B,OAAA,CAAQuB,WAAW,EAAEd,MAAA,GAAST,OAAA,CAAQgC,KAAK,CAACC,IAAI,CAAC;QACjF,MAAMC,cAAA,GAAiBH,uBAAA,EAAyBI,SAAA;QAChD,IAAIC,KAAA,CAAMC,OAAO,CAACH,cAAA,KAAmBA,cAAA,CAAeI,QAAQ,CAAC9B,EAAA,GAAK;UAChEP,YAAY,CAACO,EAAA,CAAG,CAAC2B,SAAS,GAAG;QAC/B;MACF;IACF;EACF;EACA,OAAOlC,YAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"buildInitialState.js","names":["fieldSchemasToFormState","buildInitialState","context","initialState","initialStateFromArgs","nodeData","node","children","type","blockNode","id","fields","schemaFieldsPath","lexicalFieldSchemaPath","blockType","formStateResult","clientFieldSchemaMap","collectionSlug","data","documentData","fieldSchemaMap","get","initialBlockData","operation","permissions","preferences","readOnly","disabled","renderAllFields","renderFieldFn","req","schemaPath","formState","currentFieldPreferences","field","name","collapsedArray","collapsed","Array","isArray","includes"],"sources":["../../src/utilities/buildInitialState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type {\n ClientFieldSchemaMap,\n ComponentRenderer,\n DocumentPreferences,\n FieldSchemaMap,\n FormState,\n Operation,\n PayloadRequest,\n RichTextField,\n SanitizedFieldPermissions,\n} from 'payload'\n\nimport { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\n\nimport type { SerializedBlockNode } from '../types/nodeTypes.js'\n\nexport type InitialLexicalFormState = {\n [nodeID: string]: {\n [key: string]: any\n formState?: FormState\n }\n}\n\ntype Props = {\n context: {\n clientFieldSchemaMap: ClientFieldSchemaMap\n collectionSlug: string\n disabled?: boolean\n documentData?: any\n field: RichTextField\n fieldSchemaMap: FieldSchemaMap\n id?: number | string\n lexicalFieldSchemaPath: string\n operation: Operation\n permissions?: SanitizedFieldPermissions\n preferences: DocumentPreferences\n renderComponent: ComponentRenderer\n renderFieldFn: any\n req: PayloadRequest\n }\n initialState?: InitialLexicalFormState\n nodeData: SerializedLexicalNode[]\n}\n\nexport async function buildInitialState({\n context,\n initialState: initialStateFromArgs,\n nodeData,\n}: Props): Promise<InitialLexicalFormState> {\n let initialState: InitialLexicalFormState = initialStateFromArgs ?? {}\n for (const node of nodeData) {\n if ('children' in node) {\n initialState = await buildInitialState({\n context,\n initialState,\n nodeData: node.children as SerializedLexicalNode[],\n })\n }\n\n if (node.type === 'block' || node.type === 'inlineBlock') {\n const blockNode = node as SerializedBlockNode\n const id = blockNode?.fields?.id\n if (!id) {\n continue\n }\n\n const schemaFieldsPath =\n node.type === 'block'\n ? `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockNode.fields.blockType}.fields`\n : `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockNode.fields.blockType}.fields`\n\n // Build form state for the block\n\n const formStateResult = await fieldSchemasToFormState({\n id: context.id,\n clientFieldSchemaMap: context.clientFieldSchemaMap,\n collectionSlug: context.collectionSlug,\n data: blockNode.fields,\n documentData: context.documentData,\n fields: (context.fieldSchemaMap.get(schemaFieldsPath) as any)?.fields,\n fieldSchemaMap: context.fieldSchemaMap,\n initialBlockData: blockNode.fields,\n operation: context.operation as any, // TODO: Type\n permissions: true,\n preferences: context.preferences,\n readOnly: context.disabled,\n renderAllFields: true, // If this function runs, the parent lexical field is being re-rendered => thus we can assume all its sub-fields need to be re-rendered\n renderFieldFn: context.renderFieldFn,\n req: context.req,\n schemaPath: schemaFieldsPath,\n })\n\n if (!initialState[id]) {\n initialState[id] = {}\n }\n\n initialState[id].formState = formStateResult\n\n if (node.type === 'block') {\n const currentFieldPreferences = context.preferences?.fields?.[context.field.name]\n const collapsedArray = currentFieldPreferences?.collapsed\n if (Array.isArray(collapsedArray) && collapsedArray.includes(id)) {\n initialState[id].collapsed = true\n }\n }\n }\n }\n return initialState\n}\n"],"mappings":"AAaA,SAASA,uBAAuB,QAAQ;AAgCxC,OAAO,eAAeC,kBAAkB;EACtCC,OAAO;EACPC,YAAA,EAAcC,oBAAoB;EAClCC;AAAQ,CACF;EACN,IAAIF,YAAA,GAAwCC,oBAAA,IAAwB,CAAC;EACrE,KAAK,MAAME,IAAA,IAAQD,QAAA,EAAU;IAC3B,IAAI,cAAcC,IAAA,EAAM;MACtBH,YAAA,GAAe,MAAMF,iBAAA,CAAkB;QACrCC,OAAA;QACAC,YAAA;QACAE,QAAA,EAAUC,IAAA,CAAKC;MACjB;IACF;IAEA,IAAID,IAAA,CAAKE,IAAI,KAAK,WAAWF,IAAA,CAAKE,IAAI,KAAK,eAAe;MACxD,MAAMC,SAAA,GAAYH,IAAA;MAClB,MAAMI,EAAA,GAAKD,SAAA,EAAWE,MAAA,EAAQD,EAAA;MAC9B,IAAI,CAACA,EAAA,EAAI;QACP;MACF;MAEA,MAAME,gBAAA,GACJN,IAAA,CAAKE,IAAI,KAAK,UACV,GAAGN,OAAA,CAAQW,sBAAsB,mDAAmDJ,SAAA,CAAUE,MAAM,CAACG,SAAS,SAAS,GACvH,GAAGZ,OAAA,CAAQW,sBAAsB,0DAA0DJ,SAAA,CAAUE,MAAM,CAACG,SAAS,SAAS;MAEpI;MAEA,MAAMC,eAAA,GAAkB,MAAMf,uBAAA,CAAwB;QACpDU,EAAA,EAAIR,OAAA,CAAQQ,EAAE;QACdM,oBAAA,EAAsBd,OAAA,CAAQc,oBAAoB;QAClDC,cAAA,EAAgBf,OAAA,CAAQe,cAAc;QACtCC,IAAA,EAAMT,SAAA,CAAUE,MAAM;QACtBQ,YAAA,EAAcjB,OAAA,CAAQiB,YAAY;QAClCR,MAAA,EAAST,OAAA,CAAQkB,cAAc,CAACC,GAAG,CAACT,gBAAA,GAA2BD,MAAA;QAC/DS,cAAA,EAAgBlB,OAAA,CAAQkB,cAAc;QACtCE,gBAAA,EAAkBb,SAAA,CAAUE,MAAM;QAClCY,SAAA,EAAWrB,OAAA,CAAQqB,SAAS;QAC5BC,WAAA,EAAa;QACbC,WAAA,EAAavB,OAAA,CAAQuB,WAAW;QAChCC,QAAA,EAAUxB,OAAA,CAAQyB,QAAQ;QAC1BC,eAAA,EAAiB;QACjBC,aAAA,EAAe3B,OAAA,CAAQ2B,aAAa;QACpCC,GAAA,EAAK5B,OAAA,CAAQ4B,GAAG;QAChBC,UAAA,EAAYnB;MACd;MAEA,IAAI,CAACT,YAAY,CAACO,EAAA,CAAG,EAAE;QACrBP,YAAY,CAACO,EAAA,CAAG,GAAG,CAAC;MACtB;MAEAP,YAAY,CAACO,EAAA,CAAG,CAACsB,SAAS,GAAGjB,eAAA;MAE7B,IAAIT,IAAA,CAAKE,IAAI,KAAK,SAAS;QACzB,MAAMyB,uBAAA,GAA0B/B,OAAA,CAAQuB,WAAW,EAAEd,MAAA,GAAST,OAAA,CAAQgC,KAAK,CAACC,IAAI,CAAC;QACjF,MAAMC,cAAA,GAAiBH,uBAAA,EAAyBI,SAAA;QAChD,IAAIC,KAAA,CAAMC,OAAO,CAACH,cAAA,KAAmBA,cAAA,CAAeI,QAAQ,CAAC9B,EAAA,GAAK;UAChEP,YAAY,CAACO,EAAA,CAAG,CAAC2B,SAAS,GAAG;QAC/B;MACF;IACF;EACF;EACA,OAAOlC,YAAA;AACT","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"editorConfigFactory.d.ts","sourceRoot":"","sources":["../../src/utilities/editorConfigFactory.ts"],"names":[],"mapp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,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAA;IAC1E,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAA;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACnC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAkDpD,CAAA"}
@@ -5,13 +5,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
5
5
  import { Drawer, EditDepthProvider, useModal } from '@payloadcms/ui';
6
6
  import React from 'react';
7
7
  import { DrawerContent } from './DrawerContent.js';
8
+ import { useDrawerSubmit } from './useDrawerSubmit.js';
8
9
  /**
9
10
  * This FieldsDrawer component can be used to easily create a Drawer that contains a form with fields within your feature.
10
11
  * The fields are taken directly from the schema map based on your `featureKey` and `schemaPathSuffix`. Thus, this can only
11
12
  * be used if you provide your field schema inside the `generateSchemaMap` prop of your feature.server.ts.
12
13
  */
13
14
  export const FieldsDrawer = t0 => {
14
- const $ = _c(15);
15
+ const $ = _c(17);
15
16
  const {
16
17
  className,
17
18
  data,
@@ -27,6 +28,10 @@ export const FieldsDrawer = t0 => {
27
28
  const {
28
29
  closeModal
29
30
  } = useModal();
31
+ const {
32
+ headerActions,
33
+ submitRef
34
+ } = useDrawerSubmit();
30
35
  const t1 = drawerTitle ?? "";
31
36
  let t2;
32
37
  if ($[0] !== closeModal || $[1] !== drawerSlug || $[2] !== handleDrawerSubmit) {
@@ -44,10 +49,11 @@ export const FieldsDrawer = t0 => {
44
49
  t2 = $[3];
45
50
  }
46
51
  let t3;
47
- if ($[4] !== className || $[5] !== data || $[6] !== drawerSlug || $[7] !== featureKey || $[8] !== fieldMapOverride || $[9] !== schemaFieldsPathOverride || $[10] !== schemaPath || $[11] !== schemaPathSuffix || $[12] !== t1 || $[13] !== t2) {
52
+ if ($[4] !== className || $[5] !== data || $[6] !== drawerSlug || $[7] !== featureKey || $[8] !== fieldMapOverride || $[9] !== headerActions || $[10] !== schemaFieldsPathOverride || $[11] !== schemaPath || $[12] !== schemaPathSuffix || $[13] !== submitRef || $[14] !== t1 || $[15] !== t2) {
48
53
  t3 = _jsx(EditDepthProvider, {
49
54
  children: _jsx(Drawer, {
50
55
  className,
56
+ headerActions,
51
57
  slug: drawerSlug,
52
58
  title: t1,
53
59
  children: _jsx(DrawerContent, {
@@ -57,7 +63,8 @@ export const FieldsDrawer = t0 => {
57
63
  handleDrawerSubmit: t2,
58
64
  schemaFieldsPathOverride,
59
65
  schemaPath,
60
- schemaPathSuffix
66
+ schemaPathSuffix,
67
+ submitRef
61
68
  })
62
69
  })
63
70
  });
@@ -66,14 +73,16 @@ export const FieldsDrawer = t0 => {
66
73
  $[6] = drawerSlug;
67
74
  $[7] = featureKey;
68
75
  $[8] = fieldMapOverride;
69
- $[9] = schemaFieldsPathOverride;
70
- $[10] = schemaPath;
71
- $[11] = schemaPathSuffix;
72
- $[12] = t1;
73
- $[13] = t2;
74
- $[14] = t3;
76
+ $[9] = headerActions;
77
+ $[10] = schemaFieldsPathOverride;
78
+ $[11] = schemaPath;
79
+ $[12] = schemaPathSuffix;
80
+ $[13] = submitRef;
81
+ $[14] = t1;
82
+ $[15] = t2;
83
+ $[16] = t3;
75
84
  } else {
76
- t3 = $[14];
85
+ t3 = $[16];
77
86
  }
78
87
  return t3;
79
88
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.js","names":["c","_c","Drawer","EditDepthProvider","useModal","React","DrawerContent","FieldsDrawer","t0","$","className","data","drawerSlug","drawerTitle","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","closeModal","t1","t2","args","args2","setTimeout","t3","_jsx","children","slug","title"],"sources":["../../../src/utilities/fieldsDrawer/Drawer.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, Data, FormState, JsonObject } from 'payload'\n\nimport { Drawer, EditDepthProvider, useModal } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { DrawerContent } from './DrawerContent.js'\n\nexport type FieldsDrawerProps = {\n readonly className?: string\n readonly data?: Data\n readonly drawerSlug: string\n readonly drawerTitle?: string\n readonly featureKey: string\n readonly fieldMapOverride?: ClientField[]\n readonly handleDrawerSubmit: (fields: FormState, data: JsonObject) => void\n readonly schemaFieldsPathOverride?: string\n readonly schemaPath: string\n readonly schemaPathSuffix?: string\n}\n\n/**\n * This FieldsDrawer component can be used to easily create a Drawer that contains a form with fields within your feature.\n * The fields are taken directly from the schema map based on your `featureKey` and `schemaPathSuffix`. Thus, this can only\n * be used if you provide your field schema inside the `generateSchemaMap` prop of your feature.server.ts.\n */\nexport const FieldsDrawer: React.FC<FieldsDrawerProps> = ({\n className,\n data,\n drawerSlug,\n drawerTitle,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { closeModal } = useModal()\n // The Drawer only renders its children (and itself) if it's open. Thus, by extracting the main content\n // to DrawerContent, this should be faster\n return (\n <EditDepthProvider>\n <Drawer className={className} slug={drawerSlug} title={drawerTitle ?? ''}>\n <DrawerContent\n data={data}\n featureKey={featureKey}\n fieldMapOverride={fieldMapOverride}\n handleDrawerSubmit={(args, args2) => {\n // Simply close drawer - no need for useLexicalDrawer here as at this point,\n // we don't need to restore the cursor position. This is handled by the useEffect in useLexicalDrawer.\n closeModal(drawerSlug)\n\n // Actual drawer submit logic needs to be triggered after the drawer is closed.\n // That's because the lexical selection / cursor restore logic that is striggerer by\n // `useLexicalDrawer` neeeds to be triggered before any editor.update calls that may happen\n // in the `handleDrawerSubmit` function.\n setTimeout(() => {\n handleDrawerSubmit(args, args2)\n }, 1)\n }}\n schemaFieldsPathOverride={schemaFieldsPathOverride}\n schemaPath={schemaPath}\n schemaPathSuffix={schemaPathSuffix}\n />\n </Drawer>\n </EditDepthProvider>\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A,EACED,IAAA,CAAAzB,MAAA;QAAAQ,SAAA;QAAAmB,IAAA,EAAoCjB,UAAA;QAAAkB,KAAA,EAAmBT,EAAe;QAAAO,QAAA,EACpED,IAAA,CAAArB,aAAA;UAAAK,IAAA;UAAAG,UAAA;UAAAC,gBAAA;UAAAC,kBAAA,EAIsBM,EAYpB;UAAAL,wBAAA;UAAAC,UAAA;UAAAC;QAAA,C;;;;;;;;;;;;;;;;;SAlBNO,E;CA0BJ","ignoreList":[]}
1
+ {"version":3,"file":"Drawer.js","names":["c","_c","Drawer","EditDepthProvider","useModal","React","DrawerContent","useDrawerSubmit","FieldsDrawer","t0","$","className","data","drawerSlug","drawerTitle","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","closeModal","headerActions","submitRef","t1","t2","args","args2","setTimeout","t3","_jsx","children","slug","title"],"sources":["../../../src/utilities/fieldsDrawer/Drawer.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, Data, FormState, JsonObject } from 'payload'\n\nimport { Drawer, EditDepthProvider, useModal } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { DrawerContent } from './DrawerContent.js'\nimport { useDrawerSubmit } from './useDrawerSubmit.js'\n\nexport type FieldsDrawerProps = {\n readonly className?: string\n readonly data?: Data\n readonly drawerSlug: string\n readonly drawerTitle?: string\n readonly featureKey: string\n readonly fieldMapOverride?: ClientField[]\n readonly handleDrawerSubmit: (fields: FormState, data: JsonObject) => void\n readonly schemaFieldsPathOverride?: string\n readonly schemaPath: string\n readonly schemaPathSuffix?: string\n}\n\n/**\n * This FieldsDrawer component can be used to easily create a Drawer that contains a form with fields within your feature.\n * The fields are taken directly from the schema map based on your `featureKey` and `schemaPathSuffix`. Thus, this can only\n * be used if you provide your field schema inside the `generateSchemaMap` prop of your feature.server.ts.\n */\nexport const FieldsDrawer: React.FC<FieldsDrawerProps> = ({\n className,\n data,\n drawerSlug,\n drawerTitle,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { closeModal } = useModal()\n const { headerActions, submitRef } = useDrawerSubmit()\n\n // The Drawer only renders its children (and itself) if it's open. Thus, by extracting the main content\n // to DrawerContent, this should be faster\n return (\n <EditDepthProvider>\n <Drawer\n className={className}\n headerActions={headerActions}\n slug={drawerSlug}\n title={drawerTitle ?? ''}\n >\n <DrawerContent\n data={data}\n featureKey={featureKey}\n fieldMapOverride={fieldMapOverride}\n handleDrawerSubmit={(args, args2) => {\n // Simply close drawer - no need for useLexicalDrawer here as at this point,\n // we don't need to restore the cursor position. This is handled by the useEffect in useLexicalDrawer.\n closeModal(drawerSlug)\n\n // Actual drawer submit logic needs to be triggered after the drawer is closed.\n // That's because the lexical selection / cursor restore logic that is striggerer by\n // `useLexicalDrawer` neeeds to be triggered before any editor.update calls that may happen\n // in the `handleDrawerSubmit` function.\n setTimeout(() => {\n handleDrawerSubmit(args, args2)\n }, 1)\n }}\n schemaFieldsPathOverride={schemaFieldsPathOverride}\n schemaPath={schemaPath}\n schemaPathSuffix={schemaPathSuffix}\n submitRef={submitRef}\n />\n </Drawer>\n </EditDepthProvider>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,MAAM,EAAEC,iBAAiB,EAAEC,QAAQ,QAAQ;AACpD,OAAOC,KAAA,MAAW;AAElB,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAehC;;;;;AAKA,OAAO,MAAMC,YAAA,GAA4CC,EAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EAAC;IAAAU,SAAA;IAAAC,IAAA;IAAAC,UAAA;IAAAC,WAAA;IAAAC,UAAA;IAAAC,gBAAA;IAAAC,kBAAA;IAAAC,wBAAA;IAAAC,UAAA;IAAAC;EAAA,IAAAX,EAWzD;EACC;IAAAY;EAAA,IAAuBjB,QAAA;EACvB;IAAAkB,aAAA;IAAAC;EA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
2
2
  import type { FieldsDrawerProps } from './Drawer.js';
3
- export declare const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>>;
3
+ import './index.css';
4
+ export declare const DrawerContent: React.FC<{
5
+ submitRef: React.RefObject<(() => void) | null>;
6
+ } & Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>>;
4
7
  //# sourceMappingURL=DrawerContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerContent.d.ts","sourceRoot":"","sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAGvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAIpD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,aAAa,CAAC,CAuJzF,CAAA"}
1
+ {"version":3,"file":"DrawerContent.d.ts","sourceRoot":"","sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAGvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAIpD,OAAO,aAAa,CAAA;AAEpB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC;IACE,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;CAChD,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,aAAa,CAAC,CAyJ1D,CAAA"}
@@ -2,12 +2,14 @@
2
2
 
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
5
- import { Form, FormSubmit, RenderFields, useDocumentForm, useDocumentInfo, useServerFunctions, useTranslation } from '@payloadcms/ui';
5
+ import { Form, RenderFields, useDocumentForm, useDocumentInfo, useServerFunctions } from '@payloadcms/ui';
6
6
  import { abortAndIgnore } from '@payloadcms/ui/shared';
7
7
  import { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared';
8
8
  import React, { useCallback, useEffect, useRef, useState } from 'react';
9
9
  import { v4 as uuid } from 'uuid';
10
10
  import { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js';
11
+ import { RegisterFormSubmit } from './useDrawerSubmit.js';
12
+ import './index.css';
11
13
  export const DrawerContent = ({
12
14
  data,
13
15
  featureKey,
@@ -15,11 +17,9 @@ export const DrawerContent = ({
15
17
  handleDrawerSubmit,
16
18
  schemaFieldsPathOverride,
17
19
  schemaPath,
18
- schemaPathSuffix
20
+ schemaPathSuffix,
21
+ submitRef
19
22
  }) => {
20
- const {
21
- t
22
- } = useTranslation();
23
23
  const {
24
24
  id,
25
25
  collectionSlug,
@@ -116,6 +116,7 @@ export const DrawerContent = ({
116
116
  }
117
117
  return /*#__PURE__*/_jsxs(Form, {
118
118
  beforeSubmit: [onChange],
119
+ className: "fields-drawer",
119
120
  disableValidationOnSubmit: true,
120
121
  fields: Array.isArray(fields) ? fields : [],
121
122
  initialState: initialState,
@@ -130,8 +131,8 @@ export const DrawerContent = ({
130
131
  parentSchemaPath: schemaFieldsPath,
131
132
  permissions: true,
132
133
  readOnly: !isEditable
133
- }), /*#__PURE__*/_jsx(FormSubmit, {
134
- children: t('fields:saveChanges')
134
+ }), /*#__PURE__*/_jsx(RegisterFormSubmit, {
135
+ submitRef: submitRef
135
136
  })]
136
137
  });
137
138
  };