@payloadcms/richtext-lexical 3.0.0-beta.24 → 3.0.0-beta.26

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 (359) hide show
  1. package/dist/exports/components.d.ts +8 -2
  2. package/dist/exports/components.d.ts.map +1 -1
  3. package/dist/exports/components.js +8 -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 +126 -46
  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/{inlineToolbarAlignGroup.js → toolbarAlignGroup.js} +3 -3
  11. package/dist/field/features/align/toolbarAlignGroup.js.map +1 -0
  12. package/dist/field/features/blockquote/feature.client.d.ts +1 -1
  13. package/dist/field/features/blockquote/feature.client.d.ts.map +1 -1
  14. package/dist/field/features/blockquote/feature.client.js +39 -25
  15. package/dist/field/features/blockquote/feature.client.js.map +1 -1
  16. package/dist/field/features/blockquote/feature.server.d.ts +1 -1
  17. package/dist/field/features/blockquote/feature.server.js +3 -3
  18. package/dist/field/features/blockquote/feature.server.js.map +1 -1
  19. package/dist/field/features/blocks/component/index.d.ts.map +1 -1
  20. package/dist/field/features/blocks/component/index.js +1 -1
  21. package/dist/field/features/blocks/component/index.js.map +1 -1
  22. package/dist/field/features/blocks/feature.client.d.ts.map +1 -1
  23. package/dist/field/features/blocks/feature.client.js +39 -8
  24. package/dist/field/features/blocks/feature.client.js.map +1 -1
  25. package/dist/field/features/blocks/feature.server.d.ts +2 -5
  26. package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
  27. package/dist/field/features/blocks/feature.server.js +2 -2
  28. package/dist/field/features/blocks/feature.server.js.map +1 -1
  29. package/dist/field/features/blocks/plugin/index.d.ts +3 -2
  30. package/dist/field/features/blocks/plugin/index.d.ts.map +1 -1
  31. package/dist/field/features/blocks/plugin/index.js +2 -2
  32. package/dist/field/features/blocks/plugin/index.js.map +1 -1
  33. package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
  34. package/dist/field/features/blocks/populationPromise.js +2 -1
  35. package/dist/field/features/blocks/populationPromise.js.map +1 -1
  36. package/dist/field/features/debug/testRecorder/plugin/index.d.ts +2 -2
  37. package/dist/field/features/debug/testRecorder/plugin/index.d.ts.map +1 -1
  38. package/dist/field/features/debug/testRecorder/plugin/index.js.map +1 -1
  39. package/dist/field/features/debug/treeView/plugin/index.d.ts +2 -2
  40. package/dist/field/features/debug/treeView/plugin/index.d.ts.map +1 -1
  41. package/dist/field/features/debug/treeView/plugin/index.js +2 -2
  42. package/dist/field/features/debug/treeView/plugin/index.js.map +1 -1
  43. package/dist/field/features/format/bold/feature.client.d.ts.map +1 -1
  44. package/dist/field/features/format/bold/feature.client.js +23 -19
  45. package/dist/field/features/format/bold/feature.client.js.map +1 -1
  46. package/dist/field/features/format/inlineCode/feature.client.d.ts.map +1 -1
  47. package/dist/field/features/format/inlineCode/feature.client.js +23 -19
  48. package/dist/field/features/format/inlineCode/feature.client.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 +23 -19
  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 +23 -19
  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 +23 -19
  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 +23 -19
  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 +23 -19
  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 +49 -29
  70. package/dist/field/features/heading/feature.client.js.map +1 -1
  71. package/dist/field/features/horizontalRule/feature.client.d.ts.map +1 -1
  72. package/dist/field/features/horizontalRule/feature.client.js +27 -4
  73. package/dist/field/features/horizontalRule/feature.client.js.map +1 -1
  74. package/dist/field/features/horizontalRule/plugin/index.d.ts +2 -1
  75. package/dist/field/features/horizontalRule/plugin/index.d.ts.map +1 -1
  76. package/dist/field/features/horizontalRule/plugin/index.js +2 -2
  77. package/dist/field/features/horizontalRule/plugin/index.js.map +1 -1
  78. package/dist/field/features/indent/feature.client.d.ts.map +1 -1
  79. package/dist/field/features/indent/feature.client.js +41 -37
  80. package/dist/field/features/indent/feature.client.js.map +1 -1
  81. package/dist/field/features/indent/toolbarIndentGroup.d.ts +3 -0
  82. package/dist/field/features/indent/toolbarIndentGroup.d.ts.map +1 -0
  83. package/dist/field/features/indent/toolbarIndentGroup.js +10 -0
  84. package/dist/field/features/indent/toolbarIndentGroup.js.map +1 -0
  85. package/dist/field/features/link/drawer/baseFields.d.ts +2 -2
  86. package/dist/field/features/link/drawer/baseFields.d.ts.map +1 -1
  87. package/dist/field/features/link/drawer/baseFields.js +2 -1
  88. package/dist/field/features/link/drawer/baseFields.js.map +1 -1
  89. package/dist/field/features/link/drawer/types.d.ts +2 -2
  90. package/dist/field/features/link/drawer/types.d.ts.map +1 -1
  91. package/dist/field/features/link/drawer/types.js.map +1 -1
  92. package/dist/field/features/link/feature.client.d.ts.map +1 -1
  93. package/dist/field/features/link/feature.client.js +54 -40
  94. package/dist/field/features/link/feature.client.js.map +1 -1
  95. package/dist/field/features/link/feature.server.d.ts +10 -3
  96. package/dist/field/features/link/feature.server.d.ts.map +1 -1
  97. package/dist/field/features/link/feature.server.js +3 -3
  98. package/dist/field/features/link/feature.server.js.map +1 -1
  99. package/dist/field/features/link/plugins/autoLink/index.d.ts +3 -2
  100. package/dist/field/features/link/plugins/autoLink/index.d.ts.map +1 -1
  101. package/dist/field/features/link/plugins/autoLink/index.js +2 -2
  102. package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
  103. package/dist/field/features/link/plugins/clickableLink/index.d.ts +3 -2
  104. package/dist/field/features/link/plugins/clickableLink/index.d.ts.map +1 -1
  105. package/dist/field/features/link/plugins/clickableLink/index.js +2 -2
  106. package/dist/field/features/link/plugins/clickableLink/index.js.map +1 -1
  107. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  108. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +75 -68
  109. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  110. package/dist/field/features/link/plugins/floatingLinkEditor/index.d.ts +3 -4
  111. package/dist/field/features/link/plugins/floatingLinkEditor/index.d.ts.map +1 -1
  112. package/dist/field/features/link/plugins/floatingLinkEditor/index.js.map +1 -1
  113. package/dist/field/features/link/plugins/floatingLinkEditor/index.scss +2 -2
  114. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts +3 -3
  115. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
  116. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js +2 -2
  117. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
  118. package/dist/field/features/link/plugins/link/index.d.ts +3 -1
  119. package/dist/field/features/link/plugins/link/index.d.ts.map +1 -1
  120. package/dist/field/features/link/plugins/link/index.js +2 -2
  121. package/dist/field/features/link/plugins/link/index.js.map +1 -1
  122. package/dist/field/features/link/populationPromise.d.ts.map +1 -1
  123. package/dist/field/features/link/populationPromise.js +2 -1
  124. package/dist/field/features/link/populationPromise.js.map +1 -1
  125. package/dist/field/features/link/validate.js.map +1 -1
  126. package/dist/field/features/lists/checklist/feature.client.d.ts.map +1 -1
  127. package/dist/field/features/lists/checklist/feature.client.js +44 -19
  128. package/dist/field/features/lists/checklist/feature.client.js.map +1 -1
  129. package/dist/field/features/lists/checklist/plugin/index.d.ts +2 -2
  130. package/dist/field/features/lists/checklist/plugin/index.d.ts.map +1 -1
  131. package/dist/field/features/lists/checklist/plugin/index.js +2 -2
  132. package/dist/field/features/lists/checklist/plugin/index.js.map +1 -1
  133. package/dist/field/features/lists/orderedList/feature.client.d.ts.map +1 -1
  134. package/dist/field/features/lists/orderedList/feature.client.js +44 -19
  135. package/dist/field/features/lists/orderedList/feature.client.js.map +1 -1
  136. package/dist/field/features/lists/plugin/index.d.ts +2 -2
  137. package/dist/field/features/lists/plugin/index.d.ts.map +1 -1
  138. package/dist/field/features/lists/plugin/index.js +2 -2
  139. package/dist/field/features/lists/plugin/index.js.map +1 -1
  140. package/dist/field/features/lists/unorderedList/feature.client.d.ts.map +1 -1
  141. package/dist/field/features/lists/unorderedList/feature.client.js +44 -19
  142. package/dist/field/features/lists/unorderedList/feature.client.js.map +1 -1
  143. package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/client.d.ts +1 -1
  144. package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/client.js +1 -1
  145. package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/client.js.map +1 -1
  146. package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/index.js +2 -2
  147. package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/index.js.map +1 -1
  148. package/dist/field/features/paragraph/feature.client.d.ts.map +1 -1
  149. package/dist/field/features/paragraph/feature.client.js +36 -22
  150. package/dist/field/features/paragraph/feature.client.js.map +1 -1
  151. package/dist/field/features/relationship/feature.client.d.ts.map +1 -1
  152. package/dist/field/features/relationship/feature.client.js +31 -9
  153. package/dist/field/features/relationship/feature.client.js.map +1 -1
  154. package/dist/field/features/relationship/feature.server.d.ts +10 -1
  155. package/dist/field/features/relationship/feature.server.d.ts.map +1 -1
  156. package/dist/field/features/relationship/feature.server.js +2 -2
  157. package/dist/field/features/relationship/feature.server.js.map +1 -1
  158. package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
  159. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +4 -2
  160. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
  161. package/dist/field/features/relationship/plugins/index.d.ts +2 -2
  162. package/dist/field/features/relationship/plugins/index.d.ts.map +1 -1
  163. package/dist/field/features/relationship/plugins/index.js +6 -6
  164. package/dist/field/features/relationship/plugins/index.js.map +1 -1
  165. package/dist/field/features/relationship/populationPromise.d.ts +2 -1
  166. package/dist/field/features/relationship/populationPromise.d.ts.map +1 -1
  167. package/dist/field/features/relationship/populationPromise.js +25 -20
  168. package/dist/field/features/relationship/populationPromise.js.map +1 -1
  169. package/dist/field/features/shared/toolbar/addDropdownGroup.d.ts +3 -0
  170. package/dist/field/features/shared/toolbar/addDropdownGroup.d.ts.map +1 -0
  171. package/dist/field/features/shared/toolbar/addDropdownGroup.js +12 -0
  172. package/dist/field/features/shared/toolbar/addDropdownGroup.js.map +1 -0
  173. package/dist/field/features/shared/toolbar/featureButtonsGroup.d.ts +3 -0
  174. package/dist/field/features/shared/toolbar/featureButtonsGroup.d.ts.map +1 -0
  175. package/dist/field/features/shared/toolbar/featureButtonsGroup.js +10 -0
  176. package/dist/field/features/shared/toolbar/featureButtonsGroup.js.map +1 -0
  177. package/dist/field/features/shared/toolbar/textDropdownGroup.d.ts +3 -0
  178. package/dist/field/features/shared/toolbar/textDropdownGroup.d.ts.map +1 -0
  179. package/dist/field/features/shared/{inlineToolbar → toolbar}/textDropdownGroup.js +2 -2
  180. package/dist/field/features/shared/toolbar/textDropdownGroup.js.map +1 -0
  181. package/dist/field/features/toolbars/fixed/Toolbar/index.d.ts +4 -0
  182. package/dist/field/features/toolbars/fixed/Toolbar/index.d.ts.map +1 -0
  183. package/dist/field/features/toolbars/fixed/Toolbar/index.js +152 -0
  184. package/dist/field/features/toolbars/fixed/Toolbar/index.js.map +1 -0
  185. package/dist/field/features/toolbars/fixed/Toolbar/index.scss +81 -0
  186. package/dist/field/features/toolbars/fixed/feature.client.d.ts +3 -0
  187. package/dist/field/features/toolbars/fixed/feature.client.d.ts.map +1 -0
  188. package/dist/field/features/toolbars/fixed/feature.client.js +20 -0
  189. package/dist/field/features/toolbars/fixed/feature.client.js.map +1 -0
  190. package/dist/field/features/toolbars/fixed/feature.server.d.ts +3 -0
  191. package/dist/field/features/toolbars/fixed/feature.server.d.ts.map +1 -0
  192. package/dist/field/features/toolbars/fixed/feature.server.js +16 -0
  193. package/dist/field/features/toolbars/fixed/feature.server.js.map +1 -0
  194. package/dist/field/features/toolbars/inline/Toolbar/index.d.ts +4 -0
  195. package/dist/field/features/toolbars/inline/Toolbar/index.d.ts.map +1 -0
  196. package/dist/field/{lexical/plugins → features}/toolbars/inline/Toolbar/index.js +67 -23
  197. package/dist/field/features/toolbars/inline/Toolbar/index.js.map +1 -0
  198. package/dist/field/{lexical/plugins → features}/toolbars/inline/Toolbar/index.scss +3 -8
  199. package/dist/field/features/toolbars/inline/feature.client.d.ts +3 -0
  200. package/dist/field/features/toolbars/inline/feature.client.d.ts.map +1 -0
  201. package/dist/field/features/toolbars/inline/feature.client.js +20 -0
  202. package/dist/field/features/toolbars/inline/feature.client.js.map +1 -0
  203. package/dist/field/features/toolbars/inline/feature.server.d.ts +3 -0
  204. package/dist/field/features/toolbars/inline/feature.server.d.ts.map +1 -0
  205. package/dist/field/features/toolbars/inline/feature.server.js +16 -0
  206. package/dist/field/features/toolbars/inline/feature.server.js.map +1 -0
  207. package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts +10 -0
  208. package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -0
  209. package/dist/field/{lexical/plugins/toolbars/inline → features/toolbars/shared}/ToolbarButton/index.js +21 -8
  210. package/dist/field/features/toolbars/shared/ToolbarButton/index.js.map +1 -0
  211. package/dist/field/{lexical/plugins/toolbars/inline → features/toolbars/shared}/ToolbarButton/index.scss +3 -1
  212. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts +23 -0
  213. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -0
  214. package/dist/field/{lexical/plugins/toolbars/inline → features/toolbars/shared}/ToolbarDropdown/DropDown.js +25 -67
  215. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -0
  216. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.d.ts +23 -0
  217. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -0
  218. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.js +139 -0
  219. package/dist/field/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -0
  220. package/dist/field/{lexical/plugins/toolbars/inline → features/toolbars/shared}/ToolbarDropdown/index.scss +25 -13
  221. package/dist/field/{lexical/plugins/toolbars/inline → features/toolbars}/types.d.ts +16 -8
  222. package/dist/field/features/toolbars/types.d.ts.map +1 -0
  223. package/dist/field/features/toolbars/types.js.map +1 -0
  224. package/dist/field/features/types.d.ts +27 -19
  225. package/dist/field/features/types.d.ts.map +1 -1
  226. package/dist/field/features/types.js.map +1 -1
  227. package/dist/field/features/upload/component/index.d.ts.map +1 -1
  228. package/dist/field/features/upload/component/index.js +6 -2
  229. package/dist/field/features/upload/component/index.js.map +1 -1
  230. package/dist/field/features/upload/feature.client.d.ts.map +1 -1
  231. package/dist/field/features/upload/feature.client.js +29 -4
  232. package/dist/field/features/upload/feature.client.js.map +1 -1
  233. package/dist/field/features/upload/feature.server.d.ts +10 -3
  234. package/dist/field/features/upload/feature.server.d.ts.map +1 -1
  235. package/dist/field/features/upload/feature.server.js +2 -2
  236. package/dist/field/features/upload/feature.server.js.map +1 -1
  237. package/dist/field/features/upload/nodes/UploadNode.d.ts.map +1 -1
  238. package/dist/field/features/upload/nodes/UploadNode.js +18 -2
  239. package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
  240. package/dist/field/features/upload/plugin/index.d.ts +3 -2
  241. package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
  242. package/dist/field/features/upload/plugin/index.js +2 -2
  243. package/dist/field/features/upload/plugin/index.js.map +1 -1
  244. package/dist/field/features/upload/populationPromise.d.ts.map +1 -1
  245. package/dist/field/features/upload/populationPromise.js +5 -2
  246. package/dist/field/features/upload/populationPromise.js.map +1 -1
  247. package/dist/field/features/upload/validate.d.ts.map +1 -1
  248. package/dist/field/features/upload/validate.js +3 -0
  249. package/dist/field/features/upload/validate.js.map +1 -1
  250. package/dist/field/lexical/EditorFocusProvider.d.ts +20 -0
  251. package/dist/field/lexical/EditorFocusProvider.d.ts.map +1 -0
  252. package/dist/field/lexical/EditorFocusProvider.js +78 -0
  253. package/dist/field/lexical/EditorFocusProvider.js.map +1 -0
  254. package/dist/field/lexical/EditorPlugin.d.ts +1 -0
  255. package/dist/field/lexical/EditorPlugin.d.ts.map +1 -1
  256. package/dist/field/lexical/EditorPlugin.js +6 -3
  257. package/dist/field/lexical/EditorPlugin.js.map +1 -1
  258. package/dist/field/lexical/LexicalEditor.d.ts.map +1 -1
  259. package/dist/field/lexical/LexicalEditor.js +25 -4
  260. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  261. package/dist/field/lexical/LexicalProvider.d.ts.map +1 -1
  262. package/dist/field/lexical/LexicalProvider.js +3 -2
  263. package/dist/field/lexical/LexicalProvider.js.map +1 -1
  264. package/dist/field/lexical/config/client/EditorConfigProvider.d.ts +2 -3
  265. package/dist/field/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  266. package/dist/field/lexical/config/client/EditorConfigProvider.js.map +1 -1
  267. package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
  268. package/dist/field/lexical/config/client/sanitize.js +1 -0
  269. package/dist/field/lexical/config/client/sanitize.js.map +1 -1
  270. package/dist/field/lexical/config/server/default.d.ts.map +1 -1
  271. package/dist/field/lexical/config/server/default.js +5 -3
  272. package/dist/field/lexical/config/server/default.js.map +1 -1
  273. package/dist/field/lexical/config/server/loader.d.ts +2 -1
  274. package/dist/field/lexical/config/server/loader.d.ts.map +1 -1
  275. package/dist/field/lexical/config/server/loader.js +2 -1
  276. package/dist/field/lexical/config/server/loader.js.map +1 -1
  277. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts +6 -6
  278. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts.map +1 -1
  279. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
  280. package/dist/field/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
  281. package/dist/field/lexical/plugins/SlashMenu/index.js +10 -10
  282. package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
  283. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts +1 -1
  284. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts.map +1 -1
  285. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js +2 -2
  286. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js.map +1 -1
  287. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  288. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js +6 -3
  289. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  290. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.scss +8 -0
  291. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
  292. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +25 -6
  293. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
  294. package/dist/field/lexical/ui/icons/Add/index.d.ts +3 -0
  295. package/dist/field/lexical/ui/icons/Add/index.d.ts.map +1 -0
  296. package/dist/field/lexical/ui/icons/Add/index.js +16 -0
  297. package/dist/field/lexical/ui/icons/Add/index.js.map +1 -0
  298. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts +11 -1
  299. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
  300. package/dist/field/lexical/utils/setFloatingElemPosition.js +3 -2
  301. package/dist/field/lexical/utils/setFloatingElemPosition.js.map +1 -1
  302. package/dist/index.d.ts +11 -9
  303. package/dist/index.d.ts.map +1 -1
  304. package/dist/index.js +11 -7
  305. package/dist/index.js.map +1 -1
  306. package/dist/populate/populate.d.ts +2 -1
  307. package/dist/populate/populate.d.ts.map +1 -1
  308. package/dist/populate/populate.js +13 -11
  309. package/dist/populate/populate.js.map +1 -1
  310. package/dist/populate/populateLexicalPopulationPromises.d.ts +1 -1
  311. package/dist/populate/populateLexicalPopulationPromises.d.ts.map +1 -1
  312. package/dist/populate/populateLexicalPopulationPromises.js +2 -1
  313. package/dist/populate/populateLexicalPopulationPromises.js.map +1 -1
  314. package/dist/populate/recurseNestedFields.d.ts +2 -1
  315. package/dist/populate/recurseNestedFields.d.ts.map +1 -1
  316. package/dist/populate/recurseNestedFields.js +2 -1
  317. package/dist/populate/recurseNestedFields.js.map +1 -1
  318. package/dist/types.d.ts +2 -1
  319. package/dist/types.d.ts.map +1 -1
  320. package/dist/types.js.map +1 -1
  321. package/package.json +11 -11
  322. package/dist/field/features/align/inlineToolbarAlignGroup.d.ts +0 -3
  323. package/dist/field/features/align/inlineToolbarAlignGroup.d.ts.map +0 -1
  324. package/dist/field/features/align/inlineToolbarAlignGroup.js.map +0 -1
  325. package/dist/field/features/format/shared/inlineToolbarFormatGroup.d.ts +0 -3
  326. package/dist/field/features/format/shared/inlineToolbarFormatGroup.d.ts.map +0 -1
  327. package/dist/field/features/format/shared/inlineToolbarFormatGroup.js +0 -10
  328. package/dist/field/features/format/shared/inlineToolbarFormatGroup.js.map +0 -1
  329. package/dist/field/features/indent/inlineToolbarIndentGroup.d.ts +0 -3
  330. package/dist/field/features/indent/inlineToolbarIndentGroup.d.ts.map +0 -1
  331. package/dist/field/features/indent/inlineToolbarIndentGroup.js +0 -10
  332. package/dist/field/features/indent/inlineToolbarIndentGroup.js.map +0 -1
  333. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.d.ts +0 -3
  334. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.d.ts.map +0 -1
  335. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.js +0 -10
  336. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.js.map +0 -1
  337. package/dist/field/features/shared/inlineToolbar/textDropdownGroup.d.ts +0 -3
  338. package/dist/field/features/shared/inlineToolbar/textDropdownGroup.d.ts.map +0 -1
  339. package/dist/field/features/shared/inlineToolbar/textDropdownGroup.js.map +0 -1
  340. package/dist/field/lexical/plugins/toolbars/fixed/types.d.ts +0 -40
  341. package/dist/field/lexical/plugins/toolbars/fixed/types.d.ts.map +0 -1
  342. package/dist/field/lexical/plugins/toolbars/fixed/types.js.map +0 -1
  343. package/dist/field/lexical/plugins/toolbars/inline/Toolbar/index.d.ts +0 -6
  344. package/dist/field/lexical/plugins/toolbars/inline/Toolbar/index.d.ts.map +0 -1
  345. package/dist/field/lexical/plugins/toolbars/inline/Toolbar/index.js.map +0 -1
  346. package/dist/field/lexical/plugins/toolbars/inline/ToolbarButton/index.d.ts +0 -8
  347. package/dist/field/lexical/plugins/toolbars/inline/ToolbarButton/index.d.ts.map +0 -1
  348. package/dist/field/lexical/plugins/toolbars/inline/ToolbarButton/index.js.map +0 -1
  349. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/DropDown.d.ts +0 -17
  350. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/DropDown.d.ts.map +0 -1
  351. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/DropDown.js.map +0 -1
  352. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/index.d.ts +0 -18
  353. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/index.d.ts.map +0 -1
  354. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/index.js +0 -42
  355. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/index.js.map +0 -1
  356. package/dist/field/lexical/plugins/toolbars/inline/types.d.ts.map +0 -1
  357. package/dist/field/lexical/plugins/toolbars/inline/types.js +0 -3
  358. package/dist/field/lexical/plugins/toolbars/inline/types.js.map +0 -1
  359. /package/dist/field/{lexical/plugins/toolbars/fixed → features/toolbars}/types.js +0 -0
