@atlaskit/editor-plugin-block-controls 6.3.4 → 6.3.6
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/editor-commands/move-node-with-block-menu.js +9 -0
- package/dist/cjs/editor-commands/utils/move-node-utils.js +11 -0
- package/dist/cjs/pm-plugins/utils/getSelection.js +10 -1
- package/dist/cjs/ui/drag-handle.js +54 -25
- package/dist/es2019/editor-commands/move-node-with-block-menu.js +9 -0
- package/dist/es2019/editor-commands/utils/move-node-utils.js +11 -0
- package/dist/es2019/pm-plugins/utils/getSelection.js +10 -1
- package/dist/es2019/ui/drag-handle.js +40 -10
- package/dist/esm/editor-commands/move-node-with-block-menu.js +9 -0
- package/dist/esm/editor-commands/utils/move-node-utils.js +11 -0
- package/dist/esm/pm-plugins/utils/getSelection.js +10 -1
- package/dist/esm/ui/drag-handle.js +54 -25
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 6.3.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ef686b3cfdbff`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ef686b3cfdbff) -
|
|
8
|
+
ED-29222: Make empty line experiment dependent on block menu
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 6.3.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`d5e5b25fe885a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d5e5b25fe885a) -
|
|
16
|
+
[ux] ED-29226 Open block menu when drag handle is focussed and space or enter key is pressed
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 6.3.4
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.moveNodeWithBlockMenu = void 0;
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
8
|
var _types = require("@atlaskit/editor-common/types");
|
|
9
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
9
11
|
var _moveNode = require("./move-node");
|
|
10
12
|
var _moveNodeUtils = require("./utils/move-node-utils");
|
|
11
13
|
var moveNodeWithBlockMenu = exports.moveNodeWithBlockMenu = function moveNodeWithBlockMenu(api, direction) {
|
|
@@ -36,6 +38,13 @@ var moveNodeWithBlockMenu = exports.moveNodeWithBlockMenu = function moveNodeWit
|
|
|
36
38
|
(0, _moveNode.moveNode)(api)(currentNodePos, moveToPos, _analytics.INPUT_METHOD.BLOCK_MENU)({
|
|
37
39
|
tr: tr
|
|
38
40
|
});
|
|
41
|
+
if (tr.selection.empty && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
42
|
+
var nodeAtCurrentPos = tr.doc.nodeAt(currentNodePos);
|
|
43
|
+
var nodeAfter = tr.doc.nodeAt(moveToPos);
|
|
44
|
+
var isConsecutiveEmptyLineMove = (nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0;
|
|
45
|
+
var cursorPos = direction === _types.DIRECTION.UP || direction === _types.DIRECTION.DOWN && isConsecutiveEmptyLineMove ? moveToPos : moveToPos - 1;
|
|
46
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, cursorPos));
|
|
47
|
+
}
|
|
39
48
|
tr.scrollIntoView();
|
|
40
49
|
}
|
|
41
50
|
}
|
|
@@ -6,12 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getShouldMoveNode = exports.getPosWhenMoveNodeUp = exports.getPosWhenMoveNodeDown = exports.getCurrentNodePosFromDragHandleSelection = exports.canMoveNodeUpOrDown = void 0;
|
|
7
7
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
8
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
9
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
9
10
|
var _getNestedNodePosition = require("../../pm-plugins/utils/getNestedNodePosition");
|
|
10
11
|
var getCurrentNodePosFromDragHandleSelection = exports.getCurrentNodePosFromDragHandleSelection = function getCurrentNodePosFromDragHandleSelection(_ref) {
|
|
11
12
|
var selection = _ref.selection,
|
|
12
13
|
schema = _ref.schema,
|
|
13
14
|
resolve = _ref.resolve;
|
|
14
15
|
var currentNodePos = -1;
|
|
16
|
+
if (selection.empty && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
17
|
+
currentNodePos = selection.$from.pos;
|
|
18
|
+
}
|
|
15
19
|
if ((0, _utils.isTableSelected)(selection)) {
|
|
16
20
|
var _findTable$pos, _findTable;
|
|
17
21
|
// We only move table node if it's fully selected
|
|
@@ -45,6 +49,13 @@ var getPosWhenMoveNodeDown = exports.getPosWhenMoveNodeDown = function getPosWhe
|
|
|
45
49
|
return -1;
|
|
46
50
|
}
|
|
47
51
|
var nodeAfter = tr.doc.nodeAt(nodeAfterPos);
|
|
52
|
+
if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
53
|
+
var nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
|
|
54
|
+
// if move empty line down to another empty line, move to the position of the next empty line
|
|
55
|
+
if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
|
|
56
|
+
return nodeAfterPos;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
48
59
|
|
|
49
60
|
// if not the last node, move to the end of the next node
|
|
50
61
|
return nodeAfter ? nodeAfterPos + nodeAfter.nodeSize : -1;
|
|
@@ -79,9 +79,18 @@ var newGetSelection = function newGetSelection(tr, start) {
|
|
|
79
79
|
var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
80
80
|
|
|
81
81
|
// this is a fix for empty paragraph selection - put first to avoid any extra work
|
|
82
|
-
if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
|
|
82
|
+
if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
83
83
|
return false;
|
|
84
84
|
}
|
|
85
|
+
var isParagraphHeadingEmpty = ['paragraph', 'heading'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0;
|
|
86
|
+
var isBlockQuoteEmpty = nodeName === 'blockquote' && (node === null || node === void 0 ? void 0 : node.textContent) === '';
|
|
87
|
+
var isListEmpty = ['orderedList', 'bulletList', 'taskList'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.textContent) === '';
|
|
88
|
+
|
|
89
|
+
// if block menu and empty line format menu are enabled,
|
|
90
|
+
// we want to set the selection to avoid the selection goes to the top of the document
|
|
91
|
+
if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
92
|
+
return _state.TextSelection.create(tr.doc, start + 1, start + 1);
|
|
93
|
+
}
|
|
85
94
|
var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
86
95
|
var isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
87
96
|
if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension || isBlockQuoteWithMediaOrExtension ||
|
|
@@ -275,7 +275,7 @@ var getNodeMargins = function getNodeMargins(node) {
|
|
|
275
275
|
return _consts2.nodeMargins[nodeTypeName] || _consts2.nodeMargins['default'];
|
|
276
276
|
};
|
|
277
277
|
var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
278
|
-
var _api$core2, _api$blockControls4, _api$analytics2, _api$
|
|
278
|
+
var _api$core2, _api$blockControls4, _api$analytics2, _api$core5, _api$userIntent2;
|
|
279
279
|
var view = _ref.view,
|
|
280
280
|
api = _ref.api,
|
|
281
281
|
formatMessage = _ref.formatMessage,
|
|
@@ -437,6 +437,35 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
437
437
|
});
|
|
438
438
|
return tr;
|
|
439
439
|
});
|
|
440
|
+
} else if ((e.key === 'Enter' || e.key === ' ') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true)) {
|
|
441
|
+
var _api$core4;
|
|
442
|
+
if (document.activeElement !== buttonRef.current) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
e.preventDefault();
|
|
446
|
+
e.stopPropagation();
|
|
447
|
+
setDragHandleSelected(!dragHandleSelected);
|
|
448
|
+
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref4) {
|
|
449
|
+
var _api$blockControls5, _api$userIntent;
|
|
450
|
+
var tr = _ref4.tr;
|
|
451
|
+
var startPos = getPos();
|
|
452
|
+
if (startPos === undefined) {
|
|
453
|
+
return tr;
|
|
454
|
+
}
|
|
455
|
+
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType);
|
|
456
|
+
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.toggleBlockMenu({
|
|
457
|
+
anchorName: anchorName
|
|
458
|
+
})({
|
|
459
|
+
tr: tr
|
|
460
|
+
});
|
|
461
|
+
api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen')({
|
|
462
|
+
tr: tr
|
|
463
|
+
});
|
|
464
|
+
api === null || api === void 0 || api.blockControls.commands.setSelectedViaDragHandle(true)({
|
|
465
|
+
tr: tr
|
|
466
|
+
});
|
|
467
|
+
return tr;
|
|
468
|
+
});
|
|
440
469
|
} else if (![e.altKey, e.ctrlKey, e.shiftKey].some(function (pressed) {
|
|
441
470
|
return pressed;
|
|
442
471
|
})) {
|
|
@@ -444,7 +473,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
444
473
|
// return focus to editor to resume editing from caret position
|
|
445
474
|
view.focus();
|
|
446
475
|
}
|
|
447
|
-
}, [getPos, api === null || api === void 0 || (_api$
|
|
476
|
+
}, [getPos, api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions, api === null || api === void 0 ? void 0 : api.blockControls.commands, api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands, isMultiSelect, view, anchorName, dragHandleSelected, nodeType]);
|
|
448
477
|
(0, _react.useEffect)(function () {
|
|
449
478
|
var element = buttonRef.current;
|
|
450
479
|
if (!element) {
|
|
@@ -458,13 +487,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
458
487
|
start: start
|
|
459
488
|
};
|
|
460
489
|
},
|
|
461
|
-
onGenerateDragPreview: function onGenerateDragPreview(
|
|
490
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref5) {
|
|
462
491
|
var _api$blockControls$sh2;
|
|
463
|
-
var nativeSetDragImage =
|
|
492
|
+
var nativeSetDragImage = _ref5.nativeSetDragImage;
|
|
464
493
|
if (isMultiSelect) {
|
|
465
|
-
var _api$
|
|
466
|
-
api === null || api === void 0 || (_api$
|
|
467
|
-
var tr =
|
|
494
|
+
var _api$core6;
|
|
495
|
+
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref6) {
|
|
496
|
+
var tr = _ref6.tr;
|
|
468
497
|
var handlePos = getPos();
|
|
469
498
|
if (typeof handlePos !== 'number') {
|
|
470
499
|
return tr;
|
|
@@ -472,8 +501,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
472
501
|
var oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
|
|
473
502
|
var newHandlePosCheck = (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos);
|
|
474
503
|
if (!tr.selection.empty && ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
|
|
475
|
-
var _api$
|
|
476
|
-
api === null || api === void 0 || (_api$
|
|
504
|
+
var _api$blockControls6;
|
|
505
|
+
api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setMultiSelectPositions()({
|
|
477
506
|
tr: tr
|
|
478
507
|
});
|
|
479
508
|
} else if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_select_node_on_drag')) {
|
|
@@ -543,8 +572,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
543
572
|
};
|
|
544
573
|
}
|
|
545
574
|
},
|
|
546
|
-
render: function render(
|
|
547
|
-
var container =
|
|
575
|
+
render: function render(_ref7) {
|
|
576
|
+
var container = _ref7.container;
|
|
548
577
|
var dom = view.dom.querySelector("[".concat((0, _domAttrName.getAnchorAttrName)(), "=\"").concat(anchorName, "\"]"));
|
|
549
578
|
if (!dom) {
|
|
550
579
|
return;
|
|
@@ -576,13 +605,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
576
605
|
});
|
|
577
606
|
},
|
|
578
607
|
onDragStart: function onDragStart() {
|
|
579
|
-
var _api$
|
|
608
|
+
var _api$core7;
|
|
580
609
|
if (start === undefined) {
|
|
581
610
|
return;
|
|
582
611
|
}
|
|
583
|
-
api === null || api === void 0 || (_api$
|
|
584
|
-
var _api$blockControls$sh3, _api$
|
|
585
|
-
var tr =
|
|
612
|
+
api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref8) {
|
|
613
|
+
var _api$blockControls$sh3, _api$blockControls7, _api$analytics3;
|
|
614
|
+
var tr = _ref8.tr;
|
|
586
615
|
var nodeTypes, hasSelectedMultipleNodes;
|
|
587
616
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
588
617
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
@@ -595,7 +624,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
595
624
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
596
625
|
hasSelectedMultipleNodes = false;
|
|
597
626
|
}
|
|
598
|
-
api === null || api === void 0 || (_api$
|
|
627
|
+
api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 || _api$blockControls7.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
599
628
|
tr: tr
|
|
600
629
|
});
|
|
601
630
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -967,15 +996,15 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
967
996
|
var render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
968
997
|
return (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? stickyRender : render;
|
|
969
998
|
};
|
|
970
|
-
var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragHandleWithVisibility(
|
|
971
|
-
var view =
|
|
972
|
-
api =
|
|
973
|
-
formatMessage =
|
|
974
|
-
getPos =
|
|
975
|
-
anchorName =
|
|
976
|
-
nodeType =
|
|
977
|
-
handleOptions =
|
|
978
|
-
anchorRectCache =
|
|
999
|
+
var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragHandleWithVisibility(_ref9) {
|
|
1000
|
+
var view = _ref9.view,
|
|
1001
|
+
api = _ref9.api,
|
|
1002
|
+
formatMessage = _ref9.formatMessage,
|
|
1003
|
+
getPos = _ref9.getPos,
|
|
1004
|
+
anchorName = _ref9.anchorName,
|
|
1005
|
+
nodeType = _ref9.nodeType,
|
|
1006
|
+
handleOptions = _ref9.handleOptions,
|
|
1007
|
+
anchorRectCache = _ref9.anchorRectCache;
|
|
979
1008
|
return (0, _react2.jsx)(_visibilityContainer.VisibilityContainer, {
|
|
980
1009
|
api: api
|
|
981
1010
|
}, (0, _react2.jsx)(DragHandle, {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
3
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
3
5
|
import { moveNode } from './move-node';
|
|
4
6
|
import { getCurrentNodePosFromDragHandleSelection, getPosWhenMoveNodeDown, getPosWhenMoveNodeUp, getShouldMoveNode } from './utils/move-node-utils';
|
|
5
7
|
export const moveNodeWithBlockMenu = (api, direction) => {
|
|
@@ -31,6 +33,13 @@ export const moveNodeWithBlockMenu = (api, direction) => {
|
|
|
31
33
|
moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.BLOCK_MENU)({
|
|
32
34
|
tr
|
|
33
35
|
});
|
|
36
|
+
if (tr.selection.empty && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
37
|
+
const nodeAtCurrentPos = tr.doc.nodeAt(currentNodePos);
|
|
38
|
+
const nodeAfter = tr.doc.nodeAt(moveToPos);
|
|
39
|
+
const isConsecutiveEmptyLineMove = (nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0;
|
|
40
|
+
const cursorPos = direction === DIRECTION.UP || direction === DIRECTION.DOWN && isConsecutiveEmptyLineMove ? moveToPos : moveToPos - 1;
|
|
41
|
+
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
42
|
+
}
|
|
34
43
|
tr.scrollIntoView();
|
|
35
44
|
}
|
|
36
45
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
3
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
3
4
|
import { getNestedNodePosition } from '../../pm-plugins/utils/getNestedNodePosition';
|
|
4
5
|
export const getCurrentNodePosFromDragHandleSelection = ({
|
|
5
6
|
selection,
|
|
@@ -7,6 +8,9 @@ export const getCurrentNodePosFromDragHandleSelection = ({
|
|
|
7
8
|
resolve
|
|
8
9
|
}) => {
|
|
9
10
|
let currentNodePos = -1;
|
|
11
|
+
if (selection.empty && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
12
|
+
currentNodePos = selection.$from.pos;
|
|
13
|
+
}
|
|
10
14
|
if (isTableSelected(selection)) {
|
|
11
15
|
var _findTable$pos, _findTable;
|
|
12
16
|
// We only move table node if it's fully selected
|
|
@@ -41,6 +45,13 @@ export const getPosWhenMoveNodeDown = ({
|
|
|
41
45
|
return -1;
|
|
42
46
|
}
|
|
43
47
|
const nodeAfter = tr.doc.nodeAt(nodeAfterPos);
|
|
48
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
49
|
+
const nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
|
|
50
|
+
// if move empty line down to another empty line, move to the position of the next empty line
|
|
51
|
+
if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
|
|
52
|
+
return nodeAfterPos;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
44
55
|
|
|
45
56
|
// if not the last node, move to the end of the next node
|
|
46
57
|
return nodeAfter ? nodeAfterPos + nodeAfter.nodeSize : -1;
|
|
@@ -74,9 +74,18 @@ const newGetSelection = (tr, start) => {
|
|
|
74
74
|
const nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
75
75
|
|
|
76
76
|
// this is a fix for empty paragraph selection - put first to avoid any extra work
|
|
77
|
-
if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
|
|
77
|
+
if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
80
|
+
const isParagraphHeadingEmpty = ['paragraph', 'heading'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0;
|
|
81
|
+
const isBlockQuoteEmpty = nodeName === 'blockquote' && (node === null || node === void 0 ? void 0 : node.textContent) === '';
|
|
82
|
+
const isListEmpty = ['orderedList', 'bulletList', 'taskList'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.textContent) === '';
|
|
83
|
+
|
|
84
|
+
// if block menu and empty line format menu are enabled,
|
|
85
|
+
// we want to set the selection to avoid the selection goes to the top of the document
|
|
86
|
+
if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
87
|
+
return TextSelection.create(tr.doc, start + 1, start + 1);
|
|
88
|
+
}
|
|
80
89
|
const isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
81
90
|
const isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
82
91
|
if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension || isBlockQuoteWithMediaOrExtension ||
|
|
@@ -280,7 +280,7 @@ export const DragHandle = ({
|
|
|
280
280
|
isTopLevelNode = true,
|
|
281
281
|
anchorRectCache
|
|
282
282
|
}) => {
|
|
283
|
-
var _api$core2, _api$blockControls4, _api$analytics2, _api$
|
|
283
|
+
var _api$core2, _api$blockControls4, _api$analytics2, _api$core5, _api$userIntent2;
|
|
284
284
|
const buttonRef = useRef(null);
|
|
285
285
|
const [dragHandleSelected, setDragHandleSelected] = useState(false);
|
|
286
286
|
const [dragHandleDisabled, setDragHandleDisabled] = useState(false);
|
|
@@ -418,12 +418,42 @@ export const DragHandle = ({
|
|
|
418
418
|
});
|
|
419
419
|
return tr;
|
|
420
420
|
});
|
|
421
|
+
} else if ((e.key === 'Enter' || e.key === ' ') && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true)) {
|
|
422
|
+
var _api$core4;
|
|
423
|
+
if (document.activeElement !== buttonRef.current) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
e.preventDefault();
|
|
427
|
+
e.stopPropagation();
|
|
428
|
+
setDragHandleSelected(!dragHandleSelected);
|
|
429
|
+
api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions.execute(({
|
|
430
|
+
tr
|
|
431
|
+
}) => {
|
|
432
|
+
var _api$blockControls5, _api$userIntent;
|
|
433
|
+
const startPos = getPos();
|
|
434
|
+
if (startPos === undefined) {
|
|
435
|
+
return tr;
|
|
436
|
+
}
|
|
437
|
+
tr = selectNode(tr, startPos, nodeType);
|
|
438
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.toggleBlockMenu({
|
|
439
|
+
anchorName
|
|
440
|
+
})({
|
|
441
|
+
tr
|
|
442
|
+
});
|
|
443
|
+
api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen')({
|
|
444
|
+
tr
|
|
445
|
+
});
|
|
446
|
+
api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(true)({
|
|
447
|
+
tr
|
|
448
|
+
});
|
|
449
|
+
return tr;
|
|
450
|
+
});
|
|
421
451
|
} else if (![e.altKey, e.ctrlKey, e.shiftKey].some(pressed => pressed)) {
|
|
422
452
|
// If not trying to press shortcut keys,
|
|
423
453
|
// return focus to editor to resume editing from caret position
|
|
424
454
|
view.focus();
|
|
425
455
|
}
|
|
426
|
-
}, [getPos, api === null || api === void 0 ? void 0 : (_api$
|
|
456
|
+
}, [getPos, api === null || api === void 0 ? void 0 : (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions, api === null || api === void 0 ? void 0 : api.blockControls.commands, api === null || api === void 0 ? void 0 : (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands, isMultiSelect, view, anchorName, dragHandleSelected, nodeType]);
|
|
427
457
|
useEffect(() => {
|
|
428
458
|
const element = buttonRef.current;
|
|
429
459
|
if (!element) {
|
|
@@ -440,8 +470,8 @@ export const DragHandle = ({
|
|
|
440
470
|
}) => {
|
|
441
471
|
var _api$blockControls$sh2;
|
|
442
472
|
if (isMultiSelect) {
|
|
443
|
-
var _api$
|
|
444
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
473
|
+
var _api$core6;
|
|
474
|
+
api === null || api === void 0 ? void 0 : (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions.execute(({
|
|
445
475
|
tr
|
|
446
476
|
}) => {
|
|
447
477
|
const handlePos = getPos();
|
|
@@ -451,8 +481,8 @@ export const DragHandle = ({
|
|
|
451
481
|
const oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
|
|
452
482
|
const newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
453
483
|
if (!tr.selection.empty && (fg('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
|
|
454
|
-
var _api$
|
|
455
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
484
|
+
var _api$blockControls6;
|
|
485
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 ? void 0 : _api$blockControls6.commands.setMultiSelectPositions()({
|
|
456
486
|
tr
|
|
457
487
|
});
|
|
458
488
|
} else if (fg('platform_editor_elements_dnd_select_node_on_drag')) {
|
|
@@ -560,14 +590,14 @@ export const DragHandle = ({
|
|
|
560
590
|
});
|
|
561
591
|
},
|
|
562
592
|
onDragStart() {
|
|
563
|
-
var _api$
|
|
593
|
+
var _api$core7;
|
|
564
594
|
if (start === undefined) {
|
|
565
595
|
return;
|
|
566
596
|
}
|
|
567
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
597
|
+
api === null || api === void 0 ? void 0 : (_api$core7 = api.core) === null || _api$core7 === void 0 ? void 0 : _api$core7.actions.execute(({
|
|
568
598
|
tr
|
|
569
599
|
}) => {
|
|
570
|
-
var _api$blockControls$sh3, _api$
|
|
600
|
+
var _api$blockControls$sh3, _api$blockControls7, _api$analytics3;
|
|
571
601
|
let nodeTypes, hasSelectedMultipleNodes;
|
|
572
602
|
const resolvedMovingNode = tr.doc.resolve(start);
|
|
573
603
|
const maybeNode = resolvedMovingNode.nodeAfter;
|
|
@@ -580,7 +610,7 @@ export const DragHandle = ({
|
|
|
580
610
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
581
611
|
hasSelectedMultipleNodes = false;
|
|
582
612
|
}
|
|
583
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
613
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 ? void 0 : _api$blockControls7.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
584
614
|
tr
|
|
585
615
|
});
|
|
586
616
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
3
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
3
5
|
import { moveNode } from './move-node';
|
|
4
6
|
import { getCurrentNodePosFromDragHandleSelection, getPosWhenMoveNodeDown, getPosWhenMoveNodeUp, getShouldMoveNode } from './utils/move-node-utils';
|
|
5
7
|
export var moveNodeWithBlockMenu = function moveNodeWithBlockMenu(api, direction) {
|
|
@@ -30,6 +32,13 @@ export var moveNodeWithBlockMenu = function moveNodeWithBlockMenu(api, direction
|
|
|
30
32
|
moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.BLOCK_MENU)({
|
|
31
33
|
tr: tr
|
|
32
34
|
});
|
|
35
|
+
if (tr.selection.empty && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
36
|
+
var nodeAtCurrentPos = tr.doc.nodeAt(currentNodePos);
|
|
37
|
+
var nodeAfter = tr.doc.nodeAt(moveToPos);
|
|
38
|
+
var isConsecutiveEmptyLineMove = (nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0;
|
|
39
|
+
var cursorPos = direction === DIRECTION.UP || direction === DIRECTION.DOWN && isConsecutiveEmptyLineMove ? moveToPos : moveToPos - 1;
|
|
40
|
+
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
41
|
+
}
|
|
33
42
|
tr.scrollIntoView();
|
|
34
43
|
}
|
|
35
44
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
3
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
3
4
|
import { getNestedNodePosition } from '../../pm-plugins/utils/getNestedNodePosition';
|
|
4
5
|
export var getCurrentNodePosFromDragHandleSelection = function getCurrentNodePosFromDragHandleSelection(_ref) {
|
|
5
6
|
var selection = _ref.selection,
|
|
6
7
|
schema = _ref.schema,
|
|
7
8
|
resolve = _ref.resolve;
|
|
8
9
|
var currentNodePos = -1;
|
|
10
|
+
if (selection.empty && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
11
|
+
currentNodePos = selection.$from.pos;
|
|
12
|
+
}
|
|
9
13
|
if (isTableSelected(selection)) {
|
|
10
14
|
var _findTable$pos, _findTable;
|
|
11
15
|
// We only move table node if it's fully selected
|
|
@@ -39,6 +43,13 @@ export var getPosWhenMoveNodeDown = function getPosWhenMoveNodeDown(_ref2) {
|
|
|
39
43
|
return -1;
|
|
40
44
|
}
|
|
41
45
|
var nodeAfter = tr.doc.nodeAt(nodeAfterPos);
|
|
46
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
47
|
+
var nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
|
|
48
|
+
// if move empty line down to another empty line, move to the position of the next empty line
|
|
49
|
+
if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
|
|
50
|
+
return nodeAfterPos;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
42
53
|
|
|
43
54
|
// if not the last node, move to the end of the next node
|
|
44
55
|
return nodeAfter ? nodeAfterPos + nodeAfter.nodeSize : -1;
|
|
@@ -73,9 +73,18 @@ var newGetSelection = function newGetSelection(tr, start) {
|
|
|
73
73
|
var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
74
74
|
|
|
75
75
|
// this is a fix for empty paragraph selection - put first to avoid any extra work
|
|
76
|
-
if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
|
|
76
|
+
if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
77
77
|
return false;
|
|
78
78
|
}
|
|
79
|
+
var isParagraphHeadingEmpty = ['paragraph', 'heading'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0;
|
|
80
|
+
var isBlockQuoteEmpty = nodeName === 'blockquote' && (node === null || node === void 0 ? void 0 : node.textContent) === '';
|
|
81
|
+
var isListEmpty = ['orderedList', 'bulletList', 'taskList'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.textContent) === '';
|
|
82
|
+
|
|
83
|
+
// if block menu and empty line format menu are enabled,
|
|
84
|
+
// we want to set the selection to avoid the selection goes to the top of the document
|
|
85
|
+
if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
|
|
86
|
+
return TextSelection.create(tr.doc, start + 1, start + 1);
|
|
87
|
+
}
|
|
79
88
|
var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
80
89
|
var isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
81
90
|
if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension || isBlockQuoteWithMediaOrExtension ||
|
|
@@ -272,7 +272,7 @@ var getNodeMargins = function getNodeMargins(node) {
|
|
|
272
272
|
return nodeMargins[nodeTypeName] || nodeMargins['default'];
|
|
273
273
|
};
|
|
274
274
|
export var DragHandle = function DragHandle(_ref) {
|
|
275
|
-
var _api$core2, _api$blockControls4, _api$analytics2, _api$
|
|
275
|
+
var _api$core2, _api$blockControls4, _api$analytics2, _api$core5, _api$userIntent2;
|
|
276
276
|
var view = _ref.view,
|
|
277
277
|
api = _ref.api,
|
|
278
278
|
formatMessage = _ref.formatMessage,
|
|
@@ -434,6 +434,35 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
434
434
|
});
|
|
435
435
|
return tr;
|
|
436
436
|
});
|
|
437
|
+
} else if ((e.key === 'Enter' || e.key === ' ') && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true)) {
|
|
438
|
+
var _api$core4;
|
|
439
|
+
if (document.activeElement !== buttonRef.current) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
e.preventDefault();
|
|
443
|
+
e.stopPropagation();
|
|
444
|
+
setDragHandleSelected(!dragHandleSelected);
|
|
445
|
+
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref4) {
|
|
446
|
+
var _api$blockControls5, _api$userIntent;
|
|
447
|
+
var tr = _ref4.tr;
|
|
448
|
+
var startPos = getPos();
|
|
449
|
+
if (startPos === undefined) {
|
|
450
|
+
return tr;
|
|
451
|
+
}
|
|
452
|
+
tr = selectNode(tr, startPos, nodeType);
|
|
453
|
+
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.toggleBlockMenu({
|
|
454
|
+
anchorName: anchorName
|
|
455
|
+
})({
|
|
456
|
+
tr: tr
|
|
457
|
+
});
|
|
458
|
+
api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen')({
|
|
459
|
+
tr: tr
|
|
460
|
+
});
|
|
461
|
+
api === null || api === void 0 || api.blockControls.commands.setSelectedViaDragHandle(true)({
|
|
462
|
+
tr: tr
|
|
463
|
+
});
|
|
464
|
+
return tr;
|
|
465
|
+
});
|
|
437
466
|
} else if (![e.altKey, e.ctrlKey, e.shiftKey].some(function (pressed) {
|
|
438
467
|
return pressed;
|
|
439
468
|
})) {
|
|
@@ -441,7 +470,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
441
470
|
// return focus to editor to resume editing from caret position
|
|
442
471
|
view.focus();
|
|
443
472
|
}
|
|
444
|
-
}, [getPos, api === null || api === void 0 || (_api$
|
|
473
|
+
}, [getPos, api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions, api === null || api === void 0 ? void 0 : api.blockControls.commands, api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands, isMultiSelect, view, anchorName, dragHandleSelected, nodeType]);
|
|
445
474
|
useEffect(function () {
|
|
446
475
|
var element = buttonRef.current;
|
|
447
476
|
if (!element) {
|
|
@@ -455,13 +484,13 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
455
484
|
start: start
|
|
456
485
|
};
|
|
457
486
|
},
|
|
458
|
-
onGenerateDragPreview: function onGenerateDragPreview(
|
|
487
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref5) {
|
|
459
488
|
var _api$blockControls$sh2;
|
|
460
|
-
var nativeSetDragImage =
|
|
489
|
+
var nativeSetDragImage = _ref5.nativeSetDragImage;
|
|
461
490
|
if (isMultiSelect) {
|
|
462
|
-
var _api$
|
|
463
|
-
api === null || api === void 0 || (_api$
|
|
464
|
-
var tr =
|
|
491
|
+
var _api$core6;
|
|
492
|
+
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref6) {
|
|
493
|
+
var tr = _ref6.tr;
|
|
465
494
|
var handlePos = getPos();
|
|
466
495
|
if (typeof handlePos !== 'number') {
|
|
467
496
|
return tr;
|
|
@@ -469,8 +498,8 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
469
498
|
var oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
|
|
470
499
|
var newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
471
500
|
if (!tr.selection.empty && (fg('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
|
|
472
|
-
var _api$
|
|
473
|
-
api === null || api === void 0 || (_api$
|
|
501
|
+
var _api$blockControls6;
|
|
502
|
+
api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setMultiSelectPositions()({
|
|
474
503
|
tr: tr
|
|
475
504
|
});
|
|
476
505
|
} else if (fg('platform_editor_elements_dnd_select_node_on_drag')) {
|
|
@@ -540,8 +569,8 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
540
569
|
};
|
|
541
570
|
}
|
|
542
571
|
},
|
|
543
|
-
render: function render(
|
|
544
|
-
var container =
|
|
572
|
+
render: function render(_ref7) {
|
|
573
|
+
var container = _ref7.container;
|
|
545
574
|
var dom = view.dom.querySelector("[".concat(getAnchorAttrName(), "=\"").concat(anchorName, "\"]"));
|
|
546
575
|
if (!dom) {
|
|
547
576
|
return;
|
|
@@ -573,13 +602,13 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
573
602
|
});
|
|
574
603
|
},
|
|
575
604
|
onDragStart: function onDragStart() {
|
|
576
|
-
var _api$
|
|
605
|
+
var _api$core7;
|
|
577
606
|
if (start === undefined) {
|
|
578
607
|
return;
|
|
579
608
|
}
|
|
580
|
-
api === null || api === void 0 || (_api$
|
|
581
|
-
var _api$blockControls$sh3, _api$
|
|
582
|
-
var tr =
|
|
609
|
+
api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref8) {
|
|
610
|
+
var _api$blockControls$sh3, _api$blockControls7, _api$analytics3;
|
|
611
|
+
var tr = _ref8.tr;
|
|
583
612
|
var nodeTypes, hasSelectedMultipleNodes;
|
|
584
613
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
585
614
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
@@ -592,7 +621,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
592
621
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
593
622
|
hasSelectedMultipleNodes = false;
|
|
594
623
|
}
|
|
595
|
-
api === null || api === void 0 || (_api$
|
|
624
|
+
api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 || _api$blockControls7.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
596
625
|
tr: tr
|
|
597
626
|
});
|
|
598
627
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -964,15 +993,15 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
964
993
|
var render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
965
994
|
return editorExperiment('platform_editor_controls', 'variant1') ? stickyRender : render;
|
|
966
995
|
};
|
|
967
|
-
export var DragHandleWithVisibility = function DragHandleWithVisibility(
|
|
968
|
-
var view =
|
|
969
|
-
api =
|
|
970
|
-
formatMessage =
|
|
971
|
-
getPos =
|
|
972
|
-
anchorName =
|
|
973
|
-
nodeType =
|
|
974
|
-
handleOptions =
|
|
975
|
-
anchorRectCache =
|
|
996
|
+
export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref9) {
|
|
997
|
+
var view = _ref9.view,
|
|
998
|
+
api = _ref9.api,
|
|
999
|
+
formatMessage = _ref9.formatMessage,
|
|
1000
|
+
getPos = _ref9.getPos,
|
|
1001
|
+
anchorName = _ref9.anchorName,
|
|
1002
|
+
nodeType = _ref9.nodeType,
|
|
1003
|
+
handleOptions = _ref9.handleOptions,
|
|
1004
|
+
anchorRectCache = _ref9.anchorRectCache;
|
|
976
1005
|
return jsx(VisibilityContainer, {
|
|
977
1006
|
api: api
|
|
978
1007
|
}, jsx(DragHandle, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.6",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
|
|
51
51
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
52
52
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
53
|
-
"@atlaskit/primitives": "^14.
|
|
53
|
+
"@atlaskit/primitives": "^14.15.0",
|
|
54
54
|
"@atlaskit/theme": "^21.0.0",
|
|
55
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
55
|
+
"@atlaskit/tmp-editor-statsig": "^12.28.0",
|
|
56
56
|
"@atlaskit/tokens": "^6.3.0",
|
|
57
57
|
"@atlaskit/tooltip": "^20.4.0",
|
|
58
58
|
"@babel/runtime": "^7.0.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"uuid": "^3.1.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@atlaskit/editor-common": "^109.
|
|
67
|
+
"@atlaskit/editor-common": "^109.11.0",
|
|
68
68
|
"react": "^18.2.0",
|
|
69
69
|
"react-dom": "^18.2.0",
|
|
70
70
|
"react-intl-next": "npm:react-intl@^5.18.1"
|