@atlaskit/editor-plugin-floating-toolbar 6.0.2 → 6.1.0

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 (32) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/floatingToolbarPlugin.js +2 -2
  3. package/dist/cjs/ui/Dropdown.js +11 -7
  4. package/dist/cjs/ui/DropdownMenu.js +3 -3
  5. package/dist/cjs/ui/ExtensionsPlaceholder.js +19 -8
  6. package/dist/cjs/ui/ScrollButtons.js +6 -3
  7. package/dist/cjs/ui/Toolbar.js +34 -24
  8. package/dist/es2019/floatingToolbarPlugin.js +2 -2
  9. package/dist/es2019/ui/Dropdown.js +11 -7
  10. package/dist/es2019/ui/DropdownMenu.js +3 -3
  11. package/dist/es2019/ui/ExtensionsPlaceholder.js +19 -8
  12. package/dist/es2019/ui/ScrollButtons.js +6 -3
  13. package/dist/es2019/ui/Toolbar.js +34 -24
  14. package/dist/esm/floatingToolbarPlugin.js +2 -2
  15. package/dist/esm/ui/Dropdown.js +11 -7
  16. package/dist/esm/ui/DropdownMenu.js +3 -3
  17. package/dist/esm/ui/ExtensionsPlaceholder.js +19 -8
  18. package/dist/esm/ui/ScrollButtons.js +6 -3
  19. package/dist/esm/ui/Toolbar.js +34 -24
  20. package/dist/types/floatingToolbarPluginType.d.ts +3 -1
  21. package/dist/types/ui/Dropdown.d.ts +1 -0
  22. package/dist/types/ui/DropdownMenu.d.ts +1 -0
  23. package/dist/types/ui/ExtensionsPlaceholder.d.ts +1 -0
  24. package/dist/types/ui/ScrollButtons.d.ts +2 -1
  25. package/dist/types/ui/Toolbar.d.ts +1 -1
  26. package/dist/types-ts4.5/floatingToolbarPluginType.d.ts +3 -1
  27. package/dist/types-ts4.5/ui/Dropdown.d.ts +1 -0
  28. package/dist/types-ts4.5/ui/DropdownMenu.d.ts +1 -0
  29. package/dist/types-ts4.5/ui/ExtensionsPlaceholder.d.ts +1 -0
  30. package/dist/types-ts4.5/ui/ScrollButtons.d.ts +2 -1
  31. package/dist/types-ts4.5/ui/Toolbar.d.ts +1 -1
  32. package/package.json +6 -6
@@ -30,7 +30,7 @@ import { Input } from './Input';
30
30
  import { ScrollButton } from './ScrollButton';
31
31
  import { ScrollButtons } from './ScrollButtons';
32
32
  import Select from './Select';
