@payloadcms/richtext-lexical 4.0.0-internal.1f9ae9a → 4.0.0-internal.203916b

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 (531) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/cell/rscEntry.d.ts.map +1 -1
  3. package/dist/cell/rscEntry.js +5 -5
  4. package/dist/cell/rscEntry.js.map +1 -1
  5. package/dist/exports/client/Field-XH5C4HFU.js +2 -0
  6. package/dist/exports/client/Field-XH5C4HFU.js.map +7 -0
  7. package/dist/exports/client/{RelationshipComponent-RZL743CS.js → RelationshipComponent-YCPAKOL7.js} +1 -1
  8. package/dist/exports/client/RelationshipComponent-YCPAKOL7.js.map +7 -0
  9. package/dist/exports/client/bundled.css +1 -1
  10. package/dist/exports/client/chunk-5VIL27GI.js +2 -0
  11. package/dist/exports/client/chunk-5VIL27GI.js.map +7 -0
  12. package/dist/exports/client/chunk-ESITTE3C.js +2 -0
  13. package/dist/exports/client/chunk-ESITTE3C.js.map +7 -0
  14. package/dist/exports/client/chunk-UD4DQ4AK.js +2 -0
  15. package/dist/exports/client/chunk-UD4DQ4AK.js.map +7 -0
  16. package/dist/exports/client/chunk-X3D4LZS7.js +2 -0
  17. package/dist/exports/client/chunk-X3D4LZS7.js.map +7 -0
  18. package/dist/exports/client/{component-CVM4OESA.js → component-PHZQBOJE.js} +2 -2
  19. package/dist/exports/client/component-PHZQBOJE.js.map +7 -0
  20. package/dist/exports/client/componentInline-H24N7GUG.js +2 -0
  21. package/dist/exports/client/index.d.ts +0 -1
  22. package/dist/exports/client/index.d.ts.map +1 -1
  23. package/dist/exports/client/index.js +20 -21
  24. package/dist/exports/client/index.js.map +4 -4
  25. package/dist/features/blockquote/client/index.js +2 -2
  26. package/dist/features/blockquote/client/index.js.map +1 -1
  27. package/dist/features/blockquote/server/index.d.ts +1 -4
  28. package/dist/features/blockquote/server/index.d.ts.map +1 -1
  29. package/dist/features/blockquote/server/index.js +4 -2
  30. package/dist/features/blockquote/server/index.js.map +1 -1
  31. package/dist/features/blockquote/server/schema.d.ts +8 -0
  32. package/dist/features/blockquote/server/schema.d.ts.map +1 -0
  33. package/dist/features/blockquote/server/schema.js +15 -0
  34. package/dist/features/blockquote/server/schema.js.map +1 -0
  35. package/dist/features/blocks/client/component/index.css +2 -2
  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.css +8 -8
  41. package/dist/features/blocks/client/componentInline/index.d.ts +2 -1
  42. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  43. package/dist/features/blocks/client/componentInline/index.js +15 -7
  44. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  45. package/dist/features/blocks/client/index.d.ts.map +1 -1
  46. package/dist/features/blocks/client/index.js +4 -2
  47. package/dist/features/blocks/client/index.js.map +1 -1
  48. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +1 -1
  49. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -1
  50. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -1
  51. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
  52. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +1 -1
  53. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -1
  54. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +5 -2
  55. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -1
  56. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +1 -2
  57. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -1
  58. package/dist/features/blocks/client/markdown/markdownTransformer.js +4 -4
  59. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
  60. package/dist/features/blocks/client/nodes/BlocksNode.d.ts +1 -1
  61. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  62. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  63. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +1 -1
  64. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
  65. package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
  66. package/dist/features/blocks/client/plugin/index.d.ts +1 -1
  67. package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
  68. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  69. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -1
  70. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +1 -0
  71. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  72. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.css +1 -1
  73. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.css +2 -4
  74. package/dist/features/blocks/premade/CodeBlock/Component/index.css +5 -5
  75. package/dist/features/blocks/server/graphQLPopulationPromise.d.ts +1 -2
  76. package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
  77. package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
  78. package/dist/features/blocks/server/index.d.ts +1 -0
  79. package/dist/features/blocks/server/index.d.ts.map +1 -1
  80. package/dist/features/blocks/server/index.js +24 -72
  81. package/dist/features/blocks/server/index.js.map +1 -1
  82. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +1 -1
  83. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -1
  84. package/dist/features/blocks/server/markdown/markdownTransformer.js +4 -4
  85. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
  86. package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -18
  87. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  88. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  89. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +2 -10
  90. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
  91. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  92. package/dist/features/blocks/server/schema.d.ts +45 -0
  93. package/dist/features/blocks/server/schema.d.ts.map +1 -0
  94. package/dist/features/blocks/server/schema.js +140 -0
  95. package/dist/features/blocks/server/schema.js.map +1 -0
  96. package/dist/features/blocks/server/validate.d.ts +1 -2
  97. package/dist/features/blocks/server/validate.d.ts.map +1 -1
  98. package/dist/features/blocks/server/validate.js.map +1 -1
  99. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  100. package/dist/features/converters/lexicalToHtml/async/types.d.ts +14 -15
  101. package/dist/features/converters/lexicalToHtml/async/types.d.ts.map +1 -1
  102. package/dist/features/converters/lexicalToHtml/async/types.js.map +1 -1
  103. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  104. package/dist/features/converters/lexicalToHtml/sync/types.d.ts +14 -15
  105. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  106. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  107. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +4 -2
  108. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  109. package/dist/features/converters/lexicalToJSX/Component/index.js +5 -4
  110. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  111. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  112. package/dist/features/converters/lexicalToJSX/converter/types.d.ts +12 -14
  113. package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
  114. package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
  115. package/dist/features/converters/lexicalToMarkdown/index.d.ts.map +1 -1
  116. package/dist/features/converters/lexicalToMarkdown/index.js +1 -1
  117. package/dist/features/converters/lexicalToMarkdown/index.js.map +1 -1
  118. package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts +12 -14
  119. package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts.map +1 -1
  120. package/dist/features/converters/lexicalToPlaintext/sync/types.js.map +1 -1
  121. package/dist/features/converters/markdownToLexical/index.d.ts.map +1 -1
  122. package/dist/features/converters/markdownToLexical/index.js +5 -2
  123. package/dist/features/converters/markdownToLexical/index.js.map +1 -1
  124. package/dist/features/debug/jsxConverter/client/plugin/style.css +2 -2
  125. package/dist/features/experimental_table/client/index.js +2 -2
  126. package/dist/features/experimental_table/client/index.js.map +1 -1
  127. package/dist/features/experimental_table/markdownTransformer.d.ts +2 -2
  128. package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -1
  129. package/dist/features/experimental_table/markdownTransformer.js +6 -3
  130. package/dist/features/experimental_table/markdownTransformer.js.map +1 -1
  131. package/dist/features/experimental_table/server/index.d.ts +1 -6
  132. package/dist/features/experimental_table/server/index.d.ts.map +1 -1
  133. package/dist/features/experimental_table/server/index.js +6 -2
  134. package/dist/features/experimental_table/server/index.js.map +1 -1
  135. package/dist/features/experimental_table/server/schema.d.ts +27 -0
  136. package/dist/features/experimental_table/server/schema.d.ts.map +1 -0
  137. package/dist/features/experimental_table/server/schema.js +107 -0
  138. package/dist/features/experimental_table/server/schema.js.map +1 -0
  139. package/dist/features/format/bold/feature.client.js +1 -1
  140. package/dist/features/format/bold/feature.client.js.map +1 -1
  141. package/dist/features/format/bold/feature.server.d.ts.map +1 -1
  142. package/dist/features/format/bold/feature.server.js +1 -1
  143. package/dist/features/format/bold/feature.server.js.map +1 -1
  144. package/dist/features/format/inlineCode/feature.client.js +1 -1
  145. package/dist/features/format/inlineCode/feature.client.js.map +1 -1
  146. package/dist/features/format/inlineCode/feature.server.d.ts.map +1 -1
  147. package/dist/features/format/inlineCode/feature.server.js +1 -1
  148. package/dist/features/format/inlineCode/feature.server.js.map +1 -1
  149. package/dist/features/format/italic/feature.client.js +1 -1
  150. package/dist/features/format/italic/feature.client.js.map +1 -1
  151. package/dist/features/format/italic/feature.server.d.ts.map +1 -1
  152. package/dist/features/format/italic/feature.server.js +1 -1
  153. package/dist/features/format/italic/feature.server.js.map +1 -1
  154. package/dist/features/format/strikethrough/feature.client.js +1 -1
  155. package/dist/features/format/strikethrough/feature.client.js.map +1 -1
  156. package/dist/features/format/strikethrough/feature.server.d.ts.map +1 -1
  157. package/dist/features/format/strikethrough/feature.server.js +1 -1
  158. package/dist/features/format/strikethrough/feature.server.js.map +1 -1
  159. package/dist/features/heading/client/index.js +2 -2
  160. package/dist/features/heading/client/index.js.map +1 -1
  161. package/dist/features/heading/markdownTransformer.d.ts +2 -2
  162. package/dist/features/heading/markdownTransformer.d.ts.map +1 -1
  163. package/dist/features/heading/markdownTransformer.js +6 -19
  164. package/dist/features/heading/markdownTransformer.js.map +1 -1
  165. package/dist/features/heading/server/index.d.ts +2 -4
  166. package/dist/features/heading/server/index.d.ts.map +1 -1
  167. package/dist/features/heading/server/index.js +4 -2
  168. package/dist/features/heading/server/index.js.map +1 -1
  169. package/dist/features/heading/server/schema.d.ts +10 -0
  170. package/dist/features/heading/server/schema.d.ts.map +1 -0
  171. package/dist/features/heading/server/schema.js +37 -0
  172. package/dist/features/heading/server/schema.js.map +1 -0
  173. package/dist/features/horizontalRule/client/index.js +2 -2
  174. package/dist/features/horizontalRule/client/index.js.map +1 -1
  175. package/dist/features/horizontalRule/client/markdownTransformer.d.ts +2 -2
  176. package/dist/features/horizontalRule/client/markdownTransformer.d.ts.map +1 -1
  177. package/dist/features/horizontalRule/client/markdownTransformer.js +1 -1
  178. package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
  179. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +1 -1
  180. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  181. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  182. package/dist/features/horizontalRule/client/plugin/index.css +2 -2
  183. package/dist/features/horizontalRule/server/index.d.ts +1 -0
  184. package/dist/features/horizontalRule/server/index.d.ts.map +1 -1
  185. package/dist/features/horizontalRule/server/index.js +4 -2
  186. package/dist/features/horizontalRule/server/index.js.map +1 -1
  187. package/dist/features/horizontalRule/server/markdownTransformer.d.ts +2 -2
  188. package/dist/features/horizontalRule/server/markdownTransformer.d.ts.map +1 -1
  189. package/dist/features/horizontalRule/server/markdownTransformer.js +1 -1
  190. package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
  191. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +1 -5
  192. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
  193. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  194. package/dist/features/horizontalRule/server/schema.d.ts +7 -0
  195. package/dist/features/horizontalRule/server/schema.d.ts.map +1 -0
  196. package/dist/features/horizontalRule/server/schema.js +25 -0
  197. package/dist/features/horizontalRule/server/schema.js.map +1 -0
  198. package/dist/features/link/client/index.d.ts.map +1 -1
  199. package/dist/features/link/client/index.js +2 -2
  200. package/dist/features/link/client/index.js.map +1 -1
  201. package/dist/features/link/client/plugins/autoLink/index.d.ts +1 -1
  202. package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
  203. package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
  204. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +3 -3
  205. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  206. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +7 -11
  207. package/dist/features/link/client/plugins/floatingLinkEditor/types.d.ts +1 -1
  208. package/dist/features/link/client/plugins/floatingLinkEditor/types.d.ts.map +1 -1
  209. package/dist/features/link/client/plugins/floatingLinkEditor/types.js.map +1 -1
  210. package/dist/features/link/client/plugins/link/index.js.map +1 -1
  211. package/dist/features/link/markdownTransformer.d.ts +5 -5
  212. package/dist/features/link/markdownTransformer.d.ts.map +1 -1
  213. package/dist/features/link/markdownTransformer.js +2 -2
  214. package/dist/features/link/markdownTransformer.js.map +1 -1
  215. package/dist/features/link/markdownTransformer.spec.js +10 -10
  216. package/dist/features/link/markdownTransformer.spec.js.map +1 -1
  217. package/dist/features/link/nodes/AutoLinkNode.d.ts +3 -3
  218. package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  219. package/dist/features/link/nodes/AutoLinkNode.js +2 -1
  220. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  221. package/dist/features/link/nodes/LinkNode.d.ts +3 -3
  222. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  223. package/dist/features/link/nodes/LinkNode.js +2 -1
  224. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  225. package/dist/features/link/server/baseFields.js.map +1 -1
  226. package/dist/features/link/server/graphQLPopulationPromise.d.ts +1 -1
  227. package/dist/features/link/server/graphQLPopulationPromise.d.ts.map +1 -1
  228. package/dist/features/link/server/graphQLPopulationPromise.js.map +1 -1
  229. package/dist/features/link/server/index.d.ts +2 -1
  230. package/dist/features/link/server/index.d.ts.map +1 -1
  231. package/dist/features/link/server/index.js +5 -2
  232. package/dist/features/link/server/index.js.map +1 -1
  233. package/dist/features/link/server/schema.d.ts +32 -0
  234. package/dist/features/link/server/schema.d.ts.map +1 -0
  235. package/dist/features/link/server/schema.js +171 -0
  236. package/dist/features/link/server/schema.js.map +1 -0
  237. package/dist/features/link/server/validate.d.ts +1 -1
  238. package/dist/features/link/server/validate.d.ts.map +1 -1
  239. package/dist/features/link/server/validate.js.map +1 -1
  240. package/dist/features/lists/checklist/client/index.js +1 -1
  241. package/dist/features/lists/checklist/client/index.js.map +1 -1
  242. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  243. package/dist/features/lists/checklist/server/index.js +4 -1
  244. package/dist/features/lists/checklist/server/index.js.map +1 -1
  245. package/dist/features/lists/orderedList/client/index.js +1 -1
  246. package/dist/features/lists/orderedList/client/index.js.map +1 -1
  247. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  248. package/dist/features/lists/orderedList/server/index.js +4 -1
  249. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  250. package/dist/features/lists/plugin/index.d.ts +0 -9
  251. package/dist/features/lists/plugin/index.d.ts.map +1 -1
  252. package/dist/features/lists/plugin/index.js.map +1 -1
  253. package/dist/features/lists/shared/schema.d.ts +18 -0
  254. package/dist/features/lists/shared/schema.d.ts.map +1 -0
  255. package/dist/features/lists/shared/schema.js +62 -0
  256. package/dist/features/lists/shared/schema.js.map +1 -0
  257. package/dist/features/lists/unorderedList/client/index.js +1 -1
  258. package/dist/features/lists/unorderedList/client/index.js.map +1 -1
  259. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  260. package/dist/features/lists/unorderedList/server/index.js +4 -1
  261. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  262. package/dist/features/relationship/client/components/RelationshipComponent.d.ts +1 -1
  263. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  264. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  265. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
  266. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  267. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  268. package/dist/features/relationship/client/plugins/index.d.ts +1 -1
  269. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  270. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  271. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  272. package/dist/features/relationship/client/utils/useEnabledRelationships.js +9 -40
  273. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  274. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +1 -1
  275. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  276. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  277. package/dist/features/relationship/server/index.d.ts +1 -0
  278. package/dist/features/relationship/server/index.d.ts.map +1 -1
  279. package/dist/features/relationship/server/index.js +2 -0
  280. package/dist/features/relationship/server/index.js.map +1 -1
  281. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -10
  282. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  283. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  284. package/dist/features/relationship/server/schema.d.ts +28 -0
  285. package/dist/features/relationship/server/schema.d.ts.map +1 -0
  286. package/dist/features/relationship/server/schema.js +97 -0
  287. package/dist/features/relationship/server/schema.js.map +1 -0
  288. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +23 -0
  289. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -0
  290. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +34 -0
  291. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -0
  292. package/dist/features/textState/feature.client.js +1 -1
  293. package/dist/features/textState/feature.client.js.map +1 -1
  294. package/dist/features/toolbars/fixed/client/Toolbar/index.css +2 -2
  295. package/dist/features/toolbars/inline/client/Toolbar/index.css +2 -13
  296. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +8 -12
  297. package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -1
  298. package/dist/features/toolbars/shared/useToolbarStates.js +3 -1
  299. package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -1
  300. package/dist/features/typesClient.d.ts +1 -1
  301. package/dist/features/typesClient.d.ts.map +1 -1
  302. package/dist/features/typesClient.js.map +1 -1
  303. package/dist/features/typesServer.d.ts +18 -41
  304. package/dist/features/typesServer.d.ts.map +1 -1
  305. package/dist/features/typesServer.js.map +1 -1
  306. package/dist/features/upload/client/component/index.css +11 -11
  307. package/dist/features/upload/client/component/index.d.ts +1 -1
  308. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  309. package/dist/features/upload/client/component/index.js.map +1 -1
  310. package/dist/features/upload/client/nodes/UploadNode.d.ts +1 -1
  311. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  312. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  313. package/dist/features/upload/client/plugin/index.d.ts +1 -1
  314. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  315. package/dist/features/upload/client/plugin/index.js +5 -5
  316. package/dist/features/upload/client/plugin/index.js.map +1 -1
  317. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +1 -1
  318. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  319. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  320. package/dist/features/upload/server/index.d.ts +1 -0
  321. package/dist/features/upload/server/index.d.ts.map +1 -1
  322. package/dist/features/upload/server/index.js +5 -4
  323. package/dist/features/upload/server/index.js.map +1 -1
  324. package/dist/features/upload/server/markdownTransformer.d.ts +2 -2
  325. package/dist/features/upload/server/markdownTransformer.d.ts.map +1 -1
  326. package/dist/features/upload/server/markdownTransformer.js +1 -1
  327. package/dist/features/upload/server/markdownTransformer.js.map +1 -1
  328. package/dist/features/upload/server/nodes/UploadNode.d.ts +1 -55
  329. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  330. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  331. package/dist/features/upload/server/nodes/conversions.d.ts.map +1 -1
  332. package/dist/features/upload/server/nodes/conversions.js.map +1 -1
  333. package/dist/features/upload/server/schema.d.ts +52 -0
  334. package/dist/features/upload/server/schema.d.ts.map +1 -0
  335. package/dist/features/upload/server/schema.js +149 -0
  336. package/dist/features/upload/server/schema.js.map +1 -0
  337. package/dist/features/upload/server/validate.d.ts +1 -1
  338. package/dist/features/upload/server/validate.d.ts.map +1 -1
  339. package/dist/features/upload/server/validate.js.map +1 -1
  340. package/dist/field/Diff/converters/unknown/index.css +1 -1
  341. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  342. package/dist/field/Field.js +1 -1
  343. package/dist/field/Field.js.map +1 -1
  344. package/dist/field/ViewSelector.css +1 -1
  345. package/dist/field/bundled.css +1 -1
  346. package/dist/field/index.css +5 -5
  347. package/dist/field/index.js +1 -1
  348. package/dist/field/index.js.map +1 -1
  349. package/dist/field/rscEntry.d.ts.map +1 -1
  350. package/dist/field/rscEntry.js +2 -0
  351. package/dist/field/rscEntry.js.map +1 -1
  352. package/dist/index.d.ts +10 -7
  353. package/dist/index.d.ts.map +1 -1
  354. package/dist/index.js +3 -3
  355. package/dist/index.js.map +1 -1
  356. package/dist/lexical/LexicalEditor.css +2 -2
  357. package/dist/lexical/config/client/loader.d.ts.map +1 -1
  358. package/dist/lexical/config/client/loader.js +5 -1
  359. package/dist/lexical/config/client/loader.js.map +1 -1
  360. package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
  361. package/dist/lexical/config/server/sanitize.js +9 -11
  362. package/dist/lexical/config/server/sanitize.js.map +1 -1
  363. package/dist/lexical/plugins/DecoratorPlugin/index.css +1 -1
  364. package/dist/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  365. package/dist/lexical/plugins/MarkdownShortcut/index.js +1 -1
  366. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  367. package/dist/lexical/plugins/SlashMenu/index.css +1 -5
  368. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -1
  369. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +3 -3
  370. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +1 -1
  371. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  372. package/dist/lexical/theme/EditorTheme.css +18 -19
  373. package/dist/lexical/ui/ContentEditable.css +5 -5
  374. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts +17 -0
  375. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts.map +1 -0
  376. package/dist/lexical/utils/markdown/convertFromMarkdownString.js +27 -0
  377. package/dist/lexical/utils/markdown/convertFromMarkdownString.js.map +1 -0
  378. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js +88 -0
  379. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js.map +1 -0
  380. package/dist/lexical/utils/markdown/createBlockNode.d.ts +1 -1
  381. package/dist/lexical/utils/markdown/createBlockNode.d.ts.map +1 -1
  382. package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
  383. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts +25 -0
  384. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts.map +1 -0
  385. package/dist/lexical/utils/markdown/normalizeMarkdown.js +91 -0
  386. package/dist/lexical/utils/markdown/normalizeMarkdown.js.map +1 -0
  387. package/dist/lexical-proxy/@lexical-markdown.d.ts +1 -1
  388. package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
  389. package/dist/lexical-proxy/@lexical-markdown.js +1 -1
  390. package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
  391. package/dist/types/builtInNodes.d.ts +14 -0
  392. package/dist/types/builtInNodes.d.ts.map +1 -0
  393. package/dist/types/builtInNodes.js +203 -0
  394. package/dist/types/builtInNodes.js.map +1 -0
  395. package/dist/types/index.d.ts +16 -17
  396. package/dist/types/index.d.ts.map +1 -1
  397. package/dist/types/index.js.map +1 -1
  398. package/dist/types/jsonSchemaHelpers.d.ts +30 -0
  399. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -0
  400. package/dist/types/jsonSchemaHelpers.js +58 -0
  401. package/dist/types/jsonSchemaHelpers.js.map +1 -0
  402. package/dist/types/nodeTypes.d.ts +115 -61
  403. package/dist/types/nodeTypes.d.ts.map +1 -1
  404. package/dist/types/nodeTypes.js +3 -2
  405. package/dist/types/nodeTypes.js.map +1 -1
  406. package/dist/types/schema.d.ts.map +1 -1
  407. package/dist/types/schema.js +74 -65
  408. package/dist/types/schema.js.map +1 -1
  409. package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
  410. package/dist/utilities/applyBaseFilterToFields.js +1 -2
  411. package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
  412. package/dist/utilities/buildEditorState.d.ts +17 -3
  413. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  414. package/dist/utilities/buildEditorState.js +8 -0
  415. package/dist/utilities/buildEditorState.js.map +1 -1
  416. package/dist/utilities/buildInitialState.d.ts +2 -1
  417. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  418. package/dist/utilities/buildInitialState.js.map +1 -1
  419. package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
  420. package/dist/utilities/fieldsDrawer/Drawer.js +19 -10
  421. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  422. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts +4 -1
  423. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  424. package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -7
  425. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  426. package/dist/utilities/fieldsDrawer/index.css +12 -0
  427. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts +29 -0
  428. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts.map +1 -0
  429. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js +97 -0
  430. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -0
  431. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +1 -1
  432. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
  433. package/package.json +22 -26
  434. package/dist/exports/client/Field-G5Z2HM5Y.js +0 -2
  435. package/dist/exports/client/Field-G5Z2HM5Y.js.map +0 -7
  436. package/dist/exports/client/RelationshipComponent-RZL743CS.js.map +0 -7
  437. package/dist/exports/client/chunk-6QWQ7JV4.js +0 -2
  438. package/dist/exports/client/chunk-6QWQ7JV4.js.map +0 -7
  439. package/dist/exports/client/chunk-FEJXFRL7.js +0 -2
  440. package/dist/exports/client/chunk-FEJXFRL7.js.map +0 -7
  441. package/dist/exports/client/chunk-INBEEENE.js +0 -2
  442. package/dist/exports/client/chunk-INBEEENE.js.map +0 -7
  443. package/dist/exports/client/chunk-LH634DPU.js +0 -12
  444. package/dist/exports/client/chunk-LH634DPU.js.map +0 -7
  445. package/dist/exports/client/component-CVM4OESA.js.map +0 -7
  446. package/dist/exports/client/componentInline-JJZ2NKW2.js +0 -2
  447. package/dist/features/blockquote/markdownTransformer.d.ts +0 -3
  448. package/dist/features/blockquote/markdownTransformer.d.ts.map +0 -1
  449. package/dist/features/blockquote/markdownTransformer.js +0 -33
  450. package/dist/features/blockquote/markdownTransformer.js.map +0 -1
  451. package/dist/features/format/bold/markdownTransformers.d.ts +0 -6
  452. package/dist/features/format/bold/markdownTransformers.d.ts.map +0 -1
  453. package/dist/features/format/bold/markdownTransformers.js +0 -23
  454. package/dist/features/format/bold/markdownTransformers.js.map +0 -1
  455. package/dist/features/format/inlineCode/markdownTransformers.d.ts +0 -3
  456. package/dist/features/format/inlineCode/markdownTransformers.d.ts.map +0 -1
  457. package/dist/features/format/inlineCode/markdownTransformers.js +0 -6
  458. package/dist/features/format/inlineCode/markdownTransformers.js.map +0 -1
  459. package/dist/features/format/italic/markdownTransformers.d.ts +0 -4
  460. package/dist/features/format/italic/markdownTransformers.d.ts.map +0 -1
  461. package/dist/features/format/italic/markdownTransformers.js +0 -12
  462. package/dist/features/format/italic/markdownTransformers.js.map +0 -1
  463. package/dist/features/format/strikethrough/markdownTransformers.d.ts +0 -3
  464. package/dist/features/format/strikethrough/markdownTransformers.d.ts.map +0 -1
  465. package/dist/features/format/strikethrough/markdownTransformers.js +0 -6
  466. package/dist/features/format/strikethrough/markdownTransformers.js.map +0 -1
  467. package/dist/features/link/nodes/types.d.ts +0 -27
  468. package/dist/features/link/nodes/types.d.ts.map +0 -1
  469. package/dist/features/link/nodes/types.js +0 -2
  470. package/dist/features/link/nodes/types.js.map +0 -1
  471. package/dist/features/lists/checklist/markdownTransformers.d.ts +0 -3
  472. package/dist/features/lists/checklist/markdownTransformers.d.ts.map +0 -1
  473. package/dist/features/lists/checklist/markdownTransformers.js +0 -12
  474. package/dist/features/lists/checklist/markdownTransformers.js.map +0 -1
  475. package/dist/features/lists/orderedList/markdownTransformer.d.ts +0 -3
  476. package/dist/features/lists/orderedList/markdownTransformer.d.ts.map +0 -1
  477. package/dist/features/lists/orderedList/markdownTransformer.js +0 -12
  478. package/dist/features/lists/orderedList/markdownTransformer.js.map +0 -1
  479. package/dist/features/lists/shared/markdown.d.ts +0 -6
  480. package/dist/features/lists/shared/markdown.d.ts.map +0 -1
  481. package/dist/features/lists/shared/markdown.js +0 -57
  482. package/dist/features/lists/shared/markdown.js.map +0 -1
  483. package/dist/features/lists/unorderedList/markdownTransformer.d.ts +0 -3
  484. package/dist/features/lists/unorderedList/markdownTransformer.d.ts.map +0 -1
  485. package/dist/features/lists/unorderedList/markdownTransformer.js +0 -12
  486. package/dist/features/lists/unorderedList/markdownTransformer.js.map +0 -1
  487. package/dist/lexical/utils/guard.d.ts +0 -5
  488. package/dist/lexical/utils/guard.d.ts.map +0 -1
  489. package/dist/lexical/utils/guard.js +0 -9
  490. package/dist/lexical/utils/guard.js.map +0 -1
  491. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +0 -2
  492. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +0 -1
  493. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +0 -2
  494. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +0 -1
  495. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +0 -14
  496. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +0 -1
  497. package/dist/packages/@lexical/markdown/MarkdownExport.js +0 -213
  498. package/dist/packages/@lexical/markdown/MarkdownExport.js.map +0 -1
  499. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +0 -19
  500. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +0 -1
  501. package/dist/packages/@lexical/markdown/MarkdownImport.js +0 -198
  502. package/dist/packages/@lexical/markdown/MarkdownImport.js.map +0 -1
  503. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +0 -11
  504. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +0 -1
  505. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +0 -304
  506. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +0 -1
  507. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +0 -147
  508. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +0 -1
  509. package/dist/packages/@lexical/markdown/MarkdownTransformers.js +0 -268
  510. package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +0 -1
  511. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +0 -22
  512. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +0 -1
  513. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +0 -91
  514. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +0 -1
  515. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +0 -21
  516. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +0 -1
  517. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +0 -54
  518. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +0 -1
  519. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +0 -18
  520. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +0 -1
  521. package/dist/packages/@lexical/markdown/importTextTransformers.js +0 -54
  522. package/dist/packages/@lexical/markdown/importTextTransformers.js.map +0 -1
  523. package/dist/packages/@lexical/markdown/index.d.ts +0 -29
  524. package/dist/packages/@lexical/markdown/index.d.ts.map +0 -1
  525. package/dist/packages/@lexical/markdown/index.js +0 -39
  526. package/dist/packages/@lexical/markdown/index.js.map +0 -1
  527. package/dist/packages/@lexical/markdown/utils.d.ts +0 -34
  528. package/dist/packages/@lexical/markdown/utils.d.ts.map +0 -1
  529. package/dist/packages/@lexical/markdown/utils.js +0 -267
  530. package/dist/packages/@lexical/markdown/utils.js.map +0 -1
  531. /package/dist/exports/client/{componentInline-JJZ2NKW2.js.map → componentInline-H24N7GUG.js.map} +0 -0
