@payloadcms/richtext-lexical 4.0.0-internal.1f9ae9a → 4.0.0-internal.293e026

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 (338) hide show
  1. package/dist/@types/assets.d.js +2 -0
  2. package/dist/@types/assets.d.js.map +1 -0
  3. package/dist/cell/rscEntry.d.ts.map +1 -1
  4. package/dist/cell/rscEntry.js +5 -5
  5. package/dist/cell/rscEntry.js.map +1 -1
  6. package/dist/exports/client/Field-VYBSMSRY.js +2 -0
  7. package/dist/exports/client/Field-VYBSMSRY.js.map +7 -0
  8. package/dist/exports/client/{RelationshipComponent-RZL743CS.js → RelationshipComponent-YCPAKOL7.js} +1 -1
  9. package/dist/exports/client/RelationshipComponent-YCPAKOL7.js.map +7 -0
  10. package/dist/exports/client/bundled.css +1 -1
  11. package/dist/exports/client/chunk-5VIL27GI.js +2 -0
  12. package/dist/exports/client/chunk-5VIL27GI.js.map +7 -0
  13. package/dist/exports/client/chunk-ESITTE3C.js +2 -0
  14. package/dist/exports/client/chunk-ESITTE3C.js.map +7 -0
  15. package/dist/exports/client/chunk-UD4DQ4AK.js +2 -0
  16. package/dist/exports/client/chunk-UD4DQ4AK.js.map +7 -0
  17. package/dist/exports/client/{component-CVM4OESA.js → component-PHZQBOJE.js} +2 -2
  18. package/dist/exports/client/component-PHZQBOJE.js.map +7 -0
  19. package/dist/exports/client/componentInline-H24N7GUG.js +2 -0
  20. package/dist/exports/client/index.d.ts +1 -0
  21. package/dist/exports/client/index.d.ts.map +1 -1
  22. package/dist/exports/client/index.js +25 -25
  23. package/dist/exports/client/index.js.map +4 -4
  24. package/dist/exports/server/rsc.browser.d.ts +11 -0
  25. package/dist/exports/server/rsc.browser.d.ts.map +1 -0
  26. package/dist/exports/server/rsc.browser.js +10 -0
  27. package/dist/exports/server/rsc.browser.js.map +1 -0
  28. package/dist/features/blockquote/server/index.d.ts +1 -4
  29. package/dist/features/blockquote/server/index.d.ts.map +1 -1
  30. package/dist/features/blockquote/server/index.js +2 -0
  31. package/dist/features/blockquote/server/index.js.map +1 -1
  32. package/dist/features/blockquote/server/schema.d.ts +8 -0
  33. package/dist/features/blockquote/server/schema.d.ts.map +1 -0
  34. package/dist/features/blockquote/server/schema.js +15 -0
  35. package/dist/features/blockquote/server/schema.js.map +1 -0
  36. package/dist/features/blocks/client/component/index.d.ts +2 -1
  37. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  38. package/dist/features/blocks/client/component/index.js +16 -8
  39. package/dist/features/blocks/client/component/index.js.map +1 -1
  40. package/dist/features/blocks/client/componentInline/index.d.ts +2 -1
  41. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  42. package/dist/features/blocks/client/componentInline/index.js +15 -7
  43. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  44. package/dist/features/blocks/client/index.d.ts.map +1 -1
  45. package/dist/features/blocks/client/index.js +4 -2
  46. package/dist/features/blocks/client/index.js.map +1 -1
  47. package/dist/features/blocks/client/markdown/markdownTransformer.js +4 -4
  48. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
  49. package/dist/features/blocks/client/nodes/BlocksNode.d.ts +1 -1
  50. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  51. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  52. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +1 -1
  53. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
  54. package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
  55. package/dist/features/blocks/client/plugin/index.d.ts +1 -1
  56. package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
  57. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  58. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -1
  59. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +1 -0
  60. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  61. package/dist/features/blocks/server/graphQLPopulationPromise.d.ts +1 -2
  62. package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
  63. package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
  64. package/dist/features/blocks/server/index.d.ts +1 -0
  65. package/dist/features/blocks/server/index.d.ts.map +1 -1
  66. package/dist/features/blocks/server/index.js +24 -72
  67. package/dist/features/blocks/server/index.js.map +1 -1
  68. package/dist/features/blocks/server/markdown/markdownTransformer.js +4 -4
  69. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
  70. package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -18
  71. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  72. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  73. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +2 -10
  74. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
  75. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  76. package/dist/features/blocks/server/schema.d.ts +45 -0
  77. package/dist/features/blocks/server/schema.d.ts.map +1 -0
  78. package/dist/features/blocks/server/schema.js +139 -0
  79. package/dist/features/blocks/server/schema.js.map +1 -0
  80. package/dist/features/blocks/server/validate.d.ts +1 -2
  81. package/dist/features/blocks/server/validate.d.ts.map +1 -1
  82. package/dist/features/blocks/server/validate.js.map +1 -1
  83. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  84. package/dist/features/converters/lexicalToHtml/async/types.d.ts +14 -15
  85. package/dist/features/converters/lexicalToHtml/async/types.d.ts.map +1 -1
  86. package/dist/features/converters/lexicalToHtml/async/types.js.map +1 -1
  87. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  88. package/dist/features/converters/lexicalToHtml/sync/types.d.ts +14 -15
  89. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  90. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  91. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +4 -2
  92. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  93. package/dist/features/converters/lexicalToJSX/Component/index.js +5 -4
  94. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  95. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  96. package/dist/features/converters/lexicalToJSX/converter/types.d.ts +12 -14
  97. package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
  98. package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
  99. package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts +12 -14
  100. package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts.map +1 -1
  101. package/dist/features/converters/lexicalToPlaintext/sync/types.js.map +1 -1
  102. package/dist/features/experimental_table/server/index.d.ts +1 -6
  103. package/dist/features/experimental_table/server/index.d.ts.map +1 -1
  104. package/dist/features/experimental_table/server/index.js +4 -0
  105. package/dist/features/experimental_table/server/index.js.map +1 -1
  106. package/dist/features/experimental_table/server/schema.d.ts +27 -0
  107. package/dist/features/experimental_table/server/schema.d.ts.map +1 -0
  108. package/dist/features/experimental_table/server/schema.js +107 -0
  109. package/dist/features/experimental_table/server/schema.js.map +1 -0
  110. package/dist/features/heading/server/index.d.ts +2 -4
  111. package/dist/features/heading/server/index.d.ts.map +1 -1
  112. package/dist/features/heading/server/index.js +2 -0
  113. package/dist/features/heading/server/index.js.map +1 -1
  114. package/dist/features/heading/server/schema.d.ts +10 -0
  115. package/dist/features/heading/server/schema.d.ts.map +1 -0
  116. package/dist/features/heading/server/schema.js +37 -0
  117. package/dist/features/heading/server/schema.js.map +1 -0
  118. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +1 -1
  119. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  120. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  121. package/dist/features/horizontalRule/server/index.d.ts +1 -0
  122. package/dist/features/horizontalRule/server/index.d.ts.map +1 -1
  123. package/dist/features/horizontalRule/server/index.js +2 -0
  124. package/dist/features/horizontalRule/server/index.js.map +1 -1
  125. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +1 -5
  126. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
  127. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  128. package/dist/features/horizontalRule/server/schema.d.ts +7 -0
  129. package/dist/features/horizontalRule/server/schema.d.ts.map +1 -0
  130. package/dist/features/horizontalRule/server/schema.js +25 -0
  131. package/dist/features/horizontalRule/server/schema.js.map +1 -0
  132. package/dist/features/link/client/index.d.ts.map +1 -1
  133. package/dist/features/link/client/index.js.map +1 -1
  134. package/dist/features/link/client/plugins/autoLink/index.d.ts +1 -1
  135. package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
  136. package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
  137. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  138. package/dist/features/link/client/plugins/floatingLinkEditor/types.d.ts +1 -1
  139. package/dist/features/link/client/plugins/floatingLinkEditor/types.d.ts.map +1 -1
  140. package/dist/features/link/client/plugins/floatingLinkEditor/types.js.map +1 -1
  141. package/dist/features/link/client/plugins/link/index.js.map +1 -1
  142. package/dist/features/link/markdownTransformer.d.ts +1 -1
  143. package/dist/features/link/markdownTransformer.d.ts.map +1 -1
  144. package/dist/features/link/markdownTransformer.js.map +1 -1
  145. package/dist/features/link/markdownTransformer.spec.js.map +1 -1
  146. package/dist/features/link/nodes/AutoLinkNode.d.ts +3 -3
  147. package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  148. package/dist/features/link/nodes/AutoLinkNode.js +2 -1
  149. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  150. package/dist/features/link/nodes/LinkNode.d.ts +3 -3
  151. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  152. package/dist/features/link/nodes/LinkNode.js +2 -1
  153. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  154. package/dist/features/link/server/baseFields.js.map +1 -1
  155. package/dist/features/link/server/graphQLPopulationPromise.d.ts +1 -1
  156. package/dist/features/link/server/graphQLPopulationPromise.d.ts.map +1 -1
  157. package/dist/features/link/server/graphQLPopulationPromise.js.map +1 -1
  158. package/dist/features/link/server/index.d.ts +2 -1
  159. package/dist/features/link/server/index.d.ts.map +1 -1
  160. package/dist/features/link/server/index.js +3 -0
  161. package/dist/features/link/server/index.js.map +1 -1
  162. package/dist/features/link/server/schema.d.ts +32 -0
  163. package/dist/features/link/server/schema.d.ts.map +1 -0
  164. package/dist/features/link/server/schema.js +169 -0
  165. package/dist/features/link/server/schema.js.map +1 -0
  166. package/dist/features/link/server/validate.d.ts +1 -1
  167. package/dist/features/link/server/validate.d.ts.map +1 -1
  168. package/dist/features/link/server/validate.js.map +1 -1
  169. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  170. package/dist/features/lists/checklist/server/index.js +3 -0
  171. package/dist/features/lists/checklist/server/index.js.map +1 -1
  172. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  173. package/dist/features/lists/orderedList/server/index.js +3 -0
  174. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  175. package/dist/features/lists/plugin/index.d.ts +0 -9
  176. package/dist/features/lists/plugin/index.d.ts.map +1 -1
  177. package/dist/features/lists/plugin/index.js.map +1 -1
  178. package/dist/features/lists/shared/schema.d.ts +18 -0
  179. package/dist/features/lists/shared/schema.d.ts.map +1 -0
  180. package/dist/features/lists/shared/schema.js +62 -0
  181. package/dist/features/lists/shared/schema.js.map +1 -0
  182. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  183. package/dist/features/lists/unorderedList/server/index.js +3 -0
  184. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  185. package/dist/features/relationship/client/components/RelationshipComponent.d.ts +1 -1
  186. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  187. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  188. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
  189. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  190. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  191. package/dist/features/relationship/client/plugins/index.d.ts +1 -1
  192. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  193. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  194. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  195. package/dist/features/relationship/client/utils/useEnabledRelationships.js +9 -40
  196. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  197. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +1 -1
  198. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  199. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  200. package/dist/features/relationship/server/index.d.ts +1 -0
  201. package/dist/features/relationship/server/index.d.ts.map +1 -1
  202. package/dist/features/relationship/server/index.js +2 -0
  203. package/dist/features/relationship/server/index.js.map +1 -1
  204. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -10
  205. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  206. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  207. package/dist/features/relationship/server/schema.d.ts +28 -0
  208. package/dist/features/relationship/server/schema.d.ts.map +1 -0
  209. package/dist/features/relationship/server/schema.js +80 -0
  210. package/dist/features/relationship/server/schema.js.map +1 -0
  211. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +23 -0
  212. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -0
  213. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +34 -0
  214. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -0
  215. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  216. package/dist/features/typesServer.d.ts +17 -40
  217. package/dist/features/typesServer.d.ts.map +1 -1
  218. package/dist/features/typesServer.js.map +1 -1
  219. package/dist/features/upload/client/component/index.css +2 -2
  220. package/dist/features/upload/client/component/index.d.ts +1 -1
  221. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  222. package/dist/features/upload/client/component/index.js.map +1 -1
  223. package/dist/features/upload/client/nodes/UploadNode.d.ts +1 -1
  224. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  225. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  226. package/dist/features/upload/client/plugin/index.d.ts +1 -1
  227. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  228. package/dist/features/upload/client/plugin/index.js.map +1 -1
  229. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +1 -1
  230. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  231. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  232. package/dist/features/upload/server/index.d.ts +1 -0
  233. package/dist/features/upload/server/index.d.ts.map +1 -1
  234. package/dist/features/upload/server/index.js +3 -2
  235. package/dist/features/upload/server/index.js.map +1 -1
  236. package/dist/features/upload/server/nodes/UploadNode.d.ts +1 -55
  237. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  238. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  239. package/dist/features/upload/server/nodes/conversions.d.ts.map +1 -1
  240. package/dist/features/upload/server/nodes/conversions.js.map +1 -1
  241. package/dist/features/upload/server/schema.d.ts +52 -0
  242. package/dist/features/upload/server/schema.d.ts.map +1 -0
  243. package/dist/features/upload/server/schema.js +129 -0
  244. package/dist/features/upload/server/schema.js.map +1 -0
  245. package/dist/features/upload/server/validate.d.ts +1 -1
  246. package/dist/features/upload/server/validate.d.ts.map +1 -1
  247. package/dist/features/upload/server/validate.js.map +1 -1
  248. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  249. package/dist/field/bundled.css +1 -1
  250. package/dist/field/clientEntry.d.ts +29 -0
  251. package/dist/field/clientEntry.d.ts.map +1 -0
  252. package/dist/field/clientEntry.js +86 -0
  253. package/dist/field/clientEntry.js.map +1 -0
  254. package/dist/field/index.css +9 -12
  255. package/dist/field/index.js +1 -1
  256. package/dist/field/index.js.map +1 -1
  257. package/dist/field/rscEntry.d.ts.map +1 -1
  258. package/dist/field/rscEntry.js +2 -0
  259. package/dist/field/rscEntry.js.map +1 -1
  260. package/dist/index.d.ts +8 -5
  261. package/dist/index.d.ts.map +1 -1
  262. package/dist/index.js +47 -4
  263. package/dist/index.js.map +1 -1
  264. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  265. package/dist/lexical/LexicalEditor.js +36 -2
  266. package/dist/lexical/LexicalEditor.js.map +1 -1
  267. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  268. package/dist/lexical/LexicalProvider.js +22 -7
  269. package/dist/lexical/LexicalProvider.js.map +1 -1
  270. package/dist/lexical/config/client/loader.d.ts.map +1 -1
  271. package/dist/lexical/config/client/loader.js +5 -1
  272. package/dist/lexical/config/client/loader.js.map +1 -1
  273. package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
  274. package/dist/lexical/config/server/sanitize.js +9 -11
  275. package/dist/lexical/config/server/sanitize.js.map +1 -1
  276. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  277. package/dist/types/builtInNodes.d.ts +14 -0
  278. package/dist/types/builtInNodes.d.ts.map +1 -0
  279. package/dist/types/builtInNodes.js +203 -0
  280. package/dist/types/builtInNodes.js.map +1 -0
  281. package/dist/types/index.d.ts +16 -17
  282. package/dist/types/index.d.ts.map +1 -1
  283. package/dist/types/index.js.map +1 -1
  284. package/dist/types/jsonSchemaHelpers.d.ts +30 -0
  285. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -0
  286. package/dist/types/jsonSchemaHelpers.js +58 -0
  287. package/dist/types/jsonSchemaHelpers.js.map +1 -0
  288. package/dist/types/nodeTypes.d.ts +115 -61
  289. package/dist/types/nodeTypes.d.ts.map +1 -1
  290. package/dist/types/nodeTypes.js +3 -2
  291. package/dist/types/nodeTypes.js.map +1 -1
  292. package/dist/types/schema.d.ts.map +1 -1
  293. package/dist/types/schema.js +67 -65
  294. package/dist/types/schema.js.map +1 -1
  295. package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
  296. package/dist/utilities/applyBaseFilterToFields.js +1 -2
  297. package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
  298. package/dist/utilities/buildEditorState.d.ts +17 -3
  299. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  300. package/dist/utilities/buildEditorState.js +8 -0
  301. package/dist/utilities/buildEditorState.js.map +1 -1
  302. package/dist/utilities/buildInitialState.d.ts +2 -1
  303. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  304. package/dist/utilities/buildInitialState.js.map +1 -1
  305. package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
  306. package/dist/utilities/fieldsDrawer/Drawer.js +19 -10
  307. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  308. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts +4 -1
  309. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  310. package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -7
  311. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  312. package/dist/utilities/fieldsDrawer/index.css +12 -0
  313. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts +29 -0
  314. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts.map +1 -0
  315. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js +97 -0
  316. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -0
  317. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  318. package/dist/utilities/generateImportMap.js +7 -3
  319. package/dist/utilities/generateImportMap.js.map +1 -1
  320. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +1 -1
  321. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
  322. package/package.json +8 -7
  323. package/dist/exports/client/Field-G5Z2HM5Y.js +0 -2
  324. package/dist/exports/client/Field-G5Z2HM5Y.js.map +0 -7
  325. package/dist/exports/client/RelationshipComponent-RZL743CS.js.map +0 -7
  326. package/dist/exports/client/chunk-6QWQ7JV4.js +0 -2
  327. package/dist/exports/client/chunk-6QWQ7JV4.js.map +0 -7
  328. package/dist/exports/client/chunk-FEJXFRL7.js +0 -2
  329. package/dist/exports/client/chunk-FEJXFRL7.js.map +0 -7
  330. package/dist/exports/client/chunk-INBEEENE.js +0 -2
  331. package/dist/exports/client/chunk-INBEEENE.js.map +0 -7
  332. package/dist/exports/client/component-CVM4OESA.js.map +0 -7
  333. package/dist/exports/client/componentInline-JJZ2NKW2.js +0 -2
  334. package/dist/features/link/nodes/types.d.ts +0 -27
  335. package/dist/features/link/nodes/types.d.ts.map +0 -1
  336. package/dist/features/link/nodes/types.js +0 -2
  337. package/dist/features/link/nodes/types.js.map +0 -1
  338. /package/dist/exports/client/{componentInline-JJZ2NKW2.js.map → componentInline-H24N7GUG.js.map} +0 -0
