@payloadcms/richtext-lexical 3.0.0-alpha.65 → 3.0.0-alpha.66

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 (336) hide show
  1. package/dist/cell/index.d.ts +1 -1
  2. package/dist/cell/index.d.ts.map +1 -1
  3. package/dist/cell/index.js +2 -4
  4. package/dist/cell/index.js.map +1 -1
  5. package/dist/field/features/align/feature.client.d.ts.map +1 -1
  6. package/dist/field/features/align/feature.client.js +1 -2
  7. package/dist/field/features/align/feature.client.js.map +1 -1
  8. package/dist/field/features/blockquote/feature.client.d.ts.map +1 -1
  9. package/dist/field/features/blockquote/feature.client.js +3 -6
  10. package/dist/field/features/blockquote/feature.client.js.map +1 -1
  11. package/dist/field/features/blockquote/feature.server.d.ts.map +1 -1
  12. package/dist/field/features/blockquote/feature.server.js +1 -2
  13. package/dist/field/features/blockquote/feature.server.js.map +1 -1
  14. package/dist/field/features/blockquote/markdownTransformer.d.ts.map +1 -1
  15. package/dist/field/features/blockquote/markdownTransformer.js +2 -4
  16. package/dist/field/features/blockquote/markdownTransformer.js.map +1 -1
  17. package/dist/field/features/blocks/component/BlockContent.d.ts.map +1 -1
  18. package/dist/field/features/blocks/component/BlockContent.js +3 -5
  19. package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
  20. package/dist/field/features/blocks/drawer/index.d.ts.map +1 -1
  21. package/dist/field/features/blocks/drawer/index.js +2 -4
  22. package/dist/field/features/blocks/drawer/index.js.map +1 -1
  23. package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
  24. package/dist/field/features/blocks/feature.server.js +28 -68
  25. package/dist/field/features/blocks/feature.server.js.map +1 -1
  26. package/dist/field/features/blocks/nodes/BlocksNode.d.ts +1 -3
  27. package/dist/field/features/blocks/nodes/BlocksNode.d.ts.map +1 -1
  28. package/dist/field/features/blocks/nodes/BlocksNode.js +1 -2
  29. package/dist/field/features/blocks/nodes/BlocksNode.js.map +1 -1
  30. package/dist/field/features/blocks/plugin/commands.d.ts.map +1 -1
  31. package/dist/field/features/blocks/plugin/commands.js +1 -2
  32. package/dist/field/features/blocks/plugin/commands.js.map +1 -1
  33. package/dist/field/features/blocks/plugin/index.d.ts.map +1 -1
  34. package/dist/field/features/blocks/plugin/index.js +3 -6
  35. package/dist/field/features/blocks/plugin/index.js.map +1 -1
  36. package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
  37. package/dist/field/features/blocks/populationPromise.js +0 -13
  38. package/dist/field/features/blocks/populationPromise.js.map +1 -1
  39. package/dist/field/features/blocks/validate.d.ts.map +1 -1
  40. package/dist/field/features/blocks/validate.js +2 -14
  41. package/dist/field/features/blocks/validate.js.map +1 -1
  42. package/dist/field/features/debug/testrecorder/plugin/index.d.ts.map +1 -1
  43. package/dist/field/features/debug/testrecorder/plugin/index.js +2 -4
  44. package/dist/field/features/debug/testrecorder/plugin/index.js.map +1 -1
  45. package/dist/field/features/debug/treeview/plugin/index.d.ts.map +1 -1
  46. package/dist/field/features/debug/treeview/plugin/index.js +2 -4
  47. package/dist/field/features/debug/treeview/plugin/index.js.map +1 -1
  48. package/dist/field/features/format/bold/feature.client.d.ts.map +1 -1
  49. package/dist/field/features/format/bold/feature.client.js +1 -2
  50. package/dist/field/features/format/bold/feature.client.js.map +1 -1
  51. package/dist/field/features/format/inlinecode/feature.client.d.ts.map +1 -1
  52. package/dist/field/features/format/inlinecode/feature.client.js +1 -2
  53. package/dist/field/features/format/inlinecode/feature.client.js.map +1 -1
  54. package/dist/field/features/format/italic/feature.client.d.ts.map +1 -1
  55. package/dist/field/features/format/italic/feature.client.js +1 -2
  56. package/dist/field/features/format/italic/feature.client.js.map +1 -1
  57. package/dist/field/features/format/strikethrough/feature.client.d.ts.map +1 -1
  58. package/dist/field/features/format/strikethrough/feature.client.js +1 -2
  59. package/dist/field/features/format/strikethrough/feature.client.js.map +1 -1
  60. package/dist/field/features/format/subscript/feature.client.d.ts.map +1 -1
  61. package/dist/field/features/format/subscript/feature.client.js +1 -2
  62. package/dist/field/features/format/subscript/feature.client.js.map +1 -1
  63. package/dist/field/features/format/superscript/feature.client.d.ts.map +1 -1
  64. package/dist/field/features/format/superscript/feature.client.js +1 -2
  65. package/dist/field/features/format/superscript/feature.client.js.map +1 -1
  66. package/dist/field/features/format/underline/feature.client.d.ts.map +1 -1
  67. package/dist/field/features/format/underline/feature.client.js +1 -2
  68. package/dist/field/features/format/underline/feature.client.js.map +1 -1
  69. package/dist/field/features/heading/feature.client.d.ts.map +1 -1
  70. package/dist/field/features/heading/feature.client.js +3 -6
  71. package/dist/field/features/heading/feature.client.js.map +1 -1
  72. package/dist/field/features/heading/feature.server.d.ts.map +1 -1
  73. package/dist/field/features/heading/feature.server.js +1 -2
  74. package/dist/field/features/heading/feature.server.js.map +1 -1
  75. package/dist/field/features/heading/markdownTransformer.d.ts.map +1 -1
  76. package/dist/field/features/heading/markdownTransformer.js +1 -2
  77. package/dist/field/features/heading/markdownTransformer.js.map +1 -1
  78. package/dist/field/features/horizontalrule/component/index.d.ts.map +1 -1
  79. package/dist/field/features/horizontalrule/component/index.js +2 -4
  80. package/dist/field/features/horizontalrule/component/index.js.map +1 -1
  81. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.d.ts +1 -3
  82. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.d.ts.map +1 -1
  83. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.js +1 -2
  84. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.js.map +1 -1
  85. package/dist/field/features/horizontalrule/plugin/index.d.ts.map +1 -1
  86. package/dist/field/features/horizontalrule/plugin/index.js +3 -6
  87. package/dist/field/features/horizontalrule/plugin/index.js.map +1 -1
  88. package/dist/field/features/indent/feature.client.d.ts.map +1 -1
  89. package/dist/field/features/indent/feature.client.js +1 -2
  90. package/dist/field/features/indent/feature.client.js.map +1 -1
  91. package/dist/field/features/link/drawer/baseFields.d.ts +3 -3
  92. package/dist/field/features/link/drawer/baseFields.d.ts.map +1 -1
  93. package/dist/field/features/link/drawer/baseFields.js +28 -42
  94. package/dist/field/features/link/drawer/baseFields.js.map +1 -1
  95. package/dist/field/features/link/drawer/types.d.ts +4 -2
  96. package/dist/field/features/link/drawer/types.d.ts.map +1 -1
  97. package/dist/field/features/link/drawer/types.js.map +1 -1
  98. package/dist/field/features/link/feature.client.d.ts.map +1 -1
  99. package/dist/field/features/link/feature.client.js +2 -4
  100. package/dist/field/features/link/feature.client.js.map +1 -1
  101. package/dist/field/features/link/feature.server.d.ts +0 -2
  102. package/dist/field/features/link/feature.server.d.ts.map +1 -1
  103. package/dist/field/features/link/feature.server.js +22 -6
  104. package/dist/field/features/link/feature.server.js.map +1 -1
  105. package/dist/field/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  106. package/dist/field/features/link/nodes/AutoLinkNode.js +1 -2
  107. package/dist/field/features/link/nodes/AutoLinkNode.js.map +1 -1
  108. package/dist/field/features/link/nodes/LinkNode.d.ts +1 -3
  109. package/dist/field/features/link/nodes/LinkNode.d.ts.map +1 -1
  110. package/dist/field/features/link/nodes/LinkNode.js +2 -4
  111. package/dist/field/features/link/nodes/LinkNode.js.map +1 -1
  112. package/dist/field/features/link/plugins/autoLink/index.d.ts.map +1 -1
  113. package/dist/field/features/link/plugins/autoLink/index.js +3 -6
  114. package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
  115. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.d.ts.map +1 -1
  116. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.js +1 -2
  117. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.js.map +1 -1
  118. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  119. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +56 -39
  120. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  121. package/dist/field/features/link/plugins/floatingLinkEditor/index.scss +9 -1
  122. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts +3 -5
  123. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
  124. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js +11 -29
  125. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
  126. package/dist/field/features/link/plugins/link/index.d.ts.map +1 -1
  127. package/dist/field/features/link/plugins/link/index.js +3 -12
  128. package/dist/field/features/link/plugins/link/index.js.map +1 -1
  129. package/dist/field/features/link/populationPromise.d.ts.map +1 -1
  130. package/dist/field/features/link/populationPromise.js +5 -23
  131. package/dist/field/features/link/populationPromise.js.map +1 -1
  132. package/dist/field/features/link/validate.d.ts +5 -0
  133. package/dist/field/features/link/validate.d.ts.map +1 -0
  134. package/dist/field/features/link/validate.js +32 -0
  135. package/dist/field/features/link/validate.js.map +1 -0
  136. package/dist/field/features/lists/checklist/feature.client.d.ts.map +1 -1
  137. package/dist/field/features/lists/checklist/feature.client.js +1 -2
  138. package/dist/field/features/lists/checklist/feature.client.js.map +1 -1
  139. package/dist/field/features/lists/checklist/feature.server.d.ts.map +1 -1
  140. package/dist/field/features/lists/checklist/feature.server.js +1 -2
  141. package/dist/field/features/lists/checklist/feature.server.js.map +1 -1
  142. package/dist/field/features/lists/checklist/markdownTransformers.d.ts.map +1 -1
  143. package/dist/field/features/lists/checklist/markdownTransformers.js +1 -2
  144. package/dist/field/features/lists/checklist/markdownTransformers.js.map +1 -1
  145. package/dist/field/features/lists/checklist/plugin/index.d.ts.map +1 -1
  146. package/dist/field/features/lists/checklist/plugin/index.js +1 -2
  147. package/dist/field/features/lists/checklist/plugin/index.js.map +1 -1
  148. package/dist/field/features/lists/common/markdown.d.ts.map +1 -1
  149. package/dist/field/features/lists/common/markdown.js +1 -2
  150. package/dist/field/features/lists/common/markdown.js.map +1 -1
  151. package/dist/field/features/lists/htmlConverter.d.ts.map +1 -1
  152. package/dist/field/features/lists/htmlConverter.js +1 -2
  153. package/dist/field/features/lists/htmlConverter.js.map +1 -1
  154. package/dist/field/features/lists/orderedlist/feature.client.d.ts.map +1 -1
  155. package/dist/field/features/lists/orderedlist/feature.client.js +1 -2
  156. package/dist/field/features/lists/orderedlist/feature.client.js.map +1 -1
  157. package/dist/field/features/lists/orderedlist/feature.server.d.ts.map +1 -1
  158. package/dist/field/features/lists/orderedlist/feature.server.js +1 -2
  159. package/dist/field/features/lists/orderedlist/feature.server.js.map +1 -1
  160. package/dist/field/features/lists/orderedlist/markdownTransformer.d.ts.map +1 -1
  161. package/dist/field/features/lists/orderedlist/markdownTransformer.js +1 -2
  162. package/dist/field/features/lists/orderedlist/markdownTransformer.js.map +1 -1
  163. package/dist/field/features/lists/plugin/index.d.ts.map +1 -1
  164. package/dist/field/features/lists/plugin/index.js +1 -2
  165. package/dist/field/features/lists/plugin/index.js.map +1 -1
  166. package/dist/field/features/lists/unorderedlist/feature.client.d.ts.map +1 -1
  167. package/dist/field/features/lists/unorderedlist/feature.client.js +1 -2
  168. package/dist/field/features/lists/unorderedlist/feature.client.js.map +1 -1
  169. package/dist/field/features/lists/unorderedlist/feature.server.d.ts.map +1 -1
  170. package/dist/field/features/lists/unorderedlist/feature.server.js +1 -2
  171. package/dist/field/features/lists/unorderedlist/feature.server.js.map +1 -1
  172. package/dist/field/features/lists/unorderedlist/markdownTransformer.d.ts.map +1 -1
  173. package/dist/field/features/lists/unorderedlist/markdownTransformer.js +1 -2
  174. package/dist/field/features/lists/unorderedlist/markdownTransformer.js.map +1 -1
  175. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -3
  176. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
  177. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +2 -4
  178. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  179. package/dist/field/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
  180. package/dist/field/features/migrations/slateToLexical/converter/index.js +2 -1
  181. package/dist/field/features/migrations/slateToLexical/converter/index.js.map +1 -1
  182. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -3
  183. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
  184. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +2 -4
  185. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  186. package/dist/field/features/paragraph/feature.client.d.ts.map +1 -1
  187. package/dist/field/features/paragraph/feature.client.js +2 -4
  188. package/dist/field/features/paragraph/feature.client.js.map +1 -1
  189. package/dist/field/features/relationship/drawer/commands.d.ts.map +1 -1
  190. package/dist/field/features/relationship/drawer/commands.js +1 -2
  191. package/dist/field/features/relationship/drawer/commands.js.map +1 -1
  192. package/dist/field/features/relationship/drawer/index.d.ts.map +1 -1
  193. package/dist/field/features/relationship/drawer/index.js +2 -4
  194. package/dist/field/features/relationship/drawer/index.js.map +1 -1
  195. package/dist/field/features/relationship/nodes/RelationshipNode.d.ts +2 -4
  196. package/dist/field/features/relationship/nodes/RelationshipNode.d.ts.map +1 -1
  197. package/dist/field/features/relationship/nodes/RelationshipNode.js +1 -2
  198. package/dist/field/features/relationship/nodes/RelationshipNode.js.map +1 -1
  199. package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
  200. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +53 -6
  201. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
  202. package/dist/field/features/relationship/plugins/index.d.ts.map +1 -1
  203. package/dist/field/features/relationship/plugins/index.js +3 -6
  204. package/dist/field/features/relationship/plugins/index.js.map +1 -1
  205. package/dist/field/features/types.d.ts +5 -1
  206. package/dist/field/features/types.d.ts.map +1 -1
  207. package/dist/field/features/types.js.map +1 -1
  208. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts.map +1 -1
  209. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js +2 -4
  210. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
  211. package/dist/field/features/upload/component/index.d.ts.map +1 -1
  212. package/dist/field/features/upload/component/index.js +52 -6
  213. package/dist/field/features/upload/component/index.js.map +1 -1
  214. package/dist/field/features/upload/drawer/commands.d.ts.map +1 -1
  215. package/dist/field/features/upload/drawer/commands.js +1 -2
  216. package/dist/field/features/upload/drawer/commands.js.map +1 -1
  217. package/dist/field/features/upload/drawer/index.d.ts.map +1 -1
  218. package/dist/field/features/upload/drawer/index.js +2 -4
  219. package/dist/field/features/upload/drawer/index.js.map +1 -1
  220. package/dist/field/features/upload/feature.server.d.ts.map +1 -1
  221. package/dist/field/features/upload/feature.server.js +14 -2
  222. package/dist/field/features/upload/feature.server.js.map +1 -1
  223. package/dist/field/features/upload/nodes/UploadNode.d.ts +1 -3
  224. package/dist/field/features/upload/nodes/UploadNode.d.ts.map +1 -1
  225. package/dist/field/features/upload/nodes/UploadNode.js +2 -8
  226. package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
  227. package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
  228. package/dist/field/features/upload/plugin/index.js +3 -6
  229. package/dist/field/features/upload/plugin/index.js.map +1 -1
  230. package/dist/field/features/upload/populationPromise.d.ts.map +1 -1
  231. package/dist/field/features/upload/populationPromise.js +2 -12
  232. package/dist/field/features/upload/populationPromise.js.map +1 -1
  233. package/dist/field/features/upload/validate.d.ts +2 -1
  234. package/dist/field/features/upload/validate.d.ts.map +1 -1
  235. package/dist/field/features/upload/validate.js +33 -11
  236. package/dist/field/features/upload/validate.js.map +1 -1
  237. package/dist/field/index.d.ts +1 -1
  238. package/dist/field/index.d.ts.map +1 -1
  239. package/dist/field/index.js.map +1 -1
  240. package/dist/field/lexical/LexicalEditor.d.ts.map +1 -1
  241. package/dist/field/lexical/LexicalEditor.js +6 -11
  242. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  243. package/dist/field/lexical/LexicalProvider.d.ts +1 -1
  244. package/dist/field/lexical/LexicalProvider.d.ts.map +1 -1
  245. package/dist/field/lexical/LexicalProvider.js +1 -2
  246. package/dist/field/lexical/LexicalProvider.js.map +1 -1
  247. package/dist/field/lexical/config/client/default.d.ts +1 -1
  248. package/dist/field/lexical/config/client/default.d.ts.map +1 -1
  249. package/dist/field/lexical/config/client/default.js.map +1 -1
  250. package/dist/field/lexical/config/client/sanitize.d.ts +1 -1
  251. package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
  252. package/dist/field/lexical/config/client/sanitize.js.map +1 -1
  253. package/dist/field/lexical/config/server/default.d.ts +2 -3
  254. package/dist/field/lexical/config/server/default.d.ts.map +1 -1
  255. package/dist/field/lexical/config/server/default.js +0 -2
  256. package/dist/field/lexical/config/server/default.js.map +1 -1
  257. package/dist/field/lexical/config/server/loader.d.ts +4 -2
  258. package/dist/field/lexical/config/server/loader.d.ts.map +1 -1
  259. package/dist/field/lexical/config/server/loader.js +3 -2
  260. package/dist/field/lexical/config/server/loader.js.map +1 -1
  261. package/dist/field/lexical/config/server/sanitize.d.ts +2 -1
  262. package/dist/field/lexical/config/server/sanitize.d.ts.map +1 -1
  263. package/dist/field/lexical/config/server/sanitize.js +3 -2
  264. package/dist/field/lexical/config/server/sanitize.js.map +1 -1
  265. package/dist/field/lexical/config/types.d.ts +1 -1
  266. package/dist/field/lexical/config/types.d.ts.map +1 -1
  267. package/dist/field/lexical/config/types.js.map +1 -1
  268. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts.map +1 -1
  269. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js +3 -6
  270. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js.map +1 -1
  271. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.d.ts.map +1 -1
  272. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js +3 -6
  273. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js.map +1 -1
  274. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +1 -1
  275. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js +27 -29
  276. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +1 -1
  277. package/dist/field/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  278. package/dist/field/lexical/plugins/MarkdownShortcut/index.js +1 -2
  279. package/dist/field/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  280. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  281. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +3 -6
  282. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  283. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  284. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +3 -6
  285. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  286. package/dist/field/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
  287. package/dist/field/lexical/plugins/SlashMenu/index.js +1 -2
  288. package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
  289. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
  290. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -4
  291. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  292. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts.map +1 -1
  293. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js +1 -2
  294. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js.map +1 -1
  295. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  296. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js +2 -4
  297. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  298. package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.d.ts.map +1 -1
  299. package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js +1 -2
  300. package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js.map +1 -1
  301. package/dist/field/lexical/theme/EditorTheme.scss +7 -8
  302. package/dist/field/lexical/ui/ContentEditable.d.ts.map +1 -1
  303. package/dist/field/lexical/ui/ContentEditable.js +1 -2
  304. package/dist/field/lexical/ui/ContentEditable.js.map +1 -1
  305. package/dist/field/lexical/utils/getSelectedNode.d.ts.map +1 -1
  306. package/dist/field/lexical/utils/getSelectedNode.js +1 -2
  307. package/dist/field/lexical/utils/getSelectedNode.js.map +1 -1
  308. package/dist/field/lexical/utils/nodeFormat.d.ts +2 -1
  309. package/dist/field/lexical/utils/nodeFormat.d.ts.map +1 -1
  310. package/dist/field/lexical/utils/nodeFormat.js.map +1 -1
  311. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts +1 -1
  312. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
  313. package/dist/field/lexical/utils/setFloatingElemPosition.js +15 -13
  314. package/dist/field/lexical/utils/setFloatingElemPosition.js.map +1 -1
  315. package/dist/field/lexical/utils/url.d.ts.map +1 -1
  316. package/dist/field/lexical/utils/url.js +2 -0
  317. package/dist/field/lexical/utils/url.js.map +1 -1
  318. package/dist/generateComponentMap.d.ts.map +1 -1
  319. package/dist/generateComponentMap.js +1 -10
  320. package/dist/generateComponentMap.js.map +1 -1
  321. package/dist/generateSchemaMap.d.ts.map +1 -1
  322. package/dist/generateSchemaMap.js +1 -10
  323. package/dist/generateSchemaMap.js.map +1 -1
  324. package/dist/index.d.ts +3 -3
  325. package/dist/index.d.ts.map +1 -1
  326. package/dist/index.js +241 -234
  327. package/dist/index.js.map +1 -1
  328. package/dist/populate/defaultValue.d.ts.map +1 -1
  329. package/dist/populate/defaultValue.js +1 -0
  330. package/dist/populate/defaultValue.js.map +1 -1
  331. package/dist/types.d.ts +11 -5
  332. package/dist/types.d.ts.map +1 -1
  333. package/dist/types.js.map +1 -1
  334. package/dist/validate/index.d.ts +1 -1
  335. package/dist/validate/index.d.ts.map +1 -1
  336. package/package.json +46 -45
