@atlaskit/editor-plugin-floating-toolbar 1.19.0 → 1.20.1

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,22 @@
1
1
  # @atlaskit/editor-plugin-floating-toolbar
2
2
 
3
+ ## 1.20.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#117370](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117370)
8
+ [`bdcaab521f1ee`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bdcaab521f1ee) -
9
+ Make logic for collapse toolbar dynamic, apply only to card elements for now
10
+ - Updated dependencies
11
+
12
+ ## 1.20.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#117197](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117197)
17
+ [`d6202c120a039`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d6202c120a039) -
18
+ Remove @atlaskit/heading import which broke previous versions, replace with HeadingItem
19
+
3
20
  ## 1.19.0
4
21
 
5
22
  ### Minor Changes
@@ -7,7 +7,7 @@ exports.contextualToolbarPlugin = void 0;
7
7
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
8
  var _pluginKey = require("./plugin-key");
9
9
  var defaultEditState = {
10
- display: 'collapsed'
10
+ isCollapsed: true
11
11
  };
12
12
  var contextualToolbarPlugin = exports.contextualToolbarPlugin = function contextualToolbarPlugin() {
13
13
  return new _safePlugin.SafePlugin({
@@ -17,19 +17,16 @@ var contextualToolbarPlugin = exports.contextualToolbarPlugin = function context
17
17
  return defaultEditState;
18
18
  },
19
19
  apply: function apply(tr, pluginState) {
20
- if (pluginState.display === 'static') {
21
- return pluginState;
22
- }
23
20
  var action = tr.getMeta(_pluginKey.contextualToolbarPluginKey);
24
21
  if (action) {
25
22
  switch (action.type) {
26
23
  case 'expand-toolbar':
27
24
  return {
28
- display: 'expanded'
25
+ isCollapsed: false
29
26
  };
30
27
  case 'collapse-toolbar':
31
28
  return {
32
- display: 'collapsed'
29
+ isCollapsed: true
33
30
  };
34
31
  default:
35
32
  return pluginState;
@@ -10,7 +10,6 @@ var _react = require("react");
10
10
  var _react2 = require("@emotion/react");
11
11
  var _reactIntlNext = require("react-intl-next");
12
12
  var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
13
- var _heading = _interopRequireDefault(require("@atlaskit/heading"));
14
13
  var _done = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/done"));
15
14
  var _menu = require("@atlaskit/menu");
16
15
  var _colors = require("@atlaskit/theme/colors");
@@ -41,6 +40,9 @@ var separatorStyles = (0, _react2.css)({
41
40
  background: "var(--ds-border, #091E4224)",
42
41
  height: "var(--ds-space-025, 1px)"
43
42
  });
43
+ var headingStyles = (0, _react2.css)({
44
+ padding: "var(--ds-space-100, 8px)".concat(" 0")
45
+ });
44
46
 
45
47
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
46
48
  var menuContainerStyles = (0, _react2.css)({
@@ -268,17 +270,10 @@ var Dropdown = /*#__PURE__*/(0, _react.memo)(function (props) {
268
270
  });
269
271
  }
270
272
  if (item.type === 'overflow-dropdown-heading') {
271
- return (
272
- // eslint-disable-next-line react/no-array-index-key, @atlaskit/ui-styling-standard/enforce-style-prop
273
- (0, _react2.jsx)("div", {
274
- key: idx,
275
- style: {
276
- padding: '10px'
277
- }
278
- }, (0, _react2.jsx)(_heading.default, {
279
- size: "xxsmall"
280
- }, item.title))
281
- );
273
+ return (0, _react2.jsx)("div", {
274
+ key: item.title,
275
+ css: headingStyles
276
+ }, (0, _react2.jsx)(_menu.HeadingItem, null, item.title));
282
277
  }
283
278
  }));
284
279
  }
@@ -41,7 +41,9 @@ var _Select = _interopRequireDefault(require("./Select"));
41
41
  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); }