33
- export function groupItems(items) {
33
+ export function groupItems(items, areAnyNewToolbarFlagsEnabled) {
34
34
  const groupItems = items.reduce((accumulator, item, i) => {
35
35
  const {
36
36
  finalOutput,
@@ -54,7 +54,7 @@ export function groupItems(items) {
54
54
  } else {
55
55
  finalOutput.push(item);
56
56
  }
57
- } else if (item.type === 'separator' && areToolbarFlagsEnabled()) {
57
+ } else if (item.type === 'separator' && areAnyNewToolbarFlagsEnabled) {
58
58
  var _items;
59
59
  const isLeadingSeparator = i === 0;
60
60
  const isTrailingSeparator = i === items.length - 1;
@@ -89,7 +89,7 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
89
89
  intl
90
90
  }) => {
91
91
  const emojiAndColourPickerMountPoint = scrollable ? popupsMountPoint || (editorView === null || editorView === void 0 ? void 0 : editorView.dom.closest('.fabric-editor-popup-scroll-parent')) || (editorView === null || editorView === void 0 ? void 0 : editorView.dom.closest('.ak-editor-content-area')) || undefined : popupsMountPoint;
92
- const isNewEditorToolbarEnabled = areToolbarFlagsEnabled();
92
+ const areAnyNewToolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
93
93
  const renderItem = (item, idx) => {
94
94
  var _api$contextPanel, _api$extension;
95
95
  switch (item.type) {
@@ -159,7 +159,8 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
159
159
  ariaLabel: expValEquals('platform_editor_floating_toolbar_button_aria_label', 'isEnabled', true) ? item === null || item === void 0 ? void 0 : item.ariaLabel : undefined,
160
160
  pulse: item.pulse,
161
161
  spotlightConfig: item.spotlightConfig,
162
- interactionName: item.interactionName
162
+ interactionName: item.interactionName,
163
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
163
164
  }, item.showTitle && item.title);
164
165
  case 'input':
165
166
  return jsx(Input, {
@@ -177,7 +178,7 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
177
178
  }
178
179
  case 'overflow-dropdown':
179
180
  return jsx(Dropdown, {
180
- alignX: editorExperiment('platform_editor_toolbar_aifc', true) ? 'right' : undefined,
181
+ alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
181
182
  key: idx,
182
183
  title: intl.formatMessage(commonMessages.viewMore),
183
184
  icon: jsx(ShowMoreHorizontalIcon, {
@@ -199,7 +200,8 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
199
200
  setDisableParentScroll: scrollable ? setDisableScroll : undefined,
200
201
  dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && `${item.id}-dropdownList`,
201
202
  alignDropdownWithToolbar: items.length === 1,
202
- onClick: item.onClick
203
+ onClick: item.onClick,
204
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
203
205
  });
204
206
  case 'dropdown':
205
207
  const DropdownIcon = item.icon;
@@ -233,7 +235,8 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
233
235
  onMount: item.onMount,
234
236
  onClick: item.onClick,
235
237
  pulse: item.pulse,
236
- shouldFitContainer: item.shouldFitContainer
238
+ shouldFitContainer: item.shouldFitContainer,
239
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
237
240
  });
238
241
  case 'select':
239
242
  if (item.selectType === 'list') {
@@ -318,22 +321,25 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
318
321
  popupsBoundariesElement: popupsBoundariesElement,
319
322
  popupsScrollableElement: popupsScrollableElement,
320
323
  alignDropdownWithToolbar: items.length === 1,
321
- scrollable: scrollable
324
+ scrollable: scrollable,
325
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
322
326
  });
323
327
  case 'separator':
324
- if (isNewEditorToolbarEnabled) {
328
+ if (areAnyNewToolbarFlagsEnabled) {
325
329
  return item.fullHeight ? jsx(Separator, {
326
330
  key: idx,
327
- fullHeight: true
331
+ fullHeight: true,
332
+ areAnyNewToolbarFlagsEnabled: true
328
333
  }) : null;
329
334
  }
330
335
  return jsx(Separator, {
331
336
  key: idx,
332
- fullHeight: item.fullHeight
337
+ fullHeight: item.fullHeight,
338
+ areAnyNewToolbarFlagsEnabled: false
333
339
  });
334
340
  }
335
341
  };
336
- const groupedItems = groupItems(items.filter(item => !item.hidden));
342
+ const groupedItems = groupItems(items.filter(item => !item.hidden), areAnyNewToolbarFlagsEnabled);
337
343
  return jsx(ButtonGroup, {
338
344
  testId: "editor-floating-toolbar-items"
339
345
  }, groupedItems.map((element, index) => {
@@ -343,7 +349,7 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
343
349
  // Ignored via go/ees005
344
350
  // eslint-disable-next-line react/no-array-index-key
345
351
  key: index,
346
- css: isNewEditorToolbarEnabled ? buttonGroupStylesNew : buttonGroupStyles,
352
+ css: areAnyNewToolbarFlagsEnabled ? buttonGroupStylesNew : buttonGroupStyles,
347
353
  role: "radiogroup",
348
354
  "aria-label": groupLabel !== null && groupLabel !== void 0 ? groupLabel : undefined,
349
355
  "data-testid": "editor-floating-toolbar-grouped-buttons"
@@ -374,7 +380,7 @@ const buttonGroupStylesNew = css({
374
380
  });
375
381
 
376
382
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
377
- const toolbarContainer = (scrollable, hasSelect, firstElementIsSelect) => css({
383
+ const toolbarContainer = (areAnyNewToolbarFlagsEnabled, scrollable, hasSelect, firstElementIsSelect) => css({
378
384
  backgroundColor: "var(--ds-surface-overlay, white)",
379
385
  borderRadius: "var(--ds-radius-small, 3px)",
380
386
  boxShadow: `var(--ds-shadow-overlay, ${`0 0 1px rgba(9, 30, 66, 0.31), 0 4px 8px -2px rgba(9, 30, 66, 0.25)`})`,
@@ -404,7 +410,7 @@ css({
404
410
  overflow: 'hidden'
405
411
  }) :
406
412
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
407
- areToolbarFlagsEnabled() ?
413
+ areAnyNewToolbarFlagsEnabled ?
408
414
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
409
415
  css({
410
416
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
@@ -427,7 +433,7 @@ css({
427
433
  paddingLeft: "var(--ds-space-050, 4px)"
428
434
  })),
429
435
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
430
- areToolbarFlagsEnabled() ?
436
+ areAnyNewToolbarFlagsEnabled ?
431
437
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
432
438
  css({
433
439
  minHeight: "var(--ds-space-500, 40px)"
@@ -437,7 +443,8 @@ css({
437
443
  const toolbarOverflow = ({
438
444
  scrollable,
439
445
  scrollDisabled,
440
- firstElementIsSelect
446
+ firstElementIsSelect,
447
+ areAnyNewToolbarFlagsEnabled
441
448
  }) => css(
442
449
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
443
450
  scrollable ?
@@ -478,7 +485,7 @@ css({
478
485
  }
479
486
  },
480
487
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
481
- areToolbarFlagsEnabled() ?
488
+ areAnyNewToolbarFlagsEnabled ?
482
489
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
483
490
  css({
484
491
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
@@ -604,6 +611,7 @@ class Toolbar extends Component {
604
611
  this.resetStyling();
605
612
  }
606
613
  render() {
614
+ var _this$props$api2;
607
615
  const {
608
616
  items,
609
617
  className,
@@ -612,7 +620,7 @@ class Toolbar extends Component {
612
620
  scrollable,
613
621
  mediaAssistiveMessage
614
622
  } = this.props;
615
- const isNewEditorToolbarEnabled = areToolbarFlagsEnabled();
623
+ const areAnyNewToolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean((_this$props$api2 = this.props.api) === null || _this$props$api2 === void 0 ? void 0 : _this$props$api2.toolbar));
616
624
  if (!items || !items.length) {
617
625
  return null;
618
626
  }
@@ -633,18 +641,18 @@ class Toolbar extends Component {
633
641
  intl: intl
634
642
  }, jsx("div", {
635
643
  ref: this.toolbarContainerRef,
636
- css: () => [toolbarContainer(scrollable, hasSelect !== undefined, firstElementIsSelect)],
644
+ css: () => [toolbarContainer(areAnyNewToolbarFlagsEnabled, scrollable, hasSelect !== undefined, firstElementIsSelect)],
637
645
  "aria-label": intl.formatMessage(messages.floatingToolbarAriaLabel),
638
646
  role: "toolbar",
639
647
  "data-testid": "editor-floating-toolbar"
640
648
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
641
649
  ,
642
650
  className: className,
643
- onMouseDown: isNewEditorToolbarEnabled ? this.captureMouseEvent : undefined
651
+ onMouseDown: areAnyNewToolbarFlagsEnabled ? this.captureMouseEvent : undefined
644
652
  }, jsx(Announcer, {
645
653
  text: mediaAssistiveMessage ? `${mediaAssistiveMessage}, ${intl.formatMessage(messages.floatingToolbarAnnouncer)}` : intl.formatMessage(messages.floatingToolbarAnnouncer),
646
654
  delay: 250
647
- }), scrollable && isNewEditorToolbarEnabled && jsx(ScrollButton, {
655
+ }), scrollable && areAnyNewToolbarFlagsEnabled && jsx(ScrollButton, {
648
656
  intl: intl,
649
657
  scrollContainerRef: this.scrollContainerRef,
650
658
  node: node,
@@ -656,6 +664,7 @@ class Toolbar extends Component {
656
664
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
657
665
  ,
658
666
  css: toolbarOverflow({
667
+ areAnyNewToolbarFlagsEnabled,
659
668
  scrollable,
660
669
  scrollDisabled: this.state.scrollDisabled,
661
670
  firstElementIsSelect
@@ -667,7 +676,7 @@ class Toolbar extends Component {
667
676
  setDisableScroll: this.setDisableScroll.bind(this),
668
677
  mountRef: this.mountRef,
669
678
  mounted: this.state.mounted
670
- }))), scrollable && (isNewEditorToolbarEnabled ? jsx(ScrollButton, {
679
+ }))), scrollable && (areAnyNewToolbarFlagsEnabled ? jsx(ScrollButton, {
671
680
  intl: intl,
672
681
  scrollContainerRef: this.scrollContainerRef,
673
682
  node: node,
@@ -677,7 +686,8 @@ class Toolbar extends Component {
677
686
  intl: intl,
678
687
  scrollContainerRef: this.scrollContainerRef,
679
688
  node: node,
680
- disabled: this.state.scrollDisabled
689
+ disabled: this.state.scrollDisabled,
690
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
681
691
  }))), jsx("div", {
682
692
  ref: this.mountRef
683
693
  })));
@@ -235,7 +235,7 @@ export function ContentComponent(_ref5) {
235
235
  node = configWithNodeInfo.node;
236
236
 
237
237
  // When the new inline editor-toolbar is enabled, suppress floating toolbar for text selections.
238
- if (editorExperiment('platform_editor_toolbar_aifc', true)) {
238
+ if (Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar) && editorExperiment('platform_editor_toolbar_aifc', true)) {
239
239
  var selection = editorView.state.selection;
240
240
  var isCellSelection = '$anchorCell' in selection && !selection.empty;
241
241
  var isTextSelected = selection instanceof TextSelection && !selection.empty;
@@ -290,7 +290,7 @@ export function ContentComponent(_ref5) {
290
290
  return toolbarItemViewModeProp in item && !!item[toolbarItemViewModeProp];
291
291
  });
292
292
  }
293
- if (areToolbarFlagsEnabled()) {
293
+ if (areToolbarFlagsEnabled(Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar))) {
294
294
  var _items2;
295
295
  // Consolidate floating toolbar items
296
296
  var toolbarItemsArray = Array.isArray(items) ? items : (_items2 = items) === null || _items2 === void 0 ? void 0 : _items2(node);
@@ -18,7 +18,6 @@ import React, { Component } from 'react';
18
18
 
19
19
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
20
20
  import { css, jsx } from '@emotion/react';
21
- import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
22
21
  import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
23
22
  import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
24
23
  import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
@@ -71,13 +70,15 @@ var Dropdown = /*#__PURE__*/function (_Component) {
71
70
  var _this$props = _this.props,
72
71
  showSelected = _this$props.showSelected,
73
72
  dispatchCommand = _this$props.dispatchCommand,
74
- editorView = _this$props.editorView;
73
+ editorView = _this$props.editorView,
74
+ areAnyNewToolbarFlagsEnabled = _this$props.areAnyNewToolbarFlagsEnabled;
75
75
  return jsx(DropdownMenu, {
76
76
  hide: _this.hide,
77
77
  dispatchCommand: dispatchCommand,
78
78
  items: options,
79
79
  showSelected: showSelected,
80
- editorView: editorView
80
+ editorView: editorView,
81
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
81
82
  });
82
83
  });
83
84
  _defineProperty(_this, "toggleOpen", function () {
@@ -154,7 +155,8 @@ var Dropdown = /*#__PURE__*/function (_Component) {
154
155
  pulse = _this$props2.pulse,
155
156
  spotlightConfig = _this$props2.spotlightConfig,
156
157
  shouldFitContainer = _this$props2.shouldFitContainer,
157
- alignX = _this$props2.alignX;
158
+ alignX = _this$props2.alignX,
159
+ areAnyNewToolbarFlagsEnabled = _this$props2.areAnyNewToolbarFlagsEnabled;
158
160
  var trigger;
159
161
  if (icon) {
160
162
  var TriggerIcon = hideExpandIcon ? icon : jsx(CompositeIcon, {
@@ -169,10 +171,11 @@ var Dropdown = /*#__PURE__*/function (_Component) {
169
171
  selected: isOpen,
170
172
  disabled: disabled,
171
173
  tooltipContent: tooltip,
172
- ariaHasPopup: areToolbarFlagsEnabled() ? true : undefined,
174
+ ariaHasPopup: areAnyNewToolbarFlagsEnabled ? true : undefined,
173
175
  onMount: onMount,
174
176
  pulse: pulse,
175
- spotlightConfig: spotlightConfig
177
+ spotlightConfig: spotlightConfig,
178
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
176
179
  });
177
180
  } else {
178
181
  trigger = jsx(Button, {
@@ -196,7 +199,8 @@ var Dropdown = /*#__PURE__*/function (_Component) {
196
199
  areaControls: dropdownListId,
197
200
  onMount: onMount,
198
201
  pulse: pulse,
199
- spotlightConfig: spotlightConfig
202
+ spotlightConfig: spotlightConfig,
203
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
200
204
  }, title);
201
205
  }
202
206
 
@@ -10,7 +10,6 @@ import { css, jsx } from '@emotion/react';
10
10
 
11
11
  import { injectIntl } from 'react-intl-next';
12
12
  import { DropdownMenuItem, DropdownSeparator } from '@atlaskit/editor-common/floating-toolbar';
13
- import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
14
13
  import { HeadingItem } from '@atlaskit/menu';
15
14
  export var menuItemDimensions = {
16
15
  width: 175,
@@ -48,8 +47,9 @@ var Dropdown = /*#__PURE__*/memo(function (props) {
48
47
  intl = props.intl,
49
48
  editorView = props.editorView,
50
49
  _props$showSelected = props.showSelected,
51
- showSelected = _props$showSelected === void 0 ? true : _props$showSelected;
52
- if (areToolbarFlagsEnabled()) {
50
+ showSelected = _props$showSelected === void 0 ? true : _props$showSelected,
51
+ areAnyNewToolbarFlagsEnabled = props.areAnyNewToolbarFlagsEnabled;
52
+ if (areAnyNewToolbarFlagsEnabled) {
53
53
  return jsx("div", {
54
54
  css: menuContainerStyles,
55
55
  role: "menu"
@@ -46,7 +46,8 @@ var resolveExtensionIcon = /*#__PURE__*/function () {
46
46
  var ExtensionButton = function ExtensionButton(props) {
47
47
  var item = props.item,
48
48
  node = props.node,
49
- extensionApi = props.extensionApi;
49
+ extensionApi = props.extensionApi,
50
+ areAnyNewToolbarFlagsEnabled = props.areAnyNewToolbarFlagsEnabled;
50
51
  var ButtonIcon = React.useMemo(function () {
51
52
  return item.icon ? Loadable({
52
53
  // Ignored via go/ees005
@@ -101,7 +102,8 @@ var ExtensionButton = function ExtensionButton(props) {
101
102
  onClick: onClick,
102
103
  tooltipContent: item.tooltip,
103
104
  tooltipStyle: item.tooltipStyle,
104
- disabled: item.disabled
105
+ disabled: item.disabled,
106
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
105
107
  }, item.label);
106
108
  };
107
109
  export var ExtensionsPlaceholder = function ExtensionsPlaceholder(props) {
@@ -117,7 +119,8 @@ export var ExtensionsPlaceholder = function ExtensionsPlaceholder(props) {
117
119
  popupsMountPoint = props.popupsMountPoint,
118
120
  popupsBoundariesElement = props.popupsBoundariesElement,
119
121
  popupsScrollableElement = props.popupsScrollableElement,
120
- alignDropdownWithToolbar = props.alignDropdownWithToolbar;
122
+ alignDropdownWithToolbar = props.alignDropdownWithToolbar,
123
+ areAnyNewToolbarFlagsEnabled = props.areAnyNewToolbarFlagsEnabled;
121
124
  // Ignored via go/ees005
122
125
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
126
  var _useState = useState([]),
@@ -175,7 +178,9 @@ export var ExtensionsPlaceholder = function ExtensionsPlaceholder(props) {
175
178
  // but count fragment as 1 child, so here we create the children manually.
176
179
  var children = [];
177
180
  if (separator && ['start', 'both'].includes(separator)) {
178
- children.push( /*#__PURE__*/React.createElement(Separator, null));
181
+ children.push( /*#__PURE__*/React.createElement(Separator, {
182
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
183
+ }));
179
184
  }
180
185
  var isNestedTable = fg('platform_editor_use_nested_table_pm_nodes') && isSelectionTableNestedInTable(editorView.state);
181
186
 
@@ -210,7 +215,8 @@ export var ExtensionsPlaceholder = function ExtensionsPlaceholder(props) {
210
215
  footer: item.footer,
211
216
  onMount: item.onMount,
212
217
  onClick: item.onClick,
213
- pulse: item.pulse
218
+ pulse: item.pulse,
219
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
214
220
  }));
215
221
  } else {
216
222
  children.push( /*#__PURE__*/React.createElement(ExtensionButton, {
@@ -218,15 +224,20 @@ export var ExtensionsPlaceholder = function ExtensionsPlaceholder(props) {
218
224
  item: item,
219
225
  editorView: editorView,
220
226
  applyChangeToContextPanel: applyChangeToContextPanel,
221
- extensionApi: extensionApi
227
+ extensionApi: extensionApi,
228
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
222
229
  }));
223
230
  }
224
231
  if (index < extensionItems.length - 1) {
225
- children.push( /*#__PURE__*/React.createElement(Separator, null));
232
+ children.push( /*#__PURE__*/React.createElement(Separator, {
233
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
234
+ }));
226
235
  }
227
236
  });
228
237
  if (separator && ['end', 'both'].includes(separator)) {
229
- children.push( /*#__PURE__*/React.createElement(Separator, null));
238
+ children.push( /*#__PURE__*/React.createElement(Separator, {
239
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
240
+ }));
230
241
  }
231
242
 
232
243
  // eslint-disable-next-line react/no-children-prop
@@ -30,7 +30,8 @@ export var ScrollButtons = function ScrollButtons(_ref) {
30
30
  var intl = _ref.intl,
31
31
  scrollContainerRef = _ref.scrollContainerRef,
32
32
  node = _ref.node,
33
- disabled = _ref.disabled;
33
+ disabled = _ref.disabled,
34
+ areAnyNewToolbarFlagsEnabled = _ref.areAnyNewToolbarFlagsEnabled;
34
35
  var buttonsContainerRef = useRef(null);
35
36
  var _useState = useState(false),
36
37
  _useState2 = _slicedToArray(_useState, 2),
@@ -148,7 +149,8 @@ export var ScrollButtons = function ScrollButtons(_ref) {
148
149
  size: "small"
149
150
  }),
150
151
  onClick: scrollLeft,
151
- disabled: !canScrollLeft || disabled
152
+ disabled: !canScrollLeft || disabled,
153
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
152
154
  }), jsx(Button, {
153
155
  title: intl.formatMessage(messages.floatingToolbarScrollRight),
154
156
  icon: jsx(RightIcon, {
@@ -156,6 +158,7 @@ export var ScrollButtons = function ScrollButtons(_ref) {
156
158
  size: "small"
157
159
  }),
158
160
  onClick: scrollRight,
159
- disabled: !canScrollRight || disabled
161
+ disabled: !canScrollRight || disabled,
162
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
160
163
  })) : null;
161
164
  };
@@ -37,7 +37,7 @@ import { Input } from './Input';
37
37
  import { ScrollButton } from './ScrollButton';
38
38
  import { ScrollButtons } from './ScrollButtons';
39
39
  import Select from './Select';
40
- export function groupItems(items) {
40
+ export function groupItems(items, areAnyNewToolbarFlagsEnabled) {
41
41
  var groupItems = items.reduce(function (accumulator, item, i) {
42
42
  var finalOutput = accumulator.finalOutput,
43
43
  buttonGroup = accumulator.buttonGroup;
@@ -59,7 +59,7 @@ export function groupItems(items) {
59
59
  } else {
60
60
  finalOutput.push(item);
61
61
  }
62
- } else if (item.type === 'separator' && areToolbarFlagsEnabled()) {
62
+ } else if (item.type === 'separator' && areAnyNewToolbarFlagsEnabled) {
63
63
  var _items;
64
64
  var isLeadingSeparator = i === 0;
65
65
  var isTrailingSeparator = i === items.length - 1;
@@ -93,7 +93,7 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
93
93
  api = _ref.api,
94
94
  intl = _ref.intl;
95
95
  var emojiAndColourPickerMountPoint = scrollable ? popupsMountPoint || (editorView === null || editorView === void 0 ? void 0 : editorView.dom.closest('.fabric-editor-popup-scroll-parent')) || (editorView === null || editorView === void 0 ? void 0 : editorView.dom.closest('.ak-editor-content-area')) || undefined : popupsMountPoint;
96
- var isNewEditorToolbarEnabled = areToolbarFlagsEnabled();
96
+ var areAnyNewToolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
97
97
  var renderItem = function renderItem(item, idx) {
98
98
  var _api$contextPanel, _api$extension;
99
99
  switch (item.type) {
@@ -171,7 +171,8 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
171
171
  ariaLabel: expValEquals('platform_editor_floating_toolbar_button_aria_label', 'isEnabled', true) ? item === null || item === void 0 ? void 0 : item.ariaLabel : undefined,
172
172
  pulse: item.pulse,
173
173
  spotlightConfig: item.spotlightConfig,
174
- interactionName: item.interactionName
174
+ interactionName: item.interactionName,
175
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
175
176
  }, item.showTitle && item.title);
176
177
  case 'input':
177
178
  return jsx(Input, {
@@ -193,7 +194,7 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
193
194
  }
194
195
  case 'overflow-dropdown':
195
196
  return jsx(Dropdown, {
196
- alignX: editorExperiment('platform_editor_toolbar_aifc', true) ? 'right' : undefined,
197
+ alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
197
198
  key: idx,
198
199
  title: intl.formatMessage(commonMessages.viewMore),
199
200
  icon: jsx(ShowMoreHorizontalIcon, {
@@ -215,7 +216,8 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
215
216
  setDisableParentScroll: scrollable ? setDisableScroll : undefined,
216
217
  dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && "".concat(item.id, "-dropdownList"),
217
218
  alignDropdownWithToolbar: items.length === 1,
218
- onClick: item.onClick
219
+ onClick: item.onClick,
220
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
219
221
  });
220
222
  case 'dropdown':
221
223
  var DropdownIcon = item.icon;
@@ -249,7 +251,8 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
249
251
  onMount: item.onMount,
250
252
  onClick: item.onClick,
251
253
  pulse: item.pulse,
252
- shouldFitContainer: item.shouldFitContainer
254
+ shouldFitContainer: item.shouldFitContainer,
255
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
253
256
  });
254
257
  case 'select':
255
258
  if (item.selectType === 'list') {
@@ -338,24 +341,27 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
338
341
  popupsBoundariesElement: popupsBoundariesElement,
339
342
  popupsScrollableElement: popupsScrollableElement,
340
343
  alignDropdownWithToolbar: items.length === 1,
341
- scrollable: scrollable
344
+ scrollable: scrollable,
345
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
342
346
  });
343
347
  case 'separator':
344
- if (isNewEditorToolbarEnabled) {
348
+ if (areAnyNewToolbarFlagsEnabled) {
345
349
  return item.fullHeight ? jsx(Separator, {
346
350
  key: idx,
347
- fullHeight: true
351
+ fullHeight: true,
352
+ areAnyNewToolbarFlagsEnabled: true
348
353
  }) : null;
349
354
  }
350
355
  return jsx(Separator, {
351
356
  key: idx,
352
- fullHeight: item.fullHeight
357
+ fullHeight: item.fullHeight,
358
+ areAnyNewToolbarFlagsEnabled: false
353
359
  });
354
360
  }
355
361
  };
356
362
  var groupedItems = groupItems(items.filter(function (item) {
357
363
  return !item.hidden;
358
- }));
364
+ }), areAnyNewToolbarFlagsEnabled);
359
365
  return jsx(ButtonGroup, {
360
366
  testId: "editor-floating-toolbar-items"
361
367
  }, groupedItems.map(function (element, index) {
@@ -365,7 +371,7 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
365
371
  // Ignored via go/ees005
366
372
  // eslint-disable-next-line react/no-array-index-key
367
373
  key: index,
368
- css: isNewEditorToolbarEnabled ? buttonGroupStylesNew : buttonGroupStyles,
374
+ css: areAnyNewToolbarFlagsEnabled ? buttonGroupStylesNew : buttonGroupStyles,
369
375
  role: "radiogroup",
370
376
  "aria-label": groupLabel !== null && groupLabel !== void 0 ? groupLabel : undefined,
371
377
  "data-testid": "editor-floating-toolbar-grouped-buttons"
@@ -400,7 +406,7 @@ var buttonGroupStylesNew = css({
400
406
  });
401
407
 
402
408
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
403
- var toolbarContainer = function toolbarContainer(scrollable, hasSelect, firstElementIsSelect) {
409
+ var toolbarContainer = function toolbarContainer(areAnyNewToolbarFlagsEnabled, scrollable, hasSelect, firstElementIsSelect) {
404
410
  return css({
405
411
  backgroundColor: "var(--ds-surface-overlay, white)",
406
412
  borderRadius: "var(--ds-radius-small, 3px)",
@@ -431,7 +437,7 @@ var toolbarContainer = function toolbarContainer(scrollable, hasSelect, firstEle
431
437
  overflow: 'hidden'
432
438
  }) :
433
439
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
434
- areToolbarFlagsEnabled() ?
440
+ areAnyNewToolbarFlagsEnabled ?
435
441
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
436
442
  css({
437
443
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
@@ -454,7 +460,7 @@ var toolbarContainer = function toolbarContainer(scrollable, hasSelect, firstEle
454
460
  paddingLeft: "var(--ds-space-050, 4px)"
455
461
  })),
456
462
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
457
- areToolbarFlagsEnabled() ?
463
+ areAnyNewToolbarFlagsEnabled ?
458
464
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
459
465
  css({
460
466
  minHeight: "var(--ds-space-500, 40px)"
@@ -465,7 +471,8 @@ var toolbarContainer = function toolbarContainer(scrollable, hasSelect, firstEle
465
471
  var toolbarOverflow = function toolbarOverflow(_ref2) {
466
472
  var scrollable = _ref2.scrollable,
467
473
  scrollDisabled = _ref2.scrollDisabled,
468
- firstElementIsSelect = _ref2.firstElementIsSelect;
474
+ firstElementIsSelect = _ref2.firstElementIsSelect,
475
+ areAnyNewToolbarFlagsEnabled = _ref2.areAnyNewToolbarFlagsEnabled;
469
476
  return css(
470
477
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
471
478
  scrollable ?
@@ -506,7 +513,7 @@ var toolbarOverflow = function toolbarOverflow(_ref2) {
506
513
  }
507
514
  },
508
515
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
509
- areToolbarFlagsEnabled() ?
516
+ areAnyNewToolbarFlagsEnabled ?
510
517
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
511
518
  css({
512
519
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
@@ -645,6 +652,7 @@ var Toolbar = /*#__PURE__*/function (_Component) {
645
652
  }, {
646
653
  key: "render",
647
654
  value: function render() {
655
+ var _this$props$api2;
648
656
  var _this$props2 = this.props,
649
657
  items = _this$props2.items,
650
658
  className = _this$props2.className,
@@ -652,7 +660,7 @@ var Toolbar = /*#__PURE__*/function (_Component) {
652
660
  intl = _this$props2.intl,
653
661
  scrollable = _this$props2.scrollable,
654
662
  mediaAssistiveMessage = _this$props2.mediaAssistiveMessage;
655
- var isNewEditorToolbarEnabled = areToolbarFlagsEnabled();
663
+ var areAnyNewToolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean((_this$props$api2 = this.props.api) === null || _this$props$api2 === void 0 ? void 0 : _this$props$api2.toolbar));
656
664
  if (!items || !items.length) {
657
665
  return null;
658
666
  }
@@ -676,7 +684,7 @@ var Toolbar = /*#__PURE__*/function (_Component) {
676
684
  }, jsx("div", {
677
685
  ref: this.toolbarContainerRef,
678
686
  css: function css() {
679
- return [toolbarContainer(scrollable, hasSelect !== undefined, firstElementIsSelect)];
687
+ return [toolbarContainer(areAnyNewToolbarFlagsEnabled, scrollable, hasSelect !== undefined, firstElementIsSelect)];
680
688
  },
681
689
  "aria-label": intl.formatMessage(messages.floatingToolbarAriaLabel),
682
690
  role: "toolbar",
@@ -684,11 +692,11 @@ var Toolbar = /*#__PURE__*/function (_Component) {
684
692
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
685
693
  ,
686
694
  className: className,
687
- onMouseDown: isNewEditorToolbarEnabled ? this.captureMouseEvent : undefined
695
+ onMouseDown: areAnyNewToolbarFlagsEnabled ? this.captureMouseEvent : undefined
688
696
  }, jsx(Announcer, {
689
697
  text: mediaAssistiveMessage ? "".concat(mediaAssistiveMessage, ", ").concat(intl.formatMessage(messages.floatingToolbarAnnouncer)) : intl.formatMessage(messages.floatingToolbarAnnouncer),
690
698
  delay: 250
691
- }), scrollable && isNewEditorToolbarEnabled && jsx(ScrollButton, {
699
+ }), scrollable && areAnyNewToolbarFlagsEnabled && jsx(ScrollButton, {
692
700
  intl: intl,
693
701
  scrollContainerRef: this.scrollContainerRef,
694
702
  node: node,
@@ -700,6 +708,7 @@ var Toolbar = /*#__PURE__*/function (_Component) {
700
708
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
701
709
  ,
702
710
  css: toolbarOverflow({
711
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled,
703
712
  scrollable: scrollable,
704
713
  scrollDisabled: this.state.scrollDisabled,
705
714
  firstElementIsSelect: firstElementIsSelect
@@ -711,7 +720,7 @@ var Toolbar = /*#__PURE__*/function (_Component) {
711
720
  setDisableScroll: this.setDisableScroll.bind(this),
712
721
  mountRef: this.mountRef,
713
722
  mounted: this.state.mounted
714
- }))), scrollable && (isNewEditorToolbarEnabled ? jsx(ScrollButton, {
723
+ }))), scrollable && (areAnyNewToolbarFlagsEnabled ? jsx(ScrollButton, {
715
724
  intl: intl,
716
725
  scrollContainerRef: this.scrollContainerRef,
717
726
  node: node,
@@ -721,7 +730,8 @@ var Toolbar = /*#__PURE__*/function (_Component) {
721
730
  intl: intl,
722
731
  scrollContainerRef: this.scrollContainerRef,
723
732
  node: node,
724
- disabled: this.state.scrollDisabled
733
+ disabled: this.state.scrollDisabled,
734
+ areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
725
735
  }))), jsx("div", {
726
736
  ref: this.mountRef
727
737
  })));
@@ -9,6 +9,7 @@ import type { EmojiPlugin } from '@atlaskit/editor-plugin-emoji';
9
9
  import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
10
10
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
11
11
  import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
12
+ import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
12
13
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
13
14
  import type { Node } from '@atlaskit/editor-prosemirror/model';
14
15
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
@@ -39,7 +40,8 @@ export type FloatingToolbarPluginDependencies = [
39
40
  OptionalPlugin<EmojiPlugin>,
40
41
  OptionalPlugin<UserIntentPlugin>,
41
42
  OptionalPlugin<InteractionPlugin>,
42
- OptionalPlugin<AnalyticsPlugin>
43
+ OptionalPlugin<AnalyticsPlugin>,
44
+ OptionalPlugin<ToolbarPlugin>
43
45
  ];
44
46
  export type FloatingToolbarPlugin = NextEditorPlugin<'floatingToolbar', {
45
47
  actions: {
@@ -12,6 +12,7 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
12
12
  export interface Props {
13
13
  alignDropdownWithToolbar?: boolean;
14
14
  alignX?: 'left' | 'right' | 'center';
15
+ areAnyNewToolbarFlagsEnabled: boolean;
15
16
  boundariesElement?: HTMLElement;
16
17
  buttonTestId?: string;
17
18
  disabled?: boolean;