@atlaskit/editor-plugin-floating-toolbar 1.18.0 → 1.19.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 (30) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/floatingToolbarPlugin.js +51 -27
  3. package/dist/cjs/pm-plugins/contextual-toolbar/plugin-key.js +8 -0
  4. package/dist/cjs/pm-plugins/contextual-toolbar/plugin.js +42 -0
  5. package/dist/cjs/pm-plugins/contextual-toolbar/types.js +1 -0
  6. package/dist/cjs/ui/DropdownMenu.js +1 -3
  7. package/dist/cjs/ui/Toolbar.js +112 -8
  8. package/dist/es2019/floatingToolbarPlugin.js +25 -4
  9. package/dist/es2019/pm-plugins/contextual-toolbar/plugin-key.js +2 -0
  10. package/dist/es2019/pm-plugins/contextual-toolbar/plugin.js +36 -0
  11. package/dist/es2019/pm-plugins/contextual-toolbar/types.js +0 -0
  12. package/dist/es2019/ui/DropdownMenu.js +1 -3
  13. package/dist/es2019/ui/Toolbar.js +106 -1
  14. package/dist/esm/floatingToolbarPlugin.js +48 -24
  15. package/dist/esm/pm-plugins/contextual-toolbar/plugin-key.js +2 -0
  16. package/dist/esm/pm-plugins/contextual-toolbar/plugin.js +36 -0
  17. package/dist/esm/pm-plugins/contextual-toolbar/types.js +0 -0
  18. package/dist/esm/ui/DropdownMenu.js +1 -3
  19. package/dist/esm/ui/Toolbar.js +112 -8
  20. package/dist/types/floatingToolbarPluginType.d.ts +16 -1
  21. package/dist/types/pm-plugins/contextual-toolbar/plugin-key.d.ts +3 -0
  22. package/dist/types/pm-plugins/contextual-toolbar/plugin.d.ts +4 -0
  23. package/dist/types/pm-plugins/contextual-toolbar/types.d.ts +8 -0
  24. package/dist/types/ui/Toolbar.d.ts +1 -0
  25. package/dist/types-ts4.5/floatingToolbarPluginType.d.ts +16 -1
  26. package/dist/types-ts4.5/pm-plugins/contextual-toolbar/plugin-key.d.ts +3 -0
  27. package/dist/types-ts4.5/pm-plugins/contextual-toolbar/plugin.d.ts +4 -0
  28. package/dist/types-ts4.5/pm-plugins/contextual-toolbar/types.d.ts +8 -0
  29. package/dist/types-ts4.5/ui/Toolbar.d.ts +1 -0
  30. package/package.json +10 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-floating-toolbar
2
2
 
