@payloadcms/richtext-lexical 3.0.0-beta.2 → 3.0.0-beta.21

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 (415) hide show
  1. package/dist/cell/index.d.ts +1 -1
  2. package/dist/cell/index.d.ts.map +1 -1
  3. package/dist/cell/index.js +2 -4
  4. package/dist/cell/index.js.map +1 -1
  5. package/dist/field/features/align/feature.client.d.ts.map +1 -1
  6. package/dist/field/features/align/feature.client.js +1 -2
  7. package/dist/field/features/align/feature.client.js.map +1 -1
  8. package/dist/field/features/blockquote/feature.client.d.ts.map +1 -1
  9. package/dist/field/features/blockquote/feature.client.js +3 -6
  10. package/dist/field/features/blockquote/feature.client.js.map +1 -1
  11. package/dist/field/features/blockquote/feature.server.d.ts.map +1 -1
  12. package/dist/field/features/blockquote/feature.server.js +4 -4
  13. package/dist/field/features/blockquote/feature.server.js.map +1 -1
  14. package/dist/field/features/blockquote/markdownTransformer.d.ts.map +1 -1
  15. package/dist/field/features/blockquote/markdownTransformer.js +2 -4
  16. package/dist/field/features/blockquote/markdownTransformer.js.map +1 -1
  17. package/dist/field/features/blocks/component/BlockContent.d.ts.map +1 -1
  18. package/dist/field/features/blocks/component/BlockContent.js +3 -5
  19. package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
  20. package/dist/field/features/blocks/component/index.d.ts.map +1 -1
  21. package/dist/field/features/blocks/component/index.js +36 -3
  22. package/dist/field/features/blocks/component/index.js.map +1 -1
  23. package/dist/field/features/blocks/drawer/index.d.ts.map +1 -1
  24. package/dist/field/features/blocks/drawer/index.js +2 -4
  25. package/dist/field/features/blocks/drawer/index.js.map +1 -1
  26. package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
  27. package/dist/field/features/blocks/feature.server.js +109 -77
  28. package/dist/field/features/blocks/feature.server.js.map +1 -1
  29. package/dist/field/features/blocks/nodes/BlocksNode.d.ts +1 -3
  30. package/dist/field/features/blocks/nodes/BlocksNode.d.ts.map +1 -1
  31. package/dist/field/features/blocks/nodes/BlocksNode.js +1 -2
  32. package/dist/field/features/blocks/nodes/BlocksNode.js.map +1 -1
  33. package/dist/field/features/blocks/plugin/commands.d.ts.map +1 -1
  34. package/dist/field/features/blocks/plugin/commands.js +1 -2
  35. package/dist/field/features/blocks/plugin/commands.js.map +1 -1
  36. package/dist/field/features/blocks/plugin/index.d.ts.map +1 -1
  37. package/dist/field/features/blocks/plugin/index.js +3 -6
  38. package/dist/field/features/blocks/plugin/index.js.map +1 -1
  39. package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
  40. package/dist/field/features/blocks/populationPromise.js +3 -18
  41. package/dist/field/features/blocks/populationPromise.js.map +1 -1
  42. package/dist/field/features/blocks/validate.d.ts.map +1 -1
  43. package/dist/field/features/blocks/validate.js +22 -36
  44. package/dist/field/features/blocks/validate.js.map +1 -1
  45. package/dist/field/features/converters/html/field/index.d.ts +8 -2
  46. package/dist/field/features/converters/html/field/index.d.ts.map +1 -1
  47. package/dist/field/features/converters/html/field/index.js +6 -3
  48. package/dist/field/features/converters/html/field/index.js.map +1 -1
  49. package/dist/field/features/debug/testrecorder/plugin/index.d.ts.map +1 -1
  50. package/dist/field/features/debug/testrecorder/plugin/index.js +2 -4
  51. package/dist/field/features/debug/testrecorder/plugin/index.js.map +1 -1
  52. package/dist/field/features/debug/treeview/plugin/index.d.ts.map +1 -1
  53. package/dist/field/features/debug/treeview/plugin/index.js +2 -4
  54. package/dist/field/features/debug/treeview/plugin/index.js.map +1 -1
  55. package/dist/field/features/format/bold/feature.client.d.ts.map +1 -1
  56. package/dist/field/features/format/bold/feature.client.js +1 -2
  57. package/dist/field/features/format/bold/feature.client.js.map +1 -1
  58. package/dist/field/features/format/inlinecode/feature.client.d.ts.map +1 -1
  59. package/dist/field/features/format/inlinecode/feature.client.js +1 -2
  60. package/dist/field/features/format/inlinecode/feature.client.js.map +1 -1
  61. package/dist/field/features/format/italic/feature.client.d.ts.map +1 -1
  62. package/dist/field/features/format/italic/feature.client.js +1 -2
  63. package/dist/field/features/format/italic/feature.client.js.map +1 -1
  64. package/dist/field/features/format/strikethrough/feature.client.d.ts.map +1 -1
  65. package/dist/field/features/format/strikethrough/feature.client.js +1 -2
  66. package/dist/field/features/format/strikethrough/feature.client.js.map +1 -1
  67. package/dist/field/features/format/subscript/feature.client.d.ts.map +1 -1
  68. package/dist/field/features/format/subscript/feature.client.js +1 -2
  69. package/dist/field/features/format/subscript/feature.client.js.map +1 -1
  70. package/dist/field/features/format/superscript/feature.client.d.ts.map +1 -1
  71. package/dist/field/features/format/superscript/feature.client.js +1 -2
  72. package/dist/field/features/format/superscript/feature.client.js.map +1 -1
  73. package/dist/field/features/format/underline/feature.client.d.ts.map +1 -1
  74. package/dist/field/features/format/underline/feature.client.js +1 -2
  75. package/dist/field/features/format/underline/feature.client.js.map +1 -1
  76. package/dist/field/features/heading/feature.client.d.ts.map +1 -1
  77. package/dist/field/features/heading/feature.client.js +3 -6
  78. package/dist/field/features/heading/feature.client.js.map +1 -1
  79. package/dist/field/features/heading/feature.server.d.ts.map +1 -1
  80. package/dist/field/features/heading/feature.server.js +5 -5
  81. package/dist/field/features/heading/feature.server.js.map +1 -1
  82. package/dist/field/features/heading/markdownTransformer.d.ts.map +1 -1
  83. package/dist/field/features/heading/markdownTransformer.js +1 -2
  84. package/dist/field/features/heading/markdownTransformer.js.map +1 -1
  85. package/dist/field/features/horizontalrule/component/index.d.ts +10 -0
  86. package/dist/field/features/horizontalrule/component/index.d.ts.map +1 -0
  87. package/dist/field/features/horizontalrule/component/index.js +62 -0
  88. package/dist/field/features/horizontalrule/component/index.js.map +1 -0
  89. package/dist/field/features/horizontalrule/feature.client.d.ts +3 -0
  90. package/dist/field/features/horizontalrule/feature.client.d.ts.map +1 -0
  91. package/dist/field/features/horizontalrule/feature.client.js +53 -0
  92. package/dist/field/features/horizontalrule/feature.client.js.map +1 -0
  93. package/dist/field/features/horizontalrule/feature.server.d.ts +3 -0
  94. package/dist/field/features/horizontalrule/feature.server.d.ts.map +1 -0
  95. package/dist/field/features/horizontalrule/feature.server.js +37 -0
  96. package/dist/field/features/horizontalrule/feature.server.js.map +1 -0
  97. package/dist/field/features/horizontalrule/markdownTransformer.d.ts +3 -0
  98. package/dist/field/features/horizontalrule/markdownTransformer.d.ts.map +1 -0
  99. package/dist/field/features/horizontalrule/markdownTransformer.js +23 -0
  100. package/dist/field/features/horizontalrule/markdownTransformer.js.map +1 -0
  101. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.d.ts +53 -0
  102. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.d.ts.map +1 -0
  103. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.js +88 -0
  104. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.js.map +1 -0
  105. package/dist/field/features/horizontalrule/plugin/index.d.ts +6 -0
  106. package/dist/field/features/horizontalrule/plugin/index.d.ts.map +1 -0
  107. package/dist/field/features/horizontalrule/plugin/index.js +31 -0
  108. package/dist/field/features/horizontalrule/plugin/index.js.map +1 -0
  109. package/dist/field/features/horizontalrule/plugin/index.scss +20 -0
  110. package/dist/field/features/indent/feature.client.d.ts.map +1 -1
  111. package/dist/field/features/indent/feature.client.js +1 -2
  112. package/dist/field/features/indent/feature.client.js.map +1 -1
  113. package/dist/field/features/link/drawer/baseFields.d.ts +3 -3
  114. package/dist/field/features/link/drawer/baseFields.d.ts.map +1 -1
  115. package/dist/field/features/link/drawer/baseFields.js +28 -42
  116. package/dist/field/features/link/drawer/baseFields.js.map +1 -1
  117. package/dist/field/features/link/drawer/index.js +3 -2
  118. package/dist/field/features/link/drawer/index.js.map +1 -1
  119. package/dist/field/features/link/drawer/types.d.ts +4 -2
  120. package/dist/field/features/link/drawer/types.d.ts.map +1 -1
  121. package/dist/field/features/link/drawer/types.js.map +1 -1
  122. package/dist/field/features/link/feature.client.d.ts.map +1 -1
  123. package/dist/field/features/link/feature.client.js +2 -4
  124. package/dist/field/features/link/feature.client.js.map +1 -1
  125. package/dist/field/features/link/feature.server.d.ts +0 -2
  126. package/dist/field/features/link/feature.server.d.ts.map +1 -1
  127. package/dist/field/features/link/feature.server.js +48 -9
  128. package/dist/field/features/link/feature.server.js.map +1 -1
  129. package/dist/field/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  130. package/dist/field/features/link/nodes/AutoLinkNode.js +1 -2
  131. package/dist/field/features/link/nodes/AutoLinkNode.js.map +1 -1
  132. package/dist/field/features/link/nodes/LinkNode.d.ts +1 -3
  133. package/dist/field/features/link/nodes/LinkNode.d.ts.map +1 -1
  134. package/dist/field/features/link/nodes/LinkNode.js +2 -4
  135. package/dist/field/features/link/nodes/LinkNode.js.map +1 -1
  136. package/dist/field/features/link/plugins/autoLink/index.d.ts.map +1 -1
  137. package/dist/field/features/link/plugins/autoLink/index.js +3 -6
  138. package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
  139. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.d.ts.map +1 -1
  140. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.js +1 -2
  141. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.js.map +1 -1
  142. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  143. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +56 -39
  144. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  145. package/dist/field/features/link/plugins/floatingLinkEditor/index.scss +9 -1
  146. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts +3 -5
  147. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
  148. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js +11 -29
  149. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
  150. package/dist/field/features/link/plugins/link/index.d.ts.map +1 -1
  151. package/dist/field/features/link/plugins/link/index.js +3 -12
  152. package/dist/field/features/link/plugins/link/index.js.map +1 -1
  153. package/dist/field/features/link/populationPromise.d.ts.map +1 -1
  154. package/dist/field/features/link/populationPromise.js +9 -25
  155. package/dist/field/features/link/populationPromise.js.map +1 -1
  156. package/dist/field/features/link/validate.d.ts +5 -0
  157. package/dist/field/features/link/validate.d.ts.map +1 -0
  158. package/dist/field/features/link/validate.js +32 -0
  159. package/dist/field/features/link/validate.js.map +1 -0
  160. package/dist/field/features/lists/checklist/feature.client.d.ts.map +1 -1
  161. package/dist/field/features/lists/checklist/feature.client.js +1 -2
  162. package/dist/field/features/lists/checklist/feature.client.js.map +1 -1
  163. package/dist/field/features/lists/checklist/feature.server.d.ts.map +1 -1
  164. package/dist/field/features/lists/checklist/feature.server.js +6 -6
  165. package/dist/field/features/lists/checklist/feature.server.js.map +1 -1
  166. package/dist/field/features/lists/checklist/markdownTransformers.d.ts.map +1 -1
  167. package/dist/field/features/lists/checklist/markdownTransformers.js +1 -2
  168. package/dist/field/features/lists/checklist/markdownTransformers.js.map +1 -1
  169. package/dist/field/features/lists/checklist/plugin/index.d.ts.map +1 -1
  170. package/dist/field/features/lists/checklist/plugin/index.js +1 -2
  171. package/dist/field/features/lists/checklist/plugin/index.js.map +1 -1
  172. package/dist/field/features/lists/common/markdown.d.ts.map +1 -1
  173. package/dist/field/features/lists/common/markdown.js +1 -2
  174. package/dist/field/features/lists/common/markdown.js.map +1 -1
  175. package/dist/field/features/lists/htmlConverter.d.ts.map +1 -1
  176. package/dist/field/features/lists/htmlConverter.js +13 -6
  177. package/dist/field/features/lists/htmlConverter.js.map +1 -1
  178. package/dist/field/features/lists/orderedlist/feature.client.d.ts.map +1 -1
  179. package/dist/field/features/lists/orderedlist/feature.client.js +1 -2
  180. package/dist/field/features/lists/orderedlist/feature.client.js.map +1 -1
  181. package/dist/field/features/lists/orderedlist/feature.server.d.ts.map +1 -1
  182. package/dist/field/features/lists/orderedlist/feature.server.js +6 -6
  183. package/dist/field/features/lists/orderedlist/feature.server.js.map +1 -1
  184. package/dist/field/features/lists/orderedlist/markdownTransformer.d.ts.map +1 -1
  185. package/dist/field/features/lists/orderedlist/markdownTransformer.js +1 -2
  186. package/dist/field/features/lists/orderedlist/markdownTransformer.js.map +1 -1
  187. package/dist/field/features/lists/plugin/index.d.ts.map +1 -1
  188. package/dist/field/features/lists/plugin/index.js +1 -2
  189. package/dist/field/features/lists/plugin/index.js.map +1 -1
  190. package/dist/field/features/lists/unorderedlist/feature.client.d.ts.map +1 -1
  191. package/dist/field/features/lists/unorderedlist/feature.client.js +1 -2
  192. package/dist/field/features/lists/unorderedlist/feature.client.js.map +1 -1
  193. package/dist/field/features/lists/unorderedlist/feature.server.d.ts.map +1 -1
  194. package/dist/field/features/lists/unorderedlist/feature.server.js +6 -6
  195. package/dist/field/features/lists/unorderedlist/feature.server.js.map +1 -1
  196. package/dist/field/features/lists/unorderedlist/markdownTransformer.d.ts.map +1 -1
  197. package/dist/field/features/lists/unorderedlist/markdownTransformer.js +1 -2
  198. package/dist/field/features/lists/unorderedlist/markdownTransformer.js.map +1 -1
  199. package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.d.ts.map +1 -1
  200. package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js +2 -4
  201. package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js.map +1 -1
  202. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -3
  203. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
  204. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +2 -4
  205. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  206. package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.d.ts.map +1 -1
  207. package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.js +2 -4
  208. package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.js.map +1 -1
  209. package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.d.ts.map +1 -1
  210. package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.js +2 -4
  211. package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.js.map +1 -1
  212. package/dist/field/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
  213. package/dist/field/features/migrations/slateToLexical/converter/index.js +2 -1
  214. package/dist/field/features/migrations/slateToLexical/converter/index.js.map +1 -1
  215. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -3
  216. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
  217. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +2 -4
  218. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  219. package/dist/field/features/paragraph/feature.client.d.ts.map +1 -1
  220. package/dist/field/features/paragraph/feature.client.js +2 -4
  221. package/dist/field/features/paragraph/feature.client.js.map +1 -1
  222. package/dist/field/features/relationship/drawer/commands.d.ts.map +1 -1
  223. package/dist/field/features/relationship/drawer/commands.js +1 -2
  224. package/dist/field/features/relationship/drawer/commands.js.map +1 -1
  225. package/dist/field/features/relationship/drawer/index.d.ts.map +1 -1
  226. package/dist/field/features/relationship/drawer/index.js +7 -13
  227. package/dist/field/features/relationship/drawer/index.js.map +1 -1
  228. package/dist/field/features/relationship/feature.server.d.ts.map +1 -1
  229. package/dist/field/features/relationship/feature.server.js +3 -2
  230. package/dist/field/features/relationship/feature.server.js.map +1 -1
  231. package/dist/field/features/relationship/nodes/RelationshipNode.d.ts +3 -8
  232. package/dist/field/features/relationship/nodes/RelationshipNode.d.ts.map +1 -1
  233. package/dist/field/features/relationship/nodes/RelationshipNode.js +8 -8
  234. package/dist/field/features/relationship/nodes/RelationshipNode.js.map +1 -1
  235. package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
  236. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +54 -7
  237. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
  238. package/dist/field/features/relationship/plugins/index.d.ts.map +1 -1
  239. package/dist/field/features/relationship/plugins/index.js +3 -6
  240. package/dist/field/features/relationship/plugins/index.js.map +1 -1
  241. package/dist/field/features/relationship/populationPromise.js +7 -6
  242. package/dist/field/features/relationship/populationPromise.js.map +1 -1
  243. package/dist/field/features/typeUtilities.d.ts +8 -0
  244. package/dist/field/features/typeUtilities.d.ts.map +1 -0
  245. package/dist/field/features/typeUtilities.js +8 -0
  246. package/dist/field/features/typeUtilities.js.map +1 -0
  247. package/dist/field/features/types.d.ts +57 -33
  248. package/dist/field/features/types.d.ts.map +1 -1
  249. package/dist/field/features/types.js.map +1 -1
  250. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts.map +1 -1
  251. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js +5 -6
  252. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
  253. package/dist/field/features/upload/component/index.d.ts.map +1 -1
  254. package/dist/field/features/upload/component/index.js +55 -9
  255. package/dist/field/features/upload/component/index.js.map +1 -1
  256. package/dist/field/features/upload/drawer/commands.d.ts.map +1 -1
  257. package/dist/field/features/upload/drawer/commands.js +1 -2
  258. package/dist/field/features/upload/drawer/commands.js.map +1 -1
  259. package/dist/field/features/upload/drawer/index.d.ts.map +1 -1
  260. package/dist/field/features/upload/drawer/index.js +8 -12
  261. package/dist/field/features/upload/drawer/index.js.map +1 -1
  262. package/dist/field/features/upload/feature.server.d.ts.map +1 -1
  263. package/dist/field/features/upload/feature.server.js +39 -11
  264. package/dist/field/features/upload/feature.server.js.map +1 -1
  265. package/dist/field/features/upload/nodes/UploadNode.d.ts +2 -14
  266. package/dist/field/features/upload/nodes/UploadNode.d.ts.map +1 -1
  267. package/dist/field/features/upload/nodes/UploadNode.js +6 -9
  268. package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
  269. package/dist/field/features/upload/plugin/index.d.ts +2 -2
  270. package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
  271. package/dist/field/features/upload/plugin/index.js +4 -9
  272. package/dist/field/features/upload/plugin/index.js.map +1 -1
  273. package/dist/field/features/upload/populationPromise.js +11 -8
  274. package/dist/field/features/upload/populationPromise.js.map +1 -1
  275. package/dist/field/features/upload/validate.d.ts +2 -1
  276. package/dist/field/features/upload/validate.d.ts.map +1 -1
  277. package/dist/field/features/upload/validate.js +34 -12
  278. package/dist/field/features/upload/validate.js.map +1 -1
  279. package/dist/field/index.d.ts +1 -1
  280. package/dist/field/index.d.ts.map +1 -1
  281. package/dist/field/index.js.map +1 -1
  282. package/dist/field/lexical/LexicalEditor.d.ts.map +1 -1
  283. package/dist/field/lexical/LexicalEditor.js +6 -11
  284. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  285. package/dist/field/lexical/LexicalProvider.d.ts +1 -1
  286. package/dist/field/lexical/LexicalProvider.d.ts.map +1 -1
  287. package/dist/field/lexical/LexicalProvider.js +1 -2
  288. package/dist/field/lexical/LexicalProvider.js.map +1 -1
  289. package/dist/field/lexical/config/client/default.d.ts +1 -1
  290. package/dist/field/lexical/config/client/default.d.ts.map +1 -1
  291. package/dist/field/lexical/config/client/default.js.map +1 -1
  292. package/dist/field/lexical/config/client/sanitize.d.ts +1 -1
  293. package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
  294. package/dist/field/lexical/config/client/sanitize.js.map +1 -1
  295. package/dist/field/lexical/config/server/default.d.ts +2 -3
  296. package/dist/field/lexical/config/server/default.d.ts.map +1 -1
  297. package/dist/field/lexical/config/server/default.js +3 -3
  298. package/dist/field/lexical/config/server/default.js.map +1 -1
  299. package/dist/field/lexical/config/server/loader.d.ts +4 -2
  300. package/dist/field/lexical/config/server/loader.d.ts.map +1 -1
  301. package/dist/field/lexical/config/server/loader.js +3 -2
  302. package/dist/field/lexical/config/server/loader.js.map +1 -1
  303. package/dist/field/lexical/config/server/sanitize.d.ts +2 -1
  304. package/dist/field/lexical/config/server/sanitize.d.ts.map +1 -1
  305. package/dist/field/lexical/config/server/sanitize.js +23 -8
  306. package/dist/field/lexical/config/server/sanitize.js.map +1 -1
  307. package/dist/field/lexical/config/types.d.ts +1 -1
  308. package/dist/field/lexical/config/types.d.ts.map +1 -1
  309. package/dist/field/lexical/config/types.js.map +1 -1
  310. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts.map +1 -1
  311. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js +3 -6
  312. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js.map +1 -1
  313. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.d.ts.map +1 -1
  314. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js +3 -6
  315. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js.map +1 -1
  316. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +1 -1
  317. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js +27 -29
  318. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +1 -1
  319. package/dist/field/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  320. package/dist/field/lexical/plugins/MarkdownShortcut/index.js +1 -2
  321. package/dist/field/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  322. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  323. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +3 -6
  324. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  325. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  326. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +3 -6
  327. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  328. package/dist/field/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
  329. package/dist/field/lexical/plugins/SlashMenu/index.js +1 -2
  330. package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
  331. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
  332. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js +13 -10
  333. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  334. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts.map +1 -1
  335. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js +1 -2
  336. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js.map +1 -1
  337. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  338. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js +10 -7
  339. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  340. package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.d.ts +9 -0
  341. package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.d.ts.map +1 -0
  342. package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.js +35 -0
  343. package/dist/field/lexical/plugins/handles/utils/doesLineHeightAffectElement.js.map +1 -0
  344. package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.d.ts.map +1 -1
  345. package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js +1 -2
  346. package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js.map +1 -1
  347. package/dist/field/lexical/plugins/handles/utils/setHandlePosition.d.ts +1 -1
  348. package/dist/field/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  349. package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js +17 -7
  350. package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  351. package/dist/field/lexical/theme/EditorTheme.scss +11 -8
  352. package/dist/field/lexical/ui/ContentEditable.d.ts.map +1 -1
  353. package/dist/field/lexical/ui/ContentEditable.js +1 -2
  354. package/dist/field/lexical/ui/ContentEditable.js.map +1 -1
  355. package/dist/field/lexical/ui/icons/HorizontalRule/index.d.ts +3 -0
  356. package/dist/field/lexical/ui/icons/HorizontalRule/index.d.ts.map +1 -0
  357. package/dist/field/lexical/ui/icons/HorizontalRule/index.js +19 -0
  358. package/dist/field/lexical/ui/icons/HorizontalRule/index.js.map +1 -0
  359. package/dist/field/lexical/utils/getSelectedNode.d.ts.map +1 -1
  360. package/dist/field/lexical/utils/getSelectedNode.js +1 -2
  361. package/dist/field/lexical/utils/getSelectedNode.js.map +1 -1
  362. package/dist/field/lexical/utils/nodeFormat.d.ts +2 -1
  363. package/dist/field/lexical/utils/nodeFormat.d.ts.map +1 -1
  364. package/dist/field/lexical/utils/nodeFormat.js.map +1 -1
  365. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts +1 -1
  366. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
  367. package/dist/field/lexical/utils/setFloatingElemPosition.js +15 -13
  368. package/dist/field/lexical/utils/setFloatingElemPosition.js.map +1 -1
  369. package/dist/field/lexical/utils/url.d.ts.map +1 -1
  370. package/dist/field/lexical/utils/url.js +3 -0
  371. package/dist/field/lexical/utils/url.js.map +1 -1
  372. package/dist/forEachNodeRecursively.d.ts +10 -0
  373. package/dist/forEachNodeRecursively.d.ts.map +1 -0
  374. package/dist/forEachNodeRecursively.js +24 -0
  375. package/dist/forEachNodeRecursively.js.map +1 -0
  376. package/dist/generateComponentMap.d.ts.map +1 -1
  377. package/dist/generateComponentMap.js +16 -22
  378. package/dist/generateComponentMap.js.map +1 -1
  379. package/dist/generateSchemaMap.d.ts.map +1 -1
  380. package/dist/generateSchemaMap.js +4 -12
  381. package/dist/generateSchemaMap.js.map +1 -1
  382. package/dist/index.d.ts +6 -5
  383. package/dist/index.d.ts.map +1 -1
  384. package/dist/index.js +260 -173
  385. package/dist/index.js.map +1 -1
  386. package/dist/populate/defaultValue.d.ts.map +1 -1
  387. package/dist/populate/defaultValue.js +1 -0
  388. package/dist/populate/defaultValue.js.map +1 -1
  389. package/dist/populate/populate.d.ts +3 -3
  390. package/dist/populate/populate.d.ts.map +1 -1
  391. package/dist/populate/populate.js.map +1 -1
  392. package/dist/populate/populateLexicalPopulationPromises.d.ts +12 -0
  393. package/dist/populate/populateLexicalPopulationPromises.d.ts.map +1 -0
  394. package/dist/populate/populateLexicalPopulationPromises.js +35 -0
  395. package/dist/populate/populateLexicalPopulationPromises.js.map +1 -0
  396. package/dist/populate/recurseNestedFields.d.ts +7 -4
  397. package/dist/populate/recurseNestedFields.d.ts.map +1 -1
  398. package/dist/populate/recurseNestedFields.js +3 -5
  399. package/dist/populate/recurseNestedFields.js.map +1 -1
  400. package/dist/scss/app.scss +2 -3
  401. package/dist/scss/vars.scss +0 -7
  402. package/dist/types.d.ts +11 -5
  403. package/dist/types.d.ts.map +1 -1
  404. package/dist/types.js.map +1 -1
  405. package/dist/validate/index.d.ts +1 -1
  406. package/dist/validate/index.d.ts.map +1 -1
  407. package/package.json +47 -46
  408. package/components.d.ts +0 -6
  409. package/components.js +0 -7
  410. package/dist/populate/richTextRelationshipPromise.d.ts +0 -23
  411. package/dist/populate/richTextRelationshipPromise.d.ts.map +0 -1
  412. package/dist/populate/richTextRelationshipPromise.js +0 -68
  413. package/dist/populate/richTextRelationshipPromise.js.map +0 -1
  414. package/dist/scss/fonts.scss +0 -75
  415. package/src/index.ts +0 -423