42
42
  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; }
43
43
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
44
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation */ /**
44
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
45
+ 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; }
46
+ 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) { (0, _defineProperty2.default)(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; } /* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation */ /**
45
47
  * @jsxRuntime classic
46
48
  * @jsx jsx
47
49
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
@@ -385,40 +387,16 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
385
387
  // otherwise it causes an issue where multiple popups stays open
386
388
  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);
387
389
  });
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
- }
390
+ var getFormattedItems = function getFormattedItems(items, isCollapsed, api) {
391
+ if (isCollapsed) {
392
+ var updatedItems = items.filter(function (item) {
393
+ return item.type === 'separator' || 'contextualToolbarDefaultVisibility' in item && item.contextualToolbarDefaultVisibility === 'visible' || !('contextualToolbarDefaultVisibility' in item);
394
+ }).filter(function (item, index, items) {
395
+ return item.type !== 'separator' || index > 0 && index < items.length - 1 && items[index - 1].type !== 'separator';
396
+ });
397
+ if (updatedItems[updatedItems.length - 1].type === 'separator') {
398
+ updatedItems.pop();
420
399
  }
421
- updatedItems = updatedItems.slice(slicedIndex);
422
400
  updatedItems.unshift({
423
401
  type: 'separator'
424
402
  });
@@ -434,24 +412,55 @@ var ToolbarItemsCollapsable = /*#__PURE__*/_react.default.memo(function (_ref2)
434
412
  }
435
413
  }
436
414
  });
415
+ return updatedItems;
437
416
  }
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
- }
417
+ items.unshift({
418
+ type: 'separator'
419
+ });
420
+ items.unshift({
421
+ type: 'button',
422
+ icon: _chevronRight.default,
423
+ title: 'Hide items',
424
+ onClick: function onClick() {
425
+ if (api) {
426
+ api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
427
+ type: 'collapse-toolbar'
428
+ }));
452
429
  }