@@ -0,0 +1,58 @@
1
+ /** `format` property shared by every element node (Lexical `ElementFormatType`). */export const formatSchema = {
2
+ type: 'string',
3
+ description: 'How this element is aligned. Empty string means no explicit alignment.',
4
+ enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''],
5
+ tsType: 'LexicalElementFormat'
6
+ };
7
+ /** `direction` property shared by every element node. */
8
+ export const directionSchema = {
9
+ oneOf: [{
10
+ type: 'string',
11
+ enum: ['ltr', 'rtl']
12
+ }, {
13
+ type: 'null'
14
+ }],
15
+ tsType: 'LexicalElementDirection'
16
+ };
17
+ /** `version` property shared by every Lexical node. */
18
+ export const versionSchema = {
19
+ type: 'integer',
20
+ description: "Lexical's internal serialization version for this node type."
21
+ };
22
+ /**
23
+ * Builds the JSON Schema for a Lexical element node - merges the shared
24
+ * element-base shape (children/direction/format/indent/version) with the
25
+ * node-specific bits a feature provides.
26
+ */
27
+ export const elementNodeSchema = ({
28
+ nodeType,
29
+ nodeUnionRef,
30
+ properties = {},
31
+ required = [],
32
+ tsType
33
+ }) => ({
34
+ type: 'object',
35
+ additionalProperties: false,
36
+ properties: {
37
+ type: {
38
+ type: 'string',
39
+ const: nodeType
40
+ },
41
+ children: {
42
+ type: 'array',
43
+ items: nodeUnionRef
44
+ },
45
+ direction: directionSchema,
46
+ format: formatSchema,
47
+ indent: {
48
+ type: 'integer'
49
+ },
50
+ version: versionSchema,
51
+ ...properties
52
+ },
53
+ required: ['children', 'direction', 'format', 'indent', 'type', 'version', ...required],
54
+ ...(tsType ? {
55
+ tsType
56
+ } : {})
57
+ });
58
+ //# sourceMappingURL=jsonSchemaHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonSchemaHelpers.js","names":["formatSchema","type","description","enum","tsType","directionSchema","oneOf","versionSchema","elementNodeSchema","nodeType","nodeUnionRef","properties","required","additionalProperties","const","children","items","direction","format","indent","version"],"sources":["../../src/types/jsonSchemaHelpers.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\n/** `format` property shared by every element node (Lexical `ElementFormatType`). */\nexport const formatSchema: JSONSchema4 = {\n type: 'string',\n description: 'How this element is aligned. Empty string means no explicit alignment.',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''],\n tsType: 'LexicalElementFormat',\n}\n\n/** `direction` property shared by every element node. */\nexport const directionSchema: JSONSchema4 = {\n oneOf: [{ type: 'string', enum: ['ltr', 'rtl'] }, { type: 'null' }],\n tsType: 'LexicalElementDirection',\n}\n\n/** `version` property shared by every Lexical node. */\nexport const versionSchema: JSONSchema4 = {\n type: 'integer',\n description: \"Lexical's internal serialization version for this node type.\",\n}\n\ntype ElementNodeSchemaOptions = {\n nodeType: string\n properties?: { [k: string]: JSONSchema4 }\n required?: string[]\n /** TS helper-type expression — emitted verbatim by json-schema-to-typescript. */\n tsType?: string\n}\n\n/**\n * Builds the JSON Schema for a Lexical element node - merges the shared\n * element-base shape (children/direction/format/indent/version) with the\n * node-specific bits a feature provides.\n */\nexport const elementNodeSchema = ({\n nodeType,\n nodeUnionRef,\n properties = {},\n required = [],\n tsType,\n}: { nodeUnionRef: JSONSchema4 } & ElementNodeSchemaOptions): JSONSchema4 => ({\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', const: nodeType },\n children: { type: 'array', items: nodeUnionRef },\n direction: directionSchema,\n format: formatSchema,\n indent: { type: 'integer' },\n version: versionSchema,\n ...properties,\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version', ...required],\n ...(tsType ? { tsType } : {}),\n})\n\n/**\n * `elementNodeSchema` HOC type, so that features don't have to pass `nodeUnionRef` every time.\n */\nexport type ElementNodeSchemaFn = (opts: ElementNodeSchemaOptions) => JSONSchema4\n"],"mappings":"AAEA,oFACA,OAAO,MAAMA,YAAA,GAA4B;EACvCC,IAAA,EAAM;EACNC,WAAA,EAAa;EACbC,IAAA,EAAM,CAAC,QAAQ,SAAS,UAAU,SAAS,OAAO,WAAW,GAAG;EAChEC,MAAA,EAAQ;AACV;AAEA;AACA,OAAO,MAAMC,eAAA,GAA+B;EAC1CC,KAAA,EAAO,CAAC;IAAEL,IAAA,EAAM;IAAUE,IAAA,EAAM,CAAC,OAAO;EAAO,GAAG;IAAEF,IAAA,EAAM;EAAO,EAAE;EACnEG,MAAA,EAAQ;AACV;AAEA;AACA,OAAO,MAAMG,aAAA,GAA6B;EACxCN,IAAA,EAAM;EACNC,WAAA,EAAa;AACf;AAUA;;;;;AAKA,OAAO,MAAMM,iBAAA,GAAoBA,CAAC;EAChCC,QAAQ;EACRC,YAAY;EACZC,UAAA,GAAa,CAAC,CAAC;EACfC,QAAA,GAAW,EAAE;EACbR;AAAM,CACmD,MAAmB;EAC5EH,IAAA,EAAM;EACNY,oBAAA,EAAsB;EACtBF,UAAA,EAAY;IACVV,IAAA,EAAM;MAAEA,IAAA,EAAM;MAAUa,KAAA,EAAOL;IAAS;IACxCM,QAAA,EAAU;MAAEd,IAAA,EAAM;MAASe,KAAA,EAAON;IAAa;IAC/CO,SAAA,EAAWZ,eAAA;IACXa,MAAA,EAAQlB,YAAA;IACRmB,MAAA,EAAQ;MAAElB,IAAA,EAAM;IAAU;IAC1BmB,OAAA,EAASb,aAAA;IACT,GAAGI;EACL;EACAC,QAAA,EAAU,CAAC,YAAY,aAAa,UAAU,UAAU,QAAQ,W,GAAcA,QAAA,CAAS;EACvF,IAAIR,MAAA,GAAS;IAAEA;EAAO,IAAI,CAAC,CAAC;AAC9B","ignoreList":[]}
@@ -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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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,CA+FxC,CAAA"}
@@ -1,4 +1,14 @@
1
- import { withNullableJSONSchemaType } from 'payload';
1
+ import { createHash } from 'crypto';
2
+ import { CORE_LEXICAL_TYPE_STRING, lineBreakNodeJSONSchema, paragraphNodeJSONSchema, rootNodeJSONSchema, tabNodeJSONSchema, textNodeJSONSchema } from './builtInNodes.js';
3
+ import { elementNodeSchema } from './jsonSchemaHelpers.js';
4
+ /**
5
+ * The node-union name is a hash of its own schema (so identical editors dedupe).
6
+ * Since the schema references the union name, we use a placeholder during build
7
+ * and substitute the real hash once everything's assembled. Features can derive
8
+ * sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.
9
+ */
10
+ const NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__';
11
+ const NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`;
2
12
  export const getFieldToJSONSchema = ({
3
13
  editorConfig
4
14
  }) => {
@@ -8,74 +18,73 @@ export const getFieldToJSONSchema = ({
8
18
  field,
9
19
  i18n,
10
20
  interfaceNameDefinitions,
11
- isRequired
21
+ typeStringDefinitions,
22
+ variant = 'output'
12
23
  }) => {
13
- let jsonSchema = {
14
- // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.
15
- // In the future, we should
16
- // 1) allow recursive children
17
- // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.
18
- type: withNullableJSONSchemaType('object', isRequired),
19
- properties: {
20
- root: {
21
- type: 'object',
22
- additionalProperties: false,
23
- properties: {
24
- type: {
25
- type: 'string'
26
- },
27
- children: {
28
- type: 'array',
29
- items: {
30
- type: 'object',
31
- additionalProperties: true,
32
- properties: {
33
- type: {
34
- type: 'string',
35
- tsType: 'any'
36
- },
37
- version: {
38
- type: 'integer'
39
- }
40
- },
41
- required: ['type', 'version']
42
- }
43
- },
44
- direction: {
45
- oneOf: [{
46
- enum: ['ltr', 'rtl']
47
- }, {
48
- type: 'null'
49
- }]
50
- },
51
- format: {
52
- type: 'string',
53
- enum: ['left', 'start', 'center', 'right', 'end', 'justify', '']
54
- },
55
- indent: {
56
- type: 'integer'
57
- },
58
- version: {
59
- type: 'integer'
60
- }
61
- },
62
- required: ['children', 'direction', 'format', 'indent', 'type', 'version']
24
+ // Step 1: build the schema for every node type allowed in this field.
25
+ typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING);
26
+ const nodeJsonSchemaArgs = {
27
+ collectionIDFieldTypes,
28
+ config,
29
+ // Each element node needs its children typed using the union node type recursively
30
+ elementNodeSchema: args => elementNodeSchema({
31
+ ...args,
32
+ nodeUnionRef: {
33
+ $ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`
63
34
  }
