@atlaskit/editor-plugin-block-menu 6.0.38 → 6.0.40
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 +16 -0
- package/dist/cjs/ui/block-menu.compiled.css +2 -1
- package/dist/cjs/ui/block-menu.js +3 -1
- package/dist/cjs/ui/consts.js +1 -2
- package/dist/es2019/ui/block-menu.compiled.css +2 -1
- package/dist/es2019/ui/block-menu.js +3 -1
- package/dist/es2019/ui/consts.js +1 -2
- package/dist/esm/ui/block-menu.compiled.css +2 -1
- package/dist/esm/ui/block-menu.js +3 -1
- package/dist/esm/ui/consts.js +1 -2
- package/dist/types/ui/consts.d.ts +0 -1
- package/dist/types-ts4.5/ui/consts.d.ts +0 -1
- package/package.json +6 -3
- package/dist/cjs/ui/copy-block.js +0 -141
- package/dist/es2019/ui/copy-block.js +0 -136
- package/dist/esm/ui/copy-block.js +0 -134
- package/dist/types/ui/copy-block.d.ts +0 -11
- package/dist/types-ts4.5/ui/copy-block.d.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 6.0.40
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`25ad5c762c280`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/25ad5c762c280) -
|
|
8
|
+
[ux] Add truncation on the extention label in block menu
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 6.0.39
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`febd89b7de294`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/febd89b7de294) -
|
|
16
|
+
Remove unused 'copy content' feature from block menu project
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 6.0.38
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
3
3
|
._1cc0glyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])~*){border-block-start:none}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
4
4
|
._1k2yglyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])){display:none}
|
|
5
|
-
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
5
|
+
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
6
|
+
._p12fnklw{max-width:20pc}
|
|
@@ -21,6 +21,7 @@ var _ui = require("@atlaskit/editor-common/ui");
|
|
|
21
21
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
22
22
|
var _uiReact = require("@atlaskit/editor-common/ui-react");
|
|
23
23
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
24
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
24
25
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
25
26
|
var _prosemirrorHistory = require("@atlaskit/prosemirror-history");
|
|
26
27
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
@@ -30,6 +31,7 @@ var _BlockMenuRenderer = require("./block-menu-renderer/BlockMenuRenderer");
|
|
|
30
31
|
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 _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
31
32
|
var styles = {
|
|
32
33
|
base: "_2rko12b0 _bfhk1bhr _16qs130s",
|
|
34
|
+
maxWidthStyles: "_p12fnklw",
|
|
33
35
|
emptyMenuSectionStyles: "_1cc0glyw _1k2yglyw"
|
|
34
36
|
};
|
|
35
37
|
var DEFAULT_MENU_WIDTH = 230;
|
|
@@ -101,7 +103,7 @@ var BlockMenuContent = function BlockMenuContent(_ref2) {
|
|
|
101
103
|
testId: "editor-block-menu",
|
|
102
104
|
role: (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'menu' : undefined,
|
|
103
105
|
ref: ref,
|
|
104
|
-
xcss: (0, _css.cx)(styles.base, (0, _experiments.editorExperiment)('platform_synced_block', true) && styles.emptyMenuSectionStyles)
|
|
106
|
+
xcss: (0, _css.cx)(styles.base, (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_2') && styles.maxWidthStyles, (0, _experiments.editorExperiment)('platform_synced_block', true) && styles.emptyMenuSectionStyles)
|
|
105
107
|
}, /*#__PURE__*/_react.default.createElement(_uiMenu.ArrowKeyNavigationProvider, {
|
|
106
108
|
type: _uiMenu.ArrowKeyNavigationType.MENU,
|
|
107
109
|
handleClose: function handleClose(e) {
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
3
3
|
._1cc0glyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])~*){border-block-start:none}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
4
4
|
._1k2yglyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])){display:none}
|
|
5
|
-
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
5
|
+
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
6
|
+
._p12fnklw{max-width:20pc}
|
|
@@ -12,6 +12,7 @@ import { Popup } from '@atlaskit/editor-common/ui';
|
|
|
12
12
|
import { ArrowKeyNavigationProvider, ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu';
|
|
13
13
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
14
14
|
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
15
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
16
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
16
17
|
import { redo, undo } from '@atlaskit/prosemirror-history';
|
|
17
18
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -20,6 +21,7 @@ import { useBlockMenu } from './block-menu-provider';
|
|
|
20
21
|
import { BlockMenuRenderer } from './block-menu-renderer/BlockMenuRenderer';
|
|
21
22
|
const styles = {
|
|
22
23
|
base: "_2rko12b0 _bfhk1bhr _16qs130s",
|
|
24
|
+
maxWidthStyles: "_p12fnklw",
|
|
23
25
|
emptyMenuSectionStyles: "_1cc0glyw _1k2yglyw"
|
|
24
26
|
};
|
|
25
27
|
const DEFAULT_MENU_WIDTH = 230;
|
|
@@ -94,7 +96,7 @@ const BlockMenuContent = ({
|
|
|
94
96
|
testId: "editor-block-menu",
|
|
95
97
|
role: expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'menu' : undefined,
|
|
96
98
|
ref: ref,
|
|
97
|
-
xcss: cx(styles.base, editorExperiment('platform_synced_block', true) && styles.emptyMenuSectionStyles)
|
|
99
|
+
xcss: cx(styles.base, fg('platform_editor_block_menu_v2_patch_2') && styles.maxWidthStyles, editorExperiment('platform_synced_block', true) && styles.emptyMenuSectionStyles)
|
|
98
100
|
}, /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
|
|
99
101
|
type: ArrowKeyNavigationType.MENU,
|
|
100
102
|
handleClose: e => e.preventDefault(),
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
3
3
|
._1cc0glyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])~*){border-block-start:none}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
4
4
|
._1k2yglyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])){display:none}
|
|
5
|
-
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
5
|
+
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
6
|
+
._p12fnklw{max-width:20pc}
|
|
@@ -13,6 +13,7 @@ import { Popup } from '@atlaskit/editor-common/ui';
|
|
|
13
13
|
import { ArrowKeyNavigationProvider, ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu';
|
|
14
14
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
15
15
|
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
17
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
17
18
|
import { redo, undo } from '@atlaskit/prosemirror-history';
|
|
18
19
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -21,6 +22,7 @@ import { useBlockMenu } from './block-menu-provider';
|
|
|
21
22
|
import { BlockMenuRenderer } from './block-menu-renderer/BlockMenuRenderer';
|
|
22
23
|
var styles = {
|
|
23
24
|
base: "_2rko12b0 _bfhk1bhr _16qs130s",
|
|
25
|
+
maxWidthStyles: "_p12fnklw",
|
|
24
26
|
emptyMenuSectionStyles: "_1cc0glyw _1k2yglyw"
|
|
25
27
|
};
|
|
26
28
|
var DEFAULT_MENU_WIDTH = 230;
|
|
@@ -92,7 +94,7 @@ var BlockMenuContent = function BlockMenuContent(_ref2) {
|
|
|
92
94
|
testId: "editor-block-menu",
|
|
93
95
|
role: expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'menu' : undefined,
|
|
94
96
|
ref: ref,
|
|
95
|
-
xcss: cx(styles.base, editorExperiment('platform_synced_block', true) && styles.emptyMenuSectionStyles)
|
|
97
|
+
xcss: cx(styles.base, fg('platform_editor_block_menu_v2_patch_2') && styles.maxWidthStyles, editorExperiment('platform_synced_block', true) && styles.emptyMenuSectionStyles)
|
|
96
98
|
}, /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
|
|
97
99
|
type: ArrowKeyNavigationType.MENU,
|
|
98
100
|
handleClose: function handleClose(e) {
|
package/dist/esm/ui/consts.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.40",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
42
42
|
"@atlaskit/editor-toolbar": "^0.19.0",
|
|
43
43
|
"@atlaskit/flag": "^17.8.0",
|
|
44
|
-
"@atlaskit/icon": "^
|
|
44
|
+
"@atlaskit/icon": "^31.0.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
47
47
|
"@atlaskit/primitives": "^18.0.0",
|
|
48
48
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^24.
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^24.1.0",
|
|
50
50
|
"@atlaskit/tokens": "^11.0.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
52
52
|
"bind-event-listener": "^3.0.0"
|
|
@@ -95,6 +95,9 @@
|
|
|
95
95
|
"platform-feature-flags": {
|
|
96
96
|
"platform_editor_adf_with_localid": {
|
|
97
97
|
"type": "boolean"
|
|
98
|
+
},
|
|
99
|
+
"platform_editor_block_menu_v2_patch_2": {
|
|
100
|
+
"type": "boolean"
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _reactIntlNext = require("react-intl-next");
|
|
11
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
|
-
var _clipboard = require("@atlaskit/editor-common/clipboard");
|
|
13
|
-
var _copyButton = require("@atlaskit/editor-common/copy-button");
|
|
14
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
15
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
16
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
17
|
-
var _utils = require("@atlaskit/editor-tables/utils");
|
|
18
|
-
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
19
|
-
var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
|
|
20
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
21
|
-
var _blockMenuProvider = require("./block-menu-provider");
|
|
22
|
-
var _consts = require("./consts");
|
|
23
|
-
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; }
|
|
24
|
-
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; }
|
|
25
|
-
var toDOMFromFragment = function toDOMFromFragment(fragment, schema) {
|
|
26
|
-
return _model.DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
27
|
-
};
|
|
28
|
-
var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
|
|
29
|
-
var api = _ref.api;
|
|
30
|
-
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
31
|
-
formatMessage = _useIntl.formatMessage;
|
|
32
|
-
var _useBlockMenu = (0, _blockMenuProvider.useBlockMenu)(),
|
|
33
|
-
onDropdownOpenChanged = _useBlockMenu.onDropdownOpenChanged;
|
|
34
|
-
var copyHandler = function copyHandler(event) {
|
|
35
|
-
var _api$selection;
|
|
36
|
-
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
37
|
-
var _api$analytics;
|
|
38
|
-
var tr = _ref2.tr;
|
|
39
|
-
var payload = {
|
|
40
|
-
action: _analytics.ACTION.CLICKED,
|
|
41
|
-
actionSubject: _analytics.ACTION_SUBJECT.BLOCK_MENU_ITEM,
|
|
42
|
-
attributes: {
|
|
43
|
-
menuItemName: _consts.BLOCK_MENU_ITEM_NAME.COPY_CONTENT
|
|
44
|
-
},
|
|
45
|
-
eventType: _analytics.EVENT_TYPE.UI
|
|
46
|
-
};
|
|
47
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent(payload)(tr);
|
|
48
|
-
return tr;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// prevent click event from bubbling up to the ancestor elements
|
|
52
|
-
event.stopPropagation();
|
|
53
|
-
// get the current selection
|
|
54
|
-
var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState) === null || _api$selection === void 0 || (_api$selection = _api$selection.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
|
|
55
|
-
if (selection) {
|
|
56
|
-
var _api$blockControls;
|
|
57
|
-
var schema = selection.$from.doc.type.schema;
|
|
58
|
-
// for texts and inline nodes
|
|
59
|
-
if (selection instanceof _state.TextSelection) {
|
|
60
|
-
var _fragment, _fragment2;
|
|
61
|
-
var fragment = selection === null || selection === void 0 ? void 0 : selection.content().content;
|
|
62
|
-
if (!fragment) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
// if text is inside of a layout column, the selection contains the layoutSection and layoutColumn for some reason
|
|
66
|
-
// But the layoutSection only contains the layoutColumn that the selected text is in, hence we can use the .firstChild
|
|
67
|
-
if ((_fragment = fragment) !== null && _fragment !== void 0 && _fragment.firstChild && fragment.firstChild.type.name === 'layoutSection') {
|
|
68
|
-
var layoutSectionNode = fragment.firstChild;
|
|
69
|
-
var layoutColumnNode = layoutSectionNode.firstChild;
|
|
70
|
-
var layoutContent = layoutColumnNode === null || layoutColumnNode === void 0 ? void 0 : layoutColumnNode.firstChild;
|
|
71
|
-
fragment = (layoutContent === null || layoutContent === void 0 ? void 0 : layoutContent.content) || _model.Fragment.empty;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// if text is inside of an expand or extension, the selection contains an expand or extension for some reason
|
|
75
|
-
// the expandNode or extensionNode always and only have one child, no matter how much contents are inside the expand or extension,
|
|
76
|
-
// and the one child is the line that is being selected, so we can use the .firstChild again
|
|
77
|
-
if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && (fragment.firstChild.type.name === 'expand' || fragment.firstChild.type.name === 'bodiedExtension')) {
|
|
78
|
-
var expandOrExtensionNode = fragment.firstChild;
|
|
79
|
-
var actualNodeToCopy = expandOrExtensionNode.firstChild;
|
|
80
|
-
fragment = _model.Fragment.from(actualNodeToCopy) || _model.Fragment.empty;
|
|
81
|
-
}
|
|
82
|
-
var domNode = toDOMFromFragment(fragment, schema);
|
|
83
|
-
var div = document.createElement('div');
|
|
84
|
-
div.appendChild(domNode);
|
|
85
|
-
(0, _clipboard.copyHTMLToClipboard)(div);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// for table
|
|
89
|
-
else if ((0, _utils.isTableSelected)(selection)) {
|
|
90
|
-
var nodeType = schema.nodes.table;
|
|
91
|
-
var tableNode = selection.$anchorCell.node(-1);
|
|
92
|
-
if (!tableNode) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
var _domNode = (0, _copyButton.toDOM)(tableNode, schema);
|
|
96
|
-
(0, _copyButton.copyDomNode)(_domNode, nodeType, selection);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// for other nodes
|
|
100
|
-
else if (selection instanceof _state.NodeSelection) {
|
|
101
|
-
var _nodeType = selection.node.type;
|
|
102
|
-
|
|
103
|
-
// code block is a special case where it is a block node but has inlineContent to true,
|
|
104
|
-
// When nodeType.inlineContent is true, it will be treated as an inline node in the copyDomNode function,
|
|
105
|
-
// but we want to treat it as a block node when copying, hence setting it to false here
|
|
106
|
-
if (selection.node.type.name === 'codeBlock') {
|
|
107
|
-
var codeBlockNodeType = _objectSpread(_objectSpread({}, _nodeType), {}, {
|
|
108
|
-
inlineContent: false
|
|
109
|
-
});
|
|
110
|
-
var _domNode2 = (0, _copyButton.toDOM)(selection.node, schema);
|
|
111
|
-
(0, _copyButton.copyDomNode)(_domNode2, codeBlockNodeType, selection);
|
|
112
|
-
}
|
|
113
|
-
// source sync block (bodiedSyncBlock) is also a special case
|
|
114
|
-
// where we need to copy the content of the bodiedSyncBlock node
|
|
115
|
-
else if (selection.node.type.name === 'bodiedSyncBlock' && (0, _experiments.editorExperiment)('platform_synced_block', true)) {
|
|
116
|
-
var bodiedSyncBlockNode = selection.node;
|
|
117
|
-
var _domNode3 = toDOMFromFragment(bodiedSyncBlockNode.content, schema);
|
|
118
|
-
(0, _copyButton.copyDomNode)(_domNode3, bodiedSyncBlockNode.type, selection);
|
|
119
|
-
}
|
|
120
|
-
// for other nodes
|
|
121
|
-
else {
|
|
122
|
-
var _domNode4 = (0, _copyButton.toDOM)(selection.node, schema);
|
|
123
|
-
(0, _copyButton.copyDomNode)(_domNode4, _nodeType, selection);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// close the block menu after copying
|
|
128
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.commands.toggleBlockMenu({
|
|
129
|
-
closeMenu: true
|
|
130
|
-
}));
|
|
131
|
-
onDropdownOpenChanged(false);
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
135
|
-
elemBefore: /*#__PURE__*/_react.default.createElement(_copy.default, {
|
|
136
|
-
label: ""
|
|
137
|
-
}),
|
|
138
|
-
onClick: copyHandler
|
|
139
|
-
}, formatMessage(_messages.blockMenuMessages.copyContent));
|
|
140
|
-
};
|
|
141
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(CopyBlockMenuItem);
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { injectIntl, useIntl } from 'react-intl-next';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { copyHTMLToClipboard } from '@atlaskit/editor-common/clipboard';
|
|
5
|
-
import { toDOM, copyDomNode } from '@atlaskit/editor-common/copy-button';
|
|
6
|
-
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
7
|
-
import { Fragment, DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
-
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
-
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
10
|
-
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
11
|
-
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
12
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
|
-
import { useBlockMenu } from './block-menu-provider';
|
|
14
|
-
import { BLOCK_MENU_ITEM_NAME } from './consts';
|
|
15
|
-
const toDOMFromFragment = (fragment, schema) => {
|
|
16
|
-
return DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
17
|
-
};
|
|
18
|
-
const CopyBlockMenuItem = ({
|
|
19
|
-
api
|
|
20
|
-
}) => {
|
|
21
|
-
const {
|
|
22
|
-
formatMessage
|
|
23
|
-
} = useIntl();
|
|
24
|
-
const {
|
|
25
|
-
onDropdownOpenChanged
|
|
26
|
-
} = useBlockMenu();
|
|
27
|
-
const copyHandler = event => {
|
|
28
|
-
var _api$selection, _api$selection$shared, _api$selection$shared2;
|
|
29
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
30
|
-
tr
|
|
31
|
-
}) => {
|
|
32
|
-
var _api$analytics, _api$analytics$action;
|
|
33
|
-
const payload = {
|
|
34
|
-
action: ACTION.CLICKED,
|
|
35
|
-
actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
|
|
36
|
-
attributes: {
|
|
37
|
-
menuItemName: BLOCK_MENU_ITEM_NAME.COPY_CONTENT
|
|
38
|
-
},
|
|
39
|
-
eventType: EVENT_TYPE.UI
|
|
40
|
-
};
|
|
41
|
-
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent(payload)(tr);
|
|
42
|
-
return tr;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// prevent click event from bubbling up to the ancestor elements
|
|
46
|
-
event.stopPropagation();
|
|
47
|
-
// get the current selection
|
|
48
|
-
const selection = api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$shared = _api$selection.sharedState) === null || _api$selection$shared === void 0 ? void 0 : (_api$selection$shared2 = _api$selection$shared.currentState()) === null || _api$selection$shared2 === void 0 ? void 0 : _api$selection$shared2.selection;
|
|
49
|
-
if (selection) {
|
|
50
|
-
var _api$blockControls;
|
|
51
|
-
const schema = selection.$from.doc.type.schema;
|
|
52
|
-
// for texts and inline nodes
|
|
53
|
-
if (selection instanceof TextSelection) {
|
|
54
|
-
var _fragment, _fragment2;
|
|
55
|
-
let fragment = selection === null || selection === void 0 ? void 0 : selection.content().content;
|
|
56
|
-
if (!fragment) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
// if text is inside of a layout column, the selection contains the layoutSection and layoutColumn for some reason
|
|
60
|
-
// But the layoutSection only contains the layoutColumn that the selected text is in, hence we can use the .firstChild
|
|
61
|
-
if ((_fragment = fragment) !== null && _fragment !== void 0 && _fragment.firstChild && fragment.firstChild.type.name === 'layoutSection') {
|
|
62
|
-
const layoutSectionNode = fragment.firstChild;
|
|
63
|
-
const layoutColumnNode = layoutSectionNode.firstChild;
|
|
64
|
-
const layoutContent = layoutColumnNode === null || layoutColumnNode === void 0 ? void 0 : layoutColumnNode.firstChild;
|
|
65
|
-
fragment = (layoutContent === null || layoutContent === void 0 ? void 0 : layoutContent.content) || Fragment.empty;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// if text is inside of an expand or extension, the selection contains an expand or extension for some reason
|
|
69
|
-
// the expandNode or extensionNode always and only have one child, no matter how much contents are inside the expand or extension,
|
|
70
|
-
// and the one child is the line that is being selected, so we can use the .firstChild again
|
|
71
|
-
if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && (fragment.firstChild.type.name === 'expand' || fragment.firstChild.type.name === 'bodiedExtension')) {
|
|
72
|
-
const expandOrExtensionNode = fragment.firstChild;
|
|
73
|
-
const actualNodeToCopy = expandOrExtensionNode.firstChild;
|
|
74
|
-
fragment = Fragment.from(actualNodeToCopy) || Fragment.empty;
|
|
75
|
-
}
|
|
76
|
-
const domNode = toDOMFromFragment(fragment, schema);
|
|
77
|
-
const div = document.createElement('div');
|
|
78
|
-
div.appendChild(domNode);
|
|
79
|
-
copyHTMLToClipboard(div);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// for table
|
|
83
|
-
else if (isTableSelected(selection)) {
|
|
84
|
-
const nodeType = schema.nodes.table;
|
|
85
|
-
const tableNode = selection.$anchorCell.node(-1);
|
|
86
|
-
if (!tableNode) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const domNode = toDOM(tableNode, schema);
|
|
90
|
-
copyDomNode(domNode, nodeType, selection);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// for other nodes
|
|
94
|
-
else if (selection instanceof NodeSelection) {
|
|
95
|
-
const nodeType = selection.node.type;
|
|
96
|
-
|
|
97
|
-
// code block is a special case where it is a block node but has inlineContent to true,
|
|
98
|
-
// When nodeType.inlineContent is true, it will be treated as an inline node in the copyDomNode function,
|
|
99
|
-
// but we want to treat it as a block node when copying, hence setting it to false here
|
|
100
|
-
if (selection.node.type.name === 'codeBlock') {
|
|
101
|
-
const codeBlockNodeType = {
|
|
102
|
-
...nodeType,
|
|
103
|
-
inlineContent: false
|
|
104
|
-
};
|
|
105
|
-
const domNode = toDOM(selection.node, schema);
|
|
106
|
-
copyDomNode(domNode, codeBlockNodeType, selection);
|
|
107
|
-
}
|
|
108
|
-
// source sync block (bodiedSyncBlock) is also a special case
|
|
109
|
-
// where we need to copy the content of the bodiedSyncBlock node
|
|
110
|
-
else if (selection.node.type.name === 'bodiedSyncBlock' && editorExperiment('platform_synced_block', true)) {
|
|
111
|
-
const bodiedSyncBlockNode = selection.node;
|
|
112
|
-
const domNode = toDOMFromFragment(bodiedSyncBlockNode.content, schema);
|
|
113
|
-
copyDomNode(domNode, bodiedSyncBlockNode.type, selection);
|
|
114
|
-
}
|
|
115
|
-
// for other nodes
|
|
116
|
-
else {
|
|
117
|
-
const domNode = toDOM(selection.node, schema);
|
|
118
|
-
copyDomNode(domNode, nodeType, selection);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// close the block menu after copying
|
|
123
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.commands.toggleBlockMenu({
|
|
124
|
-
closeMenu: true
|
|
125
|
-
}));
|
|
126
|
-
onDropdownOpenChanged(false);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
130
|
-
elemBefore: /*#__PURE__*/React.createElement(CopyIcon, {
|
|
131
|
-
label: ""
|
|
132
|
-
}),
|
|
133
|
-
onClick: copyHandler
|
|
134
|
-
}, formatMessage(blockMenuMessages.copyContent));
|
|
135
|
-
};
|
|
136
|
-
export default injectIntl(CopyBlockMenuItem);
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { injectIntl, useIntl } from 'react-intl-next';
|
|
6
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
7
|
-
import { copyHTMLToClipboard } from '@atlaskit/editor-common/clipboard';
|
|
8
|
-
import { toDOM, copyDomNode } from '@atlaskit/editor-common/copy-button';
|
|
9
|
-
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
10
|
-
import { Fragment, DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
11
|
-
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
|
-
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
13
|
-
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
14
|
-
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
15
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
16
|
-
import { useBlockMenu } from './block-menu-provider';
|
|
17
|
-
import { BLOCK_MENU_ITEM_NAME } from './consts';
|
|
18
|
-
var toDOMFromFragment = function toDOMFromFragment(fragment, schema) {
|
|
19
|
-
return DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
20
|
-
};
|
|
21
|
-
var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
|
|
22
|
-
var api = _ref.api;
|
|
23
|
-
var _useIntl = useIntl(),
|
|
24
|
-
formatMessage = _useIntl.formatMessage;
|
|
25
|
-
var _useBlockMenu = useBlockMenu(),
|
|
26
|
-
onDropdownOpenChanged = _useBlockMenu.onDropdownOpenChanged;
|
|
27
|
-
var copyHandler = function copyHandler(event) {
|
|
28
|
-
var _api$selection;
|
|
29
|
-
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
30
|
-
var _api$analytics;
|
|
31
|
-
var tr = _ref2.tr;
|
|
32
|
-
var payload = {
|
|
33
|
-
action: ACTION.CLICKED,
|
|
34
|
-
actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
|
|
35
|
-
attributes: {
|
|
36
|
-
menuItemName: BLOCK_MENU_ITEM_NAME.COPY_CONTENT
|
|
37
|
-
},
|
|
38
|
-
eventType: EVENT_TYPE.UI
|
|
39
|
-
};
|
|
40
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent(payload)(tr);
|
|
41
|
-
return tr;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// prevent click event from bubbling up to the ancestor elements
|
|
45
|
-
event.stopPropagation();
|
|
46
|
-
// get the current selection
|
|
47
|
-
var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState) === null || _api$selection === void 0 || (_api$selection = _api$selection.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
|
|
48
|
-
if (selection) {
|
|
49
|
-
var _api$blockControls;
|
|
50
|
-
var schema = selection.$from.doc.type.schema;
|
|
51
|
-
// for texts and inline nodes
|
|
52
|
-
if (selection instanceof TextSelection) {
|
|
53
|
-
var _fragment, _fragment2;
|
|
54
|
-
var fragment = selection === null || selection === void 0 ? void 0 : selection.content().content;
|
|
55
|
-
if (!fragment) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
// if text is inside of a layout column, the selection contains the layoutSection and layoutColumn for some reason
|
|
59
|
-
// But the layoutSection only contains the layoutColumn that the selected text is in, hence we can use the .firstChild
|
|
60
|
-
if ((_fragment = fragment) !== null && _fragment !== void 0 && _fragment.firstChild && fragment.firstChild.type.name === 'layoutSection') {
|
|
61
|
-
var layoutSectionNode = fragment.firstChild;
|
|
62
|
-
var layoutColumnNode = layoutSectionNode.firstChild;
|
|
63
|
-
var layoutContent = layoutColumnNode === null || layoutColumnNode === void 0 ? void 0 : layoutColumnNode.firstChild;
|
|
64
|
-
fragment = (layoutContent === null || layoutContent === void 0 ? void 0 : layoutContent.content) || Fragment.empty;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// if text is inside of an expand or extension, the selection contains an expand or extension for some reason
|
|
68
|
-
// the expandNode or extensionNode always and only have one child, no matter how much contents are inside the expand or extension,
|
|
69
|
-
// and the one child is the line that is being selected, so we can use the .firstChild again
|
|
70
|
-
if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && (fragment.firstChild.type.name === 'expand' || fragment.firstChild.type.name === 'bodiedExtension')) {
|
|
71
|
-
var expandOrExtensionNode = fragment.firstChild;
|
|
72
|
-
var actualNodeToCopy = expandOrExtensionNode.firstChild;
|
|
73
|
-
fragment = Fragment.from(actualNodeToCopy) || Fragment.empty;
|
|
74
|
-
}
|
|
75
|
-
var domNode = toDOMFromFragment(fragment, schema);
|
|
76
|
-
var div = document.createElement('div');
|
|
77
|
-
div.appendChild(domNode);
|
|
78
|
-
copyHTMLToClipboard(div);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// for table
|
|
82
|
-
else if (isTableSelected(selection)) {
|
|
83
|
-
var nodeType = schema.nodes.table;
|
|
84
|
-
var tableNode = selection.$anchorCell.node(-1);
|
|
85
|
-
if (!tableNode) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
var _domNode = toDOM(tableNode, schema);
|
|
89
|
-
copyDomNode(_domNode, nodeType, selection);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// for other nodes
|
|
93
|
-
else if (selection instanceof NodeSelection) {
|
|
94
|
-
var _nodeType = selection.node.type;
|
|
95
|
-
|
|
96
|
-
// code block is a special case where it is a block node but has inlineContent to true,
|
|
97
|
-
// When nodeType.inlineContent is true, it will be treated as an inline node in the copyDomNode function,
|
|
98
|
-
// but we want to treat it as a block node when copying, hence setting it to false here
|
|
99
|
-
if (selection.node.type.name === 'codeBlock') {
|
|
100
|
-
var codeBlockNodeType = _objectSpread(_objectSpread({}, _nodeType), {}, {
|
|
101
|
-
inlineContent: false
|
|
102
|
-
});
|
|
103
|
-
var _domNode2 = toDOM(selection.node, schema);
|
|
104
|
-
copyDomNode(_domNode2, codeBlockNodeType, selection);
|
|
105
|
-
}
|
|
106
|
-
// source sync block (bodiedSyncBlock) is also a special case
|
|
107
|
-
// where we need to copy the content of the bodiedSyncBlock node
|
|
108
|
-
else if (selection.node.type.name === 'bodiedSyncBlock' && editorExperiment('platform_synced_block', true)) {
|
|
109
|
-
var bodiedSyncBlockNode = selection.node;
|
|
110
|
-
var _domNode3 = toDOMFromFragment(bodiedSyncBlockNode.content, schema);
|
|
111
|
-
copyDomNode(_domNode3, bodiedSyncBlockNode.type, selection);
|
|
112
|
-
}
|
|
113
|
-
// for other nodes
|
|
114
|
-
else {
|
|
115
|
-
var _domNode4 = toDOM(selection.node, schema);
|
|
116
|
-
copyDomNode(_domNode4, _nodeType, selection);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// close the block menu after copying
|
|
121
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.commands.toggleBlockMenu({
|
|
122
|
-
closeMenu: true
|
|
123
|
-
}));
|
|
124
|
-
onDropdownOpenChanged(false);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
128
|
-
elemBefore: /*#__PURE__*/React.createElement(CopyIcon, {
|
|
129
|
-
label: ""
|
|
130
|
-
}),
|
|
131
|
-
onClick: copyHandler
|
|
132
|
-
}, formatMessage(blockMenuMessages.copyContent));
|
|
133
|
-
};
|
|
134
|
-
export default injectIntl(CopyBlockMenuItem);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import type { BlockMenuPlugin } from '../blockMenuPluginType';
|
|
5
|
-
interface CopyBlockMenuItemProps {
|
|
6
|
-
api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
|
|
7
|
-
}
|
|
8
|
-
declare const _default: React.FC<import("react-intl-next").WithIntlProps<CopyBlockMenuItemProps & WrappedComponentProps>> & {
|
|
9
|
-
WrappedComponent: React.ComponentType<CopyBlockMenuItemProps & WrappedComponentProps>;
|
|
10
|
-
};
|
|
11
|
-
export default _default;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import type { BlockMenuPlugin } from '../blockMenuPluginType';
|
|
5
|
-
interface CopyBlockMenuItemProps {
|
|
6
|
-
api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
|
|
7
|
-
}
|
|
8
|
-
declare const _default: React.FC<import("react-intl-next").WithIntlProps<CopyBlockMenuItemProps & WrappedComponentProps>> & {
|
|
9
|
-
WrappedComponent: React.ComponentType<CopyBlockMenuItemProps & WrappedComponentProps>;
|
|
10
|
-
};
|
|
11
|
-
export default _default;
|