@atlaskit/editor-plugin-floating-toolbar 1.20.0 → 2.0.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.
- package/CHANGELOG.md +27 -0
- package/dist/cjs/pm-plugins/contextual-toolbar/plugin.js +3 -6
- package/dist/cjs/ui/Toolbar.js +58 -49
- package/dist/es2019/pm-plugins/contextual-toolbar/plugin.js +3 -6
- package/dist/es2019/ui/Toolbar.js +53 -49
- package/dist/esm/pm-plugins/contextual-toolbar/plugin.js +3 -6
- package/dist/esm/ui/Toolbar.js +57 -48
- package/dist/types/pm-plugins/contextual-toolbar/plugin.d.ts +2 -3
- package/dist/types/pm-plugins/contextual-toolbar/types.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/contextual-toolbar/plugin.d.ts +2 -3
- package/dist/types-ts4.5/pm-plugins/contextual-toolbar/types.d.ts +1 -1
- package/package.json +26 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-floating-toolbar
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#117363](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117363)
|
|
8
|
+
[`10a0f7f6c2027`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/10a0f7f6c2027) -
|
|
9
|
+
This package's `peerDependencies` have been adjusted for `react` and/or `react-dom` to reflect the
|
|
10
|
+
status of only supporting React 18 going forward. No explicit breaking change to React support has
|
|
11
|
+
been made in this release, but this is to signify going forward, breaking changes for React 16 or
|
|
12
|
+
React 17 may come via non-major semver releases.
|
|
13
|
+
|
|
14
|
+
Please refer this community post for more details:
|
|
15
|
+
https://community.developer.atlassian.com/t/rfc-78-dropping-support-for-react-16-and-rendering-in-a-react-18-concurrent-root-in-jira-and-confluence/87026
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
21
|
+
## 1.20.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#117370](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117370)
|
|
26
|
+
[`bdcaab521f1ee`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bdcaab521f1ee) -
|
|
27
|
+
Make logic for collapse toolbar dynamic, apply only to card elements for now
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
|
|
3
30
|
## 1.20.0
|
|
4
31
|
|
|
5
32
|
### 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
|
-
|
|
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
|
-
|
|
25
|
+
isCollapsed: false
|
|
29
26
|
};
|
|
30
27
|
case 'collapse-toolbar':
|
|
31
28
|
return {
|
|
32
|
-
|
|
29
|
+
isCollapsed: true
|
|
33
30
|
};
|
|
34
31
|
default:
|
|
35
32
|
return pluginState;
|
package/dist/cjs/ui/Toolbar.js
CHANGED
|
@@ -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; })(); }
|
|
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
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
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
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
+
isCollapsed: false
|
|
23
20
|
};
|
|
24
21
|
case 'collapse-toolbar':
|
|
25
22
|
return {
|
|
26
|
-
|
|
23
|
+
isCollapsed: true
|
|
27
24
|
};
|
|
28
25
|
default:
|
|
29
26
|
return pluginState;
|
|
@@ -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
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
+
isCollapsed: false
|
|
23
20
|
};
|
|
24
21
|
case 'collapse-toolbar':
|
|
25
22
|
return {
|
|
26
|
-
|
|
23
|
+
isCollapsed: true
|
|
27
24
|
};
|
|
28
25
|
default:
|
|
29
26
|
return pluginState;
|
package/dist/esm/ui/Toolbar.js
CHANGED
|
@@ -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
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
}>;
|
|
2
|
+
import type { ContextualToolbarState } from './types';
|
|
3
|
+
export declare const contextualToolbarPlugin: () => SafePlugin<ContextualToolbarState>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}>;
|
|
2
|
+
import type { ContextualToolbarState } from './types';
|
|
3
|
+
export declare const contextualToolbarPlugin: () => SafePlugin<ContextualToolbarState>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-floating-toolbar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Floating toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,31 +24,31 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@atlaskit/adf-utils": "^19.18.0",
|
|
27
|
-
"@atlaskit/button": "^
|
|
28
|
-
"@atlaskit/checkbox": "^
|
|
29
|
-
"@atlaskit/editor-common": "^
|
|
30
|
-
"@atlaskit/editor-palette": "
|
|
31
|
-
"@atlaskit/editor-plugin-block-controls": "^
|
|
32
|
-
"@atlaskit/editor-plugin-context-panel": "^
|
|
33
|
-
"@atlaskit/editor-plugin-copy-button": "^
|
|
34
|
-
"@atlaskit/editor-plugin-decorations": "^
|
|
35
|
-
"@atlaskit/editor-plugin-editor-disabled": "^
|
|
36
|
-
"@atlaskit/editor-plugin-editor-viewmode": "^
|
|
37
|
-
"@atlaskit/editor-plugin-emoji": "^
|
|
38
|
-
"@atlaskit/editor-plugin-extension": "^
|
|
39
|
-
"@atlaskit/editor-plugin-table": "^
|
|
27
|
+
"@atlaskit/button": "^21.0.0",
|
|
28
|
+
"@atlaskit/checkbox": "^16.0.0",
|
|
29
|
+
"@atlaskit/editor-common": "^100.0.0",
|
|
30
|
+
"@atlaskit/editor-palette": "2.0.0",
|
|
31
|
+
"@atlaskit/editor-plugin-block-controls": "^3.0.0",
|
|
32
|
+
"@atlaskit/editor-plugin-context-panel": "^3.0.0",
|
|
33
|
+
"@atlaskit/editor-plugin-copy-button": "^2.0.0",
|
|
34
|
+
"@atlaskit/editor-plugin-decorations": "^2.0.0",
|
|
35
|
+
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
36
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^3.0.0",
|
|
37
|
+
"@atlaskit/editor-plugin-emoji": "^3.0.0",
|
|
38
|
+
"@atlaskit/editor-plugin-extension": "^4.0.0",
|
|
39
|
+
"@atlaskit/editor-plugin-table": "^10.0.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
41
|
-
"@atlaskit/emoji": "^
|
|
42
|
-
"@atlaskit/icon": "^
|
|
43
|
-
"@atlaskit/menu": "^
|
|
44
|
-
"@atlaskit/modal-dialog": "^
|
|
41
|
+
"@atlaskit/emoji": "^68.0.0",
|
|
42
|
+
"@atlaskit/icon": "^24.0.0",
|
|
43
|
+
"@atlaskit/menu": "^3.0.0",
|
|
44
|
+
"@atlaskit/modal-dialog": "^13.0.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
46
|
-
"@atlaskit/primitives": "^
|
|
47
|
-
"@atlaskit/select": "^
|
|
48
|
-
"@atlaskit/theme": "^
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
50
|
-
"@atlaskit/tokens": "^
|
|
51
|
-
"@atlaskit/tooltip": "^
|
|
46
|
+
"@atlaskit/primitives": "^14.0.0",
|
|
47
|
+
"@atlaskit/select": "^19.0.0",
|
|
48
|
+
"@atlaskit/theme": "^17.0.0",
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^3.0.0",
|
|
50
|
+
"@atlaskit/tokens": "^4.0.0",
|
|
51
|
+
"@atlaskit/tooltip": "^20.0.0",
|
|
52
52
|
"@babel/runtime": "^7.0.0",
|
|
53
53
|
"@emotion/react": "^11.7.1",
|
|
54
54
|
"lodash": "^4.17.21",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"react-loadable": "^5.1.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"react": "^
|
|
61
|
-
"react-dom": "^
|
|
60
|
+
"react": "^18.2.0",
|
|
61
|
+
"react-dom": "^18.2.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@atlaskit/visual-regression": "*",
|