64
- },
65
- required: ['root']
35
+ }),
36
+ field,
37
+ i18n,
38
+ interfaceNameDefinitions,
39
+ nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,
40
+ typeStringDefinitions,
41
+ variant
66
42
  };
67
- for (const modifyJSONSchema of editorConfig.features.generatedTypes.modifyJSONSchemas) {
68
- jsonSchema = modifyJSONSchema({
69
- collectionIDFieldTypes,
70
- config,
71
- currentSchema: jsonSchema,
72
- field,
73
- i18n,
74
- interfaceNameDefinitions,
75
- isRequired
76
- });
43
+ const nodeSchemas = [
44
+ // Add built-in node schemas
45
+ textNodeJSONSchema(nodeJsonSchemaArgs), tabNodeJSONSchema(nodeJsonSchemaArgs), lineBreakNodeJSONSchema(nodeJsonSchemaArgs), paragraphNodeJSONSchema(nodeJsonSchemaArgs),
46
+ // Add feature node schemas
47
+ ...editorConfig.features.nodes.filter(node => node.jsonSchema).map(node => node.jsonSchema(nodeJsonSchemaArgs))];
48
+ const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs);
49
+ // Step 2: get the final node union name, then replace the placeholder
50
+ // in both the union members and the root node.
51
+ //
52
+ // See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.
53
+ const nodeUnionJson = JSON.stringify({
54
+ oneOf: nodeSchemas
55
+ });
56
+ // Features can register per-editor definitions during node-schema build (e.g. a link node's
57
+ // custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node
58
+ // union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same
59
+ // nodes but different feature config (e.g. different custom link fields) would otherwise hash
60
+ // identically and overwrite each other's definition. To avoid that, include that content into the hash too.
61
+ const pendingDefinitions = [...interfaceNameDefinitions.entries()].filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER)).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
62
+ const hashInput = pendingDefinitions.length ? JSON.stringify({
63
+ definitions: pendingDefinitions,
64
+ oneOf: nodeSchemas
65
+ }) : nodeUnionJson;
66
+ const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase();
67
+ // Distinguish an input node union from an output one with an `_Input` suffix - unless an
68
+ // identical output union already exists (a relationship-free editor whose input == output), in
69
+ // which case share it. The content hash means differing unions split and identical ones merge.
70
+ const sharesOutputUnion = variant === 'input' && interfaceNameDefinitions.has(`LexicalNodes_${hash}`);
71
+ const resolvedHash = variant === 'input' && !sharesOutputUnion ? `${hash}_Input` : hash;
72
+ const nodeUnionName = `LexicalNodes_${resolvedHash}`;
73
+ // Replacing the hash resolves the union name and any feature-derived
74
+ // sibling names in one pass.
75
+ const replacePlaceholder = schemaString => JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, resolvedHash));
76
+ // Resolve placeholders left in feature-registered definitions so Map keys
77
+ // and `$ref` targets line up.
78
+ for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {
79
+ const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, resolvedHash);
80
+ const resolvedSchema = replacePlaceholder(JSON.stringify(schema));
81
+ if (newKey !== oldKey) {
82
+ interfaceNameDefinitions.delete(oldKey);
83
+ }
84
+ interfaceNameDefinitions.set(newKey, resolvedSchema);
77
85
  }