@@ -0,0 +1,16 @@
1
+ import { InlineToolbarFeatureClientComponent } from './feature.client.js';
2
+ export const InlineToolbarFeature = (props)=>{
3
+ return {
4
+ feature: ()=>{
5
+ return {
6
+ ClientComponent: InlineToolbarFeatureClientComponent,
7
+ clientFeatureProps: null,
8
+ serverFeatureProps: props
9
+ };
10
+ },
11
+ key: 'toolbarInline',
12
+ serverFeatureProps: props
13
+ };
14
+ };
15
+
16
+ //# sourceMappingURL=feature.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/field/features/toolbars/inline/feature.server.ts"],"sourcesContent":["import type { FeatureProviderProviderServer } from '../../types.js'\n\nimport { InlineToolbarFeatureClientComponent } from './feature.client.js'\n\nexport const InlineToolbarFeature: FeatureProviderProviderServer<undefined, undefined> = (\n props,\n) => {\n return {\n feature: () => {\n return {\n ClientComponent: InlineToolbarFeatureClientComponent,\n clientFeatureProps: null,\n serverFeatureProps: props,\n }\n },\n key: 'toolbarInline',\n serverFeatureProps: props,\n }\n}\n"],"names":["InlineToolbarFeatureClientComponent","InlineToolbarFeature","props","feature","ClientComponent","clientFeatureProps","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;","mappings":"AAEA,SAASA,mCAAmC,QAAQ,sBAAqB;AAEzE,OAAO,MAAMC,uBAA4E,CACvFC;IAEA,OAAO;QACLC,SAAS;YACP,OAAO;gBACLC,iBAAiBJ;gBACjBK,oBAAoB;gBACpBC,oBAAoBJ;YACtB;QACF;QACAK,KAAK;QACLD,oBAAoBJ;IACtB;AACF,EAAC"}
@@ -0,0 +1,10 @@
1
+ import type { LexicalEditor } from 'lexical';
2
+ import React from 'react';
3
+ import type { ToolbarGroupItem } from '../../types.js';
4
+ import './index.scss';
5
+ export declare const ToolbarButton: ({ children, editor, item, }: {
6
+ children: React.JSX.Element;
7
+ editor: LexicalEditor;
8
+ item: ToolbarGroupItem;
9
+ }) => React.JSX.Element;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/toolbars/shared/ToolbarButton/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAI5C,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGtD,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,aAAa,gCAIvB;IACD,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B,MAAM,EAAE,aAAa,CAAA;IACrB,IAAI,EAAE,gBAAgB,CAAA;CACvB,sBAqFA,CAAA"}
@@ -1,21 +1,22 @@
1
1
  'use client';
