@atlaskit/editor-plugin-floating-toolbar 3.3.2 → 3.3.4

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-floating-toolbar
2
2
 
3
+ ## 3.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 3.3.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#132712](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/132712)
14
+ [`03a53eb22fbba`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/03a53eb22fbba) -
15
+ [ED-27288] Hide horizontal scrollbar for floating toolbar in narrow editor (e.g. inline comment)
16
+ - Updated dependencies
17
+
3
18
  ## 3.3.2
4
19
 
5
20
  ### Patch Changes
@@ -10,6 +10,7 @@ exports.floatingToolbarPlugin = void 0;
10
10
  exports.floatingToolbarPluginFactory = floatingToolbarPluginFactory;
11
11
  exports.pluginKey = exports.getRelevantConfig = void 0;
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
14
  var _react = _interopRequireDefault(require("react"));
14
15
  var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
15
16
  var _analytics = require("@atlaskit/editor-common/analytics");
@@ -20,6 +21,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
20
21
  var _ui = require("@atlaskit/editor-common/ui");
21
22
  var _state = require("@atlaskit/editor-prosemirror/state");
22
23
  var _utils = require("@atlaskit/editor-prosemirror/utils");
24
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
23
25
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
24
26
  var _commands = require("./pm-plugins/commands");
25
27
  var _forceFocus = _interopRequireWildcard(require("./pm-plugins/force-focus"));
@@ -30,6 +32,7 @@ var _utils2 = require("./pm-plugins/utils");
30
32
  var _ConfirmationModal = require("./ui/ConfirmationModal");
31
33
  var _ExpandButton = require("./ui/ExpandButton");
32
34
  var _ToolbarLoader = require("./ui/ToolbarLoader");
35
+ var _utils3 = require("./ui/utils");
33
36
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
34
37
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
35
38
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -275,6 +278,32 @@ function ContentComponent(_ref5) {
275
278
  return toolbarItemViewModeProp in item && !!item[toolbarItemViewModeProp];
276
279
  });
277
280
  }
281
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1')) {
282
+ var _items2;
283
+ // Consolidate floating toolbar items
284
+ var toolbarItemsArray = Array.isArray(items) ? items : (_items2 = items) === null || _items2 === void 0 ? void 0 : _items2(node);
285
+ var overflowDropdownItems = toolbarItemsArray.filter(function (item) {
286
+ return item.type === 'overflow-dropdown';
287
+ });
288
+ if (overflowDropdownItems.length > 1) {
289
+ var consolidatedOverflowDropdown = (0, _utils3.consolidateOverflowDropdownItems)(overflowDropdownItems);
290
+ var otherItems = toolbarItemsArray.filter(function (item) {
291
+ return item.type !== 'overflow-dropdown';
292
+ });
293
+ if (otherItems.length > 0) {
294
+ // remove the last separators
295
+ while (((_otherItems$at = otherItems.at(-1)) === null || _otherItems$at === void 0 ? void 0 : _otherItems$at.type) === 'separator') {
296
+ var _otherItems$at;
297
+ otherItems.pop();
298
+ }
299
+ }
300
+ items = [].concat((0, _toConsumableArray2.default)(otherItems), [{
301
+ type: 'separator',
302
+ fullHeight: true,
303
+ supportsViewMode: true
304
+ }, consolidatedOverflowDropdown]);
305
+ }
306
+ }
278
307
  var customPositionCalculation;
279
308
  var toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.copyButton) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.hoverDecoration);
280
309
  var viewModeToolbarEntry = (0, _experiments.unstable_editorExperimentParam)('live_pages_graceful_edit', 'toolbar-entry', {
@@ -16,6 +16,7 @@ var styles = (0, _primitives.xcss)({
16
16
  var Divider = exports.Divider = function Divider() {
17
17
  return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
18
18
  as: "hr",
19
- xcss: styles
19
+ xcss: styles,
20
+ role: "presentation"
20
21
  });
21
22
  };
@@ -206,11 +206,7 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
206
206
  setDisableParentScroll: scrollable ? setDisableScroll : undefined,
207
207
  dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && "".concat(item.id, "-dropdownList"),
208
208
  alignDropdownWithToolbar: items.length === 1,
209
- onToggle: item.onToggle,
210
- footer: item.footer,
211
- onMount: item.onMount,
212
- onClick: item.onClick,
213
- pulse: item.pulse
209
+ onClick: item.onClick
214
210
  });
215
211
  case 'dropdown':
