@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,74 +1,128 @@
1
- import type { SerializedLineBreakNode as _SerializedLineBreakNode, SerializedTabNode as _SerializedTabNode, SerializedTextNode as _SerializedTextNode, SerializedEditorState, SerializedElementNode, SerializedLexicalNode } from 'lexical';
2
- import type { SerializedQuoteNode } from '../features/blockquote/server/index.js';
3
- import type { SerializedBlockNode } from '../features/blocks/server/nodes/BlocksNode.js';
4
- import type { SerializedInlineBlockNode } from '../features/blocks/server/nodes/InlineBlocksNode.js';
5
- import type { SerializedTableCellNode, SerializedTableNode, SerializedTableRowNode } from '../features/experimental_table/server/index.js';
6
- import type { SerializedHeadingNode } from '../features/heading/server/index.js';
7
- import type { SerializedHorizontalRuleNode } from '../features/horizontalRule/server/nodes/HorizontalRuleNode.js';
8
- import type { SerializedAutoLinkNode, SerializedLinkNode } from '../features/link/nodes/types.js';
9
- import type { SerializedListItemNode, SerializedListNode } from '../features/lists/plugin/index.js';
10
- import type { SerializedRelationshipNode } from '../features/relationship/server/nodes/RelationshipNode.js';
11
- import type { SerializedUploadNode } from '../features/upload/server/nodes/UploadNode.js';
1
+ import type { SerializedLexicalNode } from 'lexical';
2
+ import type { SerializedQuoteNode } from '../features/blockquote/server/schema.js';
3
+ import type { SerializedBlockNode, SerializedInlineBlockNode } from '../features/blocks/server/schema.js';
4
+ import type { SerializedTableCellNode, SerializedTableNode, SerializedTableRowNode } from '../features/experimental_table/server/schema.js';
5
+ import type { SerializedHeadingNode } from '../features/heading/server/schema.js';
6
+ import type { SerializedHorizontalRuleNode } from '../features/horizontalRule/server/schema.js';
7
+ import type { SerializedAutoLinkNode, SerializedLinkNode } from '../features/link/server/schema.js';
8
+ import type { SerializedListItemNode, SerializedListNode } from '../features/lists/shared/schema.js';
9
+ import type { SerializedRelationshipNode } from '../features/relationship/server/schema.js';
10
+ import type { SerializedUploadNode } from '../features/upload/server/schema.js';
11
+ /** @internal Core Lexical types see @payloadcms/richtext-lexical. */
12
+ export type LexicalElementFormat = '' | 'center' | 'end' | 'justify' | 'left' | 'right' | 'start';
13
+ export type LexicalElementDirection = ('ltr' | 'rtl') | null;
14
+ export interface SerializedLexicalElementBase<TChildren> {
15
+ children: TChildren[];
16
+ direction: LexicalElementDirection;
17
+ format: LexicalElementFormat;
18
+ indent: number;
19
+ textFormat?: number;
20
+ textStyle?: string;
21
+ version: number;
22
+ }
23
+ export type LexicalTextMode = 'normal' | 'segmented' | 'token';
24
+ export interface SerializedTextNode {
25
+ detail: number;
26
+ format: number;
27
+ mode: LexicalTextMode;
28
+ style: string;
29
+ text: string;
30
+ type: 'text';
31
+ version: number;
32
+ }
33
+ export interface SerializedTabNode {
34
+ detail: number;
35
+ format: number;
36
+ mode: LexicalTextMode;
37
+ style: string;
38
+ text: string;
39
+ type: 'tab';
40
+ version: number;
41
+ }
42
+ export interface SerializedLineBreakNode {
43
+ type: 'linebreak';
44
+ version: number;
45
+ }
46
+ export interface SerializedParagraphNode<TChildren extends SerializedLexicalNode = SerializedLexicalNode> extends SerializedLexicalElementBase<TChildren> {
47
+ textFormat: number;
48
+ textStyle: string;
49
+ type: 'paragraph';
50
+ }
51
+ /** Shape of a Lexical `richText` field. */
52
+ export interface LexicalRichText<TNode> {
53
+ root: {
54
+ children: TNode[];
55
+ direction: LexicalElementDirection;
56
+ format: LexicalElementFormat;
57
+ indent: number;
58
+ type: 'root';
59
+ version: number;
60
+ };
61
+ }
62
+ export type { SerializedAutoLinkNode, SerializedBlockNode, SerializedHeadingNode, SerializedHorizontalRuleNode, SerializedInlineBlockNode, SerializedLinkNode, SerializedListItemNode, SerializedListNode, SerializedQuoteNode, SerializedRelationshipNode, SerializedTableCellNode, SerializedTableNode, SerializedTableRowNode, SerializedUploadNode, };
63
+ /** `SerializedEditorState` with nodes narrowed by `type`. No type-casting needed. */
64
+ export type TypedEditorState<TNode extends SerializedLexicalNode = SerializedLexicalNode> = LexicalRichText<TNode>;
12
65
  /**
13
- * Helper type to create strongly typed serialized nodes with flexible children types.
14
- * Omits 'children' and 'type' from the base node type and redeclares them with proper typing.
15
- *
16
- * @param TBase - The base Lexical node type (e.g., _SerializedHeadingNode)
17
- * @param TType - The node type string (e.g., 'heading')
18
- * @param TChildren - The type for children (defaults to SerializedLexicalNode)
66
+ * The node union of a generated `richText` field. Pass the field type — e.g.
67
+ * `RichTextNodes<Post['richText']>` to type an individual node you build for that editor (for
68
+ * example a single block, or a `.map()` of nodes). To build a whole editor state, prefer passing
69
+ * the field type straight to {@link buildEditorState}.
19
70
  */
20
- export type StronglyTypedElementNode<TBase, TType extends string, TChildren extends SerializedLexicalNode = SerializedLexicalNode> = {
21
- children: TChildren[];
22
- type: TType;
23
- } & Omit<TBase, 'children' | 'type'>;
71
+ export type RichTextNodes<TRichText> = NonNullable<TRichText> extends LexicalRichText<infer TNode> ? TNode : never;
24
72
  /**
25
- * Helper type to create strongly typed leaf nodes (nodes without children).
26
- * Omits 'children' and 'type' from the base node type and redeclares 'type' with a literal.
27
- *
28
- * @param TBase - The base Lexical node type (e.g., _SerializedTextNode)
29
- * @param TType - The node type string (e.g., 'text')
73
+ * All node types included by default in a lexical editor. Self-recursive —
74
+ * each element node's `children` is `DefaultNodeTypes` again, no depth limit.
75
+ * To compose your own union including the defaults, see {@link WithDefaultNodes}.
30
76
  */
