@atlaskit/editor-plugin-block-menu 6.1.12 → 7.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 +14 -0
- package/dist/cjs/blockMenuPlugin.js +4 -2
- package/dist/cjs/pm-plugins/experiences/block-menu-experiences.js +25 -8
- package/dist/cjs/pm-plugins/experiences/experience-check-utils.js +1 -34
- package/dist/cjs/ui/block-menu-components.js +30 -5
- package/dist/es2019/blockMenuPlugin.js +3 -2
- package/dist/es2019/pm-plugins/experiences/block-menu-experiences.js +29 -12
- package/dist/es2019/pm-plugins/experiences/experience-check-utils.js +0 -35
- package/dist/es2019/ui/block-menu-components.js +24 -2
- package/dist/esm/blockMenuPlugin.js +4 -2
- package/dist/esm/pm-plugins/experiences/block-menu-experiences.js +26 -10
- package/dist/esm/pm-plugins/experiences/experience-check-utils.js +0 -33
- package/dist/esm/ui/block-menu-components.js +31 -6
- package/dist/types/pm-plugins/experiences/experience-check-utils.d.ts +0 -9
- package/dist/types-ts4.5/pm-plugins/experiences/experience-check-utils.d.ts +0 -9
- package/package.json +12 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 7.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 6.1.13
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`7951795610960`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7951795610960) -
|
|
14
|
+
Add a divider above the "copy link to selection" option in block menu
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 6.1.12
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.blockMenuPlugin = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
9
11
|
var _editorActions = require("./editor-actions");
|
|
10
12
|
var _isTransformToTargetDisabled = require("./editor-actions/isTransformToTargetDisabled");
|
|
11
13
|
var _transformNode2 = require("./editor-commands/transformNode");
|
|
@@ -38,7 +40,7 @@ var blockMenuPlugin = exports.blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
38
40
|
plugin: function plugin() {
|
|
39
41
|
return (0, _keymap.keymapPlugin)(api, config);
|
|
40
42
|
}
|
|
41
|
-
}, {
|
|
43
|
+
}].concat((0, _toConsumableArray2.default)((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_experience_tracking_observer', 'isEnabled', true) ? [{
|
|
42
44
|
name: 'blockMenuExperiences',
|
|
43
45
|
plugin: function plugin() {
|
|
44
46
|
return (0, _blockMenuExperiences.getBlockMenuExperiencesPlugin)({
|
|
@@ -49,7 +51,7 @@ var blockMenuPlugin = exports.blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
49
51
|
}
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
|
-
}];
|
|
54
|
+
}] : []));
|
|
53
55
|
},
|
|
54
56
|
actions: {
|
|
55
57
|
registerBlockMenuComponents: function registerBlockMenuComponents(blockMenuComponents) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getBlockMenuExperiencesPlugin = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
9
|
var _bindEventListener = require("bind-event-listener");
|
|
8
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
11
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
@@ -37,6 +39,13 @@ var getBlockMenuExperiencesPlugin = exports.getBlockMenuExperiencesPlugin = func
|
|
|
37
39
|
}
|
|
38
40
|
return popupTargetEl;
|
|
39
41
|
};
|
|
42
|
+
var getEditorDom = function getEditorDom() {
|
|
43
|
+
var _editorView2;
|
|
44
|
+
if (((_editorView2 = editorView) === null || _editorView2 === void 0 ? void 0 : _editorView2.dom) instanceof HTMLElement) {
|
|
45
|
+
return editorView.dom;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
40
49
|
var blockMenuOpenExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_OPEN, {
|
|
41
50
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.BLOCK_MENU,
|
|
42
51
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
@@ -48,13 +57,21 @@ var getBlockMenuExperiencesPlugin = exports.getBlockMenuExperiencesPlugin = func
|
|
|
48
57
|
type: 'editorContent'
|
|
49
58
|
})]
|
|
50
59
|
});
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
var observeConfigs = function observeConfigs() {
|
|
61
|
+
var narrowTarget = (0, _experiences.getSelectionAncestorDOM)(editorView);
|
|
62
|
+
var editorDom = getEditorDom();
|
|
63
|
+
return [].concat((0, _toConsumableArray2.default)(narrowTarget ? [{
|
|
64
|
+
target: narrowTarget,
|
|
65
|
+
options: {
|
|
66
|
+
childList: true,
|
|
67
|
+
subtree: true
|
|
68
|
+
}
|
|
69
|
+
}] : []), (0, _toConsumableArray2.default)(editorDom ? [{
|
|
70
|
+
target: editorDom,
|
|
54
71
|
options: {
|
|
55
72
|
childList: true
|
|
56
73
|
}
|
|
57
|
-
};
|
|
74
|
+
}] : []));
|
|
58
75
|
};
|
|
59
76
|
var blockMoveUpExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_ACTION, {
|
|
60
77
|
action: _analytics.ACTION.MOVED,
|
|
@@ -64,7 +81,7 @@ var getBlockMenuExperiencesPlugin = exports.getBlockMenuExperiencesPlugin = func
|
|
|
64
81
|
durationMs: TIMEOUT_DURATION
|
|
65
82
|
}), new _experiences.ExperienceCheckDomMutation({
|
|
66
83
|
onDomMutation: _experienceCheckUtils.handleMoveDomMutation,
|
|
67
|
-
observeConfig:
|
|
84
|
+
observeConfig: observeConfigs
|
|
68
85
|
})]
|
|
69
86
|
});
|
|
70
87
|
var blockMoveDownExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_ACTION, {
|
|
@@ -75,7 +92,7 @@ var getBlockMenuExperiencesPlugin = exports.getBlockMenuExperiencesPlugin = func
|
|
|
75
92
|
durationMs: TIMEOUT_DURATION
|
|
76
93
|
}), new _experiences.ExperienceCheckDomMutation({
|
|
77
94
|
onDomMutation: _experienceCheckUtils.handleMoveDomMutation,
|
|
78
|
-
observeConfig:
|
|
95
|
+
observeConfig: observeConfigs
|
|
79
96
|
})]
|
|
80
97
|
});
|
|
81
98
|
var blockDeleteExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_ACTION, {
|
|
@@ -86,7 +103,7 @@ var getBlockMenuExperiencesPlugin = exports.getBlockMenuExperiencesPlugin = func
|
|
|
86
103
|
durationMs: TIMEOUT_DURATION
|
|
87
104
|
}), new _experiences.ExperienceCheckDomMutation({
|
|
88
105
|
onDomMutation: _experienceCheckUtils.handleDeleteDomMutation,
|
|
89
|
-
observeConfig:
|
|
106
|
+
observeConfig: observeConfigs
|
|
90
107
|
}), new _experiences.ExperienceCheckPopupMutation({
|
|
91
108
|
nestedElementQuery: "[data-testid=\"".concat(PORTAL_TEST_ID.SYNC_BLOCK_DELETE_CONFIRMATION, "\"]"),
|
|
92
109
|
type: 'portalRoot'
|
|
@@ -100,7 +117,7 @@ var getBlockMenuExperiencesPlugin = exports.getBlockMenuExperiencesPlugin = func
|
|
|
100
117
|
durationMs: TIMEOUT_DURATION
|
|
101
118
|
}), new _experiences.ExperienceCheckDomMutation({
|
|
102
119
|
onDomMutation: _experienceCheckUtils.handleTransformDomMutation,
|
|
103
|
-
observeConfig:
|
|
120
|
+
observeConfig: observeConfigs
|
|
104
121
|
})]
|
|
105
122
|
});
|
|
106
123
|
var blockCopyLinkExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_ACTION, {
|
|
@@ -4,11 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.isDragHandleElement = exports.isBlockMenuVisible = exports.handleTransformDomMutation = exports.handleMoveDomMutation = exports.handleMenuOpenDomMutation = exports.handleDeleteDomMutation =
|
|
7
|
+
exports.isDragHandleElement = exports.isBlockMenuVisible = exports.handleTransformDomMutation = exports.handleMoveDomMutation = exports.handleMenuOpenDomMutation = exports.handleDeleteDomMutation = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
10
10
|
var _experiences = require("@atlaskit/editor-common/experiences");
|
|
11
|
-
var _editorTables = require("@atlaskit/editor-tables");
|
|
12
11
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
13
12
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
13
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -34,38 +33,6 @@ var isBlockMenuVisible = exports.isBlockMenuVisible = function isBlockMenuVisibl
|
|
|
34
33
|
}
|
|
35
34
|
return (0, _experiences.popupWithNestedElement)(popupsTarget, "[data-testid=\"".concat(_blockMenu.BLOCK_MENU_TEST_ID, "\"]")) !== null;
|
|
36
35
|
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Gets the parent DOM element at the starting position of the current selection
|
|
40
|
-
* from the provided editor view.
|
|
41
|
-
*
|
|
42
|
-
* @param editorView - The editor view from which to get the parent DOM element
|
|
43
|
-
* @returns The parent HTMLElement of the block at the selection, or null if not found
|
|
44
|
-
*/
|
|
45
|
-
var getParentDOMAtSelection = exports.getParentDOMAtSelection = function getParentDOMAtSelection(editorView) {
|
|
46
|
-
if (!editorView) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
var selection = editorView.state.selection;
|
|
50
|
-
if (selection instanceof _editorTables.CellSelection) {
|
|
51
|
-
// $anchorCell resolves inside the row (before the cell), so
|
|
52
|
-
// $anchorCell.depth is the row's depth. Table is one level up.
|
|
53
|
-
var $cell = selection.$anchorCell;
|
|
54
|
-
var tableDepth = $cell.depth - 1;
|
|
55
|
-
if (tableDepth > 0) {
|
|
56
|
-
var dom = editorView.nodeDOM($cell.before(tableDepth));
|
|
57
|
-
if (dom instanceof HTMLElement && dom.parentElement) {
|
|
58
|
-
return dom.parentElement;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
var from = selection.from;
|
|
63
|
-
var nodeDOM = editorView.nodeDOM(from);
|
|
64
|
-
if (nodeDOM instanceof HTMLElement) {
|
|
65
|
-
return nodeDOM.parentElement;
|
|
66
|
-
}
|
|
67
|
-
return editorView.dom || null;
|
|
68
|
-
};
|
|
69
36
|
var isBlockMenuAddedInMutation = function isBlockMenuAddedInMutation(_ref) {
|
|
70
37
|
var type = _ref.type,
|
|
71
38
|
addedNodes = _ref.addedNodes;
|
|
@@ -10,6 +10,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
11
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
12
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _utils = require("./block-menu-renderer/utils");
|
|
14
15
|
var _copyLink = require("./copy-link");
|
|
15
16
|
var _copySection = require("./copy-section");
|
|
@@ -208,7 +209,31 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
|
|
|
208
209
|
api: api
|
|
209
210
|
}, children);
|
|
210
211
|
}
|
|
212
|
+
}], (0, _toConsumableArray2.default)((0, _platformFeatureFlags.fg)('platform_editor_block_menu_copy_section') ? [{
|
|
213
|
+
type: 'block-menu-section',
|
|
214
|
+
key: _blockMenu.BLOCK_ACTIONS_COPY_MENU_SECTION.key,
|
|
215
|
+
rank: _blockMenu.MAIN_BLOCK_MENU_SECTION_RANK[_blockMenu.BLOCK_ACTIONS_COPY_MENU_SECTION.key],
|
|
216
|
+
component: function component(_ref9) {
|
|
217
|
+
var children = _ref9.children;
|
|
218
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
219
|
+
hasSeparator: true
|
|
220
|
+
}, children);
|
|
221
|
+
}
|
|
211
222
|
}, {
|
|
223
|
+
type: 'block-menu-item',
|
|
224
|
+
key: _blockMenu.BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM.key,
|
|
225
|
+
parent: {
|
|
226
|
+
type: 'block-menu-section',
|
|
227
|
+
key: _blockMenu.BLOCK_ACTIONS_COPY_MENU_SECTION.key,
|
|
228
|
+
rank: _blockMenu.BLOCK_ACTIONS_COPY_MENU_SECTION_RANK[_blockMenu.BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM.key]
|
|
229
|
+
},
|
|
230
|
+
component: function component() {
|
|
231
|
+
return /*#__PURE__*/_react.default.createElement(_copyLink.CopyLinkDropdownItem, {
|
|
232
|
+
api: api,
|
|
233
|
+
config: config
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}] : [{
|
|
212
237
|
type: 'block-menu-item',
|
|
213
238
|
key: _blockMenu.BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM.key,
|
|
214
239
|
parent: {
|
|
@@ -222,12 +247,12 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
|
|
|
222
247
|
config: config
|
|
223
248
|
});
|
|
224
249
|
}
|
|
225
|
-
}, {
|
|
250
|
+
}]), [{
|
|
226
251
|
type: 'block-menu-section',
|
|
227
252
|
key: _blockMenu.POSITION_MENU_SECTION.key,
|
|
228
253
|
rank: _blockMenu.MAIN_BLOCK_MENU_SECTION_RANK[_blockMenu.POSITION_MENU_SECTION.key],
|
|
229
|
-
component: function component(
|
|
230
|
-
var children =
|
|
254
|
+
component: function component(_ref0) {
|
|
255
|
+
var children = _ref0.children;
|
|
231
256
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
232
257
|
hasSeparator: true
|
|
233
258
|
}, children);
|
|
@@ -236,8 +261,8 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
|
|
|
236
261
|
type: 'block-menu-section',
|
|
237
262
|
key: _blockMenu.DELETE_MENU_SECTION.key,
|
|
238
263
|
rank: _blockMenu.MAIN_BLOCK_MENU_SECTION_RANK[_blockMenu.DELETE_MENU_SECTION.key],
|
|
239
|
-
component: function component(
|
|
240
|
-
var children =
|
|
264
|
+
component: function component(_ref1) {
|
|
265
|
+
var children = _ref1.children;
|
|
241
266
|
return /*#__PURE__*/_react.default.createElement(_deleteSection.DeleteSection, null, children);
|
|
242
267
|
}
|
|
243
268
|
}, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
2
3
|
import { createBlockMenuRegistry } from './editor-actions';
|
|
3
4
|
import { isTransformToTargetDisabled } from './editor-actions/isTransformToTargetDisabled';
|
|
4
5
|
import { transformNode } from './editor-commands/transformNode';
|
|
@@ -28,7 +29,7 @@ export const blockMenuPlugin = ({
|
|
|
28
29
|
}, {
|
|
29
30
|
name: 'blockMenuKeymap',
|
|
30
31
|
plugin: () => keymapPlugin(api, config)
|
|
31
|
-
}, {
|
|
32
|
+
}, ...(expValEqualsNoExposure('platform_editor_experience_tracking_observer', 'isEnabled', true) ? [{
|
|
32
33
|
name: 'blockMenuExperiences',
|
|
33
34
|
plugin: () => getBlockMenuExperiencesPlugin({
|
|
34
35
|
refs,
|
|
@@ -37,7 +38,7 @@ export const blockMenuPlugin = ({
|
|
|
37
38
|
return 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.fireAnalyticsEvent(payload);
|
|
38
39
|
}
|
|
39
40
|
})
|
|
40
|
-
}];
|
|
41
|
+
}] : [])];
|
|
41
42
|
},
|
|
42
43
|
actions: {
|
|
43
44
|
registerBlockMenuComponents: blockMenuComponents => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { bind } from 'bind-event-listener';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { BLOCK_MENU_ACTION_TEST_ID, BLOCK_MENU_TEST_ID, EXTENSION_MENU_ITEM_TEST_ID } from '@atlaskit/editor-common/block-menu';
|
|
4
|
-
import { Experience, EXPERIENCE_ID, ExperienceCheckDomMutation, ExperienceCheckPopupMutation, ExperienceCheckTimeout, getPopupContainerFromEditorView } from '@atlaskit/editor-common/experiences';
|
|
4
|
+
import { Experience, EXPERIENCE_ID, ExperienceCheckDomMutation, ExperienceCheckPopupMutation, ExperienceCheckTimeout, getPopupContainerFromEditorView, getSelectionAncestorDOM } from '@atlaskit/editor-common/experiences';
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import {
|
|
7
|
+
import { handleDeleteDomMutation, handleMoveDomMutation, handleTransformDomMutation, isBlockMenuVisible, isDragHandleElement } from './experience-check-utils';
|
|
8
8
|
const TIMEOUT_DURATION = 1000;
|
|
9
9
|
const PORTAL_TEST_ID = {
|
|
10
10
|
LINK_COPIED_TO_CLIPBOARD: 'link-copied-to-clipboard',
|
|
@@ -32,6 +32,13 @@ export const getBlockMenuExperiencesPlugin = ({
|
|
|
32
32
|
}
|
|
33
33
|
return popupTargetEl;
|
|
34
34
|
};
|
|
35
|
+
const getEditorDom = () => {
|
|
36
|
+
var _editorView2;
|
|
37
|
+
if (((_editorView2 = editorView) === null || _editorView2 === void 0 ? void 0 : _editorView2.dom) instanceof HTMLElement) {
|
|
38
|
+
return editorView.dom;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
35
42
|
const blockMenuOpenExperience = new Experience(EXPERIENCE_ID.MENU_OPEN, {
|
|
36
43
|
actionSubjectId: ACTION_SUBJECT_ID.BLOCK_MENU,
|
|
37
44
|
dispatchAnalyticsEvent,
|
|
@@ -43,12 +50,22 @@ export const getBlockMenuExperiencesPlugin = ({
|
|
|
43
50
|
type: 'editorContent'
|
|
44
51
|
})]
|
|
45
52
|
});
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
const observeConfigs = () => {
|
|
54
|
+
const narrowTarget = getSelectionAncestorDOM(editorView);
|
|
55
|
+
const editorDom = getEditorDom();
|
|
56
|
+
return [...(narrowTarget ? [{
|
|
57
|
+
target: narrowTarget,
|
|
58
|
+
options: {
|
|
59
|
+
childList: true,
|
|
60
|
+
subtree: true
|
|
61
|
+
}
|
|
62
|
+
}] : []), ...(editorDom ? [{
|
|
63
|
+
target: editorDom,
|
|
64
|
+
options: {
|
|
65
|
+
childList: true
|
|
66
|
+
}
|
|
67
|
+
}] : [])];
|
|
68
|
+
};
|
|
52
69
|
const blockMoveUpExperience = new Experience(EXPERIENCE_ID.MENU_ACTION, {
|
|
53
70
|
action: ACTION.MOVED,
|
|
54
71
|
actionSubjectId: ACTION_SUBJECT_ID.MOVE_UP_BLOCK,
|
|
@@ -57,7 +74,7 @@ export const getBlockMenuExperiencesPlugin = ({
|
|
|
57
74
|
durationMs: TIMEOUT_DURATION
|
|
58
75
|
}), new ExperienceCheckDomMutation({
|
|
59
76
|
onDomMutation: handleMoveDomMutation,
|
|
60
|
-
observeConfig:
|
|
77
|
+
observeConfig: observeConfigs
|
|
61
78
|
})]
|
|
62
79
|
});
|
|
63
80
|
const blockMoveDownExperience = new Experience(EXPERIENCE_ID.MENU_ACTION, {
|
|
@@ -68,7 +85,7 @@ export const getBlockMenuExperiencesPlugin = ({
|
|
|
68
85
|
durationMs: TIMEOUT_DURATION
|
|
69
86
|
}), new ExperienceCheckDomMutation({
|
|
70
87
|
onDomMutation: handleMoveDomMutation,
|
|
71
|
-
observeConfig:
|
|
88
|
+
observeConfig: observeConfigs
|
|
72
89
|
})]
|
|
73
90
|
});
|
|
74
91
|
const blockDeleteExperience = new Experience(EXPERIENCE_ID.MENU_ACTION, {
|
|
@@ -79,7 +96,7 @@ export const getBlockMenuExperiencesPlugin = ({
|
|
|
79
96
|
durationMs: TIMEOUT_DURATION
|
|
80
97
|
}), new ExperienceCheckDomMutation({
|
|
81
98
|
onDomMutation: handleDeleteDomMutation,
|
|
82
|
-
observeConfig:
|
|
99
|
+
observeConfig: observeConfigs
|
|
83
100
|
}), new ExperienceCheckPopupMutation({
|
|
84
101
|
nestedElementQuery: `[data-testid="${PORTAL_TEST_ID.SYNC_BLOCK_DELETE_CONFIRMATION}"]`,
|
|
85
102
|
type: 'portalRoot'
|
|
@@ -93,7 +110,7 @@ export const getBlockMenuExperiencesPlugin = ({
|
|
|
93
110
|
durationMs: TIMEOUT_DURATION
|
|
94
111
|
}), new ExperienceCheckDomMutation({
|
|
95
112
|
onDomMutation: handleTransformDomMutation,
|
|
96
|
-
observeConfig:
|
|
113
|
+
observeConfig: observeConfigs
|
|
97
114
|
})]
|
|
98
115
|
});
|
|
99
116
|
const blockCopyLinkExperience = new Experience(EXPERIENCE_ID.MENU_ACTION, {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BLOCK_MENU_TEST_ID } from '@atlaskit/editor-common/block-menu';
|
|
2
2
|
import { popupWithNestedElement } from '@atlaskit/editor-common/experiences';
|
|
3
|
-
import { CellSelection } from '@atlaskit/editor-tables';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Checks if the given element or any of its ancestors is a drag handle element.
|
|
@@ -24,40 +23,6 @@ export const isBlockMenuVisible = popupsTarget => {
|
|
|
24
23
|
}
|
|
25
24
|
return popupWithNestedElement(popupsTarget, `[data-testid="${BLOCK_MENU_TEST_ID}"]`) !== null;
|
|
26
25
|
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Gets the parent DOM element at the starting position of the current selection
|
|
30
|
-
* from the provided editor view.
|
|
31
|
-
*
|
|
32
|
-
* @param editorView - The editor view from which to get the parent DOM element
|
|
33
|
-
* @returns The parent HTMLElement of the block at the selection, or null if not found
|
|
34
|
-
*/
|
|
35
|
-
export const getParentDOMAtSelection = editorView => {
|
|
36
|
-
if (!editorView) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const {
|
|
40
|
-
selection
|
|
41
|
-
} = editorView.state;
|
|
42
|
-
if (selection instanceof CellSelection) {
|
|
43
|
-
// $anchorCell resolves inside the row (before the cell), so
|
|
44
|
-
// $anchorCell.depth is the row's depth. Table is one level up.
|
|
45
|
-
const $cell = selection.$anchorCell;
|
|
46
|
-
const tableDepth = $cell.depth - 1;
|
|
47
|
-
if (tableDepth > 0) {
|
|
48
|
-
const dom = editorView.nodeDOM($cell.before(tableDepth));
|
|
49
|
-
if (dom instanceof HTMLElement && dom.parentElement) {
|
|
50
|
-
return dom.parentElement;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const from = selection.from;
|
|
55
|
-
const nodeDOM = editorView.nodeDOM(from);
|
|
56
|
-
if (nodeDOM instanceof HTMLElement) {
|
|
57
|
-
return nodeDOM.parentElement;
|
|
58
|
-
}
|
|
59
|
-
return editorView.dom || null;
|
|
60
|
-
};
|
|
61
26
|
const isBlockMenuAddedInMutation = ({
|
|
62
27
|
type,
|
|
63
28
|
addedNodes
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM, BLOCK_ACTIONS_MENU_SECTION, BLOCK_ACTIONS_MENU_SECTION_RANK, DELETE_MENU_SECTION, DELETE_MENU_SECTION_RANK, DELETE_MENU_ITEM, POSITION_MENU_SECTION, POSITION_MENU_SECTION_RANK, POSITION_MOVE_DOWN_MENU_ITEM, POSITION_MOVE_UP_MENU_ITEM, TRANSFORM_MENU_ITEM, TRANSFORM_MENU_ITEM_RANK, TRANSFORM_MENU_SECTION, TRANSFORM_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_SUGGESTED_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_HEADINGS_MENU_SECTION, MAIN_BLOCK_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
2
|
+
import { BLOCK_ACTIONS_COPY_MENU_SECTION, BLOCK_ACTIONS_COPY_MENU_SECTION_RANK, BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM, BLOCK_ACTIONS_MENU_SECTION, BLOCK_ACTIONS_MENU_SECTION_RANK, DELETE_MENU_SECTION, DELETE_MENU_SECTION_RANK, DELETE_MENU_ITEM, POSITION_MENU_SECTION, POSITION_MENU_SECTION_RANK, POSITION_MOVE_DOWN_MENU_ITEM, POSITION_MOVE_UP_MENU_ITEM, TRANSFORM_MENU_ITEM, TRANSFORM_MENU_ITEM_RANK, TRANSFORM_MENU_SECTION, TRANSFORM_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_SUGGESTED_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_HEADINGS_MENU_SECTION, MAIN_BLOCK_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
3
3
|
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { buildChildrenMap, getChildrenMapKey, willComponentRender } from './block-menu-renderer/utils';
|
|
6
7
|
import { CopyLinkDropdownItem } from './copy-link';
|
|
7
8
|
import { CopySection } from './copy-section';
|
|
@@ -191,7 +192,28 @@ export const getBlockMenuComponents = ({
|
|
|
191
192
|
}) => /*#__PURE__*/React.createElement(CopySection, {
|
|
192
193
|
api: api
|
|
193
194
|
}, children)
|
|
195
|
+
}, ...(fg('platform_editor_block_menu_copy_section') ? [{
|
|
196
|
+
type: 'block-menu-section',
|
|
197
|
+
key: BLOCK_ACTIONS_COPY_MENU_SECTION.key,
|
|
198
|
+
rank: MAIN_BLOCK_MENU_SECTION_RANK[BLOCK_ACTIONS_COPY_MENU_SECTION.key],
|
|
199
|
+
component: ({
|
|
200
|
+
children
|
|
201
|
+
}) => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
202
|
+
hasSeparator: true
|
|
203
|
+
}, children)
|
|
194
204
|
}, {
|
|
205
|
+
type: 'block-menu-item',
|
|
206
|
+
key: BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM.key,
|
|
207
|
+
parent: {
|
|
208
|
+
type: 'block-menu-section',
|
|
209
|
+
key: BLOCK_ACTIONS_COPY_MENU_SECTION.key,
|
|
210
|
+
rank: BLOCK_ACTIONS_COPY_MENU_SECTION_RANK[BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM.key]
|
|
211
|
+
},
|
|
212
|
+
component: () => /*#__PURE__*/React.createElement(CopyLinkDropdownItem, {
|
|
213
|
+
api: api,
|
|
214
|
+
config: config
|
|
215
|
+
})
|
|
216
|
+
}] : [{
|
|
195
217
|
type: 'block-menu-item',
|
|
196
218
|
key: BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM.key,
|
|
197
219
|
parent: {
|
|
@@ -203,7 +225,7 @@ export const getBlockMenuComponents = ({
|
|
|
203
225
|
api: api,
|
|
204
226
|
config: config
|
|
205
227
|
})
|
|
206
|
-
}, {
|
|
228
|
+
}]), {
|
|
207
229
|
type: 'block-menu-section',
|
|
208
230
|
key: POSITION_MENU_SECTION.key,
|
|
209
231
|
rank: MAIN_BLOCK_MENU_SECTION_RANK[POSITION_MENU_SECTION.key],
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import React from 'react';
|
|
3
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
2
4
|
import { createBlockMenuRegistry } from './editor-actions';
|
|
3
5
|
import { isTransformToTargetDisabled } from './editor-actions/isTransformToTargetDisabled';
|
|
4
6
|
import { transformNode as _transformNode } from './editor-commands/transformNode';
|
|
@@ -31,7 +33,7 @@ export var blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
31
33
|
plugin: function plugin() {
|
|
32
34
|
return keymapPlugin(api, config);
|
|
33
35
|
}
|
|
34
|
-
}, {
|
|
36
|
+
}].concat(_toConsumableArray(expValEqualsNoExposure('platform_editor_experience_tracking_observer', 'isEnabled', true) ? [{
|
|
35
37
|
name: 'blockMenuExperiences',
|
|
36
38
|
plugin: function plugin() {
|
|
37
39
|
return getBlockMenuExperiencesPlugin({
|
|
@@ -42,7 +44,7 @@ export var blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
42
44
|
}
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
|
-
}];
|
|
47
|
+
}] : []));
|
|
46
48
|
},
|
|
47
49
|
actions: {
|
|
48
50
|
registerBlockMenuComponents: function registerBlockMenuComponents(blockMenuComponents) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import { bind } from 'bind-event-listener';
|
|
2
3
|
import { ACTION, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { BLOCK_MENU_ACTION_TEST_ID, BLOCK_MENU_TEST_ID, EXTENSION_MENU_ITEM_TEST_ID } from '@atlaskit/editor-common/block-menu';
|
|
4
|
-
import { Experience, EXPERIENCE_ID, ExperienceCheckDomMutation, ExperienceCheckPopupMutation, ExperienceCheckTimeout, getPopupContainerFromEditorView } from '@atlaskit/editor-common/experiences';
|
|
5
|
+
import { Experience, EXPERIENCE_ID, ExperienceCheckDomMutation, ExperienceCheckPopupMutation, ExperienceCheckTimeout, getPopupContainerFromEditorView, getSelectionAncestorDOM } from '@atlaskit/editor-common/experiences';
|
|
5
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
7
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import {
|
|
8
|
+
import { handleDeleteDomMutation, handleMoveDomMutation, handleTransformDomMutation, isBlockMenuVisible, isDragHandleElement } from './experience-check-utils';
|
|
8
9
|
var TIMEOUT_DURATION = 1000;
|
|
9
10
|
var PORTAL_TEST_ID = {
|
|
10
11
|
LINK_COPIED_TO_CLIPBOARD: 'link-copied-to-clipboard',
|
|
@@ -31,6 +32,13 @@ export var getBlockMenuExperiencesPlugin = function getBlockMenuExperiencesPlugi
|
|
|
31
32
|
}
|
|
32
33
|
return popupTargetEl;
|
|
33
34
|
};
|
|
35
|
+
var getEditorDom = function getEditorDom() {
|
|
36
|
+
var _editorView2;
|
|
37
|
+
if (((_editorView2 = editorView) === null || _editorView2 === void 0 ? void 0 : _editorView2.dom) instanceof HTMLElement) {
|
|
38
|
+
return editorView.dom;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
34
42
|
var blockMenuOpenExperience = new Experience(EXPERIENCE_ID.MENU_OPEN, {
|
|
35
43
|
actionSubjectId: ACTION_SUBJECT_ID.BLOCK_MENU,
|
|
36
44
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
@@ -42,13 +50,21 @@ export var getBlockMenuExperiencesPlugin = function getBlockMenuExperiencesPlugi
|
|
|
42
50
|
type: 'editorContent'
|
|
43
51
|
})]
|
|
44
52
|
});
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
var observeConfigs = function observeConfigs() {
|
|
54
|
+
var narrowTarget = getSelectionAncestorDOM(editorView);
|
|
55
|
+
var editorDom = getEditorDom();
|
|
56
|
+
return [].concat(_toConsumableArray(narrowTarget ? [{
|
|
57
|
+
target: narrowTarget,
|
|
58
|
+
options: {
|
|
59
|
+
childList: true,
|
|
60
|
+
subtree: true
|
|
61
|
+
}
|
|
62
|
+
}] : []), _toConsumableArray(editorDom ? [{
|
|
63
|
+
target: editorDom,
|
|
48
64
|
options: {
|
|
49
65
|
childList: true
|
|
50
66
|
}
|
|
51
|
-
};
|
|
67
|
+
}] : []));
|
|
52
68
|
};
|
|
53
69
|
var blockMoveUpExperience = new Experience(EXPERIENCE_ID.MENU_ACTION, {
|
|
54
70
|
action: ACTION.MOVED,
|
|
@@ -58,7 +74,7 @@ export var getBlockMenuExperiencesPlugin = function getBlockMenuExperiencesPlugi
|
|
|
58
74
|
durationMs: TIMEOUT_DURATION
|
|
59
75
|
}), new ExperienceCheckDomMutation({
|
|
60
76
|
onDomMutation: handleMoveDomMutation,
|
|
61
|
-
observeConfig:
|
|
77
|
+
observeConfig: observeConfigs
|
|
62
78
|
})]
|
|
63
79
|
});
|
|
64
80
|
var blockMoveDownExperience = new Experience(EXPERIENCE_ID.MENU_ACTION, {
|
|
@@ -69,7 +85,7 @@ export var getBlockMenuExperiencesPlugin = function getBlockMenuExperiencesPlugi
|
|
|
69
85
|
durationMs: TIMEOUT_DURATION
|
|
70
86
|
}), new ExperienceCheckDomMutation({
|
|
71
87
|
onDomMutation: handleMoveDomMutation,
|
|
72
|
-
observeConfig:
|
|
88
|
+
observeConfig: observeConfigs
|
|
73
89
|
})]
|
|
74
90
|
});
|
|
75
91
|
var blockDeleteExperience = new Experience(EXPERIENCE_ID.MENU_ACTION, {
|
|
@@ -80,7 +96,7 @@ export var getBlockMenuExperiencesPlugin = function getBlockMenuExperiencesPlugi
|
|
|
80
96
|
durationMs: TIMEOUT_DURATION
|
|
81
97
|
}), new ExperienceCheckDomMutation({
|
|
82
98
|
onDomMutation: handleDeleteDomMutation,
|
|
83
|
-
observeConfig:
|
|
99
|
+
observeConfig: observeConfigs
|
|
84
100
|
}), new ExperienceCheckPopupMutation({
|
|
85
101
|
nestedElementQuery: "[data-testid=\"".concat(PORTAL_TEST_ID.SYNC_BLOCK_DELETE_CONFIRMATION, "\"]"),
|
|
86
102
|
type: 'portalRoot'
|
|
@@ -94,7 +110,7 @@ export var getBlockMenuExperiencesPlugin = function getBlockMenuExperiencesPlugi
|
|
|
94
110
|
durationMs: TIMEOUT_DURATION
|
|
95
111
|
}), new ExperienceCheckDomMutation({
|
|
96
112
|
onDomMutation: handleTransformDomMutation,
|
|
97
|
-
observeConfig:
|
|
113
|
+
observeConfig: observeConfigs
|
|
98
114
|
})]
|
|
99
115
|
});
|
|
100
116
|
var blockCopyLinkExperience = new Experience(EXPERIENCE_ID.MENU_ACTION, {
|
|
@@ -4,7 +4,6 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
4
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
5
|
import { BLOCK_MENU_TEST_ID } from '@atlaskit/editor-common/block-menu';
|
|
6
6
|
import { popupWithNestedElement } from '@atlaskit/editor-common/experiences';
|
|
7
|
-
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Checks if the given element or any of its ancestors is a drag handle element.
|
|
@@ -28,38 +27,6 @@ export var isBlockMenuVisible = function isBlockMenuVisible(popupsTarget) {
|
|
|
28
27
|
}
|
|
29
28
|
return popupWithNestedElement(popupsTarget, "[data-testid=\"".concat(BLOCK_MENU_TEST_ID, "\"]")) !== null;
|
|
30
29
|
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Gets the parent DOM element at the starting position of the current selection
|
|
34
|
-
* from the provided editor view.
|
|
35
|
-
*
|
|
36
|
-
* @param editorView - The editor view from which to get the parent DOM element
|
|
37
|
-
* @returns The parent HTMLElement of the block at the selection, or null if not found
|
|
38
|
-
*/
|
|
39
|
-
export var getParentDOMAtSelection = function getParentDOMAtSelection(editorView) {
|
|
40
|
-
if (!editorView) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
var selection = editorView.state.selection;
|
|
44
|
-
if (selection instanceof CellSelection) {
|
|
45
|
-
// $anchorCell resolves inside the row (before the cell), so
|
|
46
|
-
// $anchorCell.depth is the row's depth. Table is one level up.
|
|
47
|
-
var $cell = selection.$anchorCell;
|
|
48
|
-
var tableDepth = $cell.depth - 1;
|
|
49
|
-
if (tableDepth > 0) {
|
|
50
|
-
var dom = editorView.nodeDOM($cell.before(tableDepth));
|
|
51
|
-
if (dom instanceof HTMLElement && dom.parentElement) {
|
|
52
|
-
return dom.parentElement;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
var from = selection.from;
|
|
57
|
-
var nodeDOM = editorView.nodeDOM(from);
|
|
58
|
-
if (nodeDOM instanceof HTMLElement) {
|
|
59
|
-
return nodeDOM.parentElement;
|
|
60
|
-
}
|
|
61
|
-
return editorView.dom || null;
|
|
62
|
-
};
|
|
63
30
|
var isBlockMenuAddedInMutation = function isBlockMenuAddedInMutation(_ref) {
|
|
64
31
|
var type = _ref.type,
|
|
65
32
|
addedNodes = _ref.addedNodes;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM, BLOCK_ACTIONS_MENU_SECTION, BLOCK_ACTIONS_MENU_SECTION_RANK, DELETE_MENU_SECTION, DELETE_MENU_SECTION_RANK, DELETE_MENU_ITEM, POSITION_MENU_SECTION, POSITION_MENU_SECTION_RANK, POSITION_MOVE_DOWN_MENU_ITEM, POSITION_MOVE_UP_MENU_ITEM, TRANSFORM_MENU_ITEM, TRANSFORM_MENU_ITEM_RANK, TRANSFORM_MENU_SECTION, TRANSFORM_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_SUGGESTED_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_HEADINGS_MENU_SECTION, MAIN_BLOCK_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
3
|
+
import { BLOCK_ACTIONS_COPY_MENU_SECTION, BLOCK_ACTIONS_COPY_MENU_SECTION_RANK, BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM, BLOCK_ACTIONS_MENU_SECTION, BLOCK_ACTIONS_MENU_SECTION_RANK, DELETE_MENU_SECTION, DELETE_MENU_SECTION_RANK, DELETE_MENU_ITEM, POSITION_MENU_SECTION, POSITION_MENU_SECTION_RANK, POSITION_MOVE_DOWN_MENU_ITEM, POSITION_MOVE_UP_MENU_ITEM, TRANSFORM_MENU_ITEM, TRANSFORM_MENU_ITEM_RANK, TRANSFORM_MENU_SECTION, TRANSFORM_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_SUGGESTED_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_HEADINGS_MENU_SECTION, MAIN_BLOCK_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
4
4
|
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { buildChildrenMap, getChildrenMapKey, willComponentRender } from './block-menu-renderer/utils';
|
|
7
8
|
import { CopyLinkDropdownItem } from './copy-link';
|
|
8
9
|
import { CopySection } from './copy-section';
|
|
@@ -201,7 +202,31 @@ export var getBlockMenuComponents = function getBlockMenuComponents(_ref7) {
|
|
|
201
202
|
api: api
|
|
202
203
|
}, children);
|
|
203
204
|
}
|
|
205
|
+
}], _toConsumableArray(fg('platform_editor_block_menu_copy_section') ? [{
|
|
206
|
+
type: 'block-menu-section',
|
|
207
|
+
key: BLOCK_ACTIONS_COPY_MENU_SECTION.key,
|
|
208
|
+
rank: MAIN_BLOCK_MENU_SECTION_RANK[BLOCK_ACTIONS_COPY_MENU_SECTION.key],
|
|
209
|
+
component: function component(_ref9) {
|
|
210
|
+
var children = _ref9.children;
|
|
211
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
212
|
+
hasSeparator: true
|
|
213
|
+
}, children);
|
|
214
|
+
}
|
|
204
215
|
}, {
|
|
216
|
+
type: 'block-menu-item',
|
|
217
|
+
key: BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM.key,
|
|
218
|
+
parent: {
|
|
219
|
+
type: 'block-menu-section',
|
|
220
|
+
key: BLOCK_ACTIONS_COPY_MENU_SECTION.key,
|
|
221
|
+
rank: BLOCK_ACTIONS_COPY_MENU_SECTION_RANK[BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM.key]
|
|
222
|
+
},
|
|
223
|
+
component: function component() {
|
|
224
|
+
return /*#__PURE__*/React.createElement(CopyLinkDropdownItem, {
|
|
225
|
+
api: api,
|
|
226
|
+
config: config
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}] : [{
|
|
205
230
|
type: 'block-menu-item',
|
|
206
231
|
key: BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM.key,
|
|
207
232
|
parent: {
|
|
@@ -215,12 +240,12 @@ export var getBlockMenuComponents = function getBlockMenuComponents(_ref7) {
|
|
|
215
240
|
config: config
|
|
216
241
|
});
|
|
217
242
|
}
|
|
218
|
-
}, {
|
|
243
|
+
}]), [{
|
|
219
244
|
type: 'block-menu-section',
|
|
220
245
|
key: POSITION_MENU_SECTION.key,
|
|
221
246
|
rank: MAIN_BLOCK_MENU_SECTION_RANK[POSITION_MENU_SECTION.key],
|
|
222
|
-
component: function component(
|
|
223
|
-
var children =
|
|
247
|
+
component: function component(_ref0) {
|
|
248
|
+
var children = _ref0.children;
|
|
224
249
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
225
250
|
hasSeparator: true
|
|
226
251
|
}, children);
|
|
@@ -229,8 +254,8 @@ export var getBlockMenuComponents = function getBlockMenuComponents(_ref7) {
|
|
|
229
254
|
type: 'block-menu-section',
|
|
230
255
|
key: DELETE_MENU_SECTION.key,
|
|
231
256
|
rank: MAIN_BLOCK_MENU_SECTION_RANK[DELETE_MENU_SECTION.key],
|
|
232
|
-
component: function component(
|
|
233
|
-
var children =
|
|
257
|
+
component: function component(_ref1) {
|
|
258
|
+
var children = _ref1.children;
|
|
234
259
|
return /*#__PURE__*/React.createElement(DeleteSection, null, children);
|
|
235
260
|
}
|
|
236
261
|
}, {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type ExperienceCheckResult } from '@atlaskit/editor-common/experiences';
|
|
2
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
2
|
/**
|
|
4
3
|
* Checks if the given element or any of its ancestors is a drag handle element.
|
|
5
4
|
*
|
|
@@ -14,14 +13,6 @@ export declare const isDragHandleElement: (element: Element | null) => boolean;
|
|
|
14
13
|
* @returns True if the block menu is visible, false otherwise.
|
|
15
14
|
*/
|
|
16
15
|
export declare const isBlockMenuVisible: (popupsTarget: HTMLElement | undefined) => boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Gets the parent DOM element at the starting position of the current selection
|
|
19
|
-
* from the provided editor view.
|
|
20
|
-
*
|
|
21
|
-
* @param editorView - The editor view from which to get the parent DOM element
|
|
22
|
-
* @returns The parent HTMLElement of the block at the selection, or null if not found
|
|
23
|
-
*/
|
|
24
|
-
export declare const getParentDOMAtSelection: (editorView?: EditorView) => HTMLElement | null;
|
|
25
16
|
/**
|
|
26
17
|
* Handles DOM mutations to determine if the block menu was opened
|
|
27
18
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type ExperienceCheckResult } from '@atlaskit/editor-common/experiences';
|
|
2
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
2
|
/**
|
|
4
3
|
* Checks if the given element or any of its ancestors is a drag handle element.
|
|
5
4
|
*
|
|
@@ -14,14 +13,6 @@ export declare const isDragHandleElement: (element: Element | null) => boolean;
|
|
|
14
13
|
* @returns True if the block menu is visible, false otherwise.
|
|
15
14
|
*/
|
|
16
15
|
export declare const isBlockMenuVisible: (popupsTarget: HTMLElement | undefined) => boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Gets the parent DOM element at the starting position of the current selection
|
|
19
|
-
* from the provided editor view.
|
|
20
|
-
*
|
|
21
|
-
* @param editorView - The editor view from which to get the parent DOM element
|
|
22
|
-
* @returns The parent HTMLElement of the block at the selection, or null if not found
|
|
23
|
-
*/
|
|
24
|
-
export declare const getParentDOMAtSelection: (editorView?: EditorView) => HTMLElement | null;
|
|
25
16
|
/**
|
|
26
17
|
* Handles DOM mutations to determine if the block menu was opened
|
|
27
18
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/browser-apis": "^0.0.1",
|
|
32
32
|
"@atlaskit/css": "^0.19.0",
|
|
33
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
34
|
-
"@atlaskit/editor-plugin-block-controls": "^
|
|
35
|
-
"@atlaskit/editor-plugin-decorations": "^
|
|
36
|
-
"@atlaskit/editor-plugin-selection": "^
|
|
37
|
-
"@atlaskit/editor-plugin-user-intent": "^
|
|
33
|
+
"@atlaskit/editor-plugin-analytics": "^8.0.0",
|
|
34
|
+
"@atlaskit/editor-plugin-block-controls": "^9.0.0",
|
|
35
|
+
"@atlaskit/editor-plugin-decorations": "^8.0.0",
|
|
36
|
+
"@atlaskit/editor-plugin-selection": "^8.0.0",
|
|
37
|
+
"@atlaskit/editor-plugin-user-intent": "^6.0.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
39
39
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
40
40
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
45
|
"@atlaskit/primitives": "^18.0.0",
|
|
46
46
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^35.
|
|
48
|
-
"@atlaskit/tokens": "^11.
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^35.10.0",
|
|
48
|
+
"@atlaskit/tokens": "^11.1.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0",
|
|
50
50
|
"bind-event-listener": "^3.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@atlaskit/editor-common": "^
|
|
53
|
+
"@atlaskit/editor-common": "^112.0.0",
|
|
54
54
|
"react": "^18.2.0",
|
|
55
55
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
56
56
|
},
|
|
@@ -94,6 +94,9 @@
|
|
|
94
94
|
"platform_editor_adf_with_localid": {
|
|
95
95
|
"type": "boolean"
|
|
96
96
|
},
|
|
97
|
+
"platform_editor_block_menu_copy_section": {
|
|
98
|
+
"type": "boolean"
|
|
99
|
+
},
|
|
97
100
|
"platform_editor_block_menu_expand_localid_fix": {
|
|
98
101
|
"type": "boolean"
|
|
99
102
|
},
|