2
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
2
  import { mergeRegister } from '@lexical/utils';
4
3
  import { $getSelection } from 'lexical';
5
4
  import React, { useCallback, useEffect, useState } from 'react';
5
+ import { useEditorFocus } from '../../../../lexical/EditorFocusProvider.js';
6
6
  import './index.scss';
7
- const baseClass = 'inline-toolbar-popup__button';
8
- export const ToolbarButton = ({ children, item })=>{
9
- const [editor] = useLexicalComposerContext();
7
+ const baseClass = 'toolbar-popup__button';
8
+ export const ToolbarButton = ({ children, editor, item })=>{
10
9
  const [enabled, setEnabled] = useState(true);
11
10
  const [active, setActive] = useState(false);
12
11
  const [className, setClassName] = useState(baseClass);
12
+ const editorFocusContext = useEditorFocus();
13
13
  const updateStates = useCallback(()=>{
14
14
  editor.getEditorState().read(()=>{
15
15
  const selection = $getSelection();
16
16
  if (item.isActive) {
17
17
  const isActive = item.isActive({
18
18
  editor,
19
+ editorFocusContext,
19
20
  selection
20
21
  });
21
22
  if (active !== isActive) {
@@ -25,6 +26,7 @@ export const ToolbarButton = ({ children, item })=>{
25
26
  if (item.isEnabled) {
26
27
  const isEnabled = item.isEnabled({
27
28
  editor,
29
+ editorFocusContext,
28
30
  selection
29
31
  });
30
32
  if (enabled !== isEnabled) {
@@ -35,6 +37,7 @@ export const ToolbarButton = ({ children, item })=>{
35
37
  }, [
36
38
  active,
37
39
  editor,
40
+ editorFocusContext,
38
41
  enabled,
39
42
  item
40
43
  ]);
@@ -69,16 +72,26 @@ export const ToolbarButton = ({ children, item })=>{
69
72
  }, [
70
73
  enabled,
71
74
  active,
72
- className
75
+ className,
76
+ item.key
73
77
  ]);
74
78
  return /*#__PURE__*/ React.createElement("button", {
75
79
  className: className,
76
80
  onClick: ()=>{
77
81
  if (enabled !== false) {
78
- item.onSelect({
79
- editor,
80
- isActive: active
82
+ editor._updateTags = new Set([
83
+ ...editor._updateTags,
84
+ 'toolbar'
85
+ ]) // without setting the tags, our onSelect will not be able to trigger our onChange as focus onChanges are ignored.
86
+ ;
87
+ editor.focus(()=>{
88
+ // We need to wrap the onSelect in the callback, so the editor is properly focused before the onSelect is called.
89
+ item.onSelect({
90
+ editor,
91
+ isActive: active
92
+ });
81
93
  });
94
+ return true;
82
95
  }
83
96
  },
84
97
  onMouseDown: (e)=>{
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/field/features/toolbars/shared/ToolbarButton/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { mergeRegister } from '@lexical/utils'\nimport { $getSelection } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { ToolbarGroupItem } from '../../types.js'\n\nimport { useEditorFocus } from '../../../../lexical/EditorFocusProvider.js'\nimport './index.scss'\n\nconst baseClass = 'toolbar-popup__button'\n\nexport const ToolbarButton = ({\n children,\n editor,\n item,\n}: {\n children: React.JSX.Element\n editor: LexicalEditor\n item: ToolbarGroupItem\n}) => {\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n const editorFocusContext = useEditorFocus()\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (item.isActive) {\n const isActive = item.isActive({ editor, editorFocusContext, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (item.isEnabled) {\n const isEnabled = item.isEnabled({ editor, editorFocusContext, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, editorFocusContext, enabled, item])\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 item?.key ? `${baseClass}-` + item.key : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className, item.key])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n editor._updateTags = new Set([...editor._updateTags, 'toolbar']) // without setting the tags, our onSelect will not be able to trigger our onChange as focus onChanges are ignored.\n\n editor.focus(() => {\n // We need to wrap the onSelect in the callback, so the editor is properly focused before the onSelect is called.\n item.onSelect({\n editor,\n isActive: active,\n })\n })\n\n return true\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":["mergeRegister","$getSelection","React","useCallback","useEffect","useState","useEditorFocus","baseClass","ToolbarButton","children","editor","item","enabled","setEnabled","active","setActive","className","setClassName","editorFocusContext","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","button","onClick","_updateTags","Set","focus","onSelect","onMouseDown","e","preventDefault","type"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,aAAa,QAAQ,UAAS;AACvC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI/D,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,OAAO,MAAMC,gBAAgB,CAAC,EAC5BC,QAAQ,EACRC,MAAM,EACNC,IAAI,EAKL;IACC,MAAM,CAACC,SAASC,WAAW,GAAGR,SAAkB;IAChD,MAAM,CAACS,QAAQC,UAAU,GAAGV,SAAkB;IAC9C,MAAM,CAACW,WAAWC,aAAa,GAAGZ,SAAiBE;IACnD,MAAMW,qBAAqBZ;IAE3B,MAAMa,eAAehB,YA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AC;wBACZ5B;wBACAa,UAAUT;oBACZ;gBACF;gBAEA,OAAO;YACT;QACF;QACAyB,aAAa,CAACC;YACZ,8HAA8H;YAC9H,2JAA2J;YAC3J,sKAAsK;YACtKA,EAAEC,cAAc;QAClB;QACAC,MAAK;OAEJjC;AAGP,EAAC"}
@@ -1,4 +1,6 @@
1
- .inline-toolbar-popup__button {
1
+ @import '../../../../../scss/styles';
2
+
3
+ .toolbar-popup__button {
2
4
  display: flex;
3
5
  align-items: center;
4
6
  vertical-align: middle;
@@ -0,0 +1,23 @@
1
+ import type { LexicalEditor } from 'lexical';
2
+ import { type ReactNode } from 'react';
3
+ import React from 'react';
4
+ import type { ToolbarGroupItem } from '../../types.js';
5
+ export declare function DropDownItem({ active, children, editor, enabled, item, title, }: {
6
+ active?: boolean;
7
+ children: React.ReactNode;
8
+ editor: LexicalEditor;
9
+ enabled?: boolean;
10
+ item: ToolbarGroupItem;
11
+ title?: string;
12
+ }): React.ReactNode;
13
+ export declare function DropDown({ Icon, buttonAriaLabel, buttonClassName, children, disabled, itemsContainerClassNames, label, stopCloseOnClickSelf, }: {
14
+ Icon?: React.FC;
15
+ buttonAriaLabel?: string;
16
+ buttonClassName: string;
17
+ children: ReactNode;
18
+ disabled?: boolean;
19
+ itemsContainerClassNames?: string[];
20
+ label?: string;
21
+ stopCloseOnClickSelf?: boolean;
22
+ }): React.ReactNode;
23
+ //# sourceMappingURL=DropDown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/toolbars/shared/ToolbarDropdown/DropDown.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,OAAO,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AACzF,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAUtD,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,QAAQ,EACR,MAAM,EACN,OAAO,EACP,IAAI,EACJ,KAAK,GACN,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,EAAE,aAAa,CAAA;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,gBAAgB,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,KAAK,CAAC,SAAS,CA4DlB;AA8ED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,eAAe,EACf,eAAe,EACf,QAAQ,EACR,QAAgB,EAChB,wBAAwB,EACxB,KAAK,EACL,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,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,GAAG,KAAK,CAAC,SAAS,CAqFlB"}
@@ -1,66 +1,11 @@
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 = 'inline-toolbar-popup__dropdown-item';
5
+ const baseClass = 'toolbar-popup__dropdown-item';
9
6
  const DropDownContext = /*#__PURE__*/ React.createContext(null);
10
- export function DropDownItem({ children, item, 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 (item.isActive) {
19
- const isActive = item.isActive({
20
- editor,
21
- selection
22
- });
23
- if (active !== isActive) {
24
- setActive(isActive);
25
- }
26
- }
27
- if (item.isEnabled) {
28
- const isEnabled = item.isEnabled({
29
- editor,
30
- selection
31
- });
32
- if (enabled !== isEnabled) {
33
- setEnabled(isEnabled);
34
- }
35
- }
36
- });
37
- }, [
38
- active,
39
- editor,
40
- enabled,
41
- item
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,
@@ -92,9 +37,17 @@ export function DropDownItem({ children, item, title }) {
92
37
  className: className,
93
38
  onClick: ()=>{
94
39
  if (enabled !== false) {
95
- item.onSelect({
96
- editor,
97
- isActive: active
40
+ editor._updateTags = new Set([
41
+ ...editor._updateTags,
42
+ 'toolbar'
43
+ ]) // without setting the tags, our onSelect will not be able to trigger our onChange as focus onChanges are ignored.
44
+ ;
45
+ editor.focus(()=>{
46
+ // We need to wrap the onSelect in the callback, so the editor is properly focused before the onSelect is called.
47
+ item.onSelect({
48
+ editor,
49
+ isActive: active
50
+ });
98
51
  });
99
52
  }
100
53
  },
@@ -108,7 +61,7 @@ export function DropDownItem({ children, item, title }) {
108
61
  type: "button"
109
62
  }, children);
110
63
  }
111
- function DropDownItems({ children, dropDownRef, onClose }) {
64
+ function DropDownItems({ children, dropDownRef, itemsContainerClassNames, onClose }) {
112
65
  const [items, setItems] = useState();
113
66
  const [highlightedItem, setHighlightedItem] = useState();
114
67
  const registerItem = useCallback((itemRef)=>{
@@ -156,7 +109,7 @@ function DropDownItems({ children, dropDownRef, onClose }) {
156
109
  if (items != null && highlightedItem == null) {
157
110
  setHighlightedItem(items[0]);
158
111
  }
159
- if (highlightedItem?.current != null) {
112
+ if (highlightedItem != null && highlightedItem?.current != null) {
160
113
  highlightedItem.current.focus();
161
114
  }
162
115
  }, [
@@ -166,12 +119,14 @@ function DropDownItems({ children, dropDownRef, onClose }) {
166
119
  return /*#__PURE__*/ React.createElement(DropDownContext.Provider, {
167
120
  value: contextValue
168
121
  }, /*#__PURE__*/ React.createElement("div", {
169
- className: "inline-toolbar-popup__dropdown-items",
122
+ className: (itemsContainerClassNames ?? [
123
+ 'toolbar-popup__dropdown-items'
124
+ ]).join(' '),
170
125
  onKeyDown: handleKeyDown,
171
126
  ref: dropDownRef
172
127
  }, children));
173
128
  }
174
- export function DropDown({ Icon, buttonAriaLabel, buttonClassName, children, disabled = false, stopCloseOnClickSelf }) {
129
+ export function DropDown({ Icon, buttonAriaLabel, buttonClassName, children, disabled = false, itemsContainerClassNames, label, stopCloseOnClickSelf }) {
175
130
  const dropDownRef = useRef(null);
176
131
  const buttonRef = useRef(null);
177
132
  const [showDropDown, setShowDropDown] = useState(false);
@@ -186,7 +141,7 @@ export function DropDown({ Icon, buttonAriaLabel, buttonClassName, children, dis
186
141
  const dropDown = dropDownRef.current;
187
142
  if (showDropDown && button !== null && dropDown !== null) {
188
143
  const { left, top } = button.getBoundingClientRect();
189
- const scrollTopOffset = window.pageYOffset || document.documentElement.scrollTop;
144
+ const scrollTopOffset = window.scrollY || document.documentElement.scrollTop;
190
145
  dropDown.style.top = `${top + scrollTopOffset + button.offsetHeight + 5}px`;
191
146
  dropDown.style.left = `${Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20)}px`;
192
147
  }
@@ -237,10 +192,13 @@ export function DropDown({ Icon, buttonAriaLabel, buttonClassName, children, dis
237
192
  },
238
193
  ref: buttonRef,
239
194
  type: "button"
240
- }, /*#__PURE__*/ React.createElement(Icon, null), /*#__PURE__*/ React.createElement("i", {
241
- className: "inline-toolbar-popup__dropdown-caret"
195
+ }, Icon && /*#__PURE__*/ React.createElement(Icon, null), label && /*#__PURE__*/ React.createElement("span", {
196
+ className: "toolbar-popup__dropdown-label"
197
+ }, label), /*#__PURE__*/ React.createElement("i", {
198
+ className: "toolbar-popup__dropdown-caret"
242
199
  })), showDropDown && /*#__PURE__*/ createPortal(/*#__PURE__*/ React.createElement(DropDownItems, {
243
200
  dropDownRef: dropDownRef,
201
+ itemsContainerClassNames: itemsContainerClassNames,
244
202
  onClose: handleClose
245
203
  }, children), document.body));
246
204
  }
@@ -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 editor._updateTags = new Set([...editor._updateTags, 'toolbar']) // without setting the tags, our onSelect will not be able to trigger our onChange as focus onChanges are ignored.\n\n editor.focus(() => {\n // We need to wrap the onSelect in the callback, so the editor is properly focused before the onSelect is called.\n item.onSelect({\n editor,\n isActive: active,\n })\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","_updateTags","Set","focus","onSelect","isActive","onMouseDown","e","preventDefault","type","DropDownItems","dropDownRef","itemsContainerClassNames","onClose","items","setItems","highlightedItem","setHighlightedItem","itemRef","prev","handleKeyDown","event","includes","index","indexOf","length","contextValue","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;IAClB;IAEA,MAAM,EAAEC,YAAY,EAAE,GAAGH;IAEzBvB,UAAU;QACR,IAAIsB,KAAKK,WAAW,MA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YACtKA,EAAEC,cAAc;QAClB;QACAf,KAAK6C;QACL7B,MAAK;OAEJuB,sBAAQ,oBAACA,aACTI,uBAAS,oBAAC6B;QAAK9E,WAAU;OAAiCiD,sBAC3D,oBAAC8B;QAAE/E,WAAU;SAGdoD,8BACC/D,2BACE,oBAACkC;QACCC,aAAaA;QACbC,0BAA0BA;QAC1BC,SAAS4B;OAER3D,WAEHmE,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,aA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J,GAAG;QAAC3B;QAAQ2B;KAAa;IAEzB,qBACE,oBAAChC;QACCmB,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';
1
+ @import '../../../../../scss/styles';
2
2
 
3
- .inline-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
- .inline-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
- .inline-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
- .inline-toolbar-popup__dropdown {
106
+ .toolbar-popup__dropdown {
95
107
  &-items {
96
108
  position: absolute;
97
109
  @include shadow-m;