3
+ ## 1.19.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#115259](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115259)
8
+ [`a3150808f308a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a3150808f308a) -
9
+ Add new forceStaticToolbar config option to floating toolbar and add it to panel and table. Add
10
+ new contextual toolbar plugin which controls expand and collapse logic for toolbar options.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
16
+ ## 1.18.1
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 1.18.0
4
23
 
5
24
  ### Minor Changes
@@ -21,10 +21,12 @@ var _ui = require("@atlaskit/editor-common/ui");
21
21
  var _state = require("@atlaskit/editor-prosemirror/state");
22
22
  var _utils = require("@atlaskit/editor-prosemirror/utils");
23
23
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
24
+ var _plugin = require("./pm-plugins/contextual-toolbar/plugin");
25
+ var _pluginKey = require("./pm-plugins/contextual-toolbar/plugin-key");
24
26
  var _forceFocus = _interopRequireWildcard(require("./pm-plugins/force-focus"));
25
27
  var _commands = require("./pm-plugins/toolbar-data/commands");
26
- var _plugin = require("./pm-plugins/toolbar-data/plugin");
27
- var _pluginKey = require("./pm-plugins/toolbar-data/plugin-key");
28
+ var _plugin2 = require("./pm-plugins/toolbar-data/plugin");
29
+ var _pluginKey2 = require("./pm-plugins/toolbar-data/plugin-key");
28
30
  var _utils2 = require("./pm-plugins/utils");
29
31
  var _ConfirmationModal = require("./ui/ConfirmationModal");
30
32
  var _ExpandButton = require("./ui/ExpandButton");
@@ -135,7 +137,7 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
135
137
  name: 'floatingToolbar',
136
138
  pmPlugins: function pmPlugins() {
137
139
  var floatingToolbarHandlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
138
- return [{
140
+ var plugins = [{
139
141
  // Should be after all toolbar plugins
140
142
  name: 'floatingToolbar',
141
143
  plugin: function plugin(_ref2) {
@@ -151,7 +153,7 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
151
153
  name: 'floatingToolbarData',
152
154
  plugin: function plugin(_ref3) {
153
155
  var dispatch = _ref3.dispatch;
154
- return (0, _plugin.createPlugin)(dispatch);
156
+ return (0, _plugin2.createPlugin)(dispatch);
155
157
  }
156
158
  }, {
157
159
  name: 'forceFocus',
@@ -159,6 +161,15 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
159
161
  return (0, _forceFocus.default)();
160
162
  }
161
163
  }];
164
+ if (!(0, _experiments.editorExperiment)('platform_editor_controls', 'control')) {
165
+ plugins.push({
166
+ name: 'contextualToolbar',
167
+ plugin: function plugin() {
168
+ return (0, _plugin.contextualToolbarPlugin)();
169
+ }
170
+ });
171
+ }
172
+ return plugins;
162
173
  },
163
174
  actions: {
164
175
  forceFocusSelector: _forceFocus.forceFocusSelector
@@ -171,16 +182,27 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
171
182
  var configWithNodeInfo = (_pluginKey$getState$g = (_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 || (_pluginKey$getState$g2 = _pluginKey$getState.getConfigWithNodeInfo) === null || _pluginKey$getState$g2 === void 0 ? void 0 : _pluginKey$getState$g2.call(_pluginKey$getState, editorState)) !== null && _pluginKey$getState$g !== void 0 ? _pluginKey$getState$g : undefined;
172
183
  return {
173
184
  configWithNodeInfo: configWithNodeInfo,
174
- floatingToolbarData: _pluginKey.pluginKey.getState(editorState)
185
+ floatingToolbarData: _pluginKey2.pluginKey.getState(editorState),
186
+ // Experimental - excluding this property from the external API whilst it's in development
187
+ contextualToolbar: _pluginKey.contextualToolbarPluginKey.getState(editorState)
175
188
  };
176
189
  },
177
- contentComponent: function contentComponent(_ref4) {
178
- var popupsMountPoint = _ref4.popupsMountPoint,
179
- popupsBoundariesElement = _ref4.popupsBoundariesElement,
180
- popupsScrollableElement = _ref4.popupsScrollableElement,
181
- editorView = _ref4.editorView,
182
- providerFactory = _ref4.providerFactory,
183
- dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
190
+ commands: {
191
+ // Experimental
192
+ updateContextualToolbar: function updateContextualToolbar(action) {
193
+ return function (_ref4) {
194
+ var tr = _ref4.tr;
195
+ return tr.setMeta(_pluginKey.contextualToolbarPluginKey, action);
196
+ };
197
+ }
198
+ },
199
+ contentComponent: function contentComponent(_ref5) {
200
+ var popupsMountPoint = _ref5.popupsMountPoint,
201
+ popupsBoundariesElement = _ref5.popupsBoundariesElement,
202
+ popupsScrollableElement = _ref5.popupsScrollableElement,
203
+ editorView = _ref5.editorView,
204
+ providerFactory = _ref5.providerFactory,
205
+ dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
184
206
  return /*#__PURE__*/_react.default.createElement(ContentComponent, {
185
207
  editorView: editorView,
186
208
  pluginInjectionApi: api,
@@ -193,23 +215,23 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
193
215
  }
194
216
  };
195
217
  };
196
- function ContentComponent(_ref5) {
218
+ function ContentComponent(_ref6) {
197
219
  var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
198
- var pluginInjectionApi = _ref5.pluginInjectionApi,
199
- editorView = _ref5.editorView,
200
- popupsMountPoint = _ref5.popupsMountPoint,
201
- popupsBoundariesElement = _ref5.popupsBoundariesElement,
202
- popupsScrollableElement = _ref5.popupsScrollableElement,
203
- providerFactory = _ref5.providerFactory,
204
- dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
220
+ var pluginInjectionApi = _ref6.pluginInjectionApi,
221
+ editorView = _ref6.editorView,
222
+ popupsMountPoint = _ref6.popupsMountPoint,
223
+ popupsBoundariesElement = _ref6.popupsBoundariesElement,
224
+ popupsScrollableElement = _ref6.popupsScrollableElement,
225
+ providerFactory = _ref6.providerFactory,
226
+ dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent;
205
227
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'blockControls']),
206
228
  floatingToolbarState = _useSharedPluginState.floatingToolbarState,
207
229
  editorDisabledState = _useSharedPluginState.editorDisabledState,
208
230
  editorViewModeState = _useSharedPluginState.editorViewModeState,
209
231
  blockControlsState = _useSharedPluginState.blockControlsState;
210
- var _ref6 = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {},
211
- configWithNodeInfo = _ref6.configWithNodeInfo,
212
- floatingToolbarData = _ref6.floatingToolbarData;
232
+ var _ref7 = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {},
233
+ configWithNodeInfo = _ref7.configWithNodeInfo,
234
+ floatingToolbarData = _ref7.floatingToolbarData;
213
235
  if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
214
236
  return null;
215
237
  }
@@ -246,7 +268,8 @@ function ContentComponent(_ref5) {
246
268
  _config$mediaAssistiv = config.mediaAssistiveMessage,
247
269
  mediaAssistiveMessage = _config$mediaAssistiv === void 0 ? '' : _config$mediaAssistiv,
248
270
  _config$stick = config.stick,
249
- stick = _config$stick === void 0 ? true : _config$stick;
271
+ stick = _config$stick === void 0 ? true : _config$stick,
272
+ forceStaticToolbar = config.forceStaticToolbar;
250
273
  var targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
251
274
  var isEditorDisabled = editorDisabledState && editorDisabledState.editorDisabled;
252
275
  var isInViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
@@ -310,8 +333,8 @@ function ContentComponent(_ref5) {
310
333
  };
311
334
 
312
335
  // Confirm dialog
313
- var _ref7 = floatingToolbarData || {},
314
- confirmDialogForItem = _ref7.confirmDialogForItem;
336
+ var _ref8 = floatingToolbarData || {},
337
+ confirmDialogForItem = _ref8.confirmDialogForItem;
315
338
  var confirmButtonItem = confirmDialogForItem ?
316
339
  // Ignored via go/ees005
317
340
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -374,7 +397,8 @@ function ContentComponent(_ref5) {
374
397
  extensionsProvider: providers.extensionProvider,
375
398
  scrollable: scrollable,
376
399
  api: pluginInjectionApi,
377
- mediaAssistiveMessage: mediaAssistiveMessage
400
+ mediaAssistiveMessage: mediaAssistiveMessage,
401
+ forceStaticToolbar: forceStaticToolbar
378
402
  });
379
403
  }
380
404
  })), /*#__PURE__*/_react.default.createElement(_ConfirmationModal.ConfirmationModal, {
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.contextualToolbarPluginKey = void 0;
7
+ var _state = require("@atlaskit/editor-prosemirror/state");
8
+ var contextualToolbarPluginKey = exports.contextualToolbarPluginKey = new _state.PluginKey('contextualToolbar');
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.contextualToolbarPlugin = void 0;
7
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
+ var _pluginKey = require("./plugin-key");
9
+ var defaultEditState = {
10
+ display: 'collapsed'
11
+ };
12
+ var contextualToolbarPlugin = exports.contextualToolbarPlugin = function contextualToolbarPlugin() {
13
+ return new _safePlugin.SafePlugin({
14
+ key: _pluginKey.contextualToolbarPluginKey,
15
+ state: {
16
+ init: function init() {
17
+ return defaultEditState;
18
+ },
19
+ apply: function apply(tr, pluginState) {
20
+ if (pluginState.display === 'static') {
21
+ return pluginState;
22
+ }
23
+ var action = tr.getMeta(_pluginKey.contextualToolbarPluginKey);
24
+ if (action) {
25
+ switch (action.type) {
26
+ case 'expand-toolbar':
27
+ return {
28
+ display: 'expanded'
29
+ };
30
+ case 'collapse-toolbar':
31
+ return {
32
+ display: 'collapsed'
33
+ };
34
+ default:
35
+ return pluginState;
36
+ }
37
+ }
38
+ return pluginState;
39
+ }
40
+ }
41
+ });
42
+ };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -39,7 +39,7 @@ var spacerStyles = (0, _react2.css)({
39
39
  });
40
40
  var separatorStyles = (0, _react2.css)({
41
41
  background: "var(--ds-border, #091E4224)",
42
- height: '1px'
42
+ height: "var(--ds-space-025, 1px)"
43
43
  });
44
44
 
45
45
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
@@ -282,8 +282,6 @@ var Dropdown = /*#__PURE__*/(0, _react.memo)(function (props) {
282
282
  }
283
283
  }));
284
284
  }
285
-
286
- // here to change based on dropdown type
287
285
  return (0, _react2.jsx)("div", {
288
286
  css: menuContainerStyles,
289
287
  role: "menu"
@@ -22,10 +22,14 @@ var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
22
22
  var _ui = require("@atlaskit/editor-common/ui");
23
23
  var _uiColor = require("@atlaskit/editor-common/ui-color");
24
24
  var _uiMenu = require("@atlaskit/editor-common/ui-menu");
25
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
25
26
  var _editorPalette = require("@atlaskit/editor-palette");
26
27
  var _commands = require("@atlaskit/editor-plugin-table/commands");
28
+ var _edit = _interopRequireDefault(require("@atlaskit/icon/core/edit"));
27
29
  var _showMoreHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/show-more-horizontal"));
30
+ var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/utility/chevron-right"));
28
31
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
32
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
29
33
  var _forceFocus = require("../pm-plugins/force-focus");
30
34
  var _commands2 = require("../pm-plugins/toolbar-data/commands");
31
35
  var _Dropdown = _interopRequireDefault(require("./Dropdown"));
@@ -381,6 +385,99 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
381
385
  // otherwise it causes an issue where multiple popups stays open
382
386
  return !(prevProps.node.type !== nextProps.node.type || prevProps.node.attrs.localId !== nextProps.node.attrs.localId || !(0, _floatingToolbar.areSameItems)(prevProps.items, nextProps.items) || !prevProps.mounted !== !nextProps.mounted);
383
387
  });
388
+ var ToolbarItemsCollapsable = /*#__PURE__*/_react.default.memo(function (_ref2) {
389
+ var items = _ref2.items,
390
+ groupLabel = _ref2.groupLabel,
391
+ dispatchCommand = _ref2.dispatchCommand,
392
+ popupsMountPoint = _ref2.popupsMountPoint,
393
+ popupsBoundariesElement = _ref2.popupsBoundariesElement,
394
+ editorView = _ref2.editorView,
395
+ dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
396
+ popupsScrollableElement = _ref2.popupsScrollableElement,
397
+ scrollable = _ref2.scrollable,
398
+ providerFactory = _ref2.providerFactory,
399
+ extensionsProvider = _ref2.extensionsProvider,
400
+ node = _ref2.node,
401
+ setDisableScroll = _ref2.setDisableScroll,
402
+ mountRef = _ref2.mountRef,
403
+ mounted = _ref2.mounted,
404
+ api = _ref2.api,
405
+ forceStaticToolbar = _ref2.forceStaticToolbar;
406
+ var contextualToolbarState = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'floatingToolbar.contextualToolbar');
407
+ var updatedItems = items.slice();
408
+ if (!forceStaticToolbar && (contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.display) === 'collapsed') {
409
+ var nonSeparatorItems = 0;
410
+ var slicedIndex = -1;
411
+ for (var i = items.length - 1; i > 0; i--) {
412
+ var item = items[i];
413
+ if (item.type !== 'separator') {
414
+ nonSeparatorItems += 1;
415
+ slicedIndex = i;
416
+ }
417
+ if (nonSeparatorItems > 2) {
418
+ break;
419
+ }
420
+ }
421
+ updatedItems = updatedItems.slice(slicedIndex);
422
+ updatedItems.unshift({
423
+ type: 'separator'
424
+ });
425
+ updatedItems.unshift({
426
+ type: 'button',
427
+ icon: _edit.default,
428
+ title: 'Show items',
429
+ onClick: function onClick() {
430
+ if (api) {
431
+ api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
432
+ type: 'expand-toolbar'
433
+ }));
434
+ }
435
+ }
436
+ });
437
+ }
438
+ if (!forceStaticToolbar && (contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.display) === 'expanded') {
439
+ updatedItems.unshift({
440
+ type: 'separator'
441
+ });
442
+ updatedItems.unshift({
443
+ type: 'button',
444
+ icon: _chevronRight.default,
445
+ title: 'Hide items',
446
+ onClick: function onClick() {
447
+ if (api) {
448
+ api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
449
+ type: 'collapse-toolbar'
450
+ }));
451
+ }
452
+ }
453
+ });
454
+ }
455
+ return (0, _react2.jsx)(ToolbarItems, {
456
+ items: updatedItems,
457
+ groupLabel: groupLabel,
458
+ dispatchCommand: dispatchCommand,
459
+ popupsMountPoint: popupsMountPoint,
460
+ popupsBoundariesElement: popupsBoundariesElement,
461
+ editorView: editorView,
462
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
463
+ popupsScrollableElement: popupsScrollableElement,
464
+ scrollable: scrollable,
465
+ providerFactory: providerFactory,
466
+ extensionsProvider: extensionsProvider,
467
+ node: node,
468
+ setDisableScroll: setDisableScroll,
469
+ mountRef: mountRef,
470
+ mounted: mounted,
471
+ api: api
472
+ });
473
+ }, function (prevProps, nextProps) {
474
+ if (!nextProps.node) {
475
+ return false;
476
+ }
477
+ // only rerender toolbar items if the node is different
478
+ // otherwise it causes an issue where multiple popups stays open
479
+ return !(prevProps.node.type !== nextProps.node.type || prevProps.node.attrs.localId !== nextProps.node.attrs.localId || !(0, _floatingToolbar.areSameItems)(prevProps.items, nextProps.items) || !prevProps.mounted !== !nextProps.mounted);
480
+ });
384
481
  var buttonGroupStyles = (0, _react2.css)({
385
482
  display: 'flex',
386
483
  gap: "var(--ds-space-050, 4px)"
@@ -430,11 +527,11 @@ var toolbarContainer = function toolbarContainer(scrollable, hasSelect, firstEle
430
527
  };
431
528
 
432
529
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
433
- var toolbarOverflow = function toolbarOverflow(_ref2) {
434
- var scrollable = _ref2.scrollable,
435
- scrollDisabled = _ref2.scrollDisabled,
436
- firstElementIsSelect = _ref2.firstElementIsSelect,
437
- paddingFeatureFlag = _ref2.paddingFeatureFlag;
530
+ var toolbarOverflow = function toolbarOverflow(_ref3) {
531
+ var scrollable = _ref3.scrollable,
532
+ scrollDisabled = _ref3.scrollDisabled,
533
+ firstElementIsSelect = _ref3.firstElementIsSelect,
534
+ paddingFeatureFlag = _ref3.paddingFeatureFlag;
438
535
  return (0, _react2.css)(
439
536
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
440
537
  scrollable ?
@@ -520,8 +617,8 @@ var Toolbar = /*#__PURE__*/function (_Component) {
520
617
  (0, _inherits2.default)(Toolbar, _Component);
521
618
  return (0, _createClass2.default)(Toolbar, [{
522
619
  key: "resetStyling",
523
- value: function resetStyling(_ref3) {
524
- var table = _ref3.table;
620
+ value: function resetStyling(_ref4) {
621
+ var table = _ref4.table;
525
622
  if (this.props.editorView) {
526
623
  var _this$props$api;
527
624
  var _this$props$editorVie2 = this.props.editorView,
@@ -637,7 +734,14 @@ var Toolbar = /*#__PURE__*/function (_Component) {
637
734
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
638
735
  paddingFeatureFlag: (0, _platformFeatureFlags.fg)('platform_editor_floating_toolbar_padding_fix')
639
736
  })
640
- }, (0, _react2.jsx)(ToolbarItems
737
+ }, (0, _experiments.editorExperiment)('platform_editor_controls', 'control') ? (0, _react2.jsx)(ToolbarItems
738
+ // Ignored via go/ees005
739
+ // eslint-disable-next-line react/jsx-props-no-spreading
740
+ , (0, _extends2.default)({}, this.props, {
741
+ setDisableScroll: this.setDisableScroll.bind(this),
742
+ mountRef: this.mountRef,
743
+ mounted: this.state.mounted
744
+ })) : (0, _react2.jsx)(ToolbarItemsCollapsable
641
745
  // Ignored via go/ees005
642
746
  // eslint-disable-next-line react/jsx-props-no-spreading
643
747
  , (0, _extends2.default)({}, this.props, {
@@ -9,6 +9,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
11
  import { editorExperiment, unstable_editorExperimentParam } from '@atlaskit/tmp-editor-statsig/experiments';
12
+ import { contextualToolbarPlugin } from './pm-plugins/contextual-toolbar/plugin';
13
+ import { contextualToolbarPluginKey } from './pm-plugins/contextual-toolbar/plugin-key';
12
14
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
13
15
  import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
14
16
  import { createPlugin as floatingToolbarDataPluginFactory } from './pm-plugins/toolbar-data/plugin';
@@ -122,7 +124,7 @@ export const floatingToolbarPlugin = ({
122
124
  return {
123
125
  name: 'floatingToolbar',
124
126
  pmPlugins(floatingToolbarHandlers = []) {
125
- return [{
127
+ const plugins = [{
126
128
  // Should be after all toolbar plugins
127
129
  name: 'floatingToolbar',
128
130
  plugin: ({
@@ -142,6 +144,13 @@ export const floatingToolbarPlugin = ({
142
144
  name: 'forceFocus',
143
145
  plugin: () => forceFocusPlugin()
144
146
  }];
147
+ if (!editorExperiment('platform_editor_controls', 'control')) {
148
+ plugins.push({
149
+ name: 'contextualToolbar',
150
+ plugin: () => contextualToolbarPlugin()
151
+ });
152
+ }
153
+ return plugins;
145
154
  },
146
155
  actions: {
147
156
  forceFocusSelector
@@ -154,9 +163,19 @@ export const floatingToolbarPlugin = ({
154
163
  const configWithNodeInfo = (_pluginKey$getState$g = (_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 ? void 0 : (_pluginKey$getState$g2 = _pluginKey$getState.getConfigWithNodeInfo) === null || _pluginKey$getState$g2 === void 0 ? void 0 : _pluginKey$getState$g2.call(_pluginKey$getState, editorState)) !== null && _pluginKey$getState$g !== void 0 ? _pluginKey$getState$g : undefined;
155
164
  return {
156
165
  configWithNodeInfo,
157
- floatingToolbarData: dataPluginKey.getState(editorState)
166
+ floatingToolbarData: dataPluginKey.getState(editorState),
167
+ // Experimental - excluding this property from the external API whilst it's in development
168
+ contextualToolbar: contextualToolbarPluginKey.getState(editorState)
158
169
  };
159
170
  },
171
+ commands: {
172
+ // Experimental
173
+ updateContextualToolbar: action => ({
174
+ tr
175
+ }) => {
176
+ return tr.setMeta(contextualToolbarPluginKey, action);
177
+ }
178
+ },
160
179
  contentComponent({
161
180
  popupsMountPoint,
162
181
  popupsBoundariesElement,
@@ -233,7 +252,8 @@ export function ContentComponent({
233
252
  },
234
253
  focusTrap,
235
254
  mediaAssistiveMessage = '',
236
- stick = true
255
+ stick = true,
256
+ forceStaticToolbar
237
257
  } = config;
238
258
  const targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
239
259
  const isEditorDisabled = editorDisabledState && editorDisabledState.editorDisabled;
@@ -353,7 +373,8 @@ export function ContentComponent({
353
373
  extensionsProvider: providers.extensionProvider,
354
374
  scrollable: scrollable,
355
375
  api: pluginInjectionApi,
356
- mediaAssistiveMessage: mediaAssistiveMessage
376
+ mediaAssistiveMessage: mediaAssistiveMessage,
377
+ forceStaticToolbar: forceStaticToolbar
357
378
  });
358
379
  }
359
380
  })), /*#__PURE__*/React.createElement(ConfirmationModal, {
@@ -0,0 +1,2 @@
1
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
+ export const contextualToolbarPluginKey = new PluginKey('contextualToolbar');
@@ -0,0 +1,36 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { contextualToolbarPluginKey } from './plugin-key';
3
+ const defaultEditState = {
4
+ display: 'collapsed'
5
+ };
6
+ export const contextualToolbarPlugin = () => {
7
+ return new SafePlugin({
8
+ key: contextualToolbarPluginKey,
9
+ state: {
10
+ init() {
11
+ return defaultEditState;
12
+ },
13
+ apply(tr, pluginState) {
14
+ if (pluginState.display === 'static') {
15
+ return pluginState;
16
+ }
17
+ const action = tr.getMeta(contextualToolbarPluginKey);
18
+ if (action) {
19
+ switch (action.type) {
20
+ case 'expand-toolbar':
21
+ return {
22
+ display: 'expanded'
23
+ };
24
+ case 'collapse-toolbar':
25
+ return {
26
+ display: 'collapsed'
27
+ };
28
+ default:
29
+ return pluginState;
30
+ }
31
+ }
32
+ return pluginState;
33
+ }
34
+ }
35
+ });
36
+ };
@@ -29,7 +29,7 @@ const spacerStyles = css({
29
29
  });
30
30
  const separatorStyles = css({
31
31
  background: "var(--ds-border, #091E4224)",
32
- height: '1px'
32
+ height: "var(--ds-space-025, 1px)"
33
33
  });
34
34
 
35
35
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
@@ -273,8 +273,6 @@ const Dropdown = /*#__PURE__*/memo(props => {
273
273
  }
274
274
  }));
275
275
  }
276
-
277
- // here to change based on dropdown type
278
276
  return jsx("div", {
279
277
  css: menuContainerStyles,
280
278
  role: "menu"
@@ -15,10 +15,14 @@ import { areSameItems, messages } from '@atlaskit/editor-common/floating-toolbar
15
15
  import { Announcer, FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
16
16
  import { backgroundPaletteTooltipMessages } from '@atlaskit/editor-common/ui-color';
17
17
  import { ColorPickerButton, ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
18
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
18
19
  import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
19
20
  import { clearHoverSelection } from '@atlaskit/editor-plugin-table/commands';
21
+ import EditIcon from '@atlaskit/icon/core/edit';
20
22
  import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
23
+ import ChevronRightIcon from '@atlaskit/icon/utility/chevron-right';
21
24
  import { fg } from '@atlaskit/platform-feature-flags';
25
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
26
  import { checkShouldForceFocusAndApply, forceFocusSelector } from '../pm-plugins/force-focus';
23
27
  import { showConfirmDialog } from '../pm-plugins/toolbar-data/commands';
24
28
  import Dropdown from './Dropdown';
@@ -344,6 +348,100 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
344
348
  // otherwise it causes an issue where multiple popups stays open
345
349
  return !(prevProps.node.type !== nextProps.node.type || prevProps.node.attrs.localId !== nextProps.node.attrs.localId || !areSameItems(prevProps.items, nextProps.items) || !prevProps.mounted !== !nextProps.mounted);
346
350
  });
351
+ const ToolbarItemsCollapsable = /*#__PURE__*/React.memo(({
352
+ items,
353
+ groupLabel,
354
+ dispatchCommand,
355
+ popupsMountPoint,
356
+ popupsBoundariesElement,
357
+ editorView,
358
+ dispatchAnalyticsEvent,
359
+ popupsScrollableElement,
360
+ scrollable,
361
+ providerFactory,
362
+ extensionsProvider,
363
+ node,
364
+ setDisableScroll,
365
+ mountRef,
366
+ mounted,
367
+ api,
368
+ forceStaticToolbar
369
+ }) => {
370
+ const contextualToolbarState = useSharedPluginStateSelector(api, 'floatingToolbar.contextualToolbar');
371
+ let updatedItems = items.slice();
372
+ if (!forceStaticToolbar && (contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.display) === 'collapsed') {
373
+ let nonSeparatorItems = 0;
374
+ let slicedIndex = -1;
375
+ for (let i = items.length - 1; i > 0; i--) {
376
+ const item = items[i];
377
+ if (item.type !== 'separator') {
378
+ nonSeparatorItems += 1;
379
+ slicedIndex = i;
380
+ }
381
+ if (nonSeparatorItems > 2) {
382
+ break;
383
+ }
384
+ }
385
+ updatedItems = updatedItems.slice(slicedIndex);
386
+ updatedItems.unshift({
387
+ type: 'separator'
388
+ });
389
+ updatedItems.unshift({
390
+ type: 'button',
391
+ icon: EditIcon,
392
+ title: 'Show items',
393
+ onClick: () => {
394
+ if (api) {
395
+ api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
396
+ type: 'expand-toolbar'
397
+ }));
398
+ }
399
+ }
400
+ });
401
+ }
402
+ if (!forceStaticToolbar && (contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.display) === 'expanded') {
403
+ updatedItems.unshift({
404
+ type: 'separator'
405
+ });
406
+ updatedItems.unshift({
407
+ type: 'button',
408
+ icon: ChevronRightIcon,
409
+ title: 'Hide items',
410
+ onClick: () => {
411
+ if (api) {
412
+ api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
413
+ type: 'collapse-toolbar'
414
+ }));
415
+ }
416
+ }
417
+ });
418
+ }
419
+ return jsx(ToolbarItems, {
420
+ items: updatedItems,
421
+ groupLabel: groupLabel,
422
+ dispatchCommand: dispatchCommand,
423
+ popupsMountPoint: popupsMountPoint,
424
+ popupsBoundariesElement: popupsBoundariesElement,
425
+ editorView: editorView,
426
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
427
+ popupsScrollableElement: popupsScrollableElement,
428
+ scrollable: scrollable,
429
+ providerFactory: providerFactory,
430
+ extensionsProvider: extensionsProvider,
431
+ node: node,
432
+ setDisableScroll: setDisableScroll,
433
+ mountRef: mountRef,
434
+ mounted: mounted,
435
+ api: api
436
+ });
437
+ }, (prevProps, nextProps) => {
438
+ if (!nextProps.node) {
439
+ return false;
440
+ }
441
+ // only rerender toolbar items if the node is different
442
+ // otherwise it causes an issue where multiple popups stays open
443
+ return !(prevProps.node.type !== nextProps.node.type || prevProps.node.attrs.localId !== nextProps.node.attrs.localId || !areSameItems(prevProps.items, nextProps.items) || !prevProps.mounted !== !nextProps.mounted);
444
+ });
347
445
  const buttonGroupStyles = css({
348
446
  display: 'flex',
349
447
  gap: "var(--ds-space-050, 4px)"
@@ -583,7 +681,14 @@ class Toolbar extends Component {
583
681
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
584
682
  paddingFeatureFlag: fg('platform_editor_floating_toolbar_padding_fix')
585
683
  })
586
- }, jsx(ToolbarItems
684
+ }, editorExperiment('platform_editor_controls', 'control') ? jsx(ToolbarItems
685
+ // Ignored via go/ees005
686
+ // eslint-disable-next-line react/jsx-props-no-spreading
687
+ , _extends({}, this.props, {
688
+ setDisableScroll: this.setDisableScroll.bind(this),
689
+ mountRef: this.mountRef,
690
+ mounted: this.state.mounted
691
+ })) : jsx(ToolbarItemsCollapsable
587
692
  // Ignored via go/ees005
588
693
  // eslint-disable-next-line react/jsx-props-no-spreading
589
694
  , _extends({}, this.props, {
@@ -12,6 +12,8 @@ import { Popup } from '@atlaskit/editor-common/ui';
12
12
  import { AllSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
13
13
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
14
14
  import { editorExperiment, unstable_editorExperimentParam } from '@atlaskit/tmp-editor-statsig/experiments';
15
+ import { contextualToolbarPlugin } from './pm-plugins/contextual-toolbar/plugin';
16
+ import { contextualToolbarPluginKey } from './pm-plugins/contextual-toolbar/plugin-key';
15
17
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
16
18
  import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
17
19
  import { createPlugin as floatingToolbarDataPluginFactory } from './pm-plugins/toolbar-data/plugin';
@@ -123,7 +125,7 @@ export var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
123
125
  name: 'floatingToolbar',
124
126
  pmPlugins: function pmPlugins() {
125
127
  var floatingToolbarHandlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
126
- return [{
128
+ var plugins = [{
127
129
  // Should be after all toolbar plugins
128
130
  name: 'floatingToolbar',
129
131
  plugin: function plugin(_ref2) {
@@ -147,6 +149,15 @@ export var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
147
149
  return forceFocusPlugin();
148
150
  }
149
151
  }];
152
+ if (!editorExperiment('platform_editor_controls', 'control')) {
153
+ plugins.push({
154
+ name: 'contextualToolbar',
155
+ plugin: function plugin() {
156
+ return contextualToolbarPlugin();
157
+ }
158
+ });
159
+ }
160
+ return plugins;
150
161
  },
151
162
  actions: {
152
163
  forceFocusSelector: forceFocusSelector
@@ -159,16 +170,27 @@ export var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
159
170
  var configWithNodeInfo = (_pluginKey$getState$g = (_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 || (_pluginKey$getState$g2 = _pluginKey$getState.getConfigWithNodeInfo) === null || _pluginKey$getState$g2 === void 0 ? void 0 : _pluginKey$getState$g2.call(_pluginKey$getState, editorState)) !== null && _pluginKey$getState$g !== void 0 ? _pluginKey$getState$g : undefined;
160
171
  return {
161
172
  configWithNodeInfo: configWithNodeInfo,
162
- floatingToolbarData: dataPluginKey.getState(editorState)
173
+ floatingToolbarData: dataPluginKey.getState(editorState),
174
+ // Experimental - excluding this property from the external API whilst it's in development
175
+ contextualToolbar: contextualToolbarPluginKey.getState(editorState)
163
176
  };
164
177
  },
165
- contentComponent: function contentComponent(_ref4) {
166
- var popupsMountPoint = _ref4.popupsMountPoint,
167
- popupsBoundariesElement = _ref4.popupsBoundariesElement,
168
- popupsScrollableElement = _ref4.popupsScrollableElement,
169
- editorView = _ref4.editorView,
170
- providerFactory = _ref4.providerFactory,
171
- dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
178
+ commands: {
179
+ // Experimental
180
+ updateContextualToolbar: function updateContextualToolbar(action) {
181
+ return function (_ref4) {
182
+ var tr = _ref4.tr;
183
+ return tr.setMeta(contextualToolbarPluginKey, action);
184
+ };
185
+ }
186
+ },
187
+ contentComponent: function contentComponent(_ref5) {
188
+ var popupsMountPoint = _ref5.popupsMountPoint,
189
+ popupsBoundariesElement = _ref5.popupsBoundariesElement,
190
+ popupsScrollableElement = _ref5.popupsScrollableElement,
191
+ editorView = _ref5.editorView,
192
+ providerFactory = _ref5.providerFactory,
193
+ dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
172
194
  return /*#__PURE__*/React.createElement(ContentComponent, {
173
195
  editorView: editorView,
174
196
  pluginInjectionApi: api,
@@ -181,23 +203,23 @@ export var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
181
203
  }
182
204
  };
183
205
  };
184
- export function ContentComponent(_ref5) {
206
+ export function ContentComponent(_ref6) {
185
207
  var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
186
- var pluginInjectionApi = _ref5.pluginInjectionApi,
187
- editorView = _ref5.editorView,
188
- popupsMountPoint = _ref5.popupsMountPoint,
189
- popupsBoundariesElement = _ref5.popupsBoundariesElement,
190
- popupsScrollableElement = _ref5.popupsScrollableElement,
191
- providerFactory = _ref5.providerFactory,
192
- dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
208
+ var pluginInjectionApi = _ref6.pluginInjectionApi,
209
+ editorView = _ref6.editorView,
210
+ popupsMountPoint = _ref6.popupsMountPoint,
211
+ popupsBoundariesElement = _ref6.popupsBoundariesElement,
212
+ popupsScrollableElement = _ref6.popupsScrollableElement,
213
+ providerFactory = _ref6.providerFactory,
214
+ dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent;
193
215
  var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'blockControls']),
194
216
  floatingToolbarState = _useSharedPluginState.floatingToolbarState,
195
217
  editorDisabledState = _useSharedPluginState.editorDisabledState,
196
218
  editorViewModeState = _useSharedPluginState.editorViewModeState,
197
219
  blockControlsState = _useSharedPluginState.blockControlsState;
198
- var _ref6 = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {},
199
- configWithNodeInfo = _ref6.configWithNodeInfo,
200
- floatingToolbarData = _ref6.floatingToolbarData;
220
+ var _ref7 = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {},
221
+ configWithNodeInfo = _ref7.configWithNodeInfo,
222
+ floatingToolbarData = _ref7.floatingToolbarData;
201
223
  if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
202
224
  return null;
203
225
  }
@@ -234,7 +256,8 @@ export function ContentComponent(_ref5) {
234
256
  _config$mediaAssistiv = config.mediaAssistiveMessage,
235
257
  mediaAssistiveMessage = _config$mediaAssistiv === void 0 ? '' : _config$mediaAssistiv,
236
258
  _config$stick = config.stick,
237
- stick = _config$stick === void 0 ? true : _config$stick;
259
+ stick = _config$stick === void 0 ? true : _config$stick,
260
+ forceStaticToolbar = config.forceStaticToolbar;
238
261
  var targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
239
262
  var isEditorDisabled = editorDisabledState && editorDisabledState.editorDisabled;
240
263
  var isInViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
@@ -298,8 +321,8 @@ export function ContentComponent(_ref5) {
298
321
  };
299
322
 
300
323
  // Confirm dialog
301
- var _ref7 = floatingToolbarData || {},
302
- confirmDialogForItem = _ref7.confirmDialogForItem;
324
+ var _ref8 = floatingToolbarData || {},
325
+ confirmDialogForItem = _ref8.confirmDialogForItem;
303
326
  var confirmButtonItem = confirmDialogForItem ?
304
327
  // Ignored via go/ees005
305
328
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -362,7 +385,8 @@ export function ContentComponent(_ref5) {
362
385
  extensionsProvider: providers.extensionProvider,
363
386
  scrollable: scrollable,
364
387
  api: pluginInjectionApi,
365
- mediaAssistiveMessage: mediaAssistiveMessage
388
+ mediaAssistiveMessage: mediaAssistiveMessage,
389
+ forceStaticToolbar: forceStaticToolbar
366
390
  });
367
391
  }
368
392
  })), /*#__PURE__*/React.createElement(ConfirmationModal, {
@@ -0,0 +1,2 @@
1
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
+ export var contextualToolbarPluginKey = new PluginKey('contextualToolbar');
@@ -0,0 +1,36 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { contextualToolbarPluginKey } from './plugin-key';
3
+ var defaultEditState = {
4
+ display: 'collapsed'
5
+ };
6
+ export var contextualToolbarPlugin = function contextualToolbarPlugin() {
7
+ return new SafePlugin({
8
+ key: contextualToolbarPluginKey,
9
+ state: {
10
+ init: function init() {
11
+ return defaultEditState;
12
+ },
13
+ apply: function apply(tr, pluginState) {
14
+ if (pluginState.display === 'static') {
15
+ return pluginState;
16
+ }
17
+ var action = tr.getMeta(contextualToolbarPluginKey);
18
+ if (action) {
19
+ switch (action.type) {
20
+ case 'expand-toolbar':
21
+ return {
22
+ display: 'expanded'
23
+ };
24
+ case 'collapse-toolbar':
25
+ return {
26
+ display: 'collapsed'
27
+ };
28
+ default:
29
+ return pluginState;
30
+ }
31
+ }
32
+ return pluginState;
33
+ }
34
+ }
35
+ });
36
+ };
@@ -30,7 +30,7 @@ var spacerStyles = css({
30
30
  });
31
31
  var separatorStyles = css({
32
32
  background: "var(--ds-border, #091E4224)",
33
- height: '1px'
33
+ height: "var(--ds-space-025, 1px)"
34
34
  });
35
35
 
36
36
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
@@ -273,8 +273,6 @@ var Dropdown = /*#__PURE__*/memo(function (props) {
273
273
  }
274
274
  }));
275
275
  }
276
-
277
- // here to change based on dropdown type
278
276
  return jsx("div", {
279
277
  css: menuContainerStyles,
280
278
  role: "menu"
@@ -22,10 +22,14 @@ import { areSameItems, messages } from '@atlaskit/editor-common/floating-toolbar
22
22
  import { Announcer, FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
23
23
  import { backgroundPaletteTooltipMessages } from '@atlaskit/editor-common/ui-color';
24
24
  import { ColorPickerButton, ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
25
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
25
26
  import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
26
27
  import { clearHoverSelection } from '@atlaskit/editor-plugin-table/commands';
28
+ import EditIcon from '@atlaskit/icon/core/edit';
27
29
  import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
30
+ import ChevronRightIcon from '@atlaskit/icon/utility/chevron-right';
28
31
  import { fg } from '@atlaskit/platform-feature-flags';
32
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
29
33
  import { checkShouldForceFocusAndApply, forceFocusSelector } from '../pm-plugins/force-focus';
30
34
  import { showConfirmDialog } from '../pm-plugins/toolbar-data/commands';
31
35
  import Dropdown from './Dropdown';
@@ -374,6 +378,99 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
374
378
  // otherwise it causes an issue where multiple popups stays open
375
379
  return !(prevProps.node.type !== nextProps.node.type || prevProps.node.attrs.localId !== nextProps.node.attrs.localId || !areSameItems(prevProps.items, nextProps.items) || !prevProps.mounted !== !nextProps.mounted);
376
380
  });
381
+ var ToolbarItemsCollapsable = /*#__PURE__*/React.memo(function (_ref2) {
382
+ var items = _ref2.items,
383
+ groupLabel = _ref2.groupLabel,
384
+ dispatchCommand = _ref2.dispatchCommand,
385
+ popupsMountPoint = _ref2.popupsMountPoint,
386
+ popupsBoundariesElement = _ref2.popupsBoundariesElement,
387
+ editorView = _ref2.editorView,
388
+ dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
389
+ popupsScrollableElement = _ref2.popupsScrollableElement,
390
+ scrollable = _ref2.scrollable,
391
+ providerFactory = _ref2.providerFactory,
392
+ extensionsProvider = _ref2.extensionsProvider,
393
+ node = _ref2.node,
394
+ setDisableScroll = _ref2.setDisableScroll,
395
+ mountRef = _ref2.mountRef,
396
+ mounted = _ref2.mounted,
397
+ api = _ref2.api,
398
+ forceStaticToolbar = _ref2.forceStaticToolbar;
399
+ var contextualToolbarState = useSharedPluginStateSelector(api, 'floatingToolbar.contextualToolbar');
400
+ var updatedItems = items.slice();
401
+ if (!forceStaticToolbar && (contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.display) === 'collapsed') {
402
+ var nonSeparatorItems = 0;
403
+ var slicedIndex = -1;
404
+ for (var i = items.length - 1; i > 0; i--) {
405
+ var item = items[i];
406
+ if (item.type !== 'separator') {
407
+ nonSeparatorItems += 1;
408
+ slicedIndex = i;
409
+ }
410
+ if (nonSeparatorItems > 2) {
411
+ break;
412
+ }
413
+ }
414
+ updatedItems = updatedItems.slice(slicedIndex);
415
+ updatedItems.unshift({
416
+ type: 'separator'
417
+ });
418
+ updatedItems.unshift({
419
+ type: 'button',
420
+ icon: EditIcon,
421
+ title: 'Show items',
422
+ onClick: function onClick() {
423
+ if (api) {
424
+ api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
425
+ type: 'expand-toolbar'
426
+ }));
427
+ }
428
+ }
429
+ });
430
+ }
431
+ if (!forceStaticToolbar && (contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.display) === 'expanded') {
432
+ updatedItems.unshift({
433
+ type: 'separator'
434
+ });
435
+ updatedItems.unshift({
436
+ type: 'button',
437
+ icon: ChevronRightIcon,
438
+ title: 'Hide items',
439
+ onClick: function onClick() {
440
+ if (api) {
441
+ api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
442
+ type: 'collapse-toolbar'
443
+ }));
444
+ }
445
+ }
446
+ });
447
+ }
448
+ return jsx(ToolbarItems, {
449
+ items: updatedItems,
450
+ groupLabel: groupLabel,
451
+ dispatchCommand: dispatchCommand,
452
+ popupsMountPoint: popupsMountPoint,
453
+ popupsBoundariesElement: popupsBoundariesElement,
454
+ editorView: editorView,
455
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
456
+ popupsScrollableElement: popupsScrollableElement,
457
+ scrollable: scrollable,
458
+ providerFactory: providerFactory,
459
+ extensionsProvider: extensionsProvider,
460
+ node: node,
461
+ setDisableScroll: setDisableScroll,
462
+ mountRef: mountRef,
463
+ mounted: mounted,
464
+ api: api
465
+ });
466
+ }, function (prevProps, nextProps) {
467
+ if (!nextProps.node) {
468
+ return false;
469
+ }
470
+ // only rerender toolbar items if the node is different
471
+ // otherwise it causes an issue where multiple popups stays open
472
+ return !(prevProps.node.type !== nextProps.node.type || prevProps.node.attrs.localId !== nextProps.node.attrs.localId || !areSameItems(prevProps.items, nextProps.items) || !prevProps.mounted !== !nextProps.mounted);
473
+ });
377
474
  var buttonGroupStyles = css({
378
475
  display: 'flex',
379
476
  gap: "var(--ds-space-050, 4px)"
@@ -423,11 +520,11 @@ var toolbarContainer = function toolbarContainer(scrollable, hasSelect, firstEle
423
520
  };
424
521
 
425
522
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
426
- var toolbarOverflow = function toolbarOverflow(_ref2) {
427
- var scrollable = _ref2.scrollable,
428
- scrollDisabled = _ref2.scrollDisabled,
429
- firstElementIsSelect = _ref2.firstElementIsSelect,
430
- paddingFeatureFlag = _ref2.paddingFeatureFlag;
523
+ var toolbarOverflow = function toolbarOverflow(_ref3) {
524
+ var scrollable = _ref3.scrollable,
525
+ scrollDisabled = _ref3.scrollDisabled,
526
+ firstElementIsSelect = _ref3.firstElementIsSelect,
527
+ paddingFeatureFlag = _ref3.paddingFeatureFlag;
431
528
  return css(
432
529
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
433
530
  scrollable ?
@@ -513,8 +610,8 @@ var Toolbar = /*#__PURE__*/function (_Component) {
513
610
  _inherits(Toolbar, _Component);
514
611
  return _createClass(Toolbar, [{
515
612
  key: "resetStyling",
516
- value: function resetStyling(_ref3) {
517
- var table = _ref3.table;
613
+ value: function resetStyling(_ref4) {
614
+ var table = _ref4.table;
518
615
  if (this.props.editorView) {
519
616
  var _this$props$api;
520
617
  var _this$props$editorVie2 = this.props.editorView,
@@ -630,7 +727,14 @@ var Toolbar = /*#__PURE__*/function (_Component) {
630
727
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
631
728
  paddingFeatureFlag: fg('platform_editor_floating_toolbar_padding_fix')
632
729
  })
633
- }, jsx(ToolbarItems
730
+ }, editorExperiment('platform_editor_controls', 'control') ? jsx(ToolbarItems
731
+ // Ignored via go/ees005
732
+ // eslint-disable-next-line react/jsx-props-no-spreading
733
+ , _extends({}, this.props, {
734
+ setDisableScroll: this.setDisableScroll.bind(this),
735
+ mountRef: this.mountRef,
736
+ mounted: this.state.mounted
737
+ })) : jsx(ToolbarItemsCollapsable
634
738
  // Ignored via go/ees005
635
739
  // eslint-disable-next-line react/jsx-props-no-spreading
636
740
  , _extends({}, this.props, {
@@ -1,4 +1,4 @@
1
- import type { FloatingToolbarConfig, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, FloatingToolbarConfig, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
3
3
  import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
4
4
  import type { CopyButtonPlugin } from '@atlaskit/editor-plugin-copy-button';
@@ -10,6 +10,7 @@ import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
10
10
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
11
11
  import type { Node } from '@atlaskit/editor-prosemirror/model';
12
12
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
13
+ import type { ContextualToolbarActions, ContextualToolbarState } from './pm-plugins/contextual-toolbar/types';
13
14
  export type ConfigWithNodeInfo = {
14
15
  config: FloatingToolbarConfig | undefined;
15
16
  pos: number;
@@ -47,3 +48,17 @@ export type FloatingToolbarPlugin = NextEditorPlugin<'floatingToolbar', {
47
48
  floatingToolbarData: FloatingToolbarPluginData | undefined;
48
49
  } | undefined;
49
50
  }>;
51
+ export type FloatingToolbarPluginNext = NextEditorPlugin<'floatingToolbar', {
52
+ dependencies: FloatingToolbarPluginDependencies;
53
+ actions: {
54
+ forceFocusSelector: ForceFocusSelector;
55
+ };
56
+ sharedState: {
57
+ configWithNodeInfo: ConfigWithNodeInfo | undefined;
58
+ floatingToolbarData: FloatingToolbarPluginData | undefined;
59
+ contextualToolbar: ContextualToolbarState | undefined;
60
+ } | undefined;
61
+ commands: {
62
+ updateContextualToolbar: (action: ContextualToolbarActions) => EditorCommand;
63
+ };
64
+ }>;
@@ -0,0 +1,3 @@
1
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
+ import type { ContextualToolbarState } from './types';
3
+ export declare const contextualToolbarPluginKey: PluginKey<ContextualToolbarState>;
@@ -0,0 +1,4 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ export declare const contextualToolbarPlugin: () => SafePlugin<{
3
+ display: string;
4
+ }>;
@@ -0,0 +1,8 @@
1
+ export type ContextualToolbarState = {
2
+ display: 'expanded' | 'collapsed' | 'static';
3
+ };
4
+ export type ContextualToolbarActions = {
5
+ type: 'expand-toolbar';
6
+ } | {
7
+ type: 'collapse-toolbar';
8
+ };
@@ -30,6 +30,7 @@ export interface Props {
30
30
  scrollable?: boolean;
31
31
  api: ExtractInjectionAPI<FloatingToolbarPlugin> | undefined;
32
32
  mediaAssistiveMessage?: string;
33
+ forceStaticToolbar?: boolean;
33
34
  }
34
35
  type GroupedItems = (Item | Item[])[];
35
36
  export declare function groupItems(items: Item[]): GroupedItems;
@@ -1,4 +1,4 @@
1
- import type { FloatingToolbarConfig, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, FloatingToolbarConfig, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
3
3
  import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
4
4
  import type { CopyButtonPlugin } from '@atlaskit/editor-plugin-copy-button';
@@ -10,6 +10,7 @@ import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
10
10
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
11
11
  import type { Node } from '@atlaskit/editor-prosemirror/model';
12
12
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
13
+ import type { ContextualToolbarActions, ContextualToolbarState } from './pm-plugins/contextual-toolbar/types';
13
14
  export type ConfigWithNodeInfo = {
14
15
  config: FloatingToolbarConfig | undefined;
15
16
  pos: number;
@@ -47,3 +48,17 @@ export type FloatingToolbarPlugin = NextEditorPlugin<'floatingToolbar', {
47
48
  floatingToolbarData: FloatingToolbarPluginData | undefined;
48
49
  } | undefined;
49
50
  }>;
51
+ export type FloatingToolbarPluginNext = NextEditorPlugin<'floatingToolbar', {
52
+ dependencies: FloatingToolbarPluginDependencies;
53
+ actions: {
54
+ forceFocusSelector: ForceFocusSelector;
55
+ };
56
+ sharedState: {
57
+ configWithNodeInfo: ConfigWithNodeInfo | undefined;
58
+ floatingToolbarData: FloatingToolbarPluginData | undefined;
59
+ contextualToolbar: ContextualToolbarState | undefined;
60
+ } | undefined;
61
+ commands: {
62
+ updateContextualToolbar: (action: ContextualToolbarActions) => EditorCommand;
63
+ };
64
+ }>;
@@ -0,0 +1,3 @@
1
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
+ import type { ContextualToolbarState } from './types';
3
+ export declare const contextualToolbarPluginKey: PluginKey<ContextualToolbarState>;
@@ -0,0 +1,4 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ export declare const contextualToolbarPlugin: () => SafePlugin<{
3
+ display: string;
4
+ }>;
@@ -0,0 +1,8 @@
1
+ export type ContextualToolbarState = {
2
+ display: 'expanded' | 'collapsed' | 'static';
3
+ };
4
+ export type ContextualToolbarActions = {
5
+ type: 'expand-toolbar';
6
+ } | {
7
+ type: 'collapse-toolbar';
8
+ };
@@ -30,6 +30,7 @@ export interface Props {
30
30
  scrollable?: boolean;
31
31
  api: ExtractInjectionAPI<FloatingToolbarPlugin> | undefined;
32
32
  mediaAssistiveMessage?: string;
33
+ forceStaticToolbar?: boolean;
33
34
  }
34
35
  type GroupedItems = (Item | Item[])[];
35
36
  export declare function groupItems(items: Item[]): GroupedItems;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-floating-toolbar",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "Floating toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -25,10 +25,10 @@
25
25
  "dependencies": {
26
26
  "@atlaskit/adf-utils": "^19.18.0",
27
27
  "@atlaskit/button": "^20.5.0",
28
- "@atlaskit/checkbox": "^15.3.0",
29
- "@atlaskit/editor-common": "^99.15.0",
28
+ "@atlaskit/checkbox": "^15.4.0",
29
+ "@atlaskit/editor-common": "^99.18.0",
30
30
  "@atlaskit/editor-palette": "1.7.0",
31
- "@atlaskit/editor-plugin-block-controls": "^2.26.0",
31
+ "@atlaskit/editor-plugin-block-controls": "^2.27.0",
32
32
  "@atlaskit/editor-plugin-context-panel": "^2.1.0",
33
33
  "@atlaskit/editor-plugin-copy-button": "^1.5.0",
34
34
  "@atlaskit/editor-plugin-decorations": "^1.5.0",
@@ -39,16 +39,16 @@
39
39
  "@atlaskit/editor-plugin-table": "^9.5.0",
40
40
  "@atlaskit/editor-prosemirror": "7.0.0",
41
41
  "@atlaskit/emoji": "^67.14.0",
42
- "@atlaskit/icon": "^23.9.0",
42
+ "@atlaskit/icon": "^23.10.0",
43
43
  "@atlaskit/menu": "^2.14.0",
44
44
  "@atlaskit/modal-dialog": "^12.20.0",
45
- "@atlaskit/platform-feature-flags": "^1.0.0",
46
- "@atlaskit/primitives": "^13.5.0",
45
+ "@atlaskit/platform-feature-flags": "^1.1.0",
46
+ "@atlaskit/primitives": "^13.6.0",
47
47
  "@atlaskit/select": "^18.10.0",
48
- "@atlaskit/theme": "^15.0.0",
49
- "@atlaskit/tmp-editor-statsig": "^2.46.0",
48
+ "@atlaskit/theme": "^16.0.0",
49
+ "@atlaskit/tmp-editor-statsig": "^2.47.0",
50
50
  "@atlaskit/tokens": "^3.3.0",
51
- "@atlaskit/tooltip": "^19.1.0",
51
+ "@atlaskit/tooltip": "^19.2.0",
52
52
  "@babel/runtime": "^7.0.0",
53
53
  "@emotion/react": "^11.7.1",
54
54
  "lodash": "^4.17.21",