31
- export type StronglyTypedLeafNode<TBase, TType extends string> = {
32
- type: TType;
33
- } & Omit<TBase, 'children' | 'type'>;
34
- export type { SerializedAutoLinkNode, SerializedBlockNode, SerializedHeadingNode, SerializedHorizontalRuleNode, SerializedInlineBlockNode, SerializedLinkNode, SerializedListItemNode, SerializedListNode, SerializedQuoteNode, SerializedRelationshipNode, SerializedTableCellNode, SerializedTableNode, SerializedTableRowNode, SerializedUploadNode, };
35
- export type SerializedParagraphNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {
36
- textFormat: number;
37
- } & StronglyTypedElementNode<SerializedElementNode, 'paragraph', T>;
38
- export type SerializedTextNode = StronglyTypedLeafNode<_SerializedTextNode, 'text'>;
39
- export type SerializedTabNode = StronglyTypedLeafNode<_SerializedTabNode, 'tab'>;
40
- export type SerializedLineBreakNode = StronglyTypedLeafNode<_SerializedLineBreakNode, 'linebreak'>;
77
+ export type DefaultNodeTypes = SerializedAutoLinkNode<DefaultNodeTypes> | SerializedHeadingNode<DefaultNodeTypes> | SerializedHorizontalRuleNode | SerializedLineBreakNode | SerializedLinkNode<DefaultNodeTypes> | SerializedListItemNode<DefaultNodeTypes> | SerializedListNode<DefaultNodeTypes> | SerializedParagraphNode<DefaultNodeTypes> | SerializedQuoteNode<DefaultNodeTypes> | SerializedRelationshipNode | SerializedTabNode | SerializedTextNode | SerializedUploadNode;
41
78
  /**
42
- * Recursively adds typed children to nodes up to a specified depth.
79
+ * The built-in lexical nodes, plus your own - with your nodes threaded into every container's
80
+ * `children`, not just the top level. Pass your custom node(s) as the generic:
43
81
  *
44
- * Key behaviors:
45
- * - `T extends any`: Distributive - processes each union member individually
46
- * - `OriginalUnion`: Preserves full union so nested children accept all node types, not just parent's type. If we just used `T`, the type would be narrowed to the parent's type and the children would only consist of the parent's type.
47
- * - `'children' extends keyof T`: Only adds children to container nodes; respects leaf nodes that use `Omit<_, 'children'>`
48
- * - `Depth`: Limits recursion to prevent infinite types (default: 4 levels)
82
+ * ```ts
83
+ * type MyNodes = WithDefaultNodes<SerializedBlockNode<MyBlockData>>
84
+ * ```
49
85
  *
50
- * @internal - this type may change or be removed in a minor release
86
+ * Built by flattening {@link DefaultNodeRegistry} (`Registry[keyof Registry]`); see that interface
87
+ * for why the node set lives in a registry instead of being written as a plain union type.
51
88
  */
52
- export type RecursiveNodes<T extends SerializedLexicalNode, Depth extends number = 4, OriginalUnion extends SerializedLexicalNode = T> = T extends any ? Depth extends 0 ? T : 'children' extends keyof T ? {
53
- children?: RecursiveNodes<OriginalUnion, DecrementDepth<Depth>, OriginalUnion>[];
54
- } & T : T : never;
55
- /** Decrements depth: 4→3, 3→2, 2→1, 1→0, 0→0 */
56
- type DecrementDepth<N extends number> = [0, 0, 1, 2, 3, 4][N];
89
+ export type WithDefaultNodes<TCustom extends SerializedLexicalNode = never> = DefaultNodeRegistry<TCustom>[keyof DefaultNodeRegistry<TCustom>];
90
+ /** @internal Re-types an element node's `children` to the recursive node union. */
91
+ type WithRecursiveChildren<TNode, TCustom extends SerializedLexicalNode> = {
92
+ children: WithDefaultNodes<TCustom>[];
93
+ } & Omit<TNode, 'children'>;
57
94
  /**
58
- * Alternative type to `SerializedEditorState` that automatically types your nodes
59
- * more strictly, narrowing down nodes based on the `type` without having to manually
60
- * type-cast.
61
- */
62
- export type TypedEditorState<T extends SerializedLexicalNode = SerializedLexicalNode> = {
63
- [k: string]: unknown;
64
- } & SerializedEditorState<RecursiveNodes<T>>;
65
- /**
66
- * All node types included by default in a lexical editor without configuration.
95
+ * @internal The set of default nodes, generic over the user's custom node(s). {@link WithDefaultNodes}
96
+ * flattens it into the node union with `Registry[keyof Registry]`.
97
+ *
98
+ * Why a registry interface instead of writing the union directly? The union has to be self-referential:
99
+ * every element node's `children` is the same node union (so custom nodes nest inside containers too).
100
+ * A generic *type alias* can't reference itself that way - `type N<T> = SerializedParagraphNode<N<T>> | ...`
101
+ * is a `TS2456` circular reference, because instantiating a type alias resolves its type argument
102
+ * eagerly. An *interface* resolves its members lazily, so the self-reference inside `children: ...[]`
103
+ * is allowed - the recursion is legal precisely because it lives inside this interface. Reusing the
104
+ * real node interfaces (re-typing only `children`) keeps each entry in sync with its node's real shape.
67
105
  */
68
- export type DefaultNodeTypes = SerializedAutoLinkNode | SerializedHeadingNode | SerializedHorizontalRuleNode | SerializedLineBreakNode | SerializedLinkNode | SerializedListItemNode | SerializedListNode | SerializedParagraphNode | SerializedQuoteNode | SerializedRelationshipNode | SerializedTabNode | SerializedTextNode | SerializedUploadNode;
106
+ interface DefaultNodeRegistry<TCustom extends SerializedLexicalNode> {
107
+ autolink: WithRecursiveChildren<SerializedAutoLinkNode<SerializedLexicalNode>, TCustom>;
108
+ custom: TCustom;
109
+ heading: WithRecursiveChildren<SerializedHeadingNode<SerializedLexicalNode>, TCustom>;
110
+ horizontalrule: SerializedHorizontalRuleNode;
111
+ linebreak: SerializedLineBreakNode;
112
+ link: WithRecursiveChildren<SerializedLinkNode<SerializedLexicalNode>, TCustom>;
113
+ list: WithRecursiveChildren<SerializedListNode<SerializedLexicalNode>, TCustom>;
114
+ listitem: WithRecursiveChildren<SerializedListItemNode<SerializedLexicalNode>, TCustom>;
115
+ paragraph: WithRecursiveChildren<SerializedParagraphNode<SerializedLexicalNode>, TCustom>;
116
+ quote: WithRecursiveChildren<SerializedQuoteNode<SerializedLexicalNode>, TCustom>;
117
+ relationship: SerializedRelationshipNode;
118
+ tab: SerializedTabNode;
119
+ text: SerializedTextNode;
120
+ upload: SerializedUploadNode;
121
+ }
69
122
  /**
70
- * Like `TypedEditorState` but includes all default node types.
71
- * You can pass *additional* node types as a generic parameter.
123
+ * Like `TypedEditorState`, but pre-filled with every default node type. Pass extra node types as a
124
+ * generic to add your own; they're threaded into every container's `children` (via
125
+ * {@link WithDefaultNodes}), not just allowed at the top level.
72
126
  */
73
- export type DefaultTypedEditorState<TAdditionalNodeTypes extends null | SerializedLexicalNode = null> = [TAdditionalNodeTypes] extends null ? TypedEditorState<DefaultNodeTypes> : TypedEditorState<DefaultNodeTypes | NonNullable<TAdditionalNodeTypes>>;
127
+ export type DefaultTypedEditorState<TAdditionalNodeTypes extends null | SerializedLexicalNode = null> = TypedEditorState<WithDefaultNodes<NonNullable<TAdditionalNodeTypes>>>;
74
128
  //# sourceMappingURL=nodeTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodeTypes.d.ts","sourceRoot":"","sources":["../../src/types/nodeTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,IAAI,wBAAwB,EACnD,iBAAiB,IAAI,kBAAkB,EACvC,kBAAkB,IAAI,mBAAmB,EACzC,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAA;AACxF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qDAAqD,CAAA;AACpG,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAChF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,+DAA+D,CAAA;AACjH,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,C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C,OAAO,SAAS,qBAAqB;IACjE,QAAQ,EAAE,qBAAqB,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IACvF,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,qBAAqB,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IACrF,cAAc,EAAE,4BAA4B,CAAA;IAC5C,SAAS,EAAE,uBAAuB,CAAA;IAClC,IAAI,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IAC/E,IAAI,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IAC/E,QAAQ,EAAE,qBAAqB,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IACvF,SAAS,EAAE,qBAAqB,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IACzF,KAAK,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IACjF,YAAY,EAAE,0BAA0B,CAAA;IACxC,GAAG,EAAE,iBAAiB,CAAA;IACtB,IAAI,EAAE,kBAAkB,CAAA;IACxB,MAAM,EAAE,oBAAoB,CAAA;CAC7B;AAED;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,CACjC,oBAAoB,SAAS,IAAI,GAAG,qBAAqB,GAAG,IAAI,IAC9D,gBAAgB,CAAC,gBAAgB,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Like `TypedEditorState` but includes all default node types.
