@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
@@ -10,7 +10,7 @@ import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js';
10
10
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
11
11
  import { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical';
12
12
  import * as React from 'react';
13
- import { useEffect, useState } from 'react';
13
+ import { useCallback, useEffect, useState } from 'react';
14
14
  import { useEditorConfigContext } from './config/client/EditorConfigProvider.js';
15
15
  import './LexicalEditor.css';
16
16
  import { EditorPlugin } from './EditorPlugin.js';
@@ -26,6 +26,40 @@ import { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js';
26
26
  import { SlashMenuPlugin } from './plugins/SlashMenu/index.js';
27
27
  import { TextPlugin } from './plugins/TextPlugin/index.js';
28
28
  import { LexicalContentEditable } from './ui/ContentEditable.js';
29
+ /**
30
+ * Marks the Lexical root element with `data-lexical-editable` once the editor
31
+ * is mounted and interactive. Tests can query this attribute to confirm that
32
+ * React event handlers are attached and keyboard input will be processed.
33
+ */
34
+ function EditorReadyPlugin() {
35
+ const $ = _c(3);
36
+ const [editor] = useLexicalComposerContext();
37
+ let t0;
38
+ let t1;
39
+ if ($[0] !== editor) {
40
+ t0 = () => {
41
+ const root = editor.getRootElement();
42
+ if (root) {
43
+ root.dataset.lexicalEditable = String(editor.isEditable());
44
+ }
45
+ return editor.registerEditableListener(editable => {
46
+ const el = editor.getRootElement();
47
+ if (el) {
48
+ el.dataset.lexicalEditable = String(editable);
49
+ }
50
+ });
51
+ };
52
+ t1 = [editor];
53
+ $[0] = editor;
54
+ $[1] = t0;
55
+ $[2] = t1;
56
+ } else {
57
+ t0 = $[1];
58
+ t1 = $[2];
59
+ }
60
+ useEffect(t0, t1);
61
+ return null;
62
+ }
29
63
  export const LexicalEditor = props => {
30
64
  const $ = _c(13);
31
65
  const {
@@ -111,7 +145,7 @@ export const LexicalEditor = props => {
111
145
  })
112
146
  }),
113
147
  ErrorBoundary: LexicalErrorBoundary
114
- }), _jsx(NormalizeSelectionPlugin, {}), isEditable && _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(ClipboardPlugin, {}), _jsx(TextPlugin, {
148
+ }), _jsx(EditorReadyPlugin, {}), _jsx(NormalizeSelectionPlugin, {}), isEditable && _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(ClipboardPlugin, {}), _jsx(TextPlugin, {
115
149
  features: editorConfig.features
116
150
  }), _jsx(SelectAllPlugin, {}), _jsx(NodeViewOverridePlugin, {}), isEditable && _jsx(OnChangePlugin, {
117
151
  ignoreSelectionChange: true,
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","ClipboardPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NodeViewOverridePlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","rtl","editorConfigContext","editor","isEditable","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","_jsxs","Fragment","children","features","plugins","map","_temp","className","dir","undefined","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","editorState","editor_0","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport './LexicalEditor.css'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport { ClipboardPlugin } from './plugins/ClipboardPlugin/index.js'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NodeViewOverridePlugin } from './plugins/NodeViewOverridePlugin/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange' | 'rtl'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange, rtl } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" dir={rtl ? 'rtl' : undefined} ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <ClipboardPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n <NodeViewOverridePlugin />\n {isEditable && (\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n )}\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && isEditable && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {isEditable && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {isEditable && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,a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IAAA,OACfd,IAAA,CAAA3D,YAAA;MAAA2E,WAAA,EAA2BH,MAAA,CAAAG,WAAA;MAAAH;IAAA,GAAyBA,MAAA,CAAAI,GAAU;EAAA;AAAA;AA3D3E,SAAAlB,OAAAwB,QAAA;EAAA,IAgEUV,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBd,IAAA,CAAA3D,YAAA;MAAA2E,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAlExE,SAAAG,OAAAI,QAAA;EAAA,IAgJUX,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBd,IAAA,CAAA3D,YAAA;MAAA2E,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAlJxE,SAAAI,OAAAI,QAAA;EAAA,IAuJUZ,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBd,IAAA,CAAA3D,YAAA;MAAA2E,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAzJxE,SAAAK,OAAAI,QAAA;EAAA,IA+JQb,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfd,IAAA,CAAA3D,YAAA;MAAA2E,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useCallback","useEffect","useState","useEditorConfigContext","EditorPlugin","ClipboardPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NodeViewOverridePlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","EditorReadyPlugin","$","editor","t0","t1","root","getRootElement","dataset","lexicalEditable","String","isEditable","registerEditableListener","editable","el","LexicalEditor","props","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","rtl","editorConfigContext","floatingAnchorElem","setFloatingAnchorElem","Symbol","for","_floatingAnchorElem","onRef","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","_jsxs","Fragment","children","features","plugins","map","_temp","className","dir","undefined","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","editorState","editor_0","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport './LexicalEditor.css'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport { ClipboardPlugin } from './plugins/ClipboardPlugin/index.js'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NodeViewOverridePlugin } from './plugins/NodeViewOverridePlugin/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\n/**\n * Marks the Lexical root element with `data-lexical-editable` once the editor\n * is mounted and interactive. Tests can query this attribute to confirm that\n * React event handlers are attached and keyboard input will be processed.\n */\nfunction EditorReadyPlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n const root = editor.getRootElement()\n if (root) {\n root.dataset.lexicalEditable = String(editor.isEditable())\n }\n return editor.registerEditableListener((editable) => {\n const el = editor.getRootElement()\n if (el) {\n el.dataset.lexicalEditable = String(editable)\n }\n })\n }, [editor])\n\n return null\n}\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange' | 'rtl'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange, rtl } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = useCallback((_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }, [])\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" dir={rtl ? 'rtl' : undefined} ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <EditorReadyPlugin />\n <NormalizeSelectionPlugin />\n {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <ClipboardPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n <NodeViewOverridePlugin />\n {isEditable && (\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n )}\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && isEditable && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {isEditable && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {isEditable && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAy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,8 @@ export const LexicalProvider = props => {
47
47
  const parentContext = useEditorConfigContext();
48
48
  const editDepth = useEditDepth();
49
49
  const editorContainerRef = React.useRef(null);
50
- // useMemo for the initialConfig that depends on readOnly and value
50
+ // useMemo for the initialConfig. `readOnly` and `value` are intentionally excluded from deps
51
+ // to avoid full remounts on every save (which would destroy cursor position and undo history).
51
52
  const initialConfig = useMemo(() => {
52
53
  if (value && typeof value !== 'object') {
53
54
  throw new Error('The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' + JSON.stringify(value));
@@ -76,16 +77,30 @@ export const LexicalProvider = props => {
76
77
  // Important: do not add readOnly and value to the dependencies array. This will cause the entire lexical editor to re-render if the document is saved, which will
77
78
  // cause the editor to lose focus.
78
79
  }, [editorConfig, views, currentView]);
79
- if (!initialConfig) {
80
+ // Track whether the editor has ever been editable. Once it transitions to editable,
81
+ // we never remount due to transient readOnly changes (e.g. during form save processing).
82
+ const hasBeenEditable = React.useRef(readOnly !== true);
83
+ if (readOnly !== true) {
84
+ hasBeenEditable.current = true;
85
+ }
86
+ // Compute the effective editable state for the config.
87
+ // Override the memoized config's editable value to reflect the current readOnly prop.
88
+ const effectiveConfig = useMemo(() => ({
89
+ ...initialConfig,
90
+ editable: readOnly !== true
91
+ }), [initialConfig, readOnly]);
92
+ if (!effectiveConfig) {
80
93
  return /*#__PURE__*/_jsx("p", {
81
94
  children: "Loading..."
82
95
  });
83
96
  }
84
- // We need to add initialConfig.editable to the key to force a re-render when the readOnly prop changes.
85
- // Without it, there were cases where lexical editors inside drawers turn readOnly initially - a few miliseconds later they turn editable, but the editor does not re-render and stays readOnly.
86
- // We also add currentView to force re-render when the view changes.
97
+ // Use `hasBeenEditable` to build the key: only force a remount when the editor has NEVER
98
+ // been editable and transitions to editable for the first time. After that, LexicalComposer
99
+ // stays mounted (preserving cursor/focus/undo) and we rely on Lexical's internal
100
+ // `editor.setEditable()` for transient readOnly changes during saves.
101
+ const editableKey = hasBeenEditable.current ? 'editable' : 'readonly';
87
102
  return /*#__PURE__*/_jsx(LexicalComposer, {
88
- initialConfig: initialConfig,
103
+ initialConfig: effectiveConfig,
89
104
  children: /*#__PURE__*/_jsx(EditorConfigProvider, {
90
105
  editorConfig: editorConfig,
91
106
  editorContainerRef: editorContainerRef,
@@ -105,6 +120,6 @@ export const LexicalProvider = props => {
105
120
  })
106
121
  })
107
122
  })
108
- }, composerKey + initialConfig.editable + currentView);
123
+ }, composerKey + editableKey + currentView);
109
124
  };
110
125
  //# sourceMappingURL=LexicalProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalProvider.js","names":["LexicalComposer","useEditDepth","React","useMemo","useRichTextView","EditorConfigProvider","useEditorConfigContext","LexicalEditor","LexicalEditorComponent","getEnabledNodes","NestProviders","children","providers","length","Component","_jsx","slice","LexicalProvider","props","composerKey","editorConfig","fieldProps","isSmallWidthViewport","onChange","readOnly","rtl","value","currentView","views","parentContext","editDepth","editorContainerRef","useRef","initialConfig","Error","JSON","stringify","Array","isArray","nodeViews","nodes","editable","editorState","undefined","namespace","lexical","onError","error","theme","features"],"sources":["../../src/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { EditorState, LexicalEditor, SerializedEditorState } from 'lexical'\n\nimport { LexicalComposer } from '@lexical/react/LexicalComposer.js'\nimport { useEditDepth } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../types/index.js'\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { useRichTextView } from '../field/RichTextViewProvider.js'\nimport {\n EditorConfigProvider,\n useEditorConfigContext,\n} from './config/client/EditorConfigProvider.js'\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n composerKey: string\n editorConfig: SanitizedClientEditorConfig\n fieldProps: LexicalRichTextFieldProps\n isSmallWidthViewport: boolean\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n readOnly: boolean\n rtl?: boolean\n value: SerializedEditorState\n}\n\nconst NestProviders = ({\n children,\n providers,\n}: {\n children: React.ReactNode\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n providers: any[]\n}) => {\n if (!providers?.length) {\n return children\n }\n const Component = providers[0]\n if (providers.length > 1) {\n return (\n <Component>\n <NestProviders providers={providers.slice(1)}>{children}</NestProviders>\n </Component>\n )\n }\n return <Component>{children}</Component>\n}\n\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const {\n composerKey,\n editorConfig,\n fieldProps,\n isSmallWidthViewport,\n onChange,\n readOnly,\n rtl,\n value,\n } = props\n\n const { currentView, views } = useRichTextView()\n\n const parentContext = useEditorConfigContext()\n\n const editDepth = useEditDepth()\n\n const editorContainerRef = React.useRef<HTMLDivElement>(null)\n\n // useMemo for the initialConfig that depends on readOnly and value\n const initialConfig = useMemo<InitialConfigType>(() => {\n if (value && typeof value !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n 'You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical',\n )\n }\n\n // Use the 'default' view if available, otherwise undefined\n const nodeViews = views?.[currentView]?.nodes\n\n return {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: getEnabledNodes({\n editorConfig,\n nodeViews,\n }),\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n // Important: do not add readOnly and value to the dependencies array. This will cause the entire lexical editor to re-render if the document is saved, which will\n // cause the editor to lose focus.\n }, [editorConfig, views, currentView])\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n // We need to add initialConfig.editable to the key to force a re-render when the readOnly prop changes.\n // Without it, there were cases where lexical editors inside drawers turn readOnly initially - a few miliseconds later they turn editable, but the editor does not re-render and stays readOnly.\n // We also add currentView to force re-render when the view changes.\n return (\n <LexicalComposer\n initialConfig={initialConfig}\n key={composerKey + initialConfig.editable + currentView}\n >\n <EditorConfigProvider\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n fieldProps={fieldProps}\n /**\n * Parent editor is not truly the parent editor, if the current editor is part of a drawer and the parent editor is the main editor.\n */\n parentContext={parentContext?.editDepth === editDepth ? parentContext : undefined}\n >\n <NestProviders providers={editorConfig.features.providers}>\n <LexicalEditorComponent\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n isSmallWidthViewport={isSmallWidthViewport}\n onChange={onChange}\n rtl={rtl}\n />\n </NestProviders>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAC7B,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AAKxB,SAASC,eAAe,QAAQ;AAChC,SACEC,oBAAoB,EACpBC,sBAAsB,QACjB;AACP,SAASC,aAAA,IAAiBC,sBAAsB,QAAQ;AACxD,SAASC,eAAe,QAAQ;AAahC,MAAMC,aAAA,GAAgBA,CAAC;EACrBC,QAAQ;EACRC;AAAS,CAKV;EACC,IAAI,CAACA,SAAA,EAAWC,MAAA,EAAQ;IACtB,OAAOF,QAAA;EACT;EACA,MAAMG,SAAA,GAAYF,SAAS,CAAC,EAAE;EAC9B,IAAIA,SAAA,CAAU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gB;QACrBW,YAAA;QACAmB;MACF;MACAO,OAAA,EAAUC,KAAA;QACR,MAAMA,KAAA;MACR;MACAC,KAAA,EAAO5B,YAAA,CAAayB,OAAO,CAACG;IAC9B;IACA;IACA;EACF,GAAG,CAAC5B,YAAA,EAAcQ,KAAA,EAAOD,WAAA,CAAY;EAErC,IAAI,CAACM,aAAA,EAAe;IAClB,oBAAOlB,IAAA,CAAC;gBAAE;;EACZ;EAEA;EACA;EACA;EACA,oBACEA,IAAA,CAACf,eAAA;IACCiC,aAAA,EAAeA,aAAA;cAGf,aAAAlB,IAAA,CAACV,oBAAA;MACCe,YAAA,EAAcA,YAAA;MACdW,kBAAA,EAAoBA,kBAAA;MACpBV,UAAA,EAAYA,UAAA;MACZ;;;MAGAQ,aAAA,EAAeA,aAAA,EAAeC,SAAA,KAAcA,SAAA,GAAYD,aAAA,GAAgBc,SAAA;gBAExE,aAAA5B,IAAA,CAACL,aAAA;QAAcE,SAAA,EAAWQ,YAAA,CAAa6B,QAAQ,CAACrC,SAAS;kBACvD,aAAAG,IAAA,CAACP,sBAAA;UACCY,YAAA,EAAcA,YAAA;UACdW,kBAAA,EAAoBA,kBAAA;UACpBT,oBAAA,EAAsBA,oBAAA;UACtBC,QAAA,EAAUA,QAAA;UACVE,GAAA,EAAKA;;;;KAjBNN,WAAA,GAAcc,aAAA,CAAcQ,QAAQ,GAAGd,WAAA;AAuBlD","ignoreList":[]}
1
+ {"version":3,"file":"LexicalProvider.js","names":["LexicalComposer","useEditDepth","React","useMemo","useRichTextView","EditorConfigProvider","useEditorConfigContext","LexicalEditor","LexicalEditorComponent","getEnabledNodes","NestProviders","children","providers","length","Component","_jsx","slice","LexicalProvider","props","composerKey","editorConfig","fieldProps","isSmallWidthViewport","onChange","readOnly","rtl","value","currentView","views","parentContext","editDepth","editorContainerRef","useRef","initialConfig","Error","JSON","stringify","Array","isArray","nodeViews","nodes","editable","editorState","undefined","namespace","lexical","onError","error","theme","hasBeenEditable","current","effectiveConfig","editableKey","features"],"sources":["../../src/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { EditorState, LexicalEditor, SerializedEditorState } from 'lexical'\n\nimport { LexicalComposer } from '@lexical/react/LexicalComposer.js'\nimport { useEditDepth } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../types/index.js'\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { useRichTextView } from '../field/RichTextViewProvider.js'\nimport {\n EditorConfigProvider,\n useEditorConfigContext,\n} from './config/client/EditorConfigProvider.js'\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n composerKey: string\n editorConfig: SanitizedClientEditorConfig\n fieldProps: LexicalRichTextFieldProps\n isSmallWidthViewport: boolean\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n readOnly: boolean\n rtl?: boolean\n value: SerializedEditorState\n}\n\nconst NestProviders = ({\n children,\n providers,\n}: {\n children: React.ReactNode\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n providers: any[]\n}) => {\n if (!providers?.length) {\n return children\n }\n const Component = providers[0]\n if (providers.length > 1) {\n return (\n <Component>\n <NestProviders providers={providers.slice(1)}>{children}</NestProviders>\n </Component>\n )\n }\n return <Component>{children}</Component>\n}\n\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const {\n composerKey,\n editorConfig,\n fieldProps,\n isSmallWidthViewport,\n onChange,\n readOnly,\n rtl,\n value,\n } = props\n\n const { currentView, views } = useRichTextView()\n\n const parentContext = useEditorConfigContext()\n\n const editDepth = useEditDepth()\n\n const editorContainerRef = React.useRef<HTMLDivElement>(null)\n\n // useMemo for the initialConfig. `readOnly` and `value` are intentionally excluded from deps\n // to avoid full remounts on every save (which would destroy cursor position and undo history).\n const initialConfig = useMemo<InitialConfigType>(() => {\n if (value && typeof value !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n 'You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical',\n )\n }\n\n // Use the 'default' view if available, otherwise undefined\n const nodeViews = views?.[currentView]?.nodes\n\n return {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: getEnabledNodes({\n editorConfig,\n nodeViews,\n }),\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n // Important: do not add readOnly and value to the dependencies array. This will cause the entire lexical editor to re-render if the document is saved, which will\n // cause the editor to lose focus.\n }, [editorConfig, views, currentView])\n\n // Track whether the editor has ever been editable. Once it transitions to editable,\n // we never remount due to transient readOnly changes (e.g. during form save processing).\n const hasBeenEditable = React.useRef(readOnly !== true)\n if (readOnly !== true) {\n hasBeenEditable.current = true\n }\n\n // Compute the effective editable state for the config.\n // Override the memoized config's editable value to reflect the current readOnly prop.\n const effectiveConfig = useMemo<InitialConfigType>(\n () => ({\n ...initialConfig,\n editable: readOnly !== true,\n }),\n\n [initialConfig, readOnly],\n )\n\n if (!effectiveConfig) {\n return <p>Loading...</p>\n }\n\n // Use `hasBeenEditable` to build the key: only force a remount when the editor has NEVER\n // been editable and transitions to editable for the first time. After that, LexicalComposer\n // stays mounted (preserving cursor/focus/undo) and we rely on Lexical's internal\n // `editor.setEditable()` for transient readOnly changes during saves.\n const editableKey = hasBeenEditable.current ? 'editable' : 'readonly'\n return (\n <LexicalComposer initialConfig={effectiveConfig} key={composerKey + editableKey + currentView}>\n <EditorConfigProvider\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n fieldProps={fieldProps}\n /**\n * Parent editor is not truly the parent editor, if the current editor is part of a drawer and the parent editor is the main editor.\n */\n parentContext={parentContext?.editDepth === editDepth ? parentContext : undefined}\n >\n <NestProviders providers={editorConfig.features.providers}>\n <LexicalEditorComponent\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n isSmallWidthViewport={isSmallWidthViewport}\n onChange={onChange}\n rtl={rtl}\n />\n </NestProviders>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAC7B,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AAKxB,SAASC,eAAe,QAAQ;AAChC,SACEC,oBAAoB,EACpBC,sBAAsB,QACjB;AACP,SAASC,aAAA,IAAiBC,sBAAsB,QAAQ;AACxD,SAASC,eAAe,QAAQ;AAahC,MAAMC,aAAA,GAAgBA,CAAC;EACrBC,QAAQ;EACRC;AAAS,CAKV;EACC,IAAI,CAACA,SAAA,EAAWC,MAAA,EAAQ;IACtB,OAAOF,QAAA;EACT;EACA,MAAMG,SAAA,GAAYF,SAAS,CAAC,EAAE;EAC9B,IAAIA,SAAA,CAAUC,MAAM,GAAG,GAAG;IACxB,oBACEE,IAAA,CAACD,SAAA;gBACC,aAAAC,IAAA,CAACL,aAAA;QAAcE,SAAA,EAAWA,SAAA,CAAUI,KAAK,CAAC;kBAAKL;;;EAGrD;EACA,oBAAOI,IAAA,CAACD,SAAA;cAAWH;;AACrB;AAEA,OAAO,MAAMM,eAAA,GAAmDC,KAAA;EAC9D,MAAM;IACJC,WAAW;IACXC,YAAY;IACZC,UAAU;IACVC,oBAAoB;IACpBC,QAAQ;IAC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IACrByB,eAAA,CAAgBC,OAAO,GAAG;EAC5B;EAEA;EACA;EACA,MAAMC,eAAA,GAAkBhD,OAAA,CACtB,OAAO;IACL,GAAG8B,aAAa;IAChBQ,QAAA,EAAUjB,QAAA,KAAa;EACzB,IAEA,CAACS,aAAA,EAAeT,QAAA,CAAS;EAG3B,IAAI,CAAC2B,eAAA,EAAiB;IACpB,oBAAOpC,IAAA,CAAC;gBAAE;;EACZ;EAEA;EACA;EACA;EACA;EACA,MAAMqC,WAAA,GAAcH,eAAA,CAAgBC,OAAO,GAAG,aAAa;EAC3D,oBACEnC,IAAA,CAACf,eAAA;IAAgBiC,aAAA,EAAekB,eAAA;cAC9B,aAAApC,IAAA,CAACV,oBAAA;MACCe,YAAA,EAAcA,YAAA;MACdW,kBAAA,EAAoBA,kBAAA;MACpBV,UAAA,EAAYA,UAAA;MACZ;;;MAGAQ,aAAA,EAAeA,aAAA,EAAeC,SAAA,KAAcA,SAAA,GAAYD,aAAA,GAAgBc,SAAA;gBAExE,aAAA5B,IAAA,CAACL,aAAA;QAAcE,SAAA,EAAWQ,YAAA,CAAaiC,QAAQ,CAACzC,SAAS;kBACvD,aAAAG,IAAA,CAACP,sBAAA;UACCY,YAAA,EAAcA,YAAA;UACdW,kBAAA,EAAoBA,kBAAA;UACpBT,oBAAA,EAAsBA,oBAAA;UACtBC,QAAA,EAAUA,QAAA;UACVE,GAAA,EAAKA;;;;KAhByCN,WAAA,GAAciC,WAAA,GAAczB,WAAA;AAsBtF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/client/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAEhE,OAAO,KAAK,EAGV,wBAAwB,EACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,EACL,UAAU,EACV,uBAAuB,GACxB,EAAE;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3C,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,KAAK,CAAC,EAAE,mBAAmB,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,uBAAuB,EAAE,kBAAkB,CAAA;CAC5C,GAAG,wBAAwB,CAoD3B"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/client/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAEhE,OAAO,KAAK,EAGV,wBAAwB,EACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,EACL,UAAU,EACV,uBAAuB,GACxB,EAAE;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3C,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,KAAK,CAAC,EAAE,mBAAmB,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,uBAAuB,EAAE,kBAAkB,CAAA;CAC5C,GAAG,wBAAwB,CA0D3B"}
@@ -13,12 +13,16 @@ export function loadClientFeatures({
13
13
  unSanitizedEditorConfig
14
14
  }) {
15
15
  const featureProviderMap = new Map();
16
+ const validFeatures = [];
16
17
  for (const featureProvider of unSanitizedEditorConfig.features) {
17
18
  if (!featureProvider?.clientFeatureProps?.featureKey || featureProvider?.clientFeatureProps?.order === undefined || featureProvider?.clientFeatureProps?.order === null) {
18
- throw new Error('A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.');
19
+ console.warn('A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected. Skipping feature.');
20
+ continue;
19
21
  }
20
22
  featureProviderMap.set(featureProvider.clientFeatureProps.featureKey, featureProvider);
23
+ validFeatures.push(featureProvider);
21
24
  }
25
+ unSanitizedEditorConfig.features = validFeatures;
22
26
  // sort unSanitizedEditorConfig.features by order
23
27
  unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.sort((a, b) => a.clientFeatureProps.order - b.clientFeatureProps.order);
24
28
  const resolvedFeatures = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","names":["loadClientFeatures","config","featureClientImportMap","featureClientSchemaMap","field","schemaPath","unSanitizedEditorConfig","featureProviderMap","Map","featureProvider","features","clientFeatureProps","featureKey","order","undefined","Error","set","sort","a","b","resolvedFeatures","loaded","feature","key"],"sources":["../../../../src/lexical/config/client/loader.ts"],"sourcesContent":["'use client'\n\nimport type { ClientConfig, RichTextFieldClient } from 'payload'\n\nimport type {\n ClientFeatureProviderMap,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n} from '../../../features/typesClient.js'\nimport type { FeatureClientSchemaMap } from '../../../types/index.js'\nimport type { ClientEditorConfig } from '../types.js'\n\n/**\n * This function expects client functions to ALREADY be ordered & dependencies checked on the server\n * @param unSanitizedEditorConfig\n */\nexport function loadClientFeatures({\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n field,\n schemaPath,\n unSanitizedEditorConfig,\n}: {\n config: ClientConfig\n featureClientImportMap: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n field?: RichTextFieldClient\n schemaPath: string\n unSanitizedEditorConfig: ClientEditorConfig\n}): ResolvedClientFeatureMap {\n const featureProviderMap: ClientFeatureProviderMap = new Map()\n\n for (const featureProvider of unSanitizedEditorConfig.features) {\n if (\n !featureProvider?.clientFeatureProps?.featureKey ||\n featureProvider?.clientFeatureProps?.order === undefined ||\n featureProvider?.clientFeatureProps?.order === null\n ) {\n throw new Error(\n 'A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.',\n )\n }\n featureProviderMap.set(featureProvider.clientFeatureProps.featureKey, featureProvider)\n }\n\n // sort unSanitizedEditorConfig.features by order\n unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.sort(\n (a, b) => a.clientFeatureProps.order - b.clientFeatureProps.order,\n )\n\n const resolvedFeatures: ResolvedClientFeatureMap = new Map()\n\n // Make sure all dependencies declared in the respective features exist\n let loaded = 0\n for (const featureProvider of unSanitizedEditorConfig.features) {\n const feature: Partial<ResolvedClientFeature<any>> =\n typeof featureProvider.feature === 'function'\n ? featureProvider.feature({\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n featureProviderMap,\n field,\n resolvedFeatures,\n schemaPath,\n unSanitizedEditorConfig,\n })\n : featureProvider.feature\n\n feature.key = featureProvider.clientFeatureProps.featureKey\n feature.order = loaded\n\n resolvedFeatures.set(\n featureProvider.clientFeatureProps.featureKey,\n feature as ResolvedClientFeature<any>,\n )\n\n loaded++\n }\n\n return resolvedFeatures\n}\n"],"mappings":"AAAA;;AAYA;;;;AAIA,OAAO,SAASA,mBAAmB;EACjCC,MAAM;EACNC,sBAAsB;EACtBC,sBAAsB;EACtBC,KAAK;EACLC,UAAU;EACVC;AAAuB,CAQxB;EACC,MAAMC,kBAAA,GAA+C,IAAIC,GAAA;EAEzD,KAAK,MAAMC,eAAA,IAAmBH,uBAAA,CAAwBI,QAAQ,EAAE;IAC9D,IACE,CAACD,eAAA,EAAiBE,kBAAA,EAAoBC,UAAA,IACtCH,eAAA,EAAiBE,kBAAA,EAAoBE,KAAA,KAAUC,SAAA,IAC/CL,eAAA,EAAiBE,kBAAA,EAAoBE,KAAA,KAAU,MAC/C;MACA,MAAM,IAAIE,KAAA,CACR;IAEJ;IACAR,kBAAA,CAAmBS,GAAG,CAACP,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,EAAEH,eAAA;EACxE;EAEA;EACAH,uBAAA,CAAwBI,QAAQ,GAAGJ,uBAAA,CAAwBI,QAAQ,CAACO,IAAI,CACtE,CAACC,CAAA,EAAGC,CAAA,KAAMD,CAAA,CAAEP,kBAAkB,CAACE,KAAK,GAAGM,CAAA,CAAER,kBAAkB,CAACE,KAAK;EAGnE,MAAMO,gBAAA,GAA6C,IAAIZ,GAAA;EAEvD;EACA,IAAIa,MAAA,GAAS;EACb,KAAK,MAAMZ,eAAA,IAAmBH,uBAAA,CAAwBI,QAAQ,EAAE;IAC9D,MAAMY,OAAA,GACJ,OAAOb,eAAA,CAAgBa,OAAO,KAAK,aAC/Bb,eAAA,CAAgBa,OAAO,CAAC;MACtBrB,MAAA;MACAC,sBAAA;MACAC,sBAAA;MACAI,kBAAA;MACAH,KAAA;MACAgB,gBAAA;MACAf,UAAA;MACAC;IACF,KACAG,eAAA,CAAgBa,OAAO;IAE7BA,OAAA,CAAQC,GAAG,GAAGd,eAAA,CAAgBE,kBAAkB,CAACC,UAAU;IAC3DU,OAAA,CAAQT,KAAK,GAAGQ,MAAA;IAEhBD,gBAAA,CAAiBJ,GAAG,CAClBP,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,EAC7CU,OAAA;IAGFD,MAAA;EACF;EAEA,OAAOD,gBAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"loader.js","names":["loadClientFeatures","config","featureClientImportMap","featureClientSchemaMap","field","schemaPath","unSanitizedEditorConfig","featureProviderMap","Map","validFeatures","featureProvider","features","clientFeatureProps","featureKey","order","undefined","console","warn","set","push","sort","a","b","resolvedFeatures","loaded","feature","key"],"sources":["../../../../src/lexical/config/client/loader.ts"],"sourcesContent":["'use client'\n\nimport type { ClientConfig, RichTextFieldClient } from 'payload'\n\nimport type {\n ClientFeatureProviderMap,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n} from '../../../features/typesClient.js'\nimport type { FeatureClientSchemaMap } from '../../../types/index.js'\nimport type { ClientEditorConfig } from '../types.js'\n\n/**\n * This function expects client functions to ALREADY be ordered & dependencies checked on the server\n * @param unSanitizedEditorConfig\n */\nexport function loadClientFeatures({\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n field,\n schemaPath,\n unSanitizedEditorConfig,\n}: {\n config: ClientConfig\n featureClientImportMap: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n field?: RichTextFieldClient\n schemaPath: string\n unSanitizedEditorConfig: ClientEditorConfig\n}): ResolvedClientFeatureMap {\n const featureProviderMap: ClientFeatureProviderMap = new Map()\n\n const validFeatures: typeof unSanitizedEditorConfig.features = []\n\n for (const featureProvider of unSanitizedEditorConfig.features) {\n if (\n !featureProvider?.clientFeatureProps?.featureKey ||\n featureProvider?.clientFeatureProps?.order === undefined ||\n featureProvider?.clientFeatureProps?.order === null\n ) {\n console.warn(\n 'A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected. Skipping feature.',\n )\n continue\n }\n featureProviderMap.set(featureProvider.clientFeatureProps.featureKey, featureProvider)\n validFeatures.push(featureProvider)\n }\n\n unSanitizedEditorConfig.features = validFeatures\n\n // sort unSanitizedEditorConfig.features by order\n unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.sort(\n (a, b) => a.clientFeatureProps.order - b.clientFeatureProps.order,\n )\n\n const resolvedFeatures: ResolvedClientFeatureMap = new Map()\n\n // Make sure all dependencies declared in the respective features exist\n let loaded = 0\n for (const featureProvider of unSanitizedEditorConfig.features) {\n const feature: Partial<ResolvedClientFeature<any>> =\n typeof featureProvider.feature === 'function'\n ? featureProvider.feature({\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n featureProviderMap,\n field,\n resolvedFeatures,\n schemaPath,\n unSanitizedEditorConfig,\n })\n : featureProvider.feature\n\n feature.key = featureProvider.clientFeatureProps.featureKey\n feature.order = loaded\n\n resolvedFeatures.set(\n featureProvider.clientFeatureProps.featureKey,\n feature as ResolvedClientFeature<any>,\n )\n\n loaded++\n }\n\n return resolvedFeatures\n}\n"],"mappings":"AAAA;;AAYA;;;;AAIA,OAAO,SAASA,mBAAmB;EACjCC,MAAM;EACNC,sBAAsB;EACtBC,sBAAsB;EACtBC,KAAK;EACLC,UAAU;EACVC;AAAuB,CAQxB;EACC,MAAMC,kBAAA,GAA+C,IAAIC,GAAA;EAEzD,MAAMC,aAAA,GAAyD,EAAE;EAEjE,KAAK,MAAMC,eAAA,IAAmBJ,uBAAA,CAAwBK,QAAQ,EAAE;IAC9D,IACE,CAACD,eAAA,EAAiBE,kBAAA,EAAoBC,UAAA,IACtCH,eAAA,EAAiBE,kBAAA,EAAoBE,KAAA,KAAUC,SAAA,IAC/CL,eAAA,EAAiBE,kBAAA,EAAoBE,KAAA,KAAU,MAC/C;MACAE,OAAA,CAAQC,IAAI,CACV;MAEF;IACF;IACAV,kBAAA,CAAmBW,GAAG,CAACR,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,EAAEH,eAAA;IACtED,aAAA,CAAcU,IAAI,CAACT,eAAA;EACrB;EAEAJ,uBAAA,CAAwBK,QAAQ,GAAGF,aAAA;EAEnC;EACAH,uBAAA,CAAwBK,QAAQ,GAAGL,uBAAA,CAAwBK,QAAQ,CAACS,IAAI,CACtE,CAACC,CAAA,EAAGC,CAAA,KAAMD,CAAA,CAAET,kBAAkB,CAACE,KAAK,GAAGQ,CAAA,CAAEV,kBAAkB,CAACE,KAAK;EAGnE,MAAMS,gBAAA,GAA6C,IAAIf,GAAA;EAEvD;EACA,IAAIgB,MAAA,GAAS;EACb,KAAK,MAAMd,eAAA,IAAmBJ,uBAAA,CAAwBK,QAAQ,EAAE;IAC9D,MAAMc,OAAA,GACJ,OAAOf,eAAA,CAAgBe,OAAO,KAAK,aAC/Bf,eAAA,CAAgBe,OAAO,CAAC;MACtBxB,MAAA;MACAC,sBAAA;MACAC,sBAAA;MACAI,kBAAA;MACAH,KAAA;MACAmB,gBAAA;MACAlB,UAAA;MACAC;IACF,KACAI,eAAA,CAAgBe,OAAO;IAE7BA,OAAA,CAAQC,GAAG,GAAGhB,eAAA,CAAgBE,kBAAkB,CAACC,UAAU;IAC3DY,OAAA,CAAQX,KAAK,GAAGU,MAAA;IAEhBD,gBAAA,CAAiBL,GAAG,CAClBR,eAAA,CAAgBE,kBAAkB,CAACC,UAAU,EAC7CY,OAAA;IAGFD,MAAA;EACF;EAEA,OAAOD,gBAAA;AACT","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/server/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIlF,eAAO,MAAM,sBAAsB,GACjC,UAAU,wBAAwB,KACjC,uBAyHF,CAAA;AAED,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,kBAAkB,EAChC,MAAM,EAAE,eAAe,EACvB,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,2BAA2B,CAAC,CAYtC"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../src/lexical/config/server/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIlF,eAAO,MAAM,sBAAsB,GACjC,UAAU,wBAAwB,KACjC,uBA0HF,CAAA;AAED,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,kBAAkB,EAChC,MAAM,EAAE,eAAe,EACvB,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,2BAA2B,CAAC,CAYtC"}
@@ -2,9 +2,6 @@ import { loadFeatures } from './loader.js';
2
2
  export const sanitizeServerFeatures = features => {
3
3
  const sanitized = {
4
4
  enabledFeatures: [],
5
- generatedTypes: {
6
- modifyJSONSchemas: []
7
- },
8
5
  getSubFields: new Map(),
9
6
  getSubFieldsData: new Map(),
10
7
  graphQLPopulationPromises: new Map(),
@@ -29,9 +26,6 @@ export const sanitizeServerFeatures = features => {
29
26
  return sanitized;
30
27
  }
31
28
  features.forEach(feature => {
32
- if (feature?.generatedTypes?.modifyJSONSchema) {
33
- sanitized.generatedTypes.modifyJSONSchemas.push(feature.generatedTypes.modifyJSONSchema);
34
- }
35
29
  if (feature?.hooks?.beforeValidate?.length) {
36
30
  sanitized.hooks.beforeValidate = sanitized.hooks.beforeValidate?.concat(feature.hooks.beforeValidate);
37
31
  }
@@ -58,11 +52,15 @@ export const sanitizeServerFeatures = features => {
58
52
  if (feature.nodes?.length) {
59
53
  // Do not concat here. We need to keep the object reference of sanitized.nodes so that function markdown transformers of features automatically get the updated nodes
60
54
  for (const node of feature.nodes) {
55
+ const nodeType = 'with' in node.node ? node.node.replace.getType() : node.node.getType();
56
+ const alreadyRegistered = sanitized.nodes.some(existing => {
57
+ const existingType = 'with' in existing.node ? existing.node.replace.getType() : existing.node.getType();
58
+ return existingType === nodeType;
59
+ });
60
+ if (alreadyRegistered) {
61
+ throw new Error(`Lexical editor config: node type "${nodeType}" was registered more than once (feature "${feature.key}"). Each lexical node type may only be registered by a single feature.`);
62
+ }
61
63
  sanitized.nodes.push(node);
62
- }
63
- feature.nodes.forEach(node => {
64
- const nodeType = 'with' in node.node ? node.node.replace.getType() : node.node.getType() // TODO: Idk if this works for node replacements
65
- ;
66
64
  if (node?.graphQLPopulationPromises?.length) {
67
65
  sanitized.graphQLPopulationPromises.set(nodeType, node.graphQLPopulationPromises);
68
66
  }
@@ -87,7 +85,7 @@ export const sanitizeServerFeatures = features => {
87
85
  if (node?.getSubFieldsData) {
88
86
  sanitized.getSubFieldsData?.set(nodeType, node.getSubFieldsData);
89
87
  }
90
- });
88
+ }
91
89
  }
92
90
  if (feature.markdownTransformers?.length) {
93
91
  // Do not concat here. We need to keep the object reference of feature.markdownTransformers
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.js","names":["loadFeatures","sanitizeServerFeatures","features","sanitized","enabledFeatures","generatedTypes","modifyJSONSchemas","getSubFields","Map","getSubFieldsData","graphQLPopulationPromises","hooks","afterChange","afterRead","beforeChange","beforeValidate","i18n","markdownTransformers","nodeHooks","nodes","validations","size","forEach","feature","modifyJSONSchema","push","length","concat","lang","lexical","key","node","nodeType","replace","getType","set","transformer","allNodes","allTransformers","sanitizeServerEditorConfig","editorConfig","config","parentIsLocalized","resolvedFeatureMap","unSanitizedEditorConfig"],"sources":["../../../../src/lexical/config/server/sanitize.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport type {\n ResolvedServerFeatureMap,\n SanitizedServerFeatures,\n} from '../../../features/typesServer.js'\nimport type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js'\n\nimport { loadFeatures } from './loader.js'\n\nexport const sanitizeServerFeatures = (\n features: ResolvedServerFeatureMap,\n): SanitizedServerFeatures => {\n const sanitized: SanitizedServerFeatures = {\n enabledFeatures: [],\n generatedTypes: {\n modifyJSONSchemas: [],\n },\n getSubFields: new Map(),\n getSubFieldsData: new Map(),\n graphQLPopulationPromises: new Map(),\n hooks: {\n afterChange: [],\n afterRead: [],\n beforeChange: [],\n beforeValidate: [],\n },\n i18n: {},\n markdownTransformers: [],\n nodeHooks: {\n afterChange: new Map(),\n afterRead: new Map(),\n beforeChange: new Map(),\n beforeValidate: new Map(),\n },\n nodes: [],\n\n validations: new Map(),\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature?.generatedTypes?.modifyJSONSchema) {\n sanitized.generatedTypes.modifyJSONSchemas.push(feature.generatedTypes.modifyJSONSchema)\n }\n\n if (feature?.hooks?.beforeValidate?.length) {\n sanitized.hooks.beforeValidate = sanitized.hooks.beforeValidate?.concat(\n feature.hooks.beforeValidate,\n )\n }\n if (feature?.hooks?.beforeChange?.length) {\n sanitized.hooks.beforeChange = sanitized.hooks.beforeChange?.concat(\n feature.hooks.beforeChange,\n )\n }\n if (feature?.hooks?.afterRead?.length) {\n sanitized.hooks.afterRead = sanitized.hooks.afterRead?.concat(feature.hooks.afterRead)\n }\n if (feature?.hooks?.afterChange?.length) {\n sanitized.hooks.afterChange = sanitized.hooks.afterChange?.concat(feature.hooks.afterChange)\n }\n\n if (feature?.i18n) {\n for (const lang in feature.i18n) {\n if (!sanitized.i18n[lang as keyof typeof sanitized.i18n]) {\n sanitized.i18n[lang as keyof typeof sanitized.i18n] = {\n lexical: {},\n }\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n sanitized.i18n[lang].lexical[feature.key] = feature.i18n[lang]\n }\n }\n\n if (feature.nodes?.length) {\n // Do not concat here. We need to keep the object reference of sanitized.nodes so that function markdown transformers of features automatically get the updated nodes\n for (const node of feature.nodes) {\n sanitized.nodes.push(node)\n }\n feature.nodes.forEach((node) => {\n const nodeType = 'with' in node.node ? node.node.replace.getType() : node.node.getType() // TODO: Idk if this works for node replacements\n if (node?.graphQLPopulationPromises?.length) {\n sanitized.graphQLPopulationPromises.set(nodeType, node.graphQLPopulationPromises)\n }\n if (node?.validations?.length) {\n sanitized.validations.set(nodeType, node.validations)\n }\n if (node?.hooks?.afterChange) {\n sanitized.nodeHooks?.afterChange?.set(nodeType, node.hooks.afterChange)\n }\n if (node?.hooks?.afterRead) {\n sanitized.nodeHooks?.afterRead?.set(nodeType, node.hooks.afterRead)\n }\n if (node?.hooks?.beforeChange) {\n sanitized.nodeHooks?.beforeChange?.set(nodeType, node.hooks.beforeChange)\n }\n if (node?.hooks?.beforeValidate) {\n sanitized.nodeHooks?.beforeValidate?.set(nodeType, node.hooks.beforeValidate)\n }\n if (node?.getSubFields) {\n sanitized.getSubFields?.set(nodeType, node.getSubFields)\n }\n if (node?.getSubFieldsData) {\n sanitized.getSubFieldsData?.set(nodeType, node.getSubFieldsData)\n }\n })\n }\n\n if (feature.markdownTransformers?.length) {\n // Do not concat here. We need to keep the object reference of feature.markdownTransformers\n\n for (const transformer of feature.markdownTransformers) {\n if (typeof transformer === 'function') {\n sanitized.markdownTransformers.push(\n transformer({\n allNodes: sanitized.nodes,\n allTransformers: sanitized.markdownTransformers,\n }),\n )\n } else {\n sanitized.markdownTransformers.push(transformer)\n }\n }\n }\n\n sanitized.enabledFeatures.push(feature.key)\n })\n\n return sanitized\n}\n\nexport async function sanitizeServerEditorConfig(\n editorConfig: ServerEditorConfig,\n config: SanitizedConfig,\n parentIsLocalized?: boolean,\n): Promise<SanitizedServerEditorConfig> {\n const resolvedFeatureMap = await loadFeatures({\n config,\n parentIsLocalized: parentIsLocalized!,\n unSanitizedEditorConfig: editorConfig,\n })\n\n return {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical: editorConfig.lexical!,\n resolvedFeatureMap,\n }\n}\n"],"mappings":"AAQA,SAASA,YAAY,QAAQ;AAE7B,OAAO,MAAMC,sBAAA,GACXC,QAAA;EAEA,MAAMC,SAAA,GAAqC;IACzCC,eAAA,EAAiB,EAAE;IACnBC,cAAA,EAAgB;MACdC,iBAAA,EAAmB;IACrB;IACAC,YAAA,EAAc,IAAIC,GAAA;IAClBC,gBAAA,EAAkB,IAAID,GAAA;IACtBE,yBAAA,EAA2B,IAAIF,GAAA;IAC/BG,KAAA,EAAO;MAC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CAAY;YACVC,QAAA,EAAUlC,SAAA,CAAUgB,KAAK;YACzBmB,eAAA,EAAiBnC,SAAA,CAAUc;UAC7B;QAEJ,OAAO;UACLd,SAAA,CAAUc,oBAAoB,CAACQ,IAAI,CAACW,WAAA;QACtC;MACF;IACF;IAEAjC,SAAA,CAAUC,eAAe,CAACqB,IAAI,CAACF,OAAA,CAAQO,GAAG;EAC5C;EAEA,OAAO3B,SAAA;AACT;AAEA,OAAO,eAAeoC,2BACpBC,YAAgC,EAChCC,MAAuB,EACvBC,iBAA2B;EAE3B,MAAMC,kBAAA,GAAqB,MAAM3C,YAAA,CAAa;IAC5CyC,MAAA;IACAC,iBAAA,EAAmBA,iBAAA;IACnBE,uBAAA,EAAyBJ;EAC3B;EAEA,OAAO;IACLtC,QAAA,EAAUD,sBAAA,CAAuB0C,kBAAA;IACjCd,OAAA,EAASW,YAAA,CAAaX,OAAO;IAC7Bc;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"sanitize.js","names":["loadFeatures","sanitizeServerFeatures","features","sanitized","enabledFeatures","getSubFields","Map","getSubFieldsData","graphQLPopulationPromises","hooks","afterChange","afterRead","beforeChange","beforeValidate","i18n","markdownTransformers","nodeHooks","nodes","validations","size","forEach","feature","length","concat","lang","lexical","key","node","nodeType","replace","getType","alreadyRegistered","some","existing","existingType","Error","push","set","transformer","allNodes","allTransformers","sanitizeServerEditorConfig","editorConfig","config","parentIsLocalized","resolvedFeatureMap","unSanitizedEditorConfig"],"sources":["../../../../src/lexical/config/server/sanitize.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport type {\n ResolvedServerFeatureMap,\n SanitizedServerFeatures,\n} from '../../../features/typesServer.js'\nimport type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js'\n\nimport { loadFeatures } from './loader.js'\n\nexport const sanitizeServerFeatures = (\n features: ResolvedServerFeatureMap,\n): SanitizedServerFeatures => {\n const sanitized: SanitizedServerFeatures = {\n enabledFeatures: [],\n getSubFields: new Map(),\n getSubFieldsData: new Map(),\n graphQLPopulationPromises: new Map(),\n hooks: {\n afterChange: [],\n afterRead: [],\n beforeChange: [],\n beforeValidate: [],\n },\n i18n: {},\n markdownTransformers: [],\n nodeHooks: {\n afterChange: new Map(),\n afterRead: new Map(),\n beforeChange: new Map(),\n beforeValidate: new Map(),\n },\n nodes: [],\n\n validations: new Map(),\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature?.hooks?.beforeValidate?.length) {\n sanitized.hooks.beforeValidate = sanitized.hooks.beforeValidate?.concat(\n feature.hooks.beforeValidate,\n )\n }\n if (feature?.hooks?.beforeChange?.length) {\n sanitized.hooks.beforeChange = sanitized.hooks.beforeChange?.concat(\n feature.hooks.beforeChange,\n )\n }\n if (feature?.hooks?.afterRead?.length) {\n sanitized.hooks.afterRead = sanitized.hooks.afterRead?.concat(feature.hooks.afterRead)\n }\n if (feature?.hooks?.afterChange?.length) {\n sanitized.hooks.afterChange = sanitized.hooks.afterChange?.concat(feature.hooks.afterChange)\n }\n\n if (feature?.i18n) {\n for (const lang in feature.i18n) {\n if (!sanitized.i18n[lang as keyof typeof sanitized.i18n]) {\n sanitized.i18n[lang as keyof typeof sanitized.i18n] = {\n lexical: {},\n }\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n sanitized.i18n[lang].lexical[feature.key] = feature.i18n[lang]\n }\n }\n\n if (feature.nodes?.length) {\n // Do not concat here. We need to keep the object reference of sanitized.nodes so that function markdown transformers of features automatically get the updated nodes\n for (const node of feature.nodes) {\n const nodeType = 'with' in node.node ? node.node.replace.getType() : node.node.getType()\n const alreadyRegistered = sanitized.nodes.some((existing) => {\n const existingType =\n 'with' in existing.node ? existing.node.replace.getType() : existing.node.getType()\n return existingType === nodeType\n })\n if (alreadyRegistered) {\n throw new Error(\n `Lexical editor config: node type \"${nodeType}\" was registered more than once (feature \"${feature.key}\"). Each lexical node type may only be registered by a single feature.`,\n )\n }\n sanitized.nodes.push(node)\n if (node?.graphQLPopulationPromises?.length) {\n sanitized.graphQLPopulationPromises.set(nodeType, node.graphQLPopulationPromises)\n }\n if (node?.validations?.length) {\n sanitized.validations.set(nodeType, node.validations)\n }\n if (node?.hooks?.afterChange) {\n sanitized.nodeHooks?.afterChange?.set(nodeType, node.hooks.afterChange)\n }\n if (node?.hooks?.afterRead) {\n sanitized.nodeHooks?.afterRead?.set(nodeType, node.hooks.afterRead)\n }\n if (node?.hooks?.beforeChange) {\n sanitized.nodeHooks?.beforeChange?.set(nodeType, node.hooks.beforeChange)\n }\n if (node?.hooks?.beforeValidate) {\n sanitized.nodeHooks?.beforeValidate?.set(nodeType, node.hooks.beforeValidate)\n }\n if (node?.getSubFields) {\n sanitized.getSubFields?.set(nodeType, node.getSubFields)\n }\n if (node?.getSubFieldsData) {\n sanitized.getSubFieldsData?.set(nodeType, node.getSubFieldsData)\n }\n }\n }\n\n if (feature.markdownTransformers?.length) {\n // Do not concat here. We need to keep the object reference of feature.markdownTransformers\n\n for (const transformer of feature.markdownTransformers) {\n if (typeof transformer === 'function') {\n sanitized.markdownTransformers.push(\n transformer({\n allNodes: sanitized.nodes,\n allTransformers: sanitized.markdownTransformers,\n }),\n )\n } else {\n sanitized.markdownTransformers.push(transformer)\n }\n }\n }\n\n sanitized.enabledFeatures.push(feature.key)\n })\n\n return sanitized\n}\n\nexport async function sanitizeServerEditorConfig(\n editorConfig: ServerEditorConfig,\n config: SanitizedConfig,\n parentIsLocalized?: boolean,\n): Promise<SanitizedServerEditorConfig> {\n const resolvedFeatureMap = await loadFeatures({\n config,\n parentIsLocalized: parentIsLocalized!,\n unSanitizedEditorConfig: editorConfig,\n })\n\n return {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical: editorConfig.lexical!,\n resolvedFeatureMap,\n }\n}\n"],"mappings":"AAQA,SAASA,YAAY,QAAQ;AAE7B,OAAO,MAAMC,sBAAA,GACXC,QAAA;EAEA,MAAMC,SAAA,GAAqC;IACzCC,e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,QAAA,EAAUD,IAAA,CAAKpB,gBAAgB;QACjE;MACF;IACF;IAEA,IAAIc,OAAA,CAAQN,oBAAoB,EAAEO,MAAA,EAAQ;MACxC;MAEA,KAAK,MAAMgB,WAAA,IAAejB,OAAA,CAAQN,oBAAoB,EAAE;QACtD,IAAI,OAAOuB,WAAA,KAAgB,YAAY;UACrCnC,SAAA,CAAUY,oBAAoB,CAACqB,IAAI,CACjCE,WAAA,CAAY;YACVC,QAAA,EAAUpC,SAAA,CAAUc,KAAK;YACzBuB,eAAA,EAAiBrC,SAAA,CAAUY;UAC7B;QAEJ,OAAO;UACLZ,SAAA,CAAUY,oBAAoB,CAACqB,IAAI,CAACE,WAAA;QACtC;MACF;IACF;IAEAnC,SAAA,CAAUC,eAAe,CAACgC,IAAI,CAACf,OAAA,CAAQK,GAAG;EAC5C;EAEA,OAAOvB,SAAA;AACT;AAEA,OAAO,eAAesC,2BACpBC,YAAgC,EAChCC,MAAuB,EACvBC,iBAA2B;EAE3B,MAAMC,kBAAA,GAAqB,MAAM7C,YAAA,CAAa;IAC5C2C,MAAA;IACAC,iBAAA,EAAmBA,iBAAA;IACnBE,uBAAA,EAAyBJ;EAC3B;EAEA,OAAO;IACLxC,QAAA,EAAUD,sBAAA,CAAuB4C,kBAAA;IACjCpB,OAAA,EAASiB,YAAA,CAAajB,OAAO;IAC7BoB;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$findMatchingParent","mergeRegister","$createNodeSelection","$getEditor","$getNearestNodeFromDOMNode","$getSelection","$isDecoratorNode","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isRootOrShadowRoot","$isTextNode","$setSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","SELECTION_CHANGE_COMMAND","useEffect","DecoratorPlugin","$","editor","$onDelete","_temp2","t0","t1","registerCommand","_temp3","_temp4","_temp6","_temp8","event_2","selection_1","selection","event","preventDefault","nextSibling","getNodes","getNextSibling","element_0","getElementByKey","getKey","element","$selectDecorator","firstDescendant","getFirstDescendant","block_0","INTERNAL_$isBlock","block","selectEnd","lastPoint","isBackward","anchor","focus","lastNode","getNode","lastSelectedBlock","_temp7","nextBlock","findLaterSiblingBlock","nextBlockElement","node","node_1","event_1","selection_0","prevSibling","getPreviousSibling","lastDescendant","getLastDescendant","selectStart","firstPoint","firstNode","firstSelectedBlock","_temp5","prevBlock","findFirstSiblingBlock","prevBlockElement","node_0","decorator_0","$getSelectedDecorator","document","querySelector","classList","remove","decorator","add","event_0","$getDecoratorByMouseEvent","target","isInteractive","HTMLElement","isContentEditable","closest","forEach","_temp","undefined","nodes","length","scrollIntoView","behavior","isInline","firstChild","getFirstChild","isLeafElement","canBeEmpty","current"],"sources":["../../../../src/lexical/plugins/DecoratorPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DecoratorNode, ElementNode, LexicalNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport {\n $createNodeSelection,\n $getEditor,\n $getNearestNodeFromDOMNode,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $isTextNode,\n $setSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport './index.css'\n\n// TODO: This should ideally be fixed in Lexical. See\n// https://github.com/facebook/lexical/pull/7072\nexport function DecoratorPlugin() {\n const [editor] = useLexicalComposerContext()\n\n const $onDelete = (event: KeyboardEvent) => {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return false\n }\n event.preventDefault()\n selection.getNodes().forEach((node) => {\n node.remove()\n })\n return true\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event) => {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const decorator = $getDecoratorByMouseEvent(event)\n if (!decorator) {\n return true\n }\n const { target } = event\n const isInteractive =\n !(target instanceof HTMLElement) ||\n target.isContentEditable ||\n target.closest(\n 'button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role=\"button\"]',\n )\n if (isInteractive) {\n $setSelection(null)\n } else {\n $selectDecorator(decorator)\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n const decorator = $getSelectedDecorator()\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n if (decorator) {\n decorator.element?.classList.add('decorator-selected')\n return true\n }\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_UP_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n const prevSibling = selection.getNodes()[0]?.getPreviousSibling()\n if ($isDecoratorNode(prevSibling)) {\n const element = $getEditor().getElementByKey(prevSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: prevSibling })\n event.preventDefault()\n return true\n }\n return false\n }\n if (!$isElementNode(prevSibling)) {\n return false\n }\n const lastDescendant = prevSibling.getLastDescendant() ?? prevSibling\n if (!lastDescendant) {\n return false\n }\n const block = $findMatchingParent(lastDescendant, INTERNAL_$isBlock)\n block?.selectStart()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get first selected block\n const firstPoint = selection.isBackward() ? selection.anchor : selection.focus\n const firstNode = firstPoint.getNode()\n const firstSelectedBlock = $findMatchingParent(firstNode, (node) => {\n return findFirstSiblingBlock(node) !== null\n })\n const prevBlock = firstSelectedBlock?.getPreviousSibling()\n if (!firstSelectedBlock || prevBlock !== findFirstSiblingBlock(firstSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(prevBlock)) {\n const prevBlockElement = $getEditor().getElementByKey(prevBlock.getKey())\n if (prevBlockElement) {\n $selectDecorator({ element: prevBlockElement, node: prevBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_DOWN_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n event.preventDefault()\n const nextSibling = selection.getNodes()[0]?.getNextSibling()\n if ($isDecoratorNode(nextSibling)) {\n const element = $getEditor().getElementByKey(nextSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: nextSibling })\n }\n return true\n }\n if (!$isElementNode(nextSibling)) {\n return true\n }\n const firstDescendant = nextSibling.getFirstDescendant() ?? nextSibling\n if (!firstDescendant) {\n return true\n }\n const block = $findMatchingParent(firstDescendant, INTERNAL_$isBlock)\n block?.selectEnd()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get last selected block\n const lastPoint = selection.isBackward() ? selection.anchor : selection.focus\n const lastNode = lastPoint.getNode()\n const lastSelectedBlock = $findMatchingParent(lastNode, (node) => {\n return findLaterSiblingBlock(node) !== null\n })\n const nextBlock = lastSelectedBlock?.getNextSibling()\n if (!lastSelectedBlock || nextBlock !== findLaterSiblingBlock(lastSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(nextBlock)) {\n const nextBlockElement = $getEditor().getElementByKey(nextBlock.getKey())\n if (nextBlockElement) {\n $selectDecorator({ element: nextBlockElement, node: nextBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return null\n}\n\nfunction $getDecoratorByMouseEvent(\n event: MouseEvent,\n): { element: HTMLElement; node: DecoratorNode<unknown> } | undefined {\n if (!(event.target instanceof HTMLElement)) {\n return undefined\n }\n const element = event.target.closest('[data-lexical-decorator=\"true\"]')\n if (!(element instanceof HTMLElement)) {\n return undefined\n }\n const node = $getNearestNodeFromDOMNode(element)\n return $isDecoratorNode(node) ? { element, node } : undefined\n}\n\nfunction $getSelectedDecorator() {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return undefined\n }\n const nodes = selection.getNodes()\n if (nodes.length !== 1) {\n return undefined\n }\n const node = nodes[0]\n return $isDecoratorNode(node)\n ? {\n decorator: node,\n element: $getEditor().getElementByKey(node.getKey()),\n }\n : undefined\n}\n\nfunction $selectDecorator({\n element,\n node,\n}: {\n element: HTMLElement\n node: DecoratorNode<unknown>\n}) {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const selection = $createNodeSelection()\n selection.add(node.getKey())\n $setSelection(selection)\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' })\n element.classList.add('decorator-selected')\n}\n\n/**\n * Copied from https://github.com/facebook/lexical/blob/main/packages/lexical/src/LexicalUtils.ts\n *\n * This function returns true for a DecoratorNode that is not inline OR\n * an ElementNode that is:\n * - not a root or shadow root\n * - not inline\n * - can't be empty\n * - has no children or an inline first child\n */\nexport function INTERNAL_$isBlock(node: LexicalNode): node is DecoratorNode<unknown> | ElementNode {\n if ($isDecoratorNode(node) && !node.isInline()) {\n return true\n }\n if (!$isElementNode(node) || $isRootOrShadowRoot(node)) {\n return false\n }\n\n const firstChild = node.getFirstChild()\n const isLeafElement =\n firstChild === null ||\n $isLineBreakNode(firstChild) ||\n $isTextNode(firstChild) ||\n firstChild.isInline()\n\n return !node.isInline() && node.canBeEmpty() !== false && isLeafElement\n}\n\nfunction findLaterSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getNextSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getNextSibling()\n }\n return null\n}\n\nfunction findFirstSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getPreviousSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getPreviousSibling()\n }\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,mBAAmB,EAAEC,aAAa,QAAQ;AACnD,SACEC,oBAAoB,EACpBC,UAAU,EACVC,0BAA0B,EAC1BC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,WAAW,EACXC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,sBAAsB,EACtBC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,EAClBC,wBAAwB,QACnB;AACP,SAASC,SAAS,QAAQ;AAE1B,OAAO;AAEP;AACA;AACA,OAAO,SAAAC,gBAAA;EAAA,MAAAC,CAAA,GAAAzB,EAAA;EACL,OAAA0B,MAAA,IAAiBzB,yBAAA;EAEjB,MAAA0B,SAAA,GAAAC,MAAA;EAUA,IAAAC,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAL,CAAA,QAAAC,MAAA;IAEUG,EAAA,GAAAA,CAAA,KACD1B,aAAA,CACLuB,MAAA,CAAAK,eAAA,CAAAf,aAAA,EAAAgB,MAAA,EAAAf,oBAsBE,GAEFS,MAAA,CAAAK,eAAA,CAAAV,kBAAA,EAA2CM,SAAA,EAAAV,oBAAW,GACtDS,MAAA,CAAAK,eAAA,CAAAX,qBAAA,EAA8CO,SAAA,EAAAV,oBAAW,GACzDS,MAAA,CAAAK,eAAA,CAAAT,wBAAA,E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;EAC9C,IAAI4C,OAAA,GAAU5C,IAAA,CAAKvB,cAAc;EACjC,OAAOmE,OAAA,KAAY,MAAM;IACvB,IAAI1D,iBAAA,CAAkB0D,OAAA,GAAU;MAC9B,OAAOA,OAAA;IACT;IACAA,OAAA,GAAUA,OAAA,CAAQnE,cAAc;EAClC;EACA,OAAO;AACT;AAEA,SAASqC,sBAAsBd,IAAiB;EAC9C,IAAI4C,OAAA,GAAU5C,IAAA,CAAKK,kBAAkB;EACrC,OAAOuC,OAAA,KAAY,MAAM;IACvB,IAAI1D,iBAAA,CAAkB0D,OAAA,GAAU;MAC9B,OAAOA,OAAA;IACT;IACAA,OAAA,GAAUA,OAAA,CAAQvC,kBAAkB;EACtC;EACA,OAAO;AACT","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$findMatchingParent","mergeRegister","$createNodeSelection","$getEditor","$getNearestNodeFromDOMNode","$getSelection","$isDecoratorNode","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isRootOrShadowRoot","$isTextNode","$setSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","SELECTION_CHANGE_COMMAND","useEffect","DecoratorPlugin","$","editor","$onDelete","_temp2","t0","t1","registerCommand","_temp3","_temp4","_temp6","_temp8","event_2","selection_1","selection","event","preventDefault","nextSibling","getNodes","getNextSibling","element_0","getElementByKey","getKey","element","$selectDecorator","node","firstDescendant","getFirstDescendant","block_0","INTERNAL_$isBlock","block","selectEnd","lastPoint","isBackward","anchor","focus","lastNode","getNode","lastSelectedBlock","_temp7","nextBlock","findLaterSiblingBlock","nextBlockElement","node_1","event_1","selection_0","prevSibling","getPreviousSibling","lastDescendant","getLastDescendant","selectStart","firstPoint","firstNode","firstSelectedBlock","_temp5","prevBlock","findFirstSiblingBlock","prevBlockElement","node_0","decorator_0","$getSelectedDecorator","document","querySelector","classList","remove","decorator","add","event_0","$getDecoratorByMouseEvent","target","isInteractive","HTMLElement","isContentEditable","closest","forEach","_temp","undefined","nodes","length","scrollIntoView","behavior","isInline","firstChild","getFirstChild","isLeafElement","canBeEmpty","current"],"sources":["../../../../src/lexical/plugins/DecoratorPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DecoratorNode, ElementNode, LexicalNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport {\n $createNodeSelection,\n $getEditor,\n $getNearestNodeFromDOMNode,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $isTextNode,\n $setSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport './index.css'\n\n// TODO: This should ideally be fixed in Lexical. See\n// https://github.com/facebook/lexical/pull/7072\nexport function DecoratorPlugin() {\n const [editor] = useLexicalComposerContext()\n\n const $onDelete = (event: KeyboardEvent) => {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return false\n }\n event.preventDefault()\n selection.getNodes().forEach((node) => {\n node.remove()\n })\n return true\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event) => {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const decorator = $getDecoratorByMouseEvent(event)\n if (!decorator) {\n return true\n }\n const { target } = event\n const isInteractive =\n !(target instanceof HTMLElement) ||\n target.isContentEditable ||\n target.closest(\n 'button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role=\"button\"]',\n )\n if (isInteractive) {\n $setSelection(null)\n } else {\n $selectDecorator(decorator)\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n const decorator = $getSelectedDecorator()\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n if (decorator) {\n decorator.element?.classList.add('decorator-selected')\n return true\n }\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_UP_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n const prevSibling = selection.getNodes()[0]?.getPreviousSibling()\n if ($isDecoratorNode(prevSibling)) {\n const element = $getEditor().getElementByKey(prevSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: prevSibling })\n event.preventDefault()\n return true\n }\n return false\n }\n if (!$isElementNode(prevSibling)) {\n return false\n }\n const lastDescendant = prevSibling.getLastDescendant() ?? prevSibling\n if (!lastDescendant) {\n return false\n }\n const block = $findMatchingParent(lastDescendant, INTERNAL_$isBlock)\n block?.selectStart()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get first selected block\n const firstPoint = selection.isBackward() ? selection.anchor : selection.focus\n const firstNode = firstPoint.getNode()\n const firstSelectedBlock = $findMatchingParent(firstNode, (node) => {\n return findFirstSiblingBlock(node) !== null\n })\n const prevBlock = firstSelectedBlock?.getPreviousSibling()\n if (!firstSelectedBlock || prevBlock !== findFirstSiblingBlock(firstSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(prevBlock)) {\n const prevBlockElement = $getEditor().getElementByKey(prevBlock.getKey())\n if (prevBlockElement) {\n $selectDecorator({ element: prevBlockElement, node: prevBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_DOWN_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n event.preventDefault()\n const nextSibling = selection.getNodes()[0]?.getNextSibling()\n if ($isDecoratorNode(nextSibling)) {\n const element = $getEditor().getElementByKey(nextSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: nextSibling })\n }\n return true\n }\n if (!$isElementNode(nextSibling)) {\n return true\n }\n const firstDescendant = nextSibling.getFirstDescendant() ?? nextSibling\n if (!firstDescendant) {\n return true\n }\n const block = $findMatchingParent(firstDescendant, INTERNAL_$isBlock)\n block?.selectEnd()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get last selected block\n const lastPoint = selection.isBackward() ? selection.anchor : selection.focus\n const lastNode = lastPoint.getNode()\n const lastSelectedBlock = $findMatchingParent(lastNode, (node) => {\n return findLaterSiblingBlock(node) !== null\n })\n const nextBlock = lastSelectedBlock?.getNextSibling()\n if (!lastSelectedBlock || nextBlock !== findLaterSiblingBlock(lastSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(nextBlock)) {\n const nextBlockElement = $getEditor().getElementByKey(nextBlock.getKey())\n if (nextBlockElement) {\n $selectDecorator({ element: nextBlockElement, node: nextBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return null\n}\n\nfunction $getDecoratorByMouseEvent(\n event: MouseEvent,\n): { element: HTMLElement; node: DecoratorNode<unknown> } | undefined {\n if (!(event.target instanceof HTMLElement)) {\n return undefined\n }\n const element = event.target.closest('[data-lexical-decorator=\"true\"]')\n if (!(element instanceof HTMLElement)) {\n return undefined\n }\n const node = $getNearestNodeFromDOMNode(element)\n return $isDecoratorNode(node) ? { element, node } : undefined\n}\n\nfunction $getSelectedDecorator() {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return undefined\n }\n const nodes = selection.getNodes()\n if (nodes.length !== 1) {\n return undefined\n }\n const node = nodes[0]\n return $isDecoratorNode(node)\n ? {\n decorator: node,\n element: $getEditor().getElementByKey(node.getKey()),\n }\n : undefined\n}\n\nfunction $selectDecorator({\n element,\n node,\n}: {\n element: HTMLElement\n node: DecoratorNode<unknown>\n}) {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const selection = $createNodeSelection()\n selection.add(node.getKey())\n $setSelection(selection)\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' })\n element.classList.add('decorator-selected')\n}\n\n/**\n * Copied from https://github.com/facebook/lexical/blob/main/packages/lexical/src/LexicalUtils.ts\n *\n * This function returns true for a DecoratorNode that is not inline OR\n * an ElementNode that is:\n * - not a root or shadow root\n * - not inline\n * - can't be empty\n * - has no children or an inline first child\n */\nexport function INTERNAL_$isBlock(node: LexicalNode): node is DecoratorNode<unknown> | ElementNode {\n if ($isDecoratorNode(node) && !node.isInline()) {\n return true\n }\n if (!$isElementNode(node) || $isRootOrShadowRoot(node)) {\n return false\n }\n\n const firstChild = node.getFirstChild()\n const isLeafElement =\n firstChild === null ||\n $isLineBreakNode(firstChild) ||\n $isTextNode(firstChild) ||\n firstChild.isInline()\n\n return !node.isInline() && node.canBeEmpty() !== false && isLeafElement\n}\n\nfunction findLaterSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getNextSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getNextSibling()\n }\n return null\n}\n\nfunction findFirstSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getPreviousSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getPreviousSibling()\n }\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,mBAAmB,EAAEC,aAAa,QAAQ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UA,OAAA,CAAQvC,kBAAkB;EACtC;EACA,OAAO;AACT","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import type { JSONSchemaFn } from '../features/typesServer.js';
2
+ /**
3
+ * Cross-cutting Lexical types shared by every element node. Inlined into
4
+ * `payload-types.ts`. Must stay byte-for-byte in sync with the runtime twins
5
+ * in `types/nodeTypes.ts` (`LexicalElementFormat`, `LexicalElementDirection`,
6
+ * `SerializedLexicalElementBase`) — cross-module assignability depends on it.
7
+ */
8
+ export declare const CORE_LEXICAL_TYPE_STRING = "/** @internal Core Lexical types \u2014 see @payloadcms/richtext-lexical. */\nexport type LexicalElementFormat = 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';\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}";
9
+ export declare const textNodeJSONSchema: JSONSchemaFn;
10
+ export declare const tabNodeJSONSchema: JSONSchemaFn;
11
+ export declare const lineBreakNodeJSONSchema: JSONSchemaFn;
12
+ export declare const paragraphNodeJSONSchema: JSONSchemaFn;
13
+ export declare const rootNodeJSONSchema: JSONSchemaFn;
14
+ //# sourceMappingURL=builtInNodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtInNodes.d.ts","sourceRoot":"","sources":["../../src/types/builtInNodes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAI9D;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,6eAYnC,CAAA;AA4DF,eAAO,MAAM,kBAAkB,EAAE,YAkBhC,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,YAoB/B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,YAYrC,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,YAerC,CAAA;AAeD,eAAO,MAAM,kBAAkB,EAAE,YAoBhC,CAAA"}