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

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 (256) hide show
  1. package/dist/exports/components.d.ts +2 -2
  2. package/dist/exports/components.d.ts.map +1 -1
  3. package/dist/exports/components.js +2 -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 +15 -21
  7. package/dist/field/features/align/feature.client.js.map +1 -1
  8. package/dist/field/features/align/inlineToolbarAlignGroup.d.ts +3 -0
  9. package/dist/field/features/align/inlineToolbarAlignGroup.d.ts.map +1 -0
  10. package/dist/field/features/align/{floatingSelectToolbarAlignDropdownSection.js → inlineToolbarAlignGroup.js} +4 -4
  11. package/dist/field/features/align/inlineToolbarAlignGroup.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 +33 -31
  14. package/dist/field/features/blockquote/feature.client.js.map +1 -1
  15. package/dist/field/features/blocks/feature.client.d.ts.map +1 -1
  16. package/dist/field/features/blocks/feature.client.js +25 -27
  17. package/dist/field/features/blocks/feature.client.js.map +1 -1
  18. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.d.ts.map +1 -1
  19. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.js.map +1 -1
  20. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.d.ts.map +1 -1
  21. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.js +1 -1
  22. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.js.map +1 -1
  23. package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.d.ts.map +1 -1
  24. package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.js.map +1 -1
  25. package/dist/field/features/debug/{treeview → treeView}/feature.client.d.ts.map +1 -1
  26. package/dist/field/features/debug/{treeview → treeView}/feature.client.js.map +1 -1
  27. package/dist/field/features/debug/{treeview → treeView}/feature.server.d.ts.map +1 -1
  28. package/dist/field/features/debug/{treeview → treeView}/feature.server.js +1 -1
  29. package/dist/field/features/debug/{treeview → treeView}/feature.server.js.map +1 -1
  30. package/dist/field/features/debug/{treeview → treeView}/plugin/index.d.ts.map +1 -1
  31. package/dist/field/features/debug/{treeview → treeView}/plugin/index.js.map +1 -1
  32. package/dist/field/features/format/bold/feature.client.js +7 -7
  33. package/dist/field/features/format/bold/feature.client.js.map +1 -1
  34. package/dist/field/features/format/{inlinecode → inlineCode}/feature.client.d.ts.map +1 -1
  35. package/dist/field/features/format/{inlinecode → inlineCode}/feature.client.js +10 -10
  36. package/dist/field/features/format/inlineCode/feature.client.js.map +1 -0
  37. package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.d.ts.map +1 -1
  38. package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.js +1 -1
  39. package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.js.map +1 -1
  40. package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.d.ts.map +1 -1
  41. package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.js.map +1 -1
  42. package/dist/field/features/format/italic/feature.client.js +10 -10
  43. package/dist/field/features/format/italic/feature.client.js.map +1 -1
  44. package/dist/field/features/format/shared/inlineToolbarFormatGroup.d.ts +3 -0
  45. package/dist/field/features/format/shared/inlineToolbarFormatGroup.d.ts.map +1 -0
  46. package/dist/field/features/format/shared/inlineToolbarFormatGroup.js +10 -0
  47. package/dist/field/features/format/shared/inlineToolbarFormatGroup.js.map +1 -0
  48. package/dist/field/features/format/strikethrough/feature.client.js +9 -9
  49. package/dist/field/features/format/strikethrough/feature.client.js.map +1 -1
  50. package/dist/field/features/format/subscript/feature.client.js +5 -5
  51. package/dist/field/features/format/subscript/feature.client.js.map +1 -1
  52. package/dist/field/features/format/superscript/feature.client.js +5 -5
  53. package/dist/field/features/format/superscript/feature.client.js.map +1 -1
  54. package/dist/field/features/format/underline/feature.client.js +5 -5
  55. package/dist/field/features/format/underline/feature.client.js.map +1 -1
  56. package/dist/field/features/heading/feature.client.d.ts.map +1 -1
  57. package/dist/field/features/heading/feature.client.js +39 -39
  58. package/dist/field/features/heading/feature.client.js.map +1 -1
  59. package/dist/field/features/{horizontalrule → horizontalRule}/component/index.d.ts.map +1 -1
  60. package/dist/field/features/{horizontalrule → horizontalRule}/component/index.js.map +1 -1
  61. package/dist/field/features/{horizontalrule → horizontalRule}/feature.client.d.ts.map +1 -1
  62. package/dist/field/features/{horizontalrule → horizontalRule}/feature.client.js +7 -7
  63. package/dist/field/features/horizontalRule/feature.client.js.map +1 -0
  64. package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.d.ts.map +1 -1
  65. package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.js +1 -1
  66. package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.js.map +1 -1
  67. package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.d.ts.map +1 -1
  68. package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.js.map +1 -1
  69. package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.d.ts.map +1 -1
  70. package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.js.map +1 -1
  71. package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.d.ts.map +1 -1
  72. package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.js.map +1 -1
  73. package/dist/field/features/indent/feature.client.d.ts.map +1 -1
  74. package/dist/field/features/indent/feature.client.js +9 -11
  75. package/dist/field/features/indent/feature.client.js.map +1 -1
  76. package/dist/field/features/indent/inlineToolbarIndentGroup.d.ts +3 -0
  77. package/dist/field/features/indent/inlineToolbarIndentGroup.d.ts.map +1 -0
  78. package/dist/field/features/indent/inlineToolbarIndentGroup.js +10 -0
  79. package/dist/field/features/indent/inlineToolbarIndentGroup.js.map +1 -0
  80. package/dist/field/features/link/feature.client.js +28 -28
  81. package/dist/field/features/link/feature.client.js.map +1 -1
  82. package/dist/field/features/lists/checklist/feature.client.d.ts +1 -1
  83. package/dist/field/features/lists/checklist/feature.client.js +28 -28
  84. package/dist/field/features/lists/checklist/feature.client.js.map +1 -1
  85. package/dist/field/features/lists/checklist/feature.server.d.ts +1 -1
  86. package/dist/field/features/lists/checklist/feature.server.js +4 -4
  87. package/dist/field/features/lists/checklist/feature.server.js.map +1 -1
  88. package/dist/field/features/lists/checklist/markdownTransformers.js +1 -1
  89. package/dist/field/features/lists/checklist/markdownTransformers.js.map +1 -1
  90. package/dist/field/features/lists/{orderedlist → orderedList}/feature.client.d.ts.map +1 -1
  91. package/dist/field/features/lists/{orderedlist → orderedList}/feature.client.js +26 -26
  92. package/dist/field/features/lists/orderedList/feature.client.js.map +1 -0
  93. package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.d.ts.map +1 -1
  94. package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.js +1 -1
  95. package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.js.map +1 -1
  96. package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.d.ts.map +1 -1
  97. package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.js +1 -1
  98. package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.js.map +1 -1
  99. package/dist/field/features/lists/{common → shared}/markdown.d.ts.map +1 -1
  100. package/dist/field/features/lists/{common → shared}/markdown.js.map +1 -1
  101. package/dist/field/features/lists/unorderedList/feature.client.d.ts.map +1 -0
  102. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.client.js +24 -24
  103. package/dist/field/features/lists/unorderedList/feature.client.js.map +1 -0
  104. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.d.ts.map +1 -1
  105. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.js +1 -1
  106. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.js.map +1 -1
  107. package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.d.ts.map +1 -1
  108. package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.js +1 -1
  109. package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.js.map +1 -1
  110. package/dist/field/features/paragraph/feature.client.js +27 -27
  111. package/dist/field/features/paragraph/feature.client.js.map +1 -1
  112. package/dist/field/features/relationship/feature.client.js +7 -7
  113. package/dist/field/features/relationship/feature.client.js.map +1 -1
  114. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.d.ts +3 -0
  115. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.d.ts.map +1 -0
  116. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.js +10 -0
  117. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.js.map +1 -0
  118. package/dist/field/features/shared/inlineToolbar/textDropdownGroup.d.ts +3 -0
  119. package/dist/field/features/shared/inlineToolbar/textDropdownGroup.d.ts.map +1 -0
  120. package/dist/field/features/{common/floatingSelectToolbarTextDropdownSection/index.js → shared/inlineToolbar/textDropdownGroup.js} +4 -4
  121. package/dist/field/features/shared/inlineToolbar/textDropdownGroup.js.map +1 -0
  122. package/dist/field/features/types.d.ts +51 -12
  123. package/dist/field/features/types.d.ts.map +1 -1
  124. package/dist/field/features/types.js.map +1 -1
  125. package/dist/field/features/upload/feature.client.d.ts.map +1 -1
  126. package/dist/field/features/upload/feature.client.js +7 -7
  127. package/dist/field/features/upload/feature.client.js.map +1 -1
  128. package/dist/field/lexical/LexicalEditor.js +1 -1
  129. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  130. package/dist/field/lexical/LexicalEditor.scss +3 -19
  131. package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
  132. package/dist/field/lexical/config/client/sanitize.js +80 -32
  133. package/dist/field/lexical/config/client/sanitize.js.map +1 -1
  134. package/dist/field/lexical/config/server/default.d.ts.map +1 -1
  135. package/dist/field/lexical/config/server/default.js +6 -6
  136. package/dist/field/lexical/config/server/default.js.map +1 -1
  137. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +9 -9
  138. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  139. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +71 -71
  140. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  141. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +4 -4
  142. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  143. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +3 -3
  144. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  145. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts +12 -20
  146. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts.map +1 -1
  147. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js +1 -37
  148. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
  149. package/dist/field/lexical/plugins/SlashMenu/index.d.ts +2 -2
  150. package/dist/field/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
  151. package/dist/field/lexical/plugins/SlashMenu/index.js +67 -61
  152. package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
  153. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/fixed}/types.d.ts +6 -6
  154. package/dist/field/lexical/plugins/toolbars/fixed/types.d.ts.map +1 -0
  155. package/dist/field/lexical/plugins/toolbars/fixed/types.js.map +1 -0
  156. package/dist/field/lexical/plugins/toolbars/inline/Toolbar/index.d.ts.map +1 -0
  157. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline/Toolbar}/index.js +32 -32
  158. package/dist/field/lexical/plugins/toolbars/inline/Toolbar/index.js.map +1 -0
  159. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline/Toolbar}/index.scss +5 -4
  160. package/dist/field/lexical/plugins/toolbars/inline/ToolbarButton/index.d.ts +8 -0
  161. package/dist/field/lexical/plugins/toolbars/inline/ToolbarButton/index.d.ts.map +1 -0
  162. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarButton/index.js +9 -9
  163. package/dist/field/lexical/plugins/toolbars/inline/ToolbarButton/index.js.map +1 -0
  164. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarButton/index.scss +1 -1
  165. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarDropdown/DropDown.d.ts +3 -3
  166. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/DropDown.d.ts.map +1 -0
  167. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarDropdown/DropDown.js +12 -12
  168. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/DropDown.js.map +1 -0
  169. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarDropdown/index.d.ts +6 -6
  170. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/index.d.ts.map +1 -0
  171. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/index.js +42 -0
  172. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/index.js.map +1 -0
  173. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarDropdown/index.scss +6 -6
  174. package/dist/field/lexical/plugins/toolbars/inline/types.d.ts +40 -0
  175. package/dist/field/lexical/plugins/toolbars/inline/types.d.ts.map +1 -0
  176. package/dist/field/lexical/plugins/toolbars/inline/types.js +3 -0
  177. package/dist/field/lexical/plugins/toolbars/inline/types.js.map +1 -0
  178. package/dist/field/lexical/theme/EditorTheme.scss +2 -6
  179. package/dist/index.d.ts +12 -11
  180. package/dist/index.d.ts.map +1 -1
  181. package/dist/index.js +11 -11
  182. package/dist/index.js.map +1 -1
  183. package/package.json +10 -10
  184. package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.d.ts +0 -3
  185. package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.d.ts.map +0 -1
  186. package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.js.map +0 -1
  187. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.d.ts +0 -3
  188. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.d.ts.map +0 -1
  189. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.js +0 -10
  190. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.js.map +0 -1
  191. package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.d.ts +0 -3
  192. package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.d.ts.map +0 -1
  193. package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.js.map +0 -1
  194. package/dist/field/features/format/common/floatingSelectToolbarSection.d.ts +0 -3
  195. package/dist/field/features/format/common/floatingSelectToolbarSection.d.ts.map +0 -1
  196. package/dist/field/features/format/common/floatingSelectToolbarSection.js +0 -10
  197. package/dist/field/features/format/common/floatingSelectToolbarSection.js.map +0 -1
  198. package/dist/field/features/format/inlinecode/feature.client.js.map +0 -1
  199. package/dist/field/features/horizontalrule/feature.client.js.map +0 -1
  200. package/dist/field/features/indent/floatingSelectToolbarIndentSection.d.ts +0 -3
  201. package/dist/field/features/indent/floatingSelectToolbarIndentSection.d.ts.map +0 -1
  202. package/dist/field/features/indent/floatingSelectToolbarIndentSection.js +0 -10
  203. package/dist/field/features/indent/floatingSelectToolbarIndentSection.js.map +0 -1
  204. package/dist/field/features/indent/index.scss +0 -4
  205. package/dist/field/features/lists/orderedlist/feature.client.js.map +0 -1
  206. package/dist/field/features/lists/unorderedlist/feature.client.d.ts.map +0 -1
  207. package/dist/field/features/lists/unorderedlist/feature.client.js.map +0 -1
  208. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts +0 -8
  209. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts.map +0 -1
  210. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js.map +0 -1
  211. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.d.ts.map +0 -1
  212. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js.map +0 -1
  213. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.d.ts.map +0 -1
  214. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.js +0 -42
  215. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.js.map +0 -1
  216. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +0 -1
  217. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +0 -1
  218. package/dist/field/lexical/plugins/FloatingSelectToolbar/types.d.ts.map +0 -1
  219. package/dist/field/lexical/plugins/FloatingSelectToolbar/types.js.map +0 -1
  220. /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.d.ts +0 -0
  221. /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.js +0 -0
  222. /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.d.ts +0 -0
  223. /package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.d.ts +0 -0
  224. /package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.js +0 -0
  225. /package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.scss +0 -0
  226. /package/dist/field/features/debug/{treeview → treeView}/feature.client.d.ts +0 -0
  227. /package/dist/field/features/debug/{treeview → treeView}/feature.client.js +0 -0
  228. /package/dist/field/features/debug/{treeview → treeView}/feature.server.d.ts +0 -0
  229. /package/dist/field/features/debug/{treeview → treeView}/plugin/index.d.ts +0 -0
  230. /package/dist/field/features/debug/{treeview → treeView}/plugin/index.js +0 -0
  231. /package/dist/field/features/debug/{treeview → treeView}/plugin/index.scss +0 -0
  232. /package/dist/field/features/format/{inlinecode → inlineCode}/feature.client.d.ts +0 -0
  233. /package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.d.ts +0 -0
  234. /package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.d.ts +0 -0
  235. /package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.js +0 -0
  236. /package/dist/field/features/{horizontalrule → horizontalRule}/component/index.d.ts +0 -0
  237. /package/dist/field/features/{horizontalrule → horizontalRule}/component/index.js +0 -0
  238. /package/dist/field/features/{horizontalrule → horizontalRule}/feature.client.d.ts +0 -0
  239. /package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.d.ts +0 -0
  240. /package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.d.ts +0 -0
  241. /package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.js +0 -0
  242. /package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.d.ts +0 -0
  243. /package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.js +0 -0
  244. /package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.d.ts +0 -0
  245. /package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.js +0 -0
  246. /package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.scss +0 -0
  247. /package/dist/field/features/lists/{orderedlist → orderedList}/feature.client.d.ts +0 -0
  248. /package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.d.ts +0 -0
  249. /package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.d.ts +0 -0
  250. /package/dist/field/features/lists/{common → shared}/markdown.d.ts +0 -0
  251. /package/dist/field/features/lists/{common → shared}/markdown.js +0 -0
  252. /package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.client.d.ts +0 -0
  253. /package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.d.ts +0 -0
  254. /package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.d.ts +0 -0
  255. /package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/fixed}/types.js +0 -0
  256. /package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline/Toolbar}/index.d.ts +0 -0