3
- * You can pass *additional* node types as a generic parameter.
2
+ * Like `TypedEditorState`, but pre-filled with every default node type. Pass extra node types as a
3
+ * generic to add your own; they're threaded into every container's `children` (via
4
+ * {@link WithDefaultNodes}), not just allowed at the top level.
4
5
  */export {};
5
6
  //# sourceMappingURL=nodeTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodeTypes.js","names":[],"sources":["../../src/types/nodeTypes.ts"],"sourcesContent":["import type {\n SerializedLineBreakNode as _SerializedLineBreakNode,\n SerializedTabNode as _SerializedTabNode,\n SerializedTextNode as _SerializedTextNode,\n SerializedEditorState,\n SerializedElementNode,\n SerializedLexicalNode,\n} from 'lexical'\n\nimport type { SerializedQuoteNode } from '../features/blockquote/server/index.js'\nimport type { SerializedBlockNode } from '../features/blocks/server/nodes/BlocksNode.js'\nimport type { SerializedInlineBlockNode } from '../features/blocks/server/nodes/InlineBlocksNode.js'\nimport type {\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n} from '../features/experimental_table/server/index.js'\nimport type { SerializedHeadingNode } from '../features/heading/server/index.js'\nimport type { SerializedHorizontalRuleNode } from '../features/horizontalRule/server/nodes/HorizontalRuleNode.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from '../features/link/nodes/types.js'\nimport type { SerializedListItemNode, SerializedListNode } from '../features/lists/plugin/index.js'\nimport type { SerializedRelationshipNode } from '../features/relationship/server/nodes/RelationshipNode.js'\nimport type { SerializedUploadNode } from '../features/upload/server/nodes/UploadNode.js'\n\n/**\n * Helper type to create strongly typed serialized nodes with flexible children types.\n * Omits 'children' and 'type' from the base node type and redeclares them with proper typing.\n *\n * @param TBase - The base Lexical node type (e.g., _SerializedHeadingNode)\n * @param TType - The node type string (e.g., 'heading')\n * @param TChildren - The type for children (defaults to SerializedLexicalNode)\n */\nexport type StronglyTypedElementNode<\n TBase,\n TType extends string,\n TChildren extends SerializedLexicalNode = SerializedLexicalNode,\n> = {\n children: TChildren[]\n type: TType\n} & Omit<TBase, 'children' | 'type'>\n\n/**\n * Helper type to create strongly typed leaf nodes (nodes without children).\n * Omits 'children' and 'type' from the base node type and redeclares 'type' with a literal.\n *\n * @param TBase - The base Lexical node type (e.g., _SerializedTextNode)\n * @param TType - The node type string (e.g., 'text')\n */\nexport type StronglyTypedLeafNode<TBase, TType extends string> = {\n type: TType\n} & Omit<TBase, 'children' | 'type'>\n\nexport type {\n SerializedAutoLinkNode,\n SerializedBlockNode,\n SerializedHeadingNode,\n SerializedHorizontalRuleNode,\n SerializedInlineBlockNode,\n SerializedLinkNode,\n SerializedListItemNode,\n SerializedListNode,\n SerializedQuoteNode,\n SerializedRelationshipNode,\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n SerializedUploadNode,\n}\n\nexport type SerializedParagraphNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {\n textFormat: number\n} & StronglyTypedElementNode<SerializedElementNode, 'paragraph', T>\n\nexport type SerializedTextNode = StronglyTypedLeafNode<_SerializedTextNode, 'text'>\n\nexport type SerializedTabNode = StronglyTypedLeafNode<_SerializedTabNode, 'tab'>\n\nexport type SerializedLineBreakNode = StronglyTypedLeafNode<_SerializedLineBreakNode, 'linebreak'>\n\n/**\n * Recursively adds typed children to nodes up to a specified depth.\n *\n * Key behaviors:\n * - `T extends any`: Distributive - processes each union member individually\n * - `OriginalUnion`: Preserves full union so nested children accept all node types, not just parent's type. If we just used `T`, the type would be narrowed to the parent's type and the children would only consist of the parent's type.\n * - `'children' extends keyof T`: Only adds children to container nodes; respects leaf nodes that use `Omit<_, 'children'>`\n * - `Depth`: Limits recursion to prevent infinite types (default: 4 levels)\n *\n * @internal - this type may change or be removed in a minor release\n */\nexport type RecursiveNodes<\n T extends SerializedLexicalNode,\n Depth extends number = 4,\n OriginalUnion extends SerializedLexicalNode = T,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n> = T extends any // Make distributive over unions\n ? Depth extends 0\n ? T\n : 'children' extends keyof T\n ? { children?: RecursiveNodes<OriginalUnion, DecrementDepth<Depth>, OriginalUnion>[] } & T\n : T // Skip leaf nodes\n : never\n\n/** Decrements depth: 4→3, 3→2, 2→1, 1→0, 0→0 */\ntype DecrementDepth<N extends number> = [0, 0, 1, 2, 3, 4][N]\n\n/**\n * Alternative type to `SerializedEditorState` that automatically types your nodes\n * more strictly, narrowing down nodes based on the `type` without having to manually\n * type-cast.\n */\nexport type TypedEditorState<T extends SerializedLexicalNode = SerializedLexicalNode> = {\n [k: string]: unknown\n} & SerializedEditorState<RecursiveNodes<T>>\n\n/**\n * All node types included by default in a lexical editor without configuration.\n */\nexport type DefaultNodeTypes =\n | SerializedAutoLinkNode\n //| SerializedBlockNode // Not included by default\n | SerializedHeadingNode\n | SerializedHorizontalRuleNode\n | SerializedLineBreakNode\n | SerializedLinkNode\n | SerializedListItemNode\n | SerializedListNode\n | SerializedParagraphNode\n | SerializedQuoteNode\n | SerializedRelationshipNode\n | SerializedTabNode\n | SerializedTextNode\n | SerializedUploadNode\n\n/**\n * Like `TypedEditorState` but includes all default node types.\n * You can pass *additional* node types as a generic parameter.\n */\nexport type DefaultTypedEditorState<\n TAdditionalNodeTypes extends null | SerializedLexicalNode = null,\n> = [TAdditionalNodeTypes] extends null\n ? TypedEditorState<DefaultNodeTypes>\n : TypedEditorState<DefaultNodeTypes | NonNullable<TAdditionalNodeTypes>>\n"],"mappings":"AAsIA;;;GAIA","ignoreList":[]}
