@atlaskit/editor-plugin-block-controls 3.2.0 → 3.3.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 +22 -0
- package/dist/cjs/blockControlsPlugin.js +10 -0
- package/dist/cjs/editor-commands/move-node.js +58 -29
- package/dist/cjs/editor-commands/move-to-layout.js +6 -0
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +2 -2
- package/dist/cjs/pm-plugins/main.js +24 -4
- package/dist/cjs/pm-plugins/utils/getSelection.js +38 -14
- package/dist/cjs/ui/drag-handle.js +1 -1
- package/dist/es2019/blockControlsPlugin.js +10 -0
- package/dist/es2019/editor-commands/move-node.js +59 -29
- package/dist/es2019/editor-commands/move-to-layout.js +6 -0
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +2 -2
- package/dist/es2019/pm-plugins/main.js +24 -4
- package/dist/es2019/pm-plugins/utils/getSelection.js +38 -14
- package/dist/es2019/ui/drag-handle.js +1 -1
- package/dist/esm/blockControlsPlugin.js +10 -0
- package/dist/esm/editor-commands/move-node.js +58 -29
- package/dist/esm/editor-commands/move-to-layout.js +6 -0
- package/dist/esm/pm-plugins/decorations-drag-handle.js +2 -2
- package/dist/esm/pm-plugins/main.js +24 -4
- package/dist/esm/pm-plugins/utils/getSelection.js +38 -14
- package/dist/esm/ui/drag-handle.js +1 -1
- package/dist/types/blockControlsPluginType.d.ts +3 -1
- package/dist/types/ui/block-menu.d.ts +1 -1
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +3 -1
- package/dist/types-ts4.5/ui/block-menu.d.ts +1 -1
- package/package.json +6 -2
|
@@ -313,6 +313,12 @@ export const moveToLayout = api => (from, to, options) => ({
|
|
|
313
313
|
if (!fromContentWithoutBreakout) {
|
|
314
314
|
return tr;
|
|
315
315
|
}
|
|
316
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
317
|
+
var _api$metrics;
|
|
318
|
+
api === null || api === void 0 ? void 0 : (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.setContentMoved()({
|
|
319
|
+
tr
|
|
320
|
+
});
|
|
321
|
+
}
|
|
316
322
|
const isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
317
323
|
if (toNode.type === layoutSection) {
|
|
318
324
|
const toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize - 1 : to + 1;
|
|
@@ -66,7 +66,7 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
|
|
|
66
66
|
// temporarily re-instating ReactDOM.render to fix drag handle focus issue, fix to
|
|
67
67
|
// follow via ED-26546
|
|
68
68
|
|
|
69
|
-
//
|
|
69
|
+
// previous under platform_editor_react18_plugin_portalprovider
|
|
70
70
|
// nodeViewPortalProviderAPI.render(
|
|
71
71
|
// () =>
|
|
72
72
|
// createElement(DragHandle, {
|
|
@@ -82,7 +82,7 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
|
|
|
82
82
|
// element,
|
|
83
83
|
// key,
|
|
84
84
|
// );
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
|
|
87
87
|
view,
|
|
88
88
|
api,
|
|
@@ -133,6 +133,12 @@ const destroyFn = (api, editorView) => {
|
|
|
133
133
|
}
|
|
134
134
|
})(tr);
|
|
135
135
|
}
|
|
136
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
137
|
+
var _api$metrics;
|
|
138
|
+
api === null || api === void 0 ? void 0 : (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.startActiveSessionTimer()({
|
|
139
|
+
tr
|
|
140
|
+
});
|
|
141
|
+
}
|
|
136
142
|
return tr.setMeta(key, {
|
|
137
143
|
...tr.getMeta(key),
|
|
138
144
|
isDragging: false,
|
|
@@ -570,7 +576,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
570
576
|
},
|
|
571
577
|
handleDOMEvents: {
|
|
572
578
|
drop(view, event) {
|
|
573
|
-
var _pluginState, _pluginState2, _pluginState3, _event$target;
|
|
579
|
+
var _pluginState, _pluginState2, _pluginState3, _event$target, _event$target$closest;
|
|
574
580
|
// Prevent native DnD from triggering if we are in drag
|
|
575
581
|
const {
|
|
576
582
|
dispatch,
|
|
@@ -581,6 +587,12 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
581
587
|
let pluginState = key.getState(state);
|
|
582
588
|
const dndDragCancelled = (_pluginState = pluginState) === null || _pluginState === void 0 ? void 0 : _pluginState.lastDragCancelled;
|
|
583
589
|
if ((_pluginState2 = pluginState) !== null && _pluginState2 !== void 0 && _pluginState2.isPMDragging || dndDragCancelled && isMultiSelectEnabled) {
|
|
590
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
591
|
+
var _api$metrics2;
|
|
592
|
+
api === null || api === void 0 ? void 0 : (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 ? void 0 : _api$metrics2.commands.startActiveSessionTimer()({
|
|
593
|
+
tr
|
|
594
|
+
});
|
|
595
|
+
}
|
|
584
596
|
dispatch(tr.setMeta(key, {
|
|
585
597
|
...tr.getMeta(key),
|
|
586
598
|
isPMDragging: false,
|
|
@@ -599,7 +611,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
599
611
|
event.preventDefault();
|
|
600
612
|
return false;
|
|
601
613
|
}
|
|
602
|
-
const nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('[data-drag-handler-anchor-name]');
|
|
614
|
+
const nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : (_event$target$closest = _event$target.closest) === null || _event$target$closest === void 0 ? void 0 : _event$target$closest.call(_event$target, '[data-drag-handler-anchor-name]');
|
|
603
615
|
if (!nodeElement) {
|
|
604
616
|
return false;
|
|
605
617
|
}
|
|
@@ -648,10 +660,18 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
648
660
|
dispatch
|
|
649
661
|
} = view;
|
|
650
662
|
if ((_key$getState3 = key.getState(state)) !== null && _key$getState3 !== void 0 && _key$getState3.isPMDragging) {
|
|
651
|
-
|
|
663
|
+
const tr = state.tr;
|
|
664
|
+
tr.setMeta(key, {
|
|
652
665
|
...state.tr.getMeta(key),
|
|
653
666
|
isPMDragging: false
|
|
654
|
-
})
|
|
667
|
+
});
|
|
668
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
669
|
+
var _api$metrics3;
|
|
670
|
+
api === null || api === void 0 ? void 0 : (_api$metrics3 = api.metrics) === null || _api$metrics3 === void 0 ? void 0 : _api$metrics3.commands.startActiveSessionTimer()({
|
|
671
|
+
tr
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
dispatch(tr);
|
|
655
675
|
}
|
|
656
676
|
},
|
|
657
677
|
mouseover: (view, event) => {
|
|
@@ -2,6 +2,7 @@ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
export const getInlineNodePos = (tr, start, nodeSize) => {
|
|
6
7
|
const $startPos = tr.doc.resolve(start);
|
|
7
8
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -53,6 +54,8 @@ export const getSelection = (tr, start) => {
|
|
|
53
54
|
// we need a quick way to make all child media nodes appear as selected without the need for a custom selection
|
|
54
55
|
nodeName === 'mediaGroup') {
|
|
55
56
|
return new NodeSelection($startPos);
|
|
57
|
+
} else if (nodeName === 'taskList' && fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
58
|
+
return TextSelection.create(tr.doc, start, start + nodeSize);
|
|
56
59
|
} else {
|
|
57
60
|
const {
|
|
58
61
|
inlineNodePos,
|
|
@@ -100,21 +103,42 @@ export const isHandleCorrelatedToSelection = (state, selection, handlePos) => {
|
|
|
100
103
|
if (selection.empty) {
|
|
101
104
|
return false;
|
|
102
105
|
}
|
|
106
|
+
let nodeStart;
|
|
103
107
|
const $selectionFrom = selection.$from;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
108
|
+
if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
109
|
+
nodeStart = $selectionFrom.before($selectionFrom.sharedDepth(selection.to) + 1);
|
|
110
|
+
if (nodeStart === $selectionFrom.pos) {
|
|
111
|
+
nodeStart = $selectionFrom.depth ? $selectionFrom.before() : $selectionFrom.pos;
|
|
112
|
+
}
|
|
113
|
+
const $resolvedNodePos = state.doc.resolve(nodeStart);
|
|
114
|
+
if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
|
|
115
|
+
const parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
|
|
116
|
+
const tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
|
|
117
|
+
nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
|
|
118
|
+
} else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
|
|
119
|
+
nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
|
|
120
|
+
} else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
|
|
121
|
+
const listdepth = rootTaskListDepth($resolvedNodePos);
|
|
122
|
+
nodeStart = $resolvedNodePos.before(listdepth);
|
|
123
|
+
} else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
|
|
124
|
+
nodeStart = $resolvedNodePos.before();
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
const selectionFrom = $selectionFrom.pos;
|
|
128
|
+
nodeStart = $selectionFrom.depth ? $selectionFrom.before() : selectionFrom;
|
|
129
|
+
const $resolvedNodePos = state.doc.resolve(nodeStart);
|
|
130
|
+
if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
|
|
131
|
+
const parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
|
|
132
|
+
const tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
|
|
133
|
+
nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
|
|
134
|
+
} else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
|
|
135
|
+
nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
|
|
136
|
+
} else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
|
|
137
|
+
const listdepth = rootTaskListDepth($resolvedNodePos);
|
|
138
|
+
nodeStart = $resolvedNodePos.before(listdepth);
|
|
139
|
+
} else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
|
|
140
|
+
nodeStart = $resolvedNodePos.before();
|
|
141
|
+
}
|
|
118
142
|
}
|
|
119
143
|
return Boolean(handlePos < selection.$to.pos && handlePos >= nodeStart);
|
|
120
144
|
};
|
|
@@ -288,7 +288,7 @@ export const DragHandle = ({
|
|
|
288
288
|
return tr;
|
|
289
289
|
}
|
|
290
290
|
const oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
|
|
291
|
-
const newHandlePosCheck =
|
|
291
|
+
const newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
292
292
|
if (!tr.selection.empty && (fg('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
|
|
293
293
|
var _api$blockControls4;
|
|
294
294
|
api === null || api === void 0 ? void 0 : (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.setMultiSelectPositions()({
|
|
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
6
6
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
9
|
import { moveNode } from './editor-commands/move-node';
|
|
9
10
|
import { moveToLayout } from './editor-commands/move-to-layout';
|
|
@@ -82,6 +83,15 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
82
83
|
nodeType: nodeType
|
|
83
84
|
}
|
|
84
85
|
}));
|
|
86
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
87
|
+
var _api$metrics;
|
|
88
|
+
api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.handleIntentToStartEdit({
|
|
89
|
+
shouldStartTimer: false,
|
|
90
|
+
shouldPersistActiveSession: true
|
|
91
|
+
})({
|
|
92
|
+
tr: tr
|
|
93
|
+
});
|
|
94
|
+
}
|
|
85
95
|
return tr;
|
|
86
96
|
};
|
|
87
97
|
},
|
|
@@ -87,6 +87,7 @@ var getFocusedHandle = function getFocusedHandle(state) {
|
|
|
87
87
|
};
|
|
88
88
|
export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, formatMessage) {
|
|
89
89
|
return function (state) {
|
|
90
|
+
var _hoistedPos;
|
|
90
91
|
var isParentNodeOfTypeLayout;
|
|
91
92
|
var shouldEnableNestedDndA11y = editorExperiment('nested-dnd', true);
|
|
92
93
|
var selection = state.selection;
|
|
@@ -97,19 +98,26 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
97
98
|
var expandedSelection = expandSelectionBounds(selection.$anchor, selection.$head);
|
|
98
99
|
var expandedAnchor = expandedSelection.$anchor.pos;
|
|
99
100
|
var expandedHead = expandedSelection.$head.pos;
|
|
100
|
-
var
|
|
101
|
+
var hoistedPos;
|
|
102
|
+
var from = Math.min(expandedAnchor, expandedHead);
|
|
103
|
+
// Nodes like lists nest within themselves, we need to find the top most position
|
|
104
|
+
if (isParentNodeOfTypeLayout && fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
105
|
+
var LAYOUT_COL_DEPTH = 3;
|
|
106
|
+
hoistedPos = state.doc.resolve(from).before(LAYOUT_COL_DEPTH);
|
|
107
|
+
}
|
|
108
|
+
var currentNodePos = isMultiSelectEnabled && !getFocusedHandle(state) && !selection.empty ? (_hoistedPos = hoistedPos) !== null && _hoistedPos !== void 0 ? _hoistedPos : from : getCurrentNodePos(state);
|
|
101
109
|
if (currentNodePos > -1) {
|
|
102
110
|
var _state$doc$nodeAt;
|
|
103
|
-
var $
|
|
104
|
-
var nodeAfterPos = isMultiSelectEnabled && !getFocusedHandle(state) ? Math.max(expandedAnchor, expandedHead) : $
|
|
105
|
-
var isTopLevelNode = $
|
|
111
|
+
var $currentNodePos = state.doc.resolve(currentNodePos);
|
|
112
|
+
var nodeAfterPos = isMultiSelectEnabled && !getFocusedHandle(state) ? Math.max(expandedAnchor, expandedHead) : $currentNodePos.posAtIndex($currentNodePos.index() + 1);
|
|
113
|
+
var isTopLevelNode = $currentNodePos.depth === 0;
|
|
106
114
|
var moveToPos = -1;
|
|
107
|
-
var nodeIndex = $
|
|
115
|
+
var nodeIndex = $currentNodePos.index();
|
|
108
116
|
var isLayoutColumnSelected = selection instanceof NodeSelection && selection.node.type.name === 'layoutColumn';
|
|
109
117
|
if (direction === DIRECTION.LEFT && shouldEnableNestedDndA11y) {
|
|
110
118
|
if (isTopLevelNode && editorExperiment('advanced_layouts', true) && fg('platform_editor_advanced_layouts_accessibility')) {
|
|
111
119
|
var _api$core, _api$core2;
|
|
112
|
-
var nodeBefore = $
|
|
120
|
+
var nodeBefore = $currentNodePos.nodeBefore;
|
|
113
121
|
if (nodeBefore) {
|
|
114
122
|
moveToPos = currentNodePos - nodeBefore.nodeSize;
|
|
115
123
|
}
|
|
@@ -133,28 +141,28 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
133
141
|
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
|
|
134
142
|
return true;
|
|
135
143
|
} else if (isLayoutColumnSelected && fg('platform_editor_advanced_layouts_accessibility')) {
|
|
136
|
-
var _$
|
|
137
|
-
moveToPos = selection.from - (((_$
|
|
144
|
+
var _$currentNodePos$node, _api$core3, _api$blockControls2;
|
|
145
|
+
moveToPos = selection.from - (((_$currentNodePos$node = $currentNodePos.nodeBefore) === null || _$currentNodePos$node === void 0 ? void 0 : _$currentNodePos$node.nodeSize) || 1);
|
|
138
146
|
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveToLayout(currentNodePos, moveToPos, {
|
|
139
147
|
selectMovedNode: true
|
|
140
148
|
}));
|
|
141
149
|
return true;
|
|
142
150
|
} else {
|
|
143
|
-
if ($
|
|
151
|
+
if ($currentNodePos.depth < 2 || !isParentNodeOfTypeLayout) {
|
|
144
152
|
return false;
|
|
145
153
|
}
|
|
146
154
|
|
|
147
155
|
// get the previous layoutSection node
|
|
148
|
-
var index = $
|
|
149
|
-
var grandParent = $
|
|
156
|
+
var index = $currentNodePos.index($currentNodePos.depth - 1);
|
|
157
|
+
var grandParent = $currentNodePos.node($currentNodePos.depth - 1);
|
|
150
158
|
var previousNode = grandParent ? grandParent.maybeChild(index - 1) : null;
|
|
151
|
-
moveToPos = $
|
|
159
|
+
moveToPos = $currentNodePos.start() - ((previousNode === null || previousNode === void 0 ? void 0 : previousNode.nodeSize) || 1);
|
|
152
160
|
}
|
|
153
161
|
} else if (direction === DIRECTION.RIGHT && shouldEnableNestedDndA11y) {
|
|
154
162
|
if (isTopLevelNode && editorExperiment('advanced_layouts', true) && fg('platform_editor_advanced_layouts_accessibility')) {
|
|
155
163
|
var _api$core4, _api$core5;
|
|
156
|
-
var endOfDoc = $
|
|
157
|
-
moveToPos = $
|
|
164
|
+
var endOfDoc = $currentNodePos.end();
|
|
165
|
+
moveToPos = $currentNodePos.posAtIndex($currentNodePos.index() + 1);
|
|
158
166
|
if (moveToPos >= endOfDoc) {
|
|
159
167
|
return false;
|
|
160
168
|
}
|
|
@@ -175,8 +183,8 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
175
183
|
return true;
|
|
176
184
|
} else if (isLayoutColumnSelected && fg('platform_editor_advanced_layouts_accessibility')) {
|
|
177
185
|
var _api$core6, _api$blockControls4;
|
|
178
|
-
var _index = $
|
|
179
|
-
var parent = $
|
|
186
|
+
var _index = $currentNodePos.index($currentNodePos.depth);
|
|
187
|
+
var parent = $currentNodePos.node($currentNodePos.depth);
|
|
180
188
|
// get the next layoutColumn node
|
|
181
189
|
var nextNode = parent ? parent.maybeChild(_index + 1) : null;
|
|
182
190
|
|
|
@@ -186,29 +194,29 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
186
194
|
return true;
|
|
187
195
|
}
|
|
188
196
|
var moveToEnd = _index === parent.childCount - 2;
|
|
189
|
-
moveToPos = moveToEnd ? $
|
|
197
|
+
moveToPos = moveToEnd ? $currentNodePos.before() : selection.to + ((nextNode === null || nextNode === void 0 ? void 0 : nextNode.nodeSize) || 1);
|
|
190
198
|
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || (_api$blockControls4 = _api$blockControls4.commands) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.moveToLayout(currentNodePos, moveToPos, {
|
|
191
199
|
moveToEnd: moveToEnd,
|
|
192
200
|
selectMovedNode: true
|
|
193
201
|
}));
|
|
194
202
|
return true;
|
|
195
203
|
} else {
|
|
196
|
-
if ($
|
|
204
|
+
if ($currentNodePos.depth < 2 || !isParentNodeOfTypeLayout) {
|
|
197
205
|
return false;
|
|
198
206
|
}
|
|
199
|
-
moveToPos = $
|
|
207
|
+
moveToPos = $currentNodePos.after($currentNodePos.depth) + 1;
|
|
200
208
|
}
|
|
201
209
|
} else if (direction === DIRECTION.UP) {
|
|
202
210
|
if (isLayoutColumnSelected && fg('platform_editor_advanced_layouts_accessibility')) {
|
|
203
|
-
moveToPos = $
|
|
211
|
+
moveToPos = $currentNodePos.start() - 1;
|
|
204
212
|
} else {
|
|
205
|
-
var _nodeBefore = $
|
|
213
|
+
var _nodeBefore = $currentNodePos.depth > 1 && nodeIndex === 0 && shouldEnableNestedDndA11y ? $currentNodePos.node($currentNodePos.depth) : $currentNodePos.nodeBefore;
|
|
206
214
|
if (_nodeBefore) {
|
|
207
215
|
moveToPos = currentNodePos - _nodeBefore.nodeSize;
|
|
208
216
|
}
|
|
209
217
|
}
|
|
210
218
|
} else {
|
|
211
|
-
var _endOfDoc = $
|
|
219
|
+
var _endOfDoc = $currentNodePos.end();
|
|
212
220
|
if (nodeAfterPos > _endOfDoc) {
|
|
213
221
|
return false;
|
|
214
222
|
}
|
|
@@ -225,14 +233,23 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
225
233
|
var nodeType = (_state$doc$nodeAt = state.doc.nodeAt(currentNodePos)) === null || _state$doc$nodeAt === void 0 ? void 0 : _state$doc$nodeAt.type.name;
|
|
226
234
|
|
|
227
235
|
// only move the node if the destination is at the same depth, not support moving a nested node to a parent node
|
|
228
|
-
var shouldMoveNode = (shouldEnableNestedDndA11y ? moveToPos > -1 && $
|
|
236
|
+
var shouldMoveNode = (shouldEnableNestedDndA11y ? moveToPos > -1 && $currentNodePos.depth === state.doc.resolve(moveToPos).depth || nodeType === 'layoutColumn' : moveToPos > -1) || nodeType === 'layoutColumn' && fg('platform_editor_advanced_layouts_accessibility');
|
|
237
|
+
var _expandSelectionBound = expandSelectionBounds($currentNodePos, selection.$to),
|
|
238
|
+
$newAnchor = _expandSelectionBound.$anchor,
|
|
239
|
+
$newHead = _expandSelectionBound.$head;
|
|
229
240
|
if (shouldMoveNode) {
|
|
230
241
|
var _api$core7;
|
|
231
242
|
api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref4) {
|
|
232
243
|
var tr = _ref4.tr;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
244
|
+
if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
245
|
+
api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
|
|
246
|
+
tr: tr
|
|
247
|
+
});
|
|
248
|
+
} else {
|
|
249
|
+
api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
250
|
+
tr: tr
|
|
251
|
+
});
|
|
252
|
+
}
|
|
236
253
|
moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.SHORTCUT, formatMessage)({
|
|
237
254
|
tr: tr
|
|
238
255
|
});
|
|
@@ -254,9 +271,15 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
254
271
|
var _api$core9;
|
|
255
272
|
api === null || api === void 0 || (_api$core9 = api.core) === null || _api$core9 === void 0 || _api$core9.actions.execute(function (_ref6) {
|
|
256
273
|
var tr = _ref6.tr;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
274
|
+
if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
275
|
+
api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
|
|
276
|
+
tr: tr
|
|
277
|
+
});
|
|
278
|
+
} else {
|
|
279
|
+
api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
280
|
+
tr: tr
|
|
281
|
+
});
|
|
282
|
+
}
|
|
260
283
|
tr.scrollIntoView();
|
|
261
284
|
return tr;
|
|
262
285
|
});
|
|
@@ -287,6 +310,12 @@ export var moveNode = function moveNode(api) {
|
|
|
287
310
|
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true, {
|
|
288
311
|
exposure: true
|
|
289
312
|
});
|
|
313
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
314
|
+
var _api$metrics;
|
|
315
|
+
api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.setContentMoved()({
|
|
316
|
+
tr: tr
|
|
317
|
+
});
|
|
318
|
+
}
|
|
290
319
|
var slicePosition = getSelectedSlicePosition(start, tr, api);
|
|
291
320
|
if (isMultiSelect) {
|
|
292
321
|
sliceFrom = slicePosition.from;
|
|
@@ -313,6 +313,12 @@ export var moveToLayout = function moveToLayout(api) {
|
|
|
313
313
|
if (!fromContentWithoutBreakout) {
|
|
314
314
|
return tr;
|
|
315
315
|
}
|
|
316
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
317
|
+
var _api$metrics;
|
|
318
|
+
api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.setContentMoved()({
|
|
319
|
+
tr: tr
|
|
320
|
+
});
|
|
321
|
+
}
|
|
316
322
|
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
317
323
|
if (toNode.type === layoutSection) {
|
|
318
324
|
var toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize - 1 : to + 1;
|
|
@@ -68,7 +68,7 @@ export var dragHandleDecoration = function dragHandleDecoration(api, formatMessa
|
|
|
68
68
|
// temporarily re-instating ReactDOM.render to fix drag handle focus issue, fix to
|
|
69
69
|
// follow via ED-26546
|
|
70
70
|
|
|
71
|
-
//
|
|
71
|
+
// previous under platform_editor_react18_plugin_portalprovider
|
|
72
72
|
// nodeViewPortalProviderAPI.render(
|
|
73
73
|
// () =>
|
|
74
74
|
// createElement(DragHandle, {
|
|
@@ -84,7 +84,7 @@ export var dragHandleDecoration = function dragHandleDecoration(api, formatMessa
|
|
|
84
84
|
// element,
|
|
85
85
|
// key,
|
|
86
86
|
// );
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
|
|
89
89
|
view: view,
|
|
90
90
|
api: api,
|
|
@@ -131,6 +131,12 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
131
131
|
})
|
|
132
132
|
})(tr);
|
|
133
133
|
}
|
|
134
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
135
|
+
var _api$metrics;
|
|
136
|
+
api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.startActiveSessionTimer()({
|
|
137
|
+
tr: tr
|
|
138
|
+
});
|
|
139
|
+
}
|
|
134
140
|
return tr.setMeta(key, _objectSpread(_objectSpread({}, tr.getMeta(key)), {}, {
|
|
135
141
|
isDragging: false,
|
|
136
142
|
isPMDragging: false,
|
|
@@ -584,7 +590,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
584
590
|
},
|
|
585
591
|
handleDOMEvents: {
|
|
586
592
|
drop: function drop(view, event) {
|
|
587
|
-
var _pluginState, _pluginState2, _pluginState3, _event$target;
|
|
593
|
+
var _pluginState, _pluginState2, _pluginState3, _event$target, _event$target$closest;
|
|
588
594
|
// Prevent native DnD from triggering if we are in drag
|
|
589
595
|
var dispatch = view.dispatch,
|
|
590
596
|
dragging = view.dragging,
|
|
@@ -593,6 +599,12 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
593
599
|
var pluginState = key.getState(state);
|
|
594
600
|
var dndDragCancelled = (_pluginState = pluginState) === null || _pluginState === void 0 ? void 0 : _pluginState.lastDragCancelled;
|
|
595
601
|
if ((_pluginState2 = pluginState) !== null && _pluginState2 !== void 0 && _pluginState2.isPMDragging || dndDragCancelled && isMultiSelectEnabled) {
|
|
602
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
603
|
+
var _api$metrics2;
|
|
604
|
+
api === null || api === void 0 || (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 || _api$metrics2.commands.startActiveSessionTimer()({
|
|
605
|
+
tr: tr
|
|
606
|
+
});
|
|
607
|
+
}
|
|
596
608
|
dispatch(tr.setMeta(key, _objectSpread(_objectSpread({}, tr.getMeta(key)), {}, {
|
|
597
609
|
isPMDragging: false,
|
|
598
610
|
lastDragCancelled: false
|
|
@@ -610,7 +622,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
610
622
|
event.preventDefault();
|
|
611
623
|
return false;
|
|
612
624
|
}
|
|
613
|
-
var nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.
|
|
625
|
+
var nodeElement = (_event$target = event.target) === null || _event$target === void 0 || (_event$target$closest = _event$target.closest) === null || _event$target$closest === void 0 ? void 0 : _event$target$closest.call(_event$target, '[data-drag-handler-anchor-name]');
|
|
614
626
|
if (!nodeElement) {
|
|
615
627
|
return false;
|
|
616
628
|
}
|
|
@@ -656,9 +668,17 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
656
668
|
var state = view.state,
|
|
657
669
|
dispatch = view.dispatch;
|
|
658
670
|
if ((_key$getState3 = key.getState(state)) !== null && _key$getState3 !== void 0 && _key$getState3.isPMDragging) {
|
|
659
|
-
|
|
671
|
+
var tr = state.tr;
|
|
672
|
+
tr.setMeta(key, _objectSpread(_objectSpread({}, state.tr.getMeta(key)), {}, {
|
|
660
673
|
isPMDragging: false
|
|
661
|
-
}))
|
|
674
|
+
}));
|
|
675
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
676
|
+
var _api$metrics3;
|
|
677
|
+
api === null || api === void 0 || (_api$metrics3 = api.metrics) === null || _api$metrics3 === void 0 || _api$metrics3.commands.startActiveSessionTimer()({
|
|
678
|
+
tr: tr
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
dispatch(tr);
|
|
662
682
|
}
|
|
663
683
|
},
|
|
664
684
|
mouseover: function mouseover(view, event) {
|
|
@@ -2,6 +2,7 @@ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
export var getInlineNodePos = function getInlineNodePos(tr, start, nodeSize) {
|
|
6
7
|
var $startPos = tr.doc.resolve(start);
|
|
7
8
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -53,6 +54,8 @@ export var getSelection = function getSelection(tr, start) {
|
|
|
53
54
|
// we need a quick way to make all child media nodes appear as selected without the need for a custom selection
|
|
54
55
|
nodeName === 'mediaGroup') {
|
|
55
56
|
return new NodeSelection($startPos);
|
|
57
|
+
} else if (nodeName === 'taskList' && fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
58
|
+
return TextSelection.create(tr.doc, start, start + nodeSize);
|
|
56
59
|
} else {
|
|
57
60
|
var _getInlineNodePos = getInlineNodePos(tr, start, nodeSize),
|
|
58
61
|
inlineNodePos = _getInlineNodePos.inlineNodePos,
|
|
@@ -98,21 +101,42 @@ export var isHandleCorrelatedToSelection = function isHandleCorrelatedToSelectio
|
|
|
98
101
|
if (selection.empty) {
|
|
99
102
|
return false;
|
|
100
103
|
}
|
|
104
|
+
var nodeStart;
|
|
101
105
|
var $selectionFrom = selection.$from;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
var
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
107
|
+
nodeStart = $selectionFrom.before($selectionFrom.sharedDepth(selection.to) + 1);
|
|
108
|
+
if (nodeStart === $selectionFrom.pos) {
|
|
109
|
+
nodeStart = $selectionFrom.depth ? $selectionFrom.before() : $selectionFrom.pos;
|
|
110
|
+
}
|
|
111
|
+
var $resolvedNodePos = state.doc.resolve(nodeStart);
|
|
112
|
+
if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
|
|
113
|
+
var parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
|
|
114
|
+
var tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
|
|
115
|
+
nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
|
|
116
|
+
} else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
|
|
117
|
+
nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
|
|
118
|
+
} else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
|
|
119
|
+
var listdepth = rootTaskListDepth($resolvedNodePos);
|
|
120
|
+
nodeStart = $resolvedNodePos.before(listdepth);
|
|
121
|
+
} else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
|
|
122
|
+
nodeStart = $resolvedNodePos.before();
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
var selectionFrom = $selectionFrom.pos;
|
|
126
|
+
nodeStart = $selectionFrom.depth ? $selectionFrom.before() : selectionFrom;
|
|
127
|
+
var _$resolvedNodePos = state.doc.resolve(nodeStart);
|
|
128
|
+
if (['tableRow', 'tableCell', 'tableHeader'].includes(_$resolvedNodePos.node().type.name)) {
|
|
129
|
+
var _parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
|
|
130
|
+
var _tablePos = _parentNodeFindRes === null || _parentNodeFindRes === void 0 ? void 0 : _parentNodeFindRes.pos;
|
|
131
|
+
nodeStart = typeof _tablePos === 'undefined' ? nodeStart : _tablePos;
|
|
132
|
+
} else if (['listItem'].includes(_$resolvedNodePos.node().type.name)) {
|
|
133
|
+
nodeStart = _$resolvedNodePos.before(rootListDepth(_$resolvedNodePos));
|
|
134
|
+
} else if (['taskList'].includes(_$resolvedNodePos.node().type.name)) {
|
|
135
|
+
var _listdepth = rootTaskListDepth(_$resolvedNodePos);
|
|
136
|
+
nodeStart = _$resolvedNodePos.before(_listdepth);
|
|
137
|
+
} else if (['blockquote'].includes(_$resolvedNodePos.node().type.name)) {
|
|
138
|
+
nodeStart = _$resolvedNodePos.before();
|
|
139
|
+
}
|
|
116
140
|
}
|
|
117
141
|
return Boolean(handlePos < selection.$to.pos && handlePos >= nodeStart);
|
|
118
142
|
};
|
|
@@ -303,7 +303,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
303
303
|
return tr;
|
|
304
304
|
}
|
|
305
305
|
var oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
|
|
306
|
-
var newHandlePosCheck =
|
|
306
|
+
var newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
307
307
|
if (!tr.selection.empty && (fg('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
|
|
308
308
|
var _api$blockControls4;
|
|
309
309
|
api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.commands.setMultiSelectPositions()({
|
|
@@ -5,6 +5,7 @@ import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibi
|
|
|
5
5
|
import { type AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
6
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
7
7
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
|
+
import type { MetricsPlugin } from '@atlaskit/editor-plugin-metrics';
|
|
8
9
|
import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
|
|
9
10
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
10
11
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
@@ -74,7 +75,8 @@ export type BlockControlsPluginDependencies = [
|
|
|
74
75
|
* Clean up ticket ED-24824
|
|
75
76
|
*/
|
|
76
77
|
OptionalPlugin<QuickInsertPlugin>,
|
|
77
|
-
OptionalPlugin<SelectionPlugin
|
|
78
|
+
OptionalPlugin<SelectionPlugin>,
|
|
79
|
+
OptionalPlugin<MetricsPlugin>
|
|
78
80
|
];
|
|
79
81
|
export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
80
82
|
dependencies: BlockControlsPluginDependencies;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/
|
|
4
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
6
6
|
type BlockMenuProps = {
|
|
7
7
|
editorView: EditorView | undefined;
|
|
@@ -5,6 +5,7 @@ import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibi
|
|
|
5
5
|
import { type AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
6
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
7
7
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
|
+
import type { MetricsPlugin } from '@atlaskit/editor-plugin-metrics';
|
|
8
9
|
import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
|
|
9
10
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
10
11
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
@@ -74,7 +75,8 @@ export type BlockControlsPluginDependencies = [
|
|
|
74
75
|
* Clean up ticket ED-24824
|
|
75
76
|
*/
|
|
76
77
|
OptionalPlugin<QuickInsertPlugin>,
|
|
77
|
-
OptionalPlugin<SelectionPlugin
|
|
78
|
+
OptionalPlugin<SelectionPlugin>,
|
|
79
|
+
OptionalPlugin<MetricsPlugin>
|
|
78
80
|
];
|
|
79
81
|
export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
80
82
|
dependencies: BlockControlsPluginDependencies;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/
|
|
4
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
6
6
|
type BlockMenuProps = {
|
|
7
7
|
editorView: EditorView | undefined;
|