@atlaskit/editor-plugin-block-controls 3.8.4 → 3.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/blockControlsPlugin.js +10 -1
- package/dist/cjs/editor-commands/move-node.js +50 -62
- package/dist/cjs/editor-commands/show-drag-handle.js +5 -73
- package/dist/cjs/pm-plugins/decorations-anchor.js +10 -13
- package/dist/cjs/pm-plugins/decorations-common.js +2 -5
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +18 -22
- package/dist/cjs/pm-plugins/decorations-drop-target.js +46 -48
- package/dist/cjs/pm-plugins/first-node-dec-plugin.js +46 -0
- package/dist/cjs/pm-plugins/handle-mouse-over.js +5 -10
- package/dist/cjs/pm-plugins/keymap.js +10 -13
- package/dist/cjs/pm-plugins/main.js +4 -177
- package/dist/cjs/ui/drag-handle.js +6 -9
- package/dist/cjs/ui/drop-target.js +1 -1
- package/dist/cjs/ui/global-styles.js +1 -28
- package/dist/es2019/blockControlsPlugin.js +7 -1
- package/dist/es2019/editor-commands/move-node.js +50 -62
- package/dist/es2019/editor-commands/show-drag-handle.js +4 -69
- package/dist/es2019/pm-plugins/decorations-anchor.js +11 -15
- package/dist/es2019/pm-plugins/decorations-common.js +1 -2
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +18 -24
- package/dist/es2019/pm-plugins/decorations-drop-target.js +47 -49
- package/dist/es2019/pm-plugins/first-node-dec-plugin.js +36 -0
- package/dist/es2019/pm-plugins/handle-mouse-over.js +5 -10
- package/dist/es2019/pm-plugins/keymap.js +10 -13
- package/dist/es2019/pm-plugins/main.js +3 -158
- package/dist/es2019/ui/drag-handle.js +6 -9
- package/dist/es2019/ui/drop-target.js +1 -1
- package/dist/es2019/ui/global-styles.js +1 -42
- package/dist/esm/blockControlsPlugin.js +10 -1
- package/dist/esm/editor-commands/move-node.js +50 -62
- package/dist/esm/editor-commands/show-drag-handle.js +5 -73
- package/dist/esm/pm-plugins/decorations-anchor.js +11 -14
- package/dist/esm/pm-plugins/decorations-common.js +1 -4
- package/dist/esm/pm-plugins/decorations-drag-handle.js +18 -22
- package/dist/esm/pm-plugins/decorations-drop-target.js +47 -49
- package/dist/esm/pm-plugins/first-node-dec-plugin.js +40 -0
- package/dist/esm/pm-plugins/handle-mouse-over.js +5 -10
- package/dist/esm/pm-plugins/keymap.js +10 -13
- package/dist/esm/pm-plugins/main.js +5 -177
- package/dist/esm/ui/drag-handle.js +6 -9
- package/dist/esm/ui/drop-target.js +1 -1
- package/dist/esm/ui/global-styles.js +1 -28
- package/dist/types/pm-plugins/decorations-common.d.ts +1 -1
- package/dist/types/pm-plugins/first-node-dec-plugin.d.ts +5 -0
- package/dist/types/pm-plugins/main.d.ts +1 -15
- package/dist/types-ts4.5/pm-plugins/decorations-common.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/first-node-dec-plugin.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -15
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
|
-
import {
|
|
5
|
+
import { NESTED_DEPTH, getNodeAnchor, getNodeTypeWithLevel, TYPE_NODE_DEC } from './decorations-common';
|
|
6
6
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
|
|
7
7
|
var IGNORE_NODES_NEXT = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption'];
|
|
8
8
|
var IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaSingle'];
|
|
@@ -81,19 +81,16 @@ export var nodeDecorations = function nodeDecorations(newState, from, to) {
|
|
|
81
81
|
var shouldDescend = shouldDescendIntoNode(node);
|
|
82
82
|
var anchorName = getNodeAnchor(node);
|
|
83
83
|
var nodeTypeWithLevel = getNodeTypeWithLevel(node);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
84
|
+
|
|
85
|
+
// Doesn't descend into a node
|
|
86
|
+
if (node.isInline) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
depth = newState.doc.resolve(pos).depth;
|
|
90
|
+
if (shouldIgnoreNode(node, ignore_nodes, depth, parent)) {
|
|
91
|
+
return shouldDescend; //skip over, don't consider it a valid depth
|
|
93
92
|
}
|
|
94
|
-
var anchorStyles =
|
|
95
|
-
// we're rendering quick insert button and drag handle. For now override margin-top to 0
|
|
96
|
-
"anchor-name: ".concat(anchorName, ";margin-top:0px;") : "anchor-name: ".concat(anchorName, ";");
|
|
93
|
+
var anchorStyles = "anchor-name: ".concat(anchorName, ";");
|
|
97
94
|
decs.push(Decoration.node(pos, pos + node.nodeSize, _defineProperty(_defineProperty(_defineProperty({
|
|
98
95
|
style: anchorStyles
|
|
99
96
|
}, 'data-drag-handler-anchor-name', anchorName), 'data-drag-handler-node-type', nodeTypeWithLevel), 'data-drag-handler-anchor-depth', "".concat(depth)), {
|
|
@@ -102,7 +99,7 @@ export var nodeDecorations = function nodeDecorations(newState, from, to) {
|
|
|
102
99
|
nodeType: node.type.name,
|
|
103
100
|
nodeTypeWithLevel: nodeTypeWithLevel
|
|
104
101
|
}));
|
|
105
|
-
return shouldDescend && depth <
|
|
102
|
+
return shouldDescend && depth < NESTED_DEPTH;
|
|
106
103
|
});
|
|
107
104
|
return decs;
|
|
108
105
|
};
|
|
@@ -3,13 +3,10 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
5
|
import uuid from 'uuid';
|
|
6
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
6
|
export var TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
|
|
8
7
|
export var TYPE_HANDLE_DEC = 'drag-handle';
|
|
9
8
|
export var TYPE_NODE_DEC = 'node-decoration';
|
|
10
|
-
export var
|
|
11
|
-
return editorExperiment('nested-dnd', true) ? 100 : 0;
|
|
12
|
-
};
|
|
9
|
+
export var NESTED_DEPTH = 100;
|
|
13
10
|
export var getNodeAnchor = function getNodeAnchor(node) {
|
|
14
11
|
var handleId = ObjHash.getForNode(node);
|
|
15
12
|
return "--node-anchor-".concat(node.type.name, "-").concat(handleId);
|
|
@@ -41,25 +41,23 @@ export var dragHandleDecoration = function dragHandleDecoration(api, formatMessa
|
|
|
41
41
|
return undefined;
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
}
|
|
44
|
+
var newPos = getPos();
|
|
45
|
+
if (typeof newPos === 'number') {
|
|
46
|
+
var $pos = view.state.doc.resolve(newPos);
|
|
47
|
+
isTopLevelNode = ($pos === null || $pos === void 0 ? void 0 : $pos.parent.type.name) === 'doc';
|
|
48
|
+
}
|
|
49
|
+
/*
|
|
50
|
+
* We disable mouseover event to fix flickering issue on hover
|
|
51
|
+
* However, the tooltip for nested drag handle is no long working.
|
|
52
|
+
*/
|
|
53
|
+
if (newPos === undefined || !isTopLevelNode) {
|
|
54
|
+
// This will also hide the tooltip.
|
|
55
|
+
unbind = bind(element, {
|
|
56
|
+
type: 'mouseover',
|
|
57
|
+
listener: function listener(e) {
|
|
58
|
+
e.stopPropagation();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
@@ -117,9 +115,7 @@ export var dragHandleDecoration = function dragHandleDecoration(api, formatMessa
|
|
|
117
115
|
type: TYPE_HANDLE_DEC,
|
|
118
116
|
testid: "".concat(TYPE_HANDLE_DEC, "-").concat(uuid()),
|
|
119
117
|
destroy: function destroy() {
|
|
120
|
-
|
|
121
|
-
unbind && unbind();
|
|
122
|
-
}
|
|
118
|
+
return unbind && unbind();
|
|
123
119
|
}
|
|
124
120
|
});
|
|
125
121
|
};
|
|
@@ -10,7 +10,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
10
10
|
import { nodeMargins } from '../ui/consts';
|
|
11
11
|
import { DropTarget, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target';
|
|
12
12
|
import { DropTargetLayout } from '../ui/drop-target-layout';
|
|
13
|
-
import {
|
|
13
|
+
import { NESTED_DEPTH, TYPE_DROP_TARGET_DEC, unmountDecorations } from './decorations-common';
|
|
14
14
|
import { maxLayoutColumnSupported } from './utils/consts';
|
|
15
15
|
import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
|
|
16
16
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
|
|
@@ -173,62 +173,60 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
173
173
|
var endPos;
|
|
174
174
|
var $pos = newState.doc.resolve(pos);
|
|
175
175
|
var isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, $pos);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) === pos && activeNode.nodeType !== 'layoutColumn') {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 && (
|
|
183
|
-
// Not the first node
|
|
184
|
-
(parent === null || parent === void 0 ? void 0 : parent.childCount) < maxLayoutColumnSupported() || isSameLayout)) {
|
|
185
|
-
// Add drop target for layout columns
|
|
186
|
-
decs.push(createLayoutDropTargetDecoration(pos, {
|
|
187
|
-
api: api,
|
|
188
|
-
parent: parent,
|
|
189
|
-
formatMessage: formatMessage
|
|
190
|
-
}, nodeViewPortalProviderAPI, anchorRectCache));
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
|
|
194
|
-
pushNodeStack(node, depth);
|
|
176
|
+
depth = $pos.depth;
|
|
177
|
+
if (isAdvancedLayoutsPreRelease2) {
|
|
178
|
+
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) === pos && activeNode.nodeType !== 'layoutColumn') {
|
|
195
179
|
return false;
|
|
196
180
|
}
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
181
|
+
if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 && (
|
|
182
|
+
// Not the first node
|
|
183
|
+
(parent === null || parent === void 0 ? void 0 : parent.childCount) < maxLayoutColumnSupported() || isSameLayout)) {
|
|
184
|
+
// Add drop target for layout columns
|
|
185
|
+
decs.push(createLayoutDropTargetDecoration(pos, {
|
|
186
|
+
api: api,
|
|
187
|
+
parent: parent,
|
|
188
|
+
formatMessage: formatMessage
|
|
189
|
+
}, nodeViewPortalProviderAPI, anchorRectCache));
|
|
200
190
|
}
|
|
191
|
+
}
|
|
192
|
+
if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
|
|
193
|
+
pushNodeStack(node, depth);
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
if (IGNORE_NODES.includes(node.type.name)) {
|
|
197
|
+
pushNodeStack(node, depth);
|
|
198
|
+
return shouldDescend(node); //skip over, don't consider it a valid depth
|
|
199
|
+
}
|
|
201
200
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
201
|
+
// When multi select is on, validate all the nodes in the selection instead of just the handle node
|
|
202
|
+
if (isMultiSelect) {
|
|
203
|
+
var selectionSlice = newState.doc.slice(selectionFrom, selectionTo, false);
|
|
204
|
+
var selectionSliceChildCount = selectionSlice.content.childCount;
|
|
205
|
+
var canDropSingleNode = true;
|
|
206
|
+
var canDropMultipleNodes = true;
|
|
208
207
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
} else {
|
|
213
|
-
canDropSingleNode = !!(activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node));
|
|
214
|
-
}
|
|
215
|
-
if (!canDropMultipleNodes || !canDropSingleNode) {
|
|
216
|
-
pushNodeStack(node, depth);
|
|
217
|
-
return false; //not valid pos, so nested not valid either
|
|
218
|
-
}
|
|
208
|
+
// when there is only one node in the slice, use the same logic as when multi select is not on
|
|
209
|
+
if (selectionSliceChildCount > 1 && handleInsideSelection) {
|
|
210
|
+
canDropMultipleNodes = canMoveSliceToIndex(selectionSlice, selectionFrom, selectionTo, parent, index, $pos);
|
|
219
211
|
} else {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return false; //not valid pos, so nested not valid either
|
|
226
|
-
}
|
|
212
|
+
canDropSingleNode = !!(activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node));
|
|
213
|
+
}
|
|
214
|
+
if (!canDropMultipleNodes || !canDropSingleNode) {
|
|
215
|
+
pushNodeStack(node, depth);
|
|
216
|
+
return false; //not valid pos, so nested not valid either
|
|
227
217
|
}
|
|
228
|
-
|
|
229
|
-
|
|
218
|
+
} else {
|
|
219
|
+
var canDrop = activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node);
|
|
220
|
+
|
|
221
|
+
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
222
|
+
if (!canDrop) {
|
|
223
|
+
pushNodeStack(node, depth);
|
|
224
|
+
return false; //not valid pos, so nested not valid either
|
|
230
225
|
}
|
|
231
226
|
}
|
|
227
|
+
if (parent.lastChild === node && !isEmptyParagraph(node) && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
228
|
+
endPos = pos + node.nodeSize;
|
|
229
|
+
}
|
|
232
230
|
var previousNode = popNodeStack(depth); // created scoped variable
|
|
233
231
|
|
|
234
232
|
// only table and layout need to render full height drop target
|
|
@@ -252,7 +250,7 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
252
250
|
}, nodeViewPortalProviderAPI, -1, anchorRectCache));
|
|
253
251
|
}
|
|
254
252
|
pushNodeStack(node, depth);
|
|
255
|
-
return depth <
|
|
253
|
+
return depth < NESTED_DEPTH && shouldDescend(node);
|
|
256
254
|
});
|
|
257
255
|
if (docTo === POS_END_OF_DOC) {
|
|
258
256
|
decs.push(createDropTargetDecoration(POS_END_OF_DOC, {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
|
+
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
export var firstNodeDecPluginKey = new PluginKey('firstNodeDec');
|
|
6
|
+
var createFirstNodeDecSet = function createFirstNodeDecSet(state) {
|
|
7
|
+
;
|
|
8
|
+
var firstNode = state.doc.firstChild;
|
|
9
|
+
if (!firstNode) {
|
|
10
|
+
return DecorationSet.empty;
|
|
11
|
+
}
|
|
12
|
+
return DecorationSet.create(state.doc, [Decoration.node(0, firstNode.nodeSize, {
|
|
13
|
+
style: 'margin-top: 0'
|
|
14
|
+
})]);
|
|
15
|
+
};
|
|
16
|
+
export var firstNodeDecPlugin = function firstNodeDecPlugin() {
|
|
17
|
+
return new SafePlugin({
|
|
18
|
+
key: firstNodeDecPluginKey,
|
|
19
|
+
state: {
|
|
20
|
+
init: function init(_, state) {
|
|
21
|
+
return createFirstNodeDecSet(state);
|
|
22
|
+
},
|
|
23
|
+
apply: function apply(tr, currentState, _, newState) {
|
|
24
|
+
var isDocChanged = tr.docChanged && tr.steps.some(function (step) {
|
|
25
|
+
return step instanceof ReplaceStep || step instanceof ReplaceAroundStep;
|
|
26
|
+
});
|
|
27
|
+
// Reapply decorations if there are any steps that modify the document
|
|
28
|
+
if (isDocChanged) {
|
|
29
|
+
return createFirstNodeDecSet(newState);
|
|
30
|
+
}
|
|
31
|
+
return currentState;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
props: {
|
|
35
|
+
decorations: function decorations(state) {
|
|
36
|
+
return firstNodeDecPluginKey.getState(state);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
@@ -28,7 +28,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
28
28
|
if (rootElement) {
|
|
29
29
|
var _rootElement$parentEl;
|
|
30
30
|
// We want to exlude handles from showing for empty paragraph and heading nodes
|
|
31
|
-
if (
|
|
31
|
+
if (isEmptyNestedParagraphOrHeading(rootElement)) {
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
if (rootElement.getAttribute('data-drag-handler-node-type') === 'media' && editorExperiment('advanced_layouts', true)) {
|
|
@@ -41,12 +41,12 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
41
41
|
var parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
|
|
42
42
|
if (editorExperiment('advanced_layouts', true)) {
|
|
43
43
|
// We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
|
|
44
|
-
if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow')
|
|
44
|
+
if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow')) {
|
|
45
45
|
rootElement = parentElement;
|
|
46
46
|
}
|
|
47
47
|
} else {
|
|
48
48
|
// We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
|
|
49
|
-
if (parentElement && parentElementType === 'table'
|
|
49
|
+
if (parentElement && parentElementType === 'table') {
|
|
50
50
|
rootElement = parentElement;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -67,7 +67,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
67
67
|
}
|
|
68
68
|
var parentRootElement = rootElement.parentElement;
|
|
69
69
|
var pos;
|
|
70
|
-
if (parentRootElement
|
|
70
|
+
if (parentRootElement) {
|
|
71
71
|
var _parentRootElement$ch;
|
|
72
72
|
var childNodes = Array.from(parentRootElement.childNodes);
|
|
73
73
|
var index = childNodes.indexOf(rootElement);
|
|
@@ -85,12 +85,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
85
85
|
// Don't show drag handle for layout column in a single column layout
|
|
86
86
|
return false;
|
|
87
87
|
}
|
|
88
|
-
var targetPos;
|
|
89
|
-
if (editorExperiment('nested-dnd', true)) {
|
|
90
|
-
targetPos = view.state.doc.resolve(pos).pos;
|
|
91
|
-
} else {
|
|
92
|
-
targetPos = view.state.doc.resolve(pos).start(1) - 1;
|
|
93
|
-
}
|
|
88
|
+
var targetPos = view.state.doc.resolve(pos).pos;
|
|
94
89
|
var rootAnchorName;
|
|
95
90
|
var rootNodeType;
|
|
96
91
|
var rootPos;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { bindKeymapWithCommand, dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, showElementDragHandle } from '@atlaskit/editor-common/keymaps';
|
|
2
2
|
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
4
|
import { moveNodeViaShortcut } from '../editor-commands/move-node';
|
|
6
5
|
import { showDragHandleAtSelection } from '../editor-commands/show-drag-handle';
|
|
7
6
|
import { DIRECTION } from './utils/consts';
|
|
@@ -11,8 +10,8 @@ function keymapList(api, formatMessage) {
|
|
|
11
10
|
bindKeymapWithCommand(
|
|
12
11
|
// Ignored via go/ees005
|
|
13
12
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
14
|
-
showElementDragHandle.common, function (state
|
|
15
|
-
showDragHandleAtSelection(api)(state
|
|
13
|
+
showElementDragHandle.common, function (state) {
|
|
14
|
+
showDragHandleAtSelection(api)(state);
|
|
16
15
|
//we always want to handle this shortcut to prevent default browser special char insert when option + alphabetical key is used
|
|
17
16
|
return true;
|
|
18
17
|
}, keymapList);
|
|
@@ -24,16 +23,14 @@ function keymapList(api, formatMessage) {
|
|
|
24
23
|
// Ignored via go/ees005
|
|
25
24
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
26
25
|
dragToMoveDown.common, moveNodeViaShortcut(api, DIRECTION.DOWN, formatMessage), keymapList);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
dragToMoveRight.common, moveNodeViaShortcut(api, DIRECTION.RIGHT, formatMessage), keymapList);
|
|
36
|
-
}
|
|
26
|
+
bindKeymapWithCommand(
|
|
27
|
+
// Ignored via go/ees005
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
29
|
+
dragToMoveLeft.common, moveNodeViaShortcut(api, DIRECTION.LEFT, formatMessage), keymapList);
|
|
30
|
+
bindKeymapWithCommand(
|
|
31
|
+
// Ignored via go/ees005
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
33
|
+
dragToMoveRight.common, moveNodeViaShortcut(api, DIRECTION.RIGHT, formatMessage), keymapList);
|
|
37
34
|
}
|
|
38
35
|
return keymapList;
|
|
39
36
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
4
|
import rafSchedule from 'raf-schd';
|
|
6
|
-
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
7
5
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
6
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
9
7
|
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
10
8
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
11
|
-
import { isEmptyDocument
|
|
9
|
+
import { isEmptyDocument } from '@atlaskit/editor-common/utils';
|
|
12
10
|
import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
11
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
14
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -180,7 +178,7 @@ var getDecorationAtPos = function getDecorationAtPos(decorations, pos, to) {
|
|
|
180
178
|
var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
|
|
181
179
|
return nodeDecAtActivePos;
|
|
182
180
|
};
|
|
183
|
-
|
|
181
|
+
var _apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
|
|
184
182
|
var _meta$multiSelectDnD, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
|
|
185
183
|
var activeNode = currentState.activeNode,
|
|
186
184
|
decorations = currentState.decorations,
|
|
@@ -421,176 +419,10 @@ export var newApply = function newApply(api, formatMessage, tr, currentState, ne
|
|
|
421
419
|
lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled
|
|
422
420
|
};
|
|
423
421
|
};
|
|
424
|
-
export
|
|
425
|
-
var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2, _meta$lastDragCancell2;
|
|
426
|
-
var isNestedEnabled = flags.isNestedEnabled;
|
|
427
|
-
var activeNode = currentState.activeNode,
|
|
428
|
-
isMenuOpen = currentState.isMenuOpen,
|
|
429
|
-
editorHeight = currentState.editorHeight,
|
|
430
|
-
editorWidthLeft = currentState.editorWidthLeft,
|
|
431
|
-
editorWidthRight = currentState.editorWidthRight,
|
|
432
|
-
isDragging = currentState.isDragging,
|
|
433
|
-
isPMDragging = currentState.isPMDragging,
|
|
434
|
-
lastDragCancelled = currentState.lastDragCancelled;
|
|
435
|
-
var decorations = currentState.decorations,
|
|
436
|
-
isResizerResizing = currentState.isResizerResizing;
|
|
437
|
-
|
|
438
|
-
// Remap existing decorations when steps exist
|
|
439
|
-
if (tr.docChanged) {
|
|
440
|
-
decorations = decorations.map(tr.mapping, tr.doc);
|
|
441
|
-
}
|
|
442
|
-
var meta = tr.getMeta(key);
|
|
443
|
-
|
|
444
|
-
// If tables or media are being resized, we want to hide the drag handle
|
|
445
|
-
var resizerMeta = tr.getMeta('is-resizer-resizing');
|
|
446
|
-
isResizerResizing = resizerMeta !== null && resizerMeta !== void 0 ? resizerMeta : isResizerResizing;
|
|
447
|
-
var canIgnoreTr = function canIgnoreTr() {
|
|
448
|
-
return !tr.steps.every(function (e) {
|
|
449
|
-
return e instanceof AnalyticsStep;
|
|
450
|
-
});
|
|
451
|
-
};
|
|
452
|
-
var maybeNodeCountChanged = isNestedEnabled ? !isTextInput(tr) && tr.docChanged && canIgnoreTr() : oldState.doc.childCount !== newState.doc.childCount;
|
|
453
|
-
var shouldRemoveHandle = !tr.getMeta('isRemote');
|
|
454
|
-
|
|
455
|
-
// During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
|
|
456
|
-
// Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
|
|
457
|
-
// Don't remove the handle if remote changes are changing the node count, its prosemirror position can be mapped instead
|
|
458
|
-
if (isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
|
|
459
|
-
var oldHandle = decorations.find(undefined, undefined, function (spec) {
|
|
460
|
-
return spec.type === 'drag-handle';
|
|
461
|
-
});
|
|
462
|
-
decorations = decorations.remove(oldHandle);
|
|
463
|
-
}
|
|
464
|
-
var decsLength = isNestedEnabled ? decorations.find(undefined, undefined, function (spec) {
|
|
465
|
-
return spec.type === 'node-decoration';
|
|
466
|
-
}).length : decorations.find().filter(function (_ref6) {
|
|
467
|
-
var spec = _ref6.spec;
|
|
468
|
-
return spec.type !== 'drag-handle';
|
|
469
|
-
}).length;
|
|
470
|
-
var isDecsMissing = false;
|
|
471
|
-
var isDropTargetsMissing = false;
|
|
472
|
-
if (isNestedEnabled) {
|
|
473
|
-
var _meta$isDragging3;
|
|
474
|
-
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && maybeNodeCountChanged;
|
|
475
|
-
isDropTargetsMissing = ((_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging) && maybeNodeCountChanged && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
476
|
-
} else {
|
|
477
|
-
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
|
|
478
|
-
var dropTargetLen = decorations.find(undefined, undefined, function (spec) {
|
|
479
|
-
return spec.type === 'drop-target-decoration';
|
|
480
|
-
}).length;
|
|
481
|
-
isDropTargetsMissing = isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && dropTargetLen !== newState.doc.childCount + 1;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// This is not targeted enough - it's trying to catch events like expand being set to breakout
|
|
485
|
-
var maybeWidthUpdated = tr.docChanged && oldState.doc.nodeSize === newState.doc.nodeSize && !maybeNodeCountChanged;
|
|
486
|
-
|
|
487
|
-
// This addresses scenarios such as undoing table resizing,
|
|
488
|
-
// where a keyboard shortcut triggers a width change, and
|
|
489
|
-
// the node's actual width is then updated in a separate renderering cycle.
|
|
490
|
-
// The tr.meta.activeNode is triggered by the showDragHandleAt function during the mouse entry event
|
|
491
|
-
// (when the table node rerenders)
|
|
492
|
-
// The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
|
|
493
|
-
var maybeTableWidthUpdated = (meta === null || meta === void 0 ? void 0 : meta.activeNode) && (meta === null || meta === void 0 || (_meta$activeNode2 = meta.activeNode) === null || _meta$activeNode2 === void 0 ? void 0 : _meta$activeNode2.nodeType) === 'table' && meta.activeNode.anchorName === (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName);
|
|
494
|
-
var redrawDecorations = decorations === DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || (meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== editorWidthLeft || (meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== editorWidthRight || maybeWidthUpdated || maybeNodeCountChanged || maybeTableWidthUpdated || resizerMeta === false || isDecsMissing || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
|
|
495
|
-
|
|
496
|
-
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
497
|
-
if (redrawDecorations && !isResizerResizing && api) {
|
|
498
|
-
var oldNodeDecs = decorations.find(undefined, undefined, function (spec) {
|
|
499
|
-
return spec.type !== 'drop-target-decoration';
|
|
500
|
-
});
|
|
501
|
-
decorations = decorations.remove(oldNodeDecs);
|
|
502
|
-
var newNodeDecs = nodeDecorations(newState);
|
|
503
|
-
decorations = decorations.add(newState.doc, _toConsumableArray(newNodeDecs));
|
|
504
|
-
if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
|
|
505
|
-
var _meta$activeNode$pos, _meta$activeNode3, _ref7, _meta$activeNode$anch, _meta$activeNode4, _decAtPos$spec, _ref8, _meta$activeNode$node, _meta$activeNode5, _decAtPos$spec2, _meta$activeNode6;
|
|
506
|
-
var mappedPosisiton = tr.mapping.map(activeNode.pos);
|
|
507
|
-
var prevMappedPos = oldState.tr.mapping.map(activeNode.pos);
|
|
508
|
-
|
|
509
|
-
// When a node type changed to be nested inside another node, the position of the active node is off by 1
|
|
510
|
-
// This is a workaround to fix the position of the active node when it is nested
|
|
511
|
-
if (tr.docChanged && !maybeNodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
|
|
512
|
-
mappedPosisiton = prevMappedPos;
|
|
513
|
-
}
|
|
514
|
-
var _newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
515
|
-
if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
|
|
516
|
-
var _oldHandle2 = decorations.find(undefined, undefined, function (spec) {
|
|
517
|
-
return spec.type === 'drag-handle';
|
|
518
|
-
});
|
|
519
|
-
decorations = decorations.remove(_oldHandle2);
|
|
520
|
-
}
|
|
521
|
-
var decAtPos = newNodeDecs.find(function (dec) {
|
|
522
|
-
return dec.from === mappedPosisiton;
|
|
523
|
-
});
|
|
524
|
-
var draghandleDec = dragHandleDecoration(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === void 0 || (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.pos) !== null && _meta$activeNode$pos !== void 0 ? _meta$activeNode$pos : mappedPosisiton, (_ref7 = (_meta$activeNode$anch = meta === null || meta === void 0 || (_meta$activeNode4 = meta.activeNode) === null || _meta$activeNode4 === void 0 ? void 0 : _meta$activeNode4.anchorName) !== null && _meta$activeNode$anch !== void 0 ? _meta$activeNode$anch : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref7 !== void 0 ? _ref7 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref8 = (_meta$activeNode$node = meta === null || meta === void 0 || (_meta$activeNode5 = meta.activeNode) === null || _meta$activeNode5 === void 0 ? void 0 : _meta$activeNode5.nodeType) !== null && _meta$activeNode$node !== void 0 ? _meta$activeNode$node : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref8 !== void 0 ? _ref8 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, nodeViewPortalProviderAPI, meta === null || meta === void 0 || (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
|
|
525
|
-
decorations = decorations.add(newState.doc, [draghandleDec]);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
// Remove previous drag handle widget and draw new drag handle widget when activeNode changes
|
|
530
|
-
if (api && meta !== null && meta !== void 0 && meta.activeNode && ((meta === null || meta === void 0 ? void 0 : meta.activeNode.pos) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) && (meta === null || meta === void 0 ? void 0 : meta.activeNode.anchorName) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) || meta !== null && meta !== void 0 && (_meta$activeNode$hand2 = meta.activeNode.handleOptions) !== null && _meta$activeNode$hand2 !== void 0 && _meta$activeNode$hand2.isFocused)) {
|
|
531
|
-
var _oldHandle3 = decorations.find(undefined, undefined, function (spec) {
|
|
532
|
-
return spec.type === 'drag-handle';
|
|
533
|
-
});
|
|
534
|
-
decorations = decorations.remove(_oldHandle3);
|
|
535
|
-
var decs = dragHandleDecoration(api, formatMessage, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, nodeViewPortalProviderAPI, meta.activeNode.handleOptions);
|
|
536
|
-
decorations = decorations.add(newState.doc, [decs]);
|
|
537
|
-
}
|
|
538
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
539
|
-
// Remove drop target decoration when dragging stops
|
|
540
|
-
var dropTargetDecs = decorations.find(undefined, undefined, function (spec) {
|
|
541
|
-
return spec.type === 'drop-target-decoration';
|
|
542
|
-
});
|
|
543
|
-
decorations = decorations.remove(dropTargetDecs);
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// Map active node position when the document changes
|
|
547
|
-
var mappedActiveNodePos = tr.docChanged && activeNode ? {
|
|
548
|
-
pos: tr.mapping.map(activeNode.pos),
|
|
549
|
-
anchorName: activeNode.anchorName,
|
|
550
|
-
nodeType: activeNode.nodeType
|
|
551
|
-
} : activeNode;
|
|
552
|
-
var shouldCreateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
|
|
553
|
-
if (api) {
|
|
554
|
-
// Add drop targets when node is being dragged
|
|
555
|
-
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
556
|
-
if (shouldCreateDropTargets) {
|
|
557
|
-
var _meta$activeNode7;
|
|
558
|
-
var _decs = dropTargetDecorations(newState, api, formatMessage, nodeViewPortalProviderAPI, isNestedEnabled ? (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode, anchorRectCache);
|
|
559
|
-
decorations = decorations.add(newState.doc, _decs);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
var isEmptyDoc = isNestedEnabled ? newState.doc.childCount === 1 && newState.doc.nodeSize <= 4 && (newState.doc.firstChild === null || newState.doc.firstChild.nodeSize <= 2) : newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
|
|
563
|
-
if (isEmptyDoc) {
|
|
564
|
-
var hasNodeDecoration = !!decorations.find(undefined, undefined, function (spec) {
|
|
565
|
-
return spec.type === 'node-decoration';
|
|
566
|
-
}).length;
|
|
567
|
-
if (!hasNodeDecoration) {
|
|
568
|
-
decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
var newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && decorations.find(undefined, undefined, function (spec) {
|
|
572
|
-
return spec.type === 'drag-handle';
|
|
573
|
-
}).length === 0 ? null : (_meta$activeNode8 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode8 !== void 0 ? _meta$activeNode8 : mappedActiveNodePos;
|
|
574
|
-
return {
|
|
575
|
-
decorations: decorations,
|
|
576
|
-
activeNode: newActiveNode,
|
|
577
|
-
isDragging: (_meta$isDragging4 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging4 !== void 0 ? _meta$isDragging4 : isDragging,
|
|
578
|
-
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
579
|
-
editorHeight: (_meta$editorHeight2 = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight2 !== void 0 ? _meta$editorHeight2 : currentState.editorHeight,
|
|
580
|
-
editorWidthLeft: (_meta$editorWidthLeft2 = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft2 !== void 0 ? _meta$editorWidthLeft2 : currentState.editorWidthLeft,
|
|
581
|
-
editorWidthRight: (_meta$editorWidthRigh2 = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh2 !== void 0 ? _meta$editorWidthRigh2 : currentState.editorWidthRight,
|
|
582
|
-
isResizerResizing: isResizerResizing,
|
|
583
|
-
isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
|
|
584
|
-
isPMDragging: (_meta$isPMDragging2 = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging2 !== void 0 ? _meta$isPMDragging2 : isPMDragging,
|
|
585
|
-
lastDragCancelled: (_meta$lastDragCancell2 = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell2 !== void 0 ? _meta$lastDragCancell2 : lastDragCancelled
|
|
586
|
-
};
|
|
587
|
-
};
|
|
422
|
+
export { _apply as apply };
|
|
588
423
|
export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI) {
|
|
589
424
|
var _getIntl = getIntl(),
|
|
590
425
|
formatMessage = _getIntl.formatMessage;
|
|
591
|
-
var isNestedEnabled = editorExperiment('nested-dnd', true, {
|
|
592
|
-
exposure: true
|
|
593
|
-
});
|
|
594
426
|
var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
|
|
595
427
|
exposure: true
|
|
596
428
|
});
|
|
@@ -598,7 +430,6 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
598
430
|
exposure: true
|
|
599
431
|
});
|
|
600
432
|
var flags = {
|
|
601
|
-
isNestedEnabled: isNestedEnabled,
|
|
602
433
|
isMultiSelectEnabled: isMultiSelectEnabled
|
|
603
434
|
};
|
|
604
435
|
var anchorRectCache;
|
|
@@ -611,11 +442,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
611
442
|
init: function init() {
|
|
612
443
|
return initialState;
|
|
613
444
|
},
|
|
614
|
-
apply: function apply(tr, currentState,
|
|
615
|
-
|
|
616
|
-
return newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
617
|
-
}
|
|
618
|
-
return oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
445
|
+
apply: function apply(tr, currentState, _, newState) {
|
|
446
|
+
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
619
447
|
}
|
|
620
448
|
},
|
|
621
449
|
props: {
|
|
@@ -509,14 +509,11 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
509
509
|
}, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
|
|
510
510
|
var macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
|
|
511
511
|
var calculatePosition = useCallback(function () {
|
|
512
|
-
var
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
518
|
-
parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
519
|
-
}
|
|
512
|
+
var pos = getPos();
|
|
513
|
+
var $pos = pos && view.state.doc.resolve(pos);
|
|
514
|
+
var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
515
|
+
var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
516
|
+
var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
520
517
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
521
518
|
var safeAnchorName = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2') ? refreshAnchorName({
|
|
522
519
|
getPos: getPos,
|
|
@@ -641,7 +638,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
641
638
|
keymap: dragToMoveDown
|
|
642
639
|
}];
|
|
643
640
|
var isParentNodeOfTypeLayout;
|
|
644
|
-
if (!isTopLevelNode
|
|
641
|
+
if (!isTopLevelNode) {
|
|
645
642
|
var pos = getPos();
|
|
646
643
|
if (typeof pos === 'number') {
|
|
647
644
|
var _$pos$parent;
|