1
+ {"version":3,"file":"nodeTypes.js","names":[],"sources":["../../src/types/nodeTypes.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type { SerializedQuoteNode } from '../features/blockquote/server/schema.js'\nimport type {\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../features/blocks/server/schema.js'\nimport type {\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n} from '../features/experimental_table/server/schema.js'\nimport type { SerializedHeadingNode } from '../features/heading/server/schema.js'\nimport type { SerializedHorizontalRuleNode } from '../features/horizontalRule/server/schema.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from '../features/link/server/schema.js'\nimport type { SerializedListItemNode, SerializedListNode } from '../features/lists/shared/schema.js'\nimport type { SerializedRelationshipNode } from '../features/relationship/server/schema.js'\nimport type { SerializedUploadNode } from '../features/upload/server/schema.js'\n\n// The declarations below must stay byte-for-byte aligned with the TS source\n// strings Payload appends to `payload-types.ts` twins live in\n// `types/builtInNodes.ts` and per-feature `schema.ts`.\n\n/** @internal Core Lexical types see @payloadcms/richtext-lexical. */\nexport type LexicalElementFormat = '' | 'center' | 'end' | 'justify' | 'left' | 'right' | 'start'\nexport type LexicalElementDirection = ('ltr' | 'rtl') | null\n\nexport interface SerializedLexicalElementBase<TChildren> {\n children: TChildren[]\n direction: LexicalElementDirection\n format: LexicalElementFormat\n indent: number\n textFormat?: number\n textStyle?: string\n version: number\n}\n\nexport type LexicalTextMode = 'normal' | 'segmented' | 'token'\n\nexport interface SerializedTextNode {\n detail: number\n format: number\n mode: LexicalTextMode\n style: string\n text: string\n type: 'text'\n version: number\n}\n\nexport interface SerializedTabNode {\n detail: number\n format: number\n mode: LexicalTextMode\n style: string\n text: string\n type: 'tab'\n version: number\n}\n\nexport interface SerializedLineBreakNode {\n type: 'linebreak'\n version: number\n}\n\nexport interface SerializedParagraphNode<\n TChildren extends SerializedLexicalNode = SerializedLexicalNode,\n> extends SerializedLexicalElementBase<TChildren> {\n textFormat: number\n textStyle: string\n type: 'paragraph'\n}\n\n/** Shape of a Lexical `richText` field. */\nexport interface LexicalRichText<TNode> {\n root: {\n children: TNode[]\n direction: LexicalElementDirection\n format: LexicalElementFormat\n indent: number\n type: 'root'\n version: number\n }\n}\n\nexport type {\n SerializedAutoLinkNode,\n SerializedBlockNode,\n SerializedHeadingNode,\n SerializedHorizontalRuleNode,\n SerializedInlineBlockNode,\n SerializedLinkNode,\n SerializedListItemNode,\n SerializedListNode,\n SerializedQuoteNode,\n SerializedRelationshipNode,\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n SerializedUploadNode,\n}\n\n/** `SerializedEditorState` with nodes narrowed by `type`. No type-casting needed. */\nexport type TypedEditorState<TNode extends SerializedLexicalNode = SerializedLexicalNode> =\n LexicalRichText<TNode>\n\n/**\n * The node union of a generated `richText` field. Pass the field type e.g.\n * `RichTextNodes<Post['richText']>` — to type an individual node you build for that editor (for\n * example a single block, or a `.map()` of nodes). To build a whole editor state, prefer passing\n * the field type straight to {@link buildEditorState}.\n */\nexport type RichTextNodes<TRichText> =\n NonNullable<TRichText> extends LexicalRichText<infer TNode> ? TNode : never\n\n/**\n * All node types included by default in a lexical editor. Self-recursive —\n * each element node's `children` is `DefaultNodeTypes` again, no depth limit.\n * To compose your own union including the defaults, see {@link WithDefaultNodes}.\n */\nexport type DefaultNodeTypes =\n | SerializedAutoLinkNode<DefaultNodeTypes>\n //| SerializedBlockNode // Not included by default\n | SerializedHeadingNode<DefaultNodeTypes>\n | SerializedHorizontalRuleNode\n | SerializedLineBreakNode\n | SerializedLinkNode<DefaultNodeTypes>\n | SerializedListItemNode<DefaultNodeTypes>\n | SerializedListNode<DefaultNodeTypes>\n | SerializedParagraphNode<DefaultNodeTypes>\n | SerializedQuoteNode<DefaultNodeTypes>\n | SerializedRelationshipNode\n | SerializedTabNode\n | SerializedTextNode\n | SerializedUploadNode\n\n/**\n * The built-in lexical nodes, plus your own - with your nodes threaded into every container's\n * `children`, not just the top level. Pass your custom node(s) as the generic:\n *\n * ```ts\n * type MyNodes = WithDefaultNodes<SerializedBlockNode<MyBlockData>>\n * ```\n *\n * Built by flattening {@link DefaultNodeRegistry} (`Registry[keyof Registry]`); see that interface\n * for why the node set lives in a registry instead of being written as a plain union type.\n */\nexport type WithDefaultNodes<TCustom extends SerializedLexicalNode = never> =\n DefaultNodeRegistry<TCustom>[keyof DefaultNodeRegistry<TCustom>]\n\n/** @internal Re-types an element node's `children` to the recursive node union. */\ntype WithRecursiveChildren<TNode, TCustom extends SerializedLexicalNode> = {\n children: WithDefaultNodes<TCustom>[]\n} & Omit<TNode, 'children'>\n\n/**\n * @internal The set of default nodes, generic over the user's custom node(s). {@link WithDefaultNodes}\n * flattens it into the node union with `Registry[keyof Registry]`.\n *\n * Why a registry interface instead of writing the union directly? The union has to be self-referential:\n * every element node's `children` is the same node union (so custom nodes nest inside containers too).\n * A generic *type alias* can't reference itself that way - `type N<T> = SerializedParagraphNode<N<T>> | ...`\n * is a `TS2456` circular reference, because instantiating a type alias resolves its type argument\n * eagerly. An *interface* resolves its members lazily, so the self-reference inside `children: ...[]`\n * is allowed - the recursion is legal precisely because it lives inside this interface. Reusing the\n * real node interfaces (re-typing only `children`) keeps each entry in sync with its node's real shape.\n */\ninterface DefaultNodeRegistry<TCustom extends SerializedLexicalNode> {\n autolink: WithRecursiveChildren<SerializedAutoLinkNode<SerializedLexicalNode>, TCustom>\n custom: TCustom\n heading: WithRecursiveChildren<SerializedHeadingNode<SerializedLexicalNode>, TCustom>\n horizontalrule: SerializedHorizontalRuleNode\n linebreak: SerializedLineBreakNode\n link: WithRecursiveChildren<SerializedLinkNode<SerializedLexicalNode>, TCustom>\n list: WithRecursiveChildren<SerializedListNode<SerializedLexicalNode>, TCustom>\n listitem: WithRecursiveChildren<SerializedListItemNode<SerializedLexicalNode>, TCustom>\n paragraph: WithRecursiveChildren<SerializedParagraphNode<SerializedLexicalNode>, TCustom>\n quote: WithRecursiveChildren<SerializedQuoteNode<SerializedLexicalNode>, TCustom>\n relationship: SerializedRelationshipNode\n tab: SerializedTabNode\n text: SerializedTextNode\n upload: SerializedUploadNode\n}\n\n/**\n * Like `TypedEditorState`, but pre-filled with every default node type. Pass extra node types as a\n * generic to add your own; they're threaded into every container's `children` (via\n * {@link WithDefaultNodes}), not just allowed at the top level.\n */\nexport type DefaultTypedEditorState<\n TAdditionalNodeTypes extends null | SerializedLexicalNode = null,\n> = TypedEditorState<WithDefaultNodes<NonNullable<TAdditionalNodeTypes>>>\n"],"mappings":"AAuLA;;;;GAKA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD,eAAO,MAAM,oBAAoB,EAAE,CAAC,IAAI,EAAE;IACxC,YAAY,EAAE,2BAA2B,CAAA;CAC1C,KAAK,sBAAsB,CAAC,YAAY,CAgFxC,CAAA"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAqBxD,eAAO,MAAM,oBAAoB,EAAE,CAAC,IAAI,EAAE;IACxC,YAAY,EAAE,2BAA2B,CAAA;CAC1C,KAAK,sBAAsB,CAAC,YAAY,CAsFxC,CAAA"}
@@ -1,4 +1,14 @@
1
- import { withNullableJSONSchemaType } from 'payload';
1
+ import { createHash } from 'crypto';
2
+ import { CORE_LEXICAL_TYPE_STRING, lineBreakNodeJSONSchema, paragraphNodeJSONSchema, rootNodeJSONSchema, tabNodeJSONSchema, textNodeJSONSchema } from './builtInNodes.js';
3
+ import { elementNodeSchema } from './jsonSchemaHelpers.js';
4
+ /**
5
+ * The node-union name is a hash of its own schema (so identical editors dedupe).
6
+ * Since the schema references the union name, we use a placeholder during build
7
+ * and substitute the real hash once everything's assembled. Features can derive
8
+ * sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.
9
+ */
10
+ const NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__';
11
+ const NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`;
2
12
  export const getFieldToJSONSchema = ({
3
13
  editorConfig
4
14
  }) => {
@@ -8,74 +18,66 @@ export const getFieldToJSONSchema = ({
8
18
  field,
9
19
  i18n,
10
20
  interfaceNameDefinitions,
11
- isRequired
21
+ typeStringDefinitions
12
22
  }) => {
13
- let jsonSchema = {
14
- // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.
15
- // In the future, we should
16
- // 1) allow recursive children
17
- // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.
18
- type: withNullableJSONSchemaType('object', isRequired),
19
- properties: {
20
- root: {
21
- type: 'object',
22
- additionalProperties: false,
23
- properties: {
24
- type: {
25
- type: 'string'
26
- },
27
- children: {
28
- type: 'array',
29
- items: {
30
- type: 'object',
31
- additionalProperties: true,
32
- properties: {
33
- type: {
34
- type: 'string',
35
- tsType: 'any'
36
- },
37
- version: {
38
- type: 'integer'
39
- }
40
- },
41
- required: ['type', 'version']
42
- }
43
- },
44
- direction: {
45
- oneOf: [{
46
- enum: ['ltr', 'rtl']
47
- }, {
48
- type: 'null'
49
- }]
50
- },
51
- format: {
52
- type: 'string',
53
- enum: ['left', 'start', 'center', 'right', 'end', 'justify', '']
54
- },
55
- indent: {
56
- type: 'integer'
57
- },
58
- version: {
59
- type: 'integer'
60
- }
61
- },
62
- required: ['children', 'direction', 'format', 'indent', 'type', 'version']
23
+ // Step 1: build the schema for every node type allowed in this field.
24
+ typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING);
25
+ const nodeJsonSchemaArgs = {
26
+ collectionIDFieldTypes,
27
+ config,
28
+ // Each element node needs its children typed using the union node type recursively
29
+ elementNodeSchema: args => elementNodeSchema({
30
+ ...args,
31
+ nodeUnionRef: {
32
+ $ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`
63
33
  }