@@ -1,75 +1,59 @@
1
+ import { traverseFields } from '@payloadcms/next/utilities';
1
2
  import { baseBlockFields, sanitizeFields } from 'payload/config';
2
3
  import { fieldsToJSONSchema, formatLabels } from 'payload/utilities';
3
- import { cloneDeep } from '../../lexical/utils/cloneDeep.js';
4
+ import { createNode } from '../typeUtilities.js';
4
5
  import { BlocksFeatureClientComponent } from './feature.client.js';
5
6
  import { BlockNode } from './nodes/BlocksNode.js';
6
7
  import { blockPopulationPromiseHOC } from './populationPromise.js';
7
8
  import { blockValidationHOC } from './validate.js';
8
9
  export const BlocksFeature = (props)=>{
9
- // Sanitization taken from payload/src/fields/config/sanitize.ts
10
- if (props?.blocks?.length) {
11
- props.blocks = props.blocks.map((block)=>{
12
- const blockCopy = cloneDeep(block);
13
- return {
14
- ...blockCopy,
15
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
16
- fields: blockCopy.fields.concat(baseBlockFields),
17
- labels: !blockCopy.labels ? formatLabels(blockCopy.slug) : blockCopy.labels
18
- };
19
- });
20
- // unSanitizedBlock.fields are sanitized in the React component and not here.
21
- // That's because we do not have access to the payload config here.
22
- }
23
- // Build clientProps
24
- const clientProps = {
25
- reducedBlocks: []
26
- };
27
- for (const block of props.blocks){
28
- clientProps.reducedBlocks.push({
29
- slug: block.slug,
30
- fieldMap: [],
31
- imageAltText: block.imageAltText,
32
- imageURL: block.imageURL,
33
- labels: block.labels
34
- });
35
- }
36
10
  return {
37
- feature: ()=>{
11
+ feature: async ({ config: _config })=>{
12
+ if (props?.blocks?.length) {
13
+ const validRelationships = _config.collections.map((c)=>c.slug) || [];
14
+ for (const block of props.blocks){
15
+ block.fields = block.fields.concat(baseBlockFields);
16
+ block.labels = !block.labels ? formatLabels(block.slug) : block.labels;
17
+ block.fields = await sanitizeFields({
18
+ config: _config,
19
+ fields: block.fields,
20
+ requireFieldLevelRichTextEditor: true,
21
+ validRelationships
22
+ });
23
+ }
24
+ }
25
+ // Build clientProps
26
+ const clientProps = {
27
+ reducedBlocks: []
28
+ };
29
+ for (const block of props.blocks){
30
+ clientProps.reducedBlocks.push({
31
+ slug: block.slug,
32
+ fieldMap: [],
33
+ imageAltText: block.imageAltText,
34
+ imageURL: block.imageURL,
35
+ labels: block.labels
36
+ });
37
+ }
38
38
  return {
39
39
  ClientComponent: BlocksFeatureClientComponent,
40
40
  clientFeatureProps: clientProps,
41
- generateSchemaMap: ({ config, props, schemaMap: schemaMapFromProps, schemaPath })=>{
42
- const schemaMap = {};
41
+ generateSchemaMap: ({ config, i18n, props })=>{
42
+ const validRelationships = config.collections.map((c)=>c.slug) || [];
43
43
  /**
44
- * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block and it runs addRow, it will request these
45
- * sub-fields from the component map. Thus we need to put them in the component map here.
46
- */ const handleFields = (parentPath, fields)=>{
47
- for (const field of fields){
48
- if ('name' in field && 'fields' in field) {
49
- schemaMap[parentPath + '.' + field.name] = field.fields;
50
- handleFields(parentPath + '.' + field.name, field.fields);
51
- }
52
- if ('blocks' in field) {
53
- for (const block of field.blocks){
54
- schemaMap[parentPath + '.' + field.name + '.' + block.slug] = block.fields || [];
55
- handleFields(parentPath + '.' + field.name + '.' + block.slug, block.fields);
56
- }
57
- }
58
- if ('tabs' in field) {
59
- for (const tab of field.tabs){
60
- if ('name' in tab) {
61
- schemaMap[parentPath + '.' + tab.name] = tab.fields || [];
62
- handleFields(parentPath + '.' + tab.name, tab.fields);
63
- } else {
64
- handleFields(parentPath, tab.fields);
65
- }
66
- }
67
- }
68
- }
69
- };
44
+ * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block, and it runs addRow, it will request these
45
+ * sub-fields from the component map. Thus, we need to put them in the component map here.
46
+ */ const schemaMap = new Map();
70
47
  for (const block of props.blocks){
71
- schemaMap[block.slug] = block.fields || [];
72
- handleFields(block.slug, block.fields);
48
+ schemaMap.set(block.slug, block.fields || []);
49
+ traverseFields({
50
+ config,
51
+ fields: block.fields,
52
+ i18n,
53
+ schemaMap,
54
+ schemaPath: block.slug,
55
+ validRelationships
56
+ });
73
57
  }
74
58
  return schemaMap;
75
59
  },
@@ -78,24 +62,10 @@ export const BlocksFeature = (props)=>{
78
62
  if (!props?.blocks?.length) {
79
63
  return currentSchema;
80
64
  }
81
- // sanitize blocks
82
- const validRelationships = config.collections.map((c)=>c.slug) || [];
83
- const sanitizedBlocks = props.blocks.map((block)=>{
84
- const blockCopy = cloneDeep(block);
85
- return {
86
- ...blockCopy,
87
- fields: sanitizeFields({
88
- config,
89
- fields: blockCopy.fields,
90
- requireFieldLevelRichTextEditor: true,
91
- validRelationships
92
- })
93
- };
94
- });
95
65
  const blocksField = {
96
66
  name: field?.name + '_lexical_blocks',
97
67
  type: 'blocks',
98
- blocks: sanitizedBlocks
68
+ blocks: props.blocks
99
69
  };
100
70
  // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.
101
71
  // we don't actually use the JSON Schema itself in the generated types yet.
@@ -106,15 +76,77 @@ export const BlocksFeature = (props)=>{
106
76
  }
107
77
  },
108
78
  nodes: [
109
- {
110
- node: BlockNode,
79
+ createNode({
80
+ /* // TODO: Implement these hooks once docWithLocales / originalSiblingDoc => node matching has been figured out
81
+ hooks: {
82
+ beforeChange: [
83
+ async ({ context, findMany, node, operation, overrideAccess, req }) => {
84
+ const blockType = node.fields.blockType
85
+
86
+ const block = deepCopyObject(
87
+ props.blocks.find((block) => block.slug === blockType),
88
+ )
89
+
90
+
91
+ await beforeChangeTraverseFields({
92
+ id: null,
93
+ collection: null,
94
+ context,
95
+ data: node.fields,
96
+ doc: node.fields,
97
+ fields: sanitizedBlock.fields,
98
+ global: null,
99
+ mergeLocaleActions: [],
100
+ operation:
101
+ operation === 'create' || operation === 'update' ? operation : 'update',
102
+ overrideAccess,
103
+ path: '',
104
+ req,
105
+ siblingData: node.fields,
106
+ siblingDoc: node.fields,
107
+ })
108
+
109
+
110
+ return node
111
+ },
112
+ ],
113
+ beforeValidate: [
114
+ async ({ context, findMany, node, operation, overrideAccess, req }) => {
115
+ const blockType = node.fields.blockType
116
+
117
+ const block = deepCopyObject(
118
+ props.blocks.find((block) => block.slug === blockType),
119
+ )
120
+
121
+
122
+
123
+ await beforeValidateTraverseFields({
124
+ id: null,
125
+ collection: null,
126
+ context,
127
+ data: node.fields,
128
+ doc: node.fields,
129
+ fields: sanitizedBlock.fields,
130
+ global: null,
131
+ operation:
132
+ operation === 'create' || operation === 'update' ? operation : 'update',
133
+ overrideAccess,
134
+ req,
135
+ siblingData: node.fields,
136
+ siblingDoc: node.fields,
137
+ })
138
+
139
+ return node
140
+ },
141
+ ],
142
+ },*/ node: BlockNode,
111
143
  populationPromises: [
112
144
  blockPopulationPromiseHOC(props)
113
145
  ],
114
146
  validations: [
115
147
  blockValidationHOC(props)
116
148
  ]
117
- }
149
+ })
118
150
  ],
119
151
  serverFeatureProps: props
120
152
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/blocks/feature.server.ts"],"sourcesContent":["import type { Block, BlockField, Field, FieldWithRichTextRequiredEditor } from 'payload/types'\n\nimport { baseBlockFields, sanitizeFields } from 'payload/config'\nimport { fieldsToJSONSchema, formatLabels } from 'payload/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { BlocksFeatureClientProps } from './feature.client.js'\n\nimport { cloneDeep } from '../../lexical/utils/cloneDeep.js'\nimport { BlocksFeatureClientComponent } from './feature.client.js'\nimport { BlockNode } from './nodes/BlocksNode.js'\nimport { blockPopulationPromiseHOC } from './populationPromise.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type LexicalBlock = Omit<Block, 'fields'> & {\n fields: FieldWithRichTextRequiredEditor[]\n}\n\nexport type BlocksFeatureProps = {\n blocks: LexicalBlock[]\n}\n\nexport const BlocksFeature: FeatureProviderProviderServer<\n BlocksFeatureProps,\n BlocksFeatureClientProps\n> = (props) => {\n // Sanitization taken from payload/src/fields/config/sanitize.ts\n\n if (props?.blocks?.length) {\n props.blocks = props.blocks.map((block) => {\n const blockCopy = cloneDeep(block)\n\n return {\n ...blockCopy,\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n fields: blockCopy.fields.concat(baseBlockFields as FieldWithRichTextRequiredEditor[]),\n labels: !blockCopy.labels ? formatLabels(blockCopy.slug) : blockCopy.labels,\n }\n })\n // unSanitizedBlock.fields are sanitized in the React component and not here.\n // That's because we do not have access to the payload config here.\n }\n\n // Build clientProps\n const clientProps: BlocksFeatureClientProps = {\n reducedBlocks: [],\n }\n for (const block of props.blocks) {\n clientProps.reducedBlocks.push({\n slug: block.slug,\n fieldMap: [],\n imageAltText: block.imageAltText,\n imageURL: block.imageURL,\n labels: block.labels,\n })\n }\n\n return {\n feature: () => {\n return {\n ClientComponent: BlocksFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, props, schemaMap: schemaMapFromProps, schemaPath }) => {\n const schemaMap: {\n [key: string]: Field[]\n } = {}\n\n /**\n * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block and it runs addRow, it will request these\n * sub-fields from the component map. Thus we need to put them in the component map here.\n */\n const handleFields = (parentPath: string, fields: Field[]) => {\n for (const field of fields) {\n if ('name' in field && 'fields' in field) {\n schemaMap[parentPath + '.' + field.name] = field.fields\n handleFields(parentPath + '.' + field.name, field.fields)\n }\n if ('blocks' in field) {\n for (const block of field.blocks) {\n schemaMap[parentPath + '.' + field.name + '.' + block.slug] = block.fields || []\n handleFields(parentPath + '.' + field.name + '.' + block.slug, block.fields)\n }\n }\n if ('tabs' in field) {\n for (const tab of field.tabs) {\n if ('name' in tab) {\n schemaMap[parentPath + '.' + tab.name] = tab.fields || []\n handleFields(parentPath + '.' + tab.name, tab.fields)\n } else {\n handleFields(parentPath, tab.fields)\n }\n }\n }\n }\n }\n\n for (const block of props.blocks) {\n schemaMap[block.slug] = block.fields || []\n handleFields(block.slug, block.fields)\n }\n\n return schemaMap\n },\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length) {\n return currentSchema\n }\n\n // sanitize blocks\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const sanitizedBlocks = props.blocks.map((block) => {\n const blockCopy = cloneDeep(block)\n return {\n ...blockCopy,\n fields: sanitizeFields({\n config,\n fields: blockCopy.fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n }),\n }\n })\n\n const blocksField: BlockField = {\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: sanitizedBlocks,\n }\n // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.\n // we don't actually use the JSON Schema itself in the generated types yet.\n fieldsToJSONSchema(\n collectionIDFieldTypes,\n [blocksField],\n interfaceNameDefinitions,\n config,\n )\n\n return currentSchema\n },\n },\n nodes: [\n {\n node: BlockNode,\n populationPromises: [blockPopulationPromiseHOC(props)],\n validations: [blockValidationHOC(props)],\n },\n ],\n serverFeatureProps: props,\n }\n },\n key: 'blocks',\n serverFeatureProps: props,\n }\n}\n"],"names":["baseBlockFields","sanitizeFields","fieldsToJSONSchema","formatLabels","cloneDeep","BlocksFeatureClientComponent","BlockNode","blockPopulationPromiseHOC","blockValidationHOC","BlocksFeature","props","blocks","length","map","block","blockCopy","fields","concat","labels","slug","clientProps","reducedBlocks","push","fieldMap","imageAltText","imageURL","feature","ClientComponent","clientFeatureProps","generateSchemaMap","config","schemaMap","schemaMapFromProps","schemaPath","handleFields","parentPath","field","name","tab","tabs","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","interfaceNameDefinitions","validRelationships","collections","c","sanitizedBlocks","requireFieldLevelRichTextEditor","blocksField","type","nodes","node","populationPromises","validations","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,eAAe,EAAEC,cAAc,QAAQ,iBAAgB;AAChE,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,oBAAmB;AAKpE,SAASC,SAAS,QAAQ,mCA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GAAG,CAAC,CAACC;4BACxC,MAAMC,YAAYX,UAAUU;4BAC5B,OAAO;gCACL,GAAGC,SAAS;gCACZC,QAAQf,eAAe;oCACrB6B;oCACAd,QAAQD,UAAUC,MAAM;oCACxBiC,iCAAiC;oCACjCJ;gCACF;4BACF;wBACF;wBAEA,MAAMK,cAA0B;4BAC9Bb,MAAMD,OAAOC,OAAO;4BACpBc,MAAM;4BACNxC,QAAQqC;wBACV;wBACA,wFAAwF;wBACxF,2EAA2E;wBAC3E9C,mBACEwC,wBACA;4BAACQ;yBAAY,EACbN,0BACAd;wBAGF,OAAOa;oBACT;gBACF;gBACAS,OAAO;oBACL;wBACEC,MAAM/C;wBACNgD,oBAAoB;4BAAC/C,0BAA0BG;yBAAO;wBACtD6C,aAAa;4BAAC/C,mBAAmBE;yBAAO;oBAC1C;iBACD;gBACD8C,oBAAoB9C;YACtB;QACF;QACA+C,KAAK;QACLD,oBAAoB9C;IACtB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/blocks/feature.server.ts"],"sourcesContent":["import type { Config } from 'payload/config'\nimport type { Block, BlockField, Field, FieldWithRichTextRequiredEditor } from 'payload/types'\n\nimport { traverseFields } from '@payloadcms/next/utilities'\nimport { baseBlockFields, sanitizeFields } from 'payload/config'\nimport { fieldsToJSONSchema, formatLabels } from 'payload/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { BlocksFeatureClientProps } from './feature.client.js'\n\nimport { createNode } from '../typeUtilities.js'\nimport { BlocksFeatureClientComponent } from './feature.client.js'\nimport { BlockNode } from './nodes/BlocksNode.js'\nimport { blockPopulationPromiseHOC } from './populationPromise.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type LexicalBlock = Omit<Block, 'fields'> & {\n fields: FieldWithRichTextRequiredEditor[]\n}\n\nexport type BlocksFeatureProps = {\n blocks: LexicalBlock[]\n}\n\nexport const BlocksFeature: FeatureProviderProviderServer<\n BlocksFeatureProps,\n BlocksFeatureClientProps\n> = (props) => {\n return {\n feature: async ({ config: _config }) => {\n if (props?.blocks?.length) {\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n for (const block of props.blocks) {\n block.fields = block.fields.concat(baseBlockFields as FieldWithRichTextRequiredEditor[])\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n\n block.fields = (await sanitizeFields({\n config: _config as unknown as Config,\n fields: block.fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })) as FieldWithRichTextRequiredEditor[]\n }\n }\n\n // Build clientProps\n const clientProps: BlocksFeatureClientProps = {\n reducedBlocks: [],\n }\n for (const block of props.blocks) {\n clientProps.reducedBlocks.push({\n slug: block.slug,\n fieldMap: [],\n imageAltText: block.imageAltText,\n imageURL: block.imageURL,\n labels: block.labels,\n })\n }\n\n return {\n ClientComponent: BlocksFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, i18n, props }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n /**\n * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block, and it runs addRow, it will request these\n * sub-fields from the component map. Thus, we need to put them in the component map here.\n */\n const schemaMap = new Map<string, Field[]>()\n\n for (const block of props.blocks) {\n schemaMap.set(block.slug, block.fields || [])\n\n traverseFields({\n config,\n fields: block.fields,\n i18n,\n schemaMap,\n schemaPath: block.slug,\n validRelationships,\n })\n }\n\n return schemaMap\n },\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length) {\n return currentSchema\n }\n\n const blocksField: BlockField = {\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n }\n // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.\n // we don't actually use the JSON Schema itself in the generated types yet.\n fieldsToJSONSchema(\n collectionIDFieldTypes,\n [blocksField],\n interfaceNameDefinitions,\n config,\n )\n\n return currentSchema\n },\n },\n nodes: [\n createNode({\n /* // TODO: Implement these hooks once docWithLocales / originalSiblingDoc => node matching has been figured out\n hooks: {\n beforeChange: [\n async ({ context, findMany, node, operation, overrideAccess, req }) => {\n const blockType = node.fields.blockType\n\n const block = deepCopyObject(\n props.blocks.find((block) => block.slug === blockType),\n )\n\n\n await beforeChangeTraverseFields({\n id: null,\n collection: null,\n context,\n data: node.fields,\n doc: node.fields,\n fields: sanitizedBlock.fields,\n global: null,\n mergeLocaleActions: [],\n operation:\n operation === 'create' || operation === 'update' ? operation : 'update',\n overrideAccess,\n path: '',\n req,\n siblingData: node.fields,\n siblingDoc: node.fields,\n })\n\n\n return node\n },\n ],\n beforeValidate: [\n async ({ context, findMany, node, operation, overrideAccess, req }) => {\n const blockType = node.fields.blockType\n\n const block = deepCopyObject(\n props.blocks.find((block) => block.slug === blockType),\n )\n\n\n\n await beforeValidateTraverseFields({\n id: null,\n collection: null,\n context,\n data: node.fields,\n doc: node.fields,\n fields: sanitizedBlock.fields,\n global: null,\n operation:\n operation === 'create' || operation === 'update' ? operation : 'update',\n overrideAccess,\n req,\n siblingData: node.fields,\n siblingDoc: node.fields,\n })\n\n return node\n },\n ],\n },*/\n node: BlockNode,\n populationPromises: [blockPopulationPromiseHOC(props)],\n validations: [blockValidationHOC(props)],\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'blocks',\n serverFeatureProps: props,\n }\n}\n"],"names":["traverseFields","baseBlockFields","sanitizeFields","fieldsToJSONSchema","formatLabels","createNode","BlocksFeatureClientComponent","BlockNode","blockPopulationPromiseHOC","blockValidationHOC","BlocksFeature","props","feature","config","_config","blocks","length","validRelationships","collections","map","c","slug","block","fields","concat","labels","requireFieldLevelRichTextEditor","clientProps","reducedBlocks","push","fieldMap","imageAltText","imageURL","ClientComponent","clientFeatureProps","generateSchemaMap","i18n","schemaMap","Map","set","schemaPath","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","field","interfaceNameDefinitions","blocksField","name","type","nodes","node","populationPromises","validations","serverFeaturePro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aAAa;4BAAC5C,mBAAmBE;yBAAO;oBAC1C;iBACD;gBACD2C,oBAAoB3C;YACtB;QACF;QACA4C,KAAK;QACLD,oBAAoB3C;IACtB;AACF,EAAC"}
@@ -1,8 +1,7 @@
1
1
  /// <reference types="react" resolution-mode="require"/>
2
2
  import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
3
3
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
4
- import lexicalDecoratorBlockNodeImport from '@lexical/react/LexicalDecoratorBlockNode.js';
5
- declare const DecoratorBlockNode: typeof lexicalDecoratorBlockNodeImport.DecoratorBlockNode;
4
+ import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
6
5
  export type BlockFields = {
7
6
  /** Block form data */
8
7
  [key: string]: any;
@@ -34,5 +33,4 @@ export declare class BlockNode extends DecoratorBlockNode {
34
33
  }
35
34
  export declare function $createBlockNode(fields: Exclude<BlockFields, 'id'>): BlockNode;
36
35
  export declare function $isBlockNode(node: BlockNode | LexicalNode | null | undefined): node is BlockNode;
37
- export {};
38
36
  //# sourceMappingURL=BlocksNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksNode.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/nodes/BlocksNode.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAA;AAEhB,OAAO,+BAA+B,MAAM,6CAA6C,CAAA;AACzF,QAAA,MAAQ,kBAAkB,2DAAoC,CAAA;AAI9D,MAAM,MAAM,WAAW,GAAG;IACxB,sBAAsB;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,GA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S,IAAI,WAAW;IAIxB,cAAc,IAAI,MAAM;IAIxB,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;CAMrC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,SAAS,CAO9E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,SAAS,CAEhG"}
@@ -1,5 +1,4 @@
1
- import lexicalDecoratorBlockNodeImport from '@lexical/react/LexicalDecoratorBlockNode.js';
2
- const { DecoratorBlockNode } = lexicalDecoratorBlockNodeImport;
1
+ import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
3
2
  import ObjectID from 'bson-objectid';
4
3
  import React from 'react';
5
4
  const BlockComponent = /*#__PURE__*/ React.lazy(()=>import('../component/index.js').then((module)=>({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/blocks/nodes/BlocksNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\n\nimport lexicalDecoratorBlockNodeImport from '@lexical/react/LexicalDecoratorBlockNode.js'\nconst { DecoratorBlockNode } = lexicalDecoratorBlockNodeImport\nimport ObjectID from 'bson-objectid'\nimport React from 'react'\n\nexport type BlockFields = {\n /** Block form data */\n [key: string]: any\n blockName: string\n blockType: string\n id: string\n}\n\nconst BlockComponent = React.lazy(() =>\n import('../component/index.js').then((module) => ({\n default: module.BlockComponent,\n })),\n)\n\nexport type SerializedBlockNode = Spread<\n {\n fields: BlockFields\n },\n SerializedDecoratorBlockNode\n>\n\nexport class BlockNode extends DecoratorBlockNode {\n __fields: BlockFields\n\n constructor({\n fields,\n format,\n key,\n }: {\n fields: BlockFields\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__fields = fields\n }\n\n static clone(node: BlockNode): BlockNode {\n return new BlockNode({\n fields: node.__fields,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'block'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedBlockNode): BlockNode {\n if (serializedNode.version === 1) {\n // Convert (version 1 had the fields wrapped in another, unnecessary data property)\n serializedNode = {\n ...serializedNode,\n fields: {\n ...(serializedNode as any).fields.data,\n },\n version: 2,\n }\n }\n const node = $createBlockNode(serializedNode.fields)\n node.setFormat(serializedNode.format)\n return node\n }\n\n static isInline(): false {\n return false\n }\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n // @ts-expect-error\n return <BlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedBlockNode {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n fields: this.getFields(),\n version: 2,\n }\n }\n\n getFields(): BlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n setFields(fields: BlockFields): void {\n const fieldsCopy = JSON.parse(JSON.stringify(fields)) as BlockFields\n\n const writable = this.getWritable()\n writable.__fields = fieldsCopy\n }\n}\n\nexport function $createBlockNode(fields: Exclude<BlockFields, 'id'>): BlockNode {\n return new BlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isBlockNode(node: BlockNode | LexicalNode | null | undefined): node is BlockNode {\n return node instanceof BlockNode\n}\n"],"names":["lexicalDecoratorBlockNodeImport","DecoratorBlockNode","ObjectID","React","BlockComponent","lazy","then","module","default","BlockNode","__fields","constructor","fields","format","key","clone","node","__format","__key","getType","importDOM","importJSON","serializedNode","version","data","$createBlockNode","setFormat","isInline","decorate","editor","config","formData","getFields","nodeKey","getKey","exportDOM","element","document","createElement","text","createTextNode","getTextContent","append","exportJSON","type","getLatest","setFields","fieldsCopy","JSON","parse","stringify","writable","getWritable","id","toHexString","$isBlockNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAYA,OAAOA,qCAAqC,8CAA6C;AACzF,MAAM,EAAEC,kBAAkB,EAAE,GAAGD;AAC/B,OAAOE,cAAc,gBAAe;AACpC,OAAOC,WAAW,QAAO;AAUzB,MAAMC,+BAAiBD,MAAME,IAAI,CAAC,IAChC,MAAM,CAAC,yBAAyBC,IAAI,CAAC,CAACC,SAAY,CAAA;YAChDC,SAASD,OAAOH,cAAc;QAChC,CAAA;AAUF,OAAO,MAAMK,kBAAkBR;IAC7BS,SAAqB;IAErBC,YAAY,EACVC,MAAM,EACNC,MAAM,EACNC,GAAG,EAKJ,CAAE;QACD,KAAK,CAACD,QAAQC;QACd,IAAI,CAACJ,QAAQ,GAAGE;IAClB;IAEA,OAAOG,MAAMC,IAAe,EAAa;QACvC,OAAO,IAAIP,UAAU;YACnBG,QAAQI,KAAKN,QAAQ;YACrBG,QAAQG,KAAKC,QAAQ;YACrBH,KAAKE,KAAKE,KAAK;QACjB;IACF;IAEA,OAAOC,UAAkB;QACvB,OAAO;IACT;IAEA,OAAOC,YAAqD;QAC1D,OAAO,CAAC;IACV;IAEA,OAAOC,WAAWC,cAAmC,EAAa;QAChE,IAAIA,eAAeC,OAAO,KAAK,GAAG;YAChC,mFAAmF;YACnFD,iBAAiB;gBACf,GAAGA,cAAc;gBACjBV,QAAQ;oBACN,GAAG,AAACU,eAAuBV,MAAM,CAACY,IAAI;gBACxC;gBACAD,SAAS;YACX;QACF;QACA,MAAMP,OAAOS,iBAAiBH,eAAeV,MAAM;QACnDI,KAAKU,SAAS,CAACJ,eAAeT,MAAM;QACpC,OAAOG;IACT;IAEA,OAAOW,WAAkB;QACvB,OAAO;IACT;IACAC,SAASC,MAAqB,EAAEC,MAAoB,EAAe;QACjE,mBAAmB;QACnB,qBAAO,oBAAC1B;YAAe2B,UAAU,IAAI,CAACC,SAAS;YAAIC,SAAS,IAAI,CAACC,MAAM;;IACzE;IAEAC,YAA6B;QAC3B,MAAMC,UAAUC,SAASC,aAAa,CAAC;QAEvC,MAAMC,OAAOF,SAASG,cAAc,CAAC,IAAI,CAACC,cAAc;QACxDL,QAAQM,MAAM,CAACH;QACf,OAAO;YAAEH;QAAQ;IACnB;IAEAO,aAAkC;QAChC,OAAO;YACL,GAAG,KAAK,CAACA,YAAY;YACrBC,MAAM,IAAI,CAACzB,OAAO;YAClBP,QAAQ,IAAI,CAACoB,SAAS;YACtBT,SAAS;QACX;IACF;IAEAS,YAAyB;QACvB,OAAO,IAAI,CAACa,SAAS,GAAGnC,QAAQ;IAClC;IAEA+B,iBAAyB;QACvB,OAAO,CAAC,WAAW,CAAC;IACtB;IAEAK,UAAUlC,MAAmB,EAAQ;QACnC,MAAMmC,aAAaC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACtC;QAE7C,MAAMuC,WAAW,IAAI,CAACC,WAAW;QACjCD,SAASzC,QAAQ,GAAGqC;IACtB;AACF;AAEA,OAAO,SAAStB,iBAAiBb,MAAkC;IACjE,OAAO,IAAIH,UAAU;QACnBG,QAAQ;YACN,GAAGA,MAAM;YACTyC,IAAIzC,QAAQyC,MAAM,IAAInD,SAASM,OAAO,GAAG8C,WAAW;QACtD;IACF;AACF;AAEA,OAAO,SAASC,aAAavC,IAAgD;IAC3E,OAAOA,gBAAgBP;AACzB"}
1
+ {"version":3,"sources":["../../../../../src/field/features/blocks/nodes/BlocksNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport React from 'react'\n\nexport type BlockFields = {\n /** Block form data */\n [key: string]: any\n blockName: string\n blockType: string\n id: string\n}\n\nconst BlockComponent = React.lazy(() =>\n import('../component/index.js').then((module) => ({\n default: module.BlockComponent,\n })),\n)\n\nexport type SerializedBlockNode = Spread<\n {\n fields: BlockFields\n },\n SerializedDecoratorBlockNode\n>\n\nexport class BlockNode extends DecoratorBlockNode {\n __fields: BlockFields\n\n constructor({\n fields,\n format,\n key,\n }: {\n fields: BlockFields\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__fields = fields\n }\n\n static clone(node: BlockNode): BlockNode {\n return new BlockNode({\n fields: node.__fields,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'block'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedBlockNode): BlockNode {\n if (serializedNode.version === 1) {\n // Convert (version 1 had the fields wrapped in another, unnecessary data property)\n serializedNode = {\n ...serializedNode,\n fields: {\n ...(serializedNode as any).fields.data,\n },\n version: 2,\n }\n }\n const node = $createBlockNode(serializedNode.fields)\n node.setFormat(serializedNode.format)\n return node\n }\n\n static isInline(): false {\n return false\n }\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n // @ts-expect-error\n return <BlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedBlockNode {\n return {\n ...super.exportJSON(),\n type: this.getType(),\n fields: this.getFields(),\n version: 2,\n }\n }\n\n getFields(): BlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n setFields(fields: BlockFields): void {\n const fieldsCopy = JSON.parse(JSON.stringify(fields)) as BlockFields\n\n const writable = this.getWritable()\n writable.__fields = fieldsCopy\n }\n}\n\nexport function $createBlockNode(fields: Exclude<BlockFields, 'id'>): BlockNode {\n return new BlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isBlockNode(node: BlockNode | LexicalNode | null | undefined): node is BlockNode {\n return node instanceof BlockNode\n}\n"],"names":["DecoratorBlockNode","ObjectID","React","BlockComponent","lazy","then","module","default","BlockNode","__fields","constructor","fields","format","key","clone","node","__format","__key","getType","importDOM","importJSON","serializedNode","version","data","$createBlockNode","setFormat","isInline","decorate","editor","config","formData","getFields","nodeKey","getKey","exportDOM","element","document","createElement","text","createTextNode","getTextContent","append","exportJSON","type","getLatest","setFields","fieldsCopy","JSON","parse","stringify","writable","getWritable","id","toHexString","$isBlockNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAYA,SAASA,kBAAkB,QAAQ,8CAA6C;AAChF,OAAOC,cAAc,gBAAe;AACpC,OAAOC,WAAW,QAAO;AAUzB,MAAMC,+BAAiBD,MAAME,IAAI,CAAC,IAChC,MAAM,CAAC,yBAAyBC,IAAI,CAAC,CAACC,SAAY,CAAA;YAChDC,SAASD,OAAOH,cAAc;QAChC,CAAA;AAUF,OAAO,MAAMK,kBAAkBR;IAC7BS,SAAqB;IAErBC,YAAY,EACVC,MAAM,EACNC,MAAM,EACNC,GAAG,EAKJ,CAAE;QACD,KAAK,CAACD,QAAQC;QACd,IAAI,CAACJ,QAAQ,GAAGE;IAClB;IAEA,OAAOG,MAAMC,IAAe,EAAa;QACvC,OAAO,IAAIP,UAAU;YACnBG,QAAQI,KAAKN,QAAQ;YACrBG,QAAQG,KAAKC,QAAQ;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AO,SAAStB,iBAAiBb,MAAkC;IACjE,OAAO,IAAIH,UAAU;QACnBG,QAAQ;YACN,GAAGA,MAAM;YACTyC,IAAIzC,QAAQyC,MAAM,IAAInD,SAASM,OAAO,GAAG8C,WAAW;QACtD;IACF;AACF;AAEA,OAAO,SAASC,aAAavC,IAAgD;IAC3E,OAAOA,gBAAgBP;AACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/plugin/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAAC,kBAAkB,CAC7B,CAAA"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/plugin/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAAC,kBAAkB,CAC7B,CAAA"}
@@ -1,5 +1,4 @@
1
- import lexicalImport from 'lexical';
2
- const { createCommand } = lexicalImport;
1
+ import { createCommand } from 'lexical';
3
2
  export const INSERT_BLOCK_COMMAND = createCommand('INSERT_BLOCK_COMMAND');
4
3
 
5
4
  //# sourceMappingURL=commands.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/blocks/plugin/commands.ts"],"sourcesContent":["import type { LexicalCommand } from 'lexical'\n\nimport lexicalImport from 'lexical'\nconst { createCommand } = lexicalImport\n\nimport type { InsertBlockPayload } from './index.js'\n\nexport const INSERT_BLOCK_COMMAND: LexicalCommand<InsertBlockPayload> =\n createCommand('INSERT_BLOCK_COMMAND')\n"],"names":["lexicalImport","createCommand","INSERT_BLOCK_COMMAND"],"rangeMappings":";;","mappings":"AAEA,OAAOA,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAI1B,OAAO,MAAME,uBACXD,cAAc,wBAAuB"}
1
+ {"version":3,"sources":["../../../../../src/field/features/blocks/plugin/commands.ts"],"sourcesContent":["import type { LexicalCommand } from 'lexical'\n\nimport { createCommand } from 'lexical'\n\nimport type { InsertBlockPayload } from './index.js'\n\nexport const INSERT_BLOCK_COMMAND: LexicalCommand<InsertBlockPayload> =\n createCommand('INSERT_BLOCK_COMMAND')\n"],"names":["createCommand","INSERT_BLOCK_COMMAND"],"rangeMappings":";","mappings":"AAEA,SAASA,aAAa,QAAQ,UAAS;AAIvC,OAAO,MAAMC,uBACXD,cAAc,wBAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/plugin/index.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAMzD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;AAE3D,wBAAgB,YAAY,IAAI,KAAK,CAAC,SAAS,CA8C9C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/plugin/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAMzD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;AAE3D,wBAAgB,YAAY,IAAI,KAAK,CAAC,SAAS,CA8C9C"}
@@ -1,10 +1,7 @@
1
1
  'use client';
2
- import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
3
- const { useLexicalComposerContext } = lexicalComposerContextImport;
4
- import lexicalUtilsImport from '@lexical/utils';
5
- const { $insertNodeToNearestRoot, mergeRegister } = lexicalUtilsImport;
6
- import lexicalImport from 'lexical';
7
- const { $getPreviousSelection, $getSelection, $isParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR } = lexicalImport;
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
+ import { $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils';
4
+ import { $getPreviousSelection, $getSelection, $isParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical';
8
5
  import React, { useEffect } from 'react';
9
6
  import { BlocksDrawerComponent } from '../drawer/index.js';
10
7
  import { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/blocks/plugin/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { $insertNodeToNearestRoot, mergeRegister } = lexicalUtilsImport\nimport lexicalImport from 'lexical'\nconst {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n} = lexicalImport\n\nimport React, { useEffect } from 'react'\n\nimport type { BlockFields } from '../nodes/BlocksNode.js'\n\nimport { BlocksDrawerComponent } from '../drawer/index.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { INSERT_BLOCK_COMMAND } from './commands.js'\n\nexport type InsertBlockPayload = Exclude<BlockFields, 'id'>\n\nexport function BlocksPlugin(): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const blockNode = $createBlockNode(payload)\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(blockNode)\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor])\n\n return <BlocksDrawerComponent />\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","$insertNodeToNearestRoot","mergeRegister","lexicalImport","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","React","useEffect","BlocksDrawerComponent","$createBlockNode","BlockNode","INSERT_BLOCK_COMMAND","BlocksPlugin","editor","hasNodes","Error","registerCommand","payload","update","blockNode","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","filter","node","length","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,wBAAwB,EAAEC,aAAa,EAAE,GAAGF;AACpD,OAAOG,mBAAmB,UAAS;AACnC,MAAM,EACJC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACxB,GAAGL;AAEJ,OAAOM,SAASC,SAAS,QAAQ,QAAO;AAIxC,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,yBAAwB;AACpE,SAASC,oBAAoB,QAAQ,gBAAe;AAIpD,OAAO,SAASC;IACd,MAAM,CAACC,OAAO,GAAGjB;IAEjBW,UAAU;QACR,IAAI,CAACM,OAAOC,QAAQ,CAAC;YAACJ;SAAU,GAAG;YACjC,MAAM,IAAIK,MAAM;QAClB;QAEA,OAAOhB,cACLc,OAAOG,eAAe,CACpBL,sBACA,CAACM;YACCJ,OAAOK,MAAM,CAAC;gBACZ,MAAMC,YAAYV,iBAAiBQ;gBAEnC,MAAMG,YAAYlB,mBAAmBD;gBAErC,IAAIG,kBAAkBgB,YAAY;oBAChC,MAAM,EAAEC,KAAK,EAAE,GAAGD;oBAClB,MAAME,YAAYD,MAAME,OAAO;oBAE/B,+FAA+F;oBAC/F,0FAA0F;oBAC1F,IACEpB,iBAAiBmB,cACjBA,UAAUE,kBAAkB,OAAO,KACnCF,UACGG,SAAS,GACTC,WAAW,GACXC,MAAM,CAAC,CAACC,OAASzB,iBAAiByB,OAAOC,MAAM,GAAG,GACrD;wBACAP,UAAUQ,MAAM;oBAClB;oBAEAhC,yBAAyBqB;gBAC3B;YACF;YAEA,OAAO;QACT,GACAd;IAGN,GAAG;QAACQ;KAAO;IAEX,qBAAO,oBAACL;AACV"}
1
+ {"version":3,"sources":["../../../../../src/field/features/blocks/plugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { BlockFields } from '../nodes/BlocksNode.js'\n\nimport { BlocksDrawerComponent } from '../drawer/index.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { INSERT_BLOCK_COMMAND } from './commands.js'\n\nexport type InsertBlockPayload = Exclude<BlockFields, 'id'>\n\nexport function BlocksPlugin(): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const blockNode = $createBlockNode(payload)\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(blockNode)\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor])\n\n return <BlocksDrawerComponent />\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","mergeRegister","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","React","useEffect","BlocksDrawerComponent","$createBlockNode","BlockNode","INSERT_BLOCK_COMMAND","BlocksPlugin","editor","hasNodes","Error","registerCommand","payload","update","blockNode","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","filter","node","length","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,EAAEC,aAAa,QAAQ,iBAAgB;AACxE,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,QAClB,UAAS;AAChB,OAAOC,SAASC,SAAS,QAAQ,QAAO;AAIxC,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,yBAAwB;AACpE,SAASC,oBAAoB,QAAQ,gBAAe;AAIpD,OAAO,SAASC;IACd,MAAM,CAACC,OAAO,GAAGf;IAEjBS,UAAU;QACR,IAAI,CAACM,OAAOC,QAAQ,CAAC;YAACJ;SAAU,GAAG;YACjC,MAAM,IAAIK,MAAM;QAClB;QAEA,OAAOf,cACLa,OAAOG,eAAe,CACpBL,sBACA,CAACM;YACCJ,OAAOK,MAAM,CAAC;gBACZ,MAAMC,YAAYV,iBAAiBQ;gBAEnC,MAAMG,YAAYlB,mBAAmBD;gBAErC,IAAIG,kBAAkBgB,YAAY;oBAChC,MAAM,EAAEC,KAAK,EAAE,GAAGD;oBAClB,MAAME,YAAYD,MAAME,OAAO;oBAE/B,+FAA+F;oBAC/F,0FAA0F;oBAC1F,IACEpB,iBAAiBmB,cACjBA,UAAUE,kBAAkB,OAAO,KACnCF,UACGG,SAAS,GACTC,WAAW,GACXC,MAAM,CAAC,CAACC,OAASzB,iBAAiByB,OAAOC,MAAM,GAAG,GACrD;wBACAP,UAAUQ,MAAM;oBAClB;oBAEA/B,yBAAyBoB;gBAC3B;YACF;YAEA,OAAO;QACT,GACAd;IAGN,GAAG;QAACQ;KAAO;IAEX,qBAAO,oBAACL;AACV"}
@@ -1 +1 @@
1
- {"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/populationPromise.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAIhE,eAAO,MAAM,yBAAyB,UAC7B,kBAAkB,KACxB,kBAAkB,mBAAmB,CA4DvC,CAAA"}
1
+ {"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/populationPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAIhE,eAAO,MAAM,yBAAyB,UAC7B,kBAAkB,KACxB,kBAAkB,mBAAmB,CA4CvC,CAAA"}
@@ -1,25 +1,11 @@
1
- import { sanitizeFields } from 'payload/config';
2
1
  import { recurseNestedFields } from '../../../populate/recurseNestedFields.js';
3
2
  export const blockPopulationPromiseHOC = (props)=>{
4
- const blockPopulationPromise = ({ context, currentDepth, depth, editorPopulationPromises, findMany, flattenLocales, node, overrideAccess, populationPromises, req, showHiddenFields, siblingDoc })=>{
5
- const blocks = props.blocks;
3
+ const blockPopulationPromise = ({ context, currentDepth, depth, editorPopulationPromises, fieldPromises, findMany, flattenLocales, node, overrideAccess, populationPromises, req, showHiddenFields, siblingDoc })=>{
6
4
  const blockFieldData = node.fields;
7
- const promises = [];
8
- // Sanitize block's fields here. This is done here and not in the feature, because the payload config is available here
9
- const payloadConfig = req.payload.config;
10
- const validRelationships = payloadConfig.collections.map((c)=>c.slug) || [];
11
- blocks.forEach((block)=>{
12
- block.fields = sanitizeFields({
13
- config: payloadConfig,
14
- fields: block.fields,
15
- requireFieldLevelRichTextEditor: true,
16
- validRelationships
17
- });
18
- });
19
5
  // find block used in this node
20
6
  const block = props.blocks.find((block)=>block.slug === blockFieldData.blockType);
21
7
  if (!block || !block?.fields?.length || !blockFieldData) {
22
- return promises;
8
+ return;
23
9
  }
24
10
  recurseNestedFields({
25
11
  context,
@@ -27,18 +13,17 @@ export const blockPopulationPromiseHOC = (props)=>{
27
13
  data: blockFieldData,
28
14
  depth,
29
15
  editorPopulationPromises,
16
+ fieldPromises,
30
17
  fields: block.fields,
31
18
  findMany,
32
19
  flattenLocales,
33
20
  overrideAccess,
34
21
  populationPromises,
35
- promises,
36
22
  req,
37
23
  showHiddenFields,
38
24
  // The afterReadPromise gets its data from looking for field.name inside the siblingDoc. Thus, here we cannot pass the whole document's siblingDoc, but only the siblingDoc (sibling fields) of the current field.
39
25
  siblingDoc: blockFieldData
40
26
  });
41
- return promises;
42
27
  };
43
28
  return blockPopulationPromise;
44
29
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/blocks/populationPromise.ts"],"sourcesContent":["import type { Block } from 'payload/types'\n\nimport { sanitizeFields } from 'payload/config'\n\nimport type { PopulationPromise } from '../types.js'\nimport type { BlocksFeatureProps } from './feature.server.js'\nimport type { SerializedBlockNode } from './nodes/BlocksNode.js'\n\nimport { recurseNestedFields } from '../../../populate/recurseNestedFields.js'\n\nexport const blockPopulationPromiseHOC = (\n props: BlocksFeatureProps,\n): PopulationPromise<SerializedBlockNode> => {\n const blockPopulationPromise: PopulationPromise<SerializedBlockNode> = ({\n context,\n currentDepth,\n depth,\n editorPopulationPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) => {\n const blocks: Block[] = props.blocks\n const blockFieldData = node.fields\n\n const promises: Promise<void>[] = []\n\n // Sanitize block's fields here. This is done here and not in the feature, because the payload config is available here\n const payloadConfig = req.payload.config\n const validRelationships = payloadConfig.collections.map((c) => c.slug) || []\n blocks.forEach((block) => {\n block.fields = sanitizeFields({\n config: payloadConfig,\n fields: block.fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })\n })\n\n // find block used in this node\n const block = props.blocks.find((block) => block.slug === blockFieldData.blockType)\n if (!block || !block?.fields?.length || !blockFieldData) {\n return promises\n }\n\n recurseNestedFields({\n context,\n currentDepth,\n data: blockFieldData,\n depth,\n editorPopulationPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n promises,\n req,\n showHiddenFields,\n // The afterReadPromise gets its data from looking for field.name inside the siblingDoc. Thus, here we cannot pass the whole document's siblingDoc, but only the siblingDoc (sibling fields) of the current field.\n siblingDoc: blockFieldData,\n })\n\n return promises\n }\n\n return blockPopulationPromise\n}\n"],"names":["sanitizeFields","recurseNestedFields","blockPopulationPromiseHOC","props","blockPopulationPromise","context","currentDepth","depth","editorPopulationPromises","findMany","flattenLocales","node","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","blocks","blockFieldData","fields","promises","payloadConfig","payload","config","validRelationships","collections","map","c","slug","forEach","block","requireFieldLevelRichTextEditor","find","blockType","length","data"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAM/C,SAASC,mBAAmB,QAAQ,2CAA0C;AAE9E,OAAO,MAAMC,4BAA4B,CACvCC;IAEA,MAAMC,yBAAiE,CAAC,EACtEC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,wBAAwB,EACxBC,QAAQ,EACRC,cAAc,EACdC,IAAI,EACJC,cAAc,EACdC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EAChBC,UAAU,EACX;QACC,MAAMC,SAAkBd,MAAMc,MAAM;QACpC,MAAMC,iBAAiBP,KAAKQ,MAAM;QAElC,MAAMC,WAA4B,EAAE;QAEpC,uHAAuH;QACvH,MAAMC,gBAAgBP,IAAIQ,OAAO,CAACC,MAAM;QACxC,MAAMC,qBAAqBH,cAAcI,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAC7EX,OAAOY,OAAO,CAAC,CAACC;YACdA,MAAMX,MAAM,GAAGnB,eAAe;gBAC5BuB,QAAQF;gBACRF,QAAQW,MAAMX,MAAM;gBACpBY,iCAAiC;gBACjCP;YACF;QACF;QAEA,+BAA+B;QAC/B,MAAMM,QAAQ3B,MAAMc,MAAM,CAACe,IAAI,CAAC,CAACF,QAAUA,MAAMF,IAAI,KAAKV,eAAee,SAAS;QAClF,IAAI,CAACH,SAAS,CAACA,OAAOX,QAAQe,UAAU,CAAChB,gBAAgB;YACvD,OAAOE;QACT;QAEAnB,oBAAoB;YAClBI;YACAC;YACA6B,MAAMjB;YACNX;YACAC;YACAW,QAAQW,MAAMX,MAAM;YACpBV;YACAC;YACAE;YACAC;YACAO;YACAN;YACAC;YACA,kNAAkN;YAClNC,YAAYE;QACd;QAEA,OAAOE;IACT;IAEA,OAAOhB;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/blocks/populationPromise.ts"],"sourcesContent":["import type { PopulationPromise } from '../types.js'\nimport type { BlocksFeatureProps } from './feature.server.js'\nimport type { SerializedBlockNode } from './nodes/BlocksNode.js'\n\nimport { recurseNestedFields } from '../../../populate/recurseNestedFields.js'\n\nexport const blockPopulationPromiseHOC = (\n props: BlocksFeatureProps,\n): PopulationPromise<SerializedBlockNode> => {\n const blockPopulationPromise: PopulationPromise<SerializedBlockNode> = ({\n context,\n currentDepth,\n depth,\n editorPopulationPromises,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) => {\n const blockFieldData = node.fields\n\n // find block used in this node\n const block = props.blocks.find((block) => block.slug === blockFieldData.blockType)\n if (!block || !block?.fields?.length || !blockFieldData) {\n return\n }\n\n recurseNestedFields({\n context,\n currentDepth,\n data: blockFieldData,\n depth,\n editorPopulationPromises,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n // The afterReadPromise gets its data from looking for field.name inside the siblingDoc. Thus, here we cannot pass the whole document's siblingDoc, but only the siblingDoc (sibling fields) of the current field.\n siblingDoc: blockFieldData,\n })\n }\n\n return blockPopulationPromise\n}\n"],"names":["recurseNestedFields","blockPopulationPromiseHOC","props","blockPopulationPromise","context","currentDepth","depth","editorPopulationPromises","fieldPromises","findMany","flattenLocales","node","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","blockFieldData","fields","block","blocks","find","slug","blockType","length","data"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,mBAAmB,QAAQ,2CAA0C;AAE9E,OAAO,MAAMC,4BAA4B,CACvCC;IAEA,MAAMC,yBAAiE,CAAC,EACtEC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,wBAAwB,EACxBC,aAAa,EACbC,QAAQ,EACRC,cAAc,EACdC,IAAI,EACJC,cAAc,EACdC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EAChBC,UAAU,EACX;QACC,MAAMC,iBAAiBN,KAAKO,MAAM;QAElC,+BAA+B;QAC/B,MAAMC,QAAQjB,MAAMkB,MAAM,CAACC,IAAI,CAAC,CAACF,QAAUA,MAAMG,IAAI,KAAKL,eAAeM,SAAS;QAClF,IAAI,CAACJ,SAAS,CAACA,OAAOD,QAAQM,UAAU,CAACP,gBAAgB;YACvD;QACF;QAEAjB,oBAAoB;YAClBI;YACAC;YACAoB,MAAMR;YACNX;YACAC;YACAC;YACAU,QAAQC,MAAMD,MAAM;YACpBT;YACAC;YACAE;YACAC;YACAC;YACAC;YACA,kNAAkN;YAClNC,YAAYC;QACd;IACF;IAEA,OAAOd;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/validate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,eAAO,MAAM,kBAAkB,UACtB,kBAAkB,KACxB,eAAe,mBAAmB,CAmEpC,CAAA"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAe,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE7E,eAAO,MAAM,kBAAkB,UACtB,kBAAkB,KACxB,eAAe,mBAAmB,CA2CpC,CAAA"}
@@ -1,50 +1,36 @@
1
- import { sanitizeFields } from 'payload/config';
1
+ import { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema';
2
2
  export const blockValidationHOC = (props)=>{
3
- const blockValidation = async ({ node, validation })=>{
4
- const blockFieldData = node.fields;
5
- const blocks = props.blocks;
6
- const { options: { req, req: { payload: { config } } } } = validation;
7
- // Sanitize block's fields here. This is done here and not in the feature, because the payload config is available here
8
- const validRelationships = config.collections.map((c)=>c.slug) || [];
9
- blocks.forEach((block)=>{
10
- block.fields = sanitizeFields({
11
- config,
12
- fields: block.fields,
13
- requireFieldLevelRichTextEditor: true,
14
- validRelationships
15
- });
16
- });
3
+ return async ({ node, validation })=>{
4
+ const blockFieldData = node.fields ?? {};
5
+ const { options: { id, operation, preferences, req } } = validation;
17
6
  // find block
18
7
  const block = props.blocks.find((block)=>block.slug === blockFieldData.blockType);
19
8
  // validate block
20
9
  if (!block) {
21
10
  return 'Block not found';
22
11
  }
23
- for (const field of block.fields){
24
- if ('validate' in field && typeof field.validate === 'function' && field.validate) {
25
- const fieldValue = 'name' in field ? node.fields[field.name] : null;
26
- const passesCondition = field.admin?.condition ? Boolean(field.admin.condition(fieldValue, node.fields, {
27
- user: req?.user
28
- })) : true;
29
- if (!passesCondition) {
30
- continue; // Fixes https://github.com/payloadcms/payload/issues/4000
31
- }
32
- const validationResult = await field.validate(fieldValue, {
33
- ...field,
34
- id: validation.options.id,
35
- data: fieldValue,
36
- operation: validation.options.operation,
37
- req,
38
- siblingData: validation.options.siblingData
39
- });
40
- if (validationResult !== true) {
41
- return validationResult;
42
- }
12
+ /**
13
+ * Run buildStateFromSchema as that properly validates block and block sub-fields
14
+ */ const result = await buildStateFromSchema({
15
+ id,
16
+ data: blockFieldData,
17
+ fieldSchema: block.fields,
18
+ operation: operation === 'create' || operation === 'update' ? operation : 'update',
19
+ preferences,
20
+ req,
21
+ siblingData: blockFieldData
22
+ });
23
+ let errorPaths = [];
24
+ for(const fieldKey in result){
25
+ if (result[fieldKey].errorPaths) {
26
+ errorPaths = errorPaths.concat(result[fieldKey].errorPaths);
43
27
  }
44
28
  }
29
+ if (errorPaths.length) {
30
+ return 'Block validation failed: ' + errorPaths.join(', ');
31
+ }
45
32
  return true;
46
33
  };
47
- return blockValidation;
48
34
  };
49
35
 
50
36
  //# sourceMappingURL=validate.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/blocks/validate.ts"],"sourcesContent":["import type { Block } from 'payload/types'\n\nimport { sanitizeFields } from 'payload/config'\n\nimport type { NodeValidation } from '../types.js'\nimport type { BlocksFeatureProps } from './feature.server.js'\nimport type { SerializedBlockNode } from './nodes/BlocksNode.js'\n\nexport const blockValidationHOC = (\n props: BlocksFeatureProps,\n): NodeValidation<SerializedBlockNode> => {\n const blockValidation: NodeValidation<SerializedBlockNode> = async ({ node, validation }) => {\n const blockFieldData = node.fields\n const blocks: Block[] = props.blocks\n\n const {\n options: {\n req,\n req: {\n payload: { config },\n },\n },\n } = validation\n\n // Sanitize block's fields here. This is done here and not in the feature, because the payload config is available here\n const validRelationships = config.collections.map((c) => c.slug) || []\n blocks.forEach((block) => {\n block.fields = sanitizeFields({\n config,\n fields: block.fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })\n })\n\n // find block\n const block = props.blocks.find((block) => block.slug === blockFieldData.blockType)\n\n // validate block\n if (!block) {\n return 'Block not found'\n }\n\n for (const field of block.fields) {\n if ('validate' in field && typeof field.validate === 'function' && field.validate) {\n const fieldValue = 'name' in field ? node.fields[field.name] : null\n\n const passesCondition = field.admin?.condition\n ? Boolean(\n field.admin.condition(fieldValue, node.fields, {\n user: req?.user,\n }),\n )\n : true\n if (!passesCondition) {\n continue // Fixes https://github.com/payloadcms/payload/issues/4000\n }\n\n const validationResult = await field.validate(fieldValue, {\n ...field,\n id: validation.options.id,\n data: fieldValue,\n operation: validation.options.operation,\n req,\n siblingData: validation.options.siblingData,\n })\n\n if (validationResult !== true) {\n return validationResult\n }\n }\n }\n\n return true\n }\n\n return blockValidation\n}\n"],"names":["sanitizeFields","blockValidationHOC","props","blockValidation","node","validation","blockFieldData","fields","blocks","options","req","payload","config","validRelationships","collections","map","c","slug","forEach","block","requireFieldLevelRichTextEditor","find","blockType","field","validate","fieldValue","name","passesCondition","admin","condition","Boolean","user","validationResult","id","data","operation","siblingData"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAM/C,OAAO,MAAMC,qBAAqB,CAChCC;IAEA,MAAMC,kBAAuD,OAAO,EAAEC,IAAI,EAAEC,UAAU,EAAE;QACtF,MAAMC,iBAAiBF,KAAKG,MAAM;QAClC,MAAMC,SAAkBN,MAAMM,MAAM;QAEpC,MAAM,EACJC,SAAS,EACPC,GAAG,EACHA,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACpB,EACF,EACF,GAAGP;QAEJ,uHAAuH;QACvH,MAAMQ,qBAAqBD,OAAOE,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QACtET,OAAOU,OAAO,CAAC,CAACC;YACdA,MAAMZ,MAAM,GAAGP,eAAe;gBAC5BY;gBACAL,QAAQY,MAAMZ,MAAM;gBACpBa,iCAAiC;gBACjCP;YACF;QACF;QAEA,aAAa;QACb,MAAMM,QAAQjB,MAAMM,MAAM,CAACa,IAAI,CAAC,CAACF,QAAUA,MAAMF,IAAI,KAAKX,eAAegB,SAAS;QAElF,iBAAiB;QACjB,IAAI,CAACH,OAAO;YACV,OAAO;QACT;QAEA,KAAK,MAAMI,SAASJ,MAAMZ,MAAM,CAAE;YAChC,IAAI,cAAcgB,SAAS,OAAOA,MAAMC,QAAQ,KAAK,cAAcD,MAAMC,QAAQ,EAAE;gBACjF,MAAMC,aAAa,UAAUF,QAAQnB,KAAKG,MAAM,CAACgB,MAAMG,IAAI,CAAC,GAAG;gBAE/D,MAAMC,kBAAkBJ,MAAMK,KAAK,EAAEC,YACjCC,QACEP,MAAMK,KAAK,CAACC,SAAS,CAACJ,YAAYrB,KAAKG,MAAM,EAAE;oBAC7CwB,MAAMrB,KAAKqB;gBACb,MAEF;gBACJ,IAAI,CAACJ,iBAAiB;oBACpB,UAAS,0DAA0D;gBACrE;gBAEA,MAAMK,mBAAmB,MAAMT,MAAMC,QAAQ,CAACC,YAAY;oBACxD,GAAGF,KAAK;oBACRU,IAAI5B,WAAWI,OAAO,CAACwB,EAAE;oBACzBC,MAAMT;oBACNU,WAAW9B,WAAWI,OAAO,CAAC0B,SAAS;oBACvCzB;oBACA0B,aAAa/B,WAAWI,OAAO,CAAC2B,WAAW;gBAC7C;gBAEA,IAAIJ,qBAAqB,MAAM;oBAC7B,OAAOA;gBACT;YACF;QACF;QAEA,OAAO;IACT;IAEA,OAAO7B;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/blocks/validate.ts"],"sourcesContent":["import { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\n\nimport type { NodeValidation } from '../types.js'\nimport type { BlocksFeatureProps } from './feature.server.js'\nimport type { BlockFields, SerializedBlockNode } from './nodes/BlocksNode.js'\n\nexport const blockValidationHOC = (\n props: BlocksFeatureProps,\n): NodeValidation<SerializedBlockNode> => {\n return async ({ node, validation }) => {\n const blockFieldData = node.fields ?? ({} as BlockFields)\n\n const {\n options: { id, operation, preferences, req },\n } = validation\n\n // find block\n const block = props.blocks.find((block) => block.slug === blockFieldData.blockType)\n\n // validate block\n if (!block) {\n return 'Block not found'\n }\n\n /**\n * Run buildStateFromSchema as that properly validates block and block sub-fields\n */\n\n const result = await buildStateFromSchema({\n id,\n data: blockFieldData,\n fieldSchema: block.fields,\n operation: operation === 'create' || operation === 'update' ? operation : 'update',\n preferences,\n req,\n siblingData: blockFieldData,\n })\n\n let errorPaths = []\n for (const fieldKey in result) {\n if (result[fieldKey].errorPaths) {\n errorPaths = errorPaths.concat(result[fieldKey].errorPaths)\n }\n }\n\n if (errorPaths.length) {\n return 'Block validation failed: ' + errorPaths.join(', ')\n }\n\n return true\n }\n}\n"],"names":["buildStateFromSchema","blockValidationHOC","props","node","validation","blockFieldData","fields","options","id","operation","preferences","req","block","blocks","find","slug","blockType","result","data","fieldSchema","siblingData","errorPaths","fieldKey","concat","length","join"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,oBAAoB,QAAQ,4CAA2C;AAMhF,OAAO,MAAMC,qBAAqB,CAChCC;IAEA,OAAO,OAAO,EAAEC,IAAI,EAAEC,UAAU,EAAE;QAChC,MAAMC,iBAAiBF,KAAKG,MAAM,IAAK,CAAC;QAExC,MAAM,EACJC,SAAS,EAAEC,EAAE,EAAEC,SAAS,EAAEC,WAAW,EAAEC,GAAG,EAAE,EAC7C,GAAGP;QAEJ,aAAa;QACb,MAAMQ,QAAQV,MAAMW,MAAM,CAACC,IAAI,CAAC,CAACF,QAAUA,MAAMG,IAAI,KAAKV,eAAeW,SAAS;QAElF,iBAAiB;QACjB,IAAI,CAACJ,OAAO;YACV,OAAO;QACT;QAEA;;KAEC,GAED,MAAMK,SAAS,MAAMjB,qBAAqB;YACxCQ;YACAU,MAAMb;YACNc,aAAaP,MAAMN,MAAM;YACzBG,WAAWA,cAAc,YAAYA,cAAc,WAAWA,YAAY;YAC1EC;YACAC;YACAS,aAAaf;QACf;QAEA,IAAIgB,aAAa,EAAE;QACnB,IAAK,MAAMC,YAAYL,OAAQ;YAC7B,IAAIA,MAAM,CAACK,SAAS,CAACD,UAAU,EAAE;gBAC/BA,aAAaA,WAAWE,MAAM,CAACN,MAAM,CAACK,SAAS,CAACD,UAAU;YAC5D;QACF;QAEA,IAAIA,WAAWG,MAAM,EAAE;YACrB,OAAO,8BAA8BH,WAAWI,IAAI,CAAC;QACvD;QAEA,OAAO;IACT;AACF,EAAC"}