@payloadcms/richtext-lexical 4.0.0-internal.ea6e8f8 → 4.0.0-internal.ee5d8bd

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 (177) hide show
  1. package/dist/exports/client/Field-334JNLRF.js +2 -0
  2. package/dist/exports/client/Field-334JNLRF.js.map +7 -0
  3. package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js → RelationshipComponent-TVK6I4W4.js} +2 -2
  4. package/dist/exports/client/chunk-BEKGION5.js +2 -0
  5. package/dist/exports/client/chunk-BEKGION5.js.map +7 -0
  6. package/dist/exports/client/{chunk-WSAPGI3Z.js → chunk-EA5BHQ2T.js} +1 -1
  7. package/dist/exports/client/{chunk-WSAPGI3Z.js.map → chunk-EA5BHQ2T.js.map} +1 -1
  8. package/dist/exports/client/chunk-FAJJXXCW.js +2 -0
  9. package/dist/exports/client/{chunk-3LRZDIIG.js.map → chunk-FAJJXXCW.js.map} +2 -2
  10. package/dist/exports/client/{chunk-5VIL27GI.js → chunk-IYBYNEKX.js} +1 -1
  11. package/dist/exports/client/{chunk-5VIL27GI.js.map → chunk-IYBYNEKX.js.map} +1 -1
  12. package/dist/exports/client/chunk-SE5IITBK.js +2 -0
  13. package/dist/exports/client/chunk-SE5IITBK.js.map +7 -0
  14. package/dist/exports/client/{component-6DQLENIE.js → component-QENB4QTS.js} +2 -2
  15. package/dist/exports/client/componentInline-AU7IBNY7.js +2 -0
  16. package/dist/exports/client/index.js +26 -26
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/features/align/client/index.js.map +1 -1
  19. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  20. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  21. package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
  22. package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
  23. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  24. package/dist/features/blocks/client/component/index.js +38 -16
  25. package/dist/features/blocks/client/component/index.js.map +1 -1
  26. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
  27. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
  28. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
  29. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
  30. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  31. package/dist/features/blocks/client/componentInline/index.js +5 -11
  32. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  33. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -1
  34. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  35. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +121 -78
  36. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  37. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +142 -87
  38. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
  39. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  40. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  41. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  42. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  43. package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
  44. package/dist/features/heading/client/index.js.map +1 -1
  45. package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
  46. package/dist/features/indent/client/index.d.ts.map +1 -1
  47. package/dist/features/indent/client/index.js +0 -2
  48. package/dist/features/indent/client/index.js.map +1 -1
  49. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  50. package/dist/features/indent/server/i18n.js.map +1 -1
  51. package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
  52. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  53. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +10 -2
  54. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  55. package/dist/features/link/client/plugins/link/index.js.map +1 -1
  56. package/dist/features/link/markdownTransformer.js +2 -2
  57. package/dist/features/link/markdownTransformer.js.map +1 -1
  58. package/dist/features/link/server/baseFields.js.map +1 -1
  59. package/dist/features/lists/shared/schema.d.ts.map +1 -1
  60. package/dist/features/lists/shared/schema.js.map +1 -1
  61. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  62. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  63. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  64. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.css +1 -1
  65. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  66. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js +6 -6
  67. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  68. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  69. package/dist/features/table/client/plugins/TablePlugin/index.js +54 -18
  70. package/dist/features/table/client/plugins/TablePlugin/index.js.map +1 -1
  71. package/dist/features/table/client/utils/useDebounce.js.map +1 -1
  72. package/dist/features/textState/defaultColors.js +1 -1
  73. package/dist/features/textState/defaultColors.js.map +1 -1
  74. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -1
  75. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  76. package/dist/features/toolbars/fixed/client/Toolbar/index.js +141 -70
  77. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  78. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  79. package/dist/features/toolbars/inline/client/Toolbar/index.js +82 -35
  80. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  81. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  82. package/dist/features/toolbars/shared/ToolbarButton/index.js +26 -2
  83. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  84. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +137 -72
  85. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  86. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  87. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +22 -6
  88. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  89. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts +5 -0
  90. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts.map +1 -0
  91. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js +109 -0
  92. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js.map +1 -0
  93. package/dist/features/upload/client/drawer/index.js.map +1 -1
  94. package/dist/features/upload/client/plugin/index.js.map +1 -1
  95. package/dist/field/RenderLexical/index.js.map +1 -1
  96. package/dist/field/ViewSelector.js +12 -4
  97. package/dist/field/ViewSelector.js.map +1 -1
  98. package/dist/field/bundled.css +1 -1
  99. package/dist/field/index.js.map +1 -1
  100. package/dist/field/rscEntry.d.ts +2 -2
  101. package/dist/field/rscEntry.d.ts.map +1 -1
  102. package/dist/field/rscEntry.js.map +1 -1
  103. package/dist/i18n.d.ts.map +1 -1
  104. package/dist/i18n.js +44 -0
  105. package/dist/i18n.js.map +1 -1
  106. package/dist/index.d.ts +3 -3
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js.map +1 -1
  109. package/dist/lexical/LexicalEditor.js.map +1 -1
  110. package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -1
  111. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  112. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  113. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  114. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
  115. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +234 -87
  116. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  117. package/dist/lexical/plugins/SlashMenu/useMenuTriggerMatch.js.map +1 -1
  118. package/dist/lexical/plugins/TextPlugin/index.js.map +1 -1
  119. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  120. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +16 -0
  121. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  122. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +126 -38
  123. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  124. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts +7 -0
  125. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts.map +1 -0
  126. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js +15 -0
  127. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js.map +1 -0
  128. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -1
  129. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +9 -12
  130. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -1
  131. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  132. package/dist/lexical/ui/ContentEditable.js +16 -9
  133. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  134. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  135. package/dist/lexical/utils/nodeFormat.js +0 -2
  136. package/dist/lexical/utils/nodeFormat.js.map +1 -1
  137. package/dist/lexical/utils/url.d.ts.map +1 -1
  138. package/dist/lexical/utils/url.js +1 -1
  139. package/dist/lexical/utils/url.js.map +1 -1
  140. package/dist/populateGraphQL/populate.d.ts.map +1 -1
  141. package/dist/populateGraphQL/populate.js +1 -2
  142. package/dist/populateGraphQL/populate.js.map +1 -1
  143. package/dist/types/index.d.ts +1 -4
  144. package/dist/types/index.d.ts.map +1 -1
  145. package/dist/types/index.js.map +1 -1
  146. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  147. package/dist/utilities/buildEditorState.js.map +1 -1
  148. package/dist/utilities/fieldsDrawer/Drawer.js +36 -36
  149. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  150. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  151. package/dist/utilities/fieldsDrawer/DrawerContent.js +6 -9
  152. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  153. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -1
  154. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
  155. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
  156. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
  157. package/dist/utilities/generateImportMap.d.ts +2 -2
  158. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  159. package/dist/utilities/generateImportMap.js.map +1 -1
  160. package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
  161. package/dist/utilities/initLexicalFeatures.js +38 -4
  162. package/dist/utilities/initLexicalFeatures.js.map +1 -1
  163. package/dist/utilities/useLexicalFeature.js +15 -6
  164. package/dist/utilities/useLexicalFeature.js.map +1 -1
  165. package/dist/utilities/useRunDeprioritized.js.map +1 -1
  166. package/package.json +32 -35
  167. package/dist/exports/client/Field-MT4FK3IP.js +0 -2
  168. package/dist/exports/client/Field-MT4FK3IP.js.map +0 -7
  169. package/dist/exports/client/chunk-3LRZDIIG.js +0 -2
  170. package/dist/exports/client/chunk-E6LSRRP2.js +0 -2
  171. package/dist/exports/client/chunk-E6LSRRP2.js.map +0 -7
  172. package/dist/exports/client/chunk-ZQX5HXUL.js +0 -2
  173. package/dist/exports/client/chunk-ZQX5HXUL.js.map +0 -7
  174. package/dist/exports/client/componentInline-HNE5G4TE.js +0 -2
  175. /package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js.map → RelationshipComponent-TVK6I4W4.js.map} +0 -0
  176. /package/dist/exports/client/{component-6DQLENIE.js.map → component-QENB4QTS.js.map} +0 -0
  177. /package/dist/exports/client/{componentInline-HNE5G4TE.js.map → componentInline-AU7IBNY7.js.map} +0 -0