64
- },
65
- required: ['root']
34
+ }),
35
+ field,
36
+ i18n,
37
+ interfaceNameDefinitions,
38
+ nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,
39
+ typeStringDefinitions
66
40
  };
67
- for (const modifyJSONSchema of editorConfig.features.generatedTypes.modifyJSONSchemas) {
68
- jsonSchema = modifyJSONSchema({
69
- collectionIDFieldTypes,
70
- config,
71
- currentSchema: jsonSchema,
72
- field,
73
- i18n,
74
- interfaceNameDefinitions,
75
- isRequired
76
- });
41
+ const nodeSchemas = [
42
+ // Add built-in node schemas
43
+ textNodeJSONSchema(nodeJsonSchemaArgs), tabNodeJSONSchema(nodeJsonSchemaArgs), lineBreakNodeJSONSchema(nodeJsonSchemaArgs), paragraphNodeJSONSchema(nodeJsonSchemaArgs),
44
+ // Add feature node schemas
45
+ ...editorConfig.features.nodes.filter(node => node.jsonSchema).map(node => node.jsonSchema(nodeJsonSchemaArgs))];
46
+ const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs);
47
+ // Step 2: get the final node union name, then replace the placeholder
48
+ // in both the union members and the root node.
49
+ //
50
+ // See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.
51
+ const nodeUnionJson = JSON.stringify({
52
+ oneOf: nodeSchemas
53
+ });
54
+ // Features can register per-editor definitions during node-schema build (e.g. a link node's
55
+ // custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node
56
+ // union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same
57
+ // nodes but different feature config (e.g. different custom link fields) would otherwise hash
58
+ // identically and overwrite each other's definition. To avoid that, include that content into the hash too.
59
+ const pendingDefinitions = [...interfaceNameDefinitions.entries()].filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER)).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
60
+ const hashInput = pendingDefinitions.length ? JSON.stringify({
61
+ definitions: pendingDefinitions,
62
+ oneOf: nodeSchemas
63
+ }) : nodeUnionJson;
64
+ const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase();
65
+ const nodeUnionName = `LexicalNodes_${hash}`;
66
+ // Replacing the hash resolves the union name and any feature-derived
67
+ // sibling names in one pass.
68
+ const replacePlaceholder = schemaString => JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash));
69
+ // Resolve placeholders left in feature-registered definitions so Map keys
70
+ // and `$ref` targets line up.
71
+ for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {
72
+ const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash);
73
+ const resolvedSchema = replacePlaceholder(JSON.stringify(schema));
74
+ if (newKey !== oldKey) {
75
+ interfaceNameDefinitions.delete(oldKey);
76
+ }
77
+ interfaceNameDefinitions.set(newKey, resolvedSchema);
77
78
  }
78
- return jsonSchema;
79
+ interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson));
80
+ return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder));
79
81
  };
80
82
  };
