@payloadcms/richtext-lexical 3.0.0-alpha.67 → 3.0.0-alpha.69

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 (342) hide show
  1. package/dist/exports/components.d.ts +3 -2
  2. package/dist/exports/components.d.ts.map +1 -1
  3. package/dist/exports/components.js +3 -2
  4. package/dist/exports/components.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 +127 -53
  7. package/dist/field/features/align/feature.client.js.map +1 -1
  8. package/dist/field/features/align/toolbarAlignGroup.d.ts +3 -0
  9. package/dist/field/features/align/toolbarAlignGroup.d.ts.map +1 -0
  10. package/dist/field/features/align/toolbarAlignGroup.js +12 -0
  11. package/dist/field/features/align/toolbarAlignGroup.js.map +1 -0
  12. package/dist/field/features/blockquote/feature.client.d.ts.map +1 -1
  13. package/dist/field/features/blockquote/feature.client.js +50 -34
  14. package/dist/field/features/blockquote/feature.client.js.map +1 -1
  15. package/dist/field/features/blocks/component/index.d.ts.map +1 -1
  16. package/dist/field/features/blocks/component/index.js +1 -1
  17. package/dist/field/features/blocks/component/index.js.map +1 -1
  18. package/dist/field/features/blocks/feature.client.d.ts.map +1 -1
  19. package/dist/field/features/blocks/feature.client.js +56 -27
  20. package/dist/field/features/blocks/feature.client.js.map +1 -1
  21. package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
  22. package/dist/field/features/blocks/populationPromise.js +2 -1
  23. package/dist/field/features/blocks/populationPromise.js.map +1 -1
  24. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.d.ts.map +1 -1
  25. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.js.map +1 -1
  26. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.d.ts.map +1 -1
  27. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.js +1 -1
  28. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.js.map +1 -1
  29. package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.d.ts.map +1 -1
  30. package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.js.map +1 -1
  31. package/dist/field/features/debug/{treeview → treeView}/feature.client.d.ts.map +1 -1
  32. package/dist/field/features/debug/{treeview → treeView}/feature.client.js.map +1 -1
  33. package/dist/field/features/debug/{treeview → treeView}/feature.server.d.ts.map +1 -1
  34. package/dist/field/features/debug/{treeview → treeView}/feature.server.js +1 -1
  35. package/dist/field/features/debug/{treeview → treeView}/feature.server.js.map +1 -1
  36. package/dist/field/features/debug/{treeview → treeView}/plugin/index.d.ts.map +1 -1
  37. package/dist/field/features/debug/{treeview → treeView}/plugin/index.js.map +1 -1
  38. package/dist/field/features/format/bold/feature.client.d.ts.map +1 -1
  39. package/dist/field/features/format/bold/feature.client.js +25 -21
  40. package/dist/field/features/format/bold/feature.client.js.map +1 -1
  41. package/dist/field/features/format/inlineCode/feature.client.d.ts.map +1 -0
  42. package/dist/field/features/format/inlineCode/feature.client.js +46 -0
  43. package/dist/field/features/format/inlineCode/feature.client.js.map +1 -0
  44. package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.d.ts.map +1 -1
  45. package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.js +1 -1
  46. package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.js.map +1 -1
  47. package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.d.ts.map +1 -1
  48. package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.js.map +1 -1
  49. package/dist/field/features/format/italic/feature.client.d.ts.map +1 -1
  50. package/dist/field/features/format/italic/feature.client.js +26 -22
  51. package/dist/field/features/format/italic/feature.client.js.map +1 -1
  52. package/dist/field/features/format/shared/toolbarFormatGroup.d.ts +3 -0
  53. package/dist/field/features/format/shared/toolbarFormatGroup.d.ts.map +1 -0
  54. package/dist/field/features/format/shared/toolbarFormatGroup.js +10 -0
  55. package/dist/field/features/format/shared/toolbarFormatGroup.js.map +1 -0
  56. package/dist/field/features/format/strikethrough/feature.client.d.ts.map +1 -1
  57. package/dist/field/features/format/strikethrough/feature.client.js +26 -22
  58. package/dist/field/features/format/strikethrough/feature.client.js.map +1 -1
  59. package/dist/field/features/format/subscript/feature.client.d.ts.map +1 -1
  60. package/dist/field/features/format/subscript/feature.client.js +24 -20
  61. package/dist/field/features/format/subscript/feature.client.js.map +1 -1
  62. package/dist/field/features/format/superscript/feature.client.d.ts.map +1 -1
  63. package/dist/field/features/format/superscript/feature.client.js +24 -20
  64. package/dist/field/features/format/superscript/feature.client.js.map +1 -1
  65. package/dist/field/features/format/underline/feature.client.d.ts.map +1 -1
  66. package/dist/field/features/format/underline/feature.client.js +24 -20
  67. package/dist/field/features/format/underline/feature.client.js.map +1 -1
  68. package/dist/field/features/heading/feature.client.d.ts.map +1 -1
  69. package/dist/field/features/heading/feature.client.js +69 -49
  70. package/dist/field/features/heading/feature.client.js.map +1 -1
  71. package/dist/field/features/{horizontalrule → horizontalRule}/component/index.d.ts.map +1 -1
  72. package/dist/field/features/{horizontalrule → horizontalRule}/component/index.js.map +1 -1
  73. package/dist/field/features/horizontalRule/feature.client.d.ts.map +1 -0
  74. package/dist/field/features/horizontalRule/feature.client.js +76 -0
  75. package/dist/field/features/horizontalRule/feature.client.js.map +1 -0
  76. package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.d.ts.map +1 -1
  77. package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.js +1 -1
  78. package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.js.map +1 -1
  79. package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.d.ts.map +1 -1
  80. package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.js.map +1 -1
  81. package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.d.ts.map +1 -1
  82. package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.js.map +1 -1
  83. package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.d.ts.map +1 -1
  84. package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.js.map +1 -1
  85. package/dist/field/features/indent/feature.client.d.ts.map +1 -1
  86. package/dist/field/features/indent/feature.client.js +42 -40
  87. package/dist/field/features/indent/feature.client.js.map +1 -1
  88. package/dist/field/features/indent/toolbarIndentGroup.d.ts +3 -0
  89. package/dist/field/features/indent/toolbarIndentGroup.d.ts.map +1 -0
  90. package/dist/field/features/indent/toolbarIndentGroup.js +10 -0
  91. package/dist/field/features/indent/toolbarIndentGroup.js.map +1 -0
  92. package/dist/field/features/link/feature.client.d.ts.map +1 -1
  93. package/dist/field/features/link/feature.client.js +47 -43
  94. package/dist/field/features/link/feature.client.js.map +1 -1
  95. package/dist/field/features/link/populationPromise.d.ts.map +1 -1
  96. package/dist/field/features/link/populationPromise.js +2 -1
  97. package/dist/field/features/link/populationPromise.js.map +1 -1
  98. package/dist/field/features/lists/checklist/feature.client.d.ts +1 -1
  99. package/dist/field/features/lists/checklist/feature.client.d.ts.map +1 -1
  100. package/dist/field/features/lists/checklist/feature.client.js +56 -31
  101. package/dist/field/features/lists/checklist/feature.client.js.map +1 -1
  102. package/dist/field/features/lists/checklist/feature.server.d.ts +1 -1
  103. package/dist/field/features/lists/checklist/feature.server.js +4 -4
  104. package/dist/field/features/lists/checklist/feature.server.js.map +1 -1
  105. package/dist/field/features/lists/checklist/markdownTransformers.js +1 -1
  106. package/dist/field/features/lists/checklist/markdownTransformers.js.map +1 -1
  107. package/dist/field/features/lists/orderedList/feature.client.d.ts.map +1 -0
  108. package/dist/field/features/lists/orderedList/feature.client.js +96 -0
  109. package/dist/field/features/lists/orderedList/feature.client.js.map +1 -0
  110. package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.d.ts.map +1 -1
  111. package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.js +1 -1
  112. package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.js.map +1 -1
  113. package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.d.ts.map +1 -1
  114. package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.js +1 -1
  115. package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.js.map +1 -1
  116. package/dist/field/features/lists/{common → shared}/markdown.d.ts.map +1 -1
  117. package/dist/field/features/lists/{common → shared}/markdown.js.map +1 -1
  118. package/dist/field/features/lists/unorderedList/feature.client.d.ts.map +1 -0
  119. package/dist/field/features/lists/unorderedList/feature.client.js +96 -0
  120. package/dist/field/features/lists/unorderedList/feature.client.js.map +1 -0
  121. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.d.ts.map +1 -1
  122. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.js +1 -1
  123. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.js.map +1 -1
  124. package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.d.ts.map +1 -1
  125. package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.js +1 -1
  126. package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.js.map +1 -1
  127. package/dist/field/features/paragraph/feature.client.d.ts.map +1 -1
  128. package/dist/field/features/paragraph/feature.client.js +44 -30
  129. package/dist/field/features/paragraph/feature.client.js.map +1 -1
  130. package/dist/field/features/relationship/feature.client.d.ts.map +1 -1
  131. package/dist/field/features/relationship/feature.client.js +36 -10
  132. package/dist/field/features/relationship/feature.client.js.map +1 -1
  133. package/dist/field/features/relationship/populationPromise.d.ts.map +1 -1
  134. package/dist/field/features/relationship/populationPromise.js +2 -1
  135. package/dist/field/features/relationship/populationPromise.js.map +1 -1
  136. package/dist/field/features/shared/toolbar/addDropdownGroup.d.ts +3 -0
  137. package/dist/field/features/shared/toolbar/addDropdownGroup.d.ts.map +1 -0
  138. package/dist/field/features/shared/toolbar/addDropdownGroup.js +12 -0
  139. package/dist/field/features/shared/toolbar/addDropdownGroup.js.map +1 -0
  140. package/dist/field/features/shared/toolbar/featureButtonsGroup.d.ts +3 -0
  141. package/dist/field/features/shared/toolbar/featureButtonsGroup.d.ts.map +1 -0
  142. package/dist/field/features/shared/toolbar/featureButtonsGroup.js +10 -0
  143. package/dist/field/features/shared/toolbar/featureButtonsGroup.js.map +1 -0
  144. package/dist/field/features/shared/toolbar/textDropdownGroup.d.ts +3 -0
  145. package/dist/field/features/shared/toolbar/textDropdownGroup.d.ts.map +1 -0
  146. package/dist/field/features/shared/toolbar/textDropdownGroup.js +12 -0
  147. package/dist/field/features/shared/toolbar/textDropdownGroup.js.map +1 -0
  148. package/dist/field/features/toolbars/fixed/Toolbar/index.d.ts +6 -0
  149. package/dist/field/features/toolbars/fixed/Toolbar/index.d.ts.map +1 -0
  150. package/dist/field/features/toolbars/fixed/Toolbar/index.js +152 -0
  151. package/dist/field/features/toolbars/fixed/Toolbar/index.js.map +1 -0
  152. package/dist/field/features/toolbars/fixed/Toolbar/index.scss +81 -0
  153. package/dist/field/features/toolbars/fixed/feature.client.d.ts +3 -0
  154. package/dist/field/features/toolbars/fixed/feature.client.d.ts.map +1 -0
  155. package/dist/field/features/toolbars/fixed/feature.client.js +20 -0
  156. package/dist/field/features/toolbars/fixed/feature.client.js.map +1 -0
  157. package/dist/field/features/toolbars/fixed/feature.server.d.ts +3 -0
  158. package/dist/field/features/toolbars/fixed/feature.server.d.ts.map +1 -0
  159. package/dist/field/features/toolbars/fixed/feature.server.js +16 -0
  160. package/dist/field/features/toolbars/fixed/feature.server.js.map +1 -0
  161. package/dist/field/features/toolbars/inline/Toolbar/index.d.ts +6 -0
  162. package/dist/field/features/toolbars/inline/Toolbar/index.d.ts.map +1 -0
  163. package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/inline/Toolbar}/index.js +64 -38
  164. package/dist/field/features/toolbars/inline/Toolbar/index.js.map +1 -0
  165. package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/inline/Toolbar}/index.scss +7 -11
  166. package/dist/field/features/toolbars/inline/feature.client.d.ts +3 -0
  167. package/dist/field/features/toolbars/inline/feature.client.d.ts.map +1 -0
  168. package/dist/field/features/toolbars/inline/feature.client.js +20 -0
  169. package/dist/field/features/toolbars/inline/feature.client.js.map +1 -0
  170. package/dist/field/features/toolbars/inline/feature.server.d.ts +3 -0
  171. package/dist/field/features/toolbars/inline/feature.server.d.ts.map +1 -0
  172. package/dist/field/features/toolbars/inline/feature.server.js +16 -0
  173. package/dist/field/features/toolbars/inline/feature.server.js.map +1 -0
  174. package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts +10 -0
  175. package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -0
  176. package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/shared}/ToolbarButton/index.js +16 -12
  177. package/dist/field/features/toolbars/shared/ToolbarButton/index.js.map +1 -0
  178. package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/shared}/ToolbarButton/index.scss +3 -1
  179. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts +23 -0
  180. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -0
  181. package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/shared}/ToolbarDropdown/DropDown.js +17 -67
  182. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -0
  183. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.d.ts +23 -0
  184. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -0
  185. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.js +139 -0
  186. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -0
  187. package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars/shared}/ToolbarDropdown/index.scss +25 -13
  188. package/dist/field/features/toolbars/types.d.ts +48 -0
  189. package/dist/field/features/toolbars/types.d.ts.map +1 -0
  190. package/dist/field/features/toolbars/types.js.map +1 -0
  191. package/dist/field/features/types.d.ts +51 -12
  192. package/dist/field/features/types.d.ts.map +1 -1
  193. package/dist/field/features/types.js.map +1 -1
  194. package/dist/field/features/upload/feature.client.d.ts.map +1 -1
  195. package/dist/field/features/upload/feature.client.js +35 -10
  196. package/dist/field/features/upload/feature.client.js.map +1 -1
  197. package/dist/field/features/upload/populationPromise.d.ts.map +1 -1
  198. package/dist/field/features/upload/populationPromise.js +3 -1
  199. package/dist/field/features/upload/populationPromise.js.map +1 -1
  200. package/dist/field/lexical/EditorFocusProvider.d.ts +20 -0
  201. package/dist/field/lexical/EditorFocusProvider.d.ts.map +1 -0
  202. package/dist/field/lexical/EditorFocusProvider.js +78 -0
  203. package/dist/field/lexical/EditorFocusProvider.js.map +1 -0
  204. package/dist/field/lexical/LexicalEditor.d.ts.map +1 -1
  205. package/dist/field/lexical/LexicalEditor.js +20 -4
  206. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  207. package/dist/field/lexical/LexicalEditor.scss +3 -19
  208. package/dist/field/lexical/LexicalProvider.d.ts.map +1 -1
  209. package/dist/field/lexical/LexicalProvider.js +3 -2
  210. package/dist/field/lexical/LexicalProvider.js.map +1 -1
  211. package/dist/field/lexical/config/client/EditorConfigProvider.d.ts +2 -3
  212. package/dist/field/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  213. package/dist/field/lexical/config/client/EditorConfigProvider.js.map +1 -1
  214. package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
  215. package/dist/field/lexical/config/client/sanitize.js +80 -32
  216. package/dist/field/lexical/config/client/sanitize.js.map +1 -1
  217. package/dist/field/lexical/config/server/default.d.ts.map +1 -1
  218. package/dist/field/lexical/config/server/default.js +9 -7
  219. package/dist/field/lexical/config/server/default.js.map +1 -1
  220. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +9 -9
  221. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  222. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +71 -71
  223. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  224. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +4 -4
  225. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  226. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +3 -3
  227. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  228. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts +17 -25
  229. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts.map +1 -1
  230. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js +1 -37
  231. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
  232. package/dist/field/lexical/plugins/SlashMenu/index.d.ts +2 -2
  233. package/dist/field/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
  234. package/dist/field/lexical/plugins/SlashMenu/index.js +71 -65
  235. package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
  236. package/dist/field/lexical/theme/EditorTheme.scss +2 -6
  237. package/dist/field/lexical/ui/icons/Add/index.d.ts +3 -0
  238. package/dist/field/lexical/ui/icons/Add/index.d.ts.map +1 -0
  239. package/dist/field/lexical/ui/icons/Add/index.js +16 -0
  240. package/dist/field/lexical/ui/icons/Add/index.js.map +1 -0
  241. package/dist/index.d.ts +15 -11
  242. package/dist/index.d.ts.map +1 -1
  243. package/dist/index.js +16 -12
  244. package/dist/index.js.map +1 -1
  245. package/dist/populate/populate.d.ts +2 -1
  246. package/dist/populate/populate.d.ts.map +1 -1
  247. package/dist/populate/populate.js +13 -11
  248. package/dist/populate/populate.js.map +1 -1
  249. package/dist/populate/populateLexicalPopulationPromises.d.ts +1 -1
  250. package/dist/populate/populateLexicalPopulationPromises.d.ts.map +1 -1
  251. package/dist/populate/populateLexicalPopulationPromises.js +2 -1
  252. package/dist/populate/populateLexicalPopulationPromises.js.map +1 -1
  253. package/dist/populate/recurseNestedFields.d.ts +2 -1
  254. package/dist/populate/recurseNestedFields.d.ts.map +1 -1
  255. package/dist/populate/recurseNestedFields.js +2 -1
  256. package/dist/populate/recurseNestedFields.js.map +1 -1
  257. package/package.json +10 -10
  258. package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.d.ts +0 -3
  259. package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.d.ts.map +0 -1
  260. package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.js +0 -12
  261. package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.js.map +0 -1
  262. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.d.ts +0 -3
  263. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.d.ts.map +0 -1
  264. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.js +0 -10
  265. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.js.map +0 -1
  266. package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.d.ts +0 -3
  267. package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.d.ts.map +0 -1
  268. package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.js +0 -12
  269. package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.js.map +0 -1
  270. package/dist/field/features/format/common/floatingSelectToolbarSection.d.ts +0 -3
  271. package/dist/field/features/format/common/floatingSelectToolbarSection.d.ts.map +0 -1
  272. package/dist/field/features/format/common/floatingSelectToolbarSection.js +0 -10
  273. package/dist/field/features/format/common/floatingSelectToolbarSection.js.map +0 -1
  274. package/dist/field/features/format/inlinecode/feature.client.d.ts.map +0 -1
  275. package/dist/field/features/format/inlinecode/feature.client.js +0 -42
  276. package/dist/field/features/format/inlinecode/feature.client.js.map +0 -1
  277. package/dist/field/features/horizontalrule/feature.client.d.ts.map +0 -1
  278. package/dist/field/features/horizontalrule/feature.client.js +0 -53
  279. package/dist/field/features/horizontalrule/feature.client.js.map +0 -1
  280. package/dist/field/features/indent/floatingSelectToolbarIndentSection.d.ts +0 -3
  281. package/dist/field/features/indent/floatingSelectToolbarIndentSection.d.ts.map +0 -1
  282. package/dist/field/features/indent/floatingSelectToolbarIndentSection.js +0 -10
  283. package/dist/field/features/indent/floatingSelectToolbarIndentSection.js.map +0 -1
  284. package/dist/field/features/indent/index.scss +0 -4
  285. package/dist/field/features/lists/orderedlist/feature.client.d.ts.map +0 -1
  286. package/dist/field/features/lists/orderedlist/feature.client.js +0 -71
  287. package/dist/field/features/lists/orderedlist/feature.client.js.map +0 -1
  288. package/dist/field/features/lists/unorderedlist/feature.client.d.ts.map +0 -1
  289. package/dist/field/features/lists/unorderedlist/feature.client.js +0 -71
  290. package/dist/field/features/lists/unorderedlist/feature.client.js.map +0 -1
  291. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts +0 -8
  292. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts.map +0 -1
  293. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js.map +0 -1
  294. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.d.ts +0 -17
  295. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.d.ts.map +0 -1
  296. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js.map +0 -1
  297. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.d.ts +0 -18
  298. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.d.ts.map +0 -1
  299. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.js +0 -42
  300. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.js.map +0 -1
  301. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts +0 -6
  302. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +0 -1
  303. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +0 -1
  304. package/dist/field/lexical/plugins/FloatingSelectToolbar/types.d.ts +0 -40
  305. package/dist/field/lexical/plugins/FloatingSelectToolbar/types.d.ts.map +0 -1
  306. package/dist/field/lexical/plugins/FloatingSelectToolbar/types.js.map +0 -1
  307. /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.d.ts +0 -0
  308. /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.js +0 -0
  309. /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.d.ts +0 -0
  310. /package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.d.ts +0 -0
  311. /package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.js +0 -0
  312. /package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.scss +0 -0
  313. /package/dist/field/features/debug/{treeview → treeView}/feature.client.d.ts +0 -0
  314. /package/dist/field/features/debug/{treeview → treeView}/feature.client.js +0 -0
  315. /package/dist/field/features/debug/{treeview → treeView}/feature.server.d.ts +0 -0
  316. /package/dist/field/features/debug/{treeview → treeView}/plugin/index.d.ts +0 -0
  317. /package/dist/field/features/debug/{treeview → treeView}/plugin/index.js +0 -0
  318. /package/dist/field/features/debug/{treeview → treeView}/plugin/index.scss +0 -0
  319. /package/dist/field/features/format/{inlinecode → inlineCode}/feature.client.d.ts +0 -0
  320. /package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.d.ts +0 -0
  321. /package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.d.ts +0 -0
  322. /package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.js +0 -0
  323. /package/dist/field/features/{horizontalrule → horizontalRule}/component/index.d.ts +0 -0
  324. /package/dist/field/features/{horizontalrule → horizontalRule}/component/index.js +0 -0
  325. /package/dist/field/features/{horizontalrule → horizontalRule}/feature.client.d.ts +0 -0
  326. /package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.d.ts +0 -0
  327. /package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.d.ts +0 -0
  328. /package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.js +0 -0
  329. /package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.d.ts +0 -0
  330. /package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.js +0 -0
  331. /package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.d.ts +0 -0
  332. /package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.js +0 -0
  333. /package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.scss +0 -0
  334. /package/dist/field/features/lists/{orderedlist → orderedList}/feature.client.d.ts +0 -0
  335. /package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.d.ts +0 -0
  336. /package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.d.ts +0 -0
  337. /package/dist/field/features/lists/{common → shared}/markdown.d.ts +0 -0
  338. /package/dist/field/features/lists/{common → shared}/markdown.js +0 -0
  339. /package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.client.d.ts +0 -0
  340. /package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.d.ts +0 -0
  341. /package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.d.ts +0 -0
  342. /package/dist/field/{lexical/plugins/FloatingSelectToolbar → features/toolbars}/types.js +0 -0
