@atlaskit/editor-plugin-block-controls 1.13.3 → 1.13.4
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 +9 -0
- package/dist/cjs/pm-plugins/main.js +32 -18
- package/dist/es2019/pm-plugins/main.js +28 -14
- package/dist/esm/pm-plugins/main.js +32 -18
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.13.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#137646](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/137646)
|
|
8
|
+
[`b287e7d5873b0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b287e7d5873b0) -
|
|
9
|
+
ED-24602 fix re map drop target during collab
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 1.13.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -22,6 +22,9 @@ var _decorations = require("./decorations");
|
|
|
22
22
|
var _handleMouseOver = require("./handle-mouse-over");
|
|
23
23
|
var _keymap = require("./keymap");
|
|
24
24
|
var key = exports.key = new _state.PluginKey('blockControls');
|
|
25
|
+
var isHTMLElement = function isHTMLElement(element) {
|
|
26
|
+
return element instanceof HTMLElement;
|
|
27
|
+
};
|
|
25
28
|
var destroyFn = function destroyFn(api) {
|
|
26
29
|
var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
27
30
|
var cleanupFn = [];
|
|
@@ -36,13 +39,17 @@ var destroyFn = function destroyFn(api) {
|
|
|
36
39
|
return source.data.type === 'element';
|
|
37
40
|
},
|
|
38
41
|
onDragStart: function onDragStart() {
|
|
39
|
-
scrollable
|
|
42
|
+
if (isHTMLElement(scrollable)) {
|
|
43
|
+
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
44
|
+
}
|
|
40
45
|
},
|
|
41
46
|
onDrop: function onDrop(_ref2) {
|
|
42
47
|
var _api$core;
|
|
43
48
|
var location = _ref2.location,
|
|
44
49
|
source = _ref2.source;
|
|
45
|
-
scrollable
|
|
50
|
+
if (isHTMLElement(scrollable)) {
|
|
51
|
+
scrollable.style.setProperty('scroll-behavior', null);
|
|
52
|
+
}
|
|
46
53
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
47
54
|
var tr = _ref3.tr;
|
|
48
55
|
var _ref4 = source.data,
|
|
@@ -101,7 +108,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
101
108
|
return initialState;
|
|
102
109
|
},
|
|
103
110
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
104
|
-
var _meta$activeNode, _meta$activeNode$hand, _activeNodeWithNewNod, _meta$
|
|
111
|
+
var _meta$activeNode, _meta$activeNode$hand, _activeNodeWithNewNod, _meta$activeNode7, _meta$isDragging2, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
105
112
|
var activeNode = currentState.activeNode,
|
|
106
113
|
decorations = currentState.decorations,
|
|
107
114
|
isMenuOpen = currentState.isMenuOpen,
|
|
@@ -151,9 +158,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
151
158
|
}).length;
|
|
152
159
|
var newNodeDecs;
|
|
153
160
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
161
|
+
var _meta$isDragging;
|
|
154
162
|
// naive solution while we work on performance optimised approach under ED-24503
|
|
155
163
|
newNodeDecs = (0, _decorations.nodeDecorations)(newState);
|
|
156
164
|
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newNodeDecs.length;
|
|
165
|
+
isDropTargetsMissing = ((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) && nodeCountChanged;
|
|
157
166
|
} else {
|
|
158
167
|
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
|
|
159
168
|
}
|
|
@@ -196,11 +205,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
196
205
|
if (tr.docChanged && !nodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
|
|
197
206
|
mappedPosisiton = prevMappedPos;
|
|
198
207
|
}
|
|
199
|
-
var
|
|
208
|
+
var _newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
200
209
|
var draghandleDec;
|
|
201
210
|
if (isPerformanceFix) {
|
|
202
211
|
var _meta$activeNode$pos, _meta$activeNode2, _ref9, _meta$activeNode$anch, _meta$activeNode3, _decAtPos$spec, _ref10, _meta$activeNode$node, _meta$activeNode4, _decAtPos$spec2, _meta$activeNode5;
|
|
203
|
-
if (
|
|
212
|
+
if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
|
|
204
213
|
var _oldHandle = decorations.find(undefined, undefined, function (spec) {
|
|
205
214
|
return spec.id === 'drag-handle';
|
|
206
215
|
});
|
|
@@ -213,8 +222,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
213
222
|
} else {
|
|
214
223
|
var nodeType = activeNode.nodeType;
|
|
215
224
|
var anchorName = activeNode.anchorName;
|
|
216
|
-
if (
|
|
217
|
-
nodeType =
|
|
225
|
+
if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
|
|
226
|
+
nodeType = _newActiveNode.type.name;
|
|
218
227
|
anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
|
|
219
228
|
activeNodeWithNewNodeType = {
|
|
220
229
|
pos: prevMappedPos,
|
|
@@ -248,7 +257,10 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
248
257
|
decorations = decorations.add(newState.doc, [_decs]);
|
|
249
258
|
}
|
|
250
259
|
var shouldUpdateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
|
|
251
|
-
|
|
260
|
+
|
|
261
|
+
// During dragging if the the document is updated by remote user, or other processes
|
|
262
|
+
// and update drop target is not required, We remap the drop target.
|
|
263
|
+
var shouldMapDropTargets = (0, _experiments.editorExperiment)('nested-dnd', true) ? !shouldUpdateDropTargets && tr.docChanged && isDragging && !(meta !== null && meta !== void 0 && meta.nodeMoved) : !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) === false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
252
264
|
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
253
265
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
254
266
|
var remainingDecs = decorations.find(undefined, undefined, function (spec) {
|
|
@@ -263,11 +275,19 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
263
275
|
decorations = decorations.remove(dropTargetDecs);
|
|
264
276
|
}
|
|
265
277
|
}
|
|
278
|
+
|
|
279
|
+
// Map active node position when the document changes
|
|
280
|
+
var mappedActiveNodePos = tr.docChanged && activeNode ? !isPerformanceFix && activeNodeWithNewNodeType || {
|
|
281
|
+
pos: tr.mapping.map(activeNode.pos),
|
|
282
|
+
anchorName: activeNode.anchorName,
|
|
283
|
+
nodeType: activeNode.nodeType
|
|
284
|
+
} : activeNode;
|
|
266
285
|
if (api) {
|
|
267
286
|
// Add drop targets when node is being dragged
|
|
268
287
|
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
269
288
|
if (shouldUpdateDropTargets || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
270
|
-
var
|
|
289
|
+
var _meta$activeNode6;
|
|
290
|
+
var _dropTargetDecoration = (0, _decorations.dropTargetDecorations)(newState, api, formatMessage, (0, _experiments.editorExperiment)('nested-dnd', true) ? (_meta$activeNode6 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode6 !== void 0 ? _meta$activeNode6 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode),
|
|
271
291
|
_decs2 = _dropTargetDecoration.decs,
|
|
272
292
|
updatedDecorationState = _dropTargetDecoration.decorationState;
|
|
273
293
|
decorationState = updatedDecorationState;
|
|
@@ -299,18 +319,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
299
319
|
if (!hasNodeDecoration && isEmptyDoc) {
|
|
300
320
|
decorations = decorations.add(newState.doc, [(0, _decorations.emptyParagraphNodeDecorations)()]);
|
|
301
321
|
}
|
|
302
|
-
|
|
303
|
-
// Map active node position when the document changes
|
|
304
|
-
var mappedActiveNodePos = tr.docChanged && activeNode ? !isPerformanceFix && activeNodeWithNewNodeType || {
|
|
305
|
-
pos: tr.mapping.map(activeNode.pos),
|
|
306
|
-
anchorName: activeNode.anchorName,
|
|
307
|
-
nodeType: activeNode.nodeType
|
|
308
|
-
} : activeNode;
|
|
322
|
+
var newActiveNode = isEmptyDoc || isHandleMissing ? null : (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos;
|
|
309
323
|
return {
|
|
310
324
|
decorations: decorations,
|
|
311
325
|
decorationState: decorationState,
|
|
312
|
-
activeNode:
|
|
313
|
-
isDragging: (_meta$
|
|
326
|
+
activeNode: newActiveNode,
|
|
327
|
+
isDragging: (_meta$isDragging2 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging2 !== void 0 ? _meta$isDragging2 : isDragging,
|
|
314
328
|
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
315
329
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
|
|
316
330
|
editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : currentState.editorWidthLeft,
|
|
@@ -14,6 +14,9 @@ import { dragHandleDecoration, dropTargetDecorations, emptyParagraphNodeDecorati
|
|
|
14
14
|
import { handleMouseOver } from './handle-mouse-over';
|
|
15
15
|
import { boundKeydownHandler } from './keymap';
|
|
16
16
|
export const key = new PluginKey('blockControls');
|
|
17
|
+
const isHTMLElement = element => {
|
|
18
|
+
return element instanceof HTMLElement;
|
|
19
|
+
};
|
|
17
20
|
const destroyFn = api => {
|
|
18
21
|
const scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
19
22
|
const cleanupFn = [];
|
|
@@ -27,14 +30,18 @@ const destroyFn = api => {
|
|
|
27
30
|
source
|
|
28
31
|
}) => source.data.type === 'element',
|
|
29
32
|
onDragStart: () => {
|
|
30
|
-
scrollable
|
|
33
|
+
if (isHTMLElement(scrollable)) {
|
|
34
|
+
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
35
|
+
}
|
|
31
36
|
},
|
|
32
37
|
onDrop: ({
|
|
33
38
|
location,
|
|
34
39
|
source
|
|
35
40
|
}) => {
|
|
36
41
|
var _api$core;
|
|
37
|
-
scrollable
|
|
42
|
+
if (isHTMLElement(scrollable)) {
|
|
43
|
+
scrollable.style.setProperty('scroll-behavior', null);
|
|
44
|
+
}
|
|
38
45
|
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
|
|
39
46
|
tr
|
|
40
47
|
}) => {
|
|
@@ -95,7 +102,7 @@ export const createPlugin = (api, getIntl) => {
|
|
|
95
102
|
return initialState;
|
|
96
103
|
},
|
|
97
104
|
apply(tr, currentState, oldState, newState) {
|
|
98
|
-
var _meta$activeNode, _meta$activeNode$hand, _activeNodeWithNewNod, _meta$
|
|
105
|
+
var _meta$activeNode, _meta$activeNode$hand, _activeNodeWithNewNod, _meta$activeNode7, _meta$isDragging2, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
99
106
|
let {
|
|
100
107
|
activeNode,
|
|
101
108
|
decorations,
|
|
@@ -143,9 +150,11 @@ export const createPlugin = (api, getIntl) => {
|
|
|
143
150
|
}) => spec.id !== 'drag-handle').length;
|
|
144
151
|
let newNodeDecs;
|
|
145
152
|
if (editorExperiment('nested-dnd', true)) {
|
|
153
|
+
var _meta$isDragging;
|
|
146
154
|
// naive solution while we work on performance optimised approach under ED-24503
|
|
147
155
|
newNodeDecs = nodeDecorations(newState);
|
|
148
156
|
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newNodeDecs.length;
|
|
157
|
+
isDropTargetsMissing = ((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) && nodeCountChanged;
|
|
149
158
|
} else {
|
|
150
159
|
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
|
|
151
160
|
}
|
|
@@ -229,7 +238,10 @@ export const createPlugin = (api, getIntl) => {
|
|
|
229
238
|
decorations = decorations.add(newState.doc, [decs]);
|
|
230
239
|
}
|
|
231
240
|
const shouldUpdateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
|
|
232
|
-
|
|
241
|
+
|
|
242
|
+
// During dragging if the the document is updated by remote user, or other processes
|
|
243
|
+
// and update drop target is not required, We remap the drop target.
|
|
244
|
+
const shouldMapDropTargets = editorExperiment('nested-dnd', true) ? !shouldUpdateDropTargets && tr.docChanged && isDragging && !(meta !== null && meta !== void 0 && meta.nodeMoved) : !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) === false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
233
245
|
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
234
246
|
if (editorExperiment('nested-dnd', true)) {
|
|
235
247
|
const remainingDecs = decorations.find(undefined, undefined, spec => spec.type !== 'drop-target-decoration');
|
|
@@ -240,14 +252,22 @@ export const createPlugin = (api, getIntl) => {
|
|
|
240
252
|
decorations = decorations.remove(dropTargetDecs);
|
|
241
253
|
}
|
|
242
254
|
}
|
|
255
|
+
|
|
256
|
+
// Map active node position when the document changes
|
|
257
|
+
const mappedActiveNodePos = tr.docChanged && activeNode ? !isPerformanceFix && activeNodeWithNewNodeType || {
|
|
258
|
+
pos: tr.mapping.map(activeNode.pos),
|
|
259
|
+
anchorName: activeNode.anchorName,
|
|
260
|
+
nodeType: activeNode.nodeType
|
|
261
|
+
} : activeNode;
|
|
243
262
|
if (api) {
|
|
244
263
|
// Add drop targets when node is being dragged
|
|
245
264
|
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
246
265
|
if (shouldUpdateDropTargets || isBlocksDragTargetDebug()) {
|
|
266
|
+
var _meta$activeNode6;
|
|
247
267
|
const {
|
|
248
268
|
decs,
|
|
249
269
|
decorationState: updatedDecorationState
|
|
250
|
-
} = dropTargetDecorations(newState, api, formatMessage, meta === null || meta === void 0 ? void 0 : meta.activeNode);
|
|
270
|
+
} = dropTargetDecorations(newState, api, formatMessage, editorExperiment('nested-dnd', true) ? (_meta$activeNode6 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode6 !== void 0 ? _meta$activeNode6 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode);
|
|
251
271
|
decorationState = updatedDecorationState;
|
|
252
272
|
decorations = decorations.add(newState.doc, decs);
|
|
253
273
|
}
|
|
@@ -277,18 +297,12 @@ export const createPlugin = (api, getIntl) => {
|
|
|
277
297
|
if (!hasNodeDecoration && isEmptyDoc) {
|
|
278
298
|
decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
|
|
279
299
|
}
|
|
280
|
-
|
|
281
|
-
// Map active node position when the document changes
|
|
282
|
-
const mappedActiveNodePos = tr.docChanged && activeNode ? !isPerformanceFix && activeNodeWithNewNodeType || {
|
|
283
|
-
pos: tr.mapping.map(activeNode.pos),
|
|
284
|
-
anchorName: activeNode.anchorName,
|
|
285
|
-
nodeType: activeNode.nodeType
|
|
286
|
-
} : activeNode;
|
|
300
|
+
const newActiveNode = isEmptyDoc || isHandleMissing ? null : (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos;
|
|
287
301
|
return {
|
|
288
302
|
decorations,
|
|
289
303
|
decorationState,
|
|
290
|
-
activeNode:
|
|
291
|
-
isDragging: (_meta$
|
|
304
|
+
activeNode: newActiveNode,
|
|
305
|
+
isDragging: (_meta$isDragging2 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging2 !== void 0 ? _meta$isDragging2 : isDragging,
|
|
292
306
|
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
293
307
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
|
|
294
308
|
editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : currentState.editorWidthLeft,
|
|
@@ -15,6 +15,9 @@ import { dragHandleDecoration, dropTargetDecorations, emptyParagraphNodeDecorati
|
|
|
15
15
|
import { handleMouseOver } from './handle-mouse-over';
|
|
16
16
|
import { boundKeydownHandler } from './keymap';
|
|
17
17
|
export var key = new PluginKey('blockControls');
|
|
18
|
+
var isHTMLElement = function isHTMLElement(element) {
|
|
19
|
+
return element instanceof HTMLElement;
|
|
20
|
+
};
|
|
18
21
|
var destroyFn = function destroyFn(api) {
|
|
19
22
|
var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
20
23
|
var cleanupFn = [];
|
|
@@ -29,13 +32,17 @@ var destroyFn = function destroyFn(api) {
|
|
|
29
32
|
return source.data.type === 'element';
|
|
30
33
|
},
|
|
31
34
|
onDragStart: function onDragStart() {
|
|
32
|
-
scrollable
|
|
35
|
+
if (isHTMLElement(scrollable)) {
|
|
36
|
+
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
37
|
+
}
|
|
33
38
|
},
|
|
34
39
|
onDrop: function onDrop(_ref2) {
|
|
35
40
|
var _api$core;
|
|
36
41
|
var location = _ref2.location,
|
|
37
42
|
source = _ref2.source;
|
|
38
|
-
scrollable
|
|
43
|
+
if (isHTMLElement(scrollable)) {
|
|
44
|
+
scrollable.style.setProperty('scroll-behavior', null);
|
|
45
|
+
}
|
|
39
46
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
40
47
|
var tr = _ref3.tr;
|
|
41
48
|
var _ref4 = source.data,
|
|
@@ -94,7 +101,7 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
94
101
|
return initialState;
|
|
95
102
|
},
|
|
96
103
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
97
|
-
var _meta$activeNode, _meta$activeNode$hand, _activeNodeWithNewNod, _meta$
|
|
104
|
+
var _meta$activeNode, _meta$activeNode$hand, _activeNodeWithNewNod, _meta$activeNode7, _meta$isDragging2, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
98
105
|
var activeNode = currentState.activeNode,
|
|
99
106
|
decorations = currentState.decorations,
|
|
100
107
|
isMenuOpen = currentState.isMenuOpen,
|
|
@@ -144,9 +151,11 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
144
151
|
}).length;
|
|
145
152
|
var newNodeDecs;
|
|
146
153
|
if (editorExperiment('nested-dnd', true)) {
|
|
154
|
+
var _meta$isDragging;
|
|
147
155
|
// naive solution while we work on performance optimised approach under ED-24503
|
|
148
156
|
newNodeDecs = nodeDecorations(newState);
|
|
149
157
|
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newNodeDecs.length;
|
|
158
|
+
isDropTargetsMissing = ((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) && nodeCountChanged;
|
|
150
159
|
} else {
|
|
151
160
|
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
|
|
152
161
|
}
|
|
@@ -189,11 +198,11 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
189
198
|
if (tr.docChanged && !nodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
|
|
190
199
|
mappedPosisiton = prevMappedPos;
|
|
191
200
|
}
|
|
192
|
-
var
|
|
201
|
+
var _newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
193
202
|
var draghandleDec;
|
|
194
203
|
if (isPerformanceFix) {
|
|
195
204
|
var _meta$activeNode$pos, _meta$activeNode2, _ref9, _meta$activeNode$anch, _meta$activeNode3, _decAtPos$spec, _ref10, _meta$activeNode$node, _meta$activeNode4, _decAtPos$spec2, _meta$activeNode5;
|
|
196
|
-
if (
|
|
205
|
+
if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
|
|
197
206
|
var _oldHandle = decorations.find(undefined, undefined, function (spec) {
|
|
198
207
|
return spec.id === 'drag-handle';
|
|
199
208
|
});
|
|
@@ -206,8 +215,8 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
206
215
|
} else {
|
|
207
216
|
var nodeType = activeNode.nodeType;
|
|
208
217
|
var anchorName = activeNode.anchorName;
|
|
209
|
-
if (
|
|
210
|
-
nodeType =
|
|
218
|
+
if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
|
|
219
|
+
nodeType = _newActiveNode.type.name;
|
|
211
220
|
anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
|
|
212
221
|
activeNodeWithNewNodeType = {
|
|
213
222
|
pos: prevMappedPos,
|
|
@@ -241,7 +250,10 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
241
250
|
decorations = decorations.add(newState.doc, [_decs]);
|
|
242
251
|
}
|
|
243
252
|
var shouldUpdateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
|
|
244
|
-
|
|
253
|
+
|
|
254
|
+
// During dragging if the the document is updated by remote user, or other processes
|
|
255
|
+
// and update drop target is not required, We remap the drop target.
|
|
256
|
+
var shouldMapDropTargets = editorExperiment('nested-dnd', true) ? !shouldUpdateDropTargets && tr.docChanged && isDragging && !(meta !== null && meta !== void 0 && meta.nodeMoved) : !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) === false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
245
257
|
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
246
258
|
if (editorExperiment('nested-dnd', true)) {
|
|
247
259
|
var remainingDecs = decorations.find(undefined, undefined, function (spec) {
|
|
@@ -256,11 +268,19 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
256
268
|
decorations = decorations.remove(dropTargetDecs);
|
|
257
269
|
}
|
|
258
270
|
}
|
|
271
|
+
|
|
272
|
+
// Map active node position when the document changes
|
|
273
|
+
var mappedActiveNodePos = tr.docChanged && activeNode ? !isPerformanceFix && activeNodeWithNewNodeType || {
|
|
274
|
+
pos: tr.mapping.map(activeNode.pos),
|
|
275
|
+
anchorName: activeNode.anchorName,
|
|
276
|
+
nodeType: activeNode.nodeType
|
|
277
|
+
} : activeNode;
|
|
259
278
|
if (api) {
|
|
260
279
|
// Add drop targets when node is being dragged
|
|
261
280
|
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
262
281
|
if (shouldUpdateDropTargets || isBlocksDragTargetDebug()) {
|
|
263
|
-
var
|
|
282
|
+
var _meta$activeNode6;
|
|
283
|
+
var _dropTargetDecoration = dropTargetDecorations(newState, api, formatMessage, editorExperiment('nested-dnd', true) ? (_meta$activeNode6 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode6 !== void 0 ? _meta$activeNode6 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode),
|
|
264
284
|
_decs2 = _dropTargetDecoration.decs,
|
|
265
285
|
updatedDecorationState = _dropTargetDecoration.decorationState;
|
|
266
286
|
decorationState = updatedDecorationState;
|
|
@@ -292,18 +312,12 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
292
312
|
if (!hasNodeDecoration && isEmptyDoc) {
|
|
293
313
|
decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
|
|
294
314
|
}
|
|
295
|
-
|
|
296
|
-
// Map active node position when the document changes
|
|
297
|
-
var mappedActiveNodePos = tr.docChanged && activeNode ? !isPerformanceFix && activeNodeWithNewNodeType || {
|
|
298
|
-
pos: tr.mapping.map(activeNode.pos),
|
|
299
|
-
anchorName: activeNode.anchorName,
|
|
300
|
-
nodeType: activeNode.nodeType
|
|
301
|
-
} : activeNode;
|
|
315
|
+
var newActiveNode = isEmptyDoc || isHandleMissing ? null : (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos;
|
|
302
316
|
return {
|
|
303
317
|
decorations: decorations,
|
|
304
318
|
decorationState: decorationState,
|
|
305
|
-
activeNode:
|
|
306
|
-
isDragging: (_meta$
|
|
319
|
+
activeNode: newActiveNode,
|
|
320
|
+
isDragging: (_meta$isDragging2 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging2 !== void 0 ? _meta$isDragging2 : isDragging,
|
|
307
321
|
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
308
322
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
|
|
309
323
|
editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : currentState.editorWidthLeft,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.4",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
".": "./src/index.ts"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@atlaskit/editor-common": "^88.
|
|
33
|
+
"@atlaskit/editor-common": "^88.13.0",
|
|
34
34
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
36
36
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|