216
212
  var DropdownIcon = item.icon;
@@ -465,7 +461,16 @@ var toolbarOverflow = function toolbarOverflow(_ref2) {
465
461
  (0, _react2.css)({
466
462
  overflow: 'hidden'
467
463
  }) :
468
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
464
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
465
+ (0, _platformFeatureFlags.fg)('platform_editor_fix_floating_toolbar_scrollbar') ?
466
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
467
+ (0, _react2.css)({
468
+ overflowX: 'auto',
469
+ overflowY: 'hidden',
470
+ // When scrollable is true, ScrollButtons will be shown, hence we want to hide show default horizontal scrollbar
471
+ scrollbarWidth: 'none'
472
+ }) :
473
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
469
474
  (0, _react2.css)({
470
475
  overflowX: 'auto',
471
476
  overflowY: 'hidden'
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.consolidateOverflowDropdownItems = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ // if there are more than 1 item with type `overflow-dropdown`, we should only show one and combine the options
10
+ var consolidateOverflowDropdownItems = exports.consolidateOverflowDropdownItems = function consolidateOverflowDropdownItems(overflowDropdowns) {
11
+ if (overflowDropdowns.length <= 1) {
12
+ return overflowDropdowns[0];
13
+ }
14
+ var combinedItems = overflowDropdowns.reduce(function (acc, item) {
15
+ if (item.options) {
16
+ acc.push.apply(acc, (0, _toConsumableArray2.default)(item.options));
17
+ }
18
+ return acc;
19
+ }, []);
20
+
21
+ // To filter out items that have a rank property, sort them by rank in descending order (highest rank first)
22
+ var rankedItems = combinedItems.filter(function (item) {
23
+ return 'rank' in item && typeof item.rank === 'number';
24
+ }).sort(function (a, b) {
25
+ return (b.rank || 0) - (a.rank || 0);
26
+ });
27
+ var unrankedItems = combinedItems.filter(function (item) {
28
+ return !('rank' in item && typeof item.rank === 'number');
29
+ });
30
+ var sortedItems = [].concat((0, _toConsumableArray2.default)(rankedItems), (0, _toConsumableArray2.default)(unrankedItems));
31
+ var largestDropdownWidth = overflowDropdowns.reduce(function (acc, item) {
32
+ if (item.dropdownWidth && item.dropdownWidth > acc) {
33
+ return item.dropdownWidth;
34
+ }
35
+ return acc;
36
+ }, 0);
37
+ return {
38
+ type: 'overflow-dropdown',
39
+ dropdownWidth: largestDropdownWidth,
40
+ options: sortedItems
41
+ };
42
+ };
@@ -8,6 +8,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
8
  import { Popup } from '@atlaskit/editor-common/ui';
9
9
  import { AllSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
10
10
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { editorExperiment, unstable_editorExperimentParam } from '@atlaskit/tmp-editor-statsig/experiments';
12
13
  import { copyNode } from './pm-plugins/commands';
13
14
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
@@ -18,6 +19,7 @@ import { findNode } from './pm-plugins/utils';
18
19
  import { ConfirmationModal } from './ui/ConfirmationModal';
19
20
  import { ExpandButton } from './ui/ExpandButton';
20
21
  import { ToolbarLoader } from './ui/ToolbarLoader';
22
+ import { consolidateOverflowDropdownItems } from './ui/utils';
21
23
 
22
24
  // TODO: AFP-2532 - Fix automatic suppressions below
23
25
  export const getRelevantConfig = (selection, configs) => {
@@ -259,6 +261,28 @@ export function ContentComponent({
259
261
  const toolbarItemViewModeProp = 'supportsViewMode';
260
262
  items = iterableItems.filter(item => toolbarItemViewModeProp in item && !!item[toolbarItemViewModeProp]);
261
263
  }
264
+ if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_1')) {
265
+ var _items2;
266
+ // Consolidate floating toolbar items
267
+ const toolbarItemsArray = Array.isArray(items) ? items : (_items2 = items) === null || _items2 === void 0 ? void 0 : _items2(node);
268
+ const overflowDropdownItems = toolbarItemsArray.filter(item => item.type === 'overflow-dropdown');
269
+ if (overflowDropdownItems.length > 1) {
270
+ const consolidatedOverflowDropdown = consolidateOverflowDropdownItems(overflowDropdownItems);
271
+ const otherItems = toolbarItemsArray.filter(item => item.type !== 'overflow-dropdown');
272
+ if (otherItems.length > 0) {
273
+ // remove the last separators
274
+ while (((_otherItems$at = otherItems.at(-1)) === null || _otherItems$at === void 0 ? void 0 : _otherItems$at.type) === 'separator') {
275
+ var _otherItems$at;
276
+ otherItems.pop();
277
+ }
278
+ }
279
+ items = [...otherItems, {
280
+ type: 'separator',
281
+ fullHeight: true,
282
+ supportsViewMode: true
283
+ }, consolidatedOverflowDropdown];
284
+ }
285
+ }
262
286
  let customPositionCalculation;
263
287
  const toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.copyButton) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.hoverDecoration);
264
288
  const viewModeToolbarEntry = unstable_editorExperimentParam('live_pages_graceful_edit', 'toolbar-entry', {
@@ -8,5 +8,6 @@ const styles = xcss({
8
8
  });
9
9
  export const Divider = () => /*#__PURE__*/React.createElement(Box, {
10
10
  as: "hr",
11
- xcss: styles
11
+ xcss: styles,
12
+ role: "presentation"
12
13
  });
@@ -183,11 +183,7 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
183
183
  setDisableParentScroll: scrollable ? setDisableScroll : undefined,
184
184
  dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && `${item.id}-dropdownList`,
185
185
  alignDropdownWithToolbar: items.length === 1,
186
- onToggle: item.onToggle,
187
- footer: item.footer,
188
- onMount: item.onMount,
189
- onClick: item.onClick,
190
- pulse: item.pulse
186
+ onClick: item.onClick
191
187
  });
192
188
  case 'dropdown':
193
189
  const DropdownIcon = item.icon;
@@ -430,7 +426,16 @@ scrollDisabled ?
430
426
  css({
431
427
  overflow: 'hidden'
432
428
  }) :
433
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
429
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
430
+ fg('platform_editor_fix_floating_toolbar_scrollbar') ?
431
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
432
+ css({
433
+ overflowX: 'auto',
434
+ overflowY: 'hidden',
435
+ // When scrollable is true, ScrollButtons will be shown, hence we want to hide show default horizontal scrollbar
436
+ scrollbarWidth: 'none'
437
+ }) :
438
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
434
439
  css({
435
440
  overflowX: 'auto',
436
441
  overflowY: 'hidden'
@@ -0,0 +1,28 @@
1
+ // if there are more than 1 item with type `overflow-dropdown`, we should only show one and combine the options
2
+ export const consolidateOverflowDropdownItems = overflowDropdowns => {
3
+ if (overflowDropdowns.length <= 1) {
4
+ return overflowDropdowns[0];
5
+ }
6
+ const combinedItems = overflowDropdowns.reduce((acc, item) => {
7
+ if (item.options) {
8
+ acc.push(...item.options);
9
+ }
10
+ return acc;
11
+ }, []);
12
+
13
+ // To filter out items that have a rank property, sort them by rank in descending order (highest rank first)
14
+ const rankedItems = combinedItems.filter(item => 'rank' in item && typeof item.rank === 'number').sort((a, b) => (b.rank || 0) - (a.rank || 0));
15
+ const unrankedItems = combinedItems.filter(item => !('rank' in item && typeof item.rank === 'number'));
16
+ const sortedItems = [...rankedItems, ...unrankedItems];
17
+ const largestDropdownWidth = overflowDropdowns.reduce((acc, item) => {
18
+ if (item.dropdownWidth && item.dropdownWidth > acc) {
19
+ return item.dropdownWidth;
20
+ }
21
+ return acc;
22
+ }, 0);
23
+ return {
24
+ type: 'overflow-dropdown',
25
+ dropdownWidth: largestDropdownWidth,
26
+ options: sortedItems
27
+ };
28
+ };
@@ -1,4 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
5
  import React from 'react';
@@ -11,6 +12,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
11
12
  import { Popup } from '@atlaskit/editor-common/ui';
12
13
  import { AllSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
13
14
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
15
+ import { fg } from '@atlaskit/platform-feature-flags';
14
16
  import { editorExperiment, unstable_editorExperimentParam } from '@atlaskit/tmp-editor-statsig/experiments';
15
17
  import { copyNode as _copyNode } from './pm-plugins/commands';
16
18
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
@@ -21,6 +23,7 @@ import { findNode } from './pm-plugins/utils';
21
23
  import { ConfirmationModal } from './ui/ConfirmationModal';
22
24
  import { ExpandButton } from './ui/ExpandButton';
23
25
  import { ToolbarLoader } from './ui/ToolbarLoader';
26
+ import { consolidateOverflowDropdownItems } from './ui/utils';
24
27
 
25
28
  // TODO: AFP-2532 - Fix automatic suppressions below
26
29
  export var getRelevantConfig = function getRelevantConfig(selection, configs) {
@@ -263,6 +266,32 @@ export function ContentComponent(_ref5) {
263
266
  return toolbarItemViewModeProp in item && !!item[toolbarItemViewModeProp];
264
267
  });
265
268
  }
269
+ if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_1')) {
270
+ var _items2;
271
+ // Consolidate floating toolbar items
272
+ var toolbarItemsArray = Array.isArray(items) ? items : (_items2 = items) === null || _items2 === void 0 ? void 0 : _items2(node);
273
+ var overflowDropdownItems = toolbarItemsArray.filter(function (item) {
274
+ return item.type === 'overflow-dropdown';
275
+ });
276
+ if (overflowDropdownItems.length > 1) {
277
+ var consolidatedOverflowDropdown = consolidateOverflowDropdownItems(overflowDropdownItems);
278
+ var otherItems = toolbarItemsArray.filter(function (item) {
279
+ return item.type !== 'overflow-dropdown';
280
+ });
281
+ if (otherItems.length > 0) {
282
+ // remove the last separators
283
+ while (((_otherItems$at = otherItems.at(-1)) === null || _otherItems$at === void 0 ? void 0 : _otherItems$at.type) === 'separator') {
284
+ var _otherItems$at;
285
+ otherItems.pop();
286
+ }
287
+ }
288
+ items = [].concat(_toConsumableArray(otherItems), [{
289
+ type: 'separator',
290
+ fullHeight: true,
291
+ supportsViewMode: true
292
+ }, consolidatedOverflowDropdown]);
293
+ }
294
+ }
266
295
  var customPositionCalculation;
267
296
  var toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.copyButton) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.hoverDecoration);
268
297
  var viewModeToolbarEntry = unstable_editorExperimentParam('live_pages_graceful_edit', 'toolbar-entry', {
@@ -9,6 +9,7 @@ var styles = xcss({
9
9
  export var Divider = function Divider() {
10
10
  return /*#__PURE__*/React.createElement(Box, {
11
11
  as: "hr",
12
- xcss: styles
12
+ xcss: styles,
13
+ role: "presentation"
13
14
  });
14
15
  };
@@ -199,11 +199,7 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
199
199
  setDisableParentScroll: scrollable ? setDisableScroll : undefined,
200
200
  dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && "".concat(item.id, "-dropdownList"),
201
201
  alignDropdownWithToolbar: items.length === 1,
202
- onToggle: item.onToggle,
203
- footer: item.footer,
204
- onMount: item.onMount,
205
- onClick: item.onClick,
206
- pulse: item.pulse
202
+ onClick: item.onClick
207
203
  });
208
204
  case 'dropdown':
209
205
  var DropdownIcon = item.icon;
@@ -458,7 +454,16 @@ var toolbarOverflow = function toolbarOverflow(_ref2) {
458
454
  css({
459
455
  overflow: 'hidden'
460
456
  }) :
461
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
457
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
458
+ fg('platform_editor_fix_floating_toolbar_scrollbar') ?
459
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
460
+ css({
461
+ overflowX: 'auto',
462
+ overflowY: 'hidden',
463
+ // When scrollable is true, ScrollButtons will be shown, hence we want to hide show default horizontal scrollbar
464
+ scrollbarWidth: 'none'
465
+ }) :
466
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
462
467
  css({
463
468
  overflowX: 'auto',
464
469
  overflowY: 'hidden'
@@ -0,0 +1,35 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ // if there are more than 1 item with type `overflow-dropdown`, we should only show one and combine the options
3
+ export var consolidateOverflowDropdownItems = function consolidateOverflowDropdownItems(overflowDropdowns) {
4
+ if (overflowDropdowns.length <= 1) {
5
+ return overflowDropdowns[0];
6
+ }
7
+ var combinedItems = overflowDropdowns.reduce(function (acc, item) {
8
+ if (item.options) {
9
+ acc.push.apply(acc, _toConsumableArray(item.options));
10
+ }
11
+ return acc;
12
+ }, []);
13
+
14
+ // To filter out items that have a rank property, sort them by rank in descending order (highest rank first)
15
+ var rankedItems = combinedItems.filter(function (item) {
16
+ return 'rank' in item && typeof item.rank === 'number';
17
+ }).sort(function (a, b) {
18
+ return (b.rank || 0) - (a.rank || 0);
19
+ });
20
+ var unrankedItems = combinedItems.filter(function (item) {
21
+ return !('rank' in item && typeof item.rank === 'number');
22
+ });
23
+ var sortedItems = [].concat(_toConsumableArray(rankedItems), _toConsumableArray(unrankedItems));
24
+ var largestDropdownWidth = overflowDropdowns.reduce(function (acc, item) {
25
+ if (item.dropdownWidth && item.dropdownWidth > acc) {
26
+ return item.dropdownWidth;
27
+ }
28
+ return acc;
29
+ }, 0);
30
+ return {
31
+ type: 'overflow-dropdown',
32
+ dropdownWidth: largestDropdownWidth,
33
+ options: sortedItems
34
+ };
35
+ };
@@ -0,0 +1,2 @@
1
+ import { Command, FloatingToolbarOverflowDropdown } from '@atlaskit/editor-common/types';
2
+ export declare const consolidateOverflowDropdownItems: (overflowDropdowns: FloatingToolbarOverflowDropdown<Command>[]) => FloatingToolbarOverflowDropdown<Command>;
@@ -0,0 +1,2 @@
1
+ import { Command, FloatingToolbarOverflowDropdown } from '@atlaskit/editor-common/types';
2
+ export declare const consolidateOverflowDropdownItems: (overflowDropdowns: FloatingToolbarOverflowDropdown<Command>[]) => FloatingToolbarOverflowDropdown<Command>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-floating-toolbar",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "description": "Floating toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -26,29 +26,29 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@atlaskit/adf-utils": "^19.19.0",
29
- "@atlaskit/button": "^21.1.0",
29
+ "@atlaskit/button": "^23.0.0",
30
30
  "@atlaskit/checkbox": "^17.0.0",
31
- "@atlaskit/editor-common": "^102.13.0",
31
+ "@atlaskit/editor-common": "^102.16.0",
32
32
  "@atlaskit/editor-palette": "^2.1.0",
33
- "@atlaskit/editor-plugin-block-controls": "^3.5.0",
33
+ "@atlaskit/editor-plugin-block-controls": "^3.8.0",
34
34
  "@atlaskit/editor-plugin-context-panel": "^4.0.0",
35
35
  "@atlaskit/editor-plugin-copy-button": "^2.0.0",
36
36
  "@atlaskit/editor-plugin-decorations": "^2.0.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
38
38
  "@atlaskit/editor-plugin-editor-viewmode": "^3.0.0",
39
- "@atlaskit/editor-plugin-emoji": "^3.2.0",
40
- "@atlaskit/editor-plugin-extension": "^5.0.0",
39
+ "@atlaskit/editor-plugin-emoji": "^3.3.0",
40
+ "@atlaskit/editor-plugin-extension": "^5.1.0",
41
41
  "@atlaskit/editor-plugin-table": "^10.5.0",
42
42
  "@atlaskit/editor-prosemirror": "7.0.0",
43
43
  "@atlaskit/emoji": "^69.0.0",
44
- "@atlaskit/icon": "^25.0.0",
45
- "@atlaskit/menu": "^3.1.0",
46
- "@atlaskit/modal-dialog": "^14.0.0",
44
+ "@atlaskit/icon": "^25.4.0",
45
+ "@atlaskit/menu": "^3.2.0",
46
+ "@atlaskit/modal-dialog": "^14.1.0",
47
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
48
48
  "@atlaskit/primitives": "^14.2.0",
49
49
  "@atlaskit/select": "^20.0.0",
50
50
  "@atlaskit/theme": "^18.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^4.4.0",
51
+ "@atlaskit/tmp-editor-statsig": "^4.6.0",
52
52
  "@atlaskit/tokens": "^4.5.0",
53
53
  "@atlaskit/tooltip": "^20.0.0",
54
54
  "@babel/runtime": "^7.0.0",
@@ -124,6 +124,12 @@
124
124
  },
125
125
  "forge-ui-macro-autoconvert": {
126
126
  "type": "boolean"
127
+ },
128
+ "platform_editor_fix_floating_toolbar_scrollbar": {
129
+ "type": "boolean"
130
+ },
131
+ "platform_editor_controls_patch_1": {
132
+ "type": "boolean"
127
133
  }
128
134
  }
129
135
  }