430
+ }
431
+ });
432
+ return items;
433
+ };
434
+ var ToolbarItemsCollapsable = /*#__PURE__*/_react.default.memo(function (_ref2) {
435
+ var _contextualToolbarSta;
436
+ var items = _ref2.items,
437
+ groupLabel = _ref2.groupLabel,
438
+ dispatchCommand = _ref2.dispatchCommand,
439
+ popupsMountPoint = _ref2.popupsMountPoint,
440
+ popupsBoundariesElement = _ref2.popupsBoundariesElement,
441
+ editorView = _ref2.editorView,
442
+ dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
443
+ popupsScrollableElement = _ref2.popupsScrollableElement,
444
+ scrollable = _ref2.scrollable,
445
+ providerFactory = _ref2.providerFactory,
446
+ extensionsProvider = _ref2.extensionsProvider,
447
+ node = _ref2.node,
448
+ setDisableScroll = _ref2.setDisableScroll,
449
+ mountRef = _ref2.mountRef,
450
+ mounted = _ref2.mounted,
451
+ api = _ref2.api;
452
+ var contextualToolbarState = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'floatingToolbar.contextualToolbar');
453
+
454
+ // NOTE: Unsure if collapse/expand logic will be needed, for now hard code for cards
455
+ var isCard = node.type.name === 'inlineCard' || node.type.name === 'blockCard' || node.type.name === 'embedCard';
456
+ var updatedItems = isCard ? getFormattedItems(items.map(function (item) {
457
+ if ('id' in item && (item.id === 'editor.link.openLink' || item.id === 'editor.floatingToolbar.copy' || item.id === 'editor.link.commentLink')) {
458
+ return item;
459
+ }
460
+ return _objectSpread(_objectSpread({}, item), {}, {
461
+ contextualToolbarDefaultVisibility: 'hidden'
453
462
  });
454
- }
463
+ }), (_contextualToolbarSta = contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.isCollapsed) !== null && _contextualToolbarSta !== void 0 ? _contextualToolbarSta : false, api) : items;
455
464
  return (0, _react2.jsx)(ToolbarItems, {
456
465
  items: updatedItems,
457
466
  groupLabel: groupLabel,
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { contextualToolbarPluginKey } from './plugin-key';
3
3
  const defaultEditState = {
4
- display: 'collapsed'
4
+ isCollapsed: true
5
5
  };
6
6
  export const contextualToolbarPlugin = () => {
7
7
  return new SafePlugin({
@@ -11,19 +11,16 @@ export const contextualToolbarPlugin = () => {
11
11
  return defaultEditState;
12
12
  },
13
13
  apply(tr, pluginState) {
14
- if (pluginState.display === 'static') {
15
- return pluginState;
16
- }
17
14
  const action = tr.getMeta(contextualToolbarPluginKey);
18
15
  if (action) {
19
16
  switch (action.type) {
20
17
  case 'expand-toolbar':
21
18
  return {
22
- display: 'expanded'
19
+ isCollapsed: false
23
20
  };
24
21
  case 'collapse-toolbar':
25
22
  return {
26
- display: 'collapsed'
23
+ isCollapsed: true
27
24
  };
28
25
  default:
29
26
  return pluginState;
@@ -10,9 +10,8 @@ import { css, jsx } from '@emotion/react';
10
10
 
11
11
  import { injectIntl } from 'react-intl-next';
12
12
  import { messages } from '@atlaskit/editor-common/floating-toolbar';
13
- import Heading from '@atlaskit/heading';
14
13
  import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
15
- import { ButtonItem } from '@atlaskit/menu';
14
+ import { ButtonItem, HeadingItem } from '@atlaskit/menu';
16
15
  import { B400 } from '@atlaskit/theme/colors';
17
16
  // eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
18
17
  import { gridSize } from '@atlaskit/theme/constants';
@@ -31,6 +30,9 @@ const separatorStyles = css({
31
30
  background: "var(--ds-border, #091E4224)",
32
31
  height: "var(--ds-space-025, 1px)"
33
32
  });
33
+ const headingStyles = css({
34
+ padding: `${"var(--ds-space-100, 8px)"} 0`
35
+ });
34
36
 
35
37
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
36
38
  const menuContainerStyles = css({
@@ -259,17 +261,10 @@ const Dropdown = /*#__PURE__*/memo(props => {
259
261
  });
260
262
  }
261
263
  if (item.type === 'overflow-dropdown-heading') {
262
- return (
263
- // eslint-disable-next-line react/no-array-index-key, @atlaskit/ui-styling-standard/enforce-style-prop
264
- jsx("div", {
265
- key: idx,
266
- style: {
267
- padding: '10px'
268
- }
269
- }, jsx(Heading, {
270
- size: "xxsmall"
271
- }, item.title))
272
- );
264
+ return jsx("div", {
265
+ key: item.title,
266
+ css: headingStyles
267
+ }, jsx(HeadingItem, null, item.title));
273
268
  }
274
269
  }));
275
270
  }
@@ -348,6 +348,46 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
348
348
  // otherwise it causes an issue where multiple popups stays open
349
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);
350
350
  });
351
+ const getFormattedItems = (items, isCollapsed, api) => {
352
+ if (isCollapsed) {
353
+ const updatedItems = items.filter(item => item.type === 'separator' || 'contextualToolbarDefaultVisibility' in item && item.contextualToolbarDefaultVisibility === 'visible' || !('contextualToolbarDefaultVisibility' in item)).filter((item, index, items) => item.type !== 'separator' || index > 0 && index < items.length - 1 && items[index - 1].type !== 'separator');
354
+ if (updatedItems[updatedItems.length - 1].type === 'separator') {
355
+ updatedItems.pop();
356
+ }
357
+ updatedItems.unshift({
358
+ type: 'separator'
359
+ });
360
+ updatedItems.unshift({
361
+ type: 'button',
362
+ icon: EditIcon,
363
+ title: 'Show items',
364
+ onClick: () => {
365
+ if (api) {
366
+ api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
367
+ type: 'expand-toolbar'
368
+ }));
369
+ }
370
+ }
371
+ });
372
+ return updatedItems;
373
+ }
374
+ items.unshift({
375
+ type: 'separator'
376
+ });
377
+ items.unshift({
378
+ type: 'button',
379
+ icon: ChevronRightIcon,
380
+ title: 'Hide items',
381
+ onClick: () => {
382
+ if (api) {
383
+ api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
384
+ type: 'collapse-toolbar'
385
+ }));
386
+ }
387
+ }
388
+ });
389
+ return items;
390
+ };
351
391
  const ToolbarItemsCollapsable = /*#__PURE__*/React.memo(({
352
392
  items,
353
393
  groupLabel,
@@ -364,58 +404,22 @@ const ToolbarItemsCollapsable = /*#__PURE__*/React.memo(({
364
404
  setDisableScroll,
365
405
  mountRef,
366
406
  mounted,
367
- api,
368
- forceStaticToolbar
407
+ api
369
408
  }) => {
409
+ var _contextualToolbarSta;
370
410
  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
- }
411
+
412
+ // NOTE: Unsure if collapse/expand logic will be needed, for now hard code for cards
413
+ const isCard = node.type.name === 'inlineCard' || node.type.name === 'blockCard' || node.type.name === 'embedCard';
414
+ const updatedItems = isCard ? getFormattedItems(items.map(item => {
415
+ if ('id' in item && (item.id === 'editor.link.openLink' || item.id === 'editor.floatingToolbar.copy' || item.id === 'editor.link.commentLink')) {
416
+ return item;
384
417
  }
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
- }
418
+ return {
419
+ ...item,
420
+ contextualToolbarDefaultVisibility: 'hidden'
421
+ };
422
+ }), (_contextualToolbarSta = contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.isCollapsed) !== null && _contextualToolbarSta !== void 0 ? _contextualToolbarSta : false, api) : items;
419
423
  return jsx(ToolbarItems, {
420
424
  items: updatedItems,
421
425
  groupLabel: groupLabel,
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { contextualToolbarPluginKey } from './plugin-key';
3
3
  var defaultEditState = {
4
- display: 'collapsed'
4
+ isCollapsed: true
5
5
  };
6
6
  export var contextualToolbarPlugin = function contextualToolbarPlugin() {
7
7
  return new SafePlugin({
@@ -11,19 +11,16 @@ export var contextualToolbarPlugin = function contextualToolbarPlugin() {
11
11
  return defaultEditState;
12
12
  },
13
13
  apply: function apply(tr, pluginState) {
14
- if (pluginState.display === 'static') {
15
- return pluginState;
16
- }
17
14
  var action = tr.getMeta(contextualToolbarPluginKey);
18
15
  if (action) {
19
16
  switch (action.type) {
20
17
  case 'expand-toolbar':
21
18
  return {
22
- display: 'expanded'
19
+ isCollapsed: false
23
20
  };
24
21
  case 'collapse-toolbar':
25
22
  return {
26
- display: 'collapsed'
23
+ isCollapsed: true
27
24
  };
28
25
  default:
29
26
  return pluginState;
@@ -11,9 +11,8 @@ import { css, jsx } from '@emotion/react';
11
11
 
12
12
  import { injectIntl } from 'react-intl-next';
13
13
  import { messages } from '@atlaskit/editor-common/floating-toolbar';
14
- import Heading from '@atlaskit/heading';
15
14
  import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
16
- import { ButtonItem } from '@atlaskit/menu';
15
+ import { ButtonItem, HeadingItem } from '@atlaskit/menu';
17
16
  import { B400 } from '@atlaskit/theme/colors';
18
17
  // eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
19
18
  import { gridSize } from '@atlaskit/theme/constants';
@@ -32,6 +31,9 @@ var separatorStyles = css({
32
31
  background: "var(--ds-border, #091E4224)",
33
32
  height: "var(--ds-space-025, 1px)"
34
33
  });
34
+ var headingStyles = css({
35
+ padding: "var(--ds-space-100, 8px)".concat(" 0")
36
+ });
35
37
 
36
38
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
37
39
  var menuContainerStyles = css({
@@ -259,17 +261,10 @@ var Dropdown = /*#__PURE__*/memo(function (props) {
259
261
  });
260
262
  }
261
263
  if (item.type === 'overflow-dropdown-heading') {
262
- return (
263
- // eslint-disable-next-line react/no-array-index-key, @atlaskit/ui-styling-standard/enforce-style-prop
264
- jsx("div", {
265
- key: idx,
266
- style: {
267
- padding: '10px'
268
- }
269
- }, jsx(Heading, {
270
- size: "xxsmall"
271
- }, item.title))
272
- );
264
+ return jsx("div", {
265
+ key: item.title,
266
+ css: headingStyles
267
+ }, jsx(HeadingItem, null, item.title));
273
268
  }
274
269
  }));
275
270
  }
@@ -7,6 +7,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
8
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
+ 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; }
11
+ 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; }
10
12
  /* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation */
11
13
  /**
12
14
  * @jsxRuntime classic
@@ -378,40 +380,16 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
378
380
  // otherwise it causes an issue where multiple popups stays open
379
381
  return !(prevProps.node.type !== nextProps.node.type || prevProps.node.attrs.localId !== nextProps.node.attrs.localId || !areSameItems(prevProps.items, nextProps.items) || !prevProps.mounted !== !nextProps.mounted);
380
382
  });
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
- }
383
+ var getFormattedItems = function getFormattedItems(items, isCollapsed, api) {
384
+ if (isCollapsed) {
385
+ var updatedItems = items.filter(function (item) {
386
+ return item.type === 'separator' || 'contextualToolbarDefaultVisibility' in item && item.contextualToolbarDefaultVisibility === 'visible' || !('contextualToolbarDefaultVisibility' in item);
387
+ }).filter(function (item, index, items) {
388
+ return item.type !== 'separator' || index > 0 && index < items.length - 1 && items[index - 1].type !== 'separator';
389
+ });
390
+ if (updatedItems[updatedItems.length - 1].type === 'separator') {
391
+ updatedItems.pop();
413
392
  }
414
- updatedItems = updatedItems.slice(slicedIndex);
415
393
  updatedItems.unshift({
416
394
  type: 'separator'
417
395
  });
@@ -427,24 +405,55 @@ var ToolbarItemsCollapsable = /*#__PURE__*/React.memo(function (_ref2) {
427
405
  }
428
406
  }
429
407
  });
408
+ return updatedItems;
430
409
  }
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
- }
410
+ items.unshift({
411
+ type: 'separator'
412
+ });
413
+ items.unshift({
414
+ type: 'button',
415
+ icon: ChevronRightIcon,
416
+ title: 'Hide items',
417
+ onClick: function onClick() {
418
+ if (api) {
419
+ api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
420
+ type: 'collapse-toolbar'
421
+ }));
445
422
  }
423
+ }
424
+ });
425
+ return items;
426
+ };
427
+ var ToolbarItemsCollapsable = /*#__PURE__*/React.memo(function (_ref2) {
428
+ var _contextualToolbarSta;
429
+ var items = _ref2.items,
430
+ groupLabel = _ref2.groupLabel,
431
+ dispatchCommand = _ref2.dispatchCommand,
432
+ popupsMountPoint = _ref2.popupsMountPoint,
433
+ popupsBoundariesElement = _ref2.popupsBoundariesElement,
434
+ editorView = _ref2.editorView,
435
+ dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
436
+ popupsScrollableElement = _ref2.popupsScrollableElement,
437
+ scrollable = _ref2.scrollable,
438
+ providerFactory = _ref2.providerFactory,
439
+ extensionsProvider = _ref2.extensionsProvider,
440
+ node = _ref2.node,
441
+ setDisableScroll = _ref2.setDisableScroll,
442
+ mountRef = _ref2.mountRef,
443
+ mounted = _ref2.mounted,
444
+ api = _ref2.api;
445
+ var contextualToolbarState = useSharedPluginStateSelector(api, 'floatingToolbar.contextualToolbar');
446
+
447
+ // NOTE: Unsure if collapse/expand logic will be needed, for now hard code for cards
448
+ var isCard = node.type.name === 'inlineCard' || node.type.name === 'blockCard' || node.type.name === 'embedCard';
449
+ var updatedItems = isCard ? getFormattedItems(items.map(function (item) {
450
+ if ('id' in item && (item.id === 'editor.link.openLink' || item.id === 'editor.floatingToolbar.copy' || item.id === 'editor.link.commentLink')) {
451
+ return item;
452
+ }
453
+ return _objectSpread(_objectSpread({}, item), {}, {
454
+ contextualToolbarDefaultVisibility: 'hidden'
446
455
  });
447
- }
456
+ }), (_contextualToolbarSta = contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.isCollapsed) !== null && _contextualToolbarSta !== void 0 ? _contextualToolbarSta : false, api) : items;
448
457
  return jsx(ToolbarItems, {
449
458
  items: updatedItems,
450
459
  groupLabel: groupLabel,
@@ -1,4 +1,3 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export declare const contextualToolbarPlugin: () => SafePlugin<{
3
- display: string;
4
- }>;
2
+ import type { ContextualToolbarState } from './types';
3
+ export declare const contextualToolbarPlugin: () => SafePlugin<ContextualToolbarState>;
@@ -1,5 +1,5 @@
1
1
  export type ContextualToolbarState = {
2
- display: 'expanded' | 'collapsed' | 'static';
2
+ isCollapsed: boolean;
3
3
  };
4
4
  export type ContextualToolbarActions = {
5
5
  type: 'expand-toolbar';
@@ -1,4 +1,3 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export declare const contextualToolbarPlugin: () => SafePlugin<{
3
- display: string;
4
- }>;
2
+ import type { ContextualToolbarState } from './types';
3
+ export declare const contextualToolbarPlugin: () => SafePlugin<ContextualToolbarState>;
@@ -1,5 +1,5 @@
1
1
  export type ContextualToolbarState = {
2
- display: 'expanded' | 'collapsed' | 'static';
2
+ isCollapsed: boolean;
3
3
  };
4
4
  export type ContextualToolbarActions = {
5
5
  type: 'expand-toolbar';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-floating-toolbar",
3
- "version": "1.19.0",
3
+ "version": "1.20.1",
4
4
  "description": "Floating toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -26,7 +26,7 @@
26
26
  "@atlaskit/adf-utils": "^19.18.0",
27
27
  "@atlaskit/button": "^20.5.0",
28
28
  "@atlaskit/checkbox": "^15.4.0",
29
- "@atlaskit/editor-common": "^99.18.0",
29
+ "@atlaskit/editor-common": "^99.19.0",
30
30
  "@atlaskit/editor-palette": "1.7.0",
31
31
  "@atlaskit/editor-plugin-block-controls": "^2.27.0",
32
32
  "@atlaskit/editor-plugin-context-panel": "^2.1.0",
@@ -39,7 +39,7 @@
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.10.0",
42
+ "@atlaskit/icon": "^23.11.0",
43
43
  "@atlaskit/menu": "^2.14.0",
44
44
  "@atlaskit/modal-dialog": "^12.20.0",
45
45
  "@atlaskit/platform-feature-flags": "^1.1.0",