@@ -1,4 +1,4 @@
1
- import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js';
1
+ import type { EditorConfig as LexicalEditorConfig } from 'lexical';
2
2
  import type { ResolvedClientFeatureMap, SanitizedClientFeatures } from '../../../features/types.js';
3
3
  import type { SanitizedClientEditorConfig } from '../types.js';
4
4
  export declare const sanitizeClientFeatures: (features: ResolvedClientFeatureMap) => SanitizedClientFeatures;
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnF,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,eAAO,MAAM,sBAAsB,0CAEhC,uBA4IF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mBAAmB,EAC5B,wBAAwB,EAAE,wBAAwB,GACjD,2BAA2B,CAM7B"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,eAAO,MAAM,sBAAsB,0CAEhC,uBA4IF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mBAAmB,EAC5B,wBAAwB,EAAE,wBAAwB,GACjD,2BAA2B,CAM7B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport type { ResolvedClientFeatureMap, SanitizedClientFeatures } from '../../../features/types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\nexport const sanitizeClientFeatures = (\n features: ResolvedClientFeatureMap,\n): SanitizedClientFeatures => {\n const sanitized: SanitizedClientFeatures = {\n enabledFeatures: [],\n floatingSelectToolbar: {\n sections: [],\n },\n hooks: {\n load: [],\n save: [],\n },\n markdownTransformers: [],\n nodes: [],\n plugins: [],\n slashMenu: {\n dynamicOptions: [],\n groupsWithOptions: [],\n },\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature.hooks) {\n if (feature.hooks?.load?.length) {\n sanitized.hooks.load = sanitized.hooks.load.concat(feature.hooks.load)\n }\n if (feature.hooks?.save?.length) {\n sanitized.hooks.save = sanitized.hooks.save.concat(feature.hooks.save)\n }\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\n }\n if (feature.plugins?.length) {\n feature.plugins.forEach((plugin, i) => {\n sanitized.plugins.push({\n Component: plugin.Component,\n key: feature.key + i,\n position: plugin.position,\n })\n })\n }\n\n if (feature.floatingSelectToolbar?.sections?.length) {\n for (const section of feature.floatingSelectToolbar.sections) {\n // 1. find the section with the same key or create new one\n let foundSection = sanitized.floatingSelectToolbar.sections.find(\n (sanitizedSection) => sanitizedSection.key === section.key,\n )\n if (!foundSection) {\n foundSection = {\n ...section,\n entries: [],\n }\n } else {\n sanitized.floatingSelectToolbar.sections =\n sanitized.floatingSelectToolbar.sections.filter(\n (sanitizedSection) => sanitizedSection.key !== section.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (section?.entries?.length) {\n foundSection.entries = foundSection.entries.concat(section.entries)\n }\n sanitized.floatingSelectToolbar?.sections.push(foundSection)\n }\n }\n\n if (feature.slashMenu?.options) {\n if (feature.slashMenu.dynamicOptions?.length) {\n sanitized.slashMenu.dynamicOptions = sanitized.slashMenu.dynamicOptions.concat(\n feature.slashMenu.dynamicOptions,\n )\n }\n\n for (const optionGroup of feature.slashMenu.options) {\n // 1. find the group with the same name or create new one\n let group = sanitized.slashMenu.groupsWithOptions.find(\n (group) => group.key === optionGroup.key,\n )\n if (!group) {\n group = {\n ...optionGroup,\n options: [],\n }\n } else {\n sanitized.slashMenu.groupsWithOptions = sanitized.slashMenu.groupsWithOptions.filter(\n (group) => group.key !== optionGroup.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (optionGroup?.options?.length) {\n group.options = group.options.concat(optionGroup.options)\n }\n sanitized.slashMenu.groupsWithOptions.push(group)\n }\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n sanitized.enabledFeatures.push(feature.key)\n })\n\n // Sort sanitized.floatingSelectToolbar.sections by order property\n sanitized.floatingSelectToolbar.sections.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n\n // Sort sanitized.floatingSelectToolbar.sections.[section].entries by order property\n for (const section of sanitized.floatingSelectToolbar.sections) {\n section.entries.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n return sanitized\n}\n\nexport function sanitizeClientEditorConfig(\n lexical: LexicalEditorConfig,\n resolvedClientFeatureMap: ResolvedClientFeatureMap,\n): SanitizedClientEditorConfig {\n return {\n features: sanitizeClientFeatures(resolvedClientFeatureMap),\n lexical,\n resolvedFeatureMap: resolvedClientFeatureMap,\n }\n}\n"],"names":["sanitizeClientFeatures","features","sanitized","enabledFeatures","floatingSelectToolbar","sections","hooks","load","save","markdownTransformers","nodes","plugins","slashMenu","dynamicOptions","groupsWithOptions","size","forEach","feature","length","concat","plugin","i","push","Component","key","position","section","foundSection","find","sanitizedSection","entries","filter","options","optionGroup","group","sort","a","b","order","sanitizeClientEditorConfig","lexical","resolvedClientFeatureMap","resolvedFeatureMap"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAOA,OAAO,MAAMA,yBAAyB,CACpCC;IAEA,MAAMC,YAAqC;QACzCC,iBAAiB,EAAE;QACnBC,uBAAuB;YACrBC,UAAU,EAAE;QACd;QACAC,OAAO;YACLC,MAAM,EAAE;YACRC,MAAM,EAAE;QACV;QACAC,sBAAsB,EAAE;QACxBC,OAAO,EAAE;QACTC,SAAS,EAAE;QACXC,WAAW;YACTC,gBAAgB,EAAE;YAClBC,mBAAmB,EAAE;QACvB;IACF;IAEA,IAAI,CAACb,UAAUc,MAAM;QACnB,OAAOb;IACT;IAEAD,SAASe,OAAO,CAAC,CAACC;QAChB,IAAIA,QAAQX,KAAK,EAAE;YACjB,IAAIW,QAAQX,KAAK,EAAEC,MAAMW,QAAQ;gBAC/BhB,UAAUI,KAAK,CAACC,IAAI,GAAGL,UAAUI,KAAK,CAACC,IAAI,CAACY,MAAM,CAACF,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AAEE,KAAK,GAAGD,EAAEC,KAAK;QAC1B,OAAO,IAAIF,EAAEE,KAAK,EAAE;YAClB,OAAO,CAAC;QACV,OAAO,IAAID,EAAEC,KAAK,EAAE;YAClB,OAAO;QACT,OAAO;YACL,OAAO;QACT;IACF;IAEA,oFAAoF;IACpF,KAAK,MAAMZ,WAAWxB,UAAUE,qBAAqB,CAACC,QAAQ,CAAE;QAC9DqB,QAAQI,OAAO,CAACK,IAAI,CAAC,CAACC,GAAGC;YACvB,IAAID,EAAEE,KAAK,IAAID,EAAEC,KAAK,EAAE;gBACtB,OAAOF,EAAEE,KAAK,GAAGD,EAAEC,KAAK;YAC1B,OAAO,IAAIF,EAAEE,KAAK,EAAE;gBAClB,OAAO,CAAC;YACV,OAAO,IAAID,EAAEC,KAAK,EAAE;gBAClB,OAAO;YACT,OAAO;gBACL,OAAO;YACT;QACF;IACF;IAEA,OAAOpC;AACT,EAAC;AAED,OAAO,SAASqC,2BACdC,OAA4B,EAC5BC,wBAAkD;IAElD,OAAO;QACLxC,UAAUD,uBAAuByC;QACjCD;QACAE,oBAAoBD;IACtB;AACF"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type { ResolvedClientFeatureMap, SanitizedClientFeatures } from '../../../features/types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\nexport const sanitizeClientFeatures = (\n features: ResolvedClientFeatureMap,\n): SanitizedClientFeatures => {\n const sanitized: SanitizedClientFeatures = {\n enabledFeatures: [],\n floatingSelectToolbar: {\n sections: [],\n },\n hooks: {\n load: [],\n save: [],\n },\n markdownTransformers: [],\n nodes: [],\n plugins: [],\n slashMenu: {\n dynamicOptions: [],\n groupsWithOptions: [],\n },\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature.hooks) {\n if (feature.hooks?.load?.length) {\n sanitized.hooks.load = sanitized.hooks.load.concat(feature.hooks.load)\n }\n if (feature.hooks?.save?.length) {\n sanitized.hooks.save = sanitized.hooks.save.concat(feature.hooks.save)\n }\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\n }\n if (feature.plugins?.length) {\n feature.plugins.forEach((plugin, i) => {\n sanitized.plugins.push({\n Component: plugin.Component,\n key: feature.key + i,\n position: plugin.position,\n })\n })\n }\n\n if (feature.floatingSelectToolbar?.sections?.length) {\n for (const section of feature.floatingSelectToolbar.sections) {\n // 1. find the section with the same key or create new one\n let foundSection = sanitized.floatingSelectToolbar.sections.find(\n (sanitizedSection) => sanitizedSection.key === section.key,\n )\n if (!foundSection) {\n foundSection = {\n ...section,\n entries: [],\n }\n } else {\n sanitized.floatingSelectToolbar.sections =\n sanitized.floatingSelectToolbar.sections.filter(\n (sanitizedSection) => sanitizedSection.key !== section.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (section?.entries?.length) {\n foundSection.entries = foundSection.entries.concat(section.entries)\n }\n sanitized.floatingSelectToolbar?.sections.push(foundSection)\n }\n }\n\n if (feature.slashMenu?.options) {\n if (feature.slashMenu.dynamicOptions?.length) {\n sanitized.slashMenu.dynamicOptions = sanitized.slashMenu.dynamicOptions.concat(\n feature.slashMenu.dynamicOptions,\n )\n }\n\n for (const optionGroup of feature.slashMenu.options) {\n // 1. find the group with the same name or create new one\n let group = sanitized.slashMenu.groupsWithOptions.find(\n (group) => group.key === optionGroup.key,\n )\n if (!group) {\n group = {\n ...optionGroup,\n options: [],\n }\n } else {\n sanitized.slashMenu.groupsWithOptions = sanitized.slashMenu.groupsWithOptions.filter(\n (group) => group.key !== optionGroup.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (optionGroup?.options?.length) {\n group.options = group.options.concat(optionGroup.options)\n }\n sanitized.slashMenu.groupsWithOptions.push(group)\n }\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n sanitized.enabledFeatures.push(feature.key)\n })\n\n // Sort sanitized.floatingSelectToolbar.sections by order property\n sanitized.floatingSelectToolbar.sections.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n\n // Sort sanitized.floatingSelectToolbar.sections.[section].entries by order property\n for (const section of sanitized.floatingSelectToolbar.sections) {\n section.entries.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n return sanitized\n}\n\nexport function sanitizeClientEditorConfig(\n lexical: LexicalEditorConfig,\n resolvedClientFeatureMap: ResolvedClientFeatureMap,\n): SanitizedClientEditorConfig {\n return {\n features: sanitizeClientFeatures(resolvedClientFeatureMap),\n lexical,\n resolvedFeatureMap: resolvedClientFeatureMap,\n }\n}\n"],"names":["sanitizeClientFeatures","features","sanitized","enabledFeatures","floatingSelectToolbar","sections","hooks","load","save","markdownTransformers","nodes","plugins","slashMenu","dynamicOptions","groupsWithOptions","size","forEach","feature","length","concat","plugin","i","push","Component","key","position","section","foundSection","find","sanitizedSection","entries","filter","options","optionGroup","group","sort","a","b","order","sanitizeClientEditorConfig","lexical","resolvedClientFeatureMap","resolvedFeatureMap"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAOA,OAAO,MAAMA,yBAAyB,CACpCC;IAEA,MAAMC,YAAqC;QACzCC,iBAAiB,EAAE;QACnBC,uBAAuB;YACrBC,UAAU,EAAE;QACd;QACAC,OAAO;YACLC,MAAM,EAAE;YACRC,MAAM,EAAE;QACV;QACAC,sBAAs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CAACY;YAC7C;QACF;QAEA,IAAIjB,QAAQR,oBAAoB,EAAES,QAAQ;YACxChB,UAAUO,oBAAoB,GAAGP,UAAUO,oBAAoB,CAACU,MAAM,CACpEF,QAAQR,oBAAoB;QAEhC;QACAP,UAAUC,eAAe,CAACmB,IAAI,CAACL,QAAQO,GAAG;IAC5C;IAEA,kEAAkE;IAClEtB,UAAUE,qBAAqB,CAACC,QAAQ,CAAC8B,IAAI,CAAC,CAACC,GAAGC;QAChD,IAAID,EAAEE,KAAK,IAAID,EAAEC,KAAK,EAAE;YACtB,OAAOF,EAAEE,KAAK,GAAGD,EAAEC,KAAK;QAC1B,OAAO,IAAIF,EAAEE,KAAK,EAAE;YAClB,OAAO,CAAC;QACV,OAAO,IAAID,EAAEC,KAAK,EAAE;YAClB,OAAO;QACT,OAAO;YACL,OAAO;QACT;IACF;IAEA,oFAAoF;IACpF,KAAK,MAAMZ,WAAWxB,UAAUE,qBAAqB,CAACC,QAAQ,CAAE;QAC9DqB,QAAQI,OAAO,CAACK,IAAI,CAAC,CAACC,GAAGC;YACvB,IAAID,EAAEE,KAAK,IAAID,EAAEC,KAAK,EAAE;gBACtB,OAAOF,EAAEE,KAAK,GAAGD,EAAEC,KAAK;YAC1B,OAAO,IAAIF,EAAEE,KAAK,EAAE;gBAClB,OAAO,CAAC;YACV,OAAO,IAAID,EAAEC,KAAK,EAAE;gBAClB,OAAO;YACT,OAAO;gBACL,OAAO;YACT;QACF;IACF;IAEA,OAAOpC;AACT,EAAC;AAED,OAAO,SAASqC,2BACdC,OAA4B,EAC5BC,wBAAkD;IAElD,OAAO;QACLxC,UAAUD,uBAAuByC;QACjCD;QACAE,oBAAoBD;IACtB;AACF"}
@@ -1,8 +1,7 @@
1
- import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js';
1
+ import type { EditorConfig as LexicalEditorConfig } from 'lexical';
2
2
  import type { FeatureProviderServer } from '../../../features/types.js';
3
- import type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js';
3
+ import type { ServerEditorConfig } from '../types.js';
4
4
  export declare const defaultEditorLexicalConfig: LexicalEditorConfig;
5
5
  export declare const defaultEditorFeatures: FeatureProviderServer<unknown, unknown>[];
6
6
  export declare const defaultEditorConfig: ServerEditorConfig;
7
- export declare const defaultSanitizedServerEditorConfig: SanitizedServerEditorConfig;
8
7
  //# sourceMappingURL=default.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAwBlF,eAAO,MAAM,0BAA0B,EAAE,mBAGxC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAoB1E,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,kBAGjC,CAAA;AAED,eAAO,MAAM,kCAAkC,EAAE,2BACA,CAAA"}
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAuBlF,eAAO,MAAM,0BAA0B,EAAE,mBAGxC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAoB1E,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,kBAGjC,CAAA"}
@@ -18,7 +18,6 @@ import { ParagraphFeature } from '../../../features/paragraph/feature.server.js'
18
18
  import { RelationshipFeature } from '../../../features/relationship/feature.server.js';
19
19
  import { UploadFeature } from '../../../features/upload/feature.server.js';
20
20
  import { LexicalEditorTheme } from '../../theme/EditorTheme.js';
21
- import { sanitizeServerEditorConfig } from './sanitize.js';
22
21
  export const defaultEditorLexicalConfig = {
23
22
  namespace: 'lexical',
24
23
  theme: LexicalEditorTheme
@@ -48,6 +47,5 @@ export const defaultEditorConfig = {
48
47
  features: defaultEditorFeatures,
49
48
  lexical: defaultEditorLexicalConfig
50
49
  };
51
- export const defaultSanitizedServerEditorConfig = sanitizeServerEditorConfig(defaultEditorConfig);
52
50
 
53
51
  //# sourceMappingURL=default.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/config/server/default.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport type { FeatureProviderServer } from '../../../features/types.js'\nimport type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js'\n\nimport { AlignFeature } from '../../../features/align/feature.server.js'\nimport { BlockQuoteFeature } from '../../../features/blockquote/feature.server.js'\nimport { BoldFeature } from '../../../features/format/bold/feature.server.js'\nimport { InlineCodeFeature } from '../../../features/format/inlinecode/feature.server.js'\nimport { ItalicFeature } from '../../../features/format/italic/feature.server.js'\nimport { StrikethroughFeature } from '../../../features/format/strikethrough/feature.server.js'\nimport { SubscriptFeature } from '../../../features/format/subscript/feature.server.js'\nimport { SuperscriptFeature } from '../../../features/format/superscript/feature.server.js'\nimport { UnderlineFeature } from '../../../features/format/underline/feature.server.js'\nimport { HeadingFeature } from '../../../features/heading/feature.server.js'\nimport { HorizontalRuleFeature } from '../../../features/horizontalrule/feature.server.js'\nimport { IndentFeature } from '../../../features/indent/feature.server.js'\nimport { LinkFeature } from '../../../features/link/feature.server.js'\nimport { CheckListFeature } from '../../../features/lists/checklist/feature.server.js'\nimport { OrderedListFeature } from '../../../features/lists/orderedlist/feature.server.js'\nimport { UnorderedListFeature } from '../../../features/lists/unorderedlist/feature.server.js'\nimport { ParagraphFeature } from '../../../features/paragraph/feature.server.js'\nimport { RelationshipFeature } from '../../../features/relationship/feature.server.js'\nimport { UploadFeature } from '../../../features/upload/feature.server.js'\nimport { LexicalEditorTheme } from '../../theme/EditorTheme.js'\nimport { sanitizeServerEditorConfig } from './sanitize.js'\n\nexport const defaultEditorLexicalConfig: LexicalEditorConfig = {\n namespace: 'lexical',\n theme: LexicalEditorTheme,\n}\n\nexport const defaultEditorFeatures: FeatureProviderServer<unknown, unknown>[] = [\n BoldFeature(),\n ItalicFeature(),\n UnderlineFeature(),\n StrikethroughFeature(),\n SubscriptFeature(),\n SuperscriptFeature(),\n InlineCodeFeature(),\n ParagraphFeature(),\n HeadingFeature(),\n AlignFeature(),\n IndentFeature(),\n UnorderedListFeature(),\n OrderedListFeature(),\n CheckListFeature(),\n LinkFeature(),\n RelationshipFeature(),\n BlockQuoteFeature(),\n UploadFeature(),\n HorizontalRuleFeature(),\n]\n\nexport const defaultEditorConfig: ServerEditorConfig = {\n features: defaultEditorFeatures,\n lexical: defaultEditorLexicalConfig,\n}\n\nexport const defaultSanitizedServerEditorConfig: SanitizedServerEditorConfig =\n sanitizeServerEditorConfig(defaultEditorConfig)\n"],"names":["AlignFeature","BlockQuoteFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","LinkFeature","CheckListFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","UploadFeature","LexicalEditorTheme","sanitizeServerEditorConfig","defaultEditorLexicalConfig","namespace","theme","defaultEditorFeatures","defaultEditorConfig","features","lexical","defaultSanitizedServerEditorConfig"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,YAAY,QAAQ,4CAA2C;AACxE,SAASC,iBAAiB,QAAQ,iDAAgD;AAClF,SAASC,WAAW,QAAQ,kDAAiD;AAC7E,SAASC,iBAAiB,QAAQ,wDAAuD;AACzF,SAASC,aAAa,QAAQ,oDAAmD;AACjF,SAASC,oBAAoB,QAAQ,2DAA0D;AAC/F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,kBAAkB,QAAQ,yDAAwD;AAC3F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,cAAc,QAAQ,8CAA6C;AAC5E,SAASC,qBAAqB,QAAQ,qDAAoD;AAC1F,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,WAAW,QAAQ,2CAA0C;AACtE,SAASC,gBAAgB,QAAQ,sDAAqD;AACtF,SAASC,kBAAkB,QAAQ,wDAAuD;AAC1F,SAASC,oBAAoB,QAAQ,0DAAyD;AAC9F,SAASC,gBAAgB,QAAQ,gDAA+C;AAChF,SAASC,mBAAmB,QAAQ,mDAAkD;AACtF,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,0BAA0B,QAAQ,gBAAe;AAE1D,OAAO,MAAMC,6BAAkD;IAC7DC,WAAW;IACXC,OAAOJ;AACT,EAAC;AAED,OAAO,MAAMK,wBAAmE;IAC9EtB;IACAE;IACAI;IACAH;IACAC;IACAC;IACAJ;IACAa;IACAP;IACAT;IACAW;IACAI;IACAD;IACAD;IACAD;IACAK;IACAhB;IACAiB;IACAR;CACD,CAAA;AAED,OAAO,MAAMe,sBAA0C;IACrDC,UAAUF;IACVG,SAASN;AACX,EAAC;AAED,OAAO,MAAMO,qCACXR,2BAA2BK,qBAAoB"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/config/server/default.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type { FeatureProviderServer } from '../../../features/types.js'\nimport type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js'\n\nimport { AlignFeature } from '../../../features/align/feature.server.js'\nimport { BlockQuoteFeature } from '../../../features/blockquote/feature.server.js'\nimport { BoldFeature } from '../../../features/format/bold/feature.server.js'\nimport { InlineCodeFeature } from '../../../features/format/inlinecode/feature.server.js'\nimport { ItalicFeature } from '../../../features/format/italic/feature.server.js'\nimport { StrikethroughFeature } from '../../../features/format/strikethrough/feature.server.js'\nimport { SubscriptFeature } from '../../../features/format/subscript/feature.server.js'\nimport { SuperscriptFeature } from '../../../features/format/superscript/feature.server.js'\nimport { UnderlineFeature } from '../../../features/format/underline/feature.server.js'\nimport { HeadingFeature } from '../../../features/heading/feature.server.js'\nimport { HorizontalRuleFeature } from '../../../features/horizontalrule/feature.server.js'\nimport { IndentFeature } from '../../../features/indent/feature.server.js'\nimport { LinkFeature } from '../../../features/link/feature.server.js'\nimport { CheckListFeature } from '../../../features/lists/checklist/feature.server.js'\nimport { OrderedListFeature } from '../../../features/lists/orderedlist/feature.server.js'\nimport { UnorderedListFeature } from '../../../features/lists/unorderedlist/feature.server.js'\nimport { ParagraphFeature } from '../../../features/paragraph/feature.server.js'\nimport { RelationshipFeature } from '../../../features/relationship/feature.server.js'\nimport { UploadFeature } from '../../../features/upload/feature.server.js'\nimport { LexicalEditorTheme } from '../../theme/EditorTheme.js'\n\nexport const defaultEditorLexicalConfig: LexicalEditorConfig = {\n namespace: 'lexical',\n theme: LexicalEditorTheme,\n}\n\nexport const defaultEditorFeatures: FeatureProviderServer<unknown, unknown>[] = [\n BoldFeature(),\n ItalicFeature(),\n UnderlineFeature(),\n StrikethroughFeature(),\n SubscriptFeature(),\n SuperscriptFeature(),\n InlineCodeFeature(),\n ParagraphFeature(),\n HeadingFeature(),\n AlignFeature(),\n IndentFeature(),\n UnorderedListFeature(),\n OrderedListFeature(),\n CheckListFeature(),\n LinkFeature(),\n RelationshipFeature(),\n BlockQuoteFeature(),\n UploadFeature(),\n HorizontalRuleFeature(),\n]\n\nexport const defaultEditorConfig: ServerEditorConfig = {\n features: defaultEditorFeatures,\n lexical: defaultEditorLexicalConfig,\n}\n"],"names":["AlignFeature","BlockQuoteFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","LinkFeature","CheckListFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","UploadFeature","LexicalEditorTheme","defaultEditorLexicalConfig","namespace","theme","defaultEditorFeatures","defaultEditorConfig","features","lexical"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,YAAY,QAAQ,4CAA2C;AACxE,SAASC,iBAAiB,QAAQ,iDAAgD;AAClF,SAASC,WAAW,QAAQ,kDAAiD;AAC7E,SAASC,iBAAiB,QAAQ,wDAAuD;AACzF,SAASC,aAAa,QAAQ,oDAAmD;AACjF,SAASC,oBAAoB,QAAQ,2DAA0D;AAC/F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,kBAAkB,QAAQ,yDAAwD;AAC3F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,cAAc,QAAQ,8CAA6C;AAC5E,SAASC,qBAAqB,QAAQ,qDAAoD;AAC1F,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,WAAW,QAAQ,2CAA0C;AACtE,SAASC,gBAAgB,QAAQ,sDAAqD;AACtF,SAASC,kBAAkB,QAAQ,wDAAuD;AAC1F,SAASC,oBAAoB,QAAQ,0DAAyD;AAC9F,SAASC,gBAAgB,QAAQ,gDAA+C;AAChF,SAASC,mBAAmB,QAAQ,mDAAkD;AACtF,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,kBAAkB,QAAQ,6BAA4B;AAE/D,OAAO,MAAMC,6BAAkD;IAC7DC,WAAW;IACXC,OAAOH;AACT,EAAC;AAED,OAAO,MAAMI,wBAAmE;IAC9ErB;IACAE;IACAI;IACAH;IACAC;IACAC;IACAJ;IACAa;IACAP;IACAT;IACAW;IACAI;IACAD;IACAD;IACAD;IACAK;IACAhB;IACAiB;IACAR;CACD,CAAA;AAED,OAAO,MAAMc,sBAA0C;IACrDC,UAAUF;IACVG,SAASN;AACX,EAAC"}
@@ -1,7 +1,9 @@
1
+ import type { SanitizedConfig } from 'payload/config';
1
2
  import type { FeatureProviderServer, ResolvedServerFeatureMap } from '../../../features/types.js';
2
3
  import type { ServerEditorConfig } from '../types.js';
3
4
  export declare function sortFeaturesForOptimalLoading(featureProviders: FeatureProviderServer<unknown, unknown>[]): FeatureProviderServer<unknown, unknown>[];
4
- export declare function loadFeatures({ unSanitizedEditorConfig, }: {
5
+ export declare function loadFeatures({ config, unSanitizedEditorConfig, }: {
6
+ config: SanitizedConfig;
5
7
  unSanitizedEditorConfig: ServerEditorConfig;
6
- }): ResolvedServerFeatureMap;
8
+ }): Promise<ResolvedServerFeatureMap>;
7
9
  //# sourceMappingURL=loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EAEzB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AA8FrD,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GAC1D,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAE3C;AAED,wBAAgB,YAAY,CAAC,EAC3B,uBAAuB,GACxB,EAAE;IACD,uBAAuB,EAAE,kBAAkB,CAAA;CAC5C,GAAG,wBAAwB,CA8E3B"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EAEzB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AA8FrD,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GAC1D,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAE3C;AAED,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,uBAAuB,GACxB,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,uBAAuB,EAAE,kBAAkB,CAAA;CAC5C,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA+EpC"}
@@ -57,7 +57,7 @@ function visit(graph, key, visited, stack, currentPath = []) {
57
57
  export function sortFeaturesForOptimalLoading(featureProviders) {
58
58
  return topologicallySortFeatures(featureProviders);
59
59
  }
60
- export function loadFeatures({ unSanitizedEditorConfig }) {
60
+ export async function loadFeatures({ config, unSanitizedEditorConfig }) {
61
61
  // First remove all duplicate features. The LAST feature with a given key wins.
62
62
  unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.reverse().filter((f, i, arr)=>{
63
63
  const firstIndex = arr.findIndex((f2)=>f2.key === f.key);
@@ -97,7 +97,8 @@ export function loadFeatures({ unSanitizedEditorConfig }) {
97
97
  }
98
98
  }
99
99
  }
100
- const feature = featureProvider.feature({
100
+ const feature = await featureProvider.feature({
101
+ config,
101
102
  featureProviderMap,
102
103
  resolvedFeatures,
103
104
  unSanitizedEditorConfig
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/config/server/loader.ts"],"sourcesContent":["import type {\n FeatureProviderServer,\n ResolvedServerFeatureMap,\n ServerFeatureProviderMap,\n} from '../../../features/types.js'\nimport type { ServerEditorConfig } from '../types.js'\n\ntype DependencyGraph = {\n [key: string]: {\n dependencies: string[]\n dependenciesPriority: string[]\n dependenciesSoft: string[]\n featureProvider: FeatureProviderServer<unknown, unknown>\n }\n}\n\nfunction createDependencyGraph(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): DependencyGraph {\n const graph: DependencyGraph = {}\n for (const fp of featureProviders) {\n graph[fp.key] = {\n dependencies: fp.dependencies || [],\n dependenciesPriority: fp.dependenciesPriority || [],\n dependenciesSoft: fp.dependenciesSoft || [],\n featureProvider: fp,\n }\n }\n return graph\n}\n\nfunction topologicallySortFeatures(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): FeatureProviderServer<unknown, unknown>[] {\n const graph = createDependencyGraph(featureProviders)\n const visited: { [key: string]: boolean } = {}\n const stack: FeatureProviderServer<unknown, unknown>[] = []\n\n for (const key in graph) {\n if (!visited[key]) {\n visit(graph, key, visited, stack)\n }\n }\n\n return stack.reverse()\n}\n\nfunction visit(\n graph: DependencyGraph,\n key: string,\n visited: { [key: string]: boolean },\n stack: FeatureProviderServer<unknown, unknown>[],\n currentPath: string[] = [],\n) {\n if (!graph[key]) {\n throw new Error(`Feature key ${key} is not present in the dependency graph.`)\n }\n\n if (currentPath.includes(key)) {\n throw new Error(`Circular dependency detected: ${currentPath.join(' -> ')} -> ${key}`)\n }\n\n if (visited[key]) {\n return\n }\n\n visited[key] = true\n currentPath.push(key)\n\n // First process the hard priority dependencies\n for (const dep of graph[key].dependenciesPriority) {\n if (!visited[dep]) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n // Then process the normal dependencies, but make sure to not violate hard dependencies\n for (const dep of graph[key].dependencies) {\n if (!visited[dep] && !graph[key].dependenciesPriority.includes(dep)) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n // Then process the soft dependencies. Make sure to not violate hard and normal dependencies.\n for (const dep of graph[key].dependenciesSoft) {\n if (\n graph[dep] &&\n !visited[dep] &&\n !graph[key].dependenciesPriority.includes(dep) &&\n !graph[key].dependencies.includes(dep)\n ) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n stack.push(graph[key].featureProvider)\n currentPath.pop()\n}\n\nexport function sortFeaturesForOptimalLoading(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): FeatureProviderServer<unknown, unknown>[] {\n return topologicallySortFeatures(featureProviders)\n}\n\nexport function loadFeatures({\n unSanitizedEditorConfig,\n}: {\n unSanitizedEditorConfig: ServerEditorConfig\n}): ResolvedServerFeatureMap {\n // First remove all duplicate features. The LAST feature with a given key wins.\n unSanitizedEditorConfig.features = unSanitizedEditorConfig.features\n .reverse()\n .filter((f, i, arr) => {\n const firstIndex = arr.findIndex((f2) => f2.key === f.key)\n return firstIndex === i\n })\n .reverse()\n\n unSanitizedEditorConfig.features = sortFeaturesForOptimalLoading(unSanitizedEditorConfig.features)\n\n const featureProviderMap: ServerFeatureProviderMap = new Map(\n unSanitizedEditorConfig.features.map(\n (f) => [f.key, f] as [string, FeatureProviderServer<unknown, unknown>],\n ),\n )\n\n const resolvedFeatures: ResolvedServerFeatureMap = 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 if (!featureProvider.key) {\n throw new Error(\n `A Feature you've added does not have a key. Please add a key to the feature. This is used to uniquely identify the feature.`,\n )\n }\n if (featureProvider.dependencies?.length) {\n for (const dependencyKey of featureProvider.dependencies) {\n const found = unSanitizedEditorConfig.features.find((f) => f.key === dependencyKey)\n if (!found) {\n throw new Error(\n `Feature ${featureProvider.key} has a dependency ${dependencyKey} which does not exist.`,\n )\n }\n }\n }\n\n if (featureProvider.dependenciesPriority?.length) {\n for (const priorityDependencyKey of featureProvider.dependenciesPriority) {\n // look in the resolved features instead of the editorConfig.features, as a dependency requires the feature to be loaded before it, contrary to a soft-dependency\n const found = resolvedFeatures.get(priorityDependencyKey)\n if (!found) {\n const existsInEditorConfig = unSanitizedEditorConfig.features.find(\n (f) => f.key === priorityDependencyKey,\n )\n if (!existsInEditorConfig) {\n throw new Error(\n `Feature ${featureProvider.key} has a priority dependency ${priorityDependencyKey} which does not exist.`,\n )\n } else {\n throw new Error(\n `Feature ${featureProvider.key} has a priority dependency ${priorityDependencyKey} which is not loaded before it.`,\n )\n }\n }\n }\n }\n\n const feature = featureProvider.feature({\n featureProviderMap,\n resolvedFeatures,\n unSanitizedEditorConfig,\n })\n resolvedFeatures.set(featureProvider.key, {\n ...feature,\n dependencies: featureProvider.dependencies,\n dependenciesPriority: featureProvider.dependenciesPriority,\n dependenciesSoft: featureProvider.dependenciesSoft,\n key: featureProvider.key,\n order: loaded,\n })\n\n loaded++\n }\n\n return resolvedFeatures\n}\n"],"names":["createDependencyGraph","featureProviders","graph","fp","key","dependencies","dependenciesPriority","dependenciesSoft","featureProvider","topologicallySortFeatures","visited","stack","visit","reverse","currentPath","Error","includes","join","push","dep","pop","sortFeaturesForOptimalLoading","loadFeatures","unSanitizedEditorConfig","features","filter","f","i","arr","firstIndex","findIndex","f2","featureProviderMap","Map","map","resolvedFeatures","loaded","length","dependencyKey","found","find","priorityDependencyKey","get","existsInEditorConfig","feature","set","order"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAgBA,SAASA,sBACPC,gBAA2D;IAE3D,MAAMC,QAAyB,CAAC;IAChC,KAAK,MAAMC,MAAMF,iBAAkB;QACjCC,KAAK,CAACC,GAAGC,GAAG,CAAC,GAAG;YACdC,cAAcF,GAAGE,YAAY,IAAI,EAAE;YACnCC,sBAAsBH,GAAGG,oBAAoB,IAAI,EAAE;YACnDC,kBAAkBJ,GAAGI,gBAAgB,IAAI,EAAE;YAC3CC,iBAAiBL;QACnB;IACF;IACA,OAAOD;AACT;AAEA,SAASO,0BACPR,gBAA2D;IAE3D,MAAMC,QAAQF,sBAAsBC;IACpC,MAAMS,UAAsC,CAAC;IAC7C,MAAMC,QAAmD,EAAE;IAE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,CAAC,kBAAkB,EAAEkC,cAAc,sBAAsB,CAAC;gBAE5F;YACF;QACF;QAEA,IAAI9B,gBAAgBF,oBAAoB,EAAE+B,QAAQ;YAChD,KAAK,MAAMI,yBAAyBjC,gBAAgBF,oBAAoB,CAAE;gBACxE,iKAAiK;gBACjK,MAAMiC,QAAQJ,iBAAiBO,GAAG,CAACD;gBACnC,IAAI,CAACF,OAAO;oBACV,MAAMI,uBAAuBpB,wBAAwBC,QAAQ,CAACgB,IAAI,CAChE,CAACd,IAAMA,EAAEtB,GAAG,KAAKqC;oBAEnB,IAAI,CAACE,sBAAsB;wBACzB,MAAM,IAAI5B,MACR,CAAC,QAAQ,EAAEP,gBAAgBJ,GAAG,CAAC,2BAA2B,EAAEqC,sBAAsB,sBAAsB,CAAC;oBAE7G,OAAO;wBACL,MAAM,IAAI1B,MACR,CAAC,QAAQ,EAAEP,gBAAgBJ,GAAG,CAAC,2BAA2B,EAAEqC,sBAAsB,+BAA+B,CAAC;oBAEtH;gBACF;YACF;QACF;QAEA,MAAMG,UAAUpC,gBAAgBoC,OAAO,CAAC;YACtCZ;YACAG;YACAZ;QACF;QACAY,iBAAiBU,GAAG,CAACrC,gBAAgBJ,GAAG,EAAE;YACxC,GAAGwC,OAAO;YACVvC,cAAcG,gBAAgBH,YAAY;YAC1CC,sBAAsBE,gBAAgBF,oBAAoB;YAC1DC,kBAAkBC,gBAAgBD,gBAAgB;YAClDH,KAAKI,gBAAgBJ,GAAG;YACxB0C,OAAOV;QACT;QAEAA;IACF;IAEA,OAAOD;AACT"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/config/server/loader.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload/config'\n\nimport type {\n FeatureProviderServer,\n ResolvedServerFeatureMap,\n ServerFeatureProviderMap,\n} from '../../../features/types.js'\nimport type { ServerEditorConfig } from '../types.js'\n\ntype DependencyGraph = {\n [key: string]: {\n dependencies: string[]\n dependenciesPriority: string[]\n dependenciesSoft: string[]\n featureProvider: FeatureProviderServer<unknown, unknown>\n }\n}\n\nfunction createDependencyGraph(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): DependencyGraph {\n const graph: DependencyGraph = {}\n for (const fp of featureProviders) {\n graph[fp.key] = {\n dependencies: fp.dependencies || [],\n dependenciesPriority: fp.dependenciesPriority || [],\n dependenciesSoft: fp.dependenciesSoft || [],\n featureProvider: fp,\n }\n }\n return graph\n}\n\nfunction topologicallySortFeatures(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): FeatureProviderServer<unknown, unknown>[] {\n const graph = createDependencyGraph(featureProviders)\n const visited: { [key: string]: boolean } = {}\n const stack: FeatureProviderServer<unknown, unknown>[] = []\n\n for (const key in graph) {\n if (!visited[key]) {\n visit(graph, key, visited, stack)\n }\n }\n\n return stack.reverse()\n}\n\nfunction visit(\n graph: DependencyGraph,\n key: string,\n visited: { [key: string]: boolean },\n stack: FeatureProviderServer<unknown, unknown>[],\n currentPath: string[] = [],\n) {\n if (!graph[key]) {\n throw new Error(`Feature key ${key} is not present in the dependency graph.`)\n }\n\n if (currentPath.includes(key)) {\n throw new Error(`Circular dependency detected: ${currentPath.join(' -> ')} -> ${key}`)\n }\n\n if (visited[key]) {\n return\n }\n\n visited[key] = true\n currentPath.push(key)\n\n // First process the hard priority dependencies\n for (const dep of graph[key].dependenciesPriority) {\n if (!visited[dep]) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n // Then process the normal dependencies, but make sure to not violate hard dependencies\n for (const dep of graph[key].dependencies) {\n if (!visited[dep] && !graph[key].dependenciesPriority.includes(dep)) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n // Then process the soft dependencies. Make sure to not violate hard and normal dependencies.\n for (const dep of graph[key].dependenciesSoft) {\n if (\n graph[dep] &&\n !visited[dep] &&\n !graph[key].dependenciesPriority.includes(dep) &&\n !graph[key].dependencies.includes(dep)\n ) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n stack.push(graph[key].featureProvider)\n currentPath.pop()\n}\n\nexport function sortFeaturesForOptimalLoading(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): FeatureProviderServer<unknown, unknown>[] {\n return topologicallySortFeatures(featureProviders)\n}\n\nexport async function loadFeatures({\n config,\n unSanitizedEditorConfig,\n}: {\n config: SanitizedConfig\n unSanitizedEditorConfig: ServerEditorConfig\n}): Promise<ResolvedServerFeatureMap> {\n // First remove all duplicate features. The LAST feature with a given key wins.\n unSanitizedEditorConfig.features = unSanitizedEditorConfig.features\n .reverse()\n .filter((f, i, arr) => {\n const firstIndex = arr.findIndex((f2) => f2.key === f.key)\n return firstIndex === i\n })\n .reverse()\n\n unSanitizedEditorConfig.features = sortFeaturesForOptimalLoading(unSanitizedEditorConfig.features)\n\n const featureProviderMap: ServerFeatureProviderMap = new Map(\n unSanitizedEditorConfig.features.map(\n (f) => [f.key, f] as [string, FeatureProviderServer<unknown, unknown>],\n ),\n )\n\n const resolvedFeatures: ResolvedServerFeatureMap = 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 if (!featureProvider.key) {\n throw new Error(\n `A Feature you've added does not have a key. Please add a key to the feature. This is used to uniquely identify the feature.`,\n )\n }\n if (featureProvider.dependencies?.length) {\n for (const dependencyKey of featureProvider.dependencies) {\n const found = unSanitizedEditorConfig.features.find((f) => f.key === dependencyKey)\n if (!found) {\n throw new Error(\n `Feature ${featureProvider.key} has a dependency ${dependencyKey} which does not exist.`,\n )\n }\n }\n }\n\n if (featureProvider.dependenciesPriority?.length) {\n for (const priorityDependencyKey of featureProvider.dependenciesPriority) {\n // look in the resolved features instead of the editorConfig.features, as a dependency requires the feature to be loaded before it, contrary to a soft-dependency\n const found = resolvedFeatures.get(priorityDependencyKey)\n if (!found) {\n const existsInEditorConfig = unSanitizedEditorConfig.features.find(\n (f) => f.key === priorityDependencyKey,\n )\n if (!existsInEditorConfig) {\n throw new Error(\n `Feature ${featureProvider.key} has a priority dependency ${priorityDependencyKey} which does not exist.`,\n )\n } else {\n throw new Error(\n `Feature ${featureProvider.key} has a priority dependency ${priorityDependencyKey} which is not loaded before it.`,\n )\n }\n }\n }\n }\n\n const feature = await featureProvider.feature({\n config,\n featureProviderMap,\n resolvedFeatures,\n unSanitizedEditorConfig,\n })\n resolvedFeatures.set(featureProvider.key, {\n ...feature,\n dependencies: featureProvider.dependencies,\n dependenciesPriority: featureProvider.dependenciesPriority,\n dependenciesSoft: featureProvider.dependenciesSoft,\n key: featureProvider.key,\n order: loaded,\n })\n\n loaded++\n }\n\n return resolvedFeatures\n}\n"],"names":["createDependencyGraph","featureProviders","graph","fp","key","dependencies","dependenciesPriority","dependenciesSoft","featureProvider","topologicallySortFeatures","visited","stack","visit","reverse","currentPath","Error","includes","join","push","dep","pop","sortFeaturesForOptimalLoading","loadFeatures","config","unSanitizedEditorConfig","features","filter","f","i","arr","firstIndex","findIndex","f2","featureProviderMap","Map","map","resolvedFeatures","loaded","length","dependencyKey","found","find","priorityDependencyKey","get","existsInEditorConfig","feature","set","order"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAkBA,SAASA,sBACPC,gBAA2D;IAE3D,MAAMC,QAAyB,CAAC;IAChC,KAAK,MAAMC,MAAMF,iBAAkB;QACjCC,KAAK,CAACC,GAAGC,GAAG,CAAC,GAAG;YACdC,cAAcF,GAAGE,YAAY,IAAI,EAAE;YACnCC,sBAAsBH,GAAGG,oBAAoB,IAAI,EAAE;YACnDC,kBAAkBJ,GAAGI,gBAAgB,IAAI,EAAE;YAC3CC,iBAAiBL;QACnB;IACF;IACA,OAAOD;AACT;AAEA,SAASO,0BACPR,gBAA2D;IAE3D,MAAMC,QAAQF,sBAAsBC;IACpC,MAAMS,UAAsC,CAAC;IAC7C,MAAMC,QAA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AAQ,EAAEP,gBAAgBJ,GAAG,CAAC,kBAAkB,EAAEmC,cAAc,sBAAsB,CAAC;gBAE5F;YACF;QACF;QAEA,IAAI/B,gBAAgBF,oBAAoB,EAAEgC,QAAQ;YAChD,KAAK,MAAMI,yBAAyBlC,gBAAgBF,oBAAoB,CAAE;gBACxE,iKAAiK;gBACjK,MAAMkC,QAAQJ,iBAAiBO,GAAG,CAACD;gBACnC,IAAI,CAACF,OAAO;oBACV,MAAMI,uBAAuBpB,wBAAwBC,QAAQ,CAACgB,IAAI,CAChE,CAACd,IAAMA,EAAEvB,GAAG,KAAKsC;oBAEnB,IAAI,CAACE,sBAAsB;wBACzB,MAAM,IAAI7B,MACR,CAAC,QAAQ,EAAEP,gBAAgBJ,GAAG,CAAC,2BAA2B,EAAEsC,sBAAsB,sBAAsB,CAAC;oBAE7G,OAAO;wBACL,MAAM,IAAI3B,MACR,CAAC,QAAQ,EAAEP,gBAAgBJ,GAAG,CAAC,2BAA2B,EAAEsC,sBAAsB,+BAA+B,CAAC;oBAEtH;gBACF;YACF;QACF;QAEA,MAAMG,UAAU,MAAMrC,gBAAgBqC,OAAO,CAAC;YAC5CtB;YACAU;YACAG;YACAZ;QACF;QACAY,iBAAiBU,GAAG,CAACtC,gBAAgBJ,GAAG,EAAE;YACxC,GAAGyC,OAAO;YACVxC,cAAcG,gBAAgBH,YAAY;YAC1CC,sBAAsBE,gBAAgBF,oBAAoB;YAC1DC,kBAAkBC,gBAAgBD,gBAAgB;YAClDH,KAAKI,gBAAgBJ,GAAG;YACxB2C,OAAOV;QACT;QAEAA;IACF;IAEA,OAAOD;AACT"}
@@ -1,5 +1,6 @@
1
+ import type { SanitizedConfig } from 'payload/config';
1
2
  import type { ResolvedServerFeatureMap, SanitizedServerFeatures } from '../../../features/types.js';
2
3
  import type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js';
3
4
  export declare const sanitizeServerFeatures: (features: ResolvedServerFeatureMap) => SanitizedServerFeatures;
4
- export declare function sanitizeServerEditorConfig(editorConfig: ServerEditorConfig): SanitizedServerEditorConfig;
5
+ export declare function sanitizeServerEditorConfig(editorConfig: ServerEditorConfig, config: SanitizedConfig): Promise<SanitizedServerEditorConfig>;
5
6
  //# sourceMappingURL=sanitize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIlF,eAAO,MAAM,sBAAsB,0CAEhC,uBA0EF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,kBAAkB,GAC/B,2BAA2B,CAU7B"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIlF,eAAO,MAAM,sBAAsB,0CAEhC,uBA0EF,CAAA;AAED,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,kBAAkB,EAChC,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,2BAA2B,CAAC,CAWtC"}
@@ -65,8 +65,9 @@ export const sanitizeServerFeatures = (features)=>{
65
65
  });
66
66
  return sanitized;
67
67
  };
68
- export function sanitizeServerEditorConfig(editorConfig) {
69
- const resolvedFeatureMap = loadFeatures({
68
+ export async function sanitizeServerEditorConfig(editorConfig, config) {
69
+ const resolvedFeatureMap = await loadFeatures({
70
+ config,
70
71
  unSanitizedEditorConfig: editorConfig
71
72
  });
72
73
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/config/server/sanitize.ts"],"sourcesContent":["import type { ResolvedServerFeatureMap, SanitizedServerFeatures } from '../../../features/types.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 converters: {\n html: [],\n },\n enabledFeatures: [],\n\n generatedTypes: {\n modifyOutputSchemas: [],\n },\n hooks: {\n afterChange: new Map(),\n afterRead: new Map(),\n beforeChange: new Map(),\n beforeDuplicate: new Map(),\n beforeValidate: new Map(),\n },\n markdownTransformers: [],\n nodes: [],\n populationPromises: new Map(),\n\n validations: new Map(),\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature?.generatedTypes?.modifyOutputSchema) {\n sanitized.generatedTypes.modifyOutputSchemas.push(feature.generatedTypes.modifyOutputSchema)\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\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?.populationPromises?.length) {\n sanitized.populationPromises.set(nodeType, node.populationPromises)\n }\n if (node?.validations?.length) {\n sanitized.validations.set(nodeType, node.validations)\n }\n if (node?.converters?.html) {\n sanitized.converters.html.push(node.converters.html)\n }\n if (node?.hooks?.afterChange) {\n sanitized.hooks.afterChange.set(nodeType, node.hooks.afterChange)\n }\n if (node?.hooks?.afterRead) {\n sanitized.hooks.afterRead.set(nodeType, node.hooks.afterRead)\n }\n if (node?.hooks?.beforeChange) {\n sanitized.hooks.beforeChange.set(nodeType, node.hooks.beforeChange)\n }\n if (node?.hooks?.beforeDuplicate) {\n sanitized.hooks.beforeDuplicate.set(nodeType, node.hooks.beforeDuplicate)\n }\n if (node?.hooks?.beforeValidate) {\n sanitized.hooks.beforeValidate.set(nodeType, node.hooks.beforeValidate)\n }\n })\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n\n sanitized.enabledFeatures.push(feature.key)\n })\n\n return sanitized\n}\n\nexport function sanitizeServerEditorConfig(\n editorConfig: ServerEditorConfig,\n): SanitizedServerEditorConfig {\n const resolvedFeatureMap = loadFeatures({\n unSanitizedEditorConfig: editorConfig,\n })\n\n return {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical: editorConfig.lexical,\n resolvedFeatureMap,\n }\n}\n"],"names":["loadFeatures","sanitizeServerFeatures","features","sanitized","converters","html","enabledFeatures","generatedTypes","modifyOutputSchemas","hooks","afterChange","Map","afterRead","beforeChange","beforeDuplicate","beforeValidate","markdownTransformers","nodes","populationPromises","validations","size","forEach","feature","modifyOutputSchema","push","length","concat","node","nodeType","replace","getType","set","key","sanitizeServerEditorConfig","editorConfig","resolvedFeatureMap","unSanitizedEditorConfig","lexical"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,YAAY,QAAQ,cAAa;AAE1C,OAAO,MAAMC,yBAAyB,CACpCC;IAEA,MAAMC,YAAqC;QACzCC,YAAY;YACVC,MAAM,EAAE;QACV;QACAC,iBAAiB,EAAE;QAEnBC,gBAAgB;YACdC,qBAAqB,EAAE;QACzB;QACAC,OAAO;YACLC,aAAa,IAAIC;YACjBC,WAAW,IAAID;YACfE,cAAc,IAAIF;YAClBG,iBAAiB,IAAIH;YACrBI,gBAAgB,IAAIJ;QACtB;QACAK,sBAAsB,EAAE;QACxBC,OAAO,EAAE;QACTC,oBAAoB,IAAIP;QAExBQ,aAAa,IAAIR;IACnB;IAEA,IAAI,CAACT,UAAUkB,MAAM;QACnB,OAAOjB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iB;oBAChCX,UAAUM,KAAK,CAACK,eAAe,CAACiB,GAAG,CAACH,UAAUD,KAAKlB,KAAK,CAACK,eAAe;gBAC1E;gBACA,IAAIa,MAAMlB,OAAOM,gBAAgB;oBAC/BZ,UAAUM,KAAK,CAACM,cAAc,CAACgB,GAAG,CAACH,UAAUD,KAAKlB,KAAK,CAACM,cAAc;gBACxE;YACF;QACF;QAEA,IAAIO,QAAQN,oBAAoB,EAAES,QAAQ;YACxCtB,UAAUa,oBAAoB,GAAGb,UAAUa,oBAAoB,CAACU,MAAM,CACpEJ,QAAQN,oBAAoB;QAEhC;QAEAb,UAAUG,eAAe,CAACkB,IAAI,CAACF,QAAQU,GAAG;IAC5C;IAEA,OAAO7B;AACT,EAAC;AAED,OAAO,SAAS8B,2BACdC,YAAgC;IAEhC,MAAMC,qBAAqBnC,aAAa;QACtCoC,yBAAyBF;IAC3B;IAEA,OAAO;QACLhC,UAAUD,uBAAuBkC;QACjCE,SAASH,aAAaG,OAAO;QAC7BF;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/config/server/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload/config'\n\nimport type { ResolvedServerFeatureMap, SanitizedServerFeatures } from '../../../features/types.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 converters: {\n html: [],\n },\n enabledFeatures: [],\n\n generatedTypes: {\n modifyOutputSchemas: [],\n },\n hooks: {\n afterChange: new Map(),\n afterRead: new Map(),\n beforeChange: new Map(),\n beforeDuplicate: new Map(),\n beforeValidate: new Map(),\n },\n markdownTransformers: [],\n nodes: [],\n populationPromises: new Map(),\n\n validations: new Map(),\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature?.generatedTypes?.modifyOutputSchema) {\n sanitized.generatedTypes.modifyOutputSchemas.push(feature.generatedTypes.modifyOutputSchema)\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\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?.populationPromises?.length) {\n sanitized.populationPromises.set(nodeType, node.populationPromises)\n }\n if (node?.validations?.length) {\n sanitized.validations.set(nodeType, node.validations)\n }\n if (node?.converters?.html) {\n sanitized.converters.html.push(node.converters.html)\n }\n if (node?.hooks?.afterChange) {\n sanitized.hooks.afterChange.set(nodeType, node.hooks.afterChange)\n }\n if (node?.hooks?.afterRead) {\n sanitized.hooks.afterRead.set(nodeType, node.hooks.afterRead)\n }\n if (node?.hooks?.beforeChange) {\n sanitized.hooks.beforeChange.set(nodeType, node.hooks.beforeChange)\n }\n if (node?.hooks?.beforeDuplicate) {\n sanitized.hooks.beforeDuplicate.set(nodeType, node.hooks.beforeDuplicate)\n }\n if (node?.hooks?.beforeValidate) {\n sanitized.hooks.beforeValidate.set(nodeType, node.hooks.beforeValidate)\n }\n })\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\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): Promise<SanitizedServerEditorConfig> {\n const resolvedFeatureMap = await loadFeatures({\n config,\n unSanitizedEditorConfig: editorConfig,\n })\n\n return {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical: editorConfig.lexical,\n resolvedFeatureMap,\n }\n}\n"],"names":["loadFeatures","sanitizeServerFeatures","features","sanitized","converters","html","enabledFeatures","generatedTypes","modifyOutputSchemas","hooks","afterChange","Map","afterRead","beforeChange","beforeDuplicate","beforeValidate","markdownTransformers","nodes","populationPromises","validations","size","forEach","feature","modifyOutputSchema","push","length","concat","node","nodeType","replace","getType","set","key","sanitizeServerEditorConfig","editorConfig","config","resolvedFeatureMap","unSanitizedEditorConfig","lexical"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,YAAY,QAAQ,cAAa;AAE1C,OAAO,MAAMC,yBAAyB,CACpCC;IAEA,MAAMC,YAAqC;QACzCC,YAAY;YACVC,MAAM,EAAE;QACV;QACAC,iBAAiB,EAAE;QAEnBC,gBAAgB;YACdC,qBAAqB,EAAE;QACzB;QACAC,OAAO;YACLC,aAAa,IAAIC;YACjBC,WAAW,IAAID;YACfE,cAAc,IAAIF;YAClBG,iBAAiB,IAAIH;YACrBI,gBAAgB,IAAIJ;QACtB;QACAK,sBAAsB,EAAE;QACxBC,OAAO,EAAE;QACTC,oBAAoB,IAAIP;QAExBQ,aAAa,IAAIR;IACnB;IAEA,IAAI,CAACT,UAAUkB,MAAM;QACnB,OAAOjB;IACT;IAEAD,SAASmB,OAAO,CAAC,CAACC;QAChB,IAAIA,SAASf,gBAAgBgB,oBAAoB;YAC/CpB,UAAUI,cAAc,CAACC,mBAAmB,CAACgB,IAAI,CAACF,QAAQf,cAAc,CAACgB,kBAAkB;QAC7F;QAEA,IAAID,QAAQL,KAAK,EAAEQ,QAAQ;YACzBtB,UAAUc,KAAK,GAAGd,UAAUc,KAAK,CAACS,MAAM,CAACJ,QAAQL,KAAK;YACtDK,QAAQL,KAAK,CAACI,OAAO,CAAC,CAACM;gBACrB,MAAMC,WAAW,UAAUD,KAAKA,IAAI,GAAGA,KAAKA,IAAI,CAACE,OAAO,CAACC,OAAO,KAAKH,KAAKA,IAAI,CAACG,OAAO,GAAG,gDAAgD;;gBACzI,IAAIH,MAAMT,oBAAoBO,QAAQ;oBACpCtB,UAAUe,kBAAkB,CAACa,GAAG,CAACH,UAAUD,KAAKT,kBAAkB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yBH;IAC3B;IAEA,OAAO;QACLhC,UAAUD,uBAAuBmC;QACjCE,SAASJ,aAAaI,OAAO;QAC7BF;IACF;AACF"}
@@ -1,4 +1,4 @@
1
- import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js';
1
+ import type { EditorConfig as LexicalEditorConfig } from 'lexical';
2
2
  import type { FeatureProviderClient, FeatureProviderServer, ResolvedClientFeatureMap, ResolvedServerFeatureMap, SanitizedClientFeatures, SanitizedServerFeatures } from '../../features/types.js';
3
3
  export type ServerEditorConfig = {
4
4
  features: FeatureProviderServer<unknown, unknown>[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/field/lexical/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnF,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAA;IACnD,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAA;IAC1C,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/field/lexical/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAA;IACnD,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAA;IAC1C,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/lexical/config/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport type {\n FeatureProviderClient,\n FeatureProviderServer,\n ResolvedClientFeatureMap,\n ResolvedServerFeatureMap,\n SanitizedClientFeatures,\n SanitizedServerFeatures,\n} from '../../features/types.js'\n\nexport type ServerEditorConfig = {\n features: FeatureProviderServer<unknown, unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedServerEditorConfig = {\n features: SanitizedServerFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedServerFeatureMap\n}\n\nexport type ClientEditorConfig = {\n features: FeatureProviderClient<unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedClientEditorConfig = {\n features: SanitizedClientFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedClientFeatureMap\n}\n"],"names":[],"rangeMappings":"","mappings":"AA2BA,WAIC"}
1
+ {"version":3,"sources":["../../../../src/field/lexical/config/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type {\n FeatureProviderClient,\n FeatureProviderServer,\n ResolvedClientFeatureMap,\n ResolvedServerFeatureMap,\n SanitizedClientFeatures,\n SanitizedServerFeatures,\n} from '../../features/types.js'\n\nexport type ServerEditorConfig = {\n features: FeatureProviderServer<unknown, unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedServerEditorConfig = {\n features: SanitizedServerFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedServerFeatureMap\n}\n\nexport type ClientEditorConfig = {\n features: FeatureProviderClient<unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedClientEditorConfig = {\n features: SanitizedClientFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedClientFeatureMap\n}\n"],"names":[],"rangeMappings":"","mappings":"AA2BA,WAIC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,aAAa,yBAGvB;IACD,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B,KAAK,EAAE,2BAA2B,CAAA;CACnC,sBA8EA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,aAAa,yBAGvB;IACD,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B,KAAK,EAAE,2BAA2B,CAAA;CACnC,sBA8EA,CAAA"}
@@ -1,10 +1,7 @@
1
1
  'use client';
2
- import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
3
- const { useLexicalComposerContext } = lexicalComposerContextImport;
4
- import lexicalUtilsImport from '@lexical/utils';
5
- const { mergeRegister } = lexicalUtilsImport;
6
- import lexicalImport from 'lexical';
7
- const { $getSelection } = lexicalImport;
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
+ import { mergeRegister } from '@lexical/utils';
4
+ import { $getSelection } from 'lexical';
8
5
  import React, { useCallback, useEffect, useState } from 'react';
9
6
  import './index.scss';
10
7
  const baseClass = 'floating-select-toolbar-popup__button';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst { $getSelection } = lexicalImport\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nimport './index.scss'\n\nconst baseClass = 'floating-select-toolbar-popup__button'\n\nexport const ToolbarButton = ({\n children,\n entry,\n}: {\n children: React.JSX.Element\n entry: FloatingToolbarSectionEntry\n}) => {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-` + entry.key : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$getSelection","React","useCallback","useEffect","useState","baseClass","ToolbarButton","children","entry","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","button","onClick","onMouseDown","e","preventDefault","type"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI/D,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,OAAO,MAAMC,gBAAgB,CAAC,EAC5BC,QAAQ,EACRC,KAAK,EAIN;IACC,MAAM,CAACC,OAAO,GAAGb;IACjB,MAAM,CAACc,SAASC,WAAW,GAAGP,SAAkB;IAChD,MAAM,CAACQ,QAAQC,UAAU,GAAGT,SAAkB;IAC9C,MAAM,CAACU,WAAWC,aAAa,GAAGX,SAAiBC;IAEnD,MAAMW,eAAed,YAAY;QAC/BO,OAAOQ,cAAc,GAAGC,IAAI,CAAC;YAC3B,MAAMC,YAAYnB;YAClB,IAAIQ,MAAMY,QAAQ,EAAE;gBAClB,MAAMA,WAAWZ,MAAMY,QAAQ,CAAC;oBAAEX;oBAAQU;gBAAU;gBACpD,IAAIP,WAAWQ,UAAU;oBACvBP,UAAUO;gBACZ;YACF;YACA,IAAIZ,MAAMa,SAAS,EAAE;gBACnB,MAAMA,YAAYb,MAAMa,SAAS,CAAC;oBAAEZ;oBAAQU;gBAAU;gBACtD,IAAIT,YAAYW,WAAW;oBACzBV,WAAWU;gBACb;YACF;QACF;IACF,GAAG;QAACT;QAAQH;QAAQC;QAASF;KAAM;IAEnCL,UAAU;QACRa;IACF,GAAG;QAACA;KAAa;IAEjBb,UAAU;QACRmB,SAASC,gBAAgB,CAAC,WAAWP;QACrC,OAAO;YACLM,SAASE,mBAAmB,CAAC,WAAWR;QAC1C;IACF,GAAG;QAACA;KAAa;IAEjBb,UAAU;QACR,OAAOL,cACLW,OAAOgB,sBAAsB,CAAC;YAC5BT;QACF;IAEJ,GAAG;QAACP;QAAQO;KAAa;IAEzBb,UAAU;QACRY,aACE;YACEV;YACAK,YAAY,QAAQ,aAAa;YACjCE,SAAS,WAAW;YACpBJ,OAAOkB,MAAM,CAAC,EAAErB,UAAU,CAAC,CAAC,GAAGG,MAAMkB,GAAG,GAAG;SAC5C,CACEC,MAAM,CAACC,SACPC,IAAI,CAAC;IAEZ,GAAG;QAACnB;QAASE;QAAQE;KAAU;IAE/B,qBACE,oBAACgB;QACChB,WAAWA;QACXiB,SAAS;YACP,IAAIrB,YAAY,OAAO;gBACrBF,MAAMuB,OAAO,CAAC;oBACZtB;oBACAW,UAAUR;gBACZ;YACF;QACF;QACAoB,aAAa,CAACC;YACZ,8HAA8H;YAC9H,2JAA2J;YAC3J,sKAAsK;YACtKA,EAAEC,cAAc;QAClB;QACAC,MAAK;OAEJ5B;AAGP,EAAC"}
1
+ {"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { $getSelection } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nimport './index.scss'\n\nconst baseClass = 'floating-select-toolbar-popup__button'\n\nexport const ToolbarButton = ({\n children,\n entry,\n}: {\n children: React.JSX.Element\n entry: FloatingToolbarSectionEntry\n}) => {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-` + entry.key : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","React","useCallback","useEffect","useState","baseClass","ToolbarButton","children","entry","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","button","onClick","onMouseDown","e","preventDefault","type"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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QAACP;QAAQO;KAAa;IAEzBb,UAAU;QACRY,aACE;YACEV;YACAK,YAAY,QAAQ,aAAa;YACjCE,SAAS,WAAW;YACpBJ,OAAOkB,MAAM,CAAC,EAAErB,UAAU,CAAC,CAAC,GAAGG,MAAMkB,GAAG,GAAG;SAC5C,CACEC,MAAM,CAACC,SACPC,IAAI,CAAC;IAEZ,GAAG;QAACnB;QAASE;QAAQE;KAAU;IAE/B,qBACE,oBAACgB;QACChB,WAAWA;QACXiB,SAAS;YACP,IAAIrB,YAAY,OAAO;gBACrBF,MAAMuB,OAAO,CAAC;oBACZtB;oBACAW,UAAUR;gBACZ;YACF;QACF;QACAoB,aAAa,CAACC;YACZ,8HAA8H;YAC9H,2JAA2J;YAC3J,sKAAsK;YACtKA,EAAEC,cAAc;QAClB;QACAC,MAAK;OAEJ5B;AAGP,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AACzF,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAU9D,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,KAAK,EACL,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,EAAE,2BAA2B,CAAA;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,KAAK,CAAC,SAAS,CA+FlB;AA4ED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,eAAe,EACf,eAAe,EACf,QAAQ,EACR,QAAgB,EAChB,oBAAoB,GACrB,EAAE;IACD,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,GAAG,KAAK,CAAC,SAAS,CAgFlB"}
1
+ {"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AACzF,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAU9D,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,KAAK,EACL,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,EAAE,2BAA2B,CAAA;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,KAAK,CAAC,SAAS,CA+FlB;AA4ED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,eAAe,EACf,eAAe,EACf,QAAQ,EACR,QAAgB,EAChB,oBAAoB,GACrB,EAAE;IACD,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,GAAG,KAAK,CAAC,SAAS,CAgFlB"}
@@ -1,10 +1,7 @@
1
1
  'use client';
2
- import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
3
- const { useLexicalComposerContext } = lexicalComposerContextImport;
4
- import lexicalUtilsImport from '@lexical/utils';
5
- const { mergeRegister } = lexicalUtilsImport;
6
- import lexicalImport from 'lexical';
7
- const { $getSelection } = lexicalImport;
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
+ import { mergeRegister } from '@lexical/utils';
4
+ import { $getSelection } from 'lexical';
8
5
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
9
6
  import React from 'react';
10
7
  import { createPortal } from 'react-dom';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst { $getSelection } = lexicalImport\n\nimport { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nconst baseClass = 'floating-select-toolbar-popup__dropdown-item'\n\ninterface DropDownContextType {\n registerItem: (ref: React.RefObject<HTMLButtonElement>) => void\n}\n\nconst DropDownContext = React.createContext<DropDownContextType | null>(null)\n\nexport function DropDownItem({\n children,\n entry,\n title,\n}: {\n children: React.ReactNode\n entry: FloatingToolbarSectionEntry\n title?: string\n}): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-${entry.key}` : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className, entry.key])\n\n const ref = useRef<HTMLButtonElement>(null)\n\n const dropDownContext = React.useContext(DropDownContext)\n\n if (dropDownContext === null) {\n throw new Error('DropDownItem must be used within a DropDown')\n }\n\n const { registerItem } = dropDownContext\n\n useEffect(() => {\n if (ref?.current != null) {\n registerItem(ref)\n }\n }, [ref, registerItem])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This is required for Firefox compatibility. Without it, the dropdown will disappear without the onClick being called.\n // This only happens in Firefox. Must be something about how Firefox handles focus events differently.\n e.preventDefault()\n }}\n ref={ref}\n title={title}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n\nfunction DropDownItems({\n children,\n dropDownRef,\n onClose,\n}: {\n children: React.ReactNode\n dropDownRef: React.Ref<HTMLDivElement>\n onClose: () => void\n}): JSX.Element {\n const [items, setItems] = useState<Array<React.RefObject<HTMLButtonElement>>>()\n const [highlightedItem, setHighlightedItem] = useState<React.RefObject<HTMLButtonElement>>()\n\n const registerItem = useCallback(\n (itemRef: React.RefObject<HTMLButtonElement>) => {\n setItems((prev) => (prev != null ? [...prev, itemRef] : [itemRef]))\n },\n [setItems],\n )\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>): void => {\n if (items == null) return\n\n const { key } = event\n\n if (['ArrowDown', 'ArrowUp', 'Escape', 'Tab'].includes(key)) {\n event.preventDefault()\n }\n\n if (key === 'Escape' || key === 'Tab') {\n onClose()\n } else if (key === 'ArrowUp') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n const index = items.indexOf(prev) - 1\n return items[index === -1 ? items.length - 1 : index]\n })\n } else if (key === 'ArrowDown') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n return items[items.indexOf(prev) + 1]\n })\n }\n }\n\n const contextValue = useMemo(\n () => ({\n registerItem,\n }),\n [registerItem],\n )\n\n useEffect(() => {\n if (items != null && highlightedItem == null) {\n setHighlightedItem(items[0])\n }\n\n if (highlightedItem?.current != null) {\n highlightedItem.current.focus()\n }\n }, [items, highlightedItem])\n\n return (\n <DropDownContext.Provider value={contextValue}>\n <div\n className=\"floating-select-toolbar-popup__dropdown-items\"\n onKeyDown={handleKeyDown}\n ref={dropDownRef}\n >\n {children}\n </div>\n </DropDownContext.Provider>\n )\n}\n\nexport function DropDown({\n Icon,\n buttonAriaLabel,\n buttonClassName,\n children,\n disabled = false,\n stopCloseOnClickSelf,\n}: {\n Icon?: React.FC\n buttonAriaLabel?: string\n buttonClassName: string\n children: ReactNode\n disabled?: boolean\n stopCloseOnClickSelf?: boolean\n}): React.ReactNode {\n const dropDownRef = useRef<HTMLDivElement>(null)\n const buttonRef = useRef<HTMLButtonElement>(null)\n const [showDropDown, setShowDropDown] = useState(false)\n\n const handleClose = (): void => {\n setShowDropDown(false)\n if (buttonRef?.current != null) {\n buttonRef.current.focus()\n }\n }\n\n useEffect(() => {\n const button = buttonRef.current\n const dropDown = dropDownRef.current\n\n if (showDropDown && button !== null && dropDown !== null) {\n const { left, top } = button.getBoundingClientRect()\n const scrollTopOffset = window.pageYOffset || document.documentElement.scrollTop\n dropDown.style.top = `${top + scrollTopOffset + button.offsetHeight + 5}px`\n dropDown.style.left = `${Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20)}px`\n }\n }, [dropDownRef, buttonRef, showDropDown])\n\n useEffect(() => {\n const button = buttonRef.current\n\n if (button !== null && showDropDown) {\n const handle = (event: MouseEvent): void => {\n const { target } = event\n if (stopCloseOnClickSelf != null) {\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (dropDownRef.current != null && dropDownRef.current.contains(target as Node)) {\n return\n }\n }\n if (!button.contains(target as Node)) {\n setShowDropDown(false)\n }\n }\n document.addEventListener('click', handle)\n\n return () => {\n document.removeEventListener('click', handle)\n }\n }\n }, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf])\n\n return (\n <React.Fragment>\n <button\n aria-label={buttonAriaLabel}\n className={buttonClassName + (showDropDown ? ' active' : '')}\n disabled={disabled}\n onClick={(event) => {\n event.preventDefault()\n setShowDropDown(!showDropDown)\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n ref={buttonRef}\n type=\"button\"\n >\n <Icon />\n <i className=\"floating-select-toolbar-popup__dropdown-caret\" />\n </button>\n\n {showDropDown &&\n createPortal(\n <DropDownItems dropDownRef={dropDownRef} onClose={handleClose}>\n {children}\n </DropDownItems>,\n document.body,\n )}\n </React.Fragment>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$getSelection","useCallback","useEffect","useMemo","useRef","useState","React","createPortal","baseClass","DropDownContext","createContext","DropDownItem","children","entry","title","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","ref","dropDownContext","useContext","Error","registerItem","current","button","onClick","onMouseDown","e","preventDefault","type","DropDownItems","dropDownRef","onClose","items","setItems","highlightedItem","setHighlightedItem","itemRef","prev","handleKeyDown","event","includes","index","indexOf","length","contextValue","focus","Provider","value","div","onKeyDown","DropDown","Icon","buttonAriaLabel","buttonClassName","disabled","stopCloseOnClickSelf","buttonRef","showDropDown","setShowDropDown","handleClose","dropDown","left","top","getBoundingClientRect","scrollTopOffset","window","pageYOffset","documentElement","scrollTop","style","offsetHeight","Math","min","innerWidth","offsetWidth","handle","target","contains","Fragment","aria-label","i","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,SAAyBE,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACzF,OAAOC,WAAW,QAAO;AACzB,SAASC,YAAY,QAAQ,YAAW;AAIxC,MAAMC,YAAY;AAMlB,MAAMC,gCAAkBH,MAAMI,aAAa,CAA6B;AAExE,OAAO,SAASC,aAAa,EAC3BC,QAAQ,EACRC,KAAK,EACLC,KAAK,EAKN;IACC,MAAM,CAACC,OAAO,GAAGnB;IACjB,MAAM,CAACoB,SAASC,WAAW,GAAGZ,SAAkB;IAChD,MAAM,CAACa,QAAQC,UAAU,GAAGd,SAAkB;IAC9C,MAAM,CAACe,WAAWC,aAAa,GAAGhB,SAAiBG;IAEnD,MAAMc,eAAerB,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GAAG,CAACX,OAAO,GAAGI,OAAOQ,UAAU,GAAGb,SAASc,WAAW,GAAG,IAAI,EAAE,CAAC;QAChG;IACF,GAAG;QAAC5C;QAAa0B;QAAWC;KAAa;IAEzC1E,UAAU;QACR,MAAMwC,SAASiC,UAAUlC,OAAO;QAEhC,IAAIC,WAAW,QAAQkC,cAAc;YACnC,MAAMkB,SAAS,CAACpC;gBACd,MAAM,EAAEqC,MAAM,EAAE,GAAGrC;gBACnB,IAAIgB,wBAAwB,MAAM;oBAChC,oEAAoE;oBACpE,IAAIzB,YAAYR,OAAO,IAAI,QAAQQ,YAAYR,OAAO,CAACuD,QAAQ,CAACD,SAAiB;wBAC/E;oBACF;gBACF;gBACA,IAAI,CAACrD,OAAOsD,QAAQ,CAACD,SAAiB;oBACpClB,gBAAgB;gBAClB;YACF;YACAjD,SAASC,gBAAgB,CAAC,SAASiE;YAEnC,OAAO;gBACLlE,SAASE,mBAAmB,CAAC,SAASgE;YACxC;QACF;IACF,GAAG;QAAC7C;QAAa0B;QAAWC;QAAcF;KAAqB;IAE/D,qBACE,oBAACpE,MAAM2F,QAAQ,sBACb,oBAACvD;QACCwD,cAAY3B;QACZnD,WAAWoD,kBAAmBI,CAAAA,eAAe,YAAY,EAAC;QAC1DH,UAAUA;QACV9B,SAAS,CAACe;YACRA,MAAMZ,cAAc;YACpB+B,gBAAgB,CAACD;QACnB;QACAhC,aAAa,CAACC;YACZ,8HAA8H;YAC9H,2JAA2J;YAC3J,sKAAsK;YACtKA,EAAEC,cAAc;QAClB;QACAV,KAAKuC;QACL5B,MAAK;qBAEL,oBAACuB,2BACD,oBAAC6B;QAAE/E,WAAU;SAGdwD,8BACCrE,2BACE,oBAACyC;QAAcC,aAAaA;QAAaC,SAAS4B;OAC/ClE,WAEHgB,SAASwE,IAAI;AAIvB"}
1
+ {"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { $getSelection } from 'lexical'\nimport { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nconst baseClass = 'floating-select-toolbar-popup__dropdown-item'\n\ninterface DropDownContextType {\n registerItem: (ref: React.RefObject<HTMLButtonElement>) => void\n}\n\nconst DropDownContext = React.createContext<DropDownContextType | null>(null)\n\nexport function DropDownItem({\n children,\n entry,\n title,\n}: {\n children: React.ReactNode\n entry: FloatingToolbarSectionEntry\n title?: string\n}): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-${entry.key}` : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className, entry.key])\n\n const ref = useRef<HTMLButtonElement>(null)\n\n const dropDownContext = React.useContext(DropDownContext)\n\n if (dropDownContext === null) {\n throw new Error('DropDownItem must be used within a DropDown')\n }\n\n const { registerItem } = dropDownContext\n\n useEffect(() => {\n if (ref?.current != null) {\n registerItem(ref)\n }\n }, [ref, registerItem])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This is required for Firefox compatibility. Without it, the dropdown will disappear without the onClick being called.\n // This only happens in Firefox. Must be something about how Firefox handles focus events differently.\n e.preventDefault()\n }}\n ref={ref}\n title={title}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n\nfunction DropDownItems({\n children,\n dropDownRef,\n onClose,\n}: {\n children: React.ReactNode\n dropDownRef: React.Ref<HTMLDivElement>\n onClose: () => void\n}): JSX.Element {\n const [items, setItems] = useState<Array<React.RefObject<HTMLButtonElement>>>()\n const [highlightedItem, setHighlightedItem] = useState<React.RefObject<HTMLButtonElement>>()\n\n const registerItem = useCallback(\n (itemRef: React.RefObject<HTMLButtonElement>) => {\n setItems((prev) => (prev != null ? [...prev, itemRef] : [itemRef]))\n },\n [setItems],\n )\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>): void => {\n if (items == null) return\n\n const { key } = event\n\n if (['ArrowDown', 'ArrowUp', 'Escape', 'Tab'].includes(key)) {\n event.preventDefault()\n }\n\n if (key === 'Escape' || key === 'Tab') {\n onClose()\n } else if (key === 'ArrowUp') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n const index = items.indexOf(prev) - 1\n return items[index === -1 ? items.length - 1 : index]\n })\n } else if (key === 'ArrowDown') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n return items[items.indexOf(prev) + 1]\n })\n }\n }\n\n const contextValue = useMemo(\n () => ({\n registerItem,\n }),\n [registerItem],\n )\n\n useEffect(() => {\n if (items != null && highlightedItem == null) {\n setHighlightedItem(items[0])\n }\n\n if (highlightedItem?.current != null) {\n highlightedItem.current.focus()\n }\n }, [items, highlightedItem])\n\n return (\n <DropDownContext.Provider value={contextValue}>\n <div\n className=\"floating-select-toolbar-popup__dropdown-items\"\n onKeyDown={handleKeyDown}\n ref={dropDownRef}\n >\n {children}\n </div>\n </DropDownContext.Provider>\n )\n}\n\nexport function DropDown({\n Icon,\n buttonAriaLabel,\n buttonClassName,\n children,\n disabled = false,\n stopCloseOnClickSelf,\n}: {\n Icon?: React.FC\n buttonAriaLabel?: string\n buttonClassName: string\n children: ReactNode\n disabled?: boolean\n stopCloseOnClickSelf?: boolean\n}): React.ReactNode {\n const dropDownRef = useRef<HTMLDivElement>(null)\n const buttonRef = useRef<HTMLButtonElement>(null)\n const [showDropDown, setShowDropDown] = useState(false)\n\n const handleClose = (): void => {\n setShowDropDown(false)\n if (buttonRef?.current != null) {\n buttonRef.current.focus()\n }\n }\n\n useEffect(() => {\n const button = buttonRef.current\n const dropDown = dropDownRef.current\n\n if (showDropDown && button !== null && dropDown !== null) {\n const { left, top } = button.getBoundingClientRect()\n const scrollTopOffset = window.pageYOffset || document.documentElement.scrollTop\n dropDown.style.top = `${top + scrollTopOffset + button.offsetHeight + 5}px`\n dropDown.style.left = `${Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20)}px`\n }\n }, [dropDownRef, buttonRef, showDropDown])\n\n useEffect(() => {\n const button = buttonRef.current\n\n if (button !== null && showDropDown) {\n const handle = (event: MouseEvent): void => {\n const { target } = event\n if (stopCloseOnClickSelf != null) {\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (dropDownRef.current != null && dropDownRef.current.contains(target as Node)) {\n return\n }\n }\n if (!button.contains(target as Node)) {\n setShowDropDown(false)\n }\n }\n document.addEventListener('click', handle)\n\n return () => {\n document.removeEventListener('click', handle)\n }\n }\n }, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf])\n\n return (\n <React.Fragment>\n <button\n aria-label={buttonAriaLabel}\n className={buttonClassName + (showDropDown ? ' active' : '')}\n disabled={disabled}\n onClick={(event) => {\n event.preventDefault()\n setShowDropDown(!showDropDown)\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n ref={buttonRef}\n type=\"button\"\n >\n <Icon />\n <i className=\"floating-select-toolbar-popup__dropdown-caret\" />\n </button>\n\n {showDropDown &&\n createPortal(\n <DropDownItems dropDownRef={dropDownRef} onClose={handleClose}>\n {children}\n </DropDownItems>,\n document.body,\n )}\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","useCallback","useEffect","useMemo","useRef","useState","React","createPortal","baseClass","DropDownContext","createContext","DropDownItem","children","entry","title","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","ref","dropDownContext","useContext","Error","registerItem","current","button","onClick","onMouseDown","e","preventDefault","type","DropDownItems","dropDownRef","onClose","items","setItems","highlightedItem","setHighlightedItem","itemRef","prev","handleKeyDown","event","includes","index","indexOf","length","contextValue","focus","Provider","value","div","onKeyDown","DropDown","Icon","buttonAriaLabel","buttonClassName","disabled","stopCloseOnClickSelf","buttonRef","showDropDown","setShowDropDown","handleClose","dropDown","left","top","getBoundingClientRect","scrollTopOffset","window","pageYOffset","documentElement","scrollTop","style","offsetHeight","Math","min","innerWidth","offsetWidth","handle","target","contains","Fragment","aria-label","i","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AASE,mBAAmB,CAAC,SAASgE;YACxC;QACF;IACF,GAAG;QAAC7C;QAAa0B;QAAWC;QAAcF;KAAqB;IAE/D,qBACE,oBAACpE,MAAM2F,QAAQ,sBACb,oBAACvD;QACCwD,cAAY3B;QACZnD,WAAWoD,kBAAmBI,CAAAA,eAAe,YAAY,EAAC;QAC1DH,UAAUA;QACV9B,SAAS,CAACe;YACRA,MAAMZ,cAAc;YACpB+B,gBAAgB,CAACD;QACnB;QACAhC,aAAa,CAACC;YACZ,8HAA8H;YAC9H,2JAA2J;YAC3J,sKAAsK;YACtKA,EAAEC,cAAc;QAClB;QACAV,KAAKuC;QACL5B,MAAK;qBAEL,oBAACuB,2BACD,oBAAC6B;QAAE/E,WAAU;SAGdwD,8BACCrE,2BACE,oBAACyC;QAAcC,aAAaA;QAAaC,SAAS4B;OAC/ClE,WAEHgB,SAASwE,IAAI;AAIvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/plugins/FloatingSelectToolbar/index.tsx"],"names":[],"mappings":";AA6BA,OAAO,cAAc,CAAA;AAoVrB,wBAAgB,2BAA2B,CAAC,EAC1C,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAGrB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/plugins/FloatingSelectToolbar/index.tsx"],"names":[],"mappings":";AAuBA,OAAO,cAAc,CAAA;AA2VrB,wBAAgB,2BAA2B,CAAC,EAC1C,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAGrB"}
@@ -1,10 +1,7 @@
1
1
  'use client';
2
- import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
3
- const { useLexicalComposerContext } = lexicalComposerContextImport;
4
- import lexicalUtilsImport from '@lexical/utils';
5
- const { mergeRegister } = lexicalUtilsImport;
6
- import lexicalImport from 'lexical';
7
- const { $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_LOW, SELECTION_CHANGE_COMMAND } = lexicalImport;
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
+ import { mergeRegister } from '@lexical/utils';
4
+ import { $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_LOW, SELECTION_CHANGE_COMMAND } from 'lexical';
8
5
  import { useCallback, useEffect, useRef, useState } from 'react';
9
6
  import * as React from 'react';
10
7
  import { createPortal } from 'react-dom';
@@ -57,33 +54,33 @@ function ToolbarSection({ anchorElem, editor, index, section }) {
57
54
  }));
58
55
  }
59
56
  function FloatingSelectToolbar({ anchorElem, editor }) {
60
- const popupCharStylesEditorRef = useRef(null);
57
+ const floatingToolbarRef = useRef(null);
61
58
  const caretRef = useRef(null);
62
59
  const { editorConfig } = useEditorConfigContext();
63
60
  const closeFloatingToolbar = useCallback(()=>{
64
- if (popupCharStylesEditorRef?.current) {
65
- const isOpacityZero = popupCharStylesEditorRef.current.style.opacity === '0';
66
- const isPointerEventsNone = popupCharStylesEditorRef.current.style.pointerEvents === 'none';
61
+ if (floatingToolbarRef?.current) {
62
+ const isOpacityZero = floatingToolbarRef.current.style.opacity === '0';
63
+ const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none';
67
64
  if (!isOpacityZero) {
68
- popupCharStylesEditorRef.current.style.opacity = '0';
65
+ floatingToolbarRef.current.style.opacity = '0';
69
66
  }
70
67
  if (!isPointerEventsNone) {
71
- popupCharStylesEditorRef.current.style.pointerEvents = 'none';
68
+ floatingToolbarRef.current.style.pointerEvents = 'none';
72
69
  }
73
70
  }
74
71
  }, [
75
- popupCharStylesEditorRef
72
+ floatingToolbarRef
76
73
  ]);
77
74
  const mouseMoveListener = useCallback((e)=>{
78
- if (popupCharStylesEditorRef?.current && (e.buttons === 1 || e.buttons === 3)) {
79
- const isOpacityZero = popupCharStylesEditorRef.current.style.opacity === '0';
80
- const isPointerEventsNone = popupCharStylesEditorRef.current.style.pointerEvents === 'none';
75
+ if (floatingToolbarRef?.current && (e.buttons === 1 || e.buttons === 3)) {
76
+ const isOpacityZero = floatingToolbarRef.current.style.opacity === '0';
77
+ const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none';
81
78
  if (!isOpacityZero || !isPointerEventsNone) {
82
79
  // Check if the mouse is not over the popup
83
80
  const x = e.clientX;
84
81
  const y = e.clientY;
85
82
  const elementUnderMouse = document.elementFromPoint(x, y);
86
- if (!popupCharStylesEditorRef.current.contains(elementUnderMouse)) {
83
+ if (!floatingToolbarRef.current.contains(elementUnderMouse)) {
87
84
  // Mouse is not over the target element => not a normal click, but probably a drag
88
85
  closeFloatingToolbar();
89
86
  }
@@ -93,16 +90,16 @@ function FloatingSelectToolbar({ anchorElem, editor }) {
93
90
  closeFloatingToolbar
94
91
  ]);
95
92
  const mouseUpListener = useCallback(()=>{
96
- if (popupCharStylesEditorRef?.current) {
97
- if (popupCharStylesEditorRef.current.style.opacity !== '1') {
98
- popupCharStylesEditorRef.current.style.opacity = '1';
93
+ if (floatingToolbarRef?.current) {
94
+ if (floatingToolbarRef.current.style.opacity !== '1') {
95
+ floatingToolbarRef.current.style.opacity = '1';
99
96
  }
100
- if (popupCharStylesEditorRef.current.style.pointerEvents !== 'auto') {
101
- popupCharStylesEditorRef.current.style.pointerEvents = 'auto';
97
+ if (floatingToolbarRef.current.style.pointerEvents !== 'auto') {
98
+ floatingToolbarRef.current.style.pointerEvents = 'auto';
102
99
  }
103
100
  }
104
101
  }, [
105
- popupCharStylesEditorRef
102
+ floatingToolbarRef
106
103
  ]);
107
104
  useEffect(()=>{
108
105
  document.addEventListener('mousemove', mouseMoveListener);
@@ -112,23 +109,24 @@ function FloatingSelectToolbar({ anchorElem, editor }) {
112
109
  document.removeEventListener('mouseup', mouseUpListener);
113
110
  };
114
111
  }, [
115
- popupCharStylesEditorRef,
112
+ floatingToolbarRef,
116
113
  mouseMoveListener,
117
114
  mouseUpListener
118
115
  ]);
119
116
  const updateTextFormatFloatingToolbar = useCallback(()=>{
120
117
  const selection = $getSelection();
121
- const popupCharStylesEditorElem = popupCharStylesEditorRef.current;
122
118
  const nativeSelection = window.getSelection();
123
- if (popupCharStylesEditorElem === null) {
119
+ if (floatingToolbarRef.current === null) {
124
120
  return;
125
121
  }
126
122
  const rootElement = editor.getRootElement();
127
123
  if (selection !== null && nativeSelection !== null && !nativeSelection.isCollapsed && rootElement !== null && rootElement.contains(nativeSelection.anchorNode)) {
128
124
  const rangeRect = getDOMRangeRect(nativeSelection, rootElement);
129
- setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem, 'center');
125
+ // Position floating toolbar
126
+ const offsetIfFlipped = setFloatingElemPosition(rangeRect, floatingToolbarRef.current, anchorElem, 'center');
127
+ // Position caret
130
128
  if (caretRef.current) {
131
- setFloatingElemPosition(rangeRect, caretRef.current, popupCharStylesEditorElem, 'center', 10, 5, true);
129
+ setFloatingElemPosition(rangeRect, caretRef.current, floatingToolbarRef.current, 'center', 10, 5, true, offsetIfFlipped);
132
130
  }
133
131
  }
134
132
  }, [
@@ -175,7 +173,7 @@ function FloatingSelectToolbar({ anchorElem, editor }) {
175
173
  ]);
176
174
  return /*#__PURE__*/ React.createElement("div", {
177
175
  className: "floating-select-toolbar-popup",
178
- ref: popupCharStylesEditorRef
176
+ ref: floatingToolbarRef
179
177
  }, /*#__PURE__*/ React.createElement("div", {
180
178
  className: "caret",
181
179
  ref: caretRef