81
83
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":["withNullableJSONSchemaType","getFieldToJSONSchema","editorConfig","collectionIDFieldTypes","config","field","i18n","interfaceNameDefinitions","isRequired","jsonSchema","type","properties","root","additionalProperties","children","items","tsType","version","required","direction","oneOf","enum","format","indent","modifyJSONSchema","features","generatedTypes","modifyJSONSchemas","currentSchema"],"sources":["../../src/types/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { withNullableJSONSchemaType } from 'payload'\n\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextAdapter } from './index.js'\n\nexport const getFieldToJSONSchema: (args: {\n editorConfig: SanitizedServerEditorConfig\n}) => LexicalRichTextAdapter['jsonSchema'] = ({ editorConfig }) => {\n return ({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n }) => {\n let jsonSchema: JSONSchema4 = {\n // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.\n // In the future, we should\n // 1) allow recursive children\n // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.\n type: withNullableJSONSchemaType('object', isRequired),\n properties: {\n root: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: {\n type: 'string',\n },\n children: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: true,\n properties: {\n type: {\n type: 'string',\n tsType: 'any',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['type', 'version'],\n },\n },\n direction: {\n oneOf: [\n {\n enum: ['ltr', 'rtl'],\n },\n {\n type: 'null',\n },\n ],\n },\n format: {\n type: 'string',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''], // ElementFormatType, since the root node is an element\n },\n indent: {\n type: 'integer',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version'],\n },\n },\n required: ['root'],\n }\n for (const modifyJSONSchema of editorConfig.features.generatedTypes.modifyJSONSchemas) {\n jsonSchema = modifyJSONSchema({\n collectionIDFieldTypes,\n config,\n currentSchema: jsonSchema,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n })\n }\n\n return jsonSchema\n }\n}\n"],"mappings":"AAEA,SAASA,0BAA0B,QAAQ;AAK3C,OAAO,MAAMC,oBAAA,GAEgCA,CAAC;EAAEC;AAAY,CAAE;EAC5D,OAAO,CAAC;IACNC,sBAAsB;IACtBC,MAAM;IACNC,KAAK;IACLC,IAAI;IACJC,wBAAwB;IACxBC;EAAU,CACX;IACC,IAAIC,UAAA,GAA0B;MAC5B;MACA;MACA;MACA;MACAC,IAAA,EAAMV,0BAAA,CAA2B,UAAUQ,UAAA;MAC3CG,UAAA,EAAY;QACVC,IAAA,EAAM;UACJF,IAAA,EAAM;UACNG,oBAAA,EAAsB;UACtBF,UAAA,EAAY;YACVD,IAAA,EAAM;cACJA,IAAA,EAAM;YACR;YACAI,QAAA,EAAU;cACRJ,IAAA,EAAM;cACNK,KAAA,EAAO;gBACLL,IAAA,EAAM;gBACNG,oBAAA,EAAsB;gBACtBF,UAAA,EAAY;kBACVD,IAAA,EAAM;oBACJA,IAAA,EAAM;oBACNM,MAAA,EAAQ;kBACV;kBACAC,OAAA,EAAS;oBACPP,IAAA,EAAM;kBACR;gBACF;gBACAQ,QAAA,EAAU,CAAC,QAAQ;cACrB;YACF;YACAC,SAAA,EAAW;cACTC,KAAA,EAAO,CACL;gBACEC,IAAA,EAAM,CAAC,OAAO;cAChB,GACA;gBACEX,IAAA,EAAM;cACR;YAEJ;YACAY,MAAA,EAAQ;cACNZ,IAAA,EAAM;cACNW,IAAA,EAAM,CAAC,QAAQ,SAAS,UAAU,SAAS,OAAO,WAAW;YAC/D;YACAE,MAAA,EAAQ;cACNb,IAAA,EAAM;YACR;YACAO,OAAA,EAAS;cACPP,IAAA,EAAM;YACR;UACF;UACAQ,QAAA,EAAU,CAAC,YAAY,aAAa,UAAU,UAAU,QAAQ;QAClE;MACF;MACAA,QAAA,EAAU,CAAC;IACb;IACA,KAAK,MAAMM,gBAAA,IAAoBtB,YAAA,CAAauB,QAAQ,CAACC,cAAc,CAACC,iBAAiB,EAAE;MACrFlB,UAAA,GAAae,gBAAA,CAAiB;QAC5BrB,sBAAA;QACAC,MAAA;QACAwB,aAAA,EAAenB,UAAA;QACfJ,KAAA;QACAC,IAAA;QACAC,wBAAA;QACAC;MACF;IACF;IAEA,OAAOC,UAAA;EACT;AACF","ignoreList":[]}
1
+ {"version":3,"file":"schema.js","names":["createHash","CORE_LEXICAL_TYPE_STRING","lineBreakNodeJSONSchema","paragraphNodeJSONSchema","rootNodeJSONSchema","tabNodeJSONSchema","textNodeJSONSchema","elementNodeSchema","NODE_UNION_HASH_PLACEHOLDER","NODE_UNION_NAME_PLACEHOLDER","getFieldToJSONSchema","editorConfig","collectionIDFieldTypes","config","field","i18n","interfaceNameDefinitions","typeStringDefinitions","add","nodeJsonSchemaArgs","args","nodeUnionRef","$ref","nodeUnionName","nodeSchemas","features","nodes","filter","node","jsonSchema","map","rootSchemaWithPlaceholder","nodeUnionJson","JSON","stringify","oneOf","pendingDefinitions","entries","key","includes","sort","a","b","hashInput","length","definitions","hash","update","digest","slice","toUpperCase","replacePlaceholder","schemaString","parse","replaceAll","oldKey","schema","newKey","resolvedSchema","delete","set"],"sources":["../../src/types/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { createHash } from 'crypto'\n\nimport type { JSONSchemaArgs } from '../features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextAdapter } from './index.js'\n\nimport {\n CORE_LEXICAL_TYPE_STRING,\n lineBreakNodeJSONSchema,\n paragraphNodeJSONSchema,\n rootNodeJSONSchema,\n tabNodeJSONSchema,\n textNodeJSONSchema,\n} from './builtInNodes.js'\nimport { elementNodeSchema } from './jsonSchemaHelpers.js'\n\n/**\n * The node-union name is a hash of its own schema (so identical editors dedupe).\n * Since the schema references the union name, we use a placeholder during build\n * and substitute the real hash once everything's assembled. Features can derive\n * sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.\n */\nconst NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__'\nconst NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`\n\nexport const getFieldToJSONSchema: (args: {\n editorConfig: SanitizedServerEditorConfig\n}) => LexicalRichTextAdapter['jsonSchema'] = ({ editorConfig }) => {\n return ({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n typeStringDefinitions,\n }) => {\n // Step 1: build the schema for every node type allowed in this field.\n\n typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING)\n\n const nodeJsonSchemaArgs: JSONSchemaArgs = {\n collectionIDFieldTypes,\n config,\n // Each element node needs its children typed using the union node type recursively\n elementNodeSchema: (args) =>\n elementNodeSchema({\n ...args,\n nodeUnionRef: {\n $ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`,\n },\n }),\n field,\n i18n,\n interfaceNameDefinitions,\n nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,\n typeStringDefinitions,\n }\n\n const nodeSchemas: JSONSchema4[] = [\n // Add built-in node schemas\n textNodeJSONSchema(nodeJsonSchemaArgs),\n tabNodeJSONSchema(nodeJsonSchemaArgs),\n lineBreakNodeJSONSchema(nodeJsonSchemaArgs),\n paragraphNodeJSONSchema(nodeJsonSchemaArgs),\n // Add feature node schemas\n ...editorConfig.features.nodes\n .filter((node) => node.jsonSchema)\n .map((node) => node.jsonSchema!(nodeJsonSchemaArgs)),\n ]\n const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs)\n\n // Step 2: get the final node union name, then replace the placeholder\n // in both the union members and the root node.\n //\n // See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.\n const nodeUnionJson = JSON.stringify({ oneOf: nodeSchemas })\n\n // Features can register per-editor definitions during node-schema build (e.g. a link node's\n // custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node\n // union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same\n // nodes but different feature config (e.g. different custom link fields) would otherwise hash\n // identically and overwrite each other's definition. To avoid that, include that content into the hash too.\n const pendingDefinitions = [...interfaceNameDefinitions.entries()]\n .filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER))\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n\n const hashInput = pendingDefinitions.length\n ? JSON.stringify({ definitions: pendingDefinitions, oneOf: nodeSchemas })\n : nodeUnionJson\n\n const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase()\n const nodeUnionName = `LexicalNodes_${hash}`\n\n // Replacing the hash resolves the union name and any feature-derived\n // sibling names in one pass.\n const replacePlaceholder = (schemaString: string) =>\n JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash)) as JSONSchema4\n\n // Resolve placeholders left in feature-registered definitions so Map keys\n // and `$ref` targets line up.\n for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {\n const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash)\n const resolvedSchema = replacePlaceholder(JSON.stringify(schema))\n if (newKey !== oldKey) {\n interfaceNameDefinitions.delete(oldKey)\n }\n interfaceNameDefinitions.set(newKey, resolvedSchema)\n }\n\n interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson))\n\n return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder))\n }\n}\n"],"mappings":"AAEA,SAASA,UAAU,QAAQ;AAM3B,SACEC,wBAAwB,EACxBC,uBAAuB,EACvBC,uBAAuB,EACvBC,kBAAkB,EAClBC,iBAAiB,EACjBC,kBAAkB,QACb;AACP,SAASC,iBAAiB,QAAQ;AAElC;;;;;;AAMA,MAAMC,2BAAA,GAA8B;AACpC,MAAMC,2BAAA,GAA8B,gBAAgBD,2BAAA,EAA6B;AAEjF,OAAO,MAAME,oBAAA,GAEgCA,CAAC;EAAEC;AAAY,CAAE;EAC5D,OAAO,CAAC;IACNC,sBAAsB;IACtBC,MAAM;IACNC,KAAK;IACLC,IAAI;IACJC,wBAAwB;IACxBC;EAAqB,CACtB;IACC;IAEAA,qBAAA,CAAsBC,GAAG,CAACjB,wBAAA;IAE1B,MAAMkB,kBAAA,GAAqC;MACzCP,sBAAA;MACAC,MAAA;MACA;MACAN,iBAAA,EAAoBa,IAAA,IAClBb,iBAAA,CAAkB;QAChB,GAAGa,IAAI;QACPC,YAAA,EAAc;UACZC,IAAA,EAAM,WAAWb,2BAAA;QACnB;MACF;MACFK,KAAA;MACAC,IAAA;MACAC,wBAAA;MACAO,aAAA,EAAed,2BAAA;MACfQ;IACF;IAEA,MAAMO,WAAA,GAA6B;IACjC;IACAlB,kBAAA,CAAmBa,kBAAA,GACnBd,iBAAA,CAAkBc,kBAAA,GAClBjB,uBAAA,CAAwBiB,kBAAA,GACxBhB,uBAAA,CAAwBgB,kBAAA;IACxB;OACGR,YAAA,CAAac,QAAQ,CAACC,KAAK,CAC3BC,MAAM,CAAEC,IAAA,IAASA,IAAA,CAAKC,UAAU,EAChCC,GAAG,CAAEF,IAAA,IAASA,IAAA,CAAKC,UAAU,CAAEV,kBAAA,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AWF,MAAA,EAAQ;QACrBvC,wBAAA,CAAyB2C,MAAM,CAACJ,MAAA;MAClC;MACAvC,wBAAA,CAAyB4C,GAAG,CAACH,MAAA,EAAQC,cAAA;IACvC;IAEA1C,wBAAA,CAAyB4C,GAAG,CAACrC,aAAA,EAAe4B,kBAAA,CAAmBnB,aAAA;IAE/D,OAAOmB,kBAAA,CAAmBlB,IAAA,CAAKC,SAAS,CAACH,yBAAA;EAC3C;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAIvE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,CAiGzF"}
1
+ {"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAIhE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,CAgGzF"}
@@ -77,10 +77,9 @@ export function applyBaseFilterToFields(fields, config) {
77
77
  }
78
78
  // Handle blocks
79
79
  if (field.type === 'blocks') {
80
- const blocks = field.blockReferences ?? field.blocks ?? [];
81
80
  return {
82
81
  ...field,
83
- blocks: blocks.map(block => {
82
+ blocks: field.blocks.map(block => {
84
83
  if (typeof block === 'string') {
85
84
  return block;
86
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"applyBaseFilterToFields.js","names":["combineWhereConstraints","applyBaseFilterToFields","fields","config","map","field","type","relationshipField","originalFilterOptions","filterOptions","args","relationTo","req","user","originalResult","admin","collections","find","slug","hidden","baseFilter","baseListFilter","baseFilterResult","limit","page","sort","tabs","tab","blocks","blockReferences","block"],"sources":["../../src/utilities/applyBaseFilterToFields.ts"],"sourcesContent":["import type { Block, Field, SanitizedConfig, TypedUser } from 'payload'\n\nimport { combineWhereConstraints } from 'payload/shared'\n\n/**\n * Recursively applies baseFilter from collection config to relationship fields\n * within blocks. This ensures that relationship drawers in blocks respect\n * collection-level filters like multi-tenant filtering.\n *\n * Based on the fix from PR #13229 for LinkFeature\n */\nexport function applyBaseFilterToFields(fields: Field[], config: SanitizedConfig): Field[] {\n return fields.map((field) => {\n // Handle relationship fields\n if (field.type === 'relationship') {\n const relationshipField = field\n\n // Store the original filterOptions\n const originalFilterOptions = relationshipField.filterOptions\n\n // Create new filterOptions that includes baseFilter\n relationshipField.filterOptions = async (args) => {\n const { relationTo, req, user } = args\n\n // Call original filterOptions if it exists\n const originalResult =\n typeof originalFilterOptions === 'function'\n ? await originalFilterOptions(args)\n : (originalFilterOptions ?? true)\n\n // If original filter returns false, respect that\n if (originalResult === false) {\n return false\n }\n\n // Get the collection's admin config\n const admin = config.collections.find(({ slug }) => slug === relationTo)?.admin\n\n // Check if collection is hidden\n const hidden = admin?.hidden\n if (typeof hidden === 'function' && hidden({ user } as { user: TypedUser })) {\n return false\n }\n\n // Apply baseFilter (with backwards compatibility for baseListFilter)\n const baseFilter = admin?.baseFilter ?? admin?.baseListFilter\n const baseFilterResult = await baseFilter?.({\n limit: 0,\n page: 1,\n req,\n sort: 'id',\n })\n\n // If no baseFilter, return original result\n if (!baseFilterResult) {\n return originalResult\n }\n\n // If original result is true, just return the baseFilter\n if (originalResult === true) {\n return baseFilterResult\n }\n\n // Combine original and baseFilter results\n return combineWhereConstraints([originalResult, baseFilterResult], 'and')\n }\n\n return relationshipField\n }\n\n // Recursively process nested fields\n if ('fields' in field && field.fields) {\n return {\n ...field,\n fields: applyBaseFilterToFields(field.fields, config),\n }\n }\n\n // Handle tabs\n if (field.type === 'tabs' && 'tabs' in field) {\n return {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: applyBaseFilterToFields(tab.fields, config),\n })),\n }\n }\n\n // Handle blocks\n if (field.type === 'blocks') {\n const blocks = (field.blockReferences ?? field.blocks ?? []) as Block[]\n return {\n ...field,\n blocks: blocks.map((block) => {\n if (typeof block === 'string') {\n return block\n }\n return {\n ...block,\n fields: applyBaseFilterToFields(block.fields, config),\n }\n }),\n }\n }\n\n return field\n })\n}\n"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ;AAExC;;;;;;;AAOA,OAAO,SAASC,wBAAwBC,MAAe,EAAEC,MAAuB;EAC9E,OAAOD,MAAA,CAAOE,GAAG,CAAEC,KAAA;IACjB;IACA,IAAIA,KAAA,CAAMC,IAAI,KAAK,gBAAgB;MACjC,MAAMC,iBAAA,GAAoBF,KAAA;MAE1B;MACA,MAAMG,qBAAA,GAAwBD,iBAAA,CAAkBE,aAAa;MAE7D;MACAF,iBAAA,CAAkBE,aAAa,GAAG,MAAOC,IAAA;QACvC,MAAM;UAAEC,UAAU;UAAEC,GAAG;UAAEC;QAAI,CAAE,GAAGH,IAAA;QAElC;QACA,MAAMI,cAAA,GACJ,OAAON,qBAAA,KAA0B,aAC7B,MAAMA,qBAAA,CAAsBE,IAAA,IAC3BF,qBAAA,IAAyB;QAEhC;QACA,IAAIM,cAAA,KAAmB,OAAO;UAC5B,OAAO;QACT;QAEA;QACA,MAAMC,KAAA,GAAQZ,MAAA,CAAOa,WAAW,CAACC,IAAI,CAAC,CAAC;UAAEC;QAAI,CAAE,KAAKA,IAAA,KAASP,UAAA,GAAaI,KAAA;QAE1E;QACA,MAAMI,MAAA,GAASJ,KAAA,EAAOI,MAAA;QACtB,IAAI,OAAOA,MAAA,KAAW,cAAcA,MAAA,CAAO;UAAEN;QAAK,IAA2B;UAC3E,OAAO;QACT;QAEA;QACA,MAAMO,UAAA,GAAaL,KAAA,EAAOK,UAAA,IAAcL,KAAA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ACF;IAEA,OAAOE,KAAA;EACT;AACF","ignoreList":[]}
1
+ {"version":3,"file":"applyBaseFilterToFields.js","names":["combineWhereConstraints","applyBaseFilterToFields","fields","config","map","field","type","relationshipField","originalFilterOptions","filterOptions","args","relationTo","req","user","originalResult","admin","collections","find","slug","hidden","baseFilter","baseListFilter","baseFilterResult","limit","page","sort","tabs","tab","blocks","block"],"sources":["../../src/utilities/applyBaseFilterToFields.ts"],"sourcesContent":["import type { Field, SanitizedConfig, TypedUser } from 'payload'\n\nimport { combineWhereConstraints } from 'payload/shared'\n\n/**\n * Recursively applies baseFilter from collection config to relationship fields\n * within blocks. This ensures that relationship drawers in blocks respect\n * collection-level filters like multi-tenant filtering.\n *\n * Based on the fix from PR #13229 for LinkFeature\n */\nexport function applyBaseFilterToFields(fields: Field[], config: SanitizedConfig): Field[] {\n return fields.map((field) => {\n // Handle relationship fields\n if (field.type === 'relationship') {\n const relationshipField = field\n\n // Store the original filterOptions\n const originalFilterOptions = relationshipField.filterOptions\n\n // Create new filterOptions that includes baseFilter\n relationshipField.filterOptions = async (args) => {\n const { relationTo, req, user } = args\n\n // Call original filterOptions if it exists\n const originalResult =\n typeof originalFilterOptions === 'function'\n ? await originalFilterOptions(args)\n : (originalFilterOptions ?? true)\n\n // If original filter returns false, respect that\n if (originalResult === false) {\n return false\n }\n\n // Get the collection's admin config\n const admin = config.collections.find(({ slug }) => slug === relationTo)?.admin\n\n // Check if collection is hidden\n const hidden = admin?.hidden\n if (typeof hidden === 'function' && hidden({ user } as { user: TypedUser })) {\n return false\n }\n\n // Apply baseFilter (with backwards compatibility for baseListFilter)\n const baseFilter = admin?.baseFilter ?? admin?.baseListFilter\n const baseFilterResult = await baseFilter?.({\n limit: 0,\n page: 1,\n req,\n sort: 'id',\n })\n\n // If no baseFilter, return original result\n if (!baseFilterResult) {\n return originalResult\n }\n\n // If original result is true, just return the baseFilter\n if (originalResult === true) {\n return baseFilterResult\n }\n\n // Combine original and baseFilter results\n return combineWhereConstraints([originalResult, baseFilterResult], 'and')\n }\n\n return relationshipField\n }\n\n // Recursively process nested fields\n if ('fields' in field && field.fields) {\n return {\n ...field,\n fields: applyBaseFilterToFields(field.fields, config),\n }\n }\n\n // Handle tabs\n if (field.type === 'tabs' && 'tabs' in field) {\n return {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: applyBaseFilterToFields(tab.fields, config),\n })),\n }\n }\n\n // Handle blocks\n if (field.type === 'blocks') {\n return {\n ...field,\n blocks: field.blocks.map((block) => {\n if (typeof block === 'string') {\n return block\n }\n return {\n ...block,\n fields: applyBaseFilterToFields(block.fields, config),\n }\n }),\n }\n }\n\n return field\n })\n}\n"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ;AAExC;;;;;;;AAOA,OAAO,SAASC,wBAAwBC,MAAe,EAAEC,MAAuB;EAC9E,OAAOD,MAAA,CAAOE,GAAG,CAAEC,KAAA;IACjB;IACA,IAAIA,KAAA,CAAMC,IAAI,KAAK,gBAAgB;MACjC,MAAMC,iBAAA,GAAoBF,KAAA;MAE1B;MACA,MAAMG,qBAAA,GAAwBD,iBAAA,CAAkBE,aAAa;MAE7D;MACAF,iBAAA,CAAkBE,aAAa,GAAG,MAAOC,IAAA;QACvC,MAAM;UAAEC,UAAU;UAAEC,GAAG;UAAEC;QAAI,CAAE,GAAGH,IAAA;QAElC;QACA,MAAMI,cAAA,GACJ,OAAON,qBAAA,KAA0B,aAC7B,MAAMA,qBAAA,CAAsBE,IAAA,IAC3BF,qBAAA,IAAyB;QAEhC;QACA,IAAIM,cAAA,KAAmB,OAAO;UAC5B,OAAO;QACT;QAEA;QACA,MAAMC,KAAA,GAAQZ,MAAA,CAAOa,WAAW,CAACC,IAAI,CAAC,CAAC;UAAEC;QAAI,CAAE,KAAKA,IAAA,KAASP,UAAA,GAAaI,KAAA;QAE1E;QACA,MAAMI,MAAA,GAASJ,KAAA,EAAOI,MAAA;QACtB,IAAI,OAAOA,MAAA,KAAW,cAAcA,MAAA,CAA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C,MAAA;UAChD;QACF;MACF;IACF;IAEA,OAAOE,KAAA;EACT;AACF","ignoreList":[]}
@@ -1,5 +1,10 @@
1
1
  import type { SerializedLexicalNode } from 'lexical';
2
2
  import type { DefaultNodeTypes, TypedEditorState } from '../types/nodeTypes.js';
3
+ /**
4
+ * The node union to build with. Accepts either a node union directly (e.g. `DefaultNodeTypes`) or a
5
+ * generated `richText` field type (e.g. `Post['richText']`), whose nodes are extracted automatically.
6
+ */
7
+ type BuildNodes<T> = NonNullable<T> extends TypedEditorState<infer TNode extends SerializedLexicalNode> ? TNode : Extract<NonNullable<T>, SerializedLexicalNode>;
3
8
  /**
4
9
  * Helper to build lexical editor state JSON from text and/or nodes.
5
10
  *
@@ -36,11 +41,19 @@ import type { DefaultNodeTypes, TypedEditorState } from '../types/nodeTypes.js';
36
41
  * ],
37
42
  * })
38
43
  * ```
44
+ *
45
+ * @example
46
+ *
47
+ * passing a generated `richText` field type — the result is exactly that field's type:
48
+ *
49
+ * ```ts
50
+ * post.richText = buildEditorState<Post['richText']>({ text: 'Hello world' })
51
+ * ```
39
52
  */
40
- export declare function buildEditorState<T extends SerializedLexicalNode>({ nodes, text, }: {
41
- nodes?: TypedEditorState<T>['root']['children'];
53
+ export declare function buildEditorState<T extends null | SerializedLexicalNode | TypedEditorState<SerializedLexicalNode> | undefined = DefaultNodeTypes>({ nodes, text, }: {
54
+ nodes?: TypedEditorState<BuildNodes<T>>['root']['children'];
42
55
  text?: string;
43
- }): TypedEditorState<T>;
56
+ }): TypedEditorState<BuildNodes<T>>;
44
57
  /**
45
58
  *
46
59
  * Alias for `buildEditorState<DefaultNodeTypes>`
@@ -49,4 +62,5 @@ export declare function buildEditorState<T extends SerializedLexicalNode>({ node
49
62
  * @internal
50
63
  */
51
64
  export declare const buildDefaultEditorState: typeof buildEditorState<DefaultNodeTypes>;
65
+ export {};
52
66
  //# sourceMappingURL=buildEditorState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,qBAAqB,EAAE,EAChE,KAAK,EACL,IAAI,GACL,EAAE;IACD,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAuDtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,gBAAgB,CAAC,gBAAgB,CAC1C,CAAA"}
1
+ {"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B;;;GAGG;AACH,KAAK,UAAU,CAAC,CAAC,IACf,WAAW,CAAC,CAAC,CAAC,SAAS,gBAAgB,CAAC,MAAM,KAAK,SAAS,qBAAqB,CAAC,GAC9E,KAAK,GACL,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,SACG,IAAI,GACJ,qBAAqB,GACrB,gBAAgB,CAAC,qBAAqB,CAAC,GACvC,SAAS,GAAG,gBAAgB,EAChC,EACA,KAAK,EACL,IAAI,GAC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