@atlaskit/editor-plugin-block-controls 1.10.6 → 1.10.7
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 +10 -0
- package/dist/cjs/pm-plugins/decorations.js +9 -14
- package/dist/cjs/pm-plugins/main.js +56 -116
- package/dist/cjs/ui/drag-handle.js +5 -14
- package/dist/cjs/ui/drop-target.js +0 -4
- package/dist/cjs/utils/drag-target-debug.js +1 -1
- package/dist/es2019/pm-plugins/decorations.js +9 -14
- package/dist/es2019/pm-plugins/main.js +52 -111
- package/dist/es2019/ui/drag-handle.js +5 -14
- package/dist/es2019/ui/drop-target.js +0 -4
- package/dist/es2019/utils/drag-target-debug.js +1 -1
- package/dist/esm/pm-plugins/decorations.js +9 -14
- package/dist/esm/pm-plugins/main.js +56 -116
- package/dist/esm/ui/drag-handle.js +6 -15
- package/dist/esm/ui/drop-target.js +0 -4
- package/dist/esm/utils/drag-target-debug.js +1 -1
- package/package.json +4 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.10.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7c744eaad4fb6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7c744eaad4fb6) -
|
|
8
|
+
ED-24473 Clean up FF in drag-handle and drop-targets
|
|
9
|
+
- [#127997](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/127997)
|
|
10
|
+
[`3d47f12053750`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3d47f12053750) -
|
|
11
|
+
ED-24404 ignore list items in Element DnD
|
|
12
|
+
|
|
3
13
|
## 1.10.6
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -15,7 +15,8 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
15
15
|
var _dragHandle = require("../ui/drag-handle");
|
|
16
16
|
var _dropTarget = require("../ui/drop-target");
|
|
17
17
|
var _validation = require("../utils/validation");
|
|
18
|
-
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn'];
|
|
18
|
+
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem'];
|
|
19
|
+
var IGNORE_NODES_AND_DESCENDANTS = ['listItem'];
|
|
19
20
|
var NESTED_DEPTH = (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
20
21
|
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(oldState, newState, api, formatMessage, activeNodeType) {
|
|
21
22
|
var decs = [];
|
|
@@ -24,8 +25,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
24
25
|
// and allows us to easily map the updated position in the plugin apply method.
|
|
25
26
|
var decorationState = [];
|
|
26
27
|
var prevNode;
|
|
27
|
-
|
|
28
|
-
state.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
|
|
28
|
+
newState.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
|
|
29
29
|
var depth = 0;
|
|
30
30
|
var nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
31
31
|
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
@@ -121,12 +121,13 @@ var emptyParagraphNodeDecorations = exports.emptyParagraphNodeDecorations = func
|
|
|
121
121
|
};
|
|
122
122
|
var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newState) {
|
|
123
123
|
var decs = [];
|
|
124
|
-
newState.doc.descendants(function (node, pos,
|
|
124
|
+
newState.doc.descendants(function (node, pos, parent, index) {
|
|
125
125
|
var _Decoration$node2;
|
|
126
126
|
var depth = 0;
|
|
127
127
|
var anchorName;
|
|
128
128
|
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
129
|
-
|
|
129
|
+
// Doesn't descend into a node
|
|
130
|
+
if (node.isInline || IGNORE_NODES_AND_DESCENDANTS.includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '')) {
|
|
130
131
|
return false;
|
|
131
132
|
}
|
|
132
133
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
@@ -148,9 +149,8 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
|
|
|
148
149
|
};
|
|
149
150
|
var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(api, getIntl, pos, anchorName, nodeType, handleOptions) {
|
|
150
151
|
var unbind;
|
|
151
|
-
var elementType = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24150') ? 'span' : 'div';
|
|
152
152
|
return _view.Decoration.widget(pos, function (view, getPos) {
|
|
153
|
-
var element = document.createElement(
|
|
153
|
+
var element = document.createElement('span');
|
|
154
154
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
155
155
|
element.style.display = 'inline';
|
|
156
156
|
element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
|
|
@@ -163,9 +163,7 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
|
|
167
|
-
unmountDecorations('data-blocks-drag-handle-container');
|
|
168
|
-
}
|
|
166
|
+
unmountDecorations('data-blocks-drag-handle-container');
|
|
169
167
|
|
|
170
168
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
171
169
|
// due to margins applied to other nodes eg. Headings
|
|
@@ -184,13 +182,10 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
184
182
|
}, {
|
|
185
183
|
side: -1,
|
|
186
184
|
id: 'drag-handle',
|
|
187
|
-
destroy: function destroy(
|
|
185
|
+
destroy: function destroy() {
|
|
188
186
|
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
189
187
|
unbind && unbind();
|
|
190
188
|
}
|
|
191
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
192
|
-
_reactDom.default.unmountComponentAtNode(node);
|
|
193
|
-
}
|
|
194
189
|
}
|
|
195
190
|
});
|
|
196
191
|
};
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.key = exports.createPlugin = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
10
|
-
var _steps = require("@atlaskit/adf-schema/steps");
|
|
11
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -93,7 +92,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
93
92
|
return initialState;
|
|
94
93
|
},
|
|
95
94
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
96
|
-
var _meta$activeNode, _meta$activeNode$hand, _meta$
|
|
95
|
+
var _meta$activeNode, _meta$activeNode$hand, _activeNodeWithNewNod, _meta$activeNode3, _meta$isDragging, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
97
96
|
var activeNode = currentState.activeNode,
|
|
98
97
|
decorations = currentState.decorations,
|
|
99
98
|
isMenuOpen = currentState.isMenuOpen,
|
|
@@ -106,20 +105,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
106
105
|
isPMDragging = currentState.isPMDragging;
|
|
107
106
|
var activeNodeWithNewNodeType = null;
|
|
108
107
|
var meta = tr.getMeta(key);
|
|
109
|
-
// when creating analytics during drag/drop events, PM thinks the doc has changed
|
|
110
|
-
// so tr.docChange is true and causes some decorations to not render
|
|
111
|
-
var isAnalyticTr = tr.steps.every(function (step) {
|
|
112
|
-
return step instanceof _steps.AnalyticsStep;
|
|
113
|
-
});
|
|
114
108
|
|
|
115
109
|
// If tables or media are being resized, we want to hide the drag handle
|
|
116
110
|
var resizerMeta = tr.getMeta('is-resizer-resizing');
|
|
117
111
|
isResizerResizing = resizerMeta !== null && resizerMeta !== void 0 ? resizerMeta : isResizerResizing;
|
|
118
112
|
var nodeCountChanged = oldState.doc.childCount !== newState.doc.childCount;
|
|
119
|
-
var shouldRemoveHandle =
|
|
120
|
-
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_24000')) {
|
|
121
|
-
shouldRemoveHandle = !tr.getMeta('isRemote');
|
|
122
|
-
}
|
|
113
|
+
var shouldRemoveHandle = !tr.getMeta('isRemote');
|
|
123
114
|
|
|
124
115
|
// During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
|
|
125
116
|
// Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
|
|
@@ -147,16 +138,14 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
147
138
|
if (!(0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
148
139
|
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
|
|
149
140
|
}
|
|
150
|
-
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}).length;
|
|
141
|
+
var dropTargetLen = decorations.find().filter(function (_ref8) {
|
|
142
|
+
var spec = _ref8.spec;
|
|
143
|
+
return spec.type === 'drop-target-decoration';
|
|
144
|
+
}).length;
|
|
155
145
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
146
|
+
//TODO: Fix this logic for nested scenarios
|
|
147
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
148
|
+
isDropTargetsMissing = isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && dropTargetLen !== newState.doc.childCount + 1;
|
|
160
149
|
}
|
|
161
150
|
|
|
162
151
|
// This is not targeted enough - it's trying to catch events like expand being set to breakout
|
|
@@ -227,90 +216,50 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
227
216
|
var decs = (0, _decorations.dragHandleDecoration)(api, getIntl, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, meta.activeNode.handleOptions);
|
|
228
217
|
decorations = decorations.add(newState.doc, [decs]);
|
|
229
218
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
var
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
decorations = decorations.add(newState.doc, [_decs]);
|
|
241
|
-
}
|
|
219
|
+
|
|
220
|
+
// Remove previous drag handle widget and draw new drag handle widget when node type changes
|
|
221
|
+
if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
|
|
222
|
+
var _oldHandle2 = decorations.find().filter(function (_ref11) {
|
|
223
|
+
var spec = _ref11.spec;
|
|
224
|
+
return spec.id === 'drag-handle';
|
|
225
|
+
});
|
|
226
|
+
decorations = decorations.remove(_oldHandle2);
|
|
227
|
+
var _decs = (0, _decorations.dragHandleDecoration)(api, getIntl, activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType);
|
|
228
|
+
decorations = decorations.add(newState.doc, [_decs]);
|
|
242
229
|
}
|
|
243
230
|
var shouldUpdateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
|
|
244
|
-
var shouldMapDropTargets = false;
|
|
245
|
-
if ((0
|
|
246
|
-
shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
247
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
248
|
-
// Remove drop target decoration when dragging stops
|
|
249
|
-
var dropTargetDecs = decorations.find().filter(function (_ref12) {
|
|
250
|
-
var spec = _ref12.spec;
|
|
251
|
-
return spec.type === 'drop-target-decoration';
|
|
252
|
-
});
|
|
253
|
-
decorations = decorations.remove(dropTargetDecs);
|
|
254
|
-
}
|
|
255
|
-
if (api) {
|
|
256
|
-
// Add drop targets when node is being dragged
|
|
257
|
-
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
258
|
-
if (shouldUpdateDropTargets || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
259
|
-
var _meta$activeNode2;
|
|
260
|
-
var _dropTargetDecoration = (0, _decorations.dropTargetDecorations)(oldState, newState, api, formatMessage, meta === null || meta === void 0 || (_meta$activeNode2 = meta.activeNode) === null || _meta$activeNode2 === void 0 ? void 0 : _meta$activeNode2.nodeType),
|
|
261
|
-
_decs2 = _dropTargetDecoration.decs,
|
|
262
|
-
updatedDecorationState = _dropTargetDecoration.decorationState;
|
|
263
|
-
decorationState = updatedDecorationState;
|
|
264
|
-
decorations = decorations.add(newState.doc, _decs2);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
//Map drop target decoration positions when the document changes
|
|
269
|
-
if (shouldMapDropTargets) {
|
|
270
|
-
decorationState = decorationState.map(function (_ref13) {
|
|
271
|
-
var id = _ref13.id,
|
|
272
|
-
pos = _ref13.pos;
|
|
273
|
-
return {
|
|
274
|
-
id: id,
|
|
275
|
-
pos: tr.mapping.map(pos)
|
|
276
|
-
};
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
} else {
|
|
280
|
-
if (api) {
|
|
281
|
-
// Add drop targets when node is being dragged
|
|
282
|
-
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
283
|
-
var shouldShowDragTarget = (meta === null || meta === void 0 ? void 0 : meta.isDragging) && (!tr.docChanged || tr.docChanged && isAnalyticTr);
|
|
284
|
-
if (shouldShowDragTarget || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
285
|
-
var _meta$activeNode3;
|
|
286
|
-
var _dropTargetDecoration2 = (0, _decorations.dropTargetDecorations)(oldState, newState, api, formatMessage, meta === null || meta === void 0 || (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.nodeType),
|
|
287
|
-
_decs3 = _dropTargetDecoration2.decs,
|
|
288
|
-
_updatedDecorationState = _dropTargetDecoration2.decorationState;
|
|
289
|
-
decorationState = _updatedDecorationState;
|
|
290
|
-
decorations = decorations.add(newState.doc, _decs3);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
231
|
+
var shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
232
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
294
233
|
// Remove drop target decoration when dragging stops
|
|
295
|
-
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
234
|
+
var dropTargetDecs = decorations.find().filter(function (_ref12) {
|
|
235
|
+
var spec = _ref12.spec;
|
|
236
|
+
return spec.type === 'drop-target-decoration';
|
|
237
|
+
});
|
|
238
|
+
decorations = decorations.remove(dropTargetDecs);
|
|
239
|
+
}
|
|
240
|
+
if (api) {
|
|
241
|
+
// Add drop targets when node is being dragged
|
|
242
|
+
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
243
|
+
if (shouldUpdateDropTargets || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
244
|
+
var _meta$activeNode2;
|
|
245
|
+
var _dropTargetDecoration = (0, _decorations.dropTargetDecorations)(oldState, newState, api, formatMessage, meta === null || meta === void 0 || (_meta$activeNode2 = meta.activeNode) === null || _meta$activeNode2 === void 0 ? void 0 : _meta$activeNode2.nodeType),
|
|
246
|
+
_decs2 = _dropTargetDecoration.decs,
|
|
247
|
+
updatedDecorationState = _dropTargetDecoration.decorationState;
|
|
248
|
+
decorationState = updatedDecorationState;
|
|
249
|
+
decorations = decorations.add(newState.doc, _decs2);
|
|
301
250
|
}
|
|
251
|
+
}
|
|
302
252
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
253
|
+
//Map drop target decoration positions when the document changes
|
|
254
|
+
if (shouldMapDropTargets) {
|
|
255
|
+
decorationState = decorationState.map(function (_ref13) {
|
|
256
|
+
var id = _ref13.id,
|
|
257
|
+
pos = _ref13.pos;
|
|
258
|
+
return {
|
|
259
|
+
id: id,
|
|
260
|
+
pos: tr.mapping.map(pos)
|
|
261
|
+
};
|
|
262
|
+
});
|
|
314
263
|
}
|
|
315
264
|
|
|
316
265
|
// Map decorations if document changes and node decorations do not need to be redrawn
|
|
@@ -318,8 +267,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
318
267
|
decorations = decorations.map(tr.mapping, tr.doc);
|
|
319
268
|
}
|
|
320
269
|
var isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
|
|
321
|
-
var hasNodeDecoration = decorations.find().some(function (
|
|
322
|
-
var spec =
|
|
270
|
+
var hasNodeDecoration = decorations.find().some(function (_ref14) {
|
|
271
|
+
var spec = _ref14.spec;
|
|
323
272
|
return spec.type === 'node-decoration';
|
|
324
273
|
});
|
|
325
274
|
if (!hasNodeDecoration && isEmptyDoc) {
|
|
@@ -327,24 +276,15 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
327
276
|
}
|
|
328
277
|
|
|
329
278
|
// Map active node position when the document changes
|
|
330
|
-
var mappedActiveNodePos
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
nodeType: activeNode.nodeType
|
|
336
|
-
} : activeNode;
|
|
337
|
-
} else {
|
|
338
|
-
mappedActiveNodePos = tr.docChanged && activeNode ? {
|
|
339
|
-
pos: tr.mapping.map(activeNode.pos),
|
|
340
|
-
anchorName: activeNode.anchorName,
|
|
341
|
-
nodeType: activeNode.nodeType
|
|
342
|
-
} : activeNode;
|
|
343
|
-
}
|
|
279
|
+
var mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
|
|
280
|
+
pos: tr.mapping.map(activeNode.pos),
|
|
281
|
+
anchorName: activeNode.anchorName,
|
|
282
|
+
nodeType: activeNode.nodeType
|
|
283
|
+
} : activeNode;
|
|
344
284
|
return {
|
|
345
285
|
decorations: decorations,
|
|
346
286
|
decorationState: decorationState,
|
|
347
|
-
activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$
|
|
287
|
+
activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$activeNode3 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode3 !== void 0 ? _meta$activeNode3 : mappedActiveNodePos,
|
|
348
288
|
isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
|
|
349
289
|
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
350
290
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
|
|
@@ -287,12 +287,9 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
287
287
|
display: 'none'
|
|
288
288
|
}),
|
|
289
289
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
positionStyles = _useState6[0],
|
|
291
|
+
setPositionStyles = _useState6[1];
|
|
292
292
|
(0, _react.useEffect)(function () {
|
|
293
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
293
|
var cleanUpTransitionListener;
|
|
297
294
|
if (nodeType === 'extension' || nodeType === 'embedCard') {
|
|
298
295
|
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
@@ -302,12 +299,12 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
302
299
|
cleanUpTransitionListener = (0, _bindEventListener.bind)(dom, {
|
|
303
300
|
type: 'transitionend',
|
|
304
301
|
listener: function listener() {
|
|
305
|
-
|
|
302
|
+
setPositionStyles(calculatePosition());
|
|
306
303
|
}
|
|
307
304
|
});
|
|
308
305
|
}
|
|
309
306
|
var calcPos = requestAnimationFrame(function () {
|
|
310
|
-
|
|
307
|
+
setPositionStyles(calculatePosition());
|
|
311
308
|
});
|
|
312
309
|
return function () {
|
|
313
310
|
var _cleanUpTransitionLis;
|
|
@@ -315,12 +312,6 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
315
312
|
(_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
|
|
316
313
|
};
|
|
317
314
|
}, [calculatePosition, view.dom, anchorName, nodeType]);
|
|
318
|
-
var positionStyles = (0, _react.useMemo)(function () {
|
|
319
|
-
if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
320
|
-
return newPositionStyles;
|
|
321
|
-
}
|
|
322
|
-
return calculatePosition();
|
|
323
|
-
}, [calculatePosition, newPositionStyles]);
|
|
324
315
|
(0, _react.useEffect)(function () {
|
|
325
316
|
if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
326
317
|
var id = requestAnimationFrame(function () {
|
|
@@ -354,7 +345,7 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
354
345
|
ref: buttonRef
|
|
355
346
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
356
347
|
,
|
|
357
|
-
style:
|
|
348
|
+
style: positionStyles,
|
|
358
349
|
onClick: handleOnClick,
|
|
359
350
|
onMouseDown: handleMouseDown,
|
|
360
351
|
onKeyDown: handleKeyDown,
|
|
@@ -9,7 +9,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _react2 = require("@emotion/react");
|
|
11
11
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
12
|
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
14
13
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
15
14
|
var _constants = require("@atlaskit/theme/constants");
|
|
@@ -54,9 +53,6 @@ var getNodeMargins = function getNodeMargins(node) {
|
|
|
54
53
|
return _consts.nodeMargins[nodeTypeName] || _consts.nodeMargins['default'];
|
|
55
54
|
};
|
|
56
55
|
var getDropTargetPositionStyle = function getDropTargetPositionStyle(prevNode, nextNode) {
|
|
57
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_gap_fix')) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
56
|
if (!prevNode || !nextNode) {
|
|
61
57
|
return null;
|
|
62
58
|
}
|
|
@@ -7,5 +7,5 @@ exports.isBlocksDragTargetDebug = void 0;
|
|
|
7
7
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
8
|
var IS_GEMINI_TEST_ENV = Boolean(process.env.NODE_ENV === 'development') && Boolean(window.__gemini_set_feature_flag__);
|
|
9
9
|
var isBlocksDragTargetDebug = exports.isBlocksDragTargetDebug = function isBlocksDragTargetDebug() {
|
|
10
|
-
return IS_GEMINI_TEST_ENV && (0, _platformFeatureFlags.fg)('
|
|
10
|
+
return IS_GEMINI_TEST_ENV && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_debug');
|
|
11
11
|
};
|
|
@@ -7,7 +7,8 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
7
7
|
import { DragHandle } from '../ui/drag-handle';
|
|
8
8
|
import { DropTarget } from '../ui/drop-target';
|
|
9
9
|
import { canMoveToIndex } from '../utils/validation';
|
|
10
|
-
const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn'];
|
|
10
|
+
const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem'];
|
|
11
|
+
const IGNORE_NODES_AND_DESCENDANTS = ['listItem'];
|
|
11
12
|
const NESTED_DEPTH = fg('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
12
13
|
export const dropTargetDecorations = (oldState, newState, api, formatMessage, activeNodeType) => {
|
|
13
14
|
const decs = [];
|
|
@@ -16,8 +17,7 @@ export const dropTargetDecorations = (oldState, newState, api, formatMessage, ac
|
|
|
16
17
|
// and allows us to easily map the updated position in the plugin apply method.
|
|
17
18
|
const decorationState = [];
|
|
18
19
|
let prevNode;
|
|
19
|
-
|
|
20
|
-
state.doc.nodesBetween(0, newState.doc.nodeSize - 2, (node, pos, parent, index) => {
|
|
20
|
+
newState.doc.nodesBetween(0, newState.doc.nodeSize - 2, (node, pos, parent, index) => {
|
|
21
21
|
let depth = 0;
|
|
22
22
|
const nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
23
23
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
@@ -114,11 +114,12 @@ export const emptyParagraphNodeDecorations = () => {
|
|
|
114
114
|
};
|
|
115
115
|
export const nodeDecorations = newState => {
|
|
116
116
|
const decs = [];
|
|
117
|
-
newState.doc.descendants((node, pos,
|
|
117
|
+
newState.doc.descendants((node, pos, parent, index) => {
|
|
118
118
|
let depth = 0;
|
|
119
119
|
let anchorName;
|
|
120
120
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
121
|
-
|
|
121
|
+
// Doesn't descend into a node
|
|
122
|
+
if (node.isInline || IGNORE_NODES_AND_DESCENDANTS.includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '')) {
|
|
122
123
|
return false;
|
|
123
124
|
}
|
|
124
125
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
@@ -143,9 +144,8 @@ export const nodeDecorations = newState => {
|
|
|
143
144
|
};
|
|
144
145
|
export const dragHandleDecoration = (api, getIntl, pos, anchorName, nodeType, handleOptions) => {
|
|
145
146
|
let unbind;
|
|
146
|
-
const elementType = fg('platform_editor_element_drag_and_drop_ed_24150') ? 'span' : 'div';
|
|
147
147
|
return Decoration.widget(pos, (view, getPos) => {
|
|
148
|
-
const element = document.createElement(
|
|
148
|
+
const element = document.createElement('span');
|
|
149
149
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
150
150
|
element.style.display = 'inline';
|
|
151
151
|
element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
|
|
@@ -158,9 +158,7 @@ export const dragHandleDecoration = (api, getIntl, pos, anchorName, nodeType, ha
|
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
unmountDecorations('data-blocks-drag-handle-container');
|
|
163
|
-
}
|
|
161
|
+
unmountDecorations('data-blocks-drag-handle-container');
|
|
164
162
|
|
|
165
163
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
166
164
|
// due to margins applied to other nodes eg. Headings
|
|
@@ -179,13 +177,10 @@ export const dragHandleDecoration = (api, getIntl, pos, anchorName, nodeType, ha
|
|
|
179
177
|
}, {
|
|
180
178
|
side: -1,
|
|
181
179
|
id: 'drag-handle',
|
|
182
|
-
destroy:
|
|
180
|
+
destroy: () => {
|
|
183
181
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
184
182
|
unbind && unbind();
|
|
185
183
|
}
|
|
186
|
-
if (!fg('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
187
|
-
ReactDOM.unmountComponentAtNode(node);
|
|
188
|
-
}
|
|
189
184
|
}
|
|
190
185
|
});
|
|
191
186
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import rafSchedule from 'raf-schd';
|
|
2
|
-
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
3
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
4
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
@@ -87,7 +86,7 @@ export const createPlugin = (api, getIntl) => {
|
|
|
87
86
|
return initialState;
|
|
88
87
|
},
|
|
89
88
|
apply(tr, currentState, oldState, newState) {
|
|
90
|
-
var _meta$activeNode, _meta$activeNode$hand, _meta$
|
|
89
|
+
var _meta$activeNode, _meta$activeNode$hand, _activeNodeWithNewNod, _meta$activeNode3, _meta$isDragging, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
91
90
|
let {
|
|
92
91
|
activeNode,
|
|
93
92
|
decorations,
|
|
@@ -102,18 +101,12 @@ export const createPlugin = (api, getIntl) => {
|
|
|
102
101
|
} = currentState;
|
|
103
102
|
let activeNodeWithNewNodeType = null;
|
|
104
103
|
const meta = tr.getMeta(key);
|
|
105
|
-
// when creating analytics during drag/drop events, PM thinks the doc has changed
|
|
106
|
-
// so tr.docChange is true and causes some decorations to not render
|
|
107
|
-
const isAnalyticTr = tr.steps.every(step => step instanceof AnalyticsStep);
|
|
108
104
|
|
|
109
105
|
// If tables or media are being resized, we want to hide the drag handle
|
|
110
106
|
const resizerMeta = tr.getMeta('is-resizer-resizing');
|
|
111
107
|
isResizerResizing = resizerMeta !== null && resizerMeta !== void 0 ? resizerMeta : isResizerResizing;
|
|
112
108
|
const nodeCountChanged = oldState.doc.childCount !== newState.doc.childCount;
|
|
113
|
-
|
|
114
|
-
if (fg('platform_editor_elements_drag_and_drop_ed_24000')) {
|
|
115
|
-
shouldRemoveHandle = !tr.getMeta('isRemote');
|
|
116
|
-
}
|
|
109
|
+
const shouldRemoveHandle = !tr.getMeta('isRemote');
|
|
117
110
|
|
|
118
111
|
// During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
|
|
119
112
|
// Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
|
|
@@ -138,15 +131,13 @@ export const createPlugin = (api, getIntl) => {
|
|
|
138
131
|
if (!fg('platform_editor_elements_dnd_nested')) {
|
|
139
132
|
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
|
|
140
133
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}) => spec.type === 'drop-target-decoration').length;
|
|
134
|
+
const dropTargetLen = decorations.find().filter(({
|
|
135
|
+
spec
|
|
136
|
+
}) => spec.type === 'drop-target-decoration').length;
|
|
145
137
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
138
|
+
//TODO: Fix this logic for nested scenarios
|
|
139
|
+
if (!fg('platform_editor_elements_dnd_nested')) {
|
|
140
|
+
isDropTargetsMissing = isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && dropTargetLen !== newState.doc.childCount + 1;
|
|
150
141
|
}
|
|
151
142
|
|
|
152
143
|
// This is not targeted enough - it's trying to catch events like expand being set to breakout
|
|
@@ -216,91 +207,50 @@ export const createPlugin = (api, getIntl) => {
|
|
|
216
207
|
const decs = dragHandleDecoration(api, getIntl, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, meta.activeNode.handleOptions);
|
|
217
208
|
decorations = decorations.add(newState.doc, [decs]);
|
|
218
209
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
decorations = decorations.add(newState.doc, [decs]);
|
|
229
|
-
}
|
|
210
|
+
|
|
211
|
+
// Remove previous drag handle widget and draw new drag handle widget when node type changes
|
|
212
|
+
if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
|
|
213
|
+
const oldHandle = decorations.find().filter(({
|
|
214
|
+
spec
|
|
215
|
+
}) => spec.id === 'drag-handle');
|
|
216
|
+
decorations = decorations.remove(oldHandle);
|
|
217
|
+
const decs = dragHandleDecoration(api, getIntl, activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType);
|
|
218
|
+
decorations = decorations.add(newState.doc, [decs]);
|
|
230
219
|
}
|
|
231
220
|
const shouldUpdateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
|
|
232
|
-
|
|
233
|
-
if (
|
|
234
|
-
shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
235
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
236
|
-
// Remove drop target decoration when dragging stops
|
|
237
|
-
const dropTargetDecs = decorations.find().filter(({
|
|
238
|
-
spec
|
|
239
|
-
}) => spec.type === 'drop-target-decoration');
|
|
240
|
-
decorations = decorations.remove(dropTargetDecs);
|
|
241
|
-
}
|
|
242
|
-
if (api) {
|
|
243
|
-
// Add drop targets when node is being dragged
|
|
244
|
-
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
245
|
-
if (shouldUpdateDropTargets || isBlocksDragTargetDebug()) {
|
|
246
|
-
var _meta$activeNode2;
|
|
247
|
-
const {
|
|
248
|
-
decs,
|
|
249
|
-
decorationState: updatedDecorationState
|
|
250
|
-
} = dropTargetDecorations(oldState, newState, api, formatMessage, meta === null || meta === void 0 ? void 0 : (_meta$activeNode2 = meta.activeNode) === null || _meta$activeNode2 === void 0 ? void 0 : _meta$activeNode2.nodeType);
|
|
251
|
-
decorationState = updatedDecorationState;
|
|
252
|
-
decorations = decorations.add(newState.doc, decs);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
//Map drop target decoration positions when the document changes
|
|
257
|
-
if (shouldMapDropTargets) {
|
|
258
|
-
decorationState = decorationState.map(({
|
|
259
|
-
id,
|
|
260
|
-
pos
|
|
261
|
-
}) => {
|
|
262
|
-
return {
|
|
263
|
-
id,
|
|
264
|
-
pos: tr.mapping.map(pos)
|
|
265
|
-
};
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
} else {
|
|
269
|
-
if (api) {
|
|
270
|
-
// Add drop targets when node is being dragged
|
|
271
|
-
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
272
|
-
const shouldShowDragTarget = (meta === null || meta === void 0 ? void 0 : meta.isDragging) && (!tr.docChanged || tr.docChanged && isAnalyticTr);
|
|
273
|
-
if (shouldShowDragTarget || isBlocksDragTargetDebug()) {
|
|
274
|
-
var _meta$activeNode3;
|
|
275
|
-
const {
|
|
276
|
-
decs,
|
|
277
|
-
decorationState: updatedDecorationState
|
|
278
|
-
} = dropTargetDecorations(oldState, newState, api, formatMessage, meta === null || meta === void 0 ? void 0 : (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.nodeType);
|
|
279
|
-
decorationState = updatedDecorationState;
|
|
280
|
-
decorations = decorations.add(newState.doc, decs);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
221
|
+
const shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
222
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
284
223
|
// Remove drop target decoration when dragging stops
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
224
|
+
const dropTargetDecs = decorations.find().filter(({
|
|
225
|
+
spec
|
|
226
|
+
}) => spec.type === 'drop-target-decoration');
|
|
227
|
+
decorations = decorations.remove(dropTargetDecs);
|
|
228
|
+
}
|
|
229
|
+
if (api) {
|
|
230
|
+
// Add drop targets when node is being dragged
|
|
231
|
+
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
232
|
+
if (shouldUpdateDropTargets || isBlocksDragTargetDebug()) {
|
|
233
|
+
var _meta$activeNode2;
|
|
234
|
+
const {
|
|
235
|
+
decs,
|
|
236
|
+
decorationState: updatedDecorationState
|
|
237
|
+
} = dropTargetDecorations(oldState, newState, api, formatMessage, meta === null || meta === void 0 ? void 0 : (_meta$activeNode2 = meta.activeNode) === null || _meta$activeNode2 === void 0 ? void 0 : _meta$activeNode2.nodeType);
|
|
238
|
+
decorationState = updatedDecorationState;
|
|
239
|
+
decorations = decorations.add(newState.doc, decs);
|
|
290
240
|
}
|
|
241
|
+
}
|
|
291
242
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
243
|
+
//Map drop target decoration positions when the document changes
|
|
244
|
+
if (shouldMapDropTargets) {
|
|
245
|
+
decorationState = decorationState.map(({
|
|
246
|
+
id,
|
|
247
|
+
pos
|
|
248
|
+
}) => {
|
|
249
|
+
return {
|
|
295
250
|
id,
|
|
296
|
-
pos
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
id,
|
|
300
|
-
pos: tr.mapping.map(pos)
|
|
301
|
-
};
|
|
302
|
-
});
|
|
303
|
-
}
|
|
251
|
+
pos: tr.mapping.map(pos)
|
|
252
|
+
};
|
|
253
|
+
});
|
|
304
254
|
}
|
|
305
255
|
|
|
306
256
|
// Map decorations if document changes and node decorations do not need to be redrawn
|
|
@@ -316,24 +266,15 @@ export const createPlugin = (api, getIntl) => {
|
|
|
316
266
|
}
|
|
317
267
|
|
|
318
268
|
// Map active node position when the document changes
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
nodeType: activeNode.nodeType
|
|
325
|
-
} : activeNode;
|
|
326
|
-
} else {
|
|
327
|
-
mappedActiveNodePos = tr.docChanged && activeNode ? {
|
|
328
|
-
pos: tr.mapping.map(activeNode.pos),
|
|
329
|
-
anchorName: activeNode.anchorName,
|
|
330
|
-
nodeType: activeNode.nodeType
|
|
331
|
-
} : activeNode;
|
|
332
|
-
}
|
|
269
|
+
const mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
|
|
270
|
+
pos: tr.mapping.map(activeNode.pos),
|
|
271
|
+
anchorName: activeNode.anchorName,
|
|
272
|
+
nodeType: activeNode.nodeType
|
|
273
|
+
} : activeNode;
|
|
333
274
|
return {
|
|
334
275
|
decorations,
|
|
335
276
|
decorationState,
|
|
336
|
-
activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$
|
|
277
|
+
activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$activeNode3 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode3 !== void 0 ? _meta$activeNode3 : mappedActiveNodePos,
|
|
337
278
|
isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
|
|
338
279
|
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
339
280
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @jsxRuntime classic
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
|
-
import { useCallback, useEffect,
|
|
5
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
8
|
import { bind } from 'bind-event-listener';
|
|
@@ -271,13 +271,10 @@ const DragHandleInternal = ({
|
|
|
271
271
|
top: fg('platform_editor_elements_dnd_ed_23674') ? getTopPosition(dom, nodeType) : getTopPosition(dom)
|
|
272
272
|
};
|
|
273
273
|
}, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates]);
|
|
274
|
-
const [
|
|
274
|
+
const [positionStyles, setPositionStyles] = useState({
|
|
275
275
|
display: 'none'
|
|
276
276
|
});
|
|
277
277
|
useEffect(() => {
|
|
278
|
-
if (!fg('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
278
|
let cleanUpTransitionListener;
|
|
282
279
|
if (nodeType === 'extension' || nodeType === 'embedCard') {
|
|
283
280
|
const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
|
|
@@ -287,12 +284,12 @@ const DragHandleInternal = ({
|
|
|
287
284
|
cleanUpTransitionListener = bind(dom, {
|
|
288
285
|
type: 'transitionend',
|
|
289
286
|
listener: () => {
|
|
290
|
-
|
|
287
|
+
setPositionStyles(calculatePosition());
|
|
291
288
|
}
|
|
292
289
|
});
|
|
293
290
|
}
|
|
294
291
|
const calcPos = requestAnimationFrame(() => {
|
|
295
|
-
|
|
292
|
+
setPositionStyles(calculatePosition());
|
|
296
293
|
});
|
|
297
294
|
return () => {
|
|
298
295
|
var _cleanUpTransitionLis;
|
|
@@ -300,12 +297,6 @@ const DragHandleInternal = ({
|
|
|
300
297
|
(_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 ? void 0 : _cleanUpTransitionLis();
|
|
301
298
|
};
|
|
302
299
|
}, [calculatePosition, view.dom, anchorName, nodeType]);
|
|
303
|
-
const positionStyles = useMemo(() => {
|
|
304
|
-
if (fg('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
305
|
-
return newPositionStyles;
|
|
306
|
-
}
|
|
307
|
-
return calculatePosition();
|
|
308
|
-
}, [calculatePosition, newPositionStyles]);
|
|
309
300
|
useEffect(() => {
|
|
310
301
|
if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
311
302
|
const id = requestAnimationFrame(() => {
|
|
@@ -338,7 +329,7 @@ const DragHandleInternal = ({
|
|
|
338
329
|
ref: buttonRef
|
|
339
330
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
340
331
|
,
|
|
341
|
-
style:
|
|
332
|
+
style: positionStyles,
|
|
342
333
|
onClick: handleOnClick,
|
|
343
334
|
onMouseDown: handleMouseDown,
|
|
344
335
|
onKeyDown: handleKeyDown,
|
|
@@ -7,7 +7,6 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
12
11
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
13
12
|
import { layers } from '@atlaskit/theme/constants';
|
|
@@ -40,9 +39,6 @@ const getNodeMargins = node => {
|
|
|
40
39
|
return nodeMargins[nodeTypeName] || nodeMargins['default'];
|
|
41
40
|
};
|
|
42
41
|
const getDropTargetPositionStyle = (prevNode, nextNode) => {
|
|
43
|
-
if (!fg('platform_editor_drag_and_drop_target_gap_fix')) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
42
|
if (!prevNode || !nextNode) {
|
|
47
43
|
return null;
|
|
48
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
const IS_GEMINI_TEST_ENV = Boolean(process.env.NODE_ENV === 'development') && Boolean(window.__gemini_set_feature_flag__);
|
|
3
3
|
export const isBlocksDragTargetDebug = () => {
|
|
4
|
-
return IS_GEMINI_TEST_ENV && fg('
|
|
4
|
+
return IS_GEMINI_TEST_ENV && fg('platform_editor_element_drag_and_drop_debug');
|
|
5
5
|
};
|
|
@@ -8,7 +8,8 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
8
8
|
import { DragHandle } from '../ui/drag-handle';
|
|
9
9
|
import { DropTarget } from '../ui/drop-target';
|
|
10
10
|
import { canMoveToIndex } from '../utils/validation';
|
|
11
|
-
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn'];
|
|
11
|
+
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem'];
|
|
12
|
+
var IGNORE_NODES_AND_DESCENDANTS = ['listItem'];
|
|
12
13
|
var NESTED_DEPTH = fg('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
13
14
|
export var dropTargetDecorations = function dropTargetDecorations(oldState, newState, api, formatMessage, activeNodeType) {
|
|
14
15
|
var decs = [];
|
|
@@ -17,8 +18,7 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
|
|
|
17
18
|
// and allows us to easily map the updated position in the plugin apply method.
|
|
18
19
|
var decorationState = [];
|
|
19
20
|
var prevNode;
|
|
20
|
-
|
|
21
|
-
state.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
|
|
21
|
+
newState.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
|
|
22
22
|
var depth = 0;
|
|
23
23
|
var nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
24
24
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
@@ -114,12 +114,13 @@ export var emptyParagraphNodeDecorations = function emptyParagraphNodeDecoration
|
|
|
114
114
|
};
|
|
115
115
|
export var nodeDecorations = function nodeDecorations(newState) {
|
|
116
116
|
var decs = [];
|
|
117
|
-
newState.doc.descendants(function (node, pos,
|
|
117
|
+
newState.doc.descendants(function (node, pos, parent, index) {
|
|
118
118
|
var _Decoration$node2;
|
|
119
119
|
var depth = 0;
|
|
120
120
|
var anchorName;
|
|
121
121
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
122
|
-
|
|
122
|
+
// Doesn't descend into a node
|
|
123
|
+
if (node.isInline || IGNORE_NODES_AND_DESCENDANTS.includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '')) {
|
|
123
124
|
return false;
|
|
124
125
|
}
|
|
125
126
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
@@ -141,9 +142,8 @@ export var nodeDecorations = function nodeDecorations(newState) {
|
|
|
141
142
|
};
|
|
142
143
|
export var dragHandleDecoration = function dragHandleDecoration(api, getIntl, pos, anchorName, nodeType, handleOptions) {
|
|
143
144
|
var unbind;
|
|
144
|
-
var elementType = fg('platform_editor_element_drag_and_drop_ed_24150') ? 'span' : 'div';
|
|
145
145
|
return Decoration.widget(pos, function (view, getPos) {
|
|
146
|
-
var element = document.createElement(
|
|
146
|
+
var element = document.createElement('span');
|
|
147
147
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
148
148
|
element.style.display = 'inline';
|
|
149
149
|
element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
|
|
@@ -156,9 +156,7 @@ export var dragHandleDecoration = function dragHandleDecoration(api, getIntl, po
|
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
-
|
|
160
|
-
unmountDecorations('data-blocks-drag-handle-container');
|
|
161
|
-
}
|
|
159
|
+
unmountDecorations('data-blocks-drag-handle-container');
|
|
162
160
|
|
|
163
161
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
164
162
|
// due to margins applied to other nodes eg. Headings
|
|
@@ -177,13 +175,10 @@ export var dragHandleDecoration = function dragHandleDecoration(api, getIntl, po
|
|
|
177
175
|
}, {
|
|
178
176
|
side: -1,
|
|
179
177
|
id: 'drag-handle',
|
|
180
|
-
destroy: function destroy(
|
|
178
|
+
destroy: function destroy() {
|
|
181
179
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
182
180
|
unbind && unbind();
|
|
183
181
|
}
|
|
184
|
-
if (!fg('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
185
|
-
ReactDOM.unmountComponentAtNode(node);
|
|
186
|
-
}
|
|
187
182
|
}
|
|
188
183
|
});
|
|
189
184
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import rafSchedule from 'raf-schd';
|
|
3
|
-
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
4
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
5
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
@@ -86,7 +85,7 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
86
85
|
return initialState;
|
|
87
86
|
},
|
|
88
87
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
89
|
-
var _meta$activeNode, _meta$activeNode$hand, _meta$
|
|
88
|
+
var _meta$activeNode, _meta$activeNode$hand, _activeNodeWithNewNod, _meta$activeNode3, _meta$isDragging, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
90
89
|
var activeNode = currentState.activeNode,
|
|
91
90
|
decorations = currentState.decorations,
|
|
92
91
|
isMenuOpen = currentState.isMenuOpen,
|
|
@@ -99,20 +98,12 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
99
98
|
isPMDragging = currentState.isPMDragging;
|
|
100
99
|
var activeNodeWithNewNodeType = null;
|
|
101
100
|
var meta = tr.getMeta(key);
|
|
102
|
-
// when creating analytics during drag/drop events, PM thinks the doc has changed
|
|
103
|
-
// so tr.docChange is true and causes some decorations to not render
|
|
104
|
-
var isAnalyticTr = tr.steps.every(function (step) {
|
|
105
|
-
return step instanceof AnalyticsStep;
|
|
106
|
-
});
|
|
107
101
|
|
|
108
102
|
// If tables or media are being resized, we want to hide the drag handle
|
|
109
103
|
var resizerMeta = tr.getMeta('is-resizer-resizing');
|
|
110
104
|
isResizerResizing = resizerMeta !== null && resizerMeta !== void 0 ? resizerMeta : isResizerResizing;
|
|
111
105
|
var nodeCountChanged = oldState.doc.childCount !== newState.doc.childCount;
|
|
112
|
-
var shouldRemoveHandle =
|
|
113
|
-
if (fg('platform_editor_elements_drag_and_drop_ed_24000')) {
|
|
114
|
-
shouldRemoveHandle = !tr.getMeta('isRemote');
|
|
115
|
-
}
|
|
106
|
+
var shouldRemoveHandle = !tr.getMeta('isRemote');
|
|
116
107
|
|
|
117
108
|
// During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
|
|
118
109
|
// Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
|
|
@@ -140,16 +131,14 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
140
131
|
if (!fg('platform_editor_elements_dnd_nested')) {
|
|
141
132
|
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
|
|
142
133
|
}
|
|
143
|
-
|
|
144
|
-
var
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}).length;
|
|
134
|
+
var dropTargetLen = decorations.find().filter(function (_ref8) {
|
|
135
|
+
var spec = _ref8.spec;
|
|
136
|
+
return spec.type === 'drop-target-decoration';
|
|
137
|
+
}).length;
|
|
148
138
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
139
|
+
//TODO: Fix this logic for nested scenarios
|
|
140
|
+
if (!fg('platform_editor_elements_dnd_nested')) {
|
|
141
|
+
isDropTargetsMissing = isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && dropTargetLen !== newState.doc.childCount + 1;
|
|
153
142
|
}
|
|
154
143
|
|
|
155
144
|
// This is not targeted enough - it's trying to catch events like expand being set to breakout
|
|
@@ -220,90 +209,50 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
220
209
|
var decs = dragHandleDecoration(api, getIntl, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, meta.activeNode.handleOptions);
|
|
221
210
|
decorations = decorations.add(newState.doc, [decs]);
|
|
222
211
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
var
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
decorations = decorations.add(newState.doc, [_decs]);
|
|
234
|
-
}
|
|
212
|
+
|
|
213
|
+
// Remove previous drag handle widget and draw new drag handle widget when node type changes
|
|
214
|
+
if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
|
|
215
|
+
var _oldHandle2 = decorations.find().filter(function (_ref11) {
|
|
216
|
+
var spec = _ref11.spec;
|
|
217
|
+
return spec.id === 'drag-handle';
|
|
218
|
+
});
|
|
219
|
+
decorations = decorations.remove(_oldHandle2);
|
|
220
|
+
var _decs = dragHandleDecoration(api, getIntl, activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType);
|
|
221
|
+
decorations = decorations.add(newState.doc, [_decs]);
|
|
235
222
|
}
|
|
236
223
|
var shouldUpdateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
|
|
237
|
-
var shouldMapDropTargets = false;
|
|
238
|
-
if (
|
|
239
|
-
shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
240
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
241
|
-
// Remove drop target decoration when dragging stops
|
|
242
|
-
var dropTargetDecs = decorations.find().filter(function (_ref12) {
|
|
243
|
-
var spec = _ref12.spec;
|
|
244
|
-
return spec.type === 'drop-target-decoration';
|
|
245
|
-
});
|
|
246
|
-
decorations = decorations.remove(dropTargetDecs);
|
|
247
|
-
}
|
|
248
|
-
if (api) {
|
|
249
|
-
// Add drop targets when node is being dragged
|
|
250
|
-
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
251
|
-
if (shouldUpdateDropTargets || isBlocksDragTargetDebug()) {
|
|
252
|
-
var _meta$activeNode2;
|
|
253
|
-
var _dropTargetDecoration = dropTargetDecorations(oldState, newState, api, formatMessage, meta === null || meta === void 0 || (_meta$activeNode2 = meta.activeNode) === null || _meta$activeNode2 === void 0 ? void 0 : _meta$activeNode2.nodeType),
|
|
254
|
-
_decs2 = _dropTargetDecoration.decs,
|
|
255
|
-
updatedDecorationState = _dropTargetDecoration.decorationState;
|
|
256
|
-
decorationState = updatedDecorationState;
|
|
257
|
-
decorations = decorations.add(newState.doc, _decs2);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
//Map drop target decoration positions when the document changes
|
|
262
|
-
if (shouldMapDropTargets) {
|
|
263
|
-
decorationState = decorationState.map(function (_ref13) {
|
|
264
|
-
var id = _ref13.id,
|
|
265
|
-
pos = _ref13.pos;
|
|
266
|
-
return {
|
|
267
|
-
id: id,
|
|
268
|
-
pos: tr.mapping.map(pos)
|
|
269
|
-
};
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
} else {
|
|
273
|
-
if (api) {
|
|
274
|
-
// Add drop targets when node is being dragged
|
|
275
|
-
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
276
|
-
var shouldShowDragTarget = (meta === null || meta === void 0 ? void 0 : meta.isDragging) && (!tr.docChanged || tr.docChanged && isAnalyticTr);
|
|
277
|
-
if (shouldShowDragTarget || isBlocksDragTargetDebug()) {
|
|
278
|
-
var _meta$activeNode3;
|
|
279
|
-
var _dropTargetDecoration2 = dropTargetDecorations(oldState, newState, api, formatMessage, meta === null || meta === void 0 || (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.nodeType),
|
|
280
|
-
_decs3 = _dropTargetDecoration2.decs,
|
|
281
|
-
_updatedDecorationState = _dropTargetDecoration2.decorationState;
|
|
282
|
-
decorationState = _updatedDecorationState;
|
|
283
|
-
decorations = decorations.add(newState.doc, _decs3);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
224
|
+
var shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
225
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
287
226
|
// Remove drop target decoration when dragging stops
|
|
288
|
-
|
|
289
|
-
var
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
227
|
+
var dropTargetDecs = decorations.find().filter(function (_ref12) {
|
|
228
|
+
var spec = _ref12.spec;
|
|
229
|
+
return spec.type === 'drop-target-decoration';
|
|
230
|
+
});
|
|
231
|
+
decorations = decorations.remove(dropTargetDecs);
|
|
232
|
+
}
|
|
233
|
+
if (api) {
|
|
234
|
+
// Add drop targets when node is being dragged
|
|
235
|
+
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
236
|
+
if (shouldUpdateDropTargets || isBlocksDragTargetDebug()) {
|
|
237
|
+
var _meta$activeNode2;
|
|
238
|
+
var _dropTargetDecoration = dropTargetDecorations(oldState, newState, api, formatMessage, meta === null || meta === void 0 || (_meta$activeNode2 = meta.activeNode) === null || _meta$activeNode2 === void 0 ? void 0 : _meta$activeNode2.nodeType),
|
|
239
|
+
_decs2 = _dropTargetDecoration.decs,
|
|
240
|
+
updatedDecorationState = _dropTargetDecoration.decorationState;
|
|
241
|
+
decorationState = updatedDecorationState;
|
|
242
|
+
decorations = decorations.add(newState.doc, _decs2);
|
|
294
243
|
}
|
|
244
|
+
}
|
|
295
245
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
246
|
+
//Map drop target decoration positions when the document changes
|
|
247
|
+
if (shouldMapDropTargets) {
|
|
248
|
+
decorationState = decorationState.map(function (_ref13) {
|
|
249
|
+
var id = _ref13.id,
|
|
250
|
+
pos = _ref13.pos;
|
|
251
|
+
return {
|
|
252
|
+
id: id,
|
|
253
|
+
pos: tr.mapping.map(pos)
|
|
254
|
+
};
|
|
255
|
+
});
|
|
307
256
|
}
|
|
308
257
|
|
|
309
258
|
// Map decorations if document changes and node decorations do not need to be redrawn
|
|
@@ -311,8 +260,8 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
311
260
|
decorations = decorations.map(tr.mapping, tr.doc);
|
|
312
261
|
}
|
|
313
262
|
var isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
|
|
314
|
-
var hasNodeDecoration = decorations.find().some(function (
|
|
315
|
-
var spec =
|
|
263
|
+
var hasNodeDecoration = decorations.find().some(function (_ref14) {
|
|
264
|
+
var spec = _ref14.spec;
|
|
316
265
|
return spec.type === 'node-decoration';
|
|
317
266
|
});
|
|
318
267
|
if (!hasNodeDecoration && isEmptyDoc) {
|
|
@@ -320,24 +269,15 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
320
269
|
}
|
|
321
270
|
|
|
322
271
|
// Map active node position when the document changes
|
|
323
|
-
var mappedActiveNodePos
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
nodeType: activeNode.nodeType
|
|
329
|
-
} : activeNode;
|
|
330
|
-
} else {
|
|
331
|
-
mappedActiveNodePos = tr.docChanged && activeNode ? {
|
|
332
|
-
pos: tr.mapping.map(activeNode.pos),
|
|
333
|
-
anchorName: activeNode.anchorName,
|
|
334
|
-
nodeType: activeNode.nodeType
|
|
335
|
-
} : activeNode;
|
|
336
|
-
}
|
|
272
|
+
var mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
|
|
273
|
+
pos: tr.mapping.map(activeNode.pos),
|
|
274
|
+
anchorName: activeNode.anchorName,
|
|
275
|
+
nodeType: activeNode.nodeType
|
|
276
|
+
} : activeNode;
|
|
337
277
|
return {
|
|
338
278
|
decorations: decorations,
|
|
339
279
|
decorationState: decorationState,
|
|
340
|
-
activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$
|
|
280
|
+
activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$activeNode3 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode3 !== void 0 ? _meta$activeNode3 : mappedActiveNodePos,
|
|
341
281
|
isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
|
|
342
282
|
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
343
283
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
|
|
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
* @jsxRuntime classic
|
|
4
4
|
* @jsx jsx
|
|
5
5
|
*/
|
|
6
|
-
import { useCallback, useEffect,
|
|
6
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { bind } from 'bind-event-listener';
|
|
@@ -278,12 +278,9 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
278
278
|
display: 'none'
|
|
279
279
|
}),
|
|
280
280
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
positionStyles = _useState6[0],
|
|
282
|
+
setPositionStyles = _useState6[1];
|
|
283
283
|
useEffect(function () {
|
|
284
|
-
if (!fg('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
284
|
var cleanUpTransitionListener;
|
|
288
285
|
if (nodeType === 'extension' || nodeType === 'embedCard') {
|
|
289
286
|
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
@@ -293,12 +290,12 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
293
290
|
cleanUpTransitionListener = bind(dom, {
|
|
294
291
|
type: 'transitionend',
|
|
295
292
|
listener: function listener() {
|
|
296
|
-
|
|
293
|
+
setPositionStyles(calculatePosition());
|
|
297
294
|
}
|
|
298
295
|
});
|
|
299
296
|
}
|
|
300
297
|
var calcPos = requestAnimationFrame(function () {
|
|
301
|
-
|
|
298
|
+
setPositionStyles(calculatePosition());
|
|
302
299
|
});
|
|
303
300
|
return function () {
|
|
304
301
|
var _cleanUpTransitionLis;
|
|
@@ -306,12 +303,6 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
306
303
|
(_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
|
|
307
304
|
};
|
|
308
305
|
}, [calculatePosition, view.dom, anchorName, nodeType]);
|
|
309
|
-
var positionStyles = useMemo(function () {
|
|
310
|
-
if (fg('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
311
|
-
return newPositionStyles;
|
|
312
|
-
}
|
|
313
|
-
return calculatePosition();
|
|
314
|
-
}, [calculatePosition, newPositionStyles]);
|
|
315
306
|
useEffect(function () {
|
|
316
307
|
if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
317
308
|
var id = requestAnimationFrame(function () {
|
|
@@ -345,7 +336,7 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
345
336
|
ref: buttonRef
|
|
346
337
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
347
338
|
,
|
|
348
|
-
style:
|
|
339
|
+
style: positionStyles,
|
|
349
340
|
onClick: handleOnClick,
|
|
350
341
|
onMouseDown: handleMouseDown,
|
|
351
342
|
onKeyDown: handleKeyDown,
|
|
@@ -8,7 +8,6 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { css, jsx } from '@emotion/react';
|
|
10
10
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
11
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
13
12
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
14
13
|
import { layers } from '@atlaskit/theme/constants';
|
|
@@ -46,9 +45,6 @@ var getNodeMargins = function getNodeMargins(node) {
|
|
|
46
45
|
return nodeMargins[nodeTypeName] || nodeMargins['default'];
|
|
47
46
|
};
|
|
48
47
|
var getDropTargetPositionStyle = function getDropTargetPositionStyle(prevNode, nextNode) {
|
|
49
|
-
if (!fg('platform_editor_drag_and_drop_target_gap_fix')) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
48
|
if (!prevNode || !nextNode) {
|
|
53
49
|
return null;
|
|
54
50
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
var IS_GEMINI_TEST_ENV = Boolean(process.env.NODE_ENV === 'development') && Boolean(window.__gemini_set_feature_flag__);
|
|
3
3
|
export var isBlocksDragTargetDebug = function isBlocksDragTargetDebug() {
|
|
4
|
-
return IS_GEMINI_TEST_ENV && fg('
|
|
4
|
+
return IS_GEMINI_TEST_ENV && fg('platform_editor_element_drag_and_drop_debug');
|
|
5
5
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.7",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/adf-schema": "^40.3.0",
|
|
35
34
|
"@atlaskit/editor-common": "^87.5.0",
|
|
36
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
37
36
|
"@atlaskit/editor-plugin-analytics": "^1.6.0",
|
|
@@ -105,9 +104,6 @@
|
|
|
105
104
|
"platform_editor_elements_drag_and_drop_ed_24000": {
|
|
106
105
|
"type": "boolean"
|
|
107
106
|
},
|
|
108
|
-
"platform.editor.elements.drag-and-drop-ed-23816": {
|
|
109
|
-
"type": "boolean"
|
|
110
|
-
},
|
|
111
107
|
"platform_editor_elements_drag_and_drop_ed_23189": {
|
|
112
108
|
"type": "boolean"
|
|
113
109
|
},
|
|
@@ -123,35 +119,23 @@
|
|
|
123
119
|
"platform_editor_element_drag_and_drop_ed_24049": {
|
|
124
120
|
"type": "boolean"
|
|
125
121
|
},
|
|
126
|
-
"platform_editor_element_drag_and_drop_ed_23896": {
|
|
127
|
-
"type": "boolean"
|
|
128
|
-
},
|
|
129
122
|
"platform_editor_element_controls_chrome_input_fix": {
|
|
130
123
|
"type": "boolean"
|
|
131
124
|
},
|
|
132
|
-
"platform_editor_drag_and_drop_target_gap_fix": {
|
|
133
|
-
"type": "boolean"
|
|
134
|
-
},
|
|
135
|
-
"platform_editor_element_drag_and_drop_ed_24150": {
|
|
136
|
-
"type": "boolean"
|
|
137
|
-
},
|
|
138
125
|
"platform_editor_element_drag_and_drop_ed_24321": {
|
|
139
126
|
"type": "boolean"
|
|
140
127
|
},
|
|
141
|
-
"platform_editor_element_drag_and_drop_ed_24330": {
|
|
142
|
-
"type": "boolean"
|
|
143
|
-
},
|
|
144
128
|
"platform_editor_element_drag_and_drop_ed_24227": {
|
|
145
129
|
"type": "boolean"
|
|
146
130
|
},
|
|
147
|
-
"platform_editor_element_drag_and_drop_ed_24372": {
|
|
148
|
-
"type": "boolean"
|
|
149
|
-
},
|
|
150
131
|
"platform_editor_elements_dnd_nested": {
|
|
151
132
|
"type": "boolean"
|
|
152
133
|
},
|
|
153
134
|
"platform_editor_element_drag_and_drop_ed_24304": {
|
|
154
135
|
"type": "boolean"
|
|
136
|
+
},
|
|
137
|
+
"platform_editor_element_drag_and_drop_debug": {
|
|
138
|
+
"type": "boolean"
|
|
155
139
|
}
|
|
156
140
|
}
|
|
157
141
|
}
|