78
- return jsonSchema;
86
+ interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson));
87
+ return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder));
79
88
  };
80
89
  };
81
90
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":["withNullableJSONSchemaType","getFieldToJSONSchema","editorConfig","collectionIDFieldTypes","config","field","i18n","interfaceNameDefinitions","isRequired","jsonSchema","type","properties","root","additionalProperties","children","items","tsType","version","required","direction","oneOf","enum","format","indent","modifyJSONSchema","features","generatedTypes","modifyJSONSchemas","currentSchema"],"sources":["../../src/types/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { withNullableJSONSchemaType } from 'payload'\n\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextAdapter } from './index.js'\n\nexport const getFieldToJSONSchema: (args: {\n editorConfig: SanitizedServerEditorConfig\n}) => LexicalRichTextAdapter['jsonSchema'] = ({ editorConfig }) => {\n return ({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n }) => {\n let jsonSchema: JSONSchema4 = {\n // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.\n // In the future, we should\n // 1) allow recursive children\n // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.\n type: withNullableJSONSchemaType('object', isRequired),\n properties: {\n root: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: {\n type: 'string',\n },\n children: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: true,\n properties: {\n type: {\n type: 'string',\n tsType: 'any',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['type', 'version'],\n },\n },\n direction: {\n oneOf: [\n {\n enum: ['ltr', 'rtl'],\n },\n {\n type: 'null',\n },\n ],\n },\n format: {\n type: 'string',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''], // ElementFormatType, since the root node is an element\n },\n indent: {\n type: 'integer',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version'],\n },\n },\n required: ['root'],\n }\n for (const modifyJSONSchema of editorConfig.features.generatedTypes.modifyJSONSchemas) {\n jsonSchema = modifyJSONSchema({\n collectionIDFieldTypes,\n config,\n currentSchema: jsonSchema,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n })\n }\n\n return jsonSchema\n }\n}\n"],"mappings":"AAEA,SAASA,0BAA0B,QAAQ;AAK3C,OAAO,MAAMC,oBAAA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ACfJ,KAAA;QACAC,IAAA;QACAC,wBAAA;QACAC;MACF;IACF;IAEA,OAAOC,UAAA;EACT;AACF","ignoreList":[]}
1
+ {"version":3,"file":"schema.js","names":["createHash","CORE_LEXICAL_TYPE_STRING","lineBreakNodeJSONSchema","paragraphNodeJSONSchema","rootNodeJSONSchema","tabNodeJSONSchema","textNodeJSONSchema","elementNodeSchema","NODE_UNION_HASH_PLACEHOLDER","NODE_UNION_NAME_PLACEHOLDER","getFieldToJSONSchema","editorConfig","collectionIDFieldTypes","config","field","i18n","interfaceNameDefinitions","typeStringDefinitions","variant","add","nodeJsonSchemaArgs","args","nodeUnionRef","$ref","nodeUnionName","nodeSchemas","features","nodes","filter","node","jsonSchema","map","rootSchemaWithPlaceholder","nodeUnionJson","JSON","stringify","oneOf","pendingDefinitions","entries","key","includes","sort","a","b","hashInput","length","definitions","hash","update","digest","slice","toUpperCase","sharesOutputUnion","has","resolvedHash","replacePlaceholder","schemaString","parse","replaceAll","oldKey","schema","newKey","resolvedSchema","delete","set"],"sources":["../../src/types/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { createHash } from 'crypto'\n\nimport type { JSONSchemaArgs } from '../features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextAdapter } from './index.js'\n\nimport {\n CORE_LEXICAL_TYPE_STRING,\n lineBreakNodeJSONSchema,\n paragraphNodeJSONSchema,\n rootNodeJSONSchema,\n tabNodeJSONSchema,\n textNodeJSONSchema,\n} from './builtInNodes.js'\nimport { elementNodeSchema } from './jsonSchemaHelpers.js'\n\n/**\n * The node-union name is a hash of its own schema (so identical editors dedupe).\n * Since the schema references the union name, we use a placeholder during build\n * and substitute the real hash once everything's assembled. Features can derive\n * sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.\n */\nconst NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__'\nconst NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`\n\nexport const getFieldToJSONSchema: (args: {\n editorConfig: SanitizedServerEditorConfig\n}) => LexicalRichTextAdapter['jsonSchema'] = ({ editorConfig }) => {\n return ({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n typeStringDefinitions,\n variant = 'output',\n }) => {\n // Step 1: build the schema for every node type allowed in this field.\n\n typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING)\n\n const nodeJsonSchemaArgs: JSONSchemaArgs = {\n collectionIDFieldTypes,\n config,\n // Each element node needs its children typed using the union node type recursively\n elementNodeSchema: (args) =>\n elementNodeSchema({\n ...args,\n nodeUnionRef: {\n $ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`,\n },\n }),\n field,\n i18n,\n interfaceNameDefinitions,\n nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,\n typeStringDefinitions,\n variant,\n }\n\n const nodeSchemas: JSONSchema4[] = [\n // Add built-in node schemas\n textNodeJSONSchema(nodeJsonSchemaArgs),\n tabNodeJSONSchema(nodeJsonSchemaArgs),\n lineBreakNodeJSONSchema(nodeJsonSchemaArgs),\n paragraphNodeJSONSchema(nodeJsonSchemaArgs),\n // Add feature node schemas\n ...editorConfig.features.nodes\n .filter((node) => node.jsonSchema)\n .map((node) => node.jsonSchema!(nodeJsonSchemaArgs)),\n ]\n const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs)\n\n // Step 2: get the final node union name, then replace the placeholder\n // in both the union members and the root node.\n //\n // See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.\n const nodeUnionJson = JSON.stringify({ oneOf: nodeSchemas })\n\n // Features can register per-editor definitions during node-schema build (e.g. a link node's\n // custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node\n // union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same\n // nodes but different feature config (e.g. different custom link fields) would otherwise hash\n // identically and overwrite each other's definition. To avoid that, include that content into the hash too.\n const pendingDefinitions = [...interfaceNameDefinitions.entries()]\n .filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER))\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n\n const hashInput = pendingDefinitions.length\n ? JSON.stringify({ definitions: pendingDefinitions, oneOf: nodeSchemas })\n : nodeUnionJson\n\n const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase()\n\n // Distinguish an input node union from an output one with an `_Input` suffix - unless an\n // identical output union already exists (a relationship-free editor whose input == output), in\n // which case share it. The content hash means differing unions split and identical ones merge.\n const sharesOutputUnion =\n variant === 'input' && interfaceNameDefinitions.has(`LexicalNodes_${hash}`)\n const resolvedHash = variant === 'input' && !sharesOutputUnion ? `${hash}_Input` : hash\n const nodeUnionName = `LexicalNodes_${resolvedHash}`\n\n // Replacing the hash resolves the union name and any feature-derived\n // sibling names in one pass.\n const replacePlaceholder = (schemaString: string) =>\n JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, resolvedHash)) as JSONSchema4\n\n // Resolve placeholders left in feature-registered definitions so Map keys\n // and `$ref` targets line up.\n for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {\n const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, resolvedHash)\n const resolvedSchema = replacePlaceholder(JSON.stringify(schema))\n if (newKey !== oldKey) {\n interfaceNameDefinitions.delete(oldKey)\n }\n interfaceNameDefinitions.set(newKey, resolvedSchema)\n }\n\n interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson))\n\n return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder))\n }\n}\n"],"mappings":"AAEA,SAASA,UAAU,QAAQ;AAM3B,SACEC,wBAAwB,EACxBC,uBAAuB,EACvBC,uBAAuB,EACvBC,kBAAkB,EAClBC,iBAAiB,EACjBC,kBAAkB,QACb;AACP,SAASC,iBAAiB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AAA,CAAyBgD,GAAG,CAACH,MAAA,EAAQC,cAAA;IACvC;IAEA9C,wBAAA,CAAyBgD,GAAG,CAACxC,aAAA,EAAe+B,kBAAA,CAAmBtB,aAAA;IAE/D,OAAOsB,kBAAA,CAAmBrB,IAAA,CAAKC,SAAS,CAACH,yBAAA;EAC3C;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAIvE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,CAiGzF"}
1
+ {"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAQ,MAAM,SAAS,CAAA;AAI3D;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,CAgGzF"}
@@ -77,10 +77,9 @@ export function applyBaseFilterToFields(fields, config) {
77
77
  }
78
78
  // Handle blocks
79
79
  if (field.type === 'blocks') {
80
- const blocks = field.blockReferences ?? field.blocks ?? [];
81
80
  return {
82
81
  ...field,
83
- blocks: blocks.map(block => {
82
+ blocks: field.blocks.map(block => {
84
83
  if (typeof block === 'string') {
85
84
  return block;
86
85
  }