@@ -1,39 +1,3 @@
1
- export class SlashMenuOption {
2
- // Icon for display
3
- Icon;
4
- displayName;
5
- // Used for class names and, if displayName is not provided, for display.
6
- key;
7
- // TBD
8
- keyboardShortcut;
9
- // For extra searching.
10
- keywords;
11
- // What happens when you select this option?
12
- onSelect;
13
- ref;
14
- constructor(key, options){
15
- this.key = key;
16
- this.ref = {
17
- current: null
18
- };
19
- this.setRefElement = this.setRefElement.bind(this);
20
- this.displayName = options.displayName;
21
- this.keywords = options.keywords || [];
22
- this.Icon = options.Icon;
23
- this.keyboardShortcut = options.keyboardShortcut;
24
- this.onSelect = options.onSelect.bind(this);
25
- }
26
- setRefElement(element) {
27
- this.ref = {
28
- current: element
29
- };
30
- }
31
- }
32
- export class SlashMenuGroup {
33
- // Used for class names and, if displayName is not provided, for display.
34
- displayName;
35
- key;
36
- options;
37
- }
1
+ export { };
38
2
 
39
3
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { LexicalEditor } from 'lexical'\nimport type { MutableRefObject } from 'react'\nimport type React from 'react'\n\nexport class SlashMenuOption {\n // Icon for display\n Icon: React.FC\n\n displayName?: (({ i18n }: { i18n: I18n }) => string) | string\n // Used for class names and, if displayName is not provided, for display.\n key: string\n // TBD\n keyboardShortcut?: string\n // For extra searching.\n keywords: Array<string>\n // What happens when you select this option?\n onSelect: ({ editor, queryString }: { editor: LexicalEditor; queryString: string }) => void\n\n ref?: MutableRefObject<HTMLElement | null>\n\n constructor(\n key: string,\n options: {\n Icon: React.FC\n displayName?: (({ i18n }: { i18n: I18n }) => string) | string\n keyboardShortcut?: string\n keywords?: Array<string>\n onSelect: ({ editor, queryString }: { editor: LexicalEditor; queryString: string }) => void\n },\n ) {\n this.key = key\n this.ref = { current: null }\n this.setRefElement = this.setRefElement.bind(this)\n\n this.displayName = options.displayName\n this.keywords = options.keywords || []\n this.Icon = options.Icon\n this.keyboardShortcut = options.keyboardShortcut\n this.onSelect = options.onSelect.bind(this)\n }\n\n setRefElement(element: HTMLElement | null) {\n this.ref = { current: element }\n }\n}\n\nexport class SlashMenuGroup {\n // Used for class names and, if displayName is not provided, for display.\n displayName?: (({ i18n }: { i18n: I18n }) => string) | string\n key: string\n options: Array<SlashMenuOption>\n}\n"],"names":["SlashMenuOption","Icon","displayName","key","keyboardShortcut","keywords","onSelect","ref","constructor","options","current","setRefElement","bind","element","SlashMenuGroup"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,OAAO,MAAMA;IACX,mBAAmB;IACnBC,KAAc;IAEdC,YAA6D;IAC7D,yEAAyE;IACzEC,IAAW;IACX,MAAM;IACNC,iBAAyB;IACzB,uBAAuB;IACvBC,SAAuB;IACvB,4CAA4C;IAC5CC,SAA2F;IAE3FC,IAA0C;IAE1CC,YACEL,GAAW,EACXM,OAMC,CACD;QACA,IAAI,CAACN,GAAG,GAAGA;QACX,IAAI,CAACI,GAAG,GAAG;YAAEG,SAAS;QAAK;QAC3B,IAAI,CAACC,aAAa,GAAG,IAAI,CAACA,aAAa,CAACC,IAAI,CAAC,IAAI;QAEjD,IAAI,CAACV,WAAW,GAAGO,QAAQP,WAAW;QACtC,IAAI,CAACG,QAAQ,GAAGI,QAAQJ,QAAQ,IAAI,EAAE;QACtC,IAAI,CAACJ,IAAI,GAAGQ,QAAQR,IAAI;QACxB,IAAI,CAACG,gBAAgB,GAAGK,QAAQL,gBAAgB;QAChD,IAAI,CAACE,QAAQ,GAAGG,QAAQH,QAAQ,CAACM,IAAI,CAAC,IAAI;IAC5C;IAEAD,cAAcE,OAA2B,EAAE;QACzC,IAAI,CAACN,GAAG,GAAG;YAAEG,SAASG;QAAQ;IAChC;AACF;AAEA,OAAO,MAAMC;IACX,yEAAyE;IACzEZ,YAA6D;IAC7DC,IAAW;IACXM,QAA+B;AACjC"}
1
+ {"version":3,"sources":["../../../../../../src/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { LexicalEditor } from 'lexical'\nimport type { MutableRefObject } from 'react'\nimport type React from 'react'\n\nexport type SlashMenuItem = {\n // Icon for display\n Icon: React.FC\n\n displayName?: (({ i18n }: { i18n: I18n }) => string) | string\n // Used for class names and, if displayName is not provided, for display.\n key: string\n // TBD\n keyboardShortcut?: string\n // For extra searching.\n keywords?: Array<string>\n // What happens when you select this item?\n onSelect: ({ editor, queryString }: { editor: LexicalEditor; queryString: string }) => void\n}\n\nexport type SlashMenuGroup = {\n // Used for class names and, if displayName is not provided, for display.\n displayName?: (({ i18n }: { i18n: I18n }) => string) | string\n items: Array<SlashMenuItem>\n key: string\n}\n\nexport type SlashMenuItemInternal = SlashMenuItem & {\n ref: MutableRefObject<HTMLButtonElement | null>\n}\n\nexport type SlashMenuGroupInternal = SlashMenuGroup & {\n items: Array<SlashMenuItemInternal>\n}\n"],"names":[],"rangeMappings":"","mappings":"AA+BA,WAEC"}
@@ -1,6 +1,6 @@
1
- /// <reference types="react" resolution-mode="require"/>
1
+ import * as React from 'react';
2
2
  import './index.scss';
3
3
  export declare function SlashMenuPlugin({ anchorElem, }: {
4
4
  anchorElem?: HTMLElement;
5
- }): JSX.Element;
5
+ }): React.ReactElement;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/plugins/SlashMenu/index.tsx"],"names":[],"mappings":";AAaA,OAAO,cAAc,CAAA;AAsDrB,wBAAgB,eAAe,CAAC,EAC9B,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,GAAG,CAAC,OAAO,CA8Jd"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/plugins/SlashMenu/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,OAAO,cAAc,CAAA;AAqDrB,wBAAgB,eAAe,CAAC,EAC9B,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,YAAY,CAiKrB"}
@@ -9,17 +9,17 @@ import { LexicalTypeaheadMenuPlugin } from './LexicalTypeaheadMenuPlugin/index.j
9
9
  import './index.scss';