@@ -1,78 +1,23 @@
1
1
  'use client';
2
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
- import { mergeRegister } from '@lexical/utils';
4
- import { $getSelection } from 'lexical';
5
2
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
6
3
  import React from 'react';
7
4
  import { createPortal } from 'react-dom';
8
- const baseClass = 'floating-select-toolbar-popup__dropdown-item';
5
+ const baseClass = 'toolbar-popup__dropdown-item';
9
6
  const DropDownContext = /*#__PURE__*/ React.createContext(null);
10
- export function DropDownItem({ children, entry, title }) {
11
- const [editor] = useLexicalComposerContext();
12
- const [enabled, setEnabled] = useState(true);
13
- const [active, setActive] = useState(false);
7
+ export function DropDownItem({ active, children, editor, enabled, item, title }) {
14
8
  const [className, setClassName] = useState(baseClass);
15
- const updateStates = useCallback(()=>{
16
- editor.getEditorState().read(()=>{
17
- const selection = $getSelection();
18
- if (entry.isActive) {
19
- const isActive = entry.isActive({
20
- editor,
21
- selection
22
- });
23
- if (active !== isActive) {
24
- setActive(isActive);
25
- }
26
- }
27
- if (entry.isEnabled) {
28
- const isEnabled = entry.isEnabled({
29
- editor,
30
- selection
31
- });
32
- if (enabled !== isEnabled) {
33
- setEnabled(isEnabled);
34
- }
35
- }
36
- });
37
- }, [
38
- active,
39
- editor,
40
- enabled,
41
- entry
42
- ]);
43
- useEffect(()=>{
44
- updateStates();
45
- }, [
46
- updateStates
47
- ]);
48
- useEffect(()=>{
49
- document.addEventListener('mouseup', updateStates);
50
- return ()=>{
51
- document.removeEventListener('mouseup', updateStates);
52
- };
53
- }, [
54
- updateStates
55
- ]);
56
- useEffect(()=>{
57
- return mergeRegister(editor.registerUpdateListener(()=>{
58
- updateStates();
59
- }));
60
- }, [
61
- editor,
62
- updateStates
63
- ]);
64
9
  useEffect(()=>{
65
10
  setClassName([
66
11
  baseClass,
67
12
  enabled === false ? 'disabled' : '',
68
13
  active ? 'active' : '',
69
- entry?.key ? `${baseClass}-${entry.key}` : ''
14
+ item?.key ? `${baseClass}-${item.key}` : ''
70
15
  ].filter(Boolean).join(' '));
71
16
  }, [
72
17
  enabled,
73
18
  active,
74
19
  className,
75
- entry.key
20
+ item.key
76
21
  ]);
77
22
  const ref = useRef(null);
78
23
  const dropDownContext = React.useContext(DropDownContext);
@@ -92,7 +37,7 @@ export function DropDownItem({ children, entry, title }) {
92
37
  className: className,
93
38
  onClick: ()=>{
94
39
  if (enabled !== false) {
95
- entry.onClick({
40
+ item.onSelect({
96
41
  editor,
97
42
  isActive: active
98
43
  });
@@ -108,7 +53,7 @@ export function DropDownItem({ children, entry, title }) {
108
53
  type: "button"
109
54
  }, children);
110
55
  }
111
- function DropDownItems({ children, dropDownRef, onClose }) {
56
+ function DropDownItems({ children, dropDownRef, itemsContainerClassNames, onClose }) {
112
57
  const [items, setItems] = useState();
113
58
  const [highlightedItem, setHighlightedItem] = useState();
114
59
  const registerItem = useCallback((itemRef)=>{
@@ -156,7 +101,7 @@ function DropDownItems({ children, dropDownRef, onClose }) {
156
101
  if (items != null && highlightedItem == null) {
157
102
  setHighlightedItem(items[0]);
158
103
  }
159
- if (highlightedItem?.current != null) {
104
+ if (highlightedItem != null && highlightedItem?.current != null) {
160
105
  highlightedItem.current.focus();
161
106
  }
162
107
  }, [
@@ -166,12 +111,14 @@ function DropDownItems({ children, dropDownRef, onClose }) {
166
111
  return /*#__PURE__*/ React.createElement(DropDownContext.Provider, {
167
112
  value: contextValue
168
113
  }, /*#__PURE__*/ React.createElement("div", {
169
- className: "floating-select-toolbar-popup__dropdown-items",
114
+ className: (itemsContainerClassNames ?? [
115
+ 'toolbar-popup__dropdown-items'
116
+ ]).join(' '),
170
117
  onKeyDown: handleKeyDown,
171
118
  ref: dropDownRef
172
119
  }, children));
173
120
  }
174
- export function DropDown({ Icon, buttonAriaLabel, buttonClassName, children, disabled = false, stopCloseOnClickSelf }) {
121
+ export function DropDown({ Icon, buttonAriaLabel, buttonClassName, children, disabled = false, itemsContainerClassNames, label, stopCloseOnClickSelf }) {
175
122
  const dropDownRef = useRef(null);
176
123
  const buttonRef = useRef(null);
177
124
  const [showDropDown, setShowDropDown] = useState(false);
@@ -186,7 +133,7 @@ export function DropDown({ Icon, buttonAriaLabel, buttonClassName, children, dis
186
133
  const dropDown = dropDownRef.current;
187
134
  if (showDropDown && button !== null && dropDown !== null) {
188
135
  const { left, top } = button.getBoundingClientRect();
189
- const scrollTopOffset = window.pageYOffset || document.documentElement.scrollTop;
136
+ const scrollTopOffset = window.scrollY || document.documentElement.scrollTop;
190
137
  dropDown.style.top = `${top + scrollTopOffset + button.offsetHeight + 5}px`;
191
138
  dropDown.style.left = `${Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20)}px`;
192
139
  }
@@ -237,10 +184,13 @@ export function DropDown({ Icon, buttonAriaLabel, buttonClassName, children, dis
237
184
  },
238
185
  ref: buttonRef,
239
186
  type: "button"
240
- }, /*#__PURE__*/ React.createElement(Icon, null), /*#__PURE__*/ React.createElement("i", {
241
- className: "floating-select-toolbar-popup__dropdown-caret"
187
+ }, Icon && /*#__PURE__*/ React.createElement(Icon, null), label && /*#__PURE__*/ React.createElement("span", {
188
+ className: "toolbar-popup__dropdown-label"
189
+ }, label), /*#__PURE__*/ React.createElement("i", {
190
+ className: "toolbar-popup__dropdown-caret"
242
191
  })), showDropDown && /*#__PURE__*/ createPortal(/*#__PURE__*/ React.createElement(DropDownItems, {
243
192
  dropDownRef: dropDownRef,
193
+ itemsContainerClassNames: itemsContainerClassNames,
244
194
  onClose: handleClose
245
195
  }, children), document.body));
246
196
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/field/features/toolbars/shared/ToolbarDropdown/DropDown.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { ToolbarGroupItem } from '../../types.js'\n\nconst baseClass = '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 active,\n children,\n editor,\n enabled,\n item,\n title,\n}: {\n active?: boolean\n children: React.ReactNode\n editor: LexicalEditor\n enabled?: boolean\n item: ToolbarGroupItem\n title?: string\n}): React.ReactNode {\n const [className, setClassName] = useState<string>(baseClass)\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n item?.key ? `${baseClass}-${item.key}` : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className, item.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 item.onSelect({\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 itemsContainerClassNames,\n onClose,\n}: {\n children: React.ReactNode\n dropDownRef: React.Ref<HTMLDivElement>\n itemsContainerClassNames?: string[]\n onClose: () => void\n}): React.ReactElement {\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 != null && highlightedItem?.current != null) {\n highlightedItem.current.focus()\n }\n }, [items, highlightedItem])\n\n return (\n <DropDownContext.Provider value={contextValue}>\n <div\n className={(itemsContainerClassNames ?? ['toolbar-popup__dropdown-items']).join(' ')}\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 itemsContainerClassNames,\n label,\n stopCloseOnClickSelf,\n}: {\n Icon?: React.FC\n buttonAriaLabel?: string\n buttonClassName: string\n children: ReactNode\n disabled?: boolean\n itemsContainerClassNames?: string[]\n label?: string\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.scrollY || 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 && <Icon />}\n {label && <span className=\"toolbar-popup__dropdown-label\">{label}</span>}\n <i className=\"toolbar-popup__dropdown-caret\" />\n </button>\n\n {showDropDown &&\n createPortal(\n <DropDownItems\n dropDownRef={dropDownRef}\n itemsContainerClassNames={itemsContainerClassNames}\n onClose={handleClose}\n >\n {children}\n </DropDownItems>,\n document.body,\n )}\n </React.Fragment>\n )\n}\n"],"names":["useCallback","useEffect","useMemo","useRef","useState","React","createPortal","baseClass","DropDownContext","createContext","DropDownItem","active","children","editor","enabled","item","title","className","setClassName","key","filter","Boolean","join","ref","dropDownContext","useContext","Error","registerItem","current","button","onClick","onSelect","isActive","onMouseDown","e","preventDefault","type","DropDownItems","dropDownRef","itemsContainerClassNames","onClose","items","setItems","highlightedItem","setHighlightedItem","itemRef","prev","handleKeyDown","event","includes","index","indexOf","length","contextValue","focus","Provider","value","div","onKeyDown","DropDown","Icon","buttonAriaLabel","buttonClassName","disabled","label","stopCloseOnClickSelf","buttonRef","showDropDown","setShowDropDown","handleClose","dropDown","left","top","getBoundingClientRect","scrollTopOffset","window","scrollY","document","documentElement","scrollTop","style","offsetHeight","Math","min","innerWidth","offsetWidth","handle","target","contains","addEventListener","removeEventListener","Fragment","aria-label","span","i","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAAyBA,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,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,KAAK,EAQN;IACC,MAAM,CAACC,WAAWC,aAAa,GAAGd,SAAiBG;IAEnDN,UAAU;QACRiB,aACE;YACEX;YACAO,YAAY,QAAQ,aAAa;YACjCH,SAAS,WAAW;YACpBI,MAAMI,MAAM,CAAC,EAAEZ,UAAU,CAAC,EAAEQ,KAAKI,GAAG,CAAC,CAAC,GAAG;SAC1C,CACEC,MAAM,CAACC,SACPC,IAAI,CAAC;IAEZ,GAAG;QAACR;QAASH;QAAQM;QAAWF,KAAKI,GAAG;KAAC;IAEzC,MAAMI,MAAMpB,OAA0B;IAEtC,MAAMqB,kBAAkBnB,MAAMoB,UAAU,CAACjB;IAEzC,IAAIgB,oBAAoB,MAAM;QAC5B,MAAM,IAAIE,MAAM;IA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sBAAQ,oBAACA,aACTI,uBAAS,oBAAC6B;QAAK5E,WAAU;OAAiC+C,sBAC3D,oBAAC8B;QAAE7E,WAAU;SAGdkD,8BACC7D,2BACE,oBAAC+B;QACCC,aAAaA;QACbC,0BAA0BA;QAC1BC,SAAS6B;OAERzD,WAEHiE,SAASkB,IAAI;AAIvB"}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import type { LexicalEditor } from 'lexical';
3
+ import type { ToolbarGroupItem } from '../../types.js';
4
+ import './index.scss';
5
+ export declare const ToolbarDropdown: ({ Icon, anchorElem, classNames, editor, groupKey, items, itemsContainerClassNames, label, maxActiveItems, onActiveChange, }: {
6
+ Icon?: React.FC;
7
+ anchorElem: HTMLElement;
8
+ classNames?: string[];
9
+ editor: LexicalEditor;
10
+ groupKey: string;
11
+ items: ToolbarGroupItem[];
12
+ itemsContainerClassNames?: string[];
13
+ label?: string;
14
+ /**
15
+ * Maximum number of active items allowed. This is a performance optimization to prevent
16
+ * unnecessary item active checks when the maximum number of active items is reached.
17
+ */
18
+ maxActiveItems?: number;
19
+ onActiveChange?: ({ activeItems }: {
20
+ activeItems: ToolbarGroupItem[];
21
+ }) => void;
22
+ }) => React.JSX.Element;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/toolbars/shared/ToolbarDropdown/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiC,MAAM,OAAO,CAAA;AAIrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAItD,OAAO,cAAc,CAAA;AAiDrB,eAAO,MAAM,eAAe,gIAWzB;IACD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,UAAU,EAAE,WAAW,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,MAAM,EAAE,aAAa,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,gBAAgB,EAAE,CAAA;IACzB,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE;QAAE,WAAW,EAAE,gBAAgB,EAAE,CAAA;KAAE,KAAK,IAAI,CAAA;CAChF,sBAoFA,CAAA"}
@@ -0,0 +1,139 @@
1
+ 'use client';
2
+ import React, { useCallback, useEffect } from 'react';
3
+ const baseClass = 'toolbar-popup__dropdown';
4
+ import { mergeRegister } from '@lexical/utils';
5
+ import { useTranslation } from '@payloadcms/ui/providers/Translation';
6
+ import { $getSelection } from 'lexical';
7
+ import { useEditorFocus } from '../../../../lexical/EditorFocusProvider.js';
8
+ import { DropDown, DropDownItem } from './DropDown.js';
9
+ import './index.scss';
10
+ const ToolbarItem = ({ active, anchorElem, editor, enabled, item })=>{
11
+ const { i18n } = useTranslation();
12
+ if (item.Component) {
13
+ return item?.Component && /*#__PURE__*/ React.createElement(item.Component, {
14
+ active: active,
15
+ anchorElem: anchorElem,
16
+ editor: editor,
17
+ enabled: enabled,
18
+ item: item,
19
+ key: item.key
20
+ });
21
+ }
22
+ let title = item.key;
23
+ if (item.label) {
24
+ title = typeof item.label === 'function' ? item.label({
25
+ i18n
26
+ }) : item.label;
27
+ }
28
+ // Crop title to max. 25 characters
29
+ if (title.length > 25) {
30
+ title = title.substring(0, 25) + '...';
31
+ }
32
+ return /*#__PURE__*/ React.createElement(DropDownItem, {
33
+ active: active,
34
+ editor: editor,
35
+ enabled: enabled,
36
+ item: item,
37
+ key: item.key
38
+ }, item?.ChildComponent && /*#__PURE__*/ React.createElement(item.ChildComponent, null), /*#__PURE__*/ React.createElement("span", {
39
+ className: "text"
40
+ }, title));
41
+ };
42
+ export const ToolbarDropdown = ({ Icon, anchorElem, classNames, editor, groupKey, items, itemsContainerClassNames, label, maxActiveItems, onActiveChange })=>{
43
+ const [activeItemKeys, setActiveItemKeys] = React.useState([]);
44
+ const [enabledItemKeys, setEnabledItemKeys] = React.useState([]);
45
+ const editorFocusContext = useEditorFocus();
46
+ const updateStates = useCallback(()=>{
47
+ editor.getEditorState().read(()=>{
48
+ const selection = $getSelection();
49
+ const _activeItemKeys = [];
50
+ const _activeItems = [];
51
+ const _enabledItemKeys = [];
52
+ for (const item of items){
53
+ if (item.isActive && (!maxActiveItems || _activeItemKeys.length < maxActiveItems)) {
54
+ const isActive = item.isActive({
55
+ editor,
56
+ editorFocusContext,
57
+ selection
58
+ });
59
+ if (isActive) {
60
+ _activeItemKeys.push(item.key);
61
+ _activeItems.push(item);
62
+ }
63
+ }
64
+ if (item.isEnabled) {
65
+ const isEnabled = item.isEnabled({
66
+ editor,
67
+ editorFocusContext,
68
+ selection
69
+ });
70
+ if (isEnabled) {
71
+ _enabledItemKeys.push(item.key);
72
+ }
73
+ } else {
74
+ _enabledItemKeys.push(item.key);
75
+ }
76
+ }
77
+ setActiveItemKeys(_activeItemKeys);
78
+ setEnabledItemKeys(_enabledItemKeys);
79
+ if (onActiveChange) {
80
+ onActiveChange({
81
+ activeItems: _activeItems
82
+ });
83
+ }
84
+ });
85
+ }, [
86
+ editor,
87
+ editorFocusContext,
88
+ items,
89
+ maxActiveItems,
90
+ onActiveChange
91
+ ]);
92
+ useEffect(()=>{
93
+ updateStates();
94
+ }, [
95
+ updateStates
96
+ ]);
97
+ useEffect(()=>{
98
+ document.addEventListener('mouseup', updateStates);
99
+ return ()=>{
100
+ document.removeEventListener('mouseup', updateStates);
101
+ };
102
+ }, [
103
+ updateStates
104
+ ]);
105
+ useEffect(()=>{
106
+ return mergeRegister(editor.registerUpdateListener(()=>{
107
+ updateStates();
108
+ }));
109
+ }, [
110
+ editor,
111
+ updateStates
112
+ ]);
113
+ return /*#__PURE__*/ React.createElement(DropDown, {
114
+ Icon: Icon,
115
+ buttonAriaLabel: `${groupKey} dropdown`,
116
+ buttonClassName: [
117
+ baseClass,
118
+ `${baseClass}-${groupKey}`,
119
+ ...classNames || []
120
+ ].filter(Boolean).join(' '),
121
+ itemsContainerClassNames: [
122
+ `${baseClass}-items`,
123
+ ...itemsContainerClassNames || []
124
+ ],
125
+ key: groupKey,
126
+ label: label
127
+ }, items.length && items.map((item)=>{
128
+ return /*#__PURE__*/ React.createElement(ToolbarItem, {
129
+ active: activeItemKeys.includes(item.key),
130
+ anchorElem: anchorElem,
131
+ editor: editor,
132
+ enabled: enabledItemKeys.includes(item.key),
133
+ item: item,
134
+ key: item.key
135
+ });
136
+ }));
137
+ };
138
+
139
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/field/features/toolbars/shared/ToolbarDropdown/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect } from 'react'\n\nconst baseClass = 'toolbar-popup__dropdown'\n\nimport type { LexicalEditor } from 'lexical'\n\nimport { mergeRegister } from '@lexical/utils'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport { $getSelection } from 'lexical'\n\nimport type { ToolbarGroupItem } from '../../types.js'\n\nimport { useEditorFocus } from '../../../../lexical/EditorFocusProvider.js'\nimport { DropDown, DropDownItem } from './DropDown.js'\nimport './index.scss'\n\nconst ToolbarItem = ({\n active,\n anchorElem,\n editor,\n enabled,\n item,\n}: {\n active?: boolean\n anchorElem: HTMLElement\n editor: LexicalEditor\n enabled?: boolean\n item: ToolbarGroupItem\n}) => {\n const { i18n } = useTranslation()\n\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component\n active={active}\n anchorElem={anchorElem}\n editor={editor}\n enabled={enabled}\n item={item}\n key={item.key}\n />\n )\n )\n }\n\n let title = item.key\n if (item.label) {\n title = typeof item.label === 'function' ? item.label({ i18n }) : item.label\n }\n // Crop title to max. 25 characters\n if (title.length > 25) {\n title = title.substring(0, 25) + '...'\n }\n\n return (\n <DropDownItem active={active} editor={editor} enabled={enabled} item={item} key={item.key}>\n {item?.ChildComponent && <item.ChildComponent />}\n <span className=\"text\">{title}</span>\n </DropDownItem>\n )\n}\n\nexport const ToolbarDropdown = ({\n Icon,\n anchorElem,\n classNames,\n editor,\n groupKey,\n items,\n itemsContainerClassNames,\n label,\n maxActiveItems,\n onActiveChange,\n}: {\n Icon?: React.FC\n anchorElem: HTMLElement\n classNames?: string[]\n editor: LexicalEditor\n groupKey: string\n items: ToolbarGroupItem[]\n itemsContainerClassNames?: string[]\n label?: string\n /**\n * Maximum number of active items allowed. This is a performance optimization to prevent\n * unnecessary item active checks when the maximum number of active items is reached.\n */\n maxActiveItems?: number\n onActiveChange?: ({ activeItems }: { activeItems: ToolbarGroupItem[] }) => void\n}) => {\n const [activeItemKeys, setActiveItemKeys] = React.useState<string[]>([])\n const [enabledItemKeys, setEnabledItemKeys] = React.useState<string[]>([])\n const editorFocusContext = useEditorFocus()\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n\n const _activeItemKeys: string[] = []\n const _activeItems: ToolbarGroupItem[] = []\n const _enabledItemKeys: string[] = []\n\n for (const item of items) {\n if (item.isActive && (!maxActiveItems || _activeItemKeys.length < maxActiveItems)) {\n const isActive = item.isActive({ editor, editorFocusContext, selection })\n if (isActive) {\n _activeItemKeys.push(item.key)\n _activeItems.push(item)\n }\n }\n if (item.isEnabled) {\n const isEnabled = item.isEnabled({ editor, editorFocusContext, selection })\n if (isEnabled) {\n _enabledItemKeys.push(item.key)\n }\n } else {\n _enabledItemKeys.push(item.key)\n }\n }\n setActiveItemKeys(_activeItemKeys)\n setEnabledItemKeys(_enabledItemKeys)\n\n if (onActiveChange) {\n onActiveChange({ activeItems: _activeItems })\n }\n })\n }, [editor, editorFocusContext, items, maxActiveItems, onActiveChange])\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 return (\n <DropDown\n Icon={Icon}\n buttonAriaLabel={`${groupKey} dropdown`}\n buttonClassName={[baseClass, `${baseClass}-${groupKey}`, ...(classNames || [])]\n .filter(Boolean)\n .join(' ')}\n itemsContainerClassNames={[`${baseClass}-items`, ...(itemsContainerClassNames || [])]}\n key={groupKey}\n label={label}\n >\n {items.length &&\n items.map((item) => {\n return (\n <ToolbarItem\n active={activeItemKeys.includes(item.key)}\n anchorElem={anchorElem}\n editor={editor}\n enabled={enabledItemKeys.includes(item.key)}\n item={item}\n key={item.key}\n />\n )\n })}\n </DropDown>\n )\n}\n"],"names":["React","useCallback","useEffect","baseClass","mergeRegister","useTranslation","$getSelection","useEditorFocus","DropDown","DropDownItem","ToolbarItem","active","anchorElem","editor","enabled","item","i18n","Component","key","title","label","length","substring","ChildComponent","span","className","ToolbarDropdown","Icon","classNames","groupKey","items","itemsContainerClassNames","maxActiveItems","onActiveChange","activeItemKeys","setActiveItemKeys","useState","enabledItemKeys","setEnabledItemKeys","editorFocusContext","updateStates","getEditorState","read","selection","_activeItemKeys","_activeItems","_enabledItemKeys","isActive","push","isEnabled","activeItems","document","addEventListener","removeEventListener","registerUpdateListener","buttonAriaLabel","buttonClassName","filter","Boolean","join","map","includes"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,SAASC,WAAW,EAAEC,SAAS,QAAQ,QAAO;AAErD,MAAMC,YAAY;AAIlB,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,cAAc,QAAQ,uCAAsC;AACrE,S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,MAAMA;QACN4B,iBAAiB,CAAC,EAAE1B,SAAS,SAAS,CAAC;QACvC2B,iBAAiB;YAACrD;YAAW,CAAC,EAAEA,UAAU,CAAC,EAAE0B,SAAS,CAAC;eAAMD,cAAc,EAAE;SAAE,CAC5E6B,MAAM,CAACC,SACPC,IAAI,CAAC;QACR5B,0BAA0B;YAAC,CAAC,EAAE5B,UAAU,MAAM,CAAC;eAAM4B,4BAA4B,EAAE;SAAE;QACrFb,KAAKW;QACLT,OAAOA;OAENU,MAAMT,MAAM,IACXS,MAAM8B,GAAG,CAAC,CAAC7C;QACT,qBACE,oBAACL;YACCC,QAAQuB,eAAe2B,QAAQ,CAAC9C,KAAKG,GAAG;YACxCN,YAAYA;YACZC,QAAQA;YACRC,SAASuB,gBAAgBwB,QAAQ,CAAC9C,KAAKG,GAAG;YAC1CH,MAAMA;YACNG,KAAKH,KAAKG,GAAG;;IAGnB;AAGR,EAAC"}
@@ -1,18 +1,22 @@
1
- @import '../../../../../scss/styles.scss';
1
+ @import '../../../../../scss/styles';
2
2
 
3
- .floating-select-toolbar-popup__dropdown {
3
+ .toolbar-popup__dropdown {
4
4
  display: flex;
5
5
  align-items: center;
6
6
  vertical-align: middle;
7
7
  justify-content: center;
8
8
  height: 30px;
9
- width: 40px;
10
9
  border: 0;
11
10
  background: none;
12
11
  border-radius: 4px;
13
12
  cursor: pointer;
14
13
  position: relative;
15
- padding: 0;
14
+ padding: 0 10px;
15
+
16
+ &-label {
17
+ color: var(--color-base-600);
18
+ padding: 0 10px;
19
+ }
16
20
 
17
21
  &:disabled {
18
22
  cursor: not-allowed;
@@ -26,10 +30,10 @@
26
30
  background-color: var(--color-base-100);
27
31
  }
28
32
 
29
- &.active {
33
+ .active {
30
34
  background-color: var(--color-base-100);
31
35
 
32
- .floating-select-toolbar-popup__dropdown-caret {
36
+ .toolbar-popup__dropdown-caret {
33
37
  &:after {
34
38
  transform: rotate(0deg);
35
39
  }
@@ -50,9 +54,9 @@
50
54
  height: 4px;
51
55
 
52
56
  opacity: 0.3;
53
- background-image: url(../../../ui/icons/Caret/index.svg);
54
- background-position-y: 0px;
55
- background-position-x: 0px;
57
+ background-image: url(../../../../lexical/ui/icons/Caret/index.svg);
58
+ background-position-y: 0;
59
+ background-position-x: 0;
56
60
  }
57
61
  }
58
62
 
@@ -60,17 +64,25 @@
60
64
  position: absolute;
61
65
  background: var(--color-base-0);
62
66
  border-radius: 4px;
63
- width: 132.5px;
67
+ min-width: 132.5px;
68
+ max-width: 200px;
64
69
  z-index: 100;
65
70
 
66
- .floating-select-toolbar-popup__dropdown-item {
71
+ .toolbar-popup__dropdown-item {
67
72
  all: unset; // reset all default button styles
68
73
  cursor: pointer;
69
74
  color: var(--color-base-900);
70
75
 
71
- &:hover:not([disabled]) {
76
+ .text {
77
+ overflow: hidden;
78
+ white-space: nowrap;
79
+ text-overflow: ellipsis;
80
+ }
81
+
82
+ &:hover:not([disabled]), &.active {
72
83
  background-color: var(--color-base-100);
73
84
  }
85
+
74
86
  padding-left: 6.25px;
75
87
  padding-right: 6.25px;
76
88
  width: 100%;
@@ -91,7 +103,7 @@
91
103
  }
92
104
 
93
105
  html[data-theme='light'] {
94
- .floating-select-toolbar-popup__dropdown {
106
+ .toolbar-popup__dropdown {
95
107
  &-items {
96
108
  position: absolute;
97
109
  @include shadow-m;
@@ -0,0 +1,48 @@
1
+ import type { I18n } from '@payloadcms/translations';
2
+ import type { BaseSelection, LexicalEditor } from 'lexical';
3
+ import type React from 'react';
4
+ import type { EditorFocusContextType } from '../../lexical/EditorFocusProvider.js';
5
+ export type ToolbarGroup = {
6
+ ChildComponent?: React.FC;
7
+ items: Array<ToolbarGroupItem>;
8
+ key: string;
9
+ order?: number;
10
+ type: 'dropdown';
11
+ } | {
12
+ items: Array<ToolbarGroupItem>;
13
+ key: string;
14
+ order?: number;
15
+ type: 'buttons';
16
+ };
17
+ export type ToolbarGroupItem = {
18
+ ChildComponent?: React.FC;
19
+ /** Use component to ignore the children and onClick properties. It does not use the default, pre-defined format Button component */
20
+ Component?: React.FC<{
21
+ active?: boolean;
22
+ anchorElem: HTMLElement;
23
+ editor: LexicalEditor;
24
+ enabled?: boolean;
25
+ item: ToolbarGroupItem;
26
+ }>;
27
+ isActive?: ({ editor, editorFocusContext, selection, }: {
28
+ editor: LexicalEditor;
29
+ editorFocusContext: EditorFocusContextType;
30
+ selection: BaseSelection;
31
+ }) => boolean;
32
+ isEnabled?: ({ editor, editorFocusContext, selection, }: {
33
+ editor: LexicalEditor;
34
+ editorFocusContext: EditorFocusContextType;
35
+ selection: BaseSelection;
36
+ }) => boolean;
37
+ key: string;
38
+ /** The label is displayed as text if the item is part of a dropdown group */
39
+ label?: (({ i18n }: {
40
+ i18n: I18n;
41
+ }) => string) | string;
42
+ onSelect?: ({ editor, isActive }: {
43
+ editor: LexicalEditor;
44
+ isActive: boolean;
45
+ }) => void;
46
+ order?: number;
47
+ };
48
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/field/features/toolbars/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAA;AAElF,MAAM,MAAM,YAAY,GACpB;IACE,cAAc,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACzB,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,UAAU,CAAA;CACjB,GACD;IACE,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,KA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Content":["import type { I18n } from '@payloadcms/translations'\nimport type { BaseSelection, LexicalEditor } from 'lexical'\nimport type React from 'react'\n\nimport type { EditorFocusContextType } from '../../lexical/EditorFocusProvider.js'\n\nexport type ToolbarGroup =\n | {\n ChildComponent?: React.FC\n items: Array<ToolbarGroupItem>\n key: string\n order?: number\n type: 'dropdown'\n }\n | {\n items: Array<ToolbarGroupItem>\n key: string\n order?: number\n type: 'buttons'\n }\n\nexport type ToolbarGroupItem = {\n ChildComponent?: React.FC\n /** Use component to ignore the children and onClick properties. It does not use the default, pre-defined format Button component */\n Component?: React.FC<{\n active?: boolean\n anchorElem: HTMLElement\n editor: LexicalEditor\n enabled?: boolean\n item: ToolbarGroupItem\n }>\n isActive?: ({\n editor,\n editorFocusContext,\n selection,\n }: {\n editor: LexicalEditor\n editorFocusContext: EditorFocusContextType\n selection: BaseSelection\n }) => boolean\n isEnabled?: ({\n editor,\n editorFocusContext,\n selection,\n }: {\n editor: LexicalEditor\n editorFocusContext: EditorFocusContextType\n selection: BaseSelection\n }) => boolean\n key: string\n /** The label is displayed as text if the item is part of a dropdown group */\n label?: (({ i18n }: { i18n: I18n }) => string) | string\n onSelect?: ({ editor, isActive }: { editor: LexicalEditor; isActive: boolean }) => void\n order?: number\n}\n"],"names":[],"rangeMappings":"","mappings":"AAqBA,WAiCC"}
@@ -10,13 +10,14 @@ import type { Field, PayloadRequestWithData, ReplaceAny, RichTextField, Validate
10
10
  import type React from 'react';
11
11
  import type { AdapterProps } from '../../types.js';
12
12
  import type { ClientEditorConfig, ServerEditorConfig } from '../lexical/config/types.js';
13
- import type { FloatingToolbarSection } from '../lexical/plugins/FloatingSelectToolbar/types.js';
14
13
  import type { SlashMenuGroup } from '../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js';
15
14
  import type { HTMLConverter } from './converters/html/converter/types.js';
15
+ import type { ToolbarGroup } from './toolbars/types.js';
16
16
  export type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = ({ context, currentDepth, depth, editorPopulationPromises, field, fieldPromises, findMany, flattenLocales, node, overrideAccess, populationPromises, req, showHiddenFields, siblingDoc, }: {
17
17
  context: RequestContext;
18
18
  currentDepth: number;
19
19
  depth: number;
20
+ draft: boolean;
20
21
  /**
21
22
  * This maps all population promises to the node type
22
23
  */
@@ -87,9 +88,6 @@ export type ClientFeature<ClientFeatureProps> = {
87
88
  * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to
88
89
  */
89
90
  clientFeatureProps: ClientComponentProps<ClientFeatureProps>;
90
- floatingSelectToolbar?: {
91
- sections: FloatingToolbarSection[];
92
- };
93
91
  hooks?: {
94
92
  load?: ({ incomingEditorState, }: {
95
93
  incomingEditorState: SerializedEditorState;
@@ -100,6 +98,9 @@ export type ClientFeature<ClientFeatureProps> = {
100
98
  };
101
99
  markdownTransformers?: Transformer[];
102
100
  nodes?: Array<Klass<LexicalNode> | LexicalNodeReplacement>;
101
+ /**
102
+ * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more "outside" functionality
103
+ */
103
104
  plugins?: Array<{
104
105
  Component: React.FC;
105
106
  position: 'bottom';
@@ -116,11 +117,36 @@ export type ClientFeature<ClientFeatureProps> = {
116
117
  position: 'floatingAnchorElem';
117
118
  }>;
118
119
  slashMenu?: {
119
- dynamicOptions?: ({ editor, queryString, }: {
120
+ /**
121
+ * Dynamic groups allow you to add different groups depending on the query string (so, the text after the slash).
122
+ * Thus, to re-calculate the available groups, this function will be called every time you type after the /.
123
+ *
124
+ * The groups provided by dynamicGroups will be merged with the static groups provided by the groups property.
125
+ */
126
+ dynamicGroups?: ({ editor, queryString, }: {
120
127
  editor: LexicalEditor;
121
128
  queryString: string;
122
129
  }) => SlashMenuGroup[];
123
- options?: SlashMenuGroup[];
130
+ /**
131
+ * Static array of groups together with the items in them. These will always be present.
132
+ * While typing after the /, they will be filtered by the query string and the keywords, key and display name of the items.
133
+ */
134
+ groups?: SlashMenuGroup[];
135
+ };
136
+ /**
137
+ * An opt-in, classic fixed toolbar which stays at the top of the editor
138
+ */
139
+ toolbarFixed?: {
140
+ groups: ToolbarGroup[];
141
+ };
142
+ /**
143
+ * The default, floating toolbar which appears when you select text.
144
+ */
145
+ toolbarInline?: {
146
+ /**
147
+ * Array of toolbar groups / sections. Each section can contain multiple toolbar items.
148
+ */
149
+ groups: ToolbarGroup[];
124
150
  };
125
151
  };
126
152
  export type ClientComponentProps<ClientFeatureProps> = ClientFeatureProps & {
@@ -216,6 +242,9 @@ export type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<unknown
216
242
  export type ResolvedClientFeatureMap = Map<string, ResolvedClientFeature<unknown>>;
217
243
  export type ServerFeatureProviderMap = Map<string, FeatureProviderServer<unknown, unknown>>;
218
244
  export type ClientFeatureProviderMap = Map<string, FeatureProviderClient<unknown>>;
245
+ /**
246
+ * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more "outside" functionality
247
+ */
219
248
  export type SanitizedPlugin = {
220
249
  Component: React.FC;
221
250
  key: string;
@@ -276,12 +305,9 @@ export type SanitizedServerFeatures = Required<Pick<ResolvedServerFeature<unknow
276
305
  /** The node types mapped to their validations */
277
306
  validations: Map<string, Array<NodeValidation>>;
278
307
  };
279
- export type SanitizedClientFeatures = Required<Pick<ResolvedClientFeature<unknown>, 'markdownTransformers' | 'nodes'>> & {
308
+ export type SanitizedClientFeatures = Required<Pick<ResolvedClientFeature<unknown>, 'markdownTransformers' | 'nodes' | 'toolbarFixed' | 'toolbarInline'>> & {
280
309
  /** The keys of all enabled features */
281
310
  enabledFeatures: string[];
282
- floatingSelectToolbar: {
283
- sections: FloatingToolbarSection[];
284
- };
285
311
  hooks: {
286
312
  load: Array<({ incomingEditorState, }: {
287
313
  incomingEditorState: SerializedEditorState;
@@ -290,13 +316,26 @@ export type SanitizedClientFeatures = Required<Pick<ResolvedClientFeature<unknow
290
316
  incomingEditorState: SerializedEditorState;
291
317
  }) => SerializedEditorState>;
292
318
  };
319
+ /**
320
+ * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more "outside" functionality
321
+ */
293
322
  plugins?: Array<SanitizedPlugin>;
294
323
  slashMenu: {
295
- dynamicOptions: Array<({ editor, queryString }: {
324
+ /**
325
+ * Dynamic groups allow you to add different groups depending on the query string (so, the text after the slash).
326
+ * Thus, to re-calculate the available groups, this function will be called every time you type after the /.
327
+ *
328
+ * The groups provided by dynamicGroups will be merged with the static groups provided by the groups property.
329
+ */
330
+ dynamicGroups: Array<({ editor, queryString }: {
296
331
  editor: LexicalEditor;
297
332
  queryString: string;
298
333
  }) => SlashMenuGroup[]>;
299
- groupsWithOptions: SlashMenuGroup[];
334
+ /**
335
+ * Static array of groups together with the items in them. These will always be present.
336
+ * While typing after the /, they will be filtered by the query string and the keywords, key and display name of the items.
337
+ */
338
+ groups: SlashMenuGroup[];
300
339
  };
301
340
  };
302
341
  //# sourceMappingURL=types.d.ts.map