@atlaskit/editor-plugin-block-controls 4.1.7 → 4.1.8
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 +9 -0
- package/dist/cjs/blockControlsPlugin.js +27 -11
- package/dist/cjs/pm-plugins/handle-mouse-over.js +10 -1
- package/dist/cjs/pm-plugins/main.js +3 -2
- package/dist/cjs/ui/drag-handle.js +16 -8
- package/dist/es2019/blockControlsPlugin.js +28 -11
- package/dist/es2019/pm-plugins/handle-mouse-over.js +10 -1
- package/dist/es2019/pm-plugins/main.js +3 -2
- package/dist/es2019/ui/drag-handle.js +16 -8
- package/dist/esm/blockControlsPlugin.js +27 -11
- package/dist/esm/pm-plugins/handle-mouse-over.js +10 -1
- package/dist/esm/pm-plugins/main.js +3 -2
- package/dist/esm/ui/drag-handle.js +16 -8
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 4.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#196697](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/196697)
|
|
8
|
+
[`18b5fbc52627b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/18b5fbc52627b) -
|
|
9
|
+
[ux] Adds block menu plugin for full-page preset and shows the menu when drag handle is clicked.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 4.1.7
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -10,6 +10,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
13
14
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
15
|
var _moveNode = require("./editor-commands/move-node");
|
|
15
16
|
var _moveToLayout = require("./editor-commands/move-to-layout");
|
|
@@ -71,6 +72,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
71
72
|
},
|
|
72
73
|
toggleBlockMenu: function toggleBlockMenu(options) {
|
|
73
74
|
return function (_ref4) {
|
|
75
|
+
var _options$anchorName;
|
|
74
76
|
var tr = _ref4.tr;
|
|
75
77
|
var currMeta = tr.getMeta(_main.key);
|
|
76
78
|
if (options !== null && options !== void 0 && options.closeMenu) {
|
|
@@ -79,6 +81,14 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
79
81
|
}));
|
|
80
82
|
return tr;
|
|
81
83
|
}
|
|
84
|
+
|
|
85
|
+
// Do not open menu on layoutColumn and close opened menu when layoutColumn drag handle is clicked
|
|
86
|
+
if (options !== null && options !== void 0 && (_options$anchorName = options.anchorName) !== null && _options$anchorName !== void 0 && _options$anchorName.includes('layoutColumn')) {
|
|
87
|
+
tr.setMeta(_main.key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
88
|
+
closeMenu: true
|
|
89
|
+
}));
|
|
90
|
+
return tr;
|
|
91
|
+
}
|
|
82
92
|
tr.setMeta(_main.key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
83
93
|
toggleMenu: {
|
|
84
94
|
anchorName: options === null || options === void 0 ? void 0 : options.anchorName
|
|
@@ -206,17 +216,23 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
206
216
|
popupsMountPoint = _ref8.popupsMountPoint,
|
|
207
217
|
popupsBoundariesElement = _ref8.popupsBoundariesElement,
|
|
208
218
|
popupsScrollableElement = _ref8.popupsScrollableElement;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
219
|
+
if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
220
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, {
|
|
221
|
+
api: api
|
|
222
|
+
}));
|
|
223
|
+
} else {
|
|
224
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? /*#__PURE__*/_react.default.createElement(_blockMenu.default, {
|
|
225
|
+
editorView: editorView,
|
|
226
|
+
mountPoint: popupsMountPoint,
|
|
227
|
+
boundariesElement: popupsBoundariesElement,
|
|
228
|
+
scrollableElement: popupsScrollableElement,
|
|
229
|
+
api: api
|
|
230
|
+
}) : /*#__PURE__*/_react.default.createElement(_dragHandleMenu.DragHandleMenu, {
|
|
231
|
+
api: api
|
|
232
|
+
}), /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, {
|
|
233
|
+
api: api
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
220
236
|
}
|
|
221
237
|
};
|
|
222
238
|
};
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.handleMouseOver = void 0;
|
|
7
7
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
8
9
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
9
10
|
var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(target) {
|
|
10
11
|
if (target instanceof HTMLHeadingElement || target instanceof HTMLParagraphElement) {
|
|
@@ -17,7 +18,9 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
17
18
|
var _api$blockControls, _target$classList;
|
|
18
19
|
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
19
20
|
isDragging = _ref.isDragging,
|
|
20
|
-
activeNode = _ref.activeNode
|
|
21
|
+
activeNode = _ref.activeNode,
|
|
22
|
+
isMenuOpen = _ref.isMenuOpen,
|
|
23
|
+
originalAnchorName = _ref.menuTriggerBy;
|
|
21
24
|
|
|
22
25
|
// Most mouseover events don't fire during drag but some can slip through
|
|
23
26
|
// when the drag begins. This prevents those.
|
|
@@ -127,6 +130,12 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
127
130
|
var _api$core2, _api$blockControls3;
|
|
128
131
|
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType));
|
|
129
132
|
}
|
|
133
|
+
if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
134
|
+
if (isMenuOpen && originalAnchorName) {
|
|
135
|
+
var _api$core3, _api$blockControls4;
|
|
136
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.toggleBlockMenu());
|
|
137
|
+
}
|
|
138
|
+
}
|
|
130
139
|
}
|
|
131
140
|
}
|
|
132
141
|
};
|
|
@@ -20,6 +20,7 @@ var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
|
|
|
20
20
|
var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
|
|
21
21
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
22
22
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
23
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
23
24
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
24
25
|
var _consts = require("../ui/consts");
|
|
25
26
|
var _decorationsAnchor = require("./decorations-anchor");
|
|
@@ -504,7 +505,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
504
505
|
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && (0, _decorationsDragHandle.findHandleDec)(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length === 0 ? null : latestActiveNode;
|
|
505
506
|
}
|
|
506
507
|
var isMenuOpenNew = isMenuOpen;
|
|
507
|
-
if (_consts.BLOCK_MENU_ENABLED && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
508
|
+
if (_consts.BLOCK_MENU_ENABLED && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') || (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
508
509
|
if (meta !== null && meta !== void 0 && meta.closeMenu) {
|
|
509
510
|
isMenuOpenNew = false;
|
|
510
511
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
@@ -526,7 +527,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
526
527
|
activeDropTargetNode: currentActiveDropTargetNode,
|
|
527
528
|
isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
|
|
528
529
|
isMenuOpen: isMenuOpenNew,
|
|
529
|
-
menuTriggerBy: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
530
|
+
menuTriggerBy: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') || (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
530
531
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : editorHeight,
|
|
531
532
|
editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : editorWidthLeft,
|
|
532
533
|
editorWidthRight: (_meta$editorWidthRigh = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh !== void 0 ? _meta$editorWidthRigh : editorWidthRight,
|
|
@@ -291,7 +291,7 @@ var useDragHandlePluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(
|
|
|
291
291
|
};
|
|
292
292
|
});
|
|
293
293
|
var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
294
|
-
var _api$core2, _api$
|
|
294
|
+
var _api$core2, _api$blockControls4, _api$analytics2, _api$core4;
|
|
295
295
|
var view = _ref.view,
|
|
296
296
|
api = _ref.api,
|
|
297
297
|
formatMessage = _ref.formatMessage,
|
|
@@ -377,13 +377,21 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
377
377
|
tr: tr
|
|
378
378
|
});
|
|
379
379
|
e.stopPropagation();
|
|
380
|
+
} else if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
381
|
+
var _api$blockControls2;
|
|
382
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
|
|
383
|
+
anchorName: anchorName
|
|
384
|
+
})({
|
|
385
|
+
tr: tr
|
|
386
|
+
});
|
|
387
|
+
e.stopPropagation();
|
|
380
388
|
}
|
|
381
389
|
} else if (isTopLevelNode && $anchor.depth <= _consts2.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
|
|
382
|
-
var _api$
|
|
390
|
+
var _api$blockControls3;
|
|
383
391
|
var alignAnchorHeadToSel = (0, _selection.alignAnchorHeadInDirectionOfPos)(tr.selection, startPos);
|
|
384
392
|
var selectionWithExpandedHead = (0, _selection.expandSelectionHeadToNodeAtPos)(alignAnchorHeadToSel, startPos);
|
|
385
393
|
tr.setSelection(selectionWithExpandedHead);
|
|
386
|
-
api === null || api === void 0 || (_api$
|
|
394
|
+
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.setMultiSelectPositions()({
|
|
387
395
|
tr: tr
|
|
388
396
|
});
|
|
389
397
|
}
|
|
@@ -403,7 +411,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
403
411
|
return tr;
|
|
404
412
|
});
|
|
405
413
|
view.focus();
|
|
406
|
-
}, [isMultiSelect, api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions, api === null || api === void 0 ? void 0 : api.blockControls.sharedState, api === null || api === void 0 || (_api$
|
|
414
|
+
}, [isMultiSelect, api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions, api === null || api === void 0 ? void 0 : api.blockControls.sharedState, api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, view, dragHandleSelected, getPos, isTopLevelNode, nodeType, anchorName]);
|
|
407
415
|
|
|
408
416
|
// TODO: ED-26959 - This needs to be investigated further. Drag preview generation is not always working
|
|
409
417
|
// as expected with a node selection. This workaround sets the selection to the node on mouseDown,
|
|
@@ -477,8 +485,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
477
485
|
var oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
|
|
478
486
|
var newHandlePosCheck = (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos);
|
|
479
487
|
if (!tr.selection.empty && ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
|
|
480
|
-
var _api$
|
|
481
|
-
api === null || api === void 0 || (_api$
|
|
488
|
+
var _api$blockControls5;
|
|
489
|
+
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
|
|
482
490
|
tr: tr
|
|
483
491
|
});
|
|
484
492
|
} else if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_select_node_on_drag')) {
|
|
@@ -586,7 +594,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
586
594
|
return;
|
|
587
595
|
}
|
|
588
596
|
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref7) {
|
|
589
|
-
var _api$blockControls$sh3, _api$
|
|
597
|
+
var _api$blockControls$sh3, _api$blockControls6, _api$analytics3;
|
|
590
598
|
var tr = _ref7.tr;
|
|
591
599
|
var nodeTypes, hasSelectedMultipleNodes;
|
|
592
600
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
@@ -600,7 +608,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
600
608
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
601
609
|
hasSelectedMultipleNodes = false;
|
|
602
610
|
}
|
|
603
|
-
api === null || api === void 0 || (_api$
|
|
611
|
+
api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
604
612
|
tr: tr
|
|
605
613
|
});
|
|
606
614
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
5
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
import { moveNode } from './editor-commands/move-node';
|
|
7
8
|
import { moveToLayout } from './editor-commands/move-to-layout';
|
|
@@ -61,6 +62,7 @@ export const blockControlsPlugin = ({
|
|
|
61
62
|
toggleBlockMenu: options => ({
|
|
62
63
|
tr
|
|
63
64
|
}) => {
|
|
65
|
+
var _options$anchorName;
|
|
64
66
|
const currMeta = tr.getMeta(key);
|
|
65
67
|
if (options !== null && options !== void 0 && options.closeMenu) {
|
|
66
68
|
tr.setMeta(key, {
|
|
@@ -69,6 +71,15 @@ export const blockControlsPlugin = ({
|
|
|
69
71
|
});
|
|
70
72
|
return tr;
|
|
71
73
|
}
|
|
74
|
+
|
|
75
|
+
// Do not open menu on layoutColumn and close opened menu when layoutColumn drag handle is clicked
|
|
76
|
+
if (options !== null && options !== void 0 && (_options$anchorName = options.anchorName) !== null && _options$anchorName !== void 0 && _options$anchorName.includes('layoutColumn')) {
|
|
77
|
+
tr.setMeta(key, {
|
|
78
|
+
...currMeta,
|
|
79
|
+
closeMenu: true
|
|
80
|
+
});
|
|
81
|
+
return tr;
|
|
82
|
+
}
|
|
72
83
|
tr.setMeta(key, {
|
|
73
84
|
...currMeta,
|
|
74
85
|
toggleMenu: {
|
|
@@ -198,16 +209,22 @@ export const blockControlsPlugin = ({
|
|
|
198
209
|
popupsBoundariesElement,
|
|
199
210
|
popupsScrollableElement
|
|
200
211
|
}) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
213
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStylesWrapper, {
|
|
214
|
+
api: api
|
|
215
|
+
}));
|
|
216
|
+
} else {
|
|
217
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, editorExperiment('platform_editor_controls', 'variant1') ? /*#__PURE__*/React.createElement(BlockMenu, {
|
|
218
|
+
editorView: editorView,
|
|
219
|
+
mountPoint: popupsMountPoint,
|
|
220
|
+
boundariesElement: popupsBoundariesElement,
|
|
221
|
+
scrollableElement: popupsScrollableElement,
|
|
222
|
+
api: api
|
|
223
|
+
}) : /*#__PURE__*/React.createElement(DragHandleMenu, {
|
|
224
|
+
api: api
|
|
225
|
+
}), /*#__PURE__*/React.createElement(GlobalStylesWrapper, {
|
|
226
|
+
api: api
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
212
229
|
}
|
|
213
230
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
2
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
const isEmptyNestedParagraphOrHeading = target => {
|
|
4
5
|
if (target instanceof HTMLHeadingElement || target instanceof HTMLParagraphElement) {
|
|
@@ -11,7 +12,9 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
11
12
|
var _api$blockControls, _target$classList;
|
|
12
13
|
const {
|
|
13
14
|
isDragging,
|
|
14
|
-
activeNode
|
|
15
|
+
activeNode,
|
|
16
|
+
isMenuOpen,
|
|
17
|
+
menuTriggerBy: originalAnchorName
|
|
15
18
|
} = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
|
|
16
19
|
|
|
17
20
|
// Most mouseover events don't fire during drag but some can slip through
|
|
@@ -122,6 +125,12 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
122
125
|
var _api$core2, _api$blockControls3;
|
|
123
126
|
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType));
|
|
124
127
|
}
|
|
128
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
129
|
+
if (isMenuOpen && originalAnchorName) {
|
|
130
|
+
var _api$core3, _api$blockControls4;
|
|
131
|
+
api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.toggleBlockMenu());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
136
|
};
|
|
@@ -12,6 +12,7 @@ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-sc
|
|
|
12
12
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
13
13
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
14
14
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
15
16
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
16
17
|
import { BLOCK_MENU_ENABLED } from '../ui/consts';
|
|
17
18
|
import { findNodeDecs, nodeDecorations } from './decorations-anchor';
|
|
@@ -504,7 +505,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
504
505
|
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length === 0 ? null : latestActiveNode;
|
|
505
506
|
}
|
|
506
507
|
let isMenuOpenNew = isMenuOpen;
|
|
507
|
-
if (BLOCK_MENU_ENABLED && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
508
|
+
if (BLOCK_MENU_ENABLED && editorExperiment('platform_editor_controls', 'variant1') || expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
508
509
|
if (meta !== null && meta !== void 0 && meta.closeMenu) {
|
|
509
510
|
isMenuOpenNew = false;
|
|
510
511
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
@@ -526,7 +527,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
526
527
|
activeDropTargetNode: currentActiveDropTargetNode,
|
|
527
528
|
isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
|
|
528
529
|
isMenuOpen: isMenuOpenNew,
|
|
529
|
-
menuTriggerBy: editorExperiment('platform_editor_controls', 'variant1') ? (meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
530
|
+
menuTriggerBy: editorExperiment('platform_editor_controls', 'variant1') || expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? (meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
530
531
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : editorHeight,
|
|
531
532
|
editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : editorWidthLeft,
|
|
532
533
|
editorWidthRight: (_meta$editorWidthRigh = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh !== void 0 ? _meta$editorWidthRigh : editorWidthRight,
|
|
@@ -298,7 +298,7 @@ export const DragHandle = ({
|
|
|
298
298
|
isTopLevelNode = true,
|
|
299
299
|
anchorRectCache
|
|
300
300
|
}) => {
|
|
301
|
-
var _api$core2, _api$
|
|
301
|
+
var _api$core2, _api$blockControls4, _api$analytics2, _api$core4;
|
|
302
302
|
const buttonRef = useRef(null);
|
|
303
303
|
const [dragHandleSelected, setDragHandleSelected] = useState(false);
|
|
304
304
|
const [dragHandleDisabled, setDragHandleDisabled] = useState(false);
|
|
@@ -359,13 +359,21 @@ export const DragHandle = ({
|
|
|
359
359
|
tr
|
|
360
360
|
});
|
|
361
361
|
e.stopPropagation();
|
|
362
|
+
} else if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
363
|
+
var _api$blockControls2;
|
|
364
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.toggleBlockMenu({
|
|
365
|
+
anchorName
|
|
366
|
+
})({
|
|
367
|
+
tr
|
|
368
|
+
});
|
|
369
|
+
e.stopPropagation();
|
|
362
370
|
}
|
|
363
371
|
} else if (isTopLevelNode && $anchor.depth <= DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
364
|
-
var _api$
|
|
372
|
+
var _api$blockControls3;
|
|
365
373
|
const alignAnchorHeadToSel = alignAnchorHeadInDirectionOfPos(tr.selection, startPos);
|
|
366
374
|
const selectionWithExpandedHead = expandSelectionHeadToNodeAtPos(alignAnchorHeadToSel, startPos);
|
|
367
375
|
tr.setSelection(selectionWithExpandedHead);
|
|
368
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
376
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.setMultiSelectPositions()({
|
|
369
377
|
tr
|
|
370
378
|
});
|
|
371
379
|
}
|
|
@@ -385,7 +393,7 @@ export const DragHandle = ({
|
|
|
385
393
|
return tr;
|
|
386
394
|
});
|
|
387
395
|
view.focus();
|
|
388
|
-
}, [isMultiSelect, api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions, api === null || api === void 0 ? void 0 : api.blockControls.sharedState, api === null || api === void 0 ? void 0 : (_api$
|
|
396
|
+
}, [isMultiSelect, api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions, api === null || api === void 0 ? void 0 : api.blockControls.sharedState, api === null || api === void 0 ? void 0 : (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, view, dragHandleSelected, getPos, isTopLevelNode, nodeType, anchorName]);
|
|
389
397
|
|
|
390
398
|
// TODO: ED-26959 - This needs to be investigated further. Drag preview generation is not always working
|
|
391
399
|
// as expected with a node selection. This workaround sets the selection to the node on mouseDown,
|
|
@@ -458,8 +466,8 @@ export const DragHandle = ({
|
|
|
458
466
|
const oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
|
|
459
467
|
const newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
460
468
|
if (!tr.selection.empty && (fg('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
|
|
461
|
-
var _api$
|
|
462
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
469
|
+
var _api$blockControls5;
|
|
470
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.setMultiSelectPositions()({
|
|
463
471
|
tr
|
|
464
472
|
});
|
|
465
473
|
} else if (fg('platform_editor_elements_dnd_select_node_on_drag')) {
|
|
@@ -574,7 +582,7 @@ export const DragHandle = ({
|
|
|
574
582
|
api === null || api === void 0 ? void 0 : (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions.execute(({
|
|
575
583
|
tr
|
|
576
584
|
}) => {
|
|
577
|
-
var _api$blockControls$sh3, _api$
|
|
585
|
+
var _api$blockControls$sh3, _api$blockControls6, _api$analytics3;
|
|
578
586
|
let nodeTypes, hasSelectedMultipleNodes;
|
|
579
587
|
const resolvedMovingNode = tr.doc.resolve(start);
|
|
580
588
|
const maybeNode = resolvedMovingNode.nodeAfter;
|
|
@@ -587,7 +595,7 @@ export const DragHandle = ({
|
|
|
587
595
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
588
596
|
hasSelectedMultipleNodes = false;
|
|
589
597
|
}
|
|
590
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
598
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 ? void 0 : _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
591
599
|
tr
|
|
592
600
|
});
|
|
593
601
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -5,6 +5,7 @@ import React from 'react';
|
|
|
5
5
|
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
6
6
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
8
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
10
|
import { moveNode } from './editor-commands/move-node';
|
|
10
11
|
import { moveToLayout } from './editor-commands/move-to-layout';
|
|
@@ -64,6 +65,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
64
65
|
},
|
|
65
66
|
toggleBlockMenu: function toggleBlockMenu(options) {
|
|
66
67
|
return function (_ref4) {
|
|
68
|
+
var _options$anchorName;
|
|
67
69
|
var tr = _ref4.tr;
|
|
68
70
|
var currMeta = tr.getMeta(key);
|
|
69
71
|
if (options !== null && options !== void 0 && options.closeMenu) {
|
|
@@ -72,6 +74,14 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
72
74
|
}));
|
|
73
75
|
return tr;
|
|
74
76
|
}
|
|
77
|
+
|
|
78
|
+
// Do not open menu on layoutColumn and close opened menu when layoutColumn drag handle is clicked
|
|
79
|
+
if (options !== null && options !== void 0 && (_options$anchorName = options.anchorName) !== null && _options$anchorName !== void 0 && _options$anchorName.includes('layoutColumn')) {
|
|
80
|
+
tr.setMeta(key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
81
|
+
closeMenu: true
|
|
82
|
+
}));
|
|
83
|
+
return tr;
|
|
84
|
+
}
|
|
75
85
|
tr.setMeta(key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
76
86
|
toggleMenu: {
|
|
77
87
|
anchorName: options === null || options === void 0 ? void 0 : options.anchorName
|
|
@@ -199,17 +209,23 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
199
209
|
popupsMountPoint = _ref8.popupsMountPoint,
|
|
200
210
|
popupsBoundariesElement = _ref8.popupsBoundariesElement,
|
|
201
211
|
popupsScrollableElement = _ref8.popupsScrollableElement;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
212
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
213
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStylesWrapper, {
|
|
214
|
+
api: api
|
|
215
|
+
}));
|
|
216
|
+
} else {
|
|
217
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, editorExperiment('platform_editor_controls', 'variant1') ? /*#__PURE__*/React.createElement(BlockMenu, {
|
|
218
|
+
editorView: editorView,
|
|
219
|
+
mountPoint: popupsMountPoint,
|
|
220
|
+
boundariesElement: popupsBoundariesElement,
|
|
221
|
+
scrollableElement: popupsScrollableElement,
|
|
222
|
+
api: api
|
|
223
|
+
}) : /*#__PURE__*/React.createElement(DragHandleMenu, {
|
|
224
|
+
api: api
|
|
225
|
+
}), /*#__PURE__*/React.createElement(GlobalStylesWrapper, {
|
|
226
|
+
api: api
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
213
229
|
}
|
|
214
230
|
};
|
|
215
231
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
2
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(target) {
|
|
4
5
|
if (target instanceof HTMLHeadingElement || target instanceof HTMLParagraphElement) {
|
|
@@ -11,7 +12,9 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
11
12
|
var _api$blockControls, _target$classList;
|
|
12
13
|
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
13
14
|
isDragging = _ref.isDragging,
|
|
14
|
-
activeNode = _ref.activeNode
|
|
15
|
+
activeNode = _ref.activeNode,
|
|
16
|
+
isMenuOpen = _ref.isMenuOpen,
|
|
17
|
+
originalAnchorName = _ref.menuTriggerBy;
|
|
15
18
|
|
|
16
19
|
// Most mouseover events don't fire during drag but some can slip through
|
|
17
20
|
// when the drag begins. This prevents those.
|
|
@@ -121,6 +124,12 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
121
124
|
var _api$core2, _api$blockControls3;
|
|
122
125
|
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType));
|
|
123
126
|
}
|
|
127
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
128
|
+
if (isMenuOpen && originalAnchorName) {
|
|
129
|
+
var _api$core3, _api$blockControls4;
|
|
130
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.toggleBlockMenu());
|
|
131
|
+
}
|
|
132
|
+
}
|
|
124
133
|
}
|
|
125
134
|
}
|
|
126
135
|
};
|
|
@@ -15,6 +15,7 @@ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-sc
|
|
|
15
15
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
16
16
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
17
17
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
18
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
18
19
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
20
|
import { BLOCK_MENU_ENABLED } from '../ui/consts';
|
|
20
21
|
import { findNodeDecs, nodeDecorations } from './decorations-anchor';
|
|
@@ -497,7 +498,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
497
498
|
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length === 0 ? null : latestActiveNode;
|
|
498
499
|
}
|
|
499
500
|
var isMenuOpenNew = isMenuOpen;
|
|
500
|
-
if (BLOCK_MENU_ENABLED && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
501
|
+
if (BLOCK_MENU_ENABLED && editorExperiment('platform_editor_controls', 'variant1') || expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
501
502
|
if (meta !== null && meta !== void 0 && meta.closeMenu) {
|
|
502
503
|
isMenuOpenNew = false;
|
|
503
504
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
@@ -519,7 +520,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
519
520
|
activeDropTargetNode: currentActiveDropTargetNode,
|
|
520
521
|
isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
|
|
521
522
|
isMenuOpen: isMenuOpenNew,
|
|
522
|
-
menuTriggerBy: editorExperiment('platform_editor_controls', 'variant1') ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
523
|
+
menuTriggerBy: editorExperiment('platform_editor_controls', 'variant1') || expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
523
524
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : editorHeight,
|
|
524
525
|
editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : editorWidthLeft,
|
|
525
526
|
editorWidthRight: (_meta$editorWidthRigh = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh !== void 0 ? _meta$editorWidthRigh : editorWidthRight,
|
|
@@ -288,7 +288,7 @@ var useDragHandlePluginState = sharedPluginStateHookMigratorFactory(function (ap
|
|
|
288
288
|
};
|
|
289
289
|
});
|
|
290
290
|
export var DragHandle = function DragHandle(_ref) {
|
|
291
|
-
var _api$core2, _api$
|
|
291
|
+
var _api$core2, _api$blockControls4, _api$analytics2, _api$core4;
|
|
292
292
|
var view = _ref.view,
|
|
293
293
|
api = _ref.api,
|
|
294
294
|
formatMessage = _ref.formatMessage,
|
|
@@ -374,13 +374,21 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
374
374
|
tr: tr
|
|
375
375
|
});
|
|
376
376
|
e.stopPropagation();
|
|
377
|
+
} else if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
378
|
+
var _api$blockControls2;
|
|
379
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
|
|
380
|
+
anchorName: anchorName
|
|
381
|
+
})({
|
|
382
|
+
tr: tr
|
|
383
|
+
});
|
|
384
|
+
e.stopPropagation();
|
|
377
385
|
}
|
|
378
386
|
} else if (isTopLevelNode && $anchor.depth <= DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
379
|
-
var _api$
|
|
387
|
+
var _api$blockControls3;
|
|
380
388
|
var alignAnchorHeadToSel = alignAnchorHeadInDirectionOfPos(tr.selection, startPos);
|
|
381
389
|
var selectionWithExpandedHead = expandSelectionHeadToNodeAtPos(alignAnchorHeadToSel, startPos);
|
|
382
390
|
tr.setSelection(selectionWithExpandedHead);
|
|
383
|
-
api === null || api === void 0 || (_api$
|
|
391
|
+
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.setMultiSelectPositions()({
|
|
384
392
|
tr: tr
|
|
385
393
|
});
|
|
386
394
|
}
|
|
@@ -400,7 +408,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
400
408
|
return tr;
|
|
401
409
|
});
|
|
402
410
|
view.focus();
|
|
403
|
-
}, [isMultiSelect, api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions, api === null || api === void 0 ? void 0 : api.blockControls.sharedState, api === null || api === void 0 || (_api$
|
|
411
|
+
}, [isMultiSelect, api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions, api === null || api === void 0 ? void 0 : api.blockControls.sharedState, api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, view, dragHandleSelected, getPos, isTopLevelNode, nodeType, anchorName]);
|
|
404
412
|
|
|
405
413
|
// TODO: ED-26959 - This needs to be investigated further. Drag preview generation is not always working
|
|
406
414
|
// as expected with a node selection. This workaround sets the selection to the node on mouseDown,
|
|
@@ -474,8 +482,8 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
474
482
|
var oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
|
|
475
483
|
var newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
476
484
|
if (!tr.selection.empty && (fg('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
|
|
477
|
-
var _api$
|
|
478
|
-
api === null || api === void 0 || (_api$
|
|
485
|
+
var _api$blockControls5;
|
|
486
|
+
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
|
|
479
487
|
tr: tr
|
|
480
488
|
});
|
|
481
489
|
} else if (fg('platform_editor_elements_dnd_select_node_on_drag')) {
|
|
@@ -583,7 +591,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
583
591
|
return;
|
|
584
592
|
}
|
|
585
593
|
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref7) {
|
|
586
|
-
var _api$blockControls$sh3, _api$
|
|
594
|
+
var _api$blockControls$sh3, _api$blockControls6, _api$analytics3;
|
|
587
595
|
var tr = _ref7.tr;
|
|
588
596
|
var nodeTypes, hasSelectedMultipleNodes;
|
|
589
597
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
@@ -597,7 +605,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
597
605
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
598
606
|
hasSelectedMultipleNodes = false;
|
|
599
607
|
}
|
|
600
|
-
api === null || api === void 0 || (_api$
|
|
608
|
+
api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
601
609
|
tr: tr
|
|
602
610
|
});
|
|
603
611
|
tr.setMeta('scrollIntoView', false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.8",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
55
55
|
"@atlaskit/primitives": "^14.11.0",
|
|
56
56
|
"@atlaskit/theme": "^19.0.0",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^9.
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^9.25.0",
|
|
58
58
|
"@atlaskit/tokens": "^6.0.0",
|
|
59
59
|
"@atlaskit/tooltip": "^20.4.0",
|
|
60
60
|
"@babel/runtime": "^7.0.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"uuid": "^3.1.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@atlaskit/editor-common": "^107.
|
|
69
|
+
"@atlaskit/editor-common": "^107.18.0",
|
|
70
70
|
"react": "^18.2.0",
|
|
71
71
|
"react-dom": "^18.2.0",
|
|
72
72
|
"react-intl-next": "npm:react-intl@^5.18.1"
|