10
10
  import { useMenuTriggerMatch } from './useMenuTriggerMatch.js';
11
11
  const baseClass = 'slash-menu-popup';
12
- function SlashMenuItem({ isSelected, onClick, onMouseEnter, option }) {
12
+ function SlashMenuItem({ isSelected, item, onClick, onMouseEnter }) {
13
13
  const { i18n } = useTranslation();
14
- let className = `${baseClass}__item ${baseClass}__item-${option.key}`;
14
+ let className = `${baseClass}__item ${baseClass}__item-${item.key}`;
15
15
  if (isSelected) {
16
16
  className += ` ${baseClass}__item--selected`;
17
17
  }
18
- let title = option.key;
19
- if (option.displayName) {
20
- title = typeof option.displayName === 'function' ? option.displayName({
18
+ let title = item.key;
19
+ if (item.displayName) {
20
+ title = typeof item.displayName === 'function' ? item.displayName({
21
21
  i18n
22
- }) : option.displayName;
22
+ }) : item.displayName;
23
23
  }
24
24
  // Crop title to max. 50 characters
25
25
  if (title.length > 25) {
@@ -28,15 +28,15 @@ function SlashMenuItem({ isSelected, onClick, onMouseEnter, option }) {
28
28
  return /*#__PURE__*/ React.createElement("button", {
29
29
  "aria-selected": isSelected,
30
30
  className: className,
31
- id: baseClass + '__item-' + option.key,
32
- key: option.key,
31
+ id: baseClass + '__item-' + item.key,
32
+ key: item.key,
33
33
  onClick: onClick,
34
34
  onMouseEnter: onMouseEnter,
35
- ref: option.setRefElement,
36
- role: "option",
35
+ ref: item.ref,
36
+ role: "item",
37
37
  tabIndex: -1,
38
38
  type: "button"
39
- }, option?.Icon && /*#__PURE__*/ React.createElement(option.Icon, null), /*#__PURE__*/ React.createElement("span", {
39
+ }, item?.Icon && /*#__PURE__*/ React.createElement(item.Icon, null), /*#__PURE__*/ React.createElement("span", {
40
40
  className: `${baseClass}__item-text`
41
41
  }, title));
42
42
  }
@@ -48,93 +48,99 @@ export function SlashMenuPlugin({ anchorElem = document.body }) {
48
48
  const checkForTriggerMatch = useMenuTriggerMatch('/', {
49
49
  minLength: 0
50
50
  });
51
- const getDynamicOptions = useCallback(()=>{
52
- let groupWithOptions = [];
53
- for (const dynamicOption of editorConfig.features.slashMenu.dynamicOptions){
54
- const dynamicGroupWithOptions = dynamicOption({
51
+ const getDynamicItems = useCallback(()=>{
52
+ let groupWithItems = [];
53
+ for (const dynamicItem of editorConfig.features.slashMenu.dynamicGroups){
54
+ const dynamicGroupWithItems = dynamicItem({
55
55
  editor,
56
56
  queryString
57
57
  });
58
- groupWithOptions = groupWithOptions.concat(dynamicGroupWithOptions);
58
+ groupWithItems = groupWithItems.concat(dynamicGroupWithItems);
59
59
  }
60
- return groupWithOptions;
60
+ return groupWithItems;
61
61
  }, [
62
62
  editor,
63
63
  queryString,
64
64
  editorConfig?.features
65
65
  ]);
66
66
  const groups = useMemo(()=>{
67
- let groupsWithOptions = [];
68
- for (const groupWithOption of editorConfig?.features.slashMenu.groupsWithOptions ?? []){
69
- groupsWithOptions.push(groupWithOption);
67
+ let groupsWithItems = [];
68
+ for (const groupWithItem of editorConfig?.features.slashMenu.groups ?? []){
69
+ groupsWithItems.push(groupWithItem);
70
70
  }
71
71
  if (queryString) {
72
72
  // Filter current groups first
73
- groupsWithOptions = groupsWithOptions.map((group)=>{
74
- const filteredOptions = group.options.filter((option)=>{
75
- let optionTitle = option.key;
76
- if (option.displayName) {
77
- optionTitle = typeof option.displayName === 'function' ? option.displayName({
73
+ groupsWithItems = groupsWithItems.map((group)=>{
74
+ const filteredItems = group.items.filter((item)=>{
75
+ let itemTitle = item.key;
76
+ if (item.displayName) {
77
+ itemTitle = typeof item.displayName === 'function' ? item.displayName({
78
78
  i18n
79
- }) : option.displayName;
79
+ }) : item.displayName;
80
80
  }
81
- return new RegExp(queryString, 'gi').exec(optionTitle) || option.keywords != null ? option.keywords.some((keyword)=>new RegExp(queryString, 'gi').exec(keyword)) : false;
81
+ if (new RegExp(queryString, 'gi').exec(itemTitle)) {
82
+ return true;
83
+ }
84
+ if (item.keywords != null) {
85
+ return item.keywords.some((keyword)=>new RegExp(queryString, 'gi').exec(keyword));
86
+ }
87
+ return false;
82
88
  });
83
- if (filteredOptions.length) {
89
+ if (filteredItems.length) {
84
90
  return {
85
91
  ...group,
86
- options: filteredOptions
92
+ items: filteredItems
87
93
  };
88
94
  }
89
95
  return null;
90
96
  });
91
- groupsWithOptions = groupsWithOptions.filter((group)=>group != null);
97
+ groupsWithItems = groupsWithItems.filter((group)=>group != null);
92
98
  // Now add dynamic groups
93
- const dynamicOptionGroups = getDynamicOptions();
94
- // merge dynamic options into groups
95
- for (const dynamicGroup of dynamicOptionGroups){
99
+ const dynamicItemGroups = getDynamicItems();
100
+ // merge dynamic items into groups
101
+ for (const dynamicGroup of dynamicItemGroups){
96
102
  // 1. find the group with the same name or create new one
97
- let group = groupsWithOptions.find((group)=>group.key === dynamicGroup.key);
103
+ let group = groupsWithItems.find((group)=>group.key === dynamicGroup.key);
98
104
  if (!group) {
99
105
  group = {
100
106
  ...dynamicGroup,
101
- options: []
107
+ items: []
102
108
  };
103
109
  } else {
104
- groupsWithOptions = groupsWithOptions.filter((group)=>group.key !== dynamicGroup.key);
110
+ groupsWithItems = groupsWithItems.filter((group)=>group.key !== dynamicGroup.key);
105
111
  }
106
- // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions
107
- if (group?.options?.length) {
108
- group.options = group.options.concat(group.options);
112
+ // 2. Add items to group items array and add to sanitized.slashMenu.groupsWithItems
113
+ if (group?.items?.length) {
114
+ group.items = group.items.concat(group.items);
109
115
  }
110
- groupsWithOptions.push(group);
116
+ groupsWithItems.push(group);
111
117
  }
112
118
  }
113
- return groupsWithOptions;
119
+ return groupsWithItems;
114
120
  }, [
115
- getDynamicOptions,
121
+ getDynamicItems,
116
122
  queryString,
117
123
  editorConfig?.features,
118
124
  i18n
119
125
  ]);
120
- const onSelectOption = useCallback((selectedOption, nodeToRemove, closeMenu, matchingString)=>{
121
- editor.update(()=>{
122
- if (nodeToRemove) {
126
+ const onSelectItem = useCallback((selectedItem, nodeToRemove, closeMenu, matchingString)=>{
127
+ if (nodeToRemove) {
128
+ editor.update(()=>{
123
129
  nodeToRemove.remove();
124
- }
125
- selectedOption.onSelect({
126
- editor,
127
- queryString: matchingString
128
130
  });
129
- closeMenu();
131
+ }
132
+ selectedItem.onSelect({
133
+ editor,
134
+ queryString: matchingString
130
135
  });
136
+ closeMenu();
131
137
  }, [
132
138
  editor
133
139
  ]);
134
140
  return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(LexicalTypeaheadMenuPlugin, {
135
141
  anchorElem: anchorElem,
136
- groupsWithOptions: groups,
137
- menuRenderFn: (anchorElementRef, { selectOptionAndCleanUp, selectedOptionKey, setSelectedOptionKey })=>anchorElementRef.current && groups.length ? /*#__PURE__*/ ReactDOM.createPortal(/*#__PURE__*/ React.createElement("div", {
142
+ groups: groups,
143
+ menuRenderFn: (anchorElementRef, { selectItemAndCleanUp, selectedItemKey, setSelectedItemKey })=>anchorElementRef.current && groups.length ? /*#__PURE__*/ ReactDOM.createPortal(/*#__PURE__*/ React.createElement("div", {
138
144
  className: baseClass
139
145
  }, groups.map((group)=>{
140
146
  let groupTitle = group.key;
@@ -148,22 +154,22 @@ export function SlashMenuPlugin({ anchorElem = document.body }) {
148
154
  key: group.key
149
155
  }, /*#__PURE__*/ React.createElement("div", {
150
156
  className: `${baseClass}__group-title`
151
- }, groupTitle), group.options.map((option, oi)=>/*#__PURE__*/ React.createElement(SlashMenuItem, {
157
+ }, groupTitle), group.items.map((item, oi)=>/*#__PURE__*/ React.createElement(SlashMenuItem, {
152
158
  index: oi,
153
- isSelected: selectedOptionKey === option.key,
154
- key: option.key,
159
+ isSelected: selectedItemKey === item.key,
160
+ item: item,
161
+ key: item.key,
155
162
  onClick: ()=>{
156
- setSelectedOptionKey(option.key);
157
- selectOptionAndCleanUp(option);
163
+ setSelectedItemKey(item.key);
164
+ selectItemAndCleanUp(item);
158
165
  },
159
166
  onMouseEnter: ()=>{
160
- setSelectedOptionKey(option.key);
161
- },
162
- option: option
167
+ setSelectedItemKey(item.key);
168
+ }
163
169
  })));
164
170
  })), anchorElementRef.current) : null,
165
171
  onQueryChange: setQueryString,
166
- onSelectOption: onSelectOption,
172
+ onSelectItem: onSelectItem,
167
173
  triggerFn: checkForTriggerMatch
168
174
  }));
169
175
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/plugins/SlashMenu/index.tsx"],"sourcesContent":["'use client'\nimport type { TextNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport { useCallback, useMemo, useState } from 'react'\nimport * as React from 'react'\nimport * as ReactDOM from 'react-dom'\n\nimport type { SlashMenuGroup, SlashMenuOption } from './LexicalTypeaheadMenuPlugin/types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { LexicalTypeaheadMenuPlugin } from './LexicalTypeaheadMenuPlugin/index.js'\nimport './index.scss'\nimport { useMenuTriggerMatch } from './useMenuTriggerMatch.js'\n\nconst baseClass = 'slash-menu-popup'\n\nfunction SlashMenuItem({\n isSelected,\n onClick,\n onMouseEnter,\n option,\n}: {\n index: number\n isSelected: boolean\n onClick: () => void\n onMouseEnter: () => void\n option: SlashMenuOption\n}) {\n const { i18n } = useTranslation()\n\n let className = `${baseClass}__item ${baseClass}__item-${option.key}`\n if (isSelected) {\n className += ` ${baseClass}__item--selected`\n }\n\n let title = option.key\n if (option.displayName) {\n title =\n typeof option.displayName === 'function' ? option.displayName({ i18n }) : option.displayName\n }\n // Crop title to max. 50 characters\n if (title.length > 25) {\n title = title.substring(0, 25) + '...'\n }\n\n return (\n <button\n aria-selected={isSelected}\n className={className}\n id={baseClass + '__item-' + option.key}\n key={option.key}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n ref={option.setRefElement}\n role=\"option\"\n tabIndex={-1}\n type=\"button\"\n >\n {option?.Icon && <option.Icon />}\n\n <span className={`${baseClass}__item-text`}>{title}</span>\n </button>\n )\n}\n\nexport function SlashMenuPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): JSX.Element {\n const [editor] = useLexicalComposerContext()\n const [queryString, setQueryString] = useState<null | string>(null)\n const { editorConfig } = useEditorConfigContext()\n const { i18n } = useTranslation()\n\n const checkForTriggerMatch = useMenuTriggerMatch('/', {\n minLength: 0,\n })\n\n const getDynamicOptions = useCallback(() => {\n let groupWithOptions: Array<SlashMenuGroup> = []\n\n for (const dynamicOption of editorConfig.features.slashMenu.dynamicOptions) {\n const dynamicGroupWithOptions = dynamicOption({\n editor,\n queryString,\n })\n groupWithOptions = groupWithOptions.concat(dynamicGroupWithOptions)\n }\n\n return groupWithOptions\n }, [editor, queryString, editorConfig?.features])\n\n const groups: SlashMenuGroup[] = useMemo(() => {\n let groupsWithOptions: SlashMenuGroup[] = []\n for (const groupWithOption of editorConfig?.features.slashMenu.groupsWithOptions ?? []) {\n groupsWithOptions.push(groupWithOption)\n }\n\n if (queryString) {\n // Filter current groups first\n groupsWithOptions = groupsWithOptions.map((group) => {\n const filteredOptions = group.options.filter((option) => {\n let optionTitle = option.key\n if (option.displayName) {\n optionTitle =\n typeof option.displayName === 'function'\n ? option.displayName({ i18n })\n : option.displayName\n }\n\n return new RegExp(queryString, 'gi').exec(optionTitle) || option.keywords != null\n ? option.keywords.some((keyword) => new RegExp(queryString, 'gi').exec(keyword))\n : false\n })\n if (filteredOptions.length) {\n return {\n ...group,\n options: filteredOptions,\n }\n }\n return null\n })\n\n groupsWithOptions = groupsWithOptions.filter((group) => group != null)\n\n // Now add dynamic groups\n const dynamicOptionGroups = getDynamicOptions()\n\n // merge dynamic options into groups\n for (const dynamicGroup of dynamicOptionGroups) {\n // 1. find the group with the same name or create new one\n let group = groupsWithOptions.find((group) => group.key === dynamicGroup.key)\n if (!group) {\n group = {\n ...dynamicGroup,\n options: [],\n }\n } else {\n groupsWithOptions = groupsWithOptions.filter((group) => group.key !== dynamicGroup.key)\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.options?.length) {\n group.options = group.options.concat(group.options)\n }\n groupsWithOptions.push(group)\n }\n }\n\n return groupsWithOptions\n }, [getDynamicOptions, queryString, editorConfig?.features, i18n])\n\n const onSelectOption = useCallback(\n (\n selectedOption: SlashMenuOption,\n nodeToRemove: TextNode | null,\n closeMenu: () => void,\n matchingString: string,\n ) => {\n editor.update(() => {\n if (nodeToRemove) {\n nodeToRemove.remove()\n }\n selectedOption.onSelect({ editor, queryString: matchingString })\n closeMenu()\n })\n },\n [editor],\n )\n\n return (\n <React.Fragment>\n <LexicalTypeaheadMenuPlugin\n anchorElem={anchorElem}\n groupsWithOptions={groups}\n menuRenderFn={(\n anchorElementRef,\n { selectOptionAndCleanUp, selectedOptionKey, setSelectedOptionKey },\n ) =>\n anchorElementRef.current && groups.length\n ? ReactDOM.createPortal(\n <div className={baseClass}>\n {groups.map((group) => {\n let groupTitle = group.key\n if (group.displayName) {\n groupTitle =\n typeof group.displayName === 'function'\n ? group.displayName({ i18n })\n : group.displayName\n }\n\n return (\n <div\n className={`${baseClass}__group ${baseClass}__group-${group.key}`}\n key={group.key}\n >\n <div className={`${baseClass}__group-title`}>{groupTitle}</div>\n {group.options.map((option, oi: number) => (\n <SlashMenuItem\n index={oi}\n isSelected={selectedOptionKey === option.key}\n key={option.key}\n onClick={() => {\n setSelectedOptionKey(option.key)\n selectOptionAndCleanUp(option)\n }}\n onMouseEnter={() => {\n setSelectedOptionKey(option.key)\n }}\n option={option}\n />\n ))}\n </div>\n )\n })}\n </div>,\n anchorElementRef.current,\n )\n : null\n }\n onQueryChange={setQueryString}\n onSelectOption={onSelectOption}\n triggerFn={checkForTriggerMatch}\n />\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","useTranslation","useCallback","useMemo","useState","React","ReactDOM","useEditorConfigContext","LexicalTypeaheadMenuPlugin","useMenuTriggerMatch","baseClass","SlashMenuItem","isSelected","onClick","onMouseEnter","option","i18n","className","key","title","displayName","length","substring","button","aria-selected","id","ref","setRefElement","role","tabIndex","type","Icon","span","SlashMenuPlugin","anchorElem","document","body","editor","queryString","setQueryString","editorConfig","checkForTriggerMatch","minLength","getDynamicOptions","groupWithOptions","dynamicOption","features","slashMenu","dynamicOptions","dynamicGroupWithOptions","concat","groups","groupsWithOptions","groupWithOption","push","map","group","filteredOptions","options","filter","optionTitle","RegExp","exec","keywords","some","keyword","dynamicOptionGroups","dynamicGroup","find","onSelectOption","selectedOption","nodeToRemove","closeMenu","matchingString","update","remove","onSelect","Fragment","menuRenderFn","anchorElementRef","selectOptionAndCleanUp","selectedOptionKey","setSelectedOptionKey","current","createPortal","div","groupTitle","oi","index","onQueryChange","triggerFn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EAAEC,iBAAiB,EAAEC,oBAAoB,EAAE,GAEnEH,iBAAiBI,OAAO,IAAIhC,OAAO9B,MAAM,iBACrCf,SAAS8E,YAAY,eACnB,oBAACC;gBAAIpE,WAAWP;eACbyC,OAAOI,GAAG,CAAC,CAACC;gBACX,IAAI8B,aAAa9B,MAAMtC,GAAG;gBAC1B,IAAIsC,MAAMpC,WAAW,EAAE;oBACrBkE,aACE,OAAO9B,MAAMpC,WAAW,KAAK,aACzBoC,MAAMpC,WAAW,CAAC;wBAAEJ;oBAAK,KACzBwC,MAAMpC,WAAW;gBACzB;gBAEA,qBACE,oBAACiE;oBACCpE,WAAW,CAAC,EAAEP,UAAU,QAAQ,EAAEA,UAAU,QAAQ,EAAE8C,MAAMtC,GAAG,CAAC,CAAC;oBACjEA,KAAKsC,MAAMtC,GAAG;iCAEd,oBAACmE;oBAAIpE,WAAW,CAAC,EAAEP,UAAU,aAAa,CAAC;mBAAG4E,aAC7C9B,MAAME,OAAO,CAACH,GAAG,CAAC,CAACxC,QAAQwE,mBAC1B,oBAAC5E;wBACC6E,OAAOD;wBACP3E,YAAYqE,sBAAsBlE,OAAOG,GAAG;wBAC5CA,KAAKH,OAAOG,GAAG;wBACfL,SAAS;4BACPqE,qBAAqBnE,OAAOG,GAAG;4BAC/B8D,uBAAuBjE;wBACzB;wBACAD,cAAc;4BACZoE,qBAAqBnE,OAAOG,GAAG;wBACjC;wBACAH,QAAQA;;YAKlB,KAEFgE,iBAAiBI,OAAO,IAE1B;QAENM,eAAelD;QACf8B,gBAAgBA;QAChBqB,WAAWjD;;AAInB"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/plugins/SlashMenu/index.tsx"],"sourcesContent":["'use client'\nimport type { TextNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport { useCallback, useMemo, useState } from 'react'\nimport * as React from 'react'\nimport * as ReactDOM from 'react-dom'\n\nimport type {\n SlashMenuGroup,\n SlashMenuGroupInternal,\n SlashMenuItemInternal,\n SlashMenuItem as SlashMenuItemType,\n} from './LexicalTypeaheadMenuPlugin/types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { LexicalTypeaheadMenuPlugin } from './LexicalTypeaheadMenuPlugin/index.js'\nimport './index.scss'\nimport { useMenuTriggerMatch } from './useMenuTriggerMatch.js'\n\nconst baseClass = 'slash-menu-popup'\n\nfunction SlashMenuItem({\n isSelected,\n item,\n onClick,\n onMouseEnter,\n}: {\n index: number\n isSelected: boolean\n item: SlashMenuItemInternal\n onClick: () => void\n onMouseEnter: () => void\n}) {\n const { i18n } = useTranslation()\n\n let className = `${baseClass}__item ${baseClass}__item-${item.key}`\n if (isSelected) {\n className += ` ${baseClass}__item--selected`\n }\n\n let title = item.key\n if (item.displayName) {\n title = typeof item.displayName === 'function' ? item.displayName({ i18n }) : item.displayName\n }\n // Crop title to max. 50 characters\n if (title.length > 25) {\n title = title.substring(0, 25) + '...'\n }\n\n return (\n <button\n aria-selected={isSelected}\n className={className}\n id={baseClass + '__item-' + item.key}\n key={item.key}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n ref={item.ref}\n role=\"item\"\n tabIndex={-1}\n type=\"button\"\n >\n {item?.Icon && <item.Icon />}\n\n <span className={`${baseClass}__item-text`}>{title}</span>\n </button>\n )\n}\n\nexport function SlashMenuPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n const [queryString, setQueryString] = useState<null | string>(null)\n const { editorConfig } = useEditorConfigContext()\n const { i18n } = useTranslation()\n\n const checkForTriggerMatch = useMenuTriggerMatch('/', {\n minLength: 0,\n })\n\n const getDynamicItems = useCallback(() => {\n let groupWithItems: Array<SlashMenuGroup> = []\n\n for (const dynamicItem of editorConfig.features.slashMenu.dynamicGroups) {\n const dynamicGroupWithItems = dynamicItem({\n editor,\n queryString,\n })\n groupWithItems = groupWithItems.concat(dynamicGroupWithItems)\n }\n\n return groupWithItems\n }, [editor, queryString, editorConfig?.features])\n\n const groups: SlashMenuGroup[] = useMemo(() => {\n let groupsWithItems: SlashMenuGroup[] = []\n for (const groupWithItem of editorConfig?.features.slashMenu.groups ?? []) {\n groupsWithItems.push(groupWithItem)\n }\n\n if (queryString) {\n // Filter current groups first\n groupsWithItems = groupsWithItems.map((group) => {\n const filteredItems = group.items.filter((item) => {\n let itemTitle = item.key\n if (item.displayName) {\n itemTitle =\n typeof item.displayName === 'function' ? item.displayName({ i18n }) : item.displayName\n }\n\n if (new RegExp(queryString, 'gi').exec(itemTitle)) {\n return true\n }\n if (item.keywords != null) {\n return item.keywords.some((keyword) => new RegExp(queryString, 'gi').exec(keyword))\n }\n return false\n })\n if (filteredItems.length) {\n return {\n ...group,\n items: filteredItems,\n }\n }\n return null\n })\n\n groupsWithItems = groupsWithItems.filter((group) => group != null)\n\n // Now add dynamic groups\n const dynamicItemGroups = getDynamicItems()\n\n // merge dynamic items into groups\n for (const dynamicGroup of dynamicItemGroups) {\n // 1. find the group with the same name or create new one\n let group = groupsWithItems.find((group) => group.key === dynamicGroup.key)\n if (!group) {\n group = {\n ...dynamicGroup,\n items: [],\n }\n } else {\n groupsWithItems = groupsWithItems.filter((group) => group.key !== dynamicGroup.key)\n }\n\n // 2. Add items to group items array and add to sanitized.slashMenu.groupsWithItems\n if (group?.items?.length) {\n group.items = group.items.concat(group.items)\n }\n groupsWithItems.push(group)\n }\n }\n\n return groupsWithItems\n }, [getDynamicItems, queryString, editorConfig?.features, i18n])\n\n const onSelectItem = useCallback(\n (\n selectedItem: SlashMenuItemType,\n nodeToRemove: TextNode | null,\n closeMenu: () => void,\n matchingString: string,\n ) => {\n if (nodeToRemove) {\n editor.update(() => {\n nodeToRemove.remove()\n })\n }\n selectedItem.onSelect({ editor, queryString: matchingString })\n\n closeMenu()\n },\n [editor],\n )\n\n return (\n <React.Fragment>\n <LexicalTypeaheadMenuPlugin\n anchorElem={anchorElem}\n groups={groups as SlashMenuGroupInternal[]}\n menuRenderFn={(\n anchorElementRef,\n { selectItemAndCleanUp, selectedItemKey, setSelectedItemKey },\n ) =>\n anchorElementRef.current && groups.length\n ? ReactDOM.createPortal(\n <div className={baseClass}>\n {groups.map((group) => {\n let groupTitle = group.key\n if (group.displayName) {\n groupTitle =\n typeof group.displayName === 'function'\n ? group.displayName({ i18n })\n : group.displayName\n }\n\n return (\n <div\n className={`${baseClass}__group ${baseClass}__group-${group.key}`}\n key={group.key}\n >\n <div className={`${baseClass}__group-title`}>{groupTitle}</div>\n {group.items.map((item, oi: number) => (\n <SlashMenuItem\n index={oi}\n isSelected={selectedItemKey === item.key}\n item={item as SlashMenuItemInternal}\n key={item.key}\n onClick={() => {\n setSelectedItemKey(item.key)\n selectItemAndCleanUp(item)\n }}\n onMouseEnter={() => {\n setSelectedItemKey(item.key)\n }}\n />\n ))}\n </div>\n )\n })}\n </div>,\n anchorElementRef.current,\n )\n : null\n }\n onQueryChange={setQueryString}\n onSelectItem={onSelectItem}\n triggerFn={checkForTriggerMatch}\n />\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","useTranslation","useCallback","useMemo","useState","React","ReactDOM","useEditorConfigContext","LexicalTypeaheadMenuPlugin","useMenuTriggerMatch","baseClass","SlashMenuItem","isSelected","item","onClick","onMouseEnter","i18n","className","key","title","displayName","length","substring","button","aria-selected","id","ref","role","tabIndex","type","Icon","span","SlashMenuPlugin","anchorElem","document","body","editor","queryString","setQueryString","editorConfig","checkForTriggerMatch","minLength","getDynamicItems","groupWithItems","dynamicItem","features","slashMenu","dynamicGroups","dynamicGroupWithItems","concat","groups","groupsWithItems","groupWithItem","push","map","group","filteredItems","items","filter","itemTitle","RegExp","exec","keywords","some","keyword","dynamicItemGroups","dynamicGroup","find","onSelectItem","selectedItem","nodeToRemove","closeMenu","matchingString","update","remove","onSelect","Fragment","menuRenderFn","anchorElementRef","selectItemAndCleanUp","selectedItemKey","setSelect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AAInB"}
@@ -1,24 +1,24 @@
1
1
  import type { BaseSelection, LexicalEditor } from 'lexical';
2
2
  import type React from 'react';
3
- export type FloatingToolbarSection = {
3
+ export type FixedToolbarGroup = {
4
4
  ChildComponent?: React.FC;
5
- entries: Array<FloatingToolbarSectionEntry>;
5
+ items: Array<FixedToolbarGroupItem>;
6
6
  key: string;
7
7
  order?: number;
8
8
  type: 'dropdown';
9
9
  } | {
10
- entries: Array<FloatingToolbarSectionEntry>;
10
+ items: Array<FixedToolbarGroupItem>;
11
11
  key: string;
12
12
  order?: number;
13
13
  type: 'buttons';
14
14
  };
15
- export type FloatingToolbarSectionEntry = {
15
+ export type FixedToolbarGroupItem = {
16
16
  ChildComponent?: React.FC;
17
17
  /** Use component to ignore the children and onClick properties. It does not use the default, pre-defined format Button component */
18
18
  Component?: React.FC<{
19
19
  anchorElem: HTMLElement;
20
20
  editor: LexicalEditor;
21
- entry: FloatingToolbarSectionEntry;
21
+ item: FixedToolbarGroupItem;
22
22
  }>;
23
23
  isActive?: ({ editor, selection }: {
24
24
  editor: LexicalEditor;
@@ -29,7 +29,7 @@ export type FloatingToolbarSectionEntry = {
29
29
  selection: BaseSelection;
30
30
  }) => boolean;
31
31
  key: string;
32
- /** The label is displayed as text if the entry is part of a dropdown section */
32
+ /** The label is displayed as text if the item is part of a dropdown group */
33
33
  label?: string;
34
34
  onClick?: ({ editor, isActive }: {
35
35
  editor: LexicalEditor;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/toolbars/fixed/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,MAAM,iBAAiB,GACzB;IACE,cAAc,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACzB,KAAK,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,UAAU,CAAA;CACjB,GACD;IACE,KAAK,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,SAAS,CAAA;CAChB,CAAA;AAEL,MAAM,MAAM,qBAAqB,GAAG;IAClC,cAAc,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACzB,oIAAoI;IACpI,SAAS,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QACnB,UAAU,EAAE,WAAW,CAAA;QACvB,MAAM,EAAE,aAAa,CAAA;QACrB,IAAI,EAAE,qBAAqB,CAAA;KAC5B,CAAC,CAAA;IACF,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,SAAS,EAAE,aAAa,CAAA;KAAE,KAAK,OAAO,CAAA;IAClG,SAAS,CAAC,EAAE,CAAC,EACX,MAAM,EACN,SAAS,GACV,EAAE;QACD,MAAM,EAAE,aAAa,CAAA;QACrB,SAAS,EAAE,aAAa,CAAA;KACzB,KAAK,OAAO,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;IACtF,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/field/lexical/plugins/toolbars/fixed/types.ts"],"sourcesContent":["import type { BaseSelection, LexicalEditor } from 'lexical'\nimport type React from 'react'\n\nexport type FixedToolbarGroup =\n | {\n ChildComponent?: React.FC\n items: Array<FixedToolbarGroupItem>\n key: string\n order?: number\n type: 'dropdown'\n }\n | {\n items: Array<FixedToolbarGroupItem>\n key: string\n order?: number\n type: 'buttons'\n }\n\nexport type FixedToolbarGroupItem = {\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 anchorElem: HTMLElement\n editor: LexicalEditor\n item: FixedToolbarGroupItem\n }>\n isActive?: ({ editor, selection }: { editor: LexicalEditor; selection: BaseSelection }) => boolean\n isEnabled?: ({\n editor,\n selection,\n }: {\n editor: LexicalEditor\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?: string\n onClick?: ({ editor, isActive }: { editor: LexicalEditor; isActive: boolean }) => void\n order?: number\n}\n"],"names":[],"rangeMappings":"","mappings":"AAkBA,WAqBC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/field/lexical/plugins/toolbars/inline/Toolbar/index.tsx"],"names":[],"mappings":";AAuBA,OAAO,cAAc,CAAA;AAsVrB,wBAAgB,2BAA2B,CAAC,EAC1C,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAGrB"}
@@ -5,51 +5,51 @@ import { $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_LOW, SE
5
5
  import { useCallback, useEffect, useRef, useState } from 'react';
6
6
  import * as React from 'react';
7
7
  import { createPortal } from 'react-dom';
8
- import { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js';
9
- import { getDOMRangeRect } from '../../utils/getDOMRangeRect.js';
10
- import { setFloatingElemPosition } from '../../utils/setFloatingElemPosition.js';
11
- import { ToolbarButton } from './ToolbarButton/index.js';
12
- import { ToolbarDropdown } from './ToolbarDropdown/index.js';
8
+ import { useEditorConfigContext } from '../../../../config/client/EditorConfigProvider.js';
9
+ import { getDOMRangeRect } from '../../../../utils/getDOMRangeRect.js';
10
+ import { setFloatingElemPosition } from '../../../../utils/setFloatingElemPosition.js';
11
+ import { ToolbarButton } from '../ToolbarButton/index.js';
12
+ import { ToolbarDropdown } from '../ToolbarDropdown/index.js';
13
13
  import './index.scss';
14
- function ButtonSectionEntry({ anchorElem, editor, entry }) {
15
- if (entry.Component) {
16
- return entry?.Component && /*#__PURE__*/ React.createElement(entry.Component, {
14
+ function ButtonGroupItem({ anchorElem, editor, item }) {
15
+ if (item.Component) {
16
+ return item?.Component && /*#__PURE__*/ React.createElement(item.Component, {
17
17
  anchorElem: anchorElem,
18
18
  editor: editor,
19
- entry: entry,
20
- key: entry.key
19
+ item: item,
20
+ key: item.key
21
21
  });
22
22
  }
23
23
  return /*#__PURE__*/ React.createElement(ToolbarButton, {
24
- entry: entry,
25
- key: entry.key
26
- }, entry?.ChildComponent && /*#__PURE__*/ React.createElement(entry.ChildComponent, null));
24
+ item: item,
25
+ key: item.key
26
+ }, item?.ChildComponent && /*#__PURE__*/ React.createElement(item.ChildComponent, null));
27
27
  }
28
- function ToolbarSection({ anchorElem, editor, index, section }) {
28
+ function ToolbarGroup({ anchorElem, editor, group, index }) {
29
29
  const { editorConfig } = useEditorConfigContext();
30
- const Icon = section?.type === 'dropdown' && section.entries.length && section.ChildComponent ? section.ChildComponent : null;
30
+ const Icon = group?.type === 'dropdown' && group.items.length && group.ChildComponent ? group.ChildComponent : null;
31
31
  return /*#__PURE__*/ React.createElement("div", {
32
- className: `floating-select-toolbar-popup__section floating-select-toolbar-popup__section-${section.key}`,
33
- key: section.key
34
- }, section.type === 'dropdown' && section.entries.length && (Icon ? /*#__PURE__*/ React.createElement(ToolbarDropdown, {
32
+ className: `inline-toolbar-popup__group inline-toolbar-popup__group-${group.key}`,
33
+ key: group.key
34
+ }, group.type === 'dropdown' && group.items.length && (Icon ? /*#__PURE__*/ React.createElement(ToolbarDropdown, {
35
35
  Icon: Icon,
36
36
  anchorElem: anchorElem,
37
37
  editor: editor,
38
- entries: section.entries,
39
- sectionKey: section.key
38
+ groupKey: group.key,
39
+ items: group.items
40
40
  }) : /*#__PURE__*/ React.createElement(ToolbarDropdown, {
41
41
  anchorElem: anchorElem,
42
42
  editor: editor,
43
- entries: section.entries,
44
- sectionKey: section.key
45
- })), section.type === 'buttons' && section.entries.length && section.entries.map((entry)=>{
46
- return /*#__PURE__*/ React.createElement(ButtonSectionEntry, {
43
+ groupKey: group.key,
44
+ items: group.items
45
+ })), group.type === 'buttons' && group.items.length && group.items.map((item)=>{
46
+ return /*#__PURE__*/ React.createElement(ButtonGroupItem, {
47
47
  anchorElem: anchorElem,
48
48
  editor: editor,
49
- entry: entry,
50
- key: entry.key
49
+ item: item,
50
+ key: item.key
51
51
  });
52
- }), index < editorConfig.features.floatingSelectToolbar?.sections.length - 1 && /*#__PURE__*/ React.createElement("div", {
52
+ }), index < editorConfig.features.toolbarInline?.groups.length - 1 && /*#__PURE__*/ React.createElement("div", {
53
53
  className: "divider"
54
54
  }));
55
55
  }
@@ -172,18 +172,18 @@ function FloatingSelectToolbar({ anchorElem, editor }) {
172
172
  updateTextFormatFloatingToolbar
173
173
  ]);
174
174
  return /*#__PURE__*/ React.createElement("div", {
175
- className: "floating-select-toolbar-popup",
175
+ className: "inline-toolbar-popup",
176
176
  ref: floatingToolbarRef
177
177
  }, /*#__PURE__*/ React.createElement("div", {
178
178
  className: "caret",
179
179
  ref: caretRef
180
- }), editor.isEditable() && /*#__PURE__*/ React.createElement(React.Fragment, null, editorConfig?.features && editorConfig.features?.floatingSelectToolbar?.sections.map((section, i)=>{
181
- return /*#__PURE__*/ React.createElement(ToolbarSection, {
180
+ }), editor.isEditable() && /*#__PURE__*/ React.createElement(React.Fragment, null, editorConfig?.features && editorConfig.features?.toolbarInline?.groups.map((group, i)=>{
181
+ return /*#__PURE__*/ React.createElement(ToolbarGroup, {
182
182
  anchorElem: anchorElem,
183
183
  editor: editor,
184
+ group: group,
184
185
  index: i,
185
- key: section.key,
186
- section: section
186
+ key: group.key
187
187
  });
188
188
  })));
189
189
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/field/lexical/plugins/toolbars/inline/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { InlineToolbarGroup, InlineToolbarGroupItem } from '../types.js'\n\nimport { useEditorConfigContext } from '../../../../config/client/EditorConfigProvider.js'\nimport { getDOMRangeRect } from '../../../../utils/getDOMRangeRect.js'\nimport { setFloatingElemPosition } from '../../../../utils/setFloatingElemPosition.js'\nimport { ToolbarButton } from '../ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../ToolbarDropdown/index.js'\nimport './index.scss'\n\nfunction ButtonGroupItem({\n anchorElem,\n editor,\n item,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n item: InlineToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n return (\n <ToolbarButton item={item} key={item.key}>\n {item?.ChildComponent && <item.ChildComponent />}\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroup({\n anchorElem,\n editor,\n group,\n index,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n group: InlineToolbarGroup\n index: number\n}): React.ReactNode {\n const { editorConfig } = useEditorConfigContext()\n\n const Icon =\n group?.type === 'dropdown' && group.items.length && group.ChildComponent\n ? group.ChildComponent\n : null\n\n return (\n <div\n className={`inline-toolbar-popup__group inline-toolbar-popup__group-${group.key}`}\n key={group.key}\n >\n {group.type === 'dropdown' &&\n group.items.length &&\n (Icon ? (\n <ToolbarDropdown\n Icon={Icon}\n anchorElem={anchorElem}\n editor={editor}\n groupKey={group.key}\n items={group.items}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n groupKey={group.key}\n items={group.items}\n />\n ))}\n {group.type === 'buttons' &&\n group.items.length &&\n group.items.map((item) => {\n return (\n <ButtonGroupItem anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n })}\n {index < editorConfig.features.toolbarInline?.groups.length - 1 && (\n <div className=\"divider\" />\n )}\n </div>\n )\n}\n\nfunction FloatingSelectToolbar({\n anchorElem,\n editor,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n}): React.ReactNode {\n const floatingToolbarRef = useRef<HTMLDivElement | null>(null)\n const caretRef = useRef<HTMLDivElement | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const closeFloatingToolbar = useCallback(() => {\n if (floatingToolbarRef?.current) {\n const isOpacityZero = floatingToolbarRef.current.style.opacity === '0'\n const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none'\n\n if (!isOpacityZero) {\n floatingToolbarRef.current.style.opacity = '0'\n }\n if (!isPointerEventsNone) {\n floatingToolbarRef.current.style.pointerEvents = 'none'\n }\n }\n }, [floatingToolbarRef])\n\n const mouseMoveListener = useCallback(\n (e: MouseEvent) => {\n if (floatingToolbarRef?.current && (e.buttons === 1 || e.buttons === 3)) {\n const isOpacityZero = floatingToolbarRef.current.style.opacity === '0'\n const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none'\n if (!isOpacityZero || !isPointerEventsNone) {\n // Check if the mouse is not over the popup\n const x = e.clientX\n const y = e.clientY\n const elementUnderMouse = document.elementFromPoint(x, y)\n if (!floatingToolbarRef.current.contains(elementUnderMouse)) {\n // Mouse is not over the target element => not a normal click, but probably a drag\n closeFloatingToolbar()\n }\n }\n }\n },\n [closeFloatingToolbar],\n )\n\n const mouseUpListener = useCallback(() => {\n if (floatingToolbarRef?.current) {\n if (floatingToolbarRef.current.style.opacity !== '1') {\n floatingToolbarRef.current.style.opacity = '1'\n }\n if (floatingToolbarRef.current.style.pointerEvents !== 'auto') {\n floatingToolbarRef.current.style.pointerEvents = 'auto'\n }\n }\n }, [floatingToolbarRef])\n\n useEffect(() => {\n document.addEventListener('mousemove', mouseMoveListener)\n document.addEventListener('mouseup', mouseUpListener)\n\n return () => {\n document.removeEventListener('mousemove', mouseMoveListener)\n document.removeEventListener('mouseup', mouseUpListener)\n }\n }, [floatingToolbarRef, mouseMoveListener, mouseUpListener])\n\n const updateTextFormatFloatingToolbar = useCallback(() => {\n const selection = $getSelection()\n\n const nativeSelection = window.getSelection()\n\n if (floatingToolbarRef.current === null) {\n return\n }\n\n const rootElement = editor.getRootElement()\n if (\n selection !== null &&\n nativeSelection !== null &&\n !nativeSelection.isCollapsed &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n const rangeRect = getDOMRangeRect(nativeSelection, rootElement)\n\n // Position floating toolbar\n const offsetIfFlipped = setFloatingElemPosition(\n rangeRect, // selection to position around\n floatingToolbarRef.current, // what to position\n anchorElem, // anchor elem\n 'center',\n )\n\n // Position caret\n if (caretRef.current) {\n setFloatingElemPosition(\n rangeRect, // selection to position around\n caretRef.current, // what to position\n floatingToolbarRef.current, // anchor elem\n 'center',\n 10,\n 5,\n true,\n offsetIfFlipped,\n )\n }\n }\n }, [editor, anchorElem])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = () => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar()\n })\n }\n\n window.addEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [editor, updateTextFormatFloatingToolbar, anchorElem])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar()\n })\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateTextFormatFloatingToolbar()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n updateTextFormatFloatingToolbar()\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateTextFormatFloatingToolbar])\n\n return (\n <div className=\"inline-toolbar-popup\" ref={floatingToolbarRef}>\n <div className=\"caret\" ref={caretRef} />\n {editor.isEditable() && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.toolbarInline?.groups.map((group, i) => {\n return (\n <ToolbarGroup\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n index={i}\n key={group.key}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nfunction useFloatingTextFormatToolbar(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n): JSX.Element | null {\n const [isText, setIsText] = useState(false)\n\n const updatePopup = useCallback(() => {\n editor.getEditorState().read(() => {\n // Should not to pop up the floating toolbar when using IME input\n if (editor.isComposing()) {\n return\n }\n const selection = $getSelection()\n const nativeSelection = window.getSelection()\n const rootElement = editor.getRootElement()\n\n if (\n nativeSelection !== null &&\n (!$isRangeSelection(selection) ||\n rootElement === null ||\n !rootElement.contains(nativeSelection.anchorNode))\n ) {\n setIsText(false)\n return\n }\n\n if (!$isRangeSelection(selection)) {\n return\n }\n\n if (selection.getTextContent() !== '') {\n const nodes = selection.getNodes()\n let foundNodeWithText = false\n for (const node of nodes) {\n if ($isTextNode(node)) {\n setIsText(true)\n foundNodeWithText = true\n break\n }\n }\n if (!foundNodeWithText) {\n setIsText(false)\n }\n } else {\n setIsText(false)\n }\n\n const rawTextContent = selection.getTextContent().replace(/\\n/g, '')\n if (!selection.isCollapsed() && rawTextContent === '') {\n setIsText(false)\n return\n }\n })\n }, [editor])\n\n useEffect(() => {\n document.addEventListener('selectionchange', updatePopup)\n document.addEventListener('mouseup', updatePopup)\n return () => {\n document.removeEventListener('selectionchange', updatePopup)\n document.removeEventListener('mouseup', updatePopup)\n }\n }, [updatePopup])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updatePopup()\n }),\n editor.registerRootListener(() => {\n if (editor.getRootElement() === null) {\n setIsText(false)\n }\n }),\n )\n }, [editor, updatePopup])\n\n if (!isText) {\n return null\n }\n\n return createPortal(<FloatingSelectToolbar anchorElem={anchorElem} editor={editor} />, anchorElem)\n}\n\nexport function FloatingSelectToolbarPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n return useFloatingTextFormatToolbar(editor, anchorElem)\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","SELECTION_CHANGE_COMMAND","useCallback","useEffect","useRef","useState","React","createPortal","useEditorConfigContext","getDOMRangeRect","setFloatingElemPosition","ToolbarButton","ToolbarDropdown","ButtonGroupItem","anchorElem","editor","item","Component","key","ChildComponent","ToolbarGroup","group","index","editorConfig","Icon","type","items","length","div","className","groupKey","map","features","toolbarInline","groups","FloatingSelectToolbar","floatingToolbarRef","caretRef","closeFloatingToolbar","current","isOpacityZero","style","opacity","isPointerEventsNone","pointerEvents","mouseMoveListener","e","buttons","x","clientX","y","clientY","elementUnderMouse","document","elementFromPoint","contains","mouseUpListener","addEventListener","removeEventListener","updateTextFormatFloatingToolbar","selection","nativeSelection","window","getSelection","rootElement","getRootElement","isCollapsed","anchorNode","rangeRect","offsetIfFlipped","scrollerElem","parentElement","update","getEditorState","read","registerUpdateListener","editorState","registerCommand","ref","isEditable","Fragment","i","useFloatingTextFormatToolbar","isText","setIsText","updatePopup","isComposing","getTextContent","nodes","getNodes","foundNodeWithText","node","rawTextContent","replace","registerRootListener","FloatingSelectToolbarPlugin","body"],"rangeMappings":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I,CAACA,mBAAmB;oBACtBN,UAAU;gBACZ;YACF,OAAO;gBACLA,UAAU;YACZ;YAEA,MAAMQ,iBAAiBhC,UAAU2B,cAAc,GAAGM,OAAO,CAAC,OAAO;YACjE,IAAI,CAACjC,UAAUM,WAAW,MAAM0B,mBAAmB,IAAI;gBACrDR,UAAU;gBACV;YACF;QACF;IACF,GAAG;QAACrE;KAAO;IAEXZ,UAAU;QACRkD,SAASI,gBAAgB,CAAC,mBAAmB4B;QAC7ChC,SAASI,gBAAgB,CAAC,WAAW4B;QACrC,OAAO;YACLhC,SAASK,mBAAmB,CAAC,mBAAmB2B;YAChDhC,SAASK,mBAAmB,CAAC,WAAW2B;QAC1C;IACF,GAAG;QAACA;KAAY;IAEhBlF,UAAU;QACR,OAAOP,cACLmB,OAAO4D,sBAAsB,CAAC;YAC5BU;QACF,IACAtE,OAAO+E,oBAAoB,CAAC;YAC1B,IAAI/E,OAAOkD,cAAc,OAAO,MAAM;gBACpCmB,UAAU;YACZ;QACF;IAEJ,GAAG;QAACrE;QAAQsE;KAAY;IAExB,IAAI,CAACF,QAAQ;QACX,OAAO;IACT;IAEA,qBAAO5E,2BAAa,oBAAC4B;QAAsBrB,YAAYA;QAAYC,QAAQA;QAAYD;AACzF;AAEA,OAAO,SAASiF,4BAA4B,EAC1CjF,aAAauC,SAAS2C,IAAI,EAG3B;IACC,MAAM,CAACjF,OAAO,GAAGpB;IACjB,OAAOuF,6BAA6BnE,QAAQD;AAC9C"}
@@ -1,12 +1,12 @@
1
- @import '../../../../scss/styles.scss';
1
+ @import '../../../../../../scss/styles';
2
2
 
3
3
  html[data-theme='light'] {
4
- .floating-select-toolbar-popup {
4
+ .inline-toolbar-popup {
5
5
  @include shadow-m;
6
6
  }
7
7
  }
8
8
 
9
- .floating-select-toolbar-popup {
9
+ .inline-toolbar-popup {
10
10
  display: flex;
11
11
  align-items: center;
12
12
  background: var(--color-base-0);
@@ -31,9 +31,10 @@ html[data-theme='light'] {
31
31
  border-top-color: var(--color-base-0);
32
32
  }
33
33
 
34
- &__section {
34
+ &__group {
35
35
  display: flex;
36
36
  align-items: center;
37
+ gap: 2px;
37
38
 
38
39
  .icon {
39
40
  min-width: 20px;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { InlineToolbarGroupItem } from '../types.js';
3
+ import './index.scss';
4
+ export declare const ToolbarButton: ({ children, item, }: {
5
+ children: React.JSX.Element;
6
+ item: InlineToolbarGroupItem;
7
+ }) => React.JSX.Element;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/field/lexical/plugins/toolbars/inline/ToolbarButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,aAAa,wBAGvB;IACD,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B,IAAI,EAAE,sBAAsB,CAAA;CAC7B,sBA8EA,CAAA"}