@atlaskit/editor-plugin-floating-toolbar 21.0.0 → 21.1.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 +20 -0
- package/dist/cjs/pm-plugins/commands.js +1 -36
- package/dist/cjs/ui/CheckboxModal.js +1 -1
- package/dist/cjs/ui/ExtensionsPlaceholder.js +48 -11
- package/dist/cjs/ui/SimpleModal.js +1 -1
- package/dist/es2019/entry-points/floatingToolbarPlugin.js +1 -0
- package/dist/es2019/pm-plugins/commands.js +2 -37
- package/dist/es2019/ui/CheckboxModal.js +1 -1
- package/dist/es2019/ui/ExtensionsPlaceholder.js +42 -7
- package/dist/es2019/ui/SimpleModal.js +1 -1
- package/dist/es2019/ui/Toolbar.js +1 -0
- package/dist/esm/entry-points/floatingToolbarPlugin.js +1 -0
- package/dist/esm/pm-plugins/commands.js +2 -37
- package/dist/esm/ui/CheckboxModal.js +1 -1
- package/dist/esm/ui/ExtensionsPlaceholder.js +47 -11
- package/dist/esm/ui/SimpleModal.js +1 -1
- package/dist/esm/ui/Toolbar.js +1 -0
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-floating-toolbar
|
|
2
2
|
|
|
3
|
+
## 21.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 21.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`21d8655ca13bf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/21d8655ca13bf) -
|
|
14
|
+
Migrate the editor floating toolbar's lazy-loaded extension controls to react-loosely-lazy behind
|
|
15
|
+
the `platform_editor_loosely_lazy_migration` experiment.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`8d37dc7e55d62`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8d37dc7e55d62) -
|
|
20
|
+
Clean up shipped experiment `platform_editor_block_menu`
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 21.0.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.copyNode = void 0;
|
|
7
|
-
var _browser = require("@atlaskit/editor-common/browser");
|
|
8
7
|
var _clipboard = require("@atlaskit/editor-common/clipboard");
|
|
9
8
|
var _copyButton = require("@atlaskit/editor-common/copy-button");
|
|
10
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
-
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
12
9
|
var copyNode = exports.copyNode = function copyNode(nodeType, editorAnalyticsApi, inputMethod) {
|
|
13
10
|
return function (_ref) {
|
|
14
11
|
var tr = _ref.tr;
|
|
@@ -26,39 +23,7 @@ var copyNode = exports.copyNode = function copyNode(nodeType, editorAnalyticsApi
|
|
|
26
23
|
var schema = tr.doc.type.schema;
|
|
27
24
|
var copyToClipboardTr = tr;
|
|
28
25
|
var domNode = (0, _copyButton.toDOM)(contentNodeWithPos.node, schema);
|
|
29
|
-
|
|
30
|
-
(0, _copyButton.copyDomNode)(domNode, contentNodeWithPos.node.type, tr.selection);
|
|
31
|
-
} else {
|
|
32
|
-
if (domNode) {
|
|
33
|
-
var div = document.createElement('div');
|
|
34
|
-
var browser = (0, _browser.getBrowserInfo)();
|
|
35
|
-
div.appendChild(domNode);
|
|
36
|
-
|
|
37
|
-
// if copying inline content
|
|
38
|
-
if (contentNodeWithPos.node.type.inlineContent) {
|
|
39
|
-
// The "1 1" refers to the start and end depth of the slice
|
|
40
|
-
// since we're copying the text inside a paragraph, it will always be 1 1
|
|
41
|
-
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
42
|
-
// Ignored via go/ees005
|
|
43
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
44
|
-
div.firstChild.setAttribute('data-pm-slice', '1 1 []');
|
|
45
|
-
} else {
|
|
46
|
-
// The "0 0" refers to the start and end depth of the slice
|
|
47
|
-
// since we're copying the block node only, it will always be 0 0
|
|
48
|
-
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
49
|
-
// Ignored via go/ees005
|
|
50
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
51
|
-
div.firstChild.setAttribute('data-pm-slice', '0 0 []');
|
|
52
|
-
}
|
|
53
|
-
// ED-17083 safari seems have bugs for extension copy because exntension do not have a child text(innerText) and it will not recognized as html in clipboard, this could be merge into one if this extension fixed children issue or safari fix the copy bug
|
|
54
|
-
// MEX-2528 safari has a bug related to the mediaSingle node with border or link. The image tag within the clipboard is not recognized as HTML when using the ClipboardItem API. To address this, we have to switch to ClipboardPolyfill
|
|
55
|
-
if (browser.safari && tr.selection instanceof _state.NodeSelection && (tr.selection.node.type === schema.nodes.extension || tr.selection.node.type === schema.nodes.mediaSingle)) {
|
|
56
|
-
(0, _clipboard.copyHTMLToClipboardPolyfill)(div);
|
|
57
|
-
} else {
|
|
58
|
-
(0, _clipboard.copyHTMLToClipboard)(div);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
26
|
+
(0, _copyButton.copyDomNode)(domNode, contentNodeWithPos.node.type, tr.selection);
|
|
62
27
|
if (editorAnalyticsApi) {
|
|
63
28
|
var analyticsPayload = (0, _clipboard.getNodeCopiedAnalyticsPayload)(contentNodeWithPos.node, inputMethod);
|
|
64
29
|
editorAnalyticsApi.attachAnalyticsEvent(analyticsPayload)(copyToClipboardTr);
|
|
@@ -12,8 +12,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _button = _interopRequireDefault(require("@atlaskit/button/default/button"));
|
|
13
13
|
var _checkbox = require("@atlaskit/checkbox/checkbox");
|
|
14
14
|
var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
|
|
15
|
-
var _modalDialog = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-dialog"));
|
|
16
15
|
var _modalBody = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-body"));
|
|
16
|
+
var _modalDialog = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-dialog"));
|
|
17
17
|
var _modalFooter = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-footer"));
|
|
18
18
|
var _modalHeader = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-header"));
|
|
19
19
|
var _modalTitle = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-title"));
|
|
@@ -11,13 +11,17 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _reactLoadable = _interopRequireDefault(require("react-loadable"));
|
|
14
|
+
var _reactLooselyLazy = require("react-loosely-lazy");
|
|
14
15
|
var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group"));
|
|
15
16
|
var _extensions = require("@atlaskit/editor-common/extensions");
|
|
16
17
|
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
17
18
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
18
19
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
20
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
19
21
|
var _Dropdown = _interopRequireDefault(require("./Dropdown"));
|
|
20
22
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
23
|
+
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
24
|
+
|
|
21
25
|
var noop = function noop() {
|
|
22
26
|
return null;
|
|
23
27
|
};
|
|
@@ -51,13 +55,25 @@ var resolveExtensionIcon = /*#__PURE__*/function () {
|
|
|
51
55
|
return _ref.apply(this, arguments);
|
|
52
56
|
};
|
|
53
57
|
}();
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
var ButtonIconLazy = function ButtonIconLazy(_ref2) {
|
|
59
|
+
var icon = _ref2.icon,
|
|
60
|
+
label = _ref2.label;
|
|
61
|
+
var Icon = _react.default.useMemo(function () {
|
|
62
|
+
return (0, _reactLooselyLazy.lazyForPaint)(function () {
|
|
63
|
+
return resolveExtensionIcon(icon);
|
|
64
|
+
});
|
|
65
|
+
}, [icon]);
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(_reactLooselyLazy.LazySuspense, {
|
|
67
|
+
fallback: null
|
|
68
|
+
}, /*#__PURE__*/_react.default.createElement(Icon, {
|
|
69
|
+
label: label
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
var ButtonIconLoadable = function ButtonIconLoadable(_ref3) {
|
|
73
|
+
var icon = _ref3.icon,
|
|
74
|
+
label = _ref3.label;
|
|
75
|
+
var Icon = _react.default.useMemo(function () {
|
|
76
|
+
return (0, _reactLoadable.default)({
|
|
61
77
|
// Ignored via go/ees005
|
|
62
78
|
// eslint-disable-next-line require-await
|
|
63
79
|
loader: function () {
|
|
@@ -65,7 +81,7 @@ var ExtensionButton = function ExtensionButton(props) {
|
|
|
65
81
|
return _regenerator.default.wrap(function (_context2) {
|
|
66
82
|
while (1) switch (_context2.prev = _context2.next) {
|
|
67
83
|
case 0:
|
|
68
|
-
return _context2.abrupt("return", resolveExtensionIcon(
|
|
84
|
+
return _context2.abrupt("return", resolveExtensionIcon(icon));
|
|
69
85
|
case 1:
|
|
70
86
|
case "end":
|
|
71
87
|
return _context2.stop();
|
|
@@ -78,8 +94,28 @@ var ExtensionButton = function ExtensionButton(props) {
|
|
|
78
94
|
return loader;
|
|
79
95
|
}(),
|
|
80
96
|
loading: noop
|
|
81
|
-
})
|
|
82
|
-
}, [
|
|
97
|
+
});
|
|
98
|
+
}, [icon]);
|
|
99
|
+
return /*#__PURE__*/_react.default.createElement(Icon, {
|
|
100
|
+
label: label
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
var ExtensionIcon = function ExtensionIcon(_ref4) {
|
|
104
|
+
var icon = _ref4.icon,
|
|
105
|
+
label = _ref4.label;
|
|
106
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_loosely_lazy_migration') ? /*#__PURE__*/_react.default.createElement(ButtonIconLazy, {
|
|
107
|
+
icon: icon,
|
|
108
|
+
label: label
|
|
109
|
+
}) : /*#__PURE__*/_react.default.createElement(ButtonIconLoadable, {
|
|
110
|
+
icon: icon,
|
|
111
|
+
label: label
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
var ExtensionButton = function ExtensionButton(props) {
|
|
115
|
+
var item = props.item,
|
|
116
|
+
node = props.node,
|
|
117
|
+
extensionApi = props.extensionApi,
|
|
118
|
+
areAnyNewToolbarFlagsEnabled = props.areAnyNewToolbarFlagsEnabled;
|
|
83
119
|
var onClick = function onClick() {
|
|
84
120
|
if (typeof item.action !== 'function') {
|
|
85
121
|
throw new Error("'action' of context toolbar item '".concat(item.key, "' is not a function"));
|
|
@@ -104,7 +140,8 @@ var ExtensionButton = function ExtensionButton(props) {
|
|
|
104
140
|
return /*#__PURE__*/_react.default.createElement(_ui.FloatingToolbarButton, {
|
|
105
141
|
title: item.label,
|
|
106
142
|
ariaLabel: getAriaLabel(),
|
|
107
|
-
icon:
|
|
143
|
+
icon: item.icon ? /*#__PURE__*/_react.default.createElement(ExtensionIcon, {
|
|
144
|
+
icon: item.icon,
|
|
108
145
|
label: item.label || ''
|
|
109
146
|
}) : undefined,
|
|
110
147
|
onClick: onClick,
|
|
@@ -8,8 +8,8 @@ exports.SimpleModal = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _button = _interopRequireDefault(require("@atlaskit/button/default/button"));
|
|
10
10
|
var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
|
|
11
|
-
var _modalDialog = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-dialog"));
|
|
12
11
|
var _modalBody = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-body"));
|
|
12
|
+
var _modalDialog = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-dialog"));
|
|
13
13
|
var _modalFooter = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-footer"));
|
|
14
14
|
var _modalHeader = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-header"));
|
|
15
15
|
var _modalTitle = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-title"));
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { copyHTMLToClipboard, copyHTMLToClipboardPolyfill, getNodeCopiedAnalyticsPayload } from '@atlaskit/editor-common/clipboard';
|
|
1
|
+
import { getNodeCopiedAnalyticsPayload } from '@atlaskit/editor-common/clipboard';
|
|
3
2
|
import { copyDomNode, getSelectedNodeOrNodeParentByNodeType, toDOM } from '@atlaskit/editor-common/copy-button';
|
|
4
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
6
3
|
export const copyNode = (nodeType, editorAnalyticsApi, inputMethod) => ({
|
|
7
4
|
tr
|
|
8
5
|
}) => {
|
|
@@ -20,39 +17,7 @@ export const copyNode = (nodeType, editorAnalyticsApi, inputMethod) => ({
|
|
|
20
17
|
const schema = tr.doc.type.schema;
|
|
21
18
|
const copyToClipboardTr = tr;
|
|
22
19
|
const domNode = toDOM(contentNodeWithPos.node, schema);
|
|
23
|
-
|
|
24
|
-
copyDomNode(domNode, contentNodeWithPos.node.type, tr.selection);
|
|
25
|
-
} else {
|
|
26
|
-
if (domNode) {
|
|
27
|
-
const div = document.createElement('div');
|
|
28
|
-
const browser = getBrowserInfo();
|
|
29
|
-
div.appendChild(domNode);
|
|
30
|
-
|
|
31
|
-
// if copying inline content
|
|
32
|
-
if (contentNodeWithPos.node.type.inlineContent) {
|
|
33
|
-
// The "1 1" refers to the start and end depth of the slice
|
|
34
|
-
// since we're copying the text inside a paragraph, it will always be 1 1
|
|
35
|
-
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
36
|
-
// Ignored via go/ees005
|
|
37
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
38
|
-
div.firstChild.setAttribute('data-pm-slice', '1 1 []');
|
|
39
|
-
} else {
|
|
40
|
-
// The "0 0" refers to the start and end depth of the slice
|
|
41
|
-
// since we're copying the block node only, it will always be 0 0
|
|
42
|
-
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
43
|
-
// Ignored via go/ees005
|
|
44
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
45
|
-
div.firstChild.setAttribute('data-pm-slice', '0 0 []');
|
|
46
|
-
}
|
|
47
|
-
// ED-17083 safari seems have bugs for extension copy because exntension do not have a child text(innerText) and it will not recognized as html in clipboard, this could be merge into one if this extension fixed children issue or safari fix the copy bug
|
|
48
|
-
// MEX-2528 safari has a bug related to the mediaSingle node with border or link. The image tag within the clipboard is not recognized as HTML when using the ClipboardItem API. To address this, we have to switch to ClipboardPolyfill
|
|
49
|
-
if (browser.safari && tr.selection instanceof NodeSelection && (tr.selection.node.type === schema.nodes.extension || tr.selection.node.type === schema.nodes.mediaSingle)) {
|
|
50
|
-
copyHTMLToClipboardPolyfill(div);
|
|
51
|
-
} else {
|
|
52
|
-
copyHTMLToClipboard(div);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
20
|
+
copyDomNode(domNode, contentNodeWithPos.node.type, tr.selection);
|
|
56
21
|
if (editorAnalyticsApi) {
|
|
57
22
|
const analyticsPayload = getNodeCopiedAnalyticsPayload(contentNodeWithPos.node, inputMethod);
|
|
58
23
|
editorAnalyticsApi.attachAnalyticsEvent(analyticsPayload)(copyToClipboardTr);
|
|
@@ -3,8 +3,8 @@ import React, { useState } from 'react';
|
|
|
3
3
|
import Button from '@atlaskit/button/default/button';
|
|
4
4
|
import { Checkbox } from '@atlaskit/checkbox/checkbox';
|
|
5
5
|
import { messages } from '@atlaskit/editor-common/floating-toolbar';
|
|
6
|
-
import Modal from '@atlaskit/modal-dialog/modal-dialog';
|
|
7
6
|
import ModalBody from '@atlaskit/modal-dialog/modal-body';
|
|
7
|
+
import Modal from '@atlaskit/modal-dialog/modal-dialog';
|
|
8
8
|
import ModalFooter from '@atlaskit/modal-dialog/modal-footer';
|
|
9
9
|
import ModalHeader from '@atlaskit/modal-dialog/modal-header';
|
|
10
10
|
import ModalTitle from '@atlaskit/modal-dialog/modal-title';
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import Loadable from 'react-loadable';
|
|
3
|
+
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
4
|
+
import { lazyForPaint, LazySuspense } from 'react-loosely-lazy';
|
|
3
5
|
import ButtonGroup from '@atlaskit/button/button-group';
|
|
4
6
|
import { getContextualToolbarItemsFromModule } from '@atlaskit/editor-common/extensions';
|
|
5
7
|
import { isNestedTablesSupported, isSelectionTableNestedInTable } from '@atlaskit/editor-common/nesting';
|
|
6
8
|
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
|
|
7
9
|
import { nodeToJSON } from '@atlaskit/editor-common/utils';
|
|
10
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
11
|
import Dropdown from './Dropdown';
|
|
9
12
|
const noop = () => null;
|
|
10
13
|
const isDefaultExport = mod => {
|
|
@@ -17,6 +20,43 @@ const resolveExtensionIcon = async getIcon => {
|
|
|
17
20
|
const maybeIcon = await getIcon();
|
|
18
21
|
return isDefaultExport(maybeIcon) ? maybeIcon.default : maybeIcon;
|
|
19
22
|
};
|
|
23
|
+
const ButtonIconLazy = ({
|
|
24
|
+
icon,
|
|
25
|
+
label
|
|
26
|
+
}) => {
|
|
27
|
+
const Icon = React.useMemo(() => lazyForPaint(() => resolveExtensionIcon(icon)), [icon]);
|
|
28
|
+
return /*#__PURE__*/React.createElement(LazySuspense, {
|
|
29
|
+
fallback: null
|
|
30
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
31
|
+
label: label
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
const ButtonIconLoadable = ({
|
|
35
|
+
icon,
|
|
36
|
+
label
|
|
37
|
+
}) => {
|
|
38
|
+
const Icon = React.useMemo(() => Loadable({
|
|
39
|
+
// Ignored via go/ees005
|
|
40
|
+
// eslint-disable-next-line require-await
|
|
41
|
+
loader: async () => resolveExtensionIcon(icon),
|
|
42
|
+
loading: noop
|
|
43
|
+
}), [icon]);
|
|
44
|
+
return /*#__PURE__*/React.createElement(Icon, {
|
|
45
|
+
label: label
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const ExtensionIcon = ({
|
|
49
|
+
icon,
|
|
50
|
+
label
|
|
51
|
+
}) => {
|
|
52
|
+
return isExperimentEnabled('platform_editor_loosely_lazy_migration') ? /*#__PURE__*/React.createElement(ButtonIconLazy, {
|
|
53
|
+
icon: icon,
|
|
54
|
+
label: label
|
|
55
|
+
}) : /*#__PURE__*/React.createElement(ButtonIconLoadable, {
|
|
56
|
+
icon: icon,
|
|
57
|
+
label: label
|
|
58
|
+
});
|
|
59
|
+
};
|
|
20
60
|
const ExtensionButton = props => {
|
|
21
61
|
const {
|
|
22
62
|
item,
|
|
@@ -24,12 +64,6 @@ const ExtensionButton = props => {
|
|
|
24
64
|
extensionApi,
|
|
25
65
|
areAnyNewToolbarFlagsEnabled
|
|
26
66
|
} = props;
|
|
27
|
-
const ButtonIcon = React.useMemo(() => item.icon ? Loadable({
|
|
28
|
-
// Ignored via go/ees005
|
|
29
|
-
// eslint-disable-next-line require-await
|
|
30
|
-
loader: async () => resolveExtensionIcon(item.icon),
|
|
31
|
-
loading: noop
|
|
32
|
-
}) : undefined, [item.icon]);
|
|
33
67
|
const onClick = () => {
|
|
34
68
|
if (typeof item.action !== 'function') {
|
|
35
69
|
throw new Error(`'action' of context toolbar item '${item.key}' is not a function`);
|
|
@@ -54,7 +88,8 @@ const ExtensionButton = props => {
|
|
|
54
88
|
return /*#__PURE__*/React.createElement(Button, {
|
|
55
89
|
title: item.label,
|
|
56
90
|
ariaLabel: getAriaLabel(),
|
|
57
|
-
icon:
|
|
91
|
+
icon: item.icon ? /*#__PURE__*/React.createElement(ExtensionIcon, {
|
|
92
|
+
icon: item.icon,
|
|
58
93
|
label: item.label || ''
|
|
59
94
|
}) : undefined,
|
|
60
95
|
onClick: onClick,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Button from '@atlaskit/button/default/button';
|
|
3
3
|
import { messages } from '@atlaskit/editor-common/floating-toolbar';
|
|
4
|
-
import Modal from '@atlaskit/modal-dialog/modal-dialog';
|
|
5
4
|
import ModalBody from '@atlaskit/modal-dialog/modal-body';
|
|
5
|
+
import Modal from '@atlaskit/modal-dialog/modal-dialog';
|
|
6
6
|
import ModalFooter from '@atlaskit/modal-dialog/modal-footer';
|
|
7
7
|
import ModalHeader from '@atlaskit/modal-dialog/modal-header';
|
|
8
8
|
import ModalTitle from '@atlaskit/modal-dialog/modal-title';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { copyHTMLToClipboard, copyHTMLToClipboardPolyfill, getNodeCopiedAnalyticsPayload } from '@atlaskit/editor-common/clipboard';
|
|
1
|
+
import { getNodeCopiedAnalyticsPayload } from '@atlaskit/editor-common/clipboard';
|
|
3
2
|
import { copyDomNode, getSelectedNodeOrNodeParentByNodeType, toDOM } from '@atlaskit/editor-common/copy-button';
|
|
4
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
6
3
|
export var copyNode = function copyNode(nodeType, editorAnalyticsApi, inputMethod) {
|
|
7
4
|
return function (_ref) {
|
|
8
5
|
var tr = _ref.tr;
|
|
@@ -20,39 +17,7 @@ export var copyNode = function copyNode(nodeType, editorAnalyticsApi, inputMetho
|
|
|
20
17
|
var schema = tr.doc.type.schema;
|
|
21
18
|
var copyToClipboardTr = tr;
|
|
22
19
|
var domNode = toDOM(contentNodeWithPos.node, schema);
|
|
23
|
-
|
|
24
|
-
copyDomNode(domNode, contentNodeWithPos.node.type, tr.selection);
|
|
25
|
-
} else {
|
|
26
|
-
if (domNode) {
|
|
27
|
-
var div = document.createElement('div');
|
|
28
|
-
var browser = getBrowserInfo();
|
|
29
|
-
div.appendChild(domNode);
|
|
30
|
-
|
|
31
|
-
// if copying inline content
|
|
32
|
-
if (contentNodeWithPos.node.type.inlineContent) {
|
|
33
|
-
// The "1 1" refers to the start and end depth of the slice
|
|
34
|
-
// since we're copying the text inside a paragraph, it will always be 1 1
|
|
35
|
-
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
36
|
-
// Ignored via go/ees005
|
|
37
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
38
|
-
div.firstChild.setAttribute('data-pm-slice', '1 1 []');
|
|
39
|
-
} else {
|
|
40
|
-
// The "0 0" refers to the start and end depth of the slice
|
|
41
|
-
// since we're copying the block node only, it will always be 0 0
|
|
42
|
-
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
43
|
-
// Ignored via go/ees005
|
|
44
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
45
|
-
div.firstChild.setAttribute('data-pm-slice', '0 0 []');
|
|
46
|
-
}
|
|
47
|
-
// ED-17083 safari seems have bugs for extension copy because exntension do not have a child text(innerText) and it will not recognized as html in clipboard, this could be merge into one if this extension fixed children issue or safari fix the copy bug
|
|
48
|
-
// MEX-2528 safari has a bug related to the mediaSingle node with border or link. The image tag within the clipboard is not recognized as HTML when using the ClipboardItem API. To address this, we have to switch to ClipboardPolyfill
|
|
49
|
-
if (browser.safari && tr.selection instanceof NodeSelection && (tr.selection.node.type === schema.nodes.extension || tr.selection.node.type === schema.nodes.mediaSingle)) {
|
|
50
|
-
copyHTMLToClipboardPolyfill(div);
|
|
51
|
-
} else {
|
|
52
|
-
copyHTMLToClipboard(div);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
20
|
+
copyDomNode(domNode, contentNodeWithPos.node.type, tr.selection);
|
|
56
21
|
if (editorAnalyticsApi) {
|
|
57
22
|
var analyticsPayload = getNodeCopiedAnalyticsPayload(contentNodeWithPos.node, inputMethod);
|
|
58
23
|
editorAnalyticsApi.attachAnalyticsEvent(analyticsPayload)(copyToClipboardTr);
|
|
@@ -4,8 +4,8 @@ import React, { useState } from 'react';
|
|
|
4
4
|
import Button from '@atlaskit/button/default/button';
|
|
5
5
|
import { Checkbox } from '@atlaskit/checkbox/checkbox';
|
|
6
6
|
import { messages } from '@atlaskit/editor-common/floating-toolbar';
|
|
7
|
-
import Modal from '@atlaskit/modal-dialog/modal-dialog';
|
|
8
7
|
import ModalBody from '@atlaskit/modal-dialog/modal-body';
|
|
8
|
+
import Modal from '@atlaskit/modal-dialog/modal-dialog';
|
|
9
9
|
import ModalFooter from '@atlaskit/modal-dialog/modal-footer';
|
|
10
10
|
import ModalHeader from '@atlaskit/modal-dialog/modal-header';
|
|
11
11
|
import ModalTitle from '@atlaskit/modal-dialog/modal-title';
|
|
@@ -3,11 +3,14 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import React, { useEffect, useState } from 'react';
|
|
5
5
|
import Loadable from 'react-loadable';
|
|
6
|
+
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
7
|
+
import { lazyForPaint, LazySuspense } from 'react-loosely-lazy';
|
|
6
8
|
import ButtonGroup from '@atlaskit/button/button-group';
|
|
7
9
|
import { getContextualToolbarItemsFromModule } from '@atlaskit/editor-common/extensions';
|
|
8
10
|
import { isNestedTablesSupported, isSelectionTableNestedInTable } from '@atlaskit/editor-common/nesting';
|
|
9
11
|
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
|
|
10
12
|
import { nodeToJSON } from '@atlaskit/editor-common/utils';
|
|
13
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
11
14
|
import Dropdown from './Dropdown';
|
|
12
15
|
var noop = function noop() {
|
|
13
16
|
return null;
|
|
@@ -42,13 +45,25 @@ var resolveExtensionIcon = /*#__PURE__*/function () {
|
|
|
42
45
|
return _ref.apply(this, arguments);
|
|
43
46
|
};
|
|
44
47
|
}();
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
var ButtonIconLazy = function ButtonIconLazy(_ref2) {
|
|
49
|
+
var icon = _ref2.icon,
|
|
50
|
+
label = _ref2.label;
|
|
51
|
+
var Icon = React.useMemo(function () {
|
|
52
|
+
return lazyForPaint(function () {
|
|
53
|
+
return resolveExtensionIcon(icon);
|
|
54
|
+
});
|
|
55
|
+
}, [icon]);
|
|
56
|
+
return /*#__PURE__*/React.createElement(LazySuspense, {
|
|
57
|
+
fallback: null
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
59
|
+
label: label
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
var ButtonIconLoadable = function ButtonIconLoadable(_ref3) {
|
|
63
|
+
var icon = _ref3.icon,
|
|
64
|
+
label = _ref3.label;
|
|
65
|
+
var Icon = React.useMemo(function () {
|
|
66
|
+
return Loadable({
|
|
52
67
|
// Ignored via go/ees005
|
|
53
68
|
// eslint-disable-next-line require-await
|
|
54
69
|
loader: function () {
|
|
@@ -56,7 +71,7 @@ var ExtensionButton = function ExtensionButton(props) {
|
|
|
56
71
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
57
72
|
while (1) switch (_context2.prev = _context2.next) {
|
|
58
73
|
case 0:
|
|
59
|
-
return _context2.abrupt("return", resolveExtensionIcon(
|
|
74
|
+
return _context2.abrupt("return", resolveExtensionIcon(icon));
|
|
60
75
|
case 1:
|
|
61
76
|
case "end":
|
|
62
77
|
return _context2.stop();
|
|
@@ -69,8 +84,28 @@ var ExtensionButton = function ExtensionButton(props) {
|
|
|
69
84
|
return loader;
|
|
70
85
|
}(),
|
|
71
86
|
loading: noop
|
|
72
|
-
})
|
|
73
|
-
}, [
|
|
87
|
+
});
|
|
88
|
+
}, [icon]);
|
|
89
|
+
return /*#__PURE__*/React.createElement(Icon, {
|
|
90
|
+
label: label
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
var ExtensionIcon = function ExtensionIcon(_ref4) {
|
|
94
|
+
var icon = _ref4.icon,
|
|
95
|
+
label = _ref4.label;
|
|
96
|
+
return isExperimentEnabled('platform_editor_loosely_lazy_migration') ? /*#__PURE__*/React.createElement(ButtonIconLazy, {
|
|
97
|
+
icon: icon,
|
|
98
|
+
label: label
|
|
99
|
+
}) : /*#__PURE__*/React.createElement(ButtonIconLoadable, {
|
|
100
|
+
icon: icon,
|
|
101
|
+
label: label
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
var ExtensionButton = function ExtensionButton(props) {
|
|
105
|
+
var item = props.item,
|
|
106
|
+
node = props.node,
|
|
107
|
+
extensionApi = props.extensionApi,
|
|
108
|
+
areAnyNewToolbarFlagsEnabled = props.areAnyNewToolbarFlagsEnabled;
|
|
74
109
|
var onClick = function onClick() {
|
|
75
110
|
if (typeof item.action !== 'function') {
|
|
76
111
|
throw new Error("'action' of context toolbar item '".concat(item.key, "' is not a function"));
|
|
@@ -95,7 +130,8 @@ var ExtensionButton = function ExtensionButton(props) {
|
|
|
95
130
|
return /*#__PURE__*/React.createElement(Button, {
|
|
96
131
|
title: item.label,
|
|
97
132
|
ariaLabel: getAriaLabel(),
|
|
98
|
-
icon:
|
|
133
|
+
icon: item.icon ? /*#__PURE__*/React.createElement(ExtensionIcon, {
|
|
134
|
+
icon: item.icon,
|
|
99
135
|
label: item.label || ''
|
|
100
136
|
}) : undefined,
|
|
101
137
|
onClick: onClick,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Button from '@atlaskit/button/default/button';
|
|
3
3
|
import { messages } from '@atlaskit/editor-common/floating-toolbar';
|
|
4
|
-
import Modal from '@atlaskit/modal-dialog/modal-dialog';
|
|
5
4
|
import ModalBody from '@atlaskit/modal-dialog/modal-body';
|
|
5
|
+
import Modal from '@atlaskit/modal-dialog/modal-dialog';
|
|
6
6
|
import ModalFooter from '@atlaskit/modal-dialog/modal-footer';
|
|
7
7
|
import ModalHeader from '@atlaskit/modal-dialog/modal-header';
|
|
8
8
|
import ModalTitle from '@atlaskit/modal-dialog/modal-title';
|
package/dist/esm/ui/Toolbar.js
CHANGED
|
@@ -14,6 +14,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
14
14
|
* @jsxRuntime classic
|
|
15
15
|
* @jsx jsx
|
|
16
16
|
*/
|
|
17
|
+
|
|
17
18
|
import React, { Component } from 'react';
|
|
18
19
|
|
|
19
20
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-floating-toolbar",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.1.1",
|
|
4
4
|
"description": "Floating toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -40,10 +40,11 @@
|
|
|
40
40
|
"@atlaskit/icon": "^37.7.0",
|
|
41
41
|
"@atlaskit/menu": "^11.0.0",
|
|
42
42
|
"@atlaskit/modal-dialog": "^16.6.0",
|
|
43
|
+
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
43
44
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
44
45
|
"@atlaskit/primitives": "^22.5.0",
|
|
45
46
|
"@atlaskit/select": "^22.11.0",
|
|
46
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^201.0.0",
|
|
47
48
|
"@atlaskit/tokens": "^18.2.0",
|
|
48
49
|
"@atlaskit/tooltip": "^24.3.0",
|
|
49
50
|
"@babel/runtime": "^7.0.0",
|
|
@@ -51,10 +52,11 @@
|
|
|
51
52
|
"bind-event-listener": "^3.0.0",
|
|
52
53
|
"lodash": "^4.17.21",
|
|
53
54
|
"raf-schd": "^4.0.3",
|
|
54
|
-
"react-loadable": "^5.1.0"
|
|
55
|
+
"react-loadable": "^5.1.0",
|
|
56
|
+
"react-loosely-lazy": "^1.0.0"
|
|
55
57
|
},
|
|
56
58
|
"peerDependencies": {
|
|
57
|
-
"@atlaskit/editor-common": "^123.
|
|
59
|
+
"@atlaskit/editor-common": "^123.2.0",
|
|
58
60
|
"react": "^18.2.0 || ^19.2.0",
|
|
59
61
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
60
62
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|