@@ -1,5 +1,6 @@
1
1
  import type { Field, UploadCollectionSlug } from 'payload';
2
2
  import type { UploadFeaturePropsClient } from '../client/index.js';
3
+ export type { Internal_UploadData, SerializedUploadNode, UploadData, UploadDataImproved, } from './schema.js';
3
4
  export type ExclusiveUploadFeatureProps = {
4
5
  /**
5
6
  * The collections that should be disabled. Overrides the `enableRichTextRelationship` property in the collection config.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/upload/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,KAAK,EAAkB,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAIlF,OAAO,KAAK,EA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C,MAAM,EAAE,KAAK,EAAE,CAAA;SAChB,CAAA;KACF,CAAA;IACD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,2BAA2B,CAAA;AAE/B,eAAO,MAAM,aAAa,gIA0JxB,CAAA"}
@@ -6,6 +6,7 @@ import { uploadPopulationPromiseHOC } from './graphQLPopulationPromise.js';
6
6
  import { i18n } from './i18n.js';
7
7
  import { UploadMarkdownTransformer } from './markdownTransformer.js';
8
8
  import { UploadServerNode } from './nodes/UploadNode.js';
9
+ import { createUploadNodeJSONSchema } from './schema.js';
9
10
  import { uploadValidation } from './validate.js';
10
11
  export const UploadFeature = createServerFeature({
11
12
  feature: async ({
@@ -120,8 +121,7 @@ export const UploadFeature = createServerFeature({
120
121
  if (!collection) {
121
122
  return node;
122
123
  }
123
- // @ts-expect-error - Fix in Payload v4
124
- const id = node?.value?.id || node?.value // for backwards-compatibility
124
+ const id = typeof node?.value === 'object' && node.value !== null && 'id' in node.value ? node.value.id : node?.value // for backwards-compatibility
125
125
  ;
126
126
  const populateDepth = props?.maxDepth !== undefined && props?.maxDepth < depth ? props?.maxDepth : depth;
127
127
  populationPromises.push(populate({
@@ -140,6 +140,7 @@ export const UploadFeature = createServerFeature({
140
140
  return node;
141
141
  }]
142
142
  },
143
+ jsonSchema: createUploadNodeJSONSchema(props),
143
144
  node: UploadServerNode,
144
145
  validations: [uploadValidation(props)]
145
146
  })],
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["sanitizeFields","populate","createServerFeature","createNode","uploadPopulationPromiseHOC","i18n","UploadMarkdownTransformer","UploadServerNode","uploadValidation","UploadFeature","feature","config","_config","isRoot","parentIsLocalized","props","collections","clientProps","disabledCollections","enabledCollections","collection","hasExtraFields","fields","length","validRelationships","map","c","slug","collectionKey","requireFieldLevelRichTextEditor","ClientFeature","clientFeatureProps","generateSchemaMap","schemaMap","Map","set","markdownTransformers","nodes","getSubFields","node","req","allSubFields","collectionFields","concat","payload","relationTo","collectionFieldSchema","Array","isArray","getSubFieldsData","graphQLPopulationPromises","hooks","afterRead","currentDepth","depth","draft","overrideAccess","populateArg","populationPromises","showHiddenFields","value","id","populateDepth","maxDepth","undefined","push","collectionSlug","data","key","select","defaultPopulate","validations","sanitizedServerFeatureProps"],"sources":["../../../../src/features/upload/server/index.ts"],"sourcesContent":["import type { Config, Field, FieldSchemaMap, UploadCollectionSlug } from 'payload'\n\nimport { sanitizeFields } from 'payload'\n\nimport type { UploadFeaturePropsClient } from '../client/index.js'\n\nimport { populate } from '../../../populateGraphQL/populate.js'\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { uploadPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { UploadMarkdownTransformer } from './markdownTransformer.js'\nimport { UploadServerNode } from './nodes/UploadNode.js'\nimport { uploadValidation } from './validate.js'\n\nexport type ExclusiveUploadFeatureProps =\n | {\n /**\n * The collections that should be disabled. Overrides the `enableRichTextRelationship` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: UploadCollectionSlug[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled. Overrides the `enableRichTextRelationship` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: UploadCollectionSlug[]\n }\n\nexport type UploadFeatureProps = {\n collections?: {\n [collection: UploadCollectionSlug]: {\n fields: Field[]\n }\n }\n /**\n * Sets a maximum population depth for this upload (not the fields for this upload), regardless of the remaining depth when the respective field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n} & ExclusiveUploadFeatureProps\n\nexport const UploadFeature = createServerFeature<\n UploadFeatureProps,\n UploadFeatureProps,\n UploadFeaturePropsClient\n>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = {\n collections: {},\n }\n if (props.disabledCollections) {\n clientProps.disabledCollections = props.disabledCollections\n }\n if (props.enabledCollections) {\n clientProps.enabledCollections = props.enabledCollections\n }\n\n if (props.collections) {\n for (const collection in props.collections) {\n clientProps.collections[collection] = {\n hasExtraFields: props.collections[collection]!.fields.length >= 1,\n }\n }\n }\n\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n for (const collectionKey in props.collections) {\n const collection = props.collections[collectionKey]!\n if (collection.fields?.length) {\n collection.fields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: collection.fields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n }\n }\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#UploadFeatureClient',\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ props }) => {\n if (!props?.collections) {\n return null\n }\n\n const schemaMap: FieldSchemaMap = new Map()\n\n for (const collectionKey in props.collections) {\n const collection = props.collections[collectionKey]!\n if (collection.fields?.length) {\n schemaMap.set(collectionKey, {\n fields: collection.fields,\n })\n }\n }\n\n return schemaMap\n },\n i18n,\n markdownTransformers: [UploadMarkdownTransformer],\n nodes: [\n createNode({\n getSubFields: ({ node, req }) => {\n if (!node) {\n let allSubFields: Field[] = []\n for (const collection in props?.collections) {\n const collectionFields = props.collections[collection]!.fields\n allSubFields = allSubFields.concat(collectionFields)\n }\n return allSubFields\n }\n const collection = req ? req.payload.collections[node?.relationTo] : null\n\n if (collection) {\n const collectionFieldSchema = props?.collections?.[node?.relationTo]?.fields\n\n if (Array.isArray(collectionFieldSchema)) {\n if (!collectionFieldSchema?.length) {\n return null\n }\n return collectionFieldSchema\n }\n }\n return null\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [uploadPopulationPromiseHOC(props)],\n hooks: {\n afterRead: [\n ({\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n }) => {\n if (!node?.value) {\n return node\n }\n const collection = req.payload.collections[node?.relationTo]\n\n if (!collection) {\n return node\n }\n // @ts-expect-error - Fix in Payload v4\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n const populateDepth =\n props?.maxDepth !== undefined && props?.maxDepth < depth ? props?.maxDepth : depth\n\n populationPromises.push(\n populate({\n id,\n collectionSlug: collection.config.slug,\n currentDepth,\n data: node,\n depth: populateDepth,\n draft,\n key: 'value',\n overrideAccess,\n req,\n select:\n populateArg?.[collection.config.slug] ?? collection.config.defaultPopulate,\n showHiddenFields,\n }),\n )\n\n return node\n },\n ],\n },\n node: UploadServerNode,\n validations: [uploadValidation(props)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'upload',\n})\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAI/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,mBAAmB,QAAQ;AACpC,SAASC,UAAU,QAAQ;AAC3B,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,IAAI,QAAQ;AACrB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,QAAQ;AAuCjC,OAAO,MAAMC,aAAA,GAAgBP,mBAAA,CAI3B;EACAQ,OAAA,EAAS,MAAAA,CAAO;IAAEC,MAAA,EAAQC,OAAO;IAAEC,MAAM;IAAEC,iBAAiB;IAAEC;EAAK,CAAE;IACnE,IAAI,CAACA,KAAA,EAAO;MACVA,KAAA,GAAQ;QAAEC,WAAA,EAAa,CAAC;MAAE;IAC5B;IAEA,MAAMC,WAAA,GAAwC;MAC5CD,WAAA,EAAa,CAAC;IAChB;IACA,IAAID,KAAA,CAAMG,mBAAmB,EAAE;MAC7BD,WAAA,CAAYC,mBAAmB,GAAGH,KAAA,CAAMG,mBAAmB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WAAW;YACXC,kBAAkB;YAClBlB,GAAG;YACHmB;UAAgB,CACjB;YACC,IAAI,CAACpB,IAAA,EAAMqB,KAAA,EAAO;cAChB,OAAOrB,IAAA;YACT;YACA,MAAMnB,UAAA,GAAaoB,GAAA,CAAII,OAAO,CAAC5B,WAAW,CAACuB,IAAA,EAAMM,UAAA,CAAW;YAE5D,IAAI,CAACzB,UAAA,EAAY;cACf,OAAOmB,IAAA;YACT;YACA;YACA,MAAMsB,EAAA,GAAKtB,IAAA,EAAMqB,KAAA,EAAOC,EAAA,IAAMtB,IAAA,EAAMqB,KAAA,CAAM;AAAA;YAE1C,MAAME,aAAA,GACJ/C,KAAA,EAAOgD,QAAA,KAAaC,SAAA,IAAajD,KAAA,EAAOgD,QAAA,GAAWT,KAAA,GAAQvC,KAAA,EAAOgD,QAAA,GAAWT,KAAA;YAE/EI,kBAAA,CAAmBO,IAAI,CACrBhE,QAAA,CAAS;cACP4D,EAAA;cACAK,cAAA,EAAgB9C,UAAA,CAAWT,MAAM,CAACgB,IAAI;cACtC0B,YAAA;cACAc,IAAA,EAAM5B,IAAA;cACNe,KAAA,EAAOQ,aAAA;cACPP,KAAA;cACAa,GAAA,EAAK;cACLZ,cAAA;cACAhB,GAAA;cACA6B,MAAA,EACEZ,WAAA,GAAcrC,UAAA,CAAWT,MAAM,CAACgB,IAAI,CAAC,IAAIP,UAAA,CAAWT,MAAM,CAAC2D,eAAe;cAC5EX;YACF;YAGF,OAAOpB,IAAA;UACT;QAEJ;QACAA,IAAA,EAAMhC,gBAAA;QACNgE,WAAA,EAAa,CAAC/D,gBAAA,CAAiBO,KAAA;MACjC,GACD;MACDyD,2BAAA,EAA6BzD;IAC/B;EACF;EACAqD,GAAA,EAAK;AACP","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["sanitizeFields","populate","createServerFeature","createNode","uploadPopulationPromiseHOC","i18n","UploadMarkdownTransformer","UploadServerNode","createUploadNodeJSONSchema","uploadValidation","UploadFeature","feature","config","_config","isRoot","parentIsLocalized","props","collections","clientProps","disabledCollections","enabledCollections","collection","hasExtraFields","fields","length","validRelationships","map","c","slug","collectionKey","requireFieldLevelRichTextEditor","ClientFeature","clientFeatureProps","generateSchemaMap","schemaMap","Map","set","markdownTransformers","nodes","getSubFields","node","req","allSubFields","collectionFields","concat","payload","relationTo","collectionFieldSchema","Array","isArray","getSubFieldsData","graphQLPopulationPromises","hooks","afterRead","currentDepth","depth","draft","overrideAccess","populateArg","populationPromises","showHiddenFields","value","id","populateDepth","maxDepth","undefined","push","collectionSlug","data","key","select","defaultPopulate","jsonSchema","validations","sanitizedServerFeatureProps"],"sources":["../../../../src/features/upload/server/index.ts"],"sourcesContent":["import type { Config, Field, FieldSchemaMap, UploadCollectionSlug } from 'payload'\n\nimport { sanitizeFields } from 'payload'\n\nimport type { UploadFeaturePropsClient } from '../client/index.js'\n\nimport { populate } from '../../../populateGraphQL/populate.js'\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { uploadPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { UploadMarkdownTransformer } from './markdownTransformer.js'\nimport { UploadServerNode } from './nodes/UploadNode.js'\nimport { createUploadNodeJSONSchema } from './schema.js'\nimport { uploadValidation } from './validate.js'\n\nexport type {\n Internal_UploadData,\n SerializedUploadNode,\n UploadData,\n UploadDataImproved,\n} from './schema.js'\n\nexport type ExclusiveUploadFeatureProps =\n | {\n /**\n * The collections that should be disabled. Overrides the `enableRichTextRelationship` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: UploadCollectionSlug[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled. Overrides the `enableRichTextRelationship` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: UploadCollectionSlug[]\n }\n\nexport type UploadFeatureProps = {\n collections?: {\n [collection: UploadCollectionSlug]: {\n fields: Field[]\n }\n }\n /**\n * Sets a maximum population depth for this upload (not the fields for this upload), regardless of the remaining depth when the respective field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n} & ExclusiveUploadFeatureProps\n\nexport const UploadFeature = createServerFeature<\n UploadFeatureProps,\n UploadFeatureProps,\n UploadFeaturePropsClient\n>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = {\n collections: {},\n }\n if (props.disabledCollections) {\n clientProps.disabledCollections = props.disabledCollections\n }\n if (props.enabledCollections) {\n clientProps.enabledCollections = props.enabledCollections\n }\n\n if (props.collections) {\n for (const collection in props.collections) {\n clientProps.collections[collection] = {\n hasExtraFields: props.collections[collection]!.fields.length >= 1,\n }\n }\n }\n\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n for (const collectionKey in props.collections) {\n const collection = props.collections[collectionKey]!\n if (collection.fields?.length) {\n collection.fields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: collection.fields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n }\n }\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#UploadFeatureClient',\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ props }) => {\n if (!props?.collections) {\n return null\n }\n\n const schemaMap: FieldSchemaMap = new Map()\n\n for (const collectionKey in props.collections) {\n const collection = props.collections[collectionKey]!\n if (collection.fields?.length) {\n schemaMap.set(collectionKey, {\n fields: collection.fields,\n })\n }\n }\n\n return schemaMap\n },\n i18n,\n markdownTransformers: [UploadMarkdownTransformer],\n nodes: [\n createNode({\n getSubFields: ({ node, req }) => {\n if (!node) {\n let allSubFields: Field[] = []\n for (const collection in props?.collections) {\n const collectionFields = props.collections[collection]!.fields\n allSubFields = allSubFields.concat(collectionFields)\n }\n return allSubFields\n }\n const collection = req ? req.payload.collections[node?.relationTo] : null\n\n if (collection) {\n const collectionFieldSchema = props?.collections?.[node?.relationTo]?.fields\n\n if (Array.isArray(collectionFieldSchema)) {\n if (!collectionFieldSchema?.length) {\n return null\n }\n return collectionFieldSchema\n }\n }\n return null\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [uploadPopulationPromiseHOC(props)],\n hooks: {\n afterRead: [\n ({\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n populateArg,\n populationPromises,\n req,\n showHiddenFields,\n }) => {\n if (!node?.value) {\n return node\n }\n const collection = req.payload.collections[node?.relationTo]\n\n if (!collection) {\n return node\n }\n const id =\n typeof node?.value === 'object' && node.value !== null && 'id' in node.value\n ? node.value.id\n : node?.value // for backwards-compatibility\n\n const populateDepth =\n props?.maxDepth !== undefined && props?.maxDepth < depth ? props?.maxDepth : depth\n\n populationPromises.push(\n populate({\n id,\n collectionSlug: collection.config.slug,\n currentDepth,\n data: node,\n depth: populateDepth,\n draft,\n key: 'value',\n overrideAccess,\n req,\n select:\n populateArg?.[collection.config.slug] ?? collection.config.defaultPopulate,\n showHiddenFields,\n }),\n )\n\n return node\n },\n ],\n },\n jsonSchema: createUploadNodeJSONSchema(props),\n node: UploadServerNode,\n validations: [uploadValidation(props)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'upload',\n})\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAI/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,mBAAmB,QAAQ;AACpC,SAASC,UAAU,QAAQ;AAC3B,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,IAAI,QAAQ;AACrB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,gBAAgB,QAAQ;AACjC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,gBAAgB,QAAQ;AA8CjC,OAAO,MA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cAAA;cACAhB,GAAA;cACA6B,MAAA,EACEZ,WAAA,GAAcrC,UAAA,CAAWT,MAAM,CAACgB,IAAI,CAAC,IAAIP,UAAA,CAAWT,MAAM,CAAC2D,eAAe;cAC5EX;YACF;YAGF,OAAOpB,IAAA;UACT;QAEJ;QACAgC,UAAA,EAAYhE,0BAAA,CAA2BQ,KAAA;QACvCwB,IAAA,EAAMjC,gBAAA;QACNkE,WAAA,EAAa,CAAChE,gBAAA,CAAiBO,KAAA;MACjC,GACD;MACD0D,2BAAA,EAA6B1D;IAC/B;EACF;EACAqD,GAAA,EAAK;AACP","ignoreList":[]}
@@ -1,61 +1,7 @@
1
- import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
2
1
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalNode, NodeKey } from 'lexical';
3
- import type { CollectionSlug, DataFromCollectionSlug, JsonObject, TypedUploadCollection, UploadCollectionSlug } from 'payload';
4
2
  import type { JSX } from 'react';
5
3
  import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
6
- import type { StronglyTypedLeafNode } from '../../../../types/nodeTypes.js';
7
- export type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {
8
- [TCollectionSlug in CollectionSlug]: {
9
- fields: TUploadExtraFieldsData;
10
- /**
11
- * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document
12
- */
13
- id: string;
14
- relationTo: TCollectionSlug;
15
- /**
16
- * Value can be just the document ID, or the full, populated document
17
- */
18
- value: DataFromCollectionSlug<TCollectionSlug> | number | string;
19
- };
20
- }[CollectionSlug];
21
- /**
22
- * Internal use only - UploadData type that can contain a pending state
23
- * @internal
24
- */
25
- export type Internal_UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {
26
- pending?: {
27
- /**
28
- * ID that corresponds to the bulk upload form ID
29
- */
30
- formID: string;
31
- /**
32
- * src value of the image dom element
33
- */
34
- src: string;
35
- };
36
- } & UploadData<TUploadExtraFieldsData>;
37
- /**
38
- * UploadDataImproved is a more precise type, and will replace UploadData in Payload v4.
39
- * This type is for internal use only as it will be deprecated in the future.
40
- * @internal
41
- *
42
- * @todo Replace UploadData with UploadDataImproved in 4.0
43
- */
44
- export type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonObject> = {
45
- [TCollectionSlug in UploadCollectionSlug]: {
46
- fields: TUploadExtraFieldsData;
47
- /**
48
- * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document
49
- */
50
- id: string;
51
- relationTo: TCollectionSlug;
52
- /**
53
- * Value can be just the document ID, or the full, populated document
54
- */
55
- value: number | string | TypedUploadCollection[TCollectionSlug];
56
- };
57
- }[UploadCollectionSlug];
58
- export type SerializedUploadNode = StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'upload'> & UploadData;
4
+ import type { SerializedUploadNode, UploadData } from '../schema.js';
59
5
  export declare class UploadServerNode extends DecoratorBlockNode {
60
6
  __data: UploadData;
61
7
  constructor({ data, format, key, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/server/nodes/UploadNode.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,WAAW,EACX,OAAO,EACR,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAKhF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AA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M,EAAE,UAAU,CAAA;gBAEN,EACV,IAAI,EACJ,MAAM,EACN,GAAG,GACJ,EAAE;QACD,IAAI,EAAE,UAAU,CAAA;QAChB,MAAM,CAAC,EAAE,iBAAiB,CAAA;QAC1B,GAAG,CAAC,EAAE,OAAO,CAAA;KACd;WAKe,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB;WAQ/C,OAAO,IAAI,MAAM;WAIjB,SAAS,IAAI,gBAAgB,CAAC,gBAAgB,CAAC;WAS/C,UAAU,CAAC,cAAc,EAAE,oBAAoB,GAAG,gBAAgB;IAuBlF,MAAM,CAAC,QAAQ,IAAI,KAAK;IAIf,SAAS,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW;IAM7C,QAAQ,IAAI,GAAG,CAAC,OAAO;IAIvB,SAAS,IAAI,eAAe;IAc5B,UAAU,IAAI,oBAAoB;IAS3C,OAAO,IAAI,UAAU;IAIrB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAKtB,SAAS,IAAI,KAAK;CAG5B;AAED,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,GACL,EAAE;IACD,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAA;CAC/D,GAAG,gBAAgB,CAKnB;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,gBAAgB,CAE1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"UploadNode.js","names":["DecoratorBlockNode","addClassNamesToElement","ObjectID","$applyNodeReplacement","$convertUploadElement","UploadServerNode","__data","constructor","data","format","key","clone","node","__format","__key","getType","importDOM","img","conversion","domNode","$createUploadServerNode","priority","importJSON","serializedNode","version","value","id","default","toHexString","importedData","fields","pending","relationTo","setFormat","isInline","createDOM","config","element","document","createElement","theme","upload","decorate","exportDOM","setAttribute","String","formID","src","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadServerNode"],"sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type {\n CollectionSlug,\n DataFromCollectionSlug,\n JsonObject,\n TypedUploadCollection,\n UploadCollectionSlug,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport { addClassNamesToElement } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\n\nimport type { StronglyTypedLeafNode } from '../../../../types/nodeTypes.js'\n\nimport { $convertUploadElement } from './conversions.js'\n\nexport type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in CollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\n/**\n * Internal use only - UploadData type that can contain a pending state\n * @internal\n */\nexport type Internal_UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n pending?: {\n /**\n * ID that corresponds to the bulk upload form ID\n */\n formID: string\n /**\n * src value of the image dom element\n */\n src: string\n }\n} & UploadData<TUploadExtraFieldsData>\n\n/**\n * UploadDataImproved is a more precise type, and will replace UploadData in Payload v4.\n * This type is for internal use only as it will be deprecated in the future.\n * @internal\n *\n * @todo Replace UploadData with UploadDataImproved in 4.0\n */\nexport type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in UploadCollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: number | string | TypedUploadCollection[TCollectionSlug]\n }\n}[UploadCollectionSlug]\n\nexport type SerializedUploadNode = StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'upload'> &\n UploadData\n\nexport class UploadServerNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'upload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadServerNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('div')\n addClassNamesToElement(element, config?.theme?.upload)\n return element\n }\n\n override decorate(): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n const data = this.__data as Internal_UploadData\n if (data.pending) {\n element.setAttribute('data-lexical-pending-upload-form-id', String(data?.pending?.formID))\n element.setAttribute('src', data?.pending?.src || '')\n } else {\n element.setAttribute('data-lexical-upload-id', String(data?.value))\n element.setAttribute('data-lexical-upload-relation-to', data?.relationTo)\n }\n\n return { element }\n }\n\n override exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n override updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is UploadServerNode {\n return node instanceof UploadServerNode\n}\n"],"mappings":"AAkBA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,sBAAsB,QAAQ;AACvC,OAAOC,QAAA,MAAc;AACrB,SAASC,qBAAqB,QAAQ;AAItC,SAASC,qBAAqB,QAAQ;AA2DtC,OAAO,MAAMC,gBAAA,SAAyBL,kBAAA;EACpCM,MAAA;EAEAC,YAAY;IACVC,IAAI;IACJC,MAAM;IACNC;EAAG,CAKJ,EAAE;IACD,KAAK,CAACD,MAAA,EAAQC,GAAA;IACd,IAAI,CAACJ,MAAM,GAAGE,IAAA;EAChB;EAEA,OAAgBG,MAAMC,IAAsB,EAAoB;IAC9D,OAAO,IAAI,IAAI,CAAC;MACdJ,IAAA,EAAMI,IAAA,CAAKN,MAAM;MACjBG,MAAA,EAAQG,IAAA,CAAKC,QAAQ;MACrBH,GAAA,EAAKE,IAAA,CAAKE;IACZ;EACF;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAA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,"file":"UploadNode.js","names":["DecoratorBlockNode","addClassNamesToElement","ObjectID","$applyNodeReplacement","$convertUploadElement","UploadServerNode","__data","constructor","data","format","key","clone","node","__format","__key","getType","importDOM","img","conversion","domNode","$createUploadServerNode","priority","importJSON","serializedNode","version","value","id","default","toHexString","importedData","fields","pending","relationTo","setFormat","isInline","createDOM","config","element","document","createElement","theme","upload","decorate","exportDOM","setAttribute","String","formID","src","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadServerNode"],"sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport { addClassNamesToElement } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\n\nimport type { Internal_UploadData, SerializedUploadNode, UploadData } from '../schema.js'\n\nimport { $convertUploadElement } from './conversions.js'\n\nexport class UploadServerNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'upload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadServerNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('div')\n addClassNamesToElement(element, config?.theme?.upload)\n return element\n }\n\n override decorate(): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n const data = this.__data as Internal_UploadData\n if (data.pending) {\n element.setAttribute('data-lexical-pending-upload-form-id', String(data?.pending?.formID))\n element.setAttribute('src', data?.pending?.src || '')\n } else {\n element.setAttribute('data-lexical-upload-id', String(data?.value))\n element.setAttribute('data-lexical-upload-relation-to', data?.relationTo)\n }\n\n return { element }\n }\n\n override exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n override updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is UploadServerNode {\n return node instanceof UploadServerNode\n}\n"],"mappings":"AAUA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,sBAAsB,QAAQ;AACvC,OAAOC,QAAA,MAAc;AACrB,SAASC,qBAAqB,QAAQ;AAItC,SAASC,qBAAqB,QAAQ;AAEtC,OAAO,MAAMC,gBAAA,SAAyB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C,UAAA,EAAmB;IAC1B,OAAO;EACT;AACF;AAEA,OAAO,SAASnC,wBAAwB;EACtCZ;AAAI,CAGL;EACC,IAAI,CAACA,IAAA,EAAMkB,EAAA,EAAI;IACblB,IAAA,CAAKkB,EAAE,GAAG,IAAIxB,QAAA,CAASyB,OAAO,GAAGC,WAAW;EAC9C;EACA,OAAOzB,qBAAA,CAAsB,IAAIE,gBAAA,CAAiB;IAAEG,IAAA,EAAMA;EAAmB;AAC/E;AAEA,OAAO,SAASgD,oBACd5C,IAAoC;EAEpC,OAAOA,IAAA,YAAgBP,gBAAA;AACzB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"conversions.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/server/nodes/conversions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAIlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,uBAAuB,EAAuB,MAAM,iBAAiB,CAAA;AAEnF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAOrE;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EACzB,WAAW,EAAE,OAAO,iBAAiB,GAAG,OAAO,uBAAuB,GACrE,mBAAmB,GAAG,IAAI,CA8C5B"}
1
+ {"version":3,"file":"conversions.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/server/nodes/conversions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAIlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAEzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAE9D,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAOrE;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EACzB,WAAW,EAAE,OAAO,iBAAiB,GAAG,OAAO,uBAAuB,GACrE,mBAAmB,GAAG,IAAI,CA8C5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"conversions.js","names":["ObjectID","isGoogleDocCheckboxImg","img","parentElement","tagName","previousSibling","getAttribute","$convertUploadElement","domNode","$createNode","hasAttribute","formID","node","data","pending","src","id","relationTo","fields","value","default","toHexString"],"sources":["../../../../../src/features/upload/server/nodes/conversions.ts"],"sourcesContent":["// This file contains functions used to convert dom elements to upload or pending upload lexical nodes. It requires the actual node\n// creation functions to be passed in to stay compatible with both client and server code.\nimport type { DOMConversionOutput } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\n\nimport type { $createUploadNode } from '../../client/nodes/UploadNode.js'\nimport type { $createUploadServerNode, Internal_UploadData } from './UploadNode.js'\n\nexport function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean {\n return (\n img.parentElement != null &&\n img.parentElement.tagName === 'LI' &&\n img.previousSibling === null &&\n img.getAttribute('aria-roledescription') === 'checkbox'\n )\n}\n\nexport function $convertUploadElement(\n domNode: HTMLImageElement,\n $createNode: typeof $createUploadNode | typeof $createUploadServerNode,\n): DOMConversionOutput | null {\n if (domNode.hasAttribute('data-lexical-pending-upload-form-id')) {\n const formID = domNode.getAttribute('data-lexical-pending-upload-form-id')\n\n if (formID != null) {\n const node = $createNode({\n data: {\n pending: {\n formID,\n src: domNode.getAttribute('src') || '',\n },\n } as Internal_UploadData,\n })\n return { node }\n }\n }\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n\n // Create pending UploadNode. Auto-Upload functionality will then be handled by the node transform\n const node = $createNode({\n data: {\n pending: {\n formID: new ObjectID.default().toHexString(),\n src: domNode.getAttribute('src') || '',\n },\n } as Internal_UploadData,\n })\n\n return { node }\n}\n"],"mappings":"AAAA;AACA;AAGA,OAAOA,QAAA,MAAc;AAKrB,OAAO,SAASC,uBAAuBC,GAAqB;EAC1D,OACEA,GAAA,CAAIC,aAAa,IAAI,QACrBD,GAAA,CAAIC,aAAa,CAACC,OAAO,KAAK,QAC9BF,GAAA,CAAIG,eAAe,KAAK,QACxBH,GAAA,CAAII,YAAY,CAAC,4BAA4B;AAEjD;AAEA,OAAO,SAASC,sBACdC,OAAyB,EACzBC,WAAsE;EAEtE,IAAID,OAAA,CAAQE,YAAY,CAAC,wCAAwC;IAC/D,MAAMC,MAAA,GAASH,OAAA,CAAQF,YAAY,CAAC;IAEpC,IAAIK,MAAA,IAAU,MAAM;MAClB,MAAMC,IAAA,GAAOH,WAAA,CAAY;QACvBI,IAAA,EAAM;UACJC,OAAA,EAAS;YACPH,MAAA;YACAI,GAAA,EAAKP,OAAA,CAAQF,YAAY,CAAC,UAAU;UACtC;QACF;MACF;MACA,OAAO;QAAEM;MAAK;IAChB;EACF;EACA,IACEJ,OAAA,CAAQE,YAAY,CAAC,sCACrBF,OAAA,CAAQE,YAAY,CAAC,2BACrB;IACA,MAAMM,EAAA,GAAKR,OAAA,CAAQF,YAAY,CAAC;IAChC,MAAMW,UAAA,GAAaT,OAAA,CAAQF,YAAY,CAAC;IAExC,IAAIU,EAAA,IAAM,QAAQC,UAAA,IAAc,MAAM;MACpC,MAAML,IAAA,GAAOH,WAAA,CAAY;QACvBI,IAAA,EAAM;UACJK,MAAA,EAAQ,CAAC;UACTD,UAAA;UACAE,KAAA,EAAOH;QACT;MACF;MACA,OAAO;QAAEJ;MAAK;IAChB;EACF;EAEA;EACA,MAAMA,IAAA,GAAOH,WAAA,CAAY;IACvBI,IAAA,EAAM;MACJC,OAAA,EAAS;QACPH,MAAA,EAAQ,IAAIX,QAAA,CAASoB,OAAO,GAAGC,WAAW;QAC1CN,GAAA,EAAKP,OAAA,CAAQF,YAAY,CAAC,UAAU;MACtC;IACF;EACF;EAEA,OAAO;IAAEM;EAAK;AAChB","ignoreList":[]}
1
+ {"version":3,"file":"conversions.js","names":["ObjectID","isGoogleDocCheckboxImg","img","parentElement","tagName","previousSibling","getAttribute","$convertUploadElement","domNode","$createNode","hasAttribute","formID","node","data","pending","src","id","relationTo","fields","value","default","toHexString"],"sources":["../../../../../src/features/upload/server/nodes/conversions.ts"],"sourcesContent":["// This file contains functions used to convert dom elements to upload or pending upload lexical nodes. It requires the actual node\n// creation functions to be passed in to stay compatible with both client and server code.\nimport type { DOMConversionOutput } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\n\nimport type { $createUploadNode } from '../../client/nodes/UploadNode.js'\nimport type { Internal_UploadData } from '../schema.js'\nimport type { $createUploadServerNode } from './UploadNode.js'\n\nexport function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean {\n return (\n img.parentElement != null &&\n img.parentElement.tagName === 'LI' &&\n img.previousSibling === null &&\n img.getAttribute('aria-roledescription') === 'checkbox'\n )\n}\n\nexport function $convertUploadElement(\n domNode: HTMLImageElement,\n $createNode: typeof $createUploadNode | typeof $createUploadServerNode,\n): DOMConversionOutput | null {\n if (domNode.hasAttribute('data-lexical-pending-upload-form-id')) {\n const formID = domNode.getAttribute('data-lexical-pending-upload-form-id')\n\n if (formID != null) {\n const node = $createNode({\n data: {\n pending: {\n formID,\n src: domNode.getAttribute('src') || '',\n },\n } as Internal_UploadData,\n })\n return { node }\n }\n }\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n\n // Create pending UploadNode. Auto-Upload functionality will then be handled by the node transform\n const node = $createNode({\n data: {\n pending: {\n formID: new ObjectID.default().toHexString(),\n src: domNode.getAttribute('src') || '',\n },\n } as Internal_UploadData,\n })\n\n return { node }\n}\n"],"mappings":"AAAA;AACA;AAGA,OAAOA,QAAA,MAAc;AAMrB,OAAO,SAASC,uBAAuBC,GAAqB;EAC1D,OACEA,GAAA,CAAIC,aAAa,IAAI,QACrBD,GAAA,CAAIC,aAAa,CAACC,OAAO,KAAK,QAC9BF,GAAA,CAAIG,eAAe,KAAK,QACxBH,GAAA,CAAII,YAAY,CAAC,4BAA4B;AAEjD;AAEA,OAAO,SAASC,sBACdC,OAAyB,EACzBC,WAAsE;EAEtE,IAAID,OAAA,CAAQE,YAAY,CAAC,wCAAwC;IAC/D,MAAMC,MAAA,GAASH,OAAA,CAAQF,YAAY,CAAC;IAEpC,IAAIK,MAAA,IAAU,MAAM;MAClB,MAAMC,IAAA,GAAOH,WAAA,CAAY;QACvBI,IAAA,EAAM;UACJC,OAAA,EAAS;YACPH,MAAA;YACAI,GAAA,EAAKP,OAAA,CAAQF,YAAY,CAAC,UAAU;UACtC;QACF;MACF;MACA,OAAO;QAAEM;MAAK;IAChB;EACF;EACA,IACEJ,OAAA,CAAQE,YAAY,CAAC,sCACrBF,OAAA,CAAQE,YAAY,CAAC,2BACrB;IACA,MAAMM,EAAA,GAAKR,OAAA,CAAQF,YAAY,CAAC;IAChC,MAAMW,UAAA,GAAaT,OAAA,CAAQF,YAAY,CAAC;IAExC,IAAIU,EAAA,IAAM,QAAQC,UAAA,IAAc,MAAM;MACpC,MAAML,IAAA,GAAOH,WAAA,CAAY;QACvBI,IAAA,EAAM;UACJK,MAAA,EAAQ,CAAC;UACTD,UAAA;UACAE,KAAA,EAAOH;QACT;MACF;MACA,OAAO;QAAEJ;MAAK;IAChB;EACF;EAEA;EACA,MAAMA,IAAA,GAAOH,WAAA,CAAY;IACvBI,IAAA,EAAM;MACJC,OAAA,EAAS;QACPH,MAAA,EAAQ,IAAIX,QAAA,CAASoB,OAAO,GAAGC,WAAW;QAC1CN,GAAA,EAAKP,OAAA,CAAQF,YAAY,CAAC,UAAU;MACtC;IACF;EACF;EAEA,OAAO;IAAEM;EAAK;AAChB","ignoreList":[]}
@@ -0,0 +1,52 @@
1
+ import type { DataFromCollectionSlug, JsonObject, TypedUploadCollection, UploadCollectionSlug } from 'payload';
2
+ import type { LexicalElementFormat } from '../../../types/nodeTypes.js';
3
+ import type { JSONSchemaFn } from '../../typesServer.js';
4
+ import type { UploadFeatureProps } from './index.js';
5
+ export type UploadData<TFields extends JsonObject = JsonObject> = {
6
+ [TCollectionSlug in UploadCollectionSlug]: {
7
+ fields: TFields;
8
+ /** ID of this upload node — NOT the linked document's ID. */
9
+ id: string;
10
+ relationTo: TCollectionSlug;
11
+ /** Either the document ID or the full populated document. */
12
+ value: DataFromCollectionSlug<TCollectionSlug> | number | string;
13
+ };
14
+ }[UploadCollectionSlug];
15
+ /** @internal Adds a pending state to `UploadData`. */
16
+ export type Internal_UploadData<TFields extends JsonObject = JsonObject> = {
17
+ pending?: {
18
+ /** Bulk upload form ID. */
19
+ formID: string;
20
+ /** `src` of the image DOM element. */
21
+ src: string;
22
+ };
23
+ } & UploadData<TFields>;
24
+ /**
25
+ * More precise variant of {@link UploadData}. Replaces `UploadData` in v4.
26
+ * @internal
27
+ * @todo Replace UploadData with UploadDataImproved in 4.0
28
+ */
29
+ export type UploadDataImproved<TFields extends JsonObject = JsonObject> = {
30
+ [TCollectionSlug in UploadCollectionSlug]: {
31
+ fields: TFields;
32
+ id: string;
33
+ relationTo: TCollectionSlug;
34
+ value: number | string | TypedUploadCollection[TCollectionSlug];
35
+ };
36
+ }[UploadCollectionSlug];
37
+ export type SerializedUploadNode<TSlugs extends UploadCollectionSlug = UploadCollectionSlug, TFields = {
38
+ [k: string]: unknown;
39
+ }> = {
40
+ [TSlug in TSlugs]: {
41
+ relationTo: TSlug;
42
+ value: DataFromCollectionSlug<TSlug> | number | string;
43
+ };
44
+ }[TSlugs] & {
45
+ fields: TFields;
46
+ format: LexicalElementFormat;
47
+ id: string;
48
+ type: 'upload';
49
+ version: number;
50
+ };
51
+ export declare const createUploadNodeJSONSchema: (props: undefined | UploadFeatureProps) => JSONSchemaFn;
52
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/features/upload/server/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAKpD,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU,IAAI;KAC/D,eAAe,IAAI,oBAAoB,GAAG;QACzC,MAAM,EAAE,OAAO,CAAA;QACf,6DAA6D;QAC7D,EAAE,EAAE,MAAM,CAAA;QACV,UAAU,EAAE,eAAe,CAAA;QAC3B,6DAA6D;QAC7D,KAAK,EAAE,sBAAsB,CAAC,eAAe,CAAC,GAAG,MAAM,GAAG,MAAM,CAAA;KACjE;CACF,CAAC,oBAAoB,CAAC,CAAA;AAEvB,sDAAsD;AACtD,MAAM,MAAM,mBAAmB,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU,IAAI;IACzE,OAAO,CAAC,EAAE;QACR,2BAA2B;QAC3B,MAAM,EAAE,MAAM,CAAA;QACd,sCAAsC;QACtC,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;CACF,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;AAEvB;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU,IAAI;KACvE,eAAe,IAAI,oBAAoB,GAAG;QACzC,MAAM,EAAE,OAAO,CAAA;QACf,EAAE,EAAE,MAAM,CAAA;QACV,UAAU,EAAE,eAAe,CAAA;QAC3B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,qBAAqB,CAAC,eAAe,CAAC,CAAA;KAChE;CACF,CAAC,oBAAoB,CAAC,CAAA;AAEvB,MAAM,MAAM,oBAAoB,CAC9B,MAAM,SAAS,oBAAoB,GAAG,oBAAoB,EAC1D,OAAO,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,IAChC;KACD,KAAK,IAAI,MAAM,GAAG;QACjB,UAAU,EAAE,KAAK,CAAA;QACjB,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,MAAM,CAAA;KACvD;CACF,CAAC,MAAM,CAAC,GAAG;IACV,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,oBAAoB,CAAA;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,QAAQ,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAmBD,eAAO,MAAM,0BAA0B,GACpC,OAAO,SAAS,GAAG,kBAAkB,KAAG,YA8FxC,CAAA"}
@@ -0,0 +1,129 @@
1
+ import { createHash } from 'crypto';
2
+ import { fieldsToJSONSchema, flattenAllFields } from 'payload';
3
+ import { formatSchema, versionSchema } from '../../../types/jsonSchemaHelpers.js';
4
+ import { filterEnabledRelationshipCollections } from '../../relationship/shared/filterEnabledRelationshipCollections.js';
5
+ /** MUST stay byte-for-byte in sync with the runtime `SerializedUploadNode` declared above. */
6
+ const SERIALIZED_UPLOAD_NODE_TS = `export type SerializedUploadNode<TSlugs extends keyof Config['collections'], TFields = { [k: string]: unknown }> = {
7
+ type: 'upload';
8
+ format: LexicalElementFormat;
9
+ id: string;
10
+ version: number;
11
+ fields: TFields;
12
+ } & {
13
+ [TSlug in TSlugs]: {
14
+ relationTo: TSlug;
15
+ value: number | string | Config['collections'][TSlug];
16
+ };
17
+ }[TSlugs];`;
18
+ const hashUploadFields = schema => createHash('sha256').update(JSON.stringify(schema)).digest('hex').slice(0, 8).toUpperCase();
19
+ export const createUploadNodeJSONSchema = props => ({
20
+ collectionIDFieldTypes,
21
+ config,
22
+ i18n,
23
+ interfaceNameDefinitions,
24
+ typeStringDefinitions
25
+ }) => {
26
+ typeStringDefinitions.add(SERIALIZED_UPLOAD_NODE_TS);
27
+ const enabledCollections = config?.collections ? filterEnabledRelationshipCollections(config.collections, {
28
+ disabledCollections: props?.disabledCollections,
29
+ enabledCollections: props?.enabledCollections,
30
+ uploads: true
31
+ }) : [];
32
+ // Configured extra fields are registered as their own interface and referenced here, so the
33
+ // generated TypeScript keeps them - the node-level `tsType` would otherwise erase `fields` to
34
+ // `{ [k: string]: unknown }`. Mirrors how LinkFeature handles custom link fields.
35
+ //
36
+ // Each collection gets its own `SerializedUploadNode<'slug', Fields>` instantiation so the
37
+ // generated union correctly pairs each `relationTo` with its own fields type. A single
38
+ // `SerializedUploadNode<'a' | 'b', AFields | BFields>` would lose that pairing.
39
+ const perCollectionTsTypes = [];
40
+ const collectionVariants = enabledCollections.map(collection => {
41
+ const slug = collection.slug;
42
+ const idType = collectionIDFieldTypes[slug] ?? 'string';
43
+ const extraFields = props?.collections?.[slug]?.fields ?? [];
44
+ const flattenedExtra = flattenAllFields({
45
+ fields: extraFields
46
+ });
47
+ const extraFieldsSchema = flattenedExtra.length > 0 && config ? fieldsToJSONSchema({
48
+ collectionIDFieldTypes,
49
+ config,
50
+ fields: flattenedExtra,
51
+ i18n,
52
+ interfaceNameDefinitions,
53
+ typeStringDefinitions
54
+ }) : {
55
+ properties: {},
56
+ required: []
57
+ };
58
+ let fieldsSchema = {
59
+ type: 'object',
60
+ additionalProperties: false,
61
+ properties: extraFieldsSchema.properties,
62
+ required: extraFieldsSchema.required
63
+ };
64
+ let fieldsTypeName;
65
+ if (flattenedExtra.length > 0) {
66
+ fieldsTypeName = `LexicalUploadFields_${hashUploadFields(fieldsSchema)}`;
67
+ interfaceNameDefinitions.set(fieldsTypeName, fieldsSchema);
68
+ fieldsSchema = {
69
+ $ref: `#/$defs/${fieldsTypeName}`
70
+ };
71
+ }
72
+ perCollectionTsTypes.push(fieldsTypeName ? `SerializedUploadNode<'${slug}', ${fieldsTypeName}>` : `SerializedUploadNode<'${slug}'>`);
73
+ return {
74
+ type: 'object',
75
+ additionalProperties: false,
76
+ properties: {
77
+ id: {
78
+ type: 'string'
79
+ },
80
+ type: {
81
+ type: 'string',
82
+ const: 'upload'
83
+ },
84
+ fields: fieldsSchema,
85
+ format: formatSchema,
86
+ relationTo: {
87
+ type: 'string',
88
+ const: slug
89
+ },
90
+ value: {
91
+ description: 'The uploaded file by ID (string or number). Populated to the full upload document when read at depth > 0.',
92
+ oneOf: [{
93
+ type: idType
94
+ }, {
95
+ $ref: `#/$defs/${slug}`
96
+ }]
97
+ },
98
+ version: versionSchema
99
+ },
100
+ required: ['fields', 'format', 'id', 'relationTo', 'type', 'value', 'version']
101
+ };
102
+ });
103
+ let schema;
104
+ if (collectionVariants.length === 0) {
105
+ // Fallback when no enabled upload collections.
106
+ schema = {
107
+ type: 'object',
108
+ additionalProperties: true,
109
+ properties: {
110
+ type: {
111
+ type: 'string',
112
+ const: 'upload'
113
+ },
114
+ version: versionSchema
115
+ },
116
+ required: ['type', 'version']
117
+ };
118
+ } else {
119
+ const baseSchema = collectionVariants.length === 1 ? collectionVariants[0] : {
120
+ oneOf: collectionVariants
121
+ };
122
+ schema = {
123
+ ...baseSchema,
124
+ tsType: perCollectionTsTypes.join(' | ')
125
+ };
126
+ }
127
+ return schema;
128
+ };
129
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","names":["createHash","fieldsToJSONSchema","flattenAllFields","formatSchema","versionSchema","filterEnabledRelationshipCollections","SERIALIZED_UPLOAD_NODE_TS","hashUploadFields","schema","update","JSON","stringify","digest","slice","toUpperCase","createUploadNodeJSONSchema","props","collectionIDFieldTypes","config","i18n","interfaceNameDefinitions","typeStringDefinitions","add","enabledCollections","collections","disabledCollections","uploads","perCollectionTsTypes","collectionVariants","map","collection","slug","idType","extraFields","fields","flattenedExtra","extraFieldsSchema","length","properties","required","fieldsSchema","type","additionalProperties","fieldsTypeName","set","$ref","push","id","const","format","relationTo","value","description","oneOf","version","baseSchema","tsType","join"],"sources":["../../../../src/features/upload/server/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport type {\n DataFromCollectionSlug,\n JsonObject,\n TypedUploadCollection,\n UploadCollectionSlug,\n} from 'payload'\n\nimport { createHash } from 'crypto'\nimport { fieldsToJSONSchema, flattenAllFields } from 'payload'\n\nimport type { LexicalElementFormat } from '../../../types/nodeTypes.js'\nimport type { JSONSchemaFn } from '../../typesServer.js'\nimport type { UploadFeatureProps } from './index.js'\n\nimport { formatSchema, versionSchema } from '../../../types/jsonSchemaHelpers.js'\nimport { filterEnabledRelationshipCollections } from '../../relationship/shared/filterEnabledRelationshipCollections.js'\n\nexport type UploadData<TFields extends JsonObject = JsonObject> = {\n [TCollectionSlug in UploadCollectionSlug]: {\n fields: TFields\n /** ID of this upload node — NOT the linked document's ID. */\n id: string\n relationTo: TCollectionSlug\n /** Either the document ID or the full populated document. */\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[UploadCollectionSlug]\n\n/** @internal Adds a pending state to `UploadData`. */\nexport type Internal_UploadData<TFields extends JsonObject = JsonObject> = {\n pending?: {\n /** Bulk upload form ID. */\n formID: string\n /** `src` of the image DOM element. */\n src: string\n }\n} & UploadData<TFields>\n\n/**\n * More precise variant of {@link UploadData}. Replaces `UploadData` in v4.\n * @internal\n * @todo Replace UploadData with UploadDataImproved in 4.0\n */\nexport type UploadDataImproved<TFields extends JsonObject = JsonObject> = {\n [TCollectionSlug in UploadCollectionSlug]: {\n fields: TFields\n id: string\n relationTo: TCollectionSlug\n value: number | string | TypedUploadCollection[TCollectionSlug]\n }\n}[UploadCollectionSlug]\n\nexport type SerializedUploadNode<\n TSlugs extends UploadCollectionSlug = UploadCollectionSlug,\n TFields = { [k: string]: unknown },\n> = {\n [TSlug in TSlugs]: {\n relationTo: TSlug\n value: DataFromCollectionSlug<TSlug> | number | string\n }\n}[TSlugs] & {\n fields: TFields\n format: LexicalElementFormat\n id: string\n type: 'upload'\n version: number\n}\n\n/** MUST stay byte-for-byte in sync with the runtime `SerializedUploadNode` declared above. */\nconst SERIALIZED_UPLOAD_NODE_TS = `export type SerializedUploadNode<TSlugs extends keyof Config['collections'], TFields = { [k: string]: unknown }> = {\n type: 'upload';\n format: LexicalElementFormat;\n id: string;\n version: number;\n fields: TFields;\n} & {\n [TSlug in TSlugs]: {\n relationTo: TSlug;\n value: number | string | Config['collections'][TSlug];\n };\n}[TSlugs];`\n\nconst hashUploadFields = (schema: JSONSchema4): string =>\n createHash('sha256').update(JSON.stringify(schema)).digest('hex').slice(0, 8).toUpperCase()\n\nexport const createUploadNodeJSONSchema =\n (props: undefined | UploadFeatureProps): JSONSchemaFn =>\n ({ collectionIDFieldTypes, config, i18n, interfaceNameDefinitions, typeStringDefinitions }) => {\n typeStringDefinitions.add(SERIALIZED_UPLOAD_NODE_TS)\n const enabledCollections = config?.collections\n ? filterEnabledRelationshipCollections(config.collections, {\n disabledCollections: props?.disabledCollections,\n enabledCollections: props?.enabledCollections,\n uploads: true,\n })\n : []\n\n // Configured extra fields are registered as their own interface and referenced here, so the\n // generated TypeScript keeps them - the node-level `tsType` would otherwise erase `fields` to\n // `{ [k: string]: unknown }`. Mirrors how LinkFeature handles custom link fields.\n //\n // Each collection gets its own `SerializedUploadNode<'slug', Fields>` instantiation so the\n // generated union correctly pairs each `relationTo` with its own fields type. A single\n // `SerializedUploadNode<'a' | 'b', AFields | BFields>` would lose that pairing.\n const perCollectionTsTypes: string[] = []\n const collectionVariants: JSONSchema4[] = enabledCollections.map((collection) => {\n const slug = collection.slug\n const idType: 'number' | 'string' = collectionIDFieldTypes[slug] ?? 'string'\n const extraFields = props?.collections?.[slug]?.fields ?? []\n const flattenedExtra = flattenAllFields({ fields: extraFields })\n const extraFieldsSchema =\n flattenedExtra.length > 0 && config\n ? fieldsToJSONSchema({\n collectionIDFieldTypes,\n config,\n fields: flattenedExtra,\n i18n,\n interfaceNameDefinitions,\n typeStringDefinitions,\n })\n : { properties: {}, required: [] }\n\n let fieldsSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: extraFieldsSchema.properties,\n required: extraFieldsSchema.required,\n }\n let fieldsTypeName: string | undefined\n if (flattenedExtra.length > 0) {\n fieldsTypeName = `LexicalUploadFields_${hashUploadFields(fieldsSchema)}`\n interfaceNameDefinitions.set(fieldsTypeName, fieldsSchema)\n fieldsSchema = { $ref: `#/$defs/${fieldsTypeName}` }\n }\n\n perCollectionTsTypes.push(\n fieldsTypeName\n ? `SerializedUploadNode<'${slug}', ${fieldsTypeName}>`\n : `SerializedUploadNode<'${slug}'>`,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: 'string' },\n type: { type: 'string', const: 'upload' },\n fields: fieldsSchema,\n format: formatSchema,\n relationTo: { type: 'string', const: slug },\n value: {\n description:\n 'The uploaded file by ID (string or number). Populated to the full upload document when read at depth > 0.',\n oneOf: [{ type: idType }, { $ref: `#/$defs/${slug}` }],\n },\n version: versionSchema,\n },\n required: ['fields', 'format', 'id', 'relationTo', 'type', 'value', 'version'],\n }\n })\n\n let schema: JSONSchema4\n if (collectionVariants.length === 0) {\n // Fallback when no enabled upload collections.\n schema = {\n type: 'object',\n additionalProperties: true,\n properties: {\n type: { type: 'string', const: 'upload' },\n version: versionSchema,\n },\n required: ['type', 'version'],\n }\n } else {\n const baseSchema: JSONSchema4 =\n collectionVariants.length === 1 ? collectionVariants[0]! : { oneOf: collectionVariants }\n schema = { ...baseSchema, tsType: perCollectionTsTypes.join(' | ') }\n }\n\n return schema\n }\n"],"mappings":"AAQA,SAASA,UAAU,QAAQ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A,CAAmBS,MAAM,KAAK,GAAG;IACnC;IACA7B,MAAA,GAAS;MACPiC,IAAA,EAAM;MACNC,oBAAA,EAAsB;MACtBJ,UAAA,EAAY;QACVG,IAAA,EAAM;UAAEA,IAAA,EAAM;UAAUO,KAAA,EAAO;QAAS;QACxCM,OAAA,EAASlD;MACX;MACAmC,QAAA,EAAU,CAAC,QAAQ;IACrB;EACF,OAAO;IACL,MAAMgB,UAAA,GACJ3B,kBAAA,CAAmBS,MAAM,KAAK,IAAIT,kBAAkB,CAAC,EAAE,GAAI;MAAEyB,KAAA,EAAOzB;IAAmB;IACzFpB,MAAA,GAAS;MAAE,GAAG+C,UAAU;MAAEC,MAAA,EAAQ7B,oBAAA,CAAqB8B,IAAI,CAAC;IAAO;EACrE;EAEA,OAAOjD,MAAA;AACT","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { NodeValidation } from '../../typesServer.js';
2
2
  import type { UploadFeatureProps } from './index.js';
3
- import type { SerializedUploadNode } from './nodes/UploadNode.js';
3
+ import type { SerializedUploadNode } from './schema.js';
4
4
  export declare const uploadValidation: (props: UploadFeatureProps) => NodeValidation<SerializedUploadNode>;
5
5
  //# sourceMappingURL=validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/features/upload/server/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE,eAAO,MAAM,gBAAgB,GAC3B,OAAO,kBAAkB,KACxB,cAAc,CAAC,oBAAoB,CAqErC,CAAA"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/features/upload/server/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvD,eAAO,MAAM,gBAAgB,GAC3B,OAAO,kBAAkB,KACxB,cAAc,CAAC,oBAAoB,CAqErC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","names":["fieldSchemasToFormState","isValidID","uploadValidation","props","node","validation","options","id","data","operation","preferences","req","payload","t","idType","collections","relationTo","customIDType","db","defaultIDType","nodeID","value","Object","keys","length","collection","fields","result","collectionSlug","documentData","fieldSchemaMap","undefined","initialBlockData","permissions","renderAllFields","schemaPath","errorPathsSet","Set","fieldKey","fieldState","errorPaths","errorPath","add","Array","from","join"],"sources":["../../../../src/features/upload/server/validate.ts"],"sourcesContent":["import { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\nimport { isValidID } from 'payload'\n\nimport type { NodeValidation } from '../../typesServer.js'\nimport type { UploadFeatureProps } from './index.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nexport const uploadValidation = (\n props: UploadFeatureProps,\n): NodeValidation<SerializedUploadNode> => {\n return async ({\n node,\n validation: {\n options: {\n id,\n data,\n operation,\n preferences,\n req,\n req: { payload, t },\n },\n },\n }) => {\n const idType = payload.collections[node.relationTo]?.customIDType || payload.db.defaultIDType\n // @ts-expect-error - Fix in Payload v4\n const nodeID = node?.value?.id || node?.value // for backwards-compatibility\n\n if (!isValidID(nodeID, idType)) {\n return t('validation:validUploadID')\n }\n\n if (!props?.collections) {\n return true\n }\n\n if (Object.keys(props?.collections).length === 0) {\n return true\n }\n\n const collection = props?.collections[node.relationTo]\n\n if (!collection?.fields?.length) {\n return true\n }\n\n const result = await fieldSchemasToFormState({\n id,\n collectionSlug: node.relationTo,\n data: node?.fields ?? {},\n documentData: data,\n fields: collection.fields,\n fieldSchemaMap: undefined,\n initialBlockData: node?.fields ?? {},\n operation: operation === 'create' || operation === 'update' ? operation : 'update',\n permissions: {},\n preferences,\n renderAllFields: false,\n req,\n schemaPath: '',\n })\n\n const errorPathsSet = new Set<string>()\n for (const fieldKey in result) {\n const fieldState = result[fieldKey]\n if (fieldState?.errorPaths?.length) {\n for (const errorPath of fieldState.errorPaths) {\n errorPathsSet.add(errorPath)\n }\n }\n }\n const errorPaths = Array.from(errorPathsSet)\n\n if (errorPaths.length) {\n return 'The following fields are invalid: ' + errorPaths.join(', ')\n }\n\n return true\n }\n}\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ;AACxC,SAASC,SAAS,QAAQ;AAM1B,OAAO,MAAMC,gBAAA,GACXC,KAAA;EAEA,OAAO,OAAO;IACZC,IAAI;IACJC,UAAA,EAAY;MACVC,OAAA,EAAS;QACPC,EAAE;QACFC,IAAI;QACJC,SAAS;QACTC,WAAW;QACXC,GAAG;QACHA,GAAA,EAAK;UAAEC,OAAO;UAAEC;QAAC;MAAE;IACpB;EACF,CACF;IACC,MAAMC,MAAA,GAASF,OAAA,CAAQG,WAAW,CAACX,IAAA,CAAKY,UAAU,CAAC,EAAEC,YAAA,IAAgBL,OAAA,CAAQM,EAAE,CAACC,aAAa;IAC7F;IACA,MAAMC,MAAA,GAAShB,IAAA,EAAMiB,KAAA,EAAOd,EAAA,IAAMH,IAAA,EAAMiB,KAAA,CAAM;AAAA;IAE9C,IAAI,CAACpB,SAAA,CAAUmB,MAAA,EAAQN,MAAA,GAAS;MAC9B,OAAOD,CAAA,CAAE;IACX;IAEA,IAAI,CAACV,KAAA,EAAOY,WAAA,EAAa;MACvB,OAAO;IACT;IAEA,IAAIO,MAAA,CAAOC,IAAI,CAACpB,KAAA,EAAOY,WAAA,EAAaS,MAAM,KAAK,GAAG;MAChD,OAAO;IACT;IAEA,MAAMC,UAAA,GAAatB,KAAA,EAAOY,WAAW,CAACX,IAAA,CAAKY,UAAU,CAAC;IAEtD,IAAI,CAACS,UAAA,EAAYC,MAAA,EAAQF,MAAA,EAAQ;MAC/B,OAAO;IACT;IAEA,MAAMG,MAAA,GAAS,MAAM3B,uBAAA,CAAwB;MAC3CO,EAAA;MACAqB,cAAA,EAAgBxB,IAAA,CAAKY,UAAU;MAC/BR,IAAA,EAAMJ,IAAA,EAAMsB,MAAA,IAAU,CAAC;MACvBG,YAAA,EAAcrB,IAAA;MACdkB,MAAA,EAAQD,UAAA,CAAWC,MAAM;MACzBI,cAAA,EAAgBC,SAAA;MAChBC,gBAAA,EAAkB5B,IAAA,EAAMsB,MAAA,IAAU,CAAC;MACnCjB,SAAA,EAAWA,SAAA,KAAc,YAAYA,SAAA,KAAc,WAAWA,SAAA,GAAY;MAC1EwB,WAAA,EAAa,CAAC;MACdvB,WAAA;MACAwB,eAAA,EAAiB;MACjBvB,GAAA;MACAwB,UAAA,EAAY;IACd;IAEA,MAAMC,aAAA,GAAgB,IAAIC,GAAA;IAC1B,KAAK,MAAMC,QAAA,IAAYX,MAAA,EAAQ;MAC7B,MAAMY,UAAA,GAAaZ,MAAM,CAACW,QAAA,CAAS;MACnC,IAAIC,UAAA,EAAYC,UAAA,EAAYhB,MAAA,EAAQ;QAClC,KAAK,MAAMiB,SAAA,IAAaF,UAAA,CAAWC,UAAU,EAAE;UAC7CJ,aAAA,CAAcM,GAAG,CAACD,SAAA;QACpB;MACF;IACF;IACA,MAAMD,UAAA,GAAaG,KAAA,CAAMC,IAAI,CAACR,aAAA;IAE9B,IAAII,UAAA,CAAWhB,MAAM,EAAE;MACrB,OAAO,uCAAuCgB,UAAA,CAAWK,IAAI,CAAC;IAChE;IAEA,OAAO;EACT;AACF","ignoreList":[]}
1
+ {"version":3,"file":"validate.js","names":["fieldSchemasToFormState","isValidID","uploadValidation","props","node","validation","options","id","data","operation","preferences","req","payload","t","idType","collections","relationTo","customIDType","db","defaultIDType","nodeID","value","Object","keys","length","collection","fields","result","collectionSlug","documentData","fieldSchemaMap","undefined","initialBlockData","permissions","renderAllFields","schemaPath","errorPathsSet","Set","fieldKey","fieldState","errorPaths","errorPath","add","Array","from","join"],"sources":["../../../../src/features/upload/server/validate.ts"],"sourcesContent":["import { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\nimport { isValidID } from 'payload'\n\nimport type { NodeValidation } from '../../typesServer.js'\nimport type { UploadFeatureProps } from './index.js'\nimport type { SerializedUploadNode } from './schema.js'\n\nexport const uploadValidation = (\n props: UploadFeatureProps,\n): NodeValidation<SerializedUploadNode> => {\n return async ({\n node,\n validation: {\n options: {\n id,\n data,\n operation,\n preferences,\n req,\n req: { payload, t },\n },\n },\n }) => {\n const idType = payload.collections[node.relationTo]?.customIDType || payload.db.defaultIDType\n // @ts-expect-error - Fix in Payload v4\n const nodeID = node?.value?.id || node?.value // for backwards-compatibility\n\n if (!isValidID(nodeID, idType)) {\n return t('validation:validUploadID')\n }\n\n if (!props?.collections) {\n return true\n }\n\n if (Object.keys(props?.collections).length === 0) {\n return true\n }\n\n const collection = props?.collections[node.relationTo]\n\n if (!collection?.fields?.length) {\n return true\n }\n\n const result = await fieldSchemasToFormState({\n id,\n collectionSlug: node.relationTo,\n data: node?.fields ?? {},\n documentData: data,\n fields: collection.fields,\n fieldSchemaMap: undefined,\n initialBlockData: node?.fields ?? {},\n operation: operation === 'create' || operation === 'update' ? operation : 'update',\n permissions: {},\n preferences,\n renderAllFields: false,\n req,\n schemaPath: '',\n })\n\n const errorPathsSet = new Set<string>()\n for (const fieldKey in result) {\n const fieldState = result[fieldKey]\n if (fieldState?.errorPaths?.length) {\n for (const errorPath of fieldState.errorPaths) {\n errorPathsSet.add(errorPath)\n }\n }\n }\n const errorPaths = Array.from(errorPathsSet)\n\n if (errorPaths.length) {\n return 'The following fields are invalid: ' + errorPaths.join(', ')\n }\n\n return true\n }\n}\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ;AACxC,SAASC,SAAS,QAAQ;AAM1B,OAAO,MAAMC,gBAAA,GACXC,KAAA;EAEA,OAAO,OAAO;IACZC,IAAI;IACJC,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A,EAAiB;MACjBvB,GAAA;MACAwB,UAAA,EAAY;IACd;IAEA,MAAMC,aAAA,GAAgB,IAAIC,GAAA;IAC1B,KAAK,MAAMC,QAAA,IAAYX,MAAA,EAAQ;MAC7B,MAAMY,UAAA,GAAaZ,MAAM,CAACW,QAAA,CAAS;MACnC,IAAIC,UAAA,EAAYC,UAAA,EAAYhB,MAAA,EAAQ;QAClC,KAAK,MAAMiB,SAAA,IAAaF,UAAA,CAAWC,UAAU,EAAE;UAC7CJ,aAAA,CAAcM,GAAG,CAACD,SAAA;QACpB;MACF;IACF;IACA,MAAMD,UAAA,GAAaG,KAAA,CAAMC,IAAI,CAACR,aAAA;IAE9B,IAAII,UAAA,CAAWhB,MAAM,EAAE;MACrB,OAAO,uCAAuCgB,UAAA,CAAWK,IAAI,CAAC;IAChE;IAEA,OAAO;EACT;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["File","createHash","formatFilesize","React","baseClass","UploadDiffHTMLConverterAsync","i18n","req","upload","node","populate","providedCSSString","uploadNode","uploadDoc","undefined","value","id","collectionSlug","relationTo","alt","fields","thumbnailSRC","thumbnailURL","url","ReactDOMServer","default","nodeFieldsHash","update","JSON","stringify","digest","filename","t","JSX","_jsx","className","_jsxs","length","src","filesize","width","height","Fragment","mimeType","html","renderToStaticMarkup"],"sources":["../../../../../src/field/Diff/converters/upload/index.tsx"],"sourcesContent":["import type { FileData, PayloadRequest, TypeWithID } from 'payload'\n\nimport { type I18nClient } from '@payloadcms/translations'\nimport { File } from '@payloadcms/ui/rsc'\nimport { createHash } from 'crypto'\n\nimport './index.css'\n\nimport { formatFilesize } from 'payload/shared'\nimport React from 'react'\n\nimport type { HTMLConvertersAsync } from '../../../../features/converters/lexicalToHtml/async/types.js'\nimport type { UploadDataImproved } from '../../../../features/upload/server/nodes/UploadNode.js'\nimport type { SerializedUploadNode } from '../../../../types/nodeTypes.js'\n\nconst baseClass = 'lexical-upload-diff'\n\nexport const UploadDiffHTMLConverterAsync: (args: {\n i18n: I18nClient\n req: PayloadRequest\n}) => HTMLConvertersAsync<SerializedUploadNode> = ({ i18n, req }) => {\n return {\n upload: async ({ node, populate, providedCSSString }) => {\n const uploadNode = node as UploadDataImproved\n\n let uploadDoc: (FileData & TypeWithID) | undefined = undefined\n\n // If there's no valid upload data, populate return an empty string\n if (typeof uploadNode.value !== 'object') {\n if (!populate) {\n return ''\n }\n uploadDoc = await populate<FileData & TypeWithID>({\n id: uploadNode.value,\n collectionSlug: uploadNode.relationTo,\n })\n } else {\n uploadDoc = uploadNode.value as unknown as FileData & TypeWithID\n }\n\n if (!uploadDoc) {\n return ''\n }\n\n const alt = (node.fields?.alt as string) || (uploadDoc as { alt?: string })?.alt || ''\n\n const thumbnailSRC: string =\n ('thumbnailURL' in uploadDoc && (uploadDoc?.thumbnailURL as string)) || uploadDoc?.url || ''\n\n const ReactDOMServer = (await import('react-dom/server')).default\n\n // hash fields to ensure they are diffed if they change\n const nodeFieldsHash = createHash('sha256')\n .update(JSON.stringify(node.fields ?? {}))\n .digest('hex')\n\n const filename =\n uploadDoc?.filename ||\n `${i18n.t('general:untitled')} - ID: ${typeof uploadNode.value === 'object' ? uploadNode.value : uploadNode.value}`\n\n const JSX = (\n <div\n className={`${baseClass}${providedCSSString}`}\n data-enable-match=\"true\"\n data-fields-hash={`${nodeFieldsHash}`}\n data-filename={uploadDoc?.filename}\n data-lexical-upload-id={uploadNode.value}\n data-lexical-upload-relation-to={uploadNode.relationTo}\n data-src={thumbnailSRC}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC?.length ? <img alt={alt} src={thumbnailSRC} /> : <File />}\n </div>\n <div className={`${baseClass}__info`} data-enable-match=\"false\">\n <strong>{filename}</strong>\n <div className={`${baseClass}__meta`}>\n {formatFilesize(uploadDoc?.filesize)}\n {typeof uploadDoc?.width === 'number' && typeof uploadDoc?.height === 'number' && (\n <React.Fragment>\n &nbsp;-&nbsp;\n {uploadDoc?.width}x{uploadDoc?.height}\n </React.Fragment>\n )}\n {uploadDoc?.mimeType && (\n <React.Fragment>\n &nbsp;-&nbsp;\n {uploadDoc?.mimeType}\n </React.Fragment>\n )}\n </div>\n </div>\n </div>\n </div>\n )\n\n // Render to HTML\n const html = ReactDOMServer.renderToStaticMarkup(JSX)\n\n return html\n },\n }\n}\n"],"mappings":";AAGA,SAASA,IAAI,QAAQ;AACrB,SAASC,UAAU,QAAQ;AAE3B,OAAO;AAEP,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAMlB,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,4BAAA,GAGqCA,CAAC;EAAEC,IAAI;EAAEC;AAAG,CAAE;EAC9D,OAAO;IACLC,MAAA,EAAQ,MAAAA,CAAO;MAAEC,IAAI;MAAEC,QAAQ;MAAEC;IAAiB,CAAE;MAClD,MAAMC,UAAA,GAAaH,IAAA;MAEnB,IAAII,SAAA,GAAiDC,SAAA;MAErD;MACA,IAAI,OAAOF,UAAA,CAAWG,KAAK,KAAK,UAAU;QACxC,IAAI,CAACL,QAAA,EAAU;UACb,OAAO;QACT;QACAG,SAAA,GAAY,MAAMH,QAAA,CAAgC;UAChDM,EAAA,EAAIJ,UAAA,CAAWG,KAAK;UACpBE,cAAA,EAAgBL,UAAA,CAAWM;QAC7B;MACF,OAAO;QACLL,SAAA,GAAYD,UAAA,CAAWG,KAAK;MAC9B;MAEA,IAAI,CAACF,SAAA,EAAW;QACd,OAAO;MACT;MAEA,MAAMM,GAAA,GAAMV,IAAC,CAAKW,MAAM,EAAED,GAAA,IAAmBN,SAAA,EAAgCM,GAAA,IAAO;MAEpF,MAAME,YAAA,GACJ,cAAC,IAAkBR,SAAA,IAAcA,SAAA,EAAWS,YAAA,IAA4BT,SAAA,EAAWU,GAAA,IAAO;MAE5F,MAAMC,cAAA,GAAiB,CAAC,MAAM,MAAM,CAAC,mBAAkB,EAAGC,OAAO;MAEjE;MACA,MAAMC,cAA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4B,MAAA;kBAGlC5B,SAAA,EAAW8B,QAAA,iBACVP,KAAA,CAACjC,KAAA,CAAMuC,QAAQ;2BAAC,OAEb7B,SAAA,EAAW8B,QAAA;;;;;;MAS1B;MACA,MAAMC,IAAA,GAAOpB,cAAA,CAAeqB,oBAAoB,CAACZ,GAAA;MAEjD,OAAOW,IAAA;IACT;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["File","createHash","formatFilesize","React","baseClass","UploadDiffHTMLConverterAsync","i18n","req","upload","node","populate","providedCSSString","uploadNode","uploadDoc","undefined","value","id","collectionSlug","relationTo","alt","fields","thumbnailSRC","thumbnailURL","url","ReactDOMServer","default","nodeFieldsHash","update","JSON","stringify","digest","filename","t","JSX","_jsx","className","_jsxs","length","src","filesize","width","height","Fragment","mimeType","html","renderToStaticMarkup"],"sources":["../../../../../src/field/Diff/converters/upload/index.tsx"],"sourcesContent":["import type { FileData, PayloadRequest, TypeWithID } from 'payload'\n\nimport { type I18nClient } from '@payloadcms/translations'\nimport { File } from '@payloadcms/ui/rsc'\nimport { createHash } from 'crypto'\n\nimport './index.css'\n\nimport { formatFilesize } from 'payload/shared'\nimport React from 'react'\n\nimport type { HTMLConvertersAsync } from '../../../../features/converters/lexicalToHtml/async/types.js'\nimport type { UploadDataImproved } from '../../../../features/upload/server/schema.js'\nimport type { SerializedUploadNode } from '../../../../types/nodeTypes.js'\n\nconst baseClass = 'lexical-upload-diff'\n\nexport const UploadDiffHTMLConverterAsync: (args: {\n i18n: I18nClient\n req: PayloadRequest\n}) => HTMLConvertersAsync<SerializedUploadNode> = ({ i18n, req }) => {\n return {\n upload: async ({ node, populate, providedCSSString }) => {\n const uploadNode = node as UploadDataImproved\n\n let uploadDoc: (FileData & TypeWithID) | undefined = undefined\n\n // If there's no valid upload data, populate return an empty string\n if (typeof uploadNode.value !== 'object') {\n if (!populate) {\n return ''\n }\n uploadDoc = await populate<FileData & TypeWithID>({\n id: uploadNode.value,\n collectionSlug: uploadNode.relationTo,\n })\n } else {\n uploadDoc = uploadNode.value as unknown as FileData & TypeWithID\n }\n\n if (!uploadDoc) {\n return ''\n }\n\n const alt = (node.fields?.alt as string) || (uploadDoc as { alt?: string })?.alt || ''\n\n const thumbnailSRC: string =\n ('thumbnailURL' in uploadDoc && (uploadDoc?.thumbnailURL as string)) || uploadDoc?.url || ''\n\n const ReactDOMServer = (await import('react-dom/server')).default\n\n // hash fields to ensure they are diffed if they change\n const nodeFieldsHash = createHash('sha256')\n .update(JSON.stringify(node.fields ?? {}))\n .digest('hex')\n\n const filename =\n uploadDoc?.filename ||\n `${i18n.t('general:untitled')} - ID: ${typeof uploadNode.value === 'object' ? uploadNode.value : uploadNode.value}`\n\n const JSX = (\n <div\n className={`${baseClass}${providedCSSString}`}\n data-enable-match=\"true\"\n data-fields-hash={`${nodeFieldsHash}`}\n data-filename={uploadDoc?.filename}\n data-lexical-upload-id={uploadNode.value}\n data-lexical-upload-relation-to={uploadNode.relationTo}\n data-src={thumbnailSRC}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC?.length ? <img alt={alt} src={thumbnailSRC} /> : <File />}\n </div>\n <div className={`${baseClass}__info`} data-enable-match=\"false\">\n <strong>{filename}</strong>\n <div className={`${baseClass}__meta`}>\n {formatFilesize(uploadDoc?.filesize)}\n {typeof uploadDoc?.width === 'number' && typeof uploadDoc?.height === 'number' && (\n <React.Fragment>\n &nbsp;-&nbsp;\n {uploadDoc?.width}x{uploadDoc?.height}\n </React.Fragment>\n )}\n {uploadDoc?.mimeType && (\n <React.Fragment>\n &nbsp;-&nbsp;\n {uploadDoc?.mimeType}\n </React.Fragment>\n )}\n </div>\n </div>\n </div>\n </div>\n )\n\n // Render to HTML\n const html = ReactDOMServer.renderToStaticMarkup(JSX)\n\n return html\n },\n }\n}\n"],"mappings":";AAGA,SAASA,IAAI,QAAQ;AACrB,SAASC,UAAU,QAAQ;AAE3B,OAAO;AAEP,SAASC,cAAc,QA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