@atlaskit/editor-plugin-block-controls 2.21.6 → 2.21.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/editor-commands/show-drag-handle.js +1 -1
- package/dist/cjs/pm-plugins/decorations-drop-target.js +32 -5
- package/dist/cjs/pm-plugins/utils/validation.js +28 -0
- package/dist/es2019/editor-commands/show-drag-handle.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drop-target.js +33 -6
- package/dist/es2019/pm-plugins/utils/validation.js +27 -0
- package/dist/esm/editor-commands/show-drag-handle.js +1 -1
- package/dist/esm/pm-plugins/decorations-drop-target.js +33 -6
- package/dist/esm/pm-plugins/utils/validation.js +27 -0
- package/dist/types/pm-plugins/utils/validation.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/utils/validation.d.ts +1 -0
- package/package.json +12 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.21.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#107795](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107795)
|
|
8
|
+
[`ccf90a27dfe6b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ccf90a27dfe6b) -
|
|
9
|
+
ED-26407 Cleaned-up FG platform_editor_element_drag_and_drop_ed_24321
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 2.21.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#105486](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/105486)
|
|
17
|
+
[`ed00542ef3156`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ed00542ef3156) -
|
|
18
|
+
Validate all the nodes in the selection instead of just the handle node
|
|
19
|
+
|
|
3
20
|
## 2.21.6
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -52,7 +52,7 @@ var showDragHandleAtSelection = exports.showDragHandleAtSelection = function sho
|
|
|
52
52
|
var rootPos = $from.before(1);
|
|
53
53
|
var dom = view === null || view === void 0 ? void 0 : view.domAtPos(rootPos, 0);
|
|
54
54
|
var nodeElement = dom === null || dom === void 0 ? void 0 : dom.node.childNodes[dom === null || dom === void 0 ? void 0 : dom.offset];
|
|
55
|
-
var rootNode = nodeElement && !nodeElement.hasAttribute('data-drag-handler-anchor-name')
|
|
55
|
+
var rootNode = nodeElement && !nodeElement.hasAttribute('data-drag-handler-anchor-name') ? nodeElement.querySelector('[data-drag-handler-anchor-name]') : nodeElement;
|
|
56
56
|
if (rootNode) {
|
|
57
57
|
// Ignored via go/ees005
|
|
58
58
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -165,6 +165,9 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
165
165
|
var activeNodePos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
|
|
166
166
|
var $activeNodePos = typeof activeNodePos === 'number' && newState.doc.resolve(activeNodePos);
|
|
167
167
|
var activePMNode = $activeNodePos && $activeNodePos.nodeAfter;
|
|
168
|
+
var isMultiSelect = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true, {
|
|
169
|
+
exposure: true
|
|
170
|
+
});
|
|
168
171
|
anchorRectCache === null || anchorRectCache === void 0 || anchorRectCache.clear();
|
|
169
172
|
var prevNodeStack = [];
|
|
170
173
|
var popNodeStack = function popNodeStack(depth) {
|
|
@@ -211,12 +214,36 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
211
214
|
pushNodeStack(node, depth);
|
|
212
215
|
return shouldDescend(node); //skip over, don't consider it a valid depth
|
|
213
216
|
}
|
|
214
|
-
var canDrop = activePMNode && (0, _validation.canMoveNodeToIndex)(parent, index, activePMNode, $pos, node);
|
|
215
217
|
|
|
216
|
-
//
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
// When multi select is on, validate all the nodes in the selection instead of just the handle node
|
|
219
|
+
if (isMultiSelect) {
|
|
220
|
+
var selection = newState.selection;
|
|
221
|
+
var selectionFrom = selection.$from.pos;
|
|
222
|
+
var selectionTo = selection.$to.pos;
|
|
223
|
+
var handleInsideSelection = activeNodePos !== undefined && activeNodePos >= selectionFrom - 1 && activeNodePos <= selectionTo;
|
|
224
|
+
var selectionSlice = newState.doc.slice(selectionFrom, selectionTo, false);
|
|
225
|
+
var selectionSliceChildCount = selectionSlice.content.childCount;
|
|
226
|
+
var canDropSingleNode = true;
|
|
227
|
+
var canDropMultipleNodes = true;
|
|
228
|
+
|
|
229
|
+
// when there is only one node in the slice, use the same logic as when multi select is not on
|
|
230
|
+
if (selectionSliceChildCount > 1 && handleInsideSelection) {
|
|
231
|
+
canDropMultipleNodes = (0, _validation.canMoveSliceToIndex)(selectionSlice, selectionFrom, newState.doc, parent, index, $pos);
|
|
232
|
+
} else {
|
|
233
|
+
canDropSingleNode = !!(activePMNode && (0, _validation.canMoveNodeToIndex)(parent, index, activePMNode, $pos, node));
|
|
234
|
+
}
|
|
235
|
+
if (!canDropMultipleNodes || !canDropSingleNode) {
|
|
236
|
+
pushNodeStack(node, depth);
|
|
237
|
+
return false; //not valid pos, so nested not valid either
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
var canDrop = activePMNode && (0, _validation.canMoveNodeToIndex)(parent, index, activePMNode, $pos, node);
|
|
241
|
+
|
|
242
|
+
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
243
|
+
if (!canDrop) {
|
|
244
|
+
pushNodeStack(node, depth);
|
|
245
|
+
return false; //not valid pos, so nested not valid either
|
|
246
|
+
}
|
|
220
247
|
}
|
|
221
248
|
if (parent.lastChild === node && !(0, _utils.isEmptyParagraph)(node) && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
222
249
|
endPos = pos + node.nodeSize;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.canMoveNodeToIndex = canMoveNodeToIndex;
|
|
8
|
+
exports.canMoveSliceToIndex = canMoveSliceToIndex;
|
|
8
9
|
exports.transformSliceExpandToNestedExpand = exports.transformExpandToNestedExpand = exports.memoizedTransformExpandToNestedExpand = exports.isNestedExpand = exports.isLayoutColumn = exports.isInsideTable = exports.isInSameLayout = exports.isExpand = exports.isDoc = void 0;
|
|
9
10
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
10
11
|
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
@@ -126,4 +127,31 @@ function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos,
|
|
|
126
127
|
srcNodeType = srcNodeType.schema.nodes.expand;
|
|
127
128
|
}
|
|
128
129
|
return destParent.canReplaceWith(indexIntoParent, indexIntoParent, srcNodeType);
|
|
130
|
+
}
|
|
131
|
+
function canMoveSliceToIndex(slice, sliceFromPos, doc, destParent, indexIntoParent, $destNodePos, destNode) {
|
|
132
|
+
var canMoveNodes = true;
|
|
133
|
+
var nodesPos = [];
|
|
134
|
+
for (var i = 0; i < slice.content.childCount; i++) {
|
|
135
|
+
var node = slice.content.maybeChild(i);
|
|
136
|
+
if (i === 0) {
|
|
137
|
+
nodesPos[i] = sliceFromPos;
|
|
138
|
+
} else {
|
|
139
|
+
var _slice$content$maybeC;
|
|
140
|
+
nodesPos[i] = nodesPos[i - 1] + (((_slice$content$maybeC = slice.content.maybeChild(i - 1)) === null || _slice$content$maybeC === void 0 ? void 0 : _slice$content$maybeC.nodeSize) || 0);
|
|
141
|
+
}
|
|
142
|
+
if (node && node.isInline) {
|
|
143
|
+
// If the node is an inline node, we need to find the parent node
|
|
144
|
+
// as passing in them into canMoveNodeToIndex will return false
|
|
145
|
+
var $nodePos = doc.resolve(nodesPos[i]);
|
|
146
|
+
var parentNode = $nodePos.parent;
|
|
147
|
+
if (!parentNode || parentNode && !canMoveNodeToIndex(destParent, indexIntoParent, parentNode, $destNodePos, destNode)) {
|
|
148
|
+
canMoveNodes = false;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
} else if (node && !canMoveNodeToIndex(destParent, indexIntoParent, node, $destNodePos, destNode)) {
|
|
152
|
+
canMoveNodes = false;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return canMoveNodes;
|
|
129
157
|
}
|
|
@@ -48,7 +48,7 @@ export const showDragHandleAtSelection = (api, shouldFocusParentNode) => (state,
|
|
|
48
48
|
const rootPos = $from.before(1);
|
|
49
49
|
const dom = view === null || view === void 0 ? void 0 : view.domAtPos(rootPos, 0);
|
|
50
50
|
const nodeElement = dom === null || dom === void 0 ? void 0 : dom.node.childNodes[dom === null || dom === void 0 ? void 0 : dom.offset];
|
|
51
|
-
const rootNode = nodeElement && !nodeElement.hasAttribute('data-drag-handler-anchor-name')
|
|
51
|
+
const rootNode = nodeElement && !nodeElement.hasAttribute('data-drag-handler-anchor-name') ? nodeElement.querySelector('[data-drag-handler-anchor-name]') : nodeElement;
|
|
52
52
|
if (rootNode) {
|
|
53
53
|
// Ignored via go/ees005
|
|
54
54
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -10,7 +10,7 @@ import { DropTarget, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONT
|
|
|
10
10
|
import { DropTargetLayout } from '../ui/drop-target-layout';
|
|
11
11
|
import { getNestedDepth, TYPE_DROP_TARGET_DEC, unmountDecorations } from './decorations-common';
|
|
12
12
|
import { maxLayoutColumnSupported } from './utils/consts';
|
|
13
|
-
import { canMoveNodeToIndex, isInSameLayout } from './utils/validation';
|
|
13
|
+
import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
|
|
14
14
|
const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
|
|
15
15
|
const PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
|
|
16
16
|
const DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
|
|
@@ -154,6 +154,9 @@ export const dropTargetDecorations = (newState, api, formatMessage, nodeViewPort
|
|
|
154
154
|
const activeNodePos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
|
|
155
155
|
const $activeNodePos = typeof activeNodePos === 'number' && newState.doc.resolve(activeNodePos);
|
|
156
156
|
const activePMNode = $activeNodePos && $activeNodePos.nodeAfter;
|
|
157
|
+
const isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true, {
|
|
158
|
+
exposure: true
|
|
159
|
+
});
|
|
157
160
|
anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.clear();
|
|
158
161
|
const prevNodeStack = [];
|
|
159
162
|
const popNodeStack = depth => {
|
|
@@ -200,12 +203,36 @@ export const dropTargetDecorations = (newState, api, formatMessage, nodeViewPort
|
|
|
200
203
|
pushNodeStack(node, depth);
|
|
201
204
|
return shouldDescend(node); //skip over, don't consider it a valid depth
|
|
202
205
|
}
|
|
203
|
-
const canDrop = activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node);
|
|
204
206
|
|
|
205
|
-
//
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
// When multi select is on, validate all the nodes in the selection instead of just the handle node
|
|
208
|
+
if (isMultiSelect) {
|
|
209
|
+
const selection = newState.selection;
|
|
210
|
+
const selectionFrom = selection.$from.pos;
|
|
211
|
+
const selectionTo = selection.$to.pos;
|
|
212
|
+
const handleInsideSelection = activeNodePos !== undefined && activeNodePos >= selectionFrom - 1 && activeNodePos <= selectionTo;
|
|
213
|
+
const selectionSlice = newState.doc.slice(selectionFrom, selectionTo, false);
|
|
214
|
+
const selectionSliceChildCount = selectionSlice.content.childCount;
|
|
215
|
+
let canDropSingleNode = true;
|
|
216
|
+
let canDropMultipleNodes = true;
|
|
217
|
+
|
|
218
|
+
// when there is only one node in the slice, use the same logic as when multi select is not on
|
|
219
|
+
if (selectionSliceChildCount > 1 && handleInsideSelection) {
|
|
220
|
+
canDropMultipleNodes = canMoveSliceToIndex(selectionSlice, selectionFrom, newState.doc, parent, index, $pos);
|
|
221
|
+
} else {
|
|
222
|
+
canDropSingleNode = !!(activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node));
|
|
223
|
+
}
|
|
224
|
+
if (!canDropMultipleNodes || !canDropSingleNode) {
|
|
225
|
+
pushNodeStack(node, depth);
|
|
226
|
+
return false; //not valid pos, so nested not valid either
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
const canDrop = activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node);
|
|
230
|
+
|
|
231
|
+
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
232
|
+
if (!canDrop) {
|
|
233
|
+
pushNodeStack(node, depth);
|
|
234
|
+
return false; //not valid pos, so nested not valid either
|
|
235
|
+
}
|
|
209
236
|
}
|
|
210
237
|
if (parent.lastChild === node && !isEmptyParagraph(node) && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
211
238
|
endPos = pos + node.nodeSize;
|
|
@@ -120,4 +120,31 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNo
|
|
|
120
120
|
srcNodeType = srcNodeType.schema.nodes.expand;
|
|
121
121
|
}
|
|
122
122
|
return destParent.canReplaceWith(indexIntoParent, indexIntoParent, srcNodeType);
|
|
123
|
+
}
|
|
124
|
+
export function canMoveSliceToIndex(slice, sliceFromPos, doc, destParent, indexIntoParent, $destNodePos, destNode) {
|
|
125
|
+
let canMoveNodes = true;
|
|
126
|
+
const nodesPos = [];
|
|
127
|
+
for (let i = 0; i < slice.content.childCount; i++) {
|
|
128
|
+
const node = slice.content.maybeChild(i);
|
|
129
|
+
if (i === 0) {
|
|
130
|
+
nodesPos[i] = sliceFromPos;
|
|
131
|
+
} else {
|
|
132
|
+
var _slice$content$maybeC;
|
|
133
|
+
nodesPos[i] = nodesPos[i - 1] + (((_slice$content$maybeC = slice.content.maybeChild(i - 1)) === null || _slice$content$maybeC === void 0 ? void 0 : _slice$content$maybeC.nodeSize) || 0);
|
|
134
|
+
}
|
|
135
|
+
if (node && node.isInline) {
|
|
136
|
+
// If the node is an inline node, we need to find the parent node
|
|
137
|
+
// as passing in them into canMoveNodeToIndex will return false
|
|
138
|
+
const $nodePos = doc.resolve(nodesPos[i]);
|
|
139
|
+
const parentNode = $nodePos.parent;
|
|
140
|
+
if (!parentNode || parentNode && !canMoveNodeToIndex(destParent, indexIntoParent, parentNode, $destNodePos, destNode)) {
|
|
141
|
+
canMoveNodes = false;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
} else if (node && !canMoveNodeToIndex(destParent, indexIntoParent, node, $destNodePos, destNode)) {
|
|
145
|
+
canMoveNodes = false;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return canMoveNodes;
|
|
123
150
|
}
|
|
@@ -46,7 +46,7 @@ export var showDragHandleAtSelection = function showDragHandleAtSelection(api, s
|
|
|
46
46
|
var rootPos = $from.before(1);
|
|
47
47
|
var dom = view === null || view === void 0 ? void 0 : view.domAtPos(rootPos, 0);
|
|
48
48
|
var nodeElement = dom === null || dom === void 0 ? void 0 : dom.node.childNodes[dom === null || dom === void 0 ? void 0 : dom.offset];
|
|
49
|
-
var rootNode = nodeElement && !nodeElement.hasAttribute('data-drag-handler-anchor-name')
|
|
49
|
+
var rootNode = nodeElement && !nodeElement.hasAttribute('data-drag-handler-anchor-name') ? nodeElement.querySelector('[data-drag-handler-anchor-name]') : nodeElement;
|
|
50
50
|
if (rootNode) {
|
|
51
51
|
// Ignored via go/ees005
|
|
52
52
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -13,7 +13,7 @@ import { DropTarget, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONT
|
|
|
13
13
|
import { DropTargetLayout } from '../ui/drop-target-layout';
|
|
14
14
|
import { getNestedDepth, TYPE_DROP_TARGET_DEC, unmountDecorations } from './decorations-common';
|
|
15
15
|
import { maxLayoutColumnSupported } from './utils/consts';
|
|
16
|
-
import { canMoveNodeToIndex, isInSameLayout } from './utils/validation';
|
|
16
|
+
import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
|
|
17
17
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
|
|
18
18
|
var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
|
|
19
19
|
var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
|
|
@@ -158,6 +158,9 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
158
158
|
var activeNodePos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
|
|
159
159
|
var $activeNodePos = typeof activeNodePos === 'number' && newState.doc.resolve(activeNodePos);
|
|
160
160
|
var activePMNode = $activeNodePos && $activeNodePos.nodeAfter;
|
|
161
|
+
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true, {
|
|
162
|
+
exposure: true
|
|
163
|
+
});
|
|
161
164
|
anchorRectCache === null || anchorRectCache === void 0 || anchorRectCache.clear();
|
|
162
165
|
var prevNodeStack = [];
|
|
163
166
|
var popNodeStack = function popNodeStack(depth) {
|
|
@@ -204,12 +207,36 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
204
207
|
pushNodeStack(node, depth);
|
|
205
208
|
return shouldDescend(node); //skip over, don't consider it a valid depth
|
|
206
209
|
}
|
|
207
|
-
var canDrop = activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node);
|
|
208
210
|
|
|
209
|
-
//
|
|
210
|
-
if (
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
// When multi select is on, validate all the nodes in the selection instead of just the handle node
|
|
212
|
+
if (isMultiSelect) {
|
|
213
|
+
var selection = newState.selection;
|
|
214
|
+
var selectionFrom = selection.$from.pos;
|
|
215
|
+
var selectionTo = selection.$to.pos;
|
|
216
|
+
var handleInsideSelection = activeNodePos !== undefined && activeNodePos >= selectionFrom - 1 && activeNodePos <= selectionTo;
|
|
217
|
+
var selectionSlice = newState.doc.slice(selectionFrom, selectionTo, false);
|
|
218
|
+
var selectionSliceChildCount = selectionSlice.content.childCount;
|
|
219
|
+
var canDropSingleNode = true;
|
|
220
|
+
var canDropMultipleNodes = true;
|
|
221
|
+
|
|
222
|
+
// when there is only one node in the slice, use the same logic as when multi select is not on
|
|
223
|
+
if (selectionSliceChildCount > 1 && handleInsideSelection) {
|
|
224
|
+
canDropMultipleNodes = canMoveSliceToIndex(selectionSlice, selectionFrom, newState.doc, parent, index, $pos);
|
|
225
|
+
} else {
|
|
226
|
+
canDropSingleNode = !!(activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node));
|
|
227
|
+
}
|
|
228
|
+
if (!canDropMultipleNodes || !canDropSingleNode) {
|
|
229
|
+
pushNodeStack(node, depth);
|
|
230
|
+
return false; //not valid pos, so nested not valid either
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
var canDrop = activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node);
|
|
234
|
+
|
|
235
|
+
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
236
|
+
if (!canDrop) {
|
|
237
|
+
pushNodeStack(node, depth);
|
|
238
|
+
return false; //not valid pos, so nested not valid either
|
|
239
|
+
}
|
|
213
240
|
}
|
|
214
241
|
if (parent.lastChild === node && !isEmptyParagraph(node) && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
215
242
|
endPos = pos + node.nodeSize;
|
|
@@ -118,4 +118,31 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNo
|
|
|
118
118
|
srcNodeType = srcNodeType.schema.nodes.expand;
|
|
119
119
|
}
|
|
120
120
|
return destParent.canReplaceWith(indexIntoParent, indexIntoParent, srcNodeType);
|
|
121
|
+
}
|
|
122
|
+
export function canMoveSliceToIndex(slice, sliceFromPos, doc, destParent, indexIntoParent, $destNodePos, destNode) {
|
|
123
|
+
var canMoveNodes = true;
|
|
124
|
+
var nodesPos = [];
|
|
125
|
+
for (var i = 0; i < slice.content.childCount; i++) {
|
|
126
|
+
var node = slice.content.maybeChild(i);
|
|
127
|
+
if (i === 0) {
|
|
128
|
+
nodesPos[i] = sliceFromPos;
|
|
129
|
+
} else {
|
|
130
|
+
var _slice$content$maybeC;
|
|
131
|
+
nodesPos[i] = nodesPos[i - 1] + (((_slice$content$maybeC = slice.content.maybeChild(i - 1)) === null || _slice$content$maybeC === void 0 ? void 0 : _slice$content$maybeC.nodeSize) || 0);
|
|
132
|
+
}
|
|
133
|
+
if (node && node.isInline) {
|
|
134
|
+
// If the node is an inline node, we need to find the parent node
|
|
135
|
+
// as passing in them into canMoveNodeToIndex will return false
|
|
136
|
+
var $nodePos = doc.resolve(nodesPos[i]);
|
|
137
|
+
var parentNode = $nodePos.parent;
|
|
138
|
+
if (!parentNode || parentNode && !canMoveNodeToIndex(destParent, indexIntoParent, parentNode, $destNodePos, destNode)) {
|
|
139
|
+
canMoveNodes = false;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
} else if (node && !canMoveNodeToIndex(destParent, indexIntoParent, node, $destNodePos, destNode)) {
|
|
143
|
+
canMoveNodes = false;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return canMoveNodes;
|
|
121
148
|
}
|
|
@@ -17,3 +17,4 @@ export declare const transformExpandToNestedExpand: (expandNode: PMNode) => PMNo
|
|
|
17
17
|
export declare const transformSliceExpandToNestedExpand: (slice: Slice) => Slice | null;
|
|
18
18
|
export declare const memoizedTransformExpandToNestedExpand: import("memoize-one").MemoizedFn<(node: PMNode) => PMNode | null>;
|
|
19
19
|
export declare function canMoveNodeToIndex(destParent: PMNode, indexIntoParent: number, srcNode: PMNode, $destNodePos: ResolvedPos, destNode?: PMNode): boolean;
|
|
20
|
+
export declare function canMoveSliceToIndex(slice: Slice, sliceFromPos: number, doc: PMNode, destParent: PMNode, indexIntoParent: number, $destNodePos: ResolvedPos, destNode?: PMNode): boolean;
|
|
@@ -17,3 +17,4 @@ export declare const transformExpandToNestedExpand: (expandNode: PMNode) => PMNo
|
|
|
17
17
|
export declare const transformSliceExpandToNestedExpand: (slice: Slice) => Slice | null;
|
|
18
18
|
export declare const memoizedTransformExpandToNestedExpand: import("memoize-one").MemoizedFn<(node: PMNode) => PMNode | null>;
|
|
19
19
|
export declare function canMoveNodeToIndex(destParent: PMNode, indexIntoParent: number, srcNode: PMNode, $destNodePos: ResolvedPos, destNode?: PMNode): boolean;
|
|
20
|
+
export declare function canMoveSliceToIndex(slice: Slice, sliceFromPos: number, doc: PMNode, destParent: PMNode, indexIntoParent: number, $destNodePos: ResolvedPos, destNode?: PMNode): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.8",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,26 +31,26 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
34
|
-
"@atlaskit/editor-common": "^99.
|
|
35
|
-
"@atlaskit/editor-plugin-accessibility-utils": "^1.
|
|
34
|
+
"@atlaskit/editor-common": "^99.7.0",
|
|
35
|
+
"@atlaskit/editor-plugin-accessibility-utils": "^1.3.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.11.0",
|
|
37
|
-
"@atlaskit/editor-plugin-editor-disabled": "^1.
|
|
37
|
+
"@atlaskit/editor-plugin-editor-disabled": "^1.4.0",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^1.2.0",
|
|
39
|
-
"@atlaskit/editor-plugin-quick-insert": "^1.
|
|
39
|
+
"@atlaskit/editor-plugin-quick-insert": "^1.9.0",
|
|
40
40
|
"@atlaskit/editor-plugin-width": "^2.0.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
44
|
-
"@atlaskit/icon": "^23.
|
|
44
|
+
"@atlaskit/icon": "^23.5.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
46
|
-
"@atlaskit/pragmatic-drag-and-drop": "^1.
|
|
46
|
+
"@atlaskit/pragmatic-drag-and-drop": "^1.5.0",
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
48
|
-
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.
|
|
49
|
-
"@atlaskit/primitives": "^13.
|
|
50
|
-
"@atlaskit/theme": "^14.
|
|
48
|
+
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.2.0",
|
|
49
|
+
"@atlaskit/primitives": "^13.4.0",
|
|
50
|
+
"@atlaskit/theme": "^14.1.0",
|
|
51
51
|
"@atlaskit/tmp-editor-statsig": "^2.41.0",
|
|
52
|
-
"@atlaskit/tokens": "^3.
|
|
53
|
-
"@atlaskit/tooltip": "^19.
|
|
52
|
+
"@atlaskit/tokens": "^3.3.0",
|
|
53
|
+
"@atlaskit/tooltip": "^19.1.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
55
55
|
"@emotion/react": "^11.7.1",
|
|
56
56
|
"bind-event-listener": "^3.0.0",
|
|
@@ -112,9 +112,6 @@
|
|
|
112
112
|
"platform_editor_element_drag_and_drop_ed_23873": {
|
|
113
113
|
"type": "boolean"
|
|
114
114
|
},
|
|
115
|
-
"platform_editor_element_drag_and_drop_ed_24321": {
|
|
116
|
-
"type": "boolean"
|
|
117
|
-
},
|
|
118
115
|
"platform_editor_element_dnd_nested_fix_patch_6": {
|
|
119
116
|
"type": "boolean"
|
|
120
117
|
},
|