@atlaskit/editor-plugin-block-controls 2.26.3 → 2.27.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 +20 -0
- package/dist/cjs/blockControlsPlugin.js +10 -4
- package/dist/cjs/editor-commands/move-node.js +38 -8
- package/dist/cjs/pm-plugins/decorations-anchor.js +8 -1
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +33 -12
- package/dist/cjs/pm-plugins/main.js +3 -1
- package/dist/cjs/pm-plugins/utils/selection.js +8 -5
- package/dist/es2019/blockControlsPlugin.js +10 -5
- package/dist/es2019/editor-commands/move-node.js +37 -5
- package/dist/es2019/pm-plugins/decorations-anchor.js +8 -1
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +25 -2
- package/dist/es2019/pm-plugins/main.js +3 -1
- package/dist/es2019/pm-plugins/utils/selection.js +8 -6
- package/dist/esm/blockControlsPlugin.js +10 -4
- package/dist/esm/editor-commands/move-node.js +39 -9
- package/dist/esm/pm-plugins/decorations-anchor.js +8 -1
- package/dist/esm/pm-plugins/decorations-drag-handle.js +33 -12
- package/dist/esm/pm-plugins/main.js +3 -1
- package/dist/esm/pm-plugins/utils/selection.js +8 -5
- package/dist/types/blockControlsPluginType.d.ts +1 -1
- package/dist/types/pm-plugins/utils/selection.d.ts +2 -2
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/selection.d.ts +2 -2
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.27.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#114097](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/114097)
|
|
8
|
+
[`c767c26ecbc7c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c767c26ecbc7c) -
|
|
9
|
+
[ux] [ED-26269] Support moving multiple nodes with shortcuts
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 2.26.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#112698](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/112698)
|
|
20
|
+
[`121f8e8854a3a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/121f8e8854a3a) -
|
|
21
|
+
[ux] [ED-26476] Bugfix for drag handle appearing on nested tables when it shouldn't.
|
|
22
|
+
|
|
3
23
|
## 2.26.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -67,16 +67,22 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
67
67
|
return tr;
|
|
68
68
|
};
|
|
69
69
|
},
|
|
70
|
-
setMultiSelectPositions: function setMultiSelectPositions() {
|
|
70
|
+
setMultiSelectPositions: function setMultiSelectPositions(anchor, head) {
|
|
71
71
|
return function (_ref5) {
|
|
72
72
|
var _api$selection;
|
|
73
73
|
var tr = _ref5.tr;
|
|
74
74
|
var _tr$selection = tr.selection,
|
|
75
75
|
userAnchor = _tr$selection.anchor,
|
|
76
76
|
userHead = _tr$selection.head;
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
var expandedAnchor, expandedHead;
|
|
78
|
+
if (anchor !== undefined && head !== undefined) {
|
|
79
|
+
expandedAnchor = tr.doc.resolve(anchor);
|
|
80
|
+
expandedHead = tr.doc.resolve(head);
|
|
81
|
+
} else {
|
|
82
|
+
var expandedSelection = (0, _selection.expandSelectionBounds)(tr.selection.$anchor, tr.selection.$head);
|
|
83
|
+
expandedAnchor = expandedSelection.$anchor;
|
|
84
|
+
expandedHead = expandedSelection.$head;
|
|
85
|
+
}
|
|
80
86
|
api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || _api$selection.commands.setManualSelection(expandedAnchor.pos, expandedHead.pos)({
|
|
81
87
|
tr: tr
|
|
82
88
|
});
|
|
@@ -95,7 +95,18 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
95
95
|
if (shouldEnableNestedDndA11y) {
|
|
96
96
|
isParentNodeOfTypeLayout = !!(0, _utils2.findParentNodeOfType)([state.schema.nodes.layoutSection])(state.selection);
|
|
97
97
|
}
|
|
98
|
-
var
|
|
98
|
+
var isMultiSelectEnabled = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true);
|
|
99
|
+
var expandedAnchor, expandedHead;
|
|
100
|
+
var pluginState = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
|
|
101
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.multiSelectDnD) {
|
|
102
|
+
expandedAnchor = pluginState.multiSelectDnD.anchor;
|
|
103
|
+
expandedHead = pluginState.multiSelectDnD.head;
|
|
104
|
+
} else {
|
|
105
|
+
var expandedSelection = (0, _selection.expandSelectionBounds)(selection.$anchor, selection.$head);
|
|
106
|
+
expandedAnchor = expandedSelection.$anchor.pos;
|
|
107
|
+
expandedHead = expandedSelection.$head.pos;
|
|
108
|
+
}
|
|
109
|
+
var currentNodePos = isMultiSelectEnabled ? Math.min(expandedAnchor, expandedHead) : getCurrentNodePos(state);
|
|
99
110
|
if (currentNodePos > -1) {
|
|
100
111
|
var _state$doc$nodeAt;
|
|
101
112
|
var $pos = state.doc.resolve(currentNodePos);
|
|
@@ -206,7 +217,7 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
206
217
|
}
|
|
207
218
|
} else {
|
|
208
219
|
var _endOfDoc = $pos.end();
|
|
209
|
-
var nodeAfterPos = $pos.posAtIndex($pos.index() + 1);
|
|
220
|
+
var nodeAfterPos = isMultiSelectEnabled ? Math.max(expandedAnchor, expandedHead) : $pos.posAtIndex($pos.index() + 1);
|
|
210
221
|
if (nodeAfterPos > _endOfDoc) {
|
|
211
222
|
return false;
|
|
212
223
|
}
|
|
@@ -228,6 +239,9 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
228
239
|
var _api$core7;
|
|
229
240
|
api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref4) {
|
|
230
241
|
var tr = _ref4.tr;
|
|
242
|
+
api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
243
|
+
tr: tr
|
|
244
|
+
});
|
|
231
245
|
moveNode(api)(currentNodePos, moveToPos, _analytics.INPUT_METHOD.SHORTCUT, formatMessage)({
|
|
232
246
|
tr: tr
|
|
233
247
|
});
|
|
@@ -235,7 +249,7 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
235
249
|
return tr;
|
|
236
250
|
});
|
|
237
251
|
return true;
|
|
238
|
-
} else if (nodeType) {
|
|
252
|
+
} else if (nodeType && !isMultiSelectEnabled) {
|
|
239
253
|
var _api$core8;
|
|
240
254
|
// If the node is first/last one, only select the node
|
|
241
255
|
api === null || api === void 0 || (_api$core8 = api.core) === null || _api$core8 === void 0 || _api$core8.actions.execute(function (_ref5) {
|
|
@@ -245,6 +259,17 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
245
259
|
return tr;
|
|
246
260
|
});
|
|
247
261
|
return true;
|
|
262
|
+
} else if (isMultiSelectEnabled) {
|
|
263
|
+
var _api$core9;
|
|
264
|
+
api === null || api === void 0 || (_api$core9 = api.core) === null || _api$core9 === void 0 || _api$core9.actions.execute(function (_ref6) {
|
|
265
|
+
var tr = _ref6.tr;
|
|
266
|
+
api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
267
|
+
tr: tr
|
|
268
|
+
});
|
|
269
|
+
tr.scrollIntoView();
|
|
270
|
+
return tr;
|
|
271
|
+
});
|
|
272
|
+
return true;
|
|
248
273
|
}
|
|
249
274
|
}
|
|
250
275
|
return false;
|
|
@@ -254,8 +279,9 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
254
279
|
return function (start, to) {
|
|
255
280
|
var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _analytics.INPUT_METHOD.DRAG_AND_DROP;
|
|
256
281
|
var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
|
|
257
|
-
return function (
|
|
258
|
-
var
|
|
282
|
+
return function (_ref7) {
|
|
283
|
+
var _api$blockControls$co;
|
|
284
|
+
var tr = _ref7.tr;
|
|
259
285
|
if (!api) {
|
|
260
286
|
return tr;
|
|
261
287
|
}
|
|
@@ -327,10 +353,14 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
327
353
|
mappedTo = tr.mapping.map(to);
|
|
328
354
|
tr.insert(mappedTo, _nodeCopy); // insert the content at the new position
|
|
329
355
|
}
|
|
330
|
-
|
|
331
|
-
tr.
|
|
356
|
+
var sliceSize = sliceTo - sliceFrom;
|
|
357
|
+
tr = inputMethod === _analytics.INPUT_METHOD.DRAG_AND_DROP ? (0, _getSelection.setCursorPositionAtMovedNode)(tr, mappedTo) : isMultiSelect ? (_api$blockControls$co = api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(mappedTo, mappedTo + sliceSize)({
|
|
358
|
+
tr: tr
|
|
359
|
+
})) !== null && _api$blockControls$co !== void 0 ? _api$blockControls$co : tr : (0, _getSelection.selectNode)(tr, mappedTo, handleNode.type.name);
|
|
360
|
+
var currMeta = tr.getMeta(_main.key);
|
|
361
|
+
tr.setMeta(_main.key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
332
362
|
nodeMoved: true
|
|
333
|
-
});
|
|
363
|
+
}));
|
|
334
364
|
api === null || api === void 0 || api.core.actions.focus();
|
|
335
365
|
var $mappedTo = tr.doc.resolve(mappedTo);
|
|
336
366
|
var expandAncestor = (0, _utils2.findParentNodeOfTypeClosestToPos)($to, [expand, nestedExpand]);
|
|
@@ -28,9 +28,16 @@ var shouldDescendIntoNode = exports.shouldDescendIntoNode = function shouldDesce
|
|
|
28
28
|
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
29
29
|
};
|
|
30
30
|
var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, parent) {
|
|
31
|
-
var _node$attrs, _node$attrs2;
|
|
31
|
+
var _nodeTypes$table, _node$attrs, _node$attrs2;
|
|
32
32
|
var isEmbedCard = node.type.name === 'embedCard';
|
|
33
33
|
var isMediaSingle = node.type.name === 'mediaSingle';
|
|
34
|
+
var nodeTypes = node.type.schema.nodes;
|
|
35
|
+
var isTable = node.type.name === (nodeTypes === null || nodeTypes === void 0 || (_nodeTypes$table = nodeTypes.table) === null || _nodeTypes$table === void 0 ? void 0 : _nodeTypes$table.name);
|
|
36
|
+
var parentIsTable = parent && [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
|
|
37
|
+
var isNestedTable = isTable && parentIsTable;
|
|
38
|
+
if (isNestedTable && (0, _platformFeatureFlags.fg)('platform_editor_disable_drag_handle_nested_tables')) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
34
41
|
var isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && (0, _experiments.editorExperiment)('advanced_layouts', true);
|
|
35
42
|
if (isFirstTableRow) {
|
|
36
43
|
return false;
|
|
@@ -8,6 +8,7 @@ exports.findHandleDec = exports.emptyParagraphNodeDecorations = exports.dragHand
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _bindEventListener = require("bind-event-listener");
|
|
11
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
11
12
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
12
13
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
13
14
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
@@ -70,18 +71,38 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
70
71
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
71
72
|
// due to margins applied to other nodes eg. Headings
|
|
72
73
|
element.style.clear = 'unset';
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
|
|
75
|
+
// temporarily re-instating ReactDOM.render to fix drag handle focus issue, fix to
|
|
76
|
+
// follow via ED-26546
|
|
77
|
+
|
|
78
|
+
// if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
79
|
+
// nodeViewPortalProviderAPI.render(
|
|
80
|
+
// () =>
|
|
81
|
+
// createElement(DragHandle, {
|
|
82
|
+
// view,
|
|
83
|
+
// api,
|
|
84
|
+
// formatMessage,
|
|
85
|
+
// getPos,
|
|
86
|
+
// anchorName,
|
|
87
|
+
// nodeType,
|
|
88
|
+
// handleOptions,
|
|
89
|
+
// isTopLevelNode,
|
|
90
|
+
// }),
|
|
91
|
+
// element,
|
|
92
|
+
// key,
|
|
93
|
+
// );
|
|
94
|
+
// } else {
|
|
95
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dragHandle.DragHandle, {
|
|
96
|
+
view: view,
|
|
97
|
+
api: api,
|
|
98
|
+
formatMessage: formatMessage,
|
|
99
|
+
getPos: getPos,
|
|
100
|
+
anchorName: anchorName,
|
|
101
|
+
nodeType: nodeType,
|
|
102
|
+
handleOptions: handleOptions,
|
|
103
|
+
isTopLevelNode: isTopLevelNode
|
|
104
|
+
}), element);
|
|
105
|
+
//}
|
|
85
106
|
return element;
|
|
86
107
|
}, {
|
|
87
108
|
side: -1,
|
|
@@ -189,7 +189,9 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
189
189
|
var resizerMeta = tr.getMeta('is-resizer-resizing');
|
|
190
190
|
isResizerResizing = resizerMeta !== null && resizerMeta !== void 0 ? resizerMeta : isResizerResizing;
|
|
191
191
|
if (multiSelectDnD && flags.isMultiSelectEnabled) {
|
|
192
|
-
multiSelectDnD = (meta === null || meta === void 0 ? void 0 : meta.isDragging) === false
|
|
192
|
+
multiSelectDnD = (meta === null || meta === void 0 ? void 0 : meta.isDragging) === false ||
|
|
193
|
+
// For move node with shortcut, only reset when the selection changes
|
|
194
|
+
tr.selection.anchor !== multiSelectDnD.textAnchor || tr.selection.head !== multiSelectDnD.textHead ? undefined : multiSelectDnD;
|
|
193
195
|
}
|
|
194
196
|
var _getTrMetadata = (0, _transactions.getTrMetadata)(tr),
|
|
195
197
|
from = _getTrMetadata.from,
|
|
@@ -4,10 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getSelectedSlicePosition = exports.getMultiSelectionIfPosInside = void 0;
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
7
|
+
var _main = require("../main");
|
|
8
|
+
var getMultiSelectionIfPosInside = exports.getMultiSelectionIfPosInside = function getMultiSelectionIfPosInside(api, pos, tr) {
|
|
9
|
+
var _api$blockControls, _pluginState$multiSel, _tr$getMeta;
|
|
10
|
+
var pluginState = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState();
|
|
11
|
+
// With move nodes shortcut, we expand selection and move node within one transaction,
|
|
12
|
+
// Hence we also look for `multiSelectDnD` in transaction meta
|
|
13
|
+
var multiSelectDnD = (_pluginState$multiSel = pluginState === null || pluginState === void 0 ? void 0 : pluginState.multiSelectDnD) !== null && _pluginState$multiSel !== void 0 ? _pluginState$multiSel : tr === null || tr === void 0 || (_tr$getMeta = tr.getMeta(_main.key)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.multiSelectDnD;
|
|
11
14
|
if (multiSelectDnD && multiSelectDnD.anchor >= 0 && multiSelectDnD.head >= 0) {
|
|
12
15
|
var multiFrom = Math.min(multiSelectDnD.anchor, multiSelectDnD.head);
|
|
13
16
|
var multiTo = Math.max(multiSelectDnD.anchor, multiSelectDnD.head);
|
|
@@ -27,7 +30,7 @@ var getMultiSelectionIfPosInside = exports.getMultiSelectionIfPosInside = functi
|
|
|
27
30
|
*/
|
|
28
31
|
var getSelectedSlicePosition = exports.getSelectedSlicePosition = function getSelectedSlicePosition(handlePos, tr, api) {
|
|
29
32
|
var _activeNode$nodeSize;
|
|
30
|
-
var _getMultiSelectionIfP = getMultiSelectionIfPosInside(api, handlePos),
|
|
33
|
+
var _getMultiSelectionIfP = getMultiSelectionIfPosInside(api, handlePos, tr),
|
|
31
34
|
anchor = _getMultiSelectionIfP.anchor,
|
|
32
35
|
head = _getMultiSelectionIfP.head;
|
|
33
36
|
var inSelection = anchor !== undefined && head !== undefined;
|
|
@@ -56,7 +56,7 @@ export const blockControlsPlugin = ({
|
|
|
56
56
|
});
|
|
57
57
|
return tr;
|
|
58
58
|
},
|
|
59
|
-
setMultiSelectPositions: () => ({
|
|
59
|
+
setMultiSelectPositions: (anchor, head) => ({
|
|
60
60
|
tr
|
|
61
61
|
}) => {
|
|
62
62
|
var _api$selection;
|
|
@@ -64,10 +64,15 @@ export const blockControlsPlugin = ({
|
|
|
64
64
|
anchor: userAnchor,
|
|
65
65
|
head: userHead
|
|
66
66
|
} = tr.selection;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
let expandedAnchor, expandedHead;
|
|
68
|
+
if (anchor !== undefined && head !== undefined) {
|
|
69
|
+
expandedAnchor = tr.doc.resolve(anchor);
|
|
70
|
+
expandedHead = tr.doc.resolve(head);
|
|
71
|
+
} else {
|
|
72
|
+
const expandedSelection = expandSelectionBounds(tr.selection.$anchor, tr.selection.$head);
|
|
73
|
+
expandedAnchor = expandedSelection.$anchor;
|
|
74
|
+
expandedHead = expandedSelection.$head;
|
|
75
|
+
}
|
|
71
76
|
api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.commands.setManualSelection(expandedAnchor.pos, expandedHead.pos)({
|
|
72
77
|
tr
|
|
73
78
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { expandedState } from '@atlaskit/editor-common/expand';
|
|
3
3
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
4
|
-
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
4
|
+
import { GapCursorSelection, expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
5
5
|
import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
|
|
6
6
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -92,7 +92,18 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
92
92
|
if (shouldEnableNestedDndA11y) {
|
|
93
93
|
isParentNodeOfTypeLayout = !!findParentNodeOfType([state.schema.nodes.layoutSection])(state.selection);
|
|
94
94
|
}
|
|
95
|
-
const
|
|
95
|
+
const isMultiSelectEnabled = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
96
|
+
let expandedAnchor, expandedHead;
|
|
97
|
+
const pluginState = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
|
|
98
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.multiSelectDnD) {
|
|
99
|
+
expandedAnchor = pluginState.multiSelectDnD.anchor;
|
|
100
|
+
expandedHead = pluginState.multiSelectDnD.head;
|
|
101
|
+
} else {
|
|
102
|
+
const expandedSelection = expandSelectionBounds(selection.$anchor, selection.$head);
|
|
103
|
+
expandedAnchor = expandedSelection.$anchor.pos;
|
|
104
|
+
expandedHead = expandedSelection.$head.pos;
|
|
105
|
+
}
|
|
106
|
+
const currentNodePos = isMultiSelectEnabled ? Math.min(expandedAnchor, expandedHead) : getCurrentNodePos(state);
|
|
96
107
|
if (currentNodePos > -1) {
|
|
97
108
|
var _state$doc$nodeAt;
|
|
98
109
|
const $pos = state.doc.resolve(currentNodePos);
|
|
@@ -205,7 +216,7 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
205
216
|
}
|
|
206
217
|
} else {
|
|
207
218
|
const endOfDoc = $pos.end();
|
|
208
|
-
const nodeAfterPos = $pos.posAtIndex($pos.index() + 1);
|
|
219
|
+
const nodeAfterPos = isMultiSelectEnabled ? Math.max(expandedAnchor, expandedHead) : $pos.posAtIndex($pos.index() + 1);
|
|
209
220
|
if (nodeAfterPos > endOfDoc) {
|
|
210
221
|
return false;
|
|
211
222
|
}
|
|
@@ -228,6 +239,9 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
228
239
|
api === null || api === void 0 ? void 0 : (_api$core7 = api.core) === null || _api$core7 === void 0 ? void 0 : _api$core7.actions.execute(({
|
|
229
240
|
tr
|
|
230
241
|
}) => {
|
|
242
|
+
api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
243
|
+
tr
|
|
244
|
+
});
|
|
231
245
|
moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.SHORTCUT, formatMessage)({
|
|
232
246
|
tr
|
|
233
247
|
});
|
|
@@ -235,7 +249,7 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
235
249
|
return tr;
|
|
236
250
|
});
|
|
237
251
|
return true;
|
|
238
|
-
} else if (nodeType) {
|
|
252
|
+
} else if (nodeType && !isMultiSelectEnabled) {
|
|
239
253
|
var _api$core8;
|
|
240
254
|
// If the node is first/last one, only select the node
|
|
241
255
|
api === null || api === void 0 ? void 0 : (_api$core8 = api.core) === null || _api$core8 === void 0 ? void 0 : _api$core8.actions.execute(({
|
|
@@ -246,6 +260,18 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
246
260
|
return tr;
|
|
247
261
|
});
|
|
248
262
|
return true;
|
|
263
|
+
} else if (isMultiSelectEnabled) {
|
|
264
|
+
var _api$core9;
|
|
265
|
+
api === null || api === void 0 ? void 0 : (_api$core9 = api.core) === null || _api$core9 === void 0 ? void 0 : _api$core9.actions.execute(({
|
|
266
|
+
tr
|
|
267
|
+
}) => {
|
|
268
|
+
api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
269
|
+
tr
|
|
270
|
+
});
|
|
271
|
+
tr.scrollIntoView();
|
|
272
|
+
return tr;
|
|
273
|
+
});
|
|
274
|
+
return true;
|
|
249
275
|
}
|
|
250
276
|
}
|
|
251
277
|
return false;
|
|
@@ -254,6 +280,7 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
254
280
|
export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_DROP, formatMessage) => ({
|
|
255
281
|
tr
|
|
256
282
|
}) => {
|
|
283
|
+
var _api$blockControls$co2;
|
|
257
284
|
if (!api) {
|
|
258
285
|
return tr;
|
|
259
286
|
}
|
|
@@ -326,8 +353,13 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
326
353
|
mappedTo = tr.mapping.map(to);
|
|
327
354
|
tr.insert(mappedTo, nodeCopy); // insert the content at the new position
|
|
328
355
|
}
|
|
329
|
-
|
|
356
|
+
const sliceSize = sliceTo - sliceFrom;
|
|
357
|
+
tr = inputMethod === INPUT_METHOD.DRAG_AND_DROP ? setCursorPositionAtMovedNode(tr, mappedTo) : isMultiSelect ? (_api$blockControls$co2 = api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(mappedTo, mappedTo + sliceSize)({
|
|
358
|
+
tr
|
|
359
|
+
})) !== null && _api$blockControls$co2 !== void 0 ? _api$blockControls$co2 : tr : selectNode(tr, mappedTo, handleNode.type.name);
|
|
360
|
+
const currMeta = tr.getMeta(key);
|
|
330
361
|
tr.setMeta(key, {
|
|
362
|
+
...currMeta,
|
|
331
363
|
nodeMoved: true
|
|
332
364
|
});
|
|
333
365
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
@@ -20,9 +20,16 @@ export const shouldDescendIntoNode = node => {
|
|
|
20
20
|
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
21
21
|
};
|
|
22
22
|
const shouldIgnoreNode = (node, ignore_nodes, depth, parent) => {
|
|
23
|
-
var _node$attrs, _node$attrs2;
|
|
23
|
+
var _nodeTypes$table, _node$attrs, _node$attrs2;
|
|
24
24
|
const isEmbedCard = node.type.name === 'embedCard';
|
|
25
25
|
const isMediaSingle = node.type.name === 'mediaSingle';
|
|
26
|
+
const nodeTypes = node.type.schema.nodes;
|
|
27
|
+
const isTable = node.type.name === (nodeTypes === null || nodeTypes === void 0 ? void 0 : (_nodeTypes$table = nodeTypes.table) === null || _nodeTypes$table === void 0 ? void 0 : _nodeTypes$table.name);
|
|
28
|
+
const parentIsTable = parent && [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
|
|
29
|
+
const isNestedTable = isTable && parentIsTable;
|
|
30
|
+
if (isNestedTable && fg('platform_editor_disable_drag_handle_nested_tables')) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
26
33
|
const isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && editorExperiment('advanced_layouts', true);
|
|
27
34
|
if (isFirstTableRow) {
|
|
28
35
|
return false;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { bind } from 'bind-event-listener';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
3
4
|
import uuid from 'uuid';
|
|
4
5
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -61,7 +62,28 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
|
|
|
61
62
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
62
63
|
// due to margins applied to other nodes eg. Headings
|
|
63
64
|
element.style.clear = 'unset';
|
|
64
|
-
|
|
65
|
+
|
|
66
|
+
// temporarily re-instating ReactDOM.render to fix drag handle focus issue, fix to
|
|
67
|
+
// follow via ED-26546
|
|
68
|
+
|
|
69
|
+
// if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
70
|
+
// nodeViewPortalProviderAPI.render(
|
|
71
|
+
// () =>
|
|
72
|
+
// createElement(DragHandle, {
|
|
73
|
+
// view,
|
|
74
|
+
// api,
|
|
75
|
+
// formatMessage,
|
|
76
|
+
// getPos,
|
|
77
|
+
// anchorName,
|
|
78
|
+
// nodeType,
|
|
79
|
+
// handleOptions,
|
|
80
|
+
// isTopLevelNode,
|
|
81
|
+
// }),
|
|
82
|
+
// element,
|
|
83
|
+
// key,
|
|
84
|
+
// );
|
|
85
|
+
// } else {
|
|
86
|
+
ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
|
|
65
87
|
view,
|
|
66
88
|
api,
|
|
67
89
|
formatMessage,
|
|
@@ -70,7 +92,8 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
|
|
|
70
92
|
nodeType,
|
|
71
93
|
handleOptions,
|
|
72
94
|
isTopLevelNode
|
|
73
|
-
}), element
|
|
95
|
+
}), element);
|
|
96
|
+
//}
|
|
74
97
|
return element;
|
|
75
98
|
}, {
|
|
76
99
|
side: -1,
|
|
@@ -189,7 +189,9 @@ export const newApply = (api, formatMessage, tr, currentState, newState, flags,
|
|
|
189
189
|
const resizerMeta = tr.getMeta('is-resizer-resizing');
|
|
190
190
|
isResizerResizing = resizerMeta !== null && resizerMeta !== void 0 ? resizerMeta : isResizerResizing;
|
|
191
191
|
if (multiSelectDnD && flags.isMultiSelectEnabled) {
|
|
192
|
-
multiSelectDnD = (meta === null || meta === void 0 ? void 0 : meta.isDragging) === false
|
|
192
|
+
multiSelectDnD = (meta === null || meta === void 0 ? void 0 : meta.isDragging) === false ||
|
|
193
|
+
// For move node with shortcut, only reset when the selection changes
|
|
194
|
+
tr.selection.anchor !== multiSelectDnD.textAnchor || tr.selection.head !== multiSelectDnD.textHead ? undefined : multiSelectDnD;
|
|
193
195
|
}
|
|
194
196
|
const {
|
|
195
197
|
from,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { key } from '../main';
|
|
2
|
+
export const getMultiSelectionIfPosInside = (api, pos, tr) => {
|
|
3
|
+
var _api$blockControls, _pluginState$multiSel, _tr$getMeta;
|
|
4
|
+
const pluginState = api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState();
|
|
5
|
+
// With move nodes shortcut, we expand selection and move node within one transaction,
|
|
6
|
+
// Hence we also look for `multiSelectDnD` in transaction meta
|
|
7
|
+
const multiSelectDnD = (_pluginState$multiSel = pluginState === null || pluginState === void 0 ? void 0 : pluginState.multiSelectDnD) !== null && _pluginState$multiSel !== void 0 ? _pluginState$multiSel : tr === null || tr === void 0 ? void 0 : (_tr$getMeta = tr.getMeta(key)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.multiSelectDnD;
|
|
6
8
|
if (multiSelectDnD && multiSelectDnD.anchor >= 0 && multiSelectDnD.head >= 0) {
|
|
7
9
|
const multiFrom = Math.min(multiSelectDnD.anchor, multiSelectDnD.head);
|
|
8
10
|
const multiTo = Math.max(multiSelectDnD.anchor, multiSelectDnD.head);
|
|
@@ -25,7 +27,7 @@ export const getSelectedSlicePosition = (handlePos, tr, api) => {
|
|
|
25
27
|
const {
|
|
26
28
|
anchor,
|
|
27
29
|
head
|
|
28
|
-
} = getMultiSelectionIfPosInside(api, handlePos);
|
|
30
|
+
} = getMultiSelectionIfPosInside(api, handlePos, tr);
|
|
29
31
|
const inSelection = anchor !== undefined && head !== undefined;
|
|
30
32
|
const from = inSelection ? Math.min(anchor, head) : handlePos;
|
|
31
33
|
const activeNode = tr.doc.nodeAt(handlePos);
|
|
@@ -60,16 +60,22 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
60
60
|
return tr;
|
|
61
61
|
};
|
|
62
62
|
},
|
|
63
|
-
setMultiSelectPositions: function setMultiSelectPositions() {
|
|
63
|
+
setMultiSelectPositions: function setMultiSelectPositions(anchor, head) {
|
|
64
64
|
return function (_ref5) {
|
|
65
65
|
var _api$selection;
|
|
66
66
|
var tr = _ref5.tr;
|
|
67
67
|
var _tr$selection = tr.selection,
|
|
68
68
|
userAnchor = _tr$selection.anchor,
|
|
69
69
|
userHead = _tr$selection.head;
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
var expandedAnchor, expandedHead;
|
|
71
|
+
if (anchor !== undefined && head !== undefined) {
|
|
72
|
+
expandedAnchor = tr.doc.resolve(anchor);
|
|
73
|
+
expandedHead = tr.doc.resolve(head);
|
|
74
|
+
} else {
|
|
75
|
+
var expandedSelection = expandSelectionBounds(tr.selection.$anchor, tr.selection.$head);
|
|
76
|
+
expandedAnchor = expandedSelection.$anchor;
|
|
77
|
+
expandedHead = expandedSelection.$head;
|
|
78
|
+
}
|
|
73
79
|
api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || _api$selection.commands.setManualSelection(expandedAnchor.pos, expandedHead.pos)({
|
|
74
80
|
tr: tr
|
|
75
81
|
});
|
|
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { expandedState } from '@atlaskit/editor-common/expand';
|
|
6
6
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
7
|
-
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
7
|
+
import { GapCursorSelection, expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
8
8
|
import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
|
|
9
9
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -89,7 +89,18 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
89
89
|
if (shouldEnableNestedDndA11y) {
|
|
90
90
|
isParentNodeOfTypeLayout = !!findParentNodeOfType([state.schema.nodes.layoutSection])(state.selection);
|
|
91
91
|
}
|
|
92
|
-
var
|
|
92
|
+
var isMultiSelectEnabled = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
93
|
+
var expandedAnchor, expandedHead;
|
|
94
|
+
var pluginState = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
|
|
95
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.multiSelectDnD) {
|
|
96
|
+
expandedAnchor = pluginState.multiSelectDnD.anchor;
|
|
97
|
+
expandedHead = pluginState.multiSelectDnD.head;
|
|
98
|
+
} else {
|
|
99
|
+
var expandedSelection = expandSelectionBounds(selection.$anchor, selection.$head);
|
|
100
|
+
expandedAnchor = expandedSelection.$anchor.pos;
|
|
101
|
+
expandedHead = expandedSelection.$head.pos;
|
|
102
|
+
}
|
|
103
|
+
var currentNodePos = isMultiSelectEnabled ? Math.min(expandedAnchor, expandedHead) : getCurrentNodePos(state);
|
|
93
104
|
if (currentNodePos > -1) {
|
|
94
105
|
var _state$doc$nodeAt;
|
|
95
106
|
var $pos = state.doc.resolve(currentNodePos);
|
|
@@ -200,7 +211,7 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
200
211
|
}
|
|
201
212
|
} else {
|
|
202
213
|
var _endOfDoc = $pos.end();
|
|
203
|
-
var nodeAfterPos = $pos.posAtIndex($pos.index() + 1);
|
|
214
|
+
var nodeAfterPos = isMultiSelectEnabled ? Math.max(expandedAnchor, expandedHead) : $pos.posAtIndex($pos.index() + 1);
|
|
204
215
|
if (nodeAfterPos > _endOfDoc) {
|
|
205
216
|
return false;
|
|
206
217
|
}
|
|
@@ -222,6 +233,9 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
222
233
|
var _api$core7;
|
|
223
234
|
api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref4) {
|
|
224
235
|
var tr = _ref4.tr;
|
|
236
|
+
api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
237
|
+
tr: tr
|
|
238
|
+
});
|
|
225
239
|
moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.SHORTCUT, formatMessage)({
|
|
226
240
|
tr: tr
|
|
227
241
|
});
|
|
@@ -229,7 +243,7 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
229
243
|
return tr;
|
|
230
244
|
});
|
|
231
245
|
return true;
|
|
232
|
-
} else if (nodeType) {
|
|
246
|
+
} else if (nodeType && !isMultiSelectEnabled) {
|
|
233
247
|
var _api$core8;
|
|
234
248
|
// If the node is first/last one, only select the node
|
|
235
249
|
api === null || api === void 0 || (_api$core8 = api.core) === null || _api$core8 === void 0 || _api$core8.actions.execute(function (_ref5) {
|
|
@@ -239,6 +253,17 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
239
253
|
return tr;
|
|
240
254
|
});
|
|
241
255
|
return true;
|
|
256
|
+
} else if (isMultiSelectEnabled) {
|
|
257
|
+
var _api$core9;
|
|
258
|
+
api === null || api === void 0 || (_api$core9 = api.core) === null || _api$core9 === void 0 || _api$core9.actions.execute(function (_ref6) {
|
|
259
|
+
var tr = _ref6.tr;
|
|
260
|
+
api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
261
|
+
tr: tr
|
|
262
|
+
});
|
|
263
|
+
tr.scrollIntoView();
|
|
264
|
+
return tr;
|
|
265
|
+
});
|
|
266
|
+
return true;
|
|
242
267
|
}
|
|
243
268
|
}
|
|
244
269
|
return false;
|
|
@@ -248,8 +273,9 @@ export var moveNode = function moveNode(api) {
|
|
|
248
273
|
return function (start, to) {
|
|
249
274
|
var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INPUT_METHOD.DRAG_AND_DROP;
|
|
250
275
|
var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
|
|
251
|
-
return function (
|
|
252
|
-
var
|
|
276
|
+
return function (_ref7) {
|
|
277
|
+
var _api$blockControls$co;
|
|
278
|
+
var tr = _ref7.tr;
|
|
253
279
|
if (!api) {
|
|
254
280
|
return tr;
|
|
255
281
|
}
|
|
@@ -321,10 +347,14 @@ export var moveNode = function moveNode(api) {
|
|
|
321
347
|
mappedTo = tr.mapping.map(to);
|
|
322
348
|
tr.insert(mappedTo, _nodeCopy); // insert the content at the new position
|
|
323
349
|
}
|
|
324
|
-
|
|
325
|
-
tr.
|
|
350
|
+
var sliceSize = sliceTo - sliceFrom;
|
|
351
|
+
tr = inputMethod === INPUT_METHOD.DRAG_AND_DROP ? setCursorPositionAtMovedNode(tr, mappedTo) : isMultiSelect ? (_api$blockControls$co = api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(mappedTo, mappedTo + sliceSize)({
|
|
352
|
+
tr: tr
|
|
353
|
+
})) !== null && _api$blockControls$co !== void 0 ? _api$blockControls$co : tr : selectNode(tr, mappedTo, handleNode.type.name);
|
|
354
|
+
var currMeta = tr.getMeta(key);
|
|
355
|
+
tr.setMeta(key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
326
356
|
nodeMoved: true
|
|
327
|
-
});
|
|
357
|
+
}));
|
|
328
358
|
api === null || api === void 0 || api.core.actions.focus();
|
|
329
359
|
var $mappedTo = tr.doc.resolve(mappedTo);
|
|
330
360
|
var expandAncestor = findParentNodeOfTypeClosestToPos($to, [expand, nestedExpand]);
|
|
@@ -21,9 +21,16 @@ export var shouldDescendIntoNode = function shouldDescendIntoNode(node) {
|
|
|
21
21
|
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
22
22
|
};
|
|
23
23
|
var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, parent) {
|
|
24
|
-
var _node$attrs, _node$attrs2;
|
|
24
|
+
var _nodeTypes$table, _node$attrs, _node$attrs2;
|
|
25
25
|
var isEmbedCard = node.type.name === 'embedCard';
|
|
26
26
|
var isMediaSingle = node.type.name === 'mediaSingle';
|
|
27
|
+
var nodeTypes = node.type.schema.nodes;
|
|
28
|
+
var isTable = node.type.name === (nodeTypes === null || nodeTypes === void 0 || (_nodeTypes$table = nodeTypes.table) === null || _nodeTypes$table === void 0 ? void 0 : _nodeTypes$table.name);
|
|
29
|
+
var parentIsTable = parent && [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
|
|
30
|
+
var isNestedTable = isTable && parentIsTable;
|
|
31
|
+
if (isNestedTable && fg('platform_editor_disable_drag_handle_nested_tables')) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
27
34
|
var isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && editorExperiment('advanced_layouts', true);
|
|
28
35
|
if (isFirstTableRow) {
|
|
29
36
|
return false;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { createElement } from 'react';
|
|
3
3
|
import { bind } from 'bind-event-listener';
|
|
4
|
+
import ReactDOM from 'react-dom';
|
|
4
5
|
import uuid from 'uuid';
|
|
5
6
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
6
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -63,18 +64,38 @@ export var dragHandleDecoration = function dragHandleDecoration(api, formatMessa
|
|
|
63
64
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
64
65
|
// due to margins applied to other nodes eg. Headings
|
|
65
66
|
element.style.clear = 'unset';
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
|
|
68
|
+
// temporarily re-instating ReactDOM.render to fix drag handle focus issue, fix to
|
|
69
|
+
// follow via ED-26546
|
|
70
|
+
|
|
71
|
+
// if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
72
|
+
// nodeViewPortalProviderAPI.render(
|
|
73
|
+
// () =>
|
|
74
|
+
// createElement(DragHandle, {
|
|
75
|
+
// view,
|
|
76
|
+
// api,
|
|
77
|
+
// formatMessage,
|
|
78
|
+
// getPos,
|
|
79
|
+
// anchorName,
|
|
80
|
+
// nodeType,
|
|
81
|
+
// handleOptions,
|
|
82
|
+
// isTopLevelNode,
|
|
83
|
+
// }),
|
|
84
|
+
// element,
|
|
85
|
+
// key,
|
|
86
|
+
// );
|
|
87
|
+
// } else {
|
|
88
|
+
ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
|
|
89
|
+
view: view,
|
|
90
|
+
api: api,
|
|
91
|
+
formatMessage: formatMessage,
|
|
92
|
+
getPos: getPos,
|
|
93
|
+
anchorName: anchorName,
|
|
94
|
+
nodeType: nodeType,
|
|
95
|
+
handleOptions: handleOptions,
|
|
96
|
+
isTopLevelNode: isTopLevelNode
|
|
97
|
+
}), element);
|
|
98
|
+
//}
|
|
78
99
|
return element;
|
|
79
100
|
}, {
|
|
80
101
|
side: -1,
|
|
@@ -182,7 +182,9 @@ export var newApply = function newApply(api, formatMessage, tr, currentState, ne
|
|
|
182
182
|
var resizerMeta = tr.getMeta('is-resizer-resizing');
|
|
183
183
|
isResizerResizing = resizerMeta !== null && resizerMeta !== void 0 ? resizerMeta : isResizerResizing;
|
|
184
184
|
if (multiSelectDnD && flags.isMultiSelectEnabled) {
|
|
185
|
-
multiSelectDnD = (meta === null || meta === void 0 ? void 0 : meta.isDragging) === false
|
|
185
|
+
multiSelectDnD = (meta === null || meta === void 0 ? void 0 : meta.isDragging) === false ||
|
|
186
|
+
// For move node with shortcut, only reset when the selection changes
|
|
187
|
+
tr.selection.anchor !== multiSelectDnD.textAnchor || tr.selection.head !== multiSelectDnD.textHead ? undefined : multiSelectDnD;
|
|
186
188
|
}
|
|
187
189
|
var _getTrMetadata = getTrMetadata(tr),
|
|
188
190
|
from = _getTrMetadata.from,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
1
|
+
import { key } from '../main';
|
|
2
|
+
export var getMultiSelectionIfPosInside = function getMultiSelectionIfPosInside(api, pos, tr) {
|
|
3
|
+
var _api$blockControls, _pluginState$multiSel, _tr$getMeta;
|
|
4
|
+
var pluginState = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState();
|
|
5
|
+
// With move nodes shortcut, we expand selection and move node within one transaction,
|
|
6
|
+
// Hence we also look for `multiSelectDnD` in transaction meta
|
|
7
|
+
var multiSelectDnD = (_pluginState$multiSel = pluginState === null || pluginState === void 0 ? void 0 : pluginState.multiSelectDnD) !== null && _pluginState$multiSel !== void 0 ? _pluginState$multiSel : tr === null || tr === void 0 || (_tr$getMeta = tr.getMeta(key)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.multiSelectDnD;
|
|
5
8
|
if (multiSelectDnD && multiSelectDnD.anchor >= 0 && multiSelectDnD.head >= 0) {
|
|
6
9
|
var multiFrom = Math.min(multiSelectDnD.anchor, multiSelectDnD.head);
|
|
7
10
|
var multiTo = Math.max(multiSelectDnD.anchor, multiSelectDnD.head);
|
|
@@ -21,7 +24,7 @@ export var getMultiSelectionIfPosInside = function getMultiSelectionIfPosInside(
|
|
|
21
24
|
*/
|
|
22
25
|
export var getSelectedSlicePosition = function getSelectedSlicePosition(handlePos, tr, api) {
|
|
23
26
|
var _activeNode$nodeSize;
|
|
24
|
-
var _getMultiSelectionIfP = getMultiSelectionIfPosInside(api, handlePos),
|
|
27
|
+
var _getMultiSelectionIfP = getMultiSelectionIfPosInside(api, handlePos, tr),
|
|
25
28
|
anchor = _getMultiSelectionIfP.anchor,
|
|
26
29
|
head = _getMultiSelectionIfP.head;
|
|
27
30
|
var inSelection = anchor !== undefined && head !== undefined;
|
|
@@ -87,7 +87,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
|
87
87
|
moveNode: MoveNode;
|
|
88
88
|
showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
|
|
89
89
|
setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
|
|
90
|
-
setMultiSelectPositions: () => EditorCommand;
|
|
90
|
+
setMultiSelectPositions: (anchor?: number, head?: number) => EditorCommand;
|
|
91
91
|
};
|
|
92
92
|
}>;
|
|
93
93
|
export type BlockControlsMeta = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
-
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { BlockControlsPlugin } from '../../blockControlsPluginType';
|
|
4
|
-
export declare const getMultiSelectionIfPosInside: (api: ExtractInjectionAPI<BlockControlsPlugin>, pos: number) => {
|
|
4
|
+
export declare const getMultiSelectionIfPosInside: (api: ExtractInjectionAPI<BlockControlsPlugin>, pos: number, tr?: Transaction) => {
|
|
5
5
|
anchor?: number;
|
|
6
6
|
head?: number;
|
|
7
7
|
};
|
|
@@ -87,7 +87,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
|
87
87
|
moveNode: MoveNode;
|
|
88
88
|
showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
|
|
89
89
|
setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
|
|
90
|
-
setMultiSelectPositions: () => EditorCommand;
|
|
90
|
+
setMultiSelectPositions: (anchor?: number, head?: number) => EditorCommand;
|
|
91
91
|
};
|
|
92
92
|
}>;
|
|
93
93
|
export type BlockControlsMeta = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
-
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { BlockControlsPlugin } from '../../blockControlsPluginType';
|
|
4
|
-
export declare const getMultiSelectionIfPosInside: (api: ExtractInjectionAPI<BlockControlsPlugin>, pos: number) => {
|
|
4
|
+
export declare const getMultiSelectionIfPosInside: (api: ExtractInjectionAPI<BlockControlsPlugin>, pos: number, tr?: Transaction) => {
|
|
5
5
|
anchor?: number;
|
|
6
6
|
head?: number;
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.27.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@atlaskit/adf-schema": "^47.2.1",
|
|
34
|
-
"@atlaskit/editor-common": "^99.
|
|
34
|
+
"@atlaskit/editor-common": "^99.16.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.4.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.12.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.5.0",
|
|
@@ -148,6 +148,9 @@
|
|
|
148
148
|
},
|
|
149
149
|
"platform_editor_track_node_types": {
|
|
150
150
|
"type": "boolean"
|
|
151
|
+
},
|
|
152
|
+
"platform_editor_disable_drag_handle_nested_tables": {
|
|
153
|
+
"type": "boolean"
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
}
|