@@ -4,12 +4,14 @@ import { c as _c } from "react/compiler-runtime";
4
4
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
5
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
6
6
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
7
+ import { getTranslation } from '@payloadcms/translations';
7
8
  import { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui';
8
9
  import * as React from 'react';
9
10
  import { useMemo } from 'react';
10
11
  import { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js';
11
12
  import { ToolbarButton } from '../../../shared/ToolbarButton/index.js';
12
13
  import { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js';
14
+ import { useToolbarKeyboardNavigation } from '../../../shared/useToolbarKeyboardNavigation.js';
13
15
  import { useToolbarStates } from '../../../shared/useToolbarStates.js';
14
16
  import { useRedirectVerticalWheelToHorizontalScroll } from './horizontalWheelScroll.js';
15
17
  import './index.css';
@@ -38,85 +40,141 @@ function ButtonGroupItem({
38
40
  children: /*#__PURE__*/_jsx(item.ChildComponent, {})
39
41
  }, item.key);
40
42
  }
41
- function ToolbarGroupComponent({
42
- anchorElem,
43
- editor,
44
- editorConfig,
45
- group,
46
- index,
47
- toolbarStates
48
- }) {
43
+ function ToolbarGroupComponent(t0) {
44
+ const $ = _c(22);
45
+ const {
46
+ anchorElem,
47
+ editor,
48
+ editorConfig,
49
+ group,
50
+ index,
51
+ toolbarStates
52
+ } = t0;
49
53
  const {
50
54
  i18n
51
55
  } = useTranslation();
52
56
  const {
53
- fieldProps: {
54
- featureClientSchemaMap,
55
- schemaPath
56
- }
57
+ fieldProps: t1
57
58
  } = useEditorConfigContext();
58
- const groupState = toolbarStates.groupStates.get(group.key);
59
- const DropdownIcon = useMemo(() => {
60
- if (group.type !== 'dropdown') {
61
- return undefined;
59
+ const {
60
+ featureClientSchemaMap,
61
+ schemaPath
62
+ } = t1;
63
+ let t2;
64
+ if ($[0] !== group.key || $[1] !== toolbarStates.groupStates) {
65
+ t2 = toolbarStates.groupStates.get(group.key);
66
+ $[0] = group.key;
67
+ $[1] = toolbarStates.groupStates;
68
+ $[2] = t2;
69
+ } else {
70
+ t2 = $[2];
71
+ }
72
+ const groupState = t2;
73
+ groupState?.activeItems;
74
+ let t3;
75
+ bb0: {
76
+ if (group.type !== "dropdown") {
77
+ t3 = undefined;
78
+ break bb0;
62
79
  }
63
80
  const activeItem = groupState?.activeItems?.[0];
64
81
  if (activeItem) {
65
- return activeItem.ChildComponent;
66
- }
67
- return group.ChildComponent;
68
- }, [group, groupState?.activeItems]);
69
- const dropdownLabel = useMemo(() => {
70
- if (group.type !== 'dropdown') {
71
- return undefined;
72
- }
73
- const activeItems = groupState?.activeItems;
74
- if (!activeItems?.length) {
75
- return undefined;
76
- }
77
- if (activeItems.length > 1) {
78
- return i18n.t('lexical:general:toolbarItemsActive', {
79
- count: activeItems.length
80
- });
82
+ t3 = activeItem.ChildComponent;
83
+ break bb0;
81
84
  }
82
- const item = activeItems[0];
83
- let label = item.key;
84
- if (item.label) {
85
- label = typeof item.label === 'function' ? item.label({
86
- featureClientSchemaMap,
87
- i18n,
88
- schemaPath
89
- }) : item.label;
90
- }
91
- if (label.length > 25) {
92
- label = label.substring(0, 25) + '...';
93
- }
94
- return label;
95
- }, [group, groupState?.activeItems, i18n, featureClientSchemaMap, schemaPath]);
96
- return /*#__PURE__*/_jsxs("div", {
97
- className: `fixed-toolbar__group fixed-toolbar__group-${group.key}`,
98
- "data-toolbar-group-key": group.key,
99
- children: [group.type === 'dropdown' && group.items.length && groupState ? /*#__PURE__*/_jsx(ToolbarDropdown, {
100
- anchorElem: anchorElem,
101
- editor: editor,
102
- group: group,
103
- groupState: groupState,
104
- Icon: DropdownIcon,
105
- itemsContainerClassNames: ['fixed-toolbar__dropdown-items'],
106
- label: dropdownLabel
107
- }) : null, group.type === 'buttons' && group.items.length ? group.items.map(item_0 => {
108
- const itemState = toolbarStates.itemStates.get(item_0.key);
109
- return /*#__PURE__*/_jsx(ButtonGroupItem, {
110
- active: itemState?.active ?? false,
111
- anchorElem: anchorElem,
112
- editor: editor,
113
- enabled: itemState?.enabled ?? true,
114
- item: item_0
115
- }, item_0.key);
116
- }) : null, index < editorConfig.features.toolbarFixed?.groups.length - 1 && /*#__PURE__*/_jsx("div", {
117
- className: "divider"
118
- })]
119
- }, group.key);
85
+ t3 = group.ChildComponent;
86
+ }
87
+ const DropdownIcon = t3;
88
+ let t4;
89
+ if ($[3] !== featureClientSchemaMap || $[4] !== group.type || $[5] !== groupState?.activeItems || $[6] !== i18n || $[7] !== schemaPath) {
90
+ t4 = () => {
91
+ if (group.type !== "dropdown") {
92
+ return;
93
+ }
94
+ const activeItems = groupState?.activeItems;
95
+ if (!activeItems?.length) {
96
+ return;
97
+ }
98
+ if (activeItems.length > 1) {
99
+ return i18n.t("lexical:general:toolbarItemsActive", {
100
+ count: activeItems.length
101
+ });
102
+ }
103
+ const item = activeItems[0];
104
+ let label = item.key;
105
+ if (item.label) {
106
+ label = typeof item.label === "function" ? item.label({
107
+ featureClientSchemaMap,
108
+ i18n,
109
+ schemaPath
110
+ }) : item.label;
111
+ }
112
+ if (label.length > 25) {
113
+ label = label.substring(0, 25) + "...";
114
+ }
115
+ return label;
116
+ };
117
+ $[3] = featureClientSchemaMap;
118
+ $[4] = group.type;
119
+ $[5] = groupState?.activeItems;
120
+ $[6] = i18n;
121
+ $[7] = schemaPath;
122
+ $[8] = t4;
123
+ } else {
124
+ t4 = $[8];
125
+ }
126
+ groupState?.activeItems;
127
+ let t5;
128
+ if ($[9] !== t4) {
129
+ t5 = t4();
130
+ $[9] = t4;
131
+ $[10] = t5;
132
+ } else {
133
+ t5 = $[10];
134
+ }
135
+ const dropdownLabel = t5;
136
+ const t6 = `fixed-toolbar__group fixed-toolbar__group-${group.key}`;
137
+ let t7;
138
+ if ($[11] !== DropdownIcon || $[12] !== anchorElem || $[13] !== dropdownLabel || $[14] !== editor || $[15] !== editorConfig.features.toolbarFixed?.groups.length || $[16] !== group || $[17] !== groupState || $[18] !== index || $[19] !== t6 || $[20] !== toolbarStates.itemStates) {
139
+ t7 = _jsxs("div", {
140
+ className: t6,
141
+ "data-toolbar-group-key": group.key,
142
+ children: [group.type === "dropdown" && group.items.length && groupState ? _jsx(ToolbarDropdown, {
143
+ anchorElem,
144
+ editor,
145
+ group,
146
+ groupState,
147
+ Icon: DropdownIcon,
148
+ itemsContainerClassNames: ["fixed-toolbar__dropdown-items"],
149
+ label: dropdownLabel
150
+ }) : null, group.type === "buttons" && group.items.length ? group.items.map(item_0 => {
151
+ const itemState = toolbarStates.itemStates.get(item_0.key);
152
+ return _jsx(ButtonGroupItem, {
153
+ active: itemState?.active ?? false,
154
+ anchorElem,
155
+ editor,
156
+ enabled: itemState?.enabled ?? true,
157
+ item: item_0
158
+ }, item_0.key);
159
+ }) : null, index < editorConfig.features.toolbarFixed?.groups.length - 1 && _jsx("div", {
160
+ className: "divider"
161
+ })]
162
+ }, group.key);
163
+ $[11] = DropdownIcon;
164
+ $[12] = anchorElem;
165
+ $[13] = dropdownLabel;
166
+ $[14] = editor;
167
+ $[15] = editorConfig.features.toolbarFixed?.groups.length;
168
+ $[16] = group;
169
+ $[17] = groupState;
170
+ $[18] = index;
171
+ $[19] = t6;
172
+ $[20] = toolbarStates.itemStates;
173
+ $[21] = t7;
174
+ } else {
175
+ t7 = $[21];
176
+ }
177
+ return t7;
120
178
  }
121
179
  function FixedToolbar({
122
180
  anchorElem,
@@ -126,6 +184,16 @@ function FixedToolbar({
126
184
  parentWithFixedToolbar
127
185
  }) {
128
186
  const currentToolbarRef = React.useRef(null);
187
+ const keyboardNavigationOptions = useMemo(() => ({
188
+ toolbarRef: currentToolbarRef
189
+ }), []);
190
+ const {
191
+ fieldProps
192
+ } = useEditorConfigContext();
193
+ const {
194
+ i18n
195
+ } = useTranslation();
196
+ useToolbarKeyboardNavigation(keyboardNavigationOptions);
129
197
  const isEditable = useLexicalEditable();
130
198
  const {
131
199
  y
@@ -176,6 +244,7 @@ function FixedToolbar({
176
244
  }
177
245
  }, 50, [currentToolbarRef, parentToolbarElem, y]);
178
246
  return /*#__PURE__*/_jsx("div", {
247
+ "aria-label": getTranslation(fieldProps.field.label || fieldProps.path, i18n) || fieldProps.path,
179
248
  className: "fixed-toolbar",
180
249
  onFocus: event => {
181
250
  // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,
@@ -183,8 +252,10 @@ function FixedToolbar({
183
252
  event.stopPropagation();
184
253
  },
185
254
  ref: currentToolbarRef,
255
+ role: "toolbar",
186
256
  children: isEditable && /*#__PURE__*/_jsx("div", {
187
257
  className: "fixed-toolbar__scroll",
258
+ tabIndex: -1,
188
259
  children: editorConfig?.features && editorConfig.features?.toolbarFixed?.groups.map((group, i) => {
189
260
  return /*#__PURE__*/_jsx(ToolbarGroupComponent, {
190
261
  anchorElem: anchorElem,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","useToolbarStates","useRedirectVerticalWheelToHorizontalScroll","ButtonGroupItem","active","anchorElem","editor","enabled","item","Component","_jsx","key","ChildComponent","ToolbarGroupComponent","editorConfig","group","index","toolbarStates","i18n","fieldProps","featureClientSchemaMap","schemaPath","groupState","groupStates","get","DropdownIcon","type","undefined","activeItem","activeItems","dropdownLabel","length","t","count","label","substring","_jsxs","className","items","Icon","itemsContainerClassNames","map","itemState","itemStates","features","toolbarFixed","groups","FixedToolbar","clientProps","parentWithFixedToolbar","currentToolbarRef","useRef","isEditable","y","parentToolbarElem","disableIfParentHasFixedToolbar","parentEditorElem","editorContainerRef","current","sibling","previousElementSibling","classList","contains","currentToolbarElem","currentRect","getBoundingClientRect","parentRect","overlapping","bottom","top","remove","add","onFocus","event","stopPropagation","ref","i","getParentEditorWithFixedToolbar","editorConfigContext","parentEditor","resolvedFeatureMap","has","FixedToolbarPlugin","t0","$","currentEditor","currentEditorConfig","applyToFocusedEditor","focusedEditor","t1","t2","Symbol","for","bb0","document","body"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ToolbarStates } from '../../../shared/useToolbarStates.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\nimport type { FixedToolbarFeatureProps } from '../../server/index.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\nimport { useToolbarStates } from '../../../shared/useToolbarStates.js'\nimport { useRedirectVerticalWheelToHorizontalScroll } from './horizontalWheelScroll.js'\nimport './index.css'\n\nfunction ButtonGroupItem({\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}): 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 if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton active={active} editor={editor} enabled={enabled} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n toolbarStates,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n toolbarStates: ToolbarStates\n}): React.ReactNode {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const groupState = toolbarStates.groupStates.get(group.key)\n\n const DropdownIcon = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItem = groupState?.activeItems?.[0]\n if (activeItem) {\n return activeItem.ChildComponent\n }\n return group.ChildComponent\n }, [group, groupState?.activeItems])\n\n const dropdownLabel = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItems = groupState?.activeItems\n if (!activeItems?.length) {\n return undefined\n }\n if (activeItems.length > 1) {\n return i18n.t('lexical:general:toolbarItemsActive', { count: activeItems.length })\n }\n const item = activeItems[0]!\n let label = item.key\n if (item.label) {\n label =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n return label\n }, [group, groupState?.activeItems, i18n, featureClientSchemaMap, schemaPath])\n\n return (\n <div\n className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`}\n data-toolbar-group-key={group.key}\n key={group.key}\n >\n {group.type === 'dropdown' && group.items.length && groupState ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n groupState={groupState}\n Icon={DropdownIcon}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n />\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n const itemState = toolbarStates.itemStates.get(item.key)\n return (\n <ButtonGroupItem\n active={itemState?.active ?? false}\n anchorElem={anchorElem}\n editor={editor}\n enabled={itemState?.enabled ?? true}\n item={item}\n key={item.key}\n />\n )\n })\n : null}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n clientProps,\n editor,\n editorConfig,\n parentWithFixedToolbar,\n}: {\n anchorElem: HTMLElement\n clientProps?: FixedToolbarFeatureProps\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n parentWithFixedToolbar: EditorConfigContextType | false\n}): React.ReactNode {\n const currentToolbarRef = React.useRef<HTMLDivElement>(null)\n const isEditable = useLexicalEditable()\n\n const { y } = useScrollInfo()\n\n useRedirectVerticalWheelToHorizontalScroll()\n\n const toolbarStates = useToolbarStates(editor, editorConfig?.features?.toolbarFixed?.groups)\n\n // Memoize the parent toolbar element\n const parentToolbarElem = useMemo(() => {\n if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {\n return null\n }\n\n const parentEditorElem = parentWithFixedToolbar.editorContainerRef.current\n let sibling = parentEditorElem.previousElementSibling\n while (sibling) {\n if (sibling.classList.contains('fixed-toolbar')) {\n return sibling\n }\n sibling = sibling.previousElementSibling\n }\n return null\n }, [clientProps?.disableIfParentHasFixedToolbar, parentWithFixedToolbar])\n\n useThrottledEffect(\n () => {\n if (!parentToolbarElem) {\n // this also checks for clientProps?.disableIfParentHasFixedToolbar indirectly, see the parentToolbarElem useMemo\n return\n }\n const currentToolbarElem = currentToolbarRef.current\n if (!currentToolbarElem) {\n return\n }\n\n const currentRect = currentToolbarElem.getBoundingClientRect()\n const parentRect = parentToolbarElem.getBoundingClientRect()\n\n // we only need to check for vertical overlap\n const overlapping = !(\n currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom\n )\n\n if (overlapping) {\n currentToolbarElem.classList.remove('fixed-toolbar')\n currentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--overlapping')\n parentToolbarElem.classList.remove('fixed-toolbar')\n parentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--hide')\n } else {\n if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {\n return\n }\n currentToolbarElem.classList.remove('fixed-toolbar--overlapping')\n currentToolbarElem.classList.add('fixed-toolbar')\n parentToolbarElem.classList.remove('fixed-toolbar--hide')\n parentToolbarElem.classList.add('fixed-toolbar')\n }\n },\n 50,\n [currentToolbarRef, parentToolbarElem, y],\n )\n\n return (\n <div\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n ref={currentToolbarRef}\n >\n {isEditable && (\n <div className=\"fixed-toolbar__scroll\">\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n toolbarStates={toolbarStates}\n />\n )\n })}\n </div>\n )}\n </div>\n )\n}\n\nconst getParentEditorWithFixedToolbar = (\n editorConfigContext: EditorConfigContextType,\n): EditorConfigContextType | false => {\n if (editorConfigContext.parentEditor?.editorConfig) {\n if (editorConfigContext.parentEditor?.editorConfig.resolvedFeatureMap.has('toolbarFixed')) {\n return editorConfigContext.parentEditor\n } else {\n if (editorConfigContext.parentEditor) {\n return getParentEditorWithFixedToolbar(editorConfigContext.parentEditor)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponent<FixedToolbarFeatureProps> = ({ clientProps }) => {\n const [currentEditor] = useLexicalComposerContext()\n const editorConfigContext = useEditorConfigContext()\n const isEditable = useLexicalEditable()\n if (!isEditable) {\n return null\n }\n\n const { editorConfig: currentEditorConfig } = editorConfigContext\n\n const editor = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editor || currentEditor\n : currentEditor\n\n const editorConfig = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig\n : currentEditorConfig\n\n const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext)\n\n if (clientProps?.disableIfParentHasFixedToolbar) {\n if (parentWithFixedToolbar) {\n return null\n }\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return (\n <FixedToolbar\n anchorElem={document.body}\n clientProps={clientProps}\n editor={editor}\n editorConfig={editorConfig}\n parentWithFixedToolbar={parentWithFixedToolbar}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,cAAc,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AASxB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,0CAA0C,QAAQ;AAC3D,OAAO;AAEP,SAASC,gBAAgB;EACvBC,MAAM;EACNC,UAAU;EACVC,MAAM;EACNC,OAAO;EACPC;AAAI,CAOL;EACC,IAAIA,IAAA,CAAKC,SAAS,EAAE;IAClB,OACED,IAAA,EAAMC,SAAA,iBACJC,IAAA,CAACF,IAAA,CAAKC,SAAS;MAACJ,UAAA,EAAYA,UAAA;MAAYC,MAAA,EAAQA,MAAA;MAAQE,IAAA,EAAMA;OAAWA,IAAA,CAAKG,GAAG;EAGvF;EAEA,IAAI,CAACH,IAAA,CAAKI,cAAc,EAAE;IACxB,OAAO;EACT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A9E,MAAA,IAAA8E,CAAA,QAAAtE,YAAA,IAAAsE,CAAA,QAAAN,mBAAA;IAMOY,EAAA,GAAAC,MAAA,CAAAC,GAAA;IAAAC,GAAA;MAJX,MAAA5C,sBAAA,GAA+B4B,+BAAA,CAAgCC,mBAAA;MAAA,IAE3D9B,WAAA,EAAAO,8BAAA;QAAA,IACEN,sBAAA;UACKyC,EAAA;UAAA,MAAAG,GAAA;QAAA;MAAA;MAAA,KAIN/E,YAAA,EAAA8B,QAAA,EAAAC,YAAA,EAAAC,MAAA,EAAAf,MAAA;QACI2D,EAAA;QAAA,MAAAG,GAAA;MAAA;MAIPJ,EAAA,GAAA/E,IAAA,CAAAqC,YAAA;QAAA1C,UAAA,EAAAyF,QAAA,CAAAC,IAAA;QAAA/C,WAAA;QAAA1C,MAAA;QAAAQ,YAAA;QAAAmC;MAAA,C;;;;;;;;;;;;;;;SAAAwC,E;CAQJ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","getTranslation","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","useToolbarKeyboardNavigation","useToolbarStates","useRedirectVerticalWheelToHorizontalScroll","ButtonGroupItem","active","anchorElem","editor","enabled","item","Component","_jsx","key","ChildComponent","ToolbarGroupComponent","t0","$","editorConfig","group","index","toolbarStates","i18n","fieldProps","t1","featureClientSchemaMap","schemaPath","t2","groupStates","get","groupState","activeItems","t3","bb0","type","undefined","activeItem","DropdownIcon","t4","length","t","count","label","substring","t5","dropdownLabel","t6","t7","features","toolbarFixed","groups","itemStates","_jsxs","className","children","items","Icon","itemsContainerClassNames","map","item_0","itemState","FixedToolbar","clientProps","parentWithFixedToolbar","currentToolbarRef","useRef","keyboardNavigationOptions","toolbarRef","isEditable","y","parentToolbarElem","disableIfParentHasFixedToolbar","parentEditorElem","editorContainerRef","current","sibling","previousElementSibling","classList","contains","currentToolbarElem","currentRect","getBoundingClientRect","parentRect","overlapping","bottom","top","remove","add","field","path","onFocus","event","stopPropagation","ref","role","tabIndex","i","getParentEditorWithFixedToolbar","editorConfigContext","parentEditor","resolvedFeatureMap","has","FixedToolbarPlugin","currentEditor","currentEditorConfig","applyToFocusedEditor","focusedEditor","Symbol","for","document","body"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ToolbarStates } from '../../../shared/useToolbarStates.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\nimport type { FixedToolbarFeatureProps } from '../../server/index.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\nimport { useToolbarKeyboardNavigation } from '../../../shared/useToolbarKeyboardNavigation.js'\nimport { useToolbarStates } from '../../../shared/useToolbarStates.js'\nimport { useRedirectVerticalWheelToHorizontalScroll } from './horizontalWheelScroll.js'\nimport './index.css'\n\nfunction ButtonGroupItem({\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}): 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 if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton active={active} editor={editor} enabled={enabled} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n toolbarStates,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n toolbarStates: ToolbarStates\n}): React.ReactNode {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const groupState = toolbarStates.groupStates.get(group.key)\n\n const DropdownIcon = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItem = groupState?.activeItems?.[0]\n if (activeItem) {\n return activeItem.ChildComponent\n }\n return group.ChildComponent\n }, [group, groupState?.activeItems])\n\n const dropdownLabel = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItems = groupState?.activeItems\n if (!activeItems?.length) {\n return undefined\n }\n if (activeItems.length > 1) {\n return i18n.t('lexical:general:toolbarItemsActive', { count: activeItems.length })\n }\n const item = activeItems[0]!\n let label = item.key\n if (item.label) {\n label =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n return label\n }, [group, groupState?.activeItems, i18n, featureClientSchemaMap, schemaPath])\n\n return (\n <div\n className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`}\n data-toolbar-group-key={group.key}\n key={group.key}\n >\n {group.type === 'dropdown' && group.items.length && groupState ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n groupState={groupState}\n Icon={DropdownIcon}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n />\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n const itemState = toolbarStates.itemStates.get(item.key)\n return (\n <ButtonGroupItem\n active={itemState?.active ?? false}\n anchorElem={anchorElem}\n editor={editor}\n enabled={itemState?.enabled ?? true}\n item={item}\n key={item.key}\n />\n )\n })\n : null}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n clientProps,\n editor,\n editorConfig,\n parentWithFixedToolbar,\n}: {\n anchorElem: HTMLElement\n clientProps?: FixedToolbarFeatureProps\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n parentWithFixedToolbar: EditorConfigContextType | false\n}): React.ReactNode {\n const currentToolbarRef = React.useRef<HTMLDivElement>(null)\n const keyboardNavigationOptions = useMemo(() => ({ toolbarRef: currentToolbarRef }), [])\n const { fieldProps } = useEditorConfigContext()\n const { i18n } = useTranslation()\n\n useToolbarKeyboardNavigation(keyboardNavigationOptions)\n\n const isEditable = useLexicalEditable()\n\n const { y } = useScrollInfo()\n\n useRedirectVerticalWheelToHorizontalScroll()\n\n const toolbarStates = useToolbarStates(editor, editorConfig?.features?.toolbarFixed?.groups)\n\n // Memoize the parent toolbar element\n const parentToolbarElem = useMemo(() => {\n if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {\n return null\n }\n\n const parentEditorElem = parentWithFixedToolbar.editorContainerRef.current\n let sibling = parentEditorElem.previousElementSibling\n while (sibling) {\n if (sibling.classList.contains('fixed-toolbar')) {\n return sibling\n }\n sibling = sibling.previousElementSibling\n }\n return null\n }, [clientProps?.disableIfParentHasFixedToolbar, parentWithFixedToolbar])\n\n useThrottledEffect(\n () => {\n if (!parentToolbarElem) {\n // this also checks for clientProps?.disableIfParentHasFixedToolbar indirectly, see the parentToolbarElem useMemo\n return\n }\n const currentToolbarElem = currentToolbarRef.current\n if (!currentToolbarElem) {\n return\n }\n\n const currentRect = currentToolbarElem.getBoundingClientRect()\n const parentRect = parentToolbarElem.getBoundingClientRect()\n\n // we only need to check for vertical overlap\n const overlapping = !(\n currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom\n )\n\n if (overlapping) {\n currentToolbarElem.classList.remove('fixed-toolbar')\n currentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--overlapping')\n parentToolbarElem.classList.remove('fixed-toolbar')\n parentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--hide')\n } else {\n if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {\n return\n }\n currentToolbarElem.classList.remove('fixed-toolbar--overlapping')\n currentToolbarElem.classList.add('fixed-toolbar')\n parentToolbarElem.classList.remove('fixed-toolbar--hide')\n parentToolbarElem.classList.add('fixed-toolbar')\n }\n },\n 50,\n [currentToolbarRef, parentToolbarElem, y],\n )\n\n return (\n <div\n aria-label={\n getTranslation(fieldProps.field.label || fieldProps.path, i18n) || fieldProps.path\n }\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n ref={currentToolbarRef}\n role=\"toolbar\"\n >\n {isEditable && (\n <div className=\"fixed-toolbar__scroll\" tabIndex={-1}>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n toolbarStates={toolbarStates}\n />\n )\n })}\n </div>\n )}\n </div>\n )\n}\n\nconst getParentEditorWithFixedToolbar = (\n editorConfigContext: EditorConfigContextType,\n): EditorConfigContextType | false => {\n if (editorConfigContext.parentEditor?.editorConfig) {\n if (editorConfigContext.parentEditor?.editorConfig.resolvedFeatureMap.has('toolbarFixed')) {\n return editorConfigContext.parentEditor\n } else {\n if (editorConfigContext.parentEditor) {\n return getParentEditorWithFixedToolbar(editorConfigContext.parentEditor)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponent<FixedToolbarFeatureProps> = ({ clientProps }) => {\n const [currentEditor] = useLexicalComposerContext()\n const editorConfigContext = useEditorConfigContext()\n const isEditable = useLexicalEditable()\n if (!isEditable) {\n return null\n }\n\n const { editorConfig: currentEditorConfig } = editorConfigContext\n\n const editor = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editor || currentEditor\n : currentEditor\n\n const editorConfig = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig\n : currentEditorConfig\n\n const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext)\n\n if (clientProps?.disableIfParentHasFixedToolbar) {\n if (parentWithFixedToolbar) {\n return null\n }\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return (\n <FixedToolbar\n anchorElem={document.body}\n clientProps={clientProps}\n editor={editor}\n editorConfig={editorConfig}\n parentWithFixedToolbar={parentWithFixedToolbar}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,cAAc,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AASxB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,gBAAgB,QAAQ;AACjC,SAASC,0CAA0C,QAAQ;AAC3D,OAAO;AAEP,SAASC,gBAAgB;EACvBC,MAAM;EACNC,UAAU;EACVC,MAAM;EACNC,OAAO;EACPC;AAAI,CAOL;EACC,IAAIA,IAAA,CAAKC,SAAS,EAAE;IAClB,OACED,IAAA,EAAMC,SAAA,iBACJC,IAAA,CAACF,IAAA,CAAKC,SAAS;MAACJ,UA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MAAA,CAAAC,GAAA;IAAA3E,GAAA;MAJX,MAAA8B,sBAAA,GAA+BkC,+BAAA,CAAgCC,mBAAA;MAE/D,IAAIpC,WAAA,EAAAS,8BAAa;QACf,IAAIR,sBAAA;UACKpC,EAAA;UAAA,MAAAM,GAAA;QAAA;MACT;MAGF,IAAI,CAACf,YAAA,EAAA8B,QAAwB,EAAAC,YAAc,EAAAC,MAAQ,EAAAX,MAAA;QAC1CZ,EAAA;QAAA,MAAAM,GAAA;MAAA;MAIPT,EAAA,GAAAZ,IAAA,CAACiD,YAAA;QAAAtD,UAAA,EACasG,QAAA,CAAAC,IAAa;QAAAhD,WAAA;QAAAtD,MAAA;QAAAU,YAAA;QAAA6C;;;;;;;;;;;;;;;;SAD3BvC,E;CAQJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/toolbars/inline/client/Toolbar/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AAU3E,OAAO,aAAa,CAAA;AA6WpB,eAAO,MAAM,mBAAmB,EAAE,yBAAyB,CAAC,SAAS,CAIpE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/toolbars/inline/client/Toolbar/index.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AAW3E,OAAO,aAAa,CAAA;AA0XpB,eAAO,MAAM,mBAAmB,EAAE,yBAAyB,CAAC,SAAS,CAIpE,CAAA"}
@@ -5,6 +5,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
5
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
6
6
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
7
7
  import { mergeRegister } from '@lexical/utils';
8
+ import { getTranslation } from '@payloadcms/translations';
9
+ import { useTranslation } from '@payloadcms/ui';
8
10
  import { $getSelection, $isRangeSelection, $isTextNode, $onUpdate, COMMAND_PRIORITY_LOW, getDOMSelection, SELECTION_CHANGE_COMMAND } from 'lexical';
9
11
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
10
12
  import * as React from 'react';
@@ -14,6 +16,7 @@ import { getDOMRangeRect } from '../../../../../lexical/utils/getDOMRangeRect.js
14
16
  import { setFloatingElemPosition } from '../../../../../lexical/utils/setFloatingElemPosition.js';
15
17
  import { ToolbarButton } from '../../../shared/ToolbarButton/index.js';
16
18
  import { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js';
19
+ import { useToolbarKeyboardNavigation } from '../../../shared/useToolbarKeyboardNavigation.js';
17
20
  import { useToolbarStates } from '../../../shared/useToolbarStates.js';
18
21
  import './index.css';
19
22
  function ButtonGroupItem({
@@ -41,52 +44,94 @@ function ButtonGroupItem({
41
44
  children: /*#__PURE__*/_jsx(item.ChildComponent, {})
42
45
  }, item.key);
43
46
  }
44
- function ToolbarGroupComponent({
45
- anchorElem,
46
- editor,
47
- group,
48
- index,
49
- toolbarStates
50
- }) {
47
+ function ToolbarGroupComponent(t0) {
48
+ const $ = _c(13);
49
+ const {
50
+ anchorElem,
51
+ editor,
52
+ group,
53
+ index,
54
+ toolbarStates
55
+ } = t0;
51
56
  const {
52
57
  editorConfig
53
58
  } = useEditorConfigContext();
54
- const groupState = toolbarStates.groupStates.get(group.key);
55
- const DropdownIcon = useMemo(() => {
56
- if (group.type !== 'dropdown') {
57
- return undefined;
59
+ let t1;
60
+ if ($[0] !== group.key || $[1] !== toolbarStates.groupStates) {
61
+ t1 = toolbarStates.groupStates.get(group.key);
62
+ $[0] = group.key;
63
+ $[1] = toolbarStates.groupStates;
64
+ $[2] = t1;
65
+ } else {
66
+ t1 = $[2];
67
+ }
68
+ const groupState = t1;
69
+ groupState?.activeItems;
70
+ let t2;
71
+ bb0: {
72
+ if (group.type !== "dropdown") {
73
+ t2 = undefined;
74
+ break bb0;
58
75
  }
59
76
  const activeItem = groupState?.activeItems?.[0];
60
- return activeItem?.ChildComponent ?? group.ChildComponent;
61
- }, [group, groupState?.activeItems]);
62
- return /*#__PURE__*/_jsxs("div", {
63
- className: `inline-toolbar-popup__group inline-toolbar-popup__group-${group.key}`,
64
- "data-toolbar-group-key": group.key,
65
- children: [group.type === 'dropdown' && group.items.length && groupState ? /*#__PURE__*/_jsx(ToolbarDropdown, {
66
- anchorElem: anchorElem,
67
- editor: editor,
68
- group: group,
69
- groupState: groupState,
70
- Icon: DropdownIcon
71
- }) : null, group.type === 'buttons' && group.items.length ? group.items.map(item => {
72
- const itemState = toolbarStates.itemStates.get(item.key);
73
- return /*#__PURE__*/_jsx(ButtonGroupItem, {
74
- active: itemState?.active ?? false,
75
- anchorElem: anchorElem,
76
- editor: editor,
77
- enabled: itemState?.enabled ?? true,
78
- item: item
79
- }, item.key);
80
- }) : null, index < editorConfig.features.toolbarInline?.groups.length - 1 && /*#__PURE__*/_jsx("div", {
81
- className: "divider"
82
- })]
83
- }, group.key);
77
+ t2 = activeItem?.ChildComponent ?? group.ChildComponent;
78
+ }
79
+ const DropdownIcon = t2;
80
+ const t3 = `inline-toolbar-popup__group inline-toolbar-popup__group-${group.key}`;
81
+ let t4;
82
+ if ($[3] !== DropdownIcon || $[4] !== anchorElem || $[5] !== editor || $[6] !== editorConfig.features.toolbarInline?.groups.length || $[7] !== group || $[8] !== groupState || $[9] !== index || $[10] !== t3 || $[11] !== toolbarStates.itemStates) {
83
+ t4 = _jsxs("div", {
84
+ className: t3,
85
+ "data-toolbar-group-key": group.key,
86
+ children: [group.type === "dropdown" && group.items.length && groupState ? _jsx(ToolbarDropdown, {
87
+ anchorElem,
88
+ editor,
89
+ group,
90
+ groupState,
91
+ Icon: DropdownIcon
92
+ }) : null, group.type === "buttons" && group.items.length ? group.items.map(item => {
93
+ const itemState = toolbarStates.itemStates.get(item.key);
94
+ return _jsx(ButtonGroupItem, {
95
+ active: itemState?.active ?? false,
96
+ anchorElem,
97
+ editor,
98
+ enabled: itemState?.enabled ?? true,
99
+ item
100
+ }, item.key);
101
+ }) : null, index < editorConfig.features.toolbarInline?.groups.length - 1 && _jsx("div", {
102
+ className: "divider"
103
+ })]
104
+ }, group.key);
105
+ $[3] = DropdownIcon;
106
+ $[4] = anchorElem;
107
+ $[5] = editor;
108
+ $[6] = editorConfig.features.toolbarInline?.groups.length;
109
+ $[7] = group;
110
+ $[8] = groupState;
111
+ $[9] = index;
112
+ $[10] = t3;
113
+ $[11] = toolbarStates.itemStates;
114
+ $[12] = t4;
115
+ } else {
116
+ t4 = $[12];
117
+ }
118
+ return t4;
84
119
  }
85
120
  function InlineToolbar({
86
121
  anchorElem,
87
122
  editor
88
123
  }) {
89
124
  const floatingToolbarRef = useRef(null);
125
+ const keyboardNavigationOptions = useMemo(() => ({
126
+ toolbarRef: floatingToolbarRef
127
+ }), []);
128
+ const {
129
+ fieldProps
130
+ } = useEditorConfigContext();
131
+ const {
132
+ i18n
133
+ } = useTranslation();
134
+ useToolbarKeyboardNavigation(keyboardNavigationOptions);
90
135
  const caretRef = useRef(null);
91
136
  const {
92
137
  editorConfig
@@ -208,8 +253,10 @@ function InlineToolbar({
208
253
  }, COMMAND_PRIORITY_LOW));
209
254
  }, [editor, $updateTextFormatFloatingToolbar]);
210
255
  return /*#__PURE__*/_jsxs("div", {
256
+ "aria-label": getTranslation(fieldProps.field.label || fieldProps.path, i18n) || fieldProps.path,
211
257
  className: "inline-toolbar-popup",
212
258
  ref: floatingToolbarRef,
259
+ role: "toolbar",
213
260
  children: [/*#__PURE__*/_jsx("div", {
214
261
  className: "caret",
215
262
  ref: caretRef