@atlaskit/editor-plugin-block-controls 1.10.6 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,9 +7,26 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import { DragHandle } from '../ui/drag-handle';
9
9
  import { DropTarget } from '../ui/drop-target';
10
+ import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
10
11
  import { canMoveToIndex } from '../utils/validation';
11
- var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn'];
12
- var NESTED_DEPTH = fg('platform_editor_elements_dnd_nested') ? 100 : 0;
12
+ var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem'];
13
+ var IGNORE_NODES_AND_DESCENDANTS = ['listItem'];
14
+ var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand'];
15
+ var getNestedDepth = function getNestedDepth() {
16
+ return fg('platform_editor_elements_dnd_nested') ? 100 : 0;
17
+ };
18
+ var createDropTargetDecoration = function createDropTargetDecoration(pos, dropTargetDec) {
19
+ return Decoration.widget(pos, function () {
20
+ var element = document.createElement('div');
21
+ element.setAttribute('data-blocks-drop-target-container', 'true');
22
+ element.style.clear = 'unset';
23
+ ReactDOM.render(dropTargetDec, element);
24
+ return element;
25
+ }, {
26
+ type: 'drop-target-decoration',
27
+ side: -1
28
+ });
29
+ };
13
30
  export var dropTargetDecorations = function dropTargetDecorations(oldState, newState, api, formatMessage, activeNodeType) {
14
31
  var decs = [];
15
32
  unmountDecorations('data-blocks-drop-target-container');
@@ -17,53 +34,61 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
17
34
  // and allows us to easily map the updated position in the plugin apply method.
18
35
  var decorationState = [];
19
36
  var prevNode;
20
- var state = fg('platform_editor_element_drag_and_drop_ed_24372') ? newState : oldState;
21
- state.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
37
+ newState.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
22
38
  var depth = 0;
23
39
  var nodeType = newState.doc.type.schema.nodes[activeNodeType];
40
+ var endDec = null;
24
41
  if (fg('platform_editor_elements_dnd_nested')) {
25
42
  depth = newState.doc.resolve(pos).depth;
26
- if (node.isInline) {
43
+ if (node.isInline || !parent) {
27
44
  return false;
28
45
  }
29
46
  if (IGNORE_NODES.includes(node.type.name)) {
30
47
  return true; //skip over, don't consider it a valid depth
31
48
  }
32
- var canDrop = parent && activeNodeType && canMoveToIndex(parent, index, nodeType);
49
+ var canDrop = activeNodeType && canMoveToIndex(parent, index, nodeType);
33
50
 
34
51
  //NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
35
- if (!canDrop) {
52
+ if (!canDrop && !isBlocksDragTargetDebug()) {
36
53
  return false; //not valid pos, so nested not valid either
37
54
  }
38
55
  decorationState.push({
39
56
  id: pos,
40
57
  pos: pos
41
58
  });
59
+ if (parent.lastChild === node && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
60
+ var endpos = pos + node.nodeSize;
61
+ endDec = {
62
+ id: endpos,
63
+ pos: endpos
64
+ };
65
+ decorationState.push({
66
+ id: endpos,
67
+ pos: endpos
68
+ });
69
+ }
42
70
  } else {
43
71
  decorationState.push({
44
72
  id: index,
45
73
  pos: pos
46
74
  });
47
75
  }
48
- var dropTargetDec = /*#__PURE__*/createElement(DropTarget, {
76
+ decs.push(createDropTargetDecoration(pos, /*#__PURE__*/createElement(DropTarget, {
49
77
  api: api,
50
78
  id: fg('platform_editor_elements_dnd_nested') ? pos : index,
51
79
  formatMessage: formatMessage,
52
80
  prevNode: prevNode,
53
81
  nextNode: node
54
- });
55
- decs.push(Decoration.widget(pos, function () {
56
- var element = document.createElement('div');
57
- element.setAttribute('data-blocks-drop-target-container', 'true');
58
- element.style.clear = 'unset';
59
- ReactDOM.render(dropTargetDec, element);
60
- return element;
61
- }, {
62
- type: 'drop-target-decoration',
63
- side: -1
64
- }));
82
+ })));
83
+ if (endDec) {
84
+ decs.push(createDropTargetDecoration(endDec.pos, /*#__PURE__*/createElement(DropTarget, {
85
+ api: api,
86
+ id: endDec.id,
87
+ formatMessage: formatMessage
88
+ })));
89
+ }
65
90
  prevNode = node;
66
- return depth < NESTED_DEPTH;
91
+ return depth < getNestedDepth();
67
92
  });
68
93
 
69
94
  /**
@@ -73,7 +98,6 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
73
98
  * node and not its size.
74
99
  *
75
100
  */
76
-
77
101
  var lastPos = newState.doc.content.size;
78
102
  if (fg('platform_editor_elements_dnd_nested')) {
79
103
  decorationState.push({
@@ -114,12 +138,13 @@ export var emptyParagraphNodeDecorations = function emptyParagraphNodeDecoration
114
138
  };
115
139
  export var nodeDecorations = function nodeDecorations(newState) {
116
140
  var decs = [];
117
- newState.doc.descendants(function (node, pos, _parent, index) {
141
+ newState.doc.descendants(function (node, pos, parent, index) {
118
142
  var _Decoration$node2;
119
143
  var depth = 0;
120
144
  var anchorName;
121
145
  if (fg('platform_editor_elements_dnd_nested')) {
122
- if (node.isInline) {
146
+ // Doesn't descend into a node
147
+ if (node.isInline || IGNORE_NODES_AND_DESCENDANTS.includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '')) {
123
148
  return false;
124
149
  }
125
150
  if (IGNORE_NODES.includes(node.type.name)) {
@@ -135,15 +160,14 @@ export var nodeDecorations = function nodeDecorations(newState) {
135
160
  }, _defineProperty(_Decoration$node2, 'data-drag-handler-anchor-name', anchorName), _defineProperty(_Decoration$node2, 'data-drag-handler-node-type', node.type.name), _defineProperty(_Decoration$node2, 'data-drag-handler-anchor-depth', "".concat(depth)), _Decoration$node2), {
136
161
  type: 'node-decoration'
137
162
  }));
138
- return depth < NESTED_DEPTH;
163
+ return depth < getNestedDepth();
139
164
  });
140
165
  return decs;
141
166
  };
142
167
  export var dragHandleDecoration = function dragHandleDecoration(api, getIntl, pos, anchorName, nodeType, handleOptions) {
143
168
  var unbind;
144
- var elementType = fg('platform_editor_element_drag_and_drop_ed_24150') ? 'span' : 'div';
145
169
  return Decoration.widget(pos, function (view, getPos) {
146
- var element = document.createElement(elementType);
170
+ var element = document.createElement('span');
147
171
  // Need to set it to inline to avoid text being split when merging two paragraphs
148
172
  element.style.display = 'inline';
149
173
  element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
@@ -156,9 +180,7 @@ export var dragHandleDecoration = function dragHandleDecoration(api, getIntl, po
156
180
  }
157
181
  });
158
182
  }
159
- if (fg('platform_editor_element_drag_and_drop_ed_23896')) {
160
- unmountDecorations('data-blocks-drag-handle-container');
161
- }
183
+ unmountDecorations('data-blocks-drag-handle-container');
162
184
 
163
185
  // There are times when global clear: "both" styles are applied to this decoration causing jumpiness
164
186
  // due to margins applied to other nodes eg. Headings
@@ -177,13 +199,10 @@ export var dragHandleDecoration = function dragHandleDecoration(api, getIntl, po
177
199
  }, {
178
200
  side: -1,
179
201
  id: 'drag-handle',
180
- destroy: function destroy(node) {
202
+ destroy: function destroy() {
181
203
  if (fg('platform_editor_elements_dnd_nested')) {
182
204
  unbind && unbind();
183
205
  }
184
- if (!fg('platform_editor_element_drag_and_drop_ed_23896')) {
185
- ReactDOM.unmountComponentAtNode(node);
186
- }
187
206
  }
188
207
  });
189
208
  };
@@ -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$activeNode4, _meta$isDragging, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
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 = true;
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
- if (fg('platform_editor_element_drag_and_drop_ed_24372')) {
144
- var dropTargetLen = decorations.find().filter(function (_ref8) {
145
- var spec = _ref8.spec;
146
- return spec.type === 'drop-target-decoration';
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
- //TODO: Fix this logic for nested scenarios
150
- if (!fg('platform_editor_elements_dnd_nested')) {
151
- isDropTargetsMissing = isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && dropTargetLen !== newState.doc.childCount + 1;
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
@@ -168,15 +157,11 @@ export var createPlugin = function createPlugin(api, getIntl) {
168
157
 
169
158
  // Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
170
159
  if (redrawDecorations && !isResizerResizing && api) {
171
- if (fg('platform_editor_elements_drag_and_drop_ed_24000')) {
172
- var oldNodeDecs = decorations.find().filter(function (_ref9) {
173
- var spec = _ref9.spec;
174
- return spec.type !== 'drop-target-decoration';
175
- });
176
- decorations = decorations.remove(oldNodeDecs);
177
- } else {
178
- decorations = DecorationSet.create(newState.doc, []);
179
- }
160
+ var oldNodeDecs = decorations.find().filter(function (_ref9) {
161
+ var spec = _ref9.spec;
162
+ return spec.type !== 'drop-target-decoration';
163
+ });
164
+ decorations = decorations.remove(oldNodeDecs);
180
165
  var nodeDecs = nodeDecorations(newState);
181
166
  decorations = decorations.add(newState.doc, _toConsumableArray(nodeDecs));
182
167
 
@@ -188,9 +173,7 @@ export var createPlugin = function createPlugin(api, getIntl) {
188
173
 
189
174
  // When a node type changed to be nested inside another node, the position of the active node is off by 1
190
175
  // This is a workaround to fix the position of the active node when it is nested
191
-
192
- var shouldUpdateNestedPosition = fg('platform_editor_element_drag_and_drop_ed_24049') ? tr.docChanged && !nodeCountChanged : true;
193
- if (shouldUpdateNestedPosition && mappedPosisiton === prevMappedPos + 1) {
176
+ if (tr.docChanged && !nodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
194
177
  mappedPosisiton = prevMappedPos;
195
178
  }
196
179
  var newActiveNode = tr.doc.nodeAt(mappedPosisiton);
@@ -220,90 +203,50 @@ export var createPlugin = function createPlugin(api, getIntl) {
220
203
  var decs = dragHandleDecoration(api, getIntl, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, meta.activeNode.handleOptions);
221
204
  decorations = decorations.add(newState.doc, [decs]);
222
205
  }
223
- if (fg('platform.editor.elements.drag-and-drop-ed-23816')) {
224
- var _activeNodeWithNewNod;
225
- // Remove previous drag handle widget and draw new drag handle widget when node type changes
226
- if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
227
- var _oldHandle2 = decorations.find().filter(function (_ref11) {
228
- var spec = _ref11.spec;
229
- return spec.id === 'drag-handle';
230
- });
231
- decorations = decorations.remove(_oldHandle2);
232
- var _decs = dragHandleDecoration(api, getIntl, activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType);
233
- decorations = decorations.add(newState.doc, [_decs]);
234
- }
206
+
207
+ // Remove previous drag handle widget and draw new drag handle widget when node type changes
208
+ if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
209
+ var _oldHandle2 = decorations.find().filter(function (_ref11) {
210
+ var spec = _ref11.spec;
211
+ return spec.id === 'drag-handle';
212
+ });
213
+ decorations = decorations.remove(_oldHandle2);
214
+ var _decs = dragHandleDecoration(api, getIntl, activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType);
215
+ decorations = decorations.add(newState.doc, [_decs]);
235
216
  }
236
217
  var shouldUpdateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
237
- var shouldMapDropTargets = false;
238
- if (fg('platform_editor_element_drag_and_drop_ed_24372')) {
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
-
218
+ var shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
219
+ if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
287
220
  // Remove drop target decoration when dragging stops
288
- if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false && (fg('platform_editor_element_drag_and_drop_ed_24330') ? true : !tr.docChanged)) {
289
- var _dropTargetDecs = decorations.find().filter(function (_ref14) {
290
- var spec = _ref14.spec;
291
- return spec.type === 'drop-target-decoration';
292
- });
293
- decorations = decorations.remove(_dropTargetDecs);
221
+ var dropTargetDecs = decorations.find().filter(function (_ref12) {
222
+ var spec = _ref12.spec;
223
+ return spec.type === 'drop-target-decoration';
224
+ });
225
+ decorations = decorations.remove(dropTargetDecs);
226
+ }
227
+ if (api) {
228
+ // Add drop targets when node is being dragged
229
+ // if the transaction is only for analytics and user is dragging, continue to draw drop targets
230
+ if (shouldUpdateDropTargets || isBlocksDragTargetDebug()) {
231
+ var _meta$activeNode2;
232
+ 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),
233
+ _decs2 = _dropTargetDecoration.decs,
234
+ updatedDecorationState = _dropTargetDecoration.decorationState;
235
+ decorationState = updatedDecorationState;
236
+ decorations = decorations.add(newState.doc, _decs2);
294
237
  }
238
+ }
295
239
 
296
- // Map drop target decoration positions when the document changes
297
- if (tr.docChanged && isDragging) {
298
- decorationState = decorationState.map(function (_ref15) {
299
- var id = _ref15.id,
300
- pos = _ref15.pos;
301
- return {
302
- id: id,
303
- pos: tr.mapping.map(pos)
304
- };
305
- });
306
- }
240
+ //Map drop target decoration positions when the document changes
241
+ if (shouldMapDropTargets) {
242
+ decorationState = decorationState.map(function (_ref13) {
243
+ var id = _ref13.id,
244
+ pos = _ref13.pos;
245
+ return {
246
+ id: id,
247
+ pos: tr.mapping.map(pos)
248
+ };
249
+ });
307
250
  }
308
251
 
309
252
  // Map decorations if document changes and node decorations do not need to be redrawn
@@ -311,8 +254,8 @@ export var createPlugin = function createPlugin(api, getIntl) {
311
254
  decorations = decorations.map(tr.mapping, tr.doc);
312
255
  }
313
256
  var isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
314
- var hasNodeDecoration = decorations.find().some(function (_ref16) {
315
- var spec = _ref16.spec;
257
+ var hasNodeDecoration = decorations.find().some(function (_ref14) {
258
+ var spec = _ref14.spec;
316
259
  return spec.type === 'node-decoration';
317
260
  });
318
261
  if (!hasNodeDecoration && isEmptyDoc) {
@@ -320,24 +263,15 @@ export var createPlugin = function createPlugin(api, getIntl) {
320
263
  }
321
264
 
322
265
  // Map active node position when the document changes
323
- var mappedActiveNodePos;
324
- if (fg('platform.editor.elements.drag-and-drop-ed-23816')) {
325
- mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
326
- pos: tr.mapping.map(activeNode.pos),
327
- anchorName: activeNode.anchorName,
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
- }
266
+ var mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
267
+ pos: tr.mapping.map(activeNode.pos),
268
+ anchorName: activeNode.anchorName,
269
+ nodeType: activeNode.nodeType
270
+ } : activeNode;
337
271
  return {
338
272
  decorations: decorations,
339
273
  decorationState: decorationState,
340
- activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$activeNode4 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode4 !== void 0 ? _meta$activeNode4 : mappedActiveNodePos,
274
+ activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$activeNode3 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode3 !== void 0 ? _meta$activeNode3 : mappedActiveNodePos,
341
275
  isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
342
276
  isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
343
277
  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, useMemo, useRef, useState } from 'react';
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';
@@ -112,7 +112,7 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
112
112
  });
113
113
  var resolvedMovingNode = tr.doc.resolve(startPos);
114
114
  var maybeNode = resolvedMovingNode.nodeAfter;
115
- fg('platform.editor.elements.drag-and-drop-long-node-scroll') && tr.setMeta('scrollIntoView', false);
115
+ tr.setMeta('scrollIntoView', false);
116
116
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
117
117
  eventType: EVENT_TYPE.UI,
118
118
  action: ACTION.CLICKED,
@@ -278,12 +278,9 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
278
278
  display: 'none'
279
279
  }),
280
280
  _useState6 = _slicedToArray(_useState5, 2),
281
- newPositionStyles = _useState6[0],
282
- setNewPositionStyles = _useState6[1];
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
- setNewPositionStyles(calculatePosition());
293
+ setPositionStyles(calculatePosition());
297
294
  }
298
295
  });
299
296
  }
300
297
  var calcPos = requestAnimationFrame(function () {
301
- setNewPositionStyles(calculatePosition());
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: fg('platform_editor_element_drag_and_drop_ed_23896') ? newPositionStyles : positionStyles,
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('platform_editor_drag_and_drop_target_gap_fix');
4
+ return IS_GEMINI_TEST_ENV && fg('platform_editor_element_drag_and_drop_debug');
5
5
  };
@@ -1,16 +1,13 @@
1
- /// <reference types="react" />
2
1
  import { jsx } from '@emotion/react';
3
2
  import { type IntlShape } from 'react-intl-next';
4
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
5
  import type { BlockControlsPlugin } from '../types';
7
- export declare const DropTarget: ({ api, id, prevNode, nextNode, formatMessage, }: {
6
+ export type DropTargetProps = {
8
7
  api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
9
8
  id: number;
10
- prevNode?: PMNode | undefined;
11
- nextNode?: PMNode | undefined;
12
- formatMessage?: {
13
- (descriptor: import("react-intl-next").MessageDescriptor, values?: Record<string, import("intl-messageformat").PrimitiveType | import("intl-messageformat").FormatXMLElementFn<string, string>> | undefined, opts?: import("intl-messageformat").Options | undefined): string;
14
- (descriptor: import("react-intl-next").MessageDescriptor, values?: Record<string, string | number | boolean | {} | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNodeArray | import("react").ReactPortal | Date | import("intl-messageformat").FormatXMLElementFn<import("react").ReactNode, import("react").ReactNode> | null | undefined> | undefined, opts?: import("intl-messageformat").Options | undefined): import("react").ReactNode;
15
- } | undefined;
16
- }) => jsx.JSX.Element;
9
+ prevNode?: PMNode;
10
+ nextNode?: PMNode;
11
+ formatMessage?: IntlShape['formatMessage'];
12
+ };
13
+ export declare const DropTarget: ({ api, id, prevNode, nextNode, formatMessage }: DropTargetProps) => jsx.JSX.Element;
@@ -1,16 +1,13 @@
1
- /// <reference types="react" />
2
1
  import { jsx } from '@emotion/react';
3
2
  import { type IntlShape } from 'react-intl-next';
4
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
5
  import type { BlockControlsPlugin } from '../types';
7
- export declare const DropTarget: ({ api, id, prevNode, nextNode, formatMessage, }: {
6
+ export type DropTargetProps = {
8
7
  api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
9
8
  id: number;
10
- prevNode?: PMNode | undefined;
11
- nextNode?: PMNode | undefined;
12
- formatMessage?: {
13
- (descriptor: import("react-intl-next").MessageDescriptor, values?: Record<string, import("intl-messageformat").PrimitiveType | import("intl-messageformat").FormatXMLElementFn<string, string>> | undefined, opts?: import("intl-messageformat").Options | undefined): string;
14
- (descriptor: import("react-intl-next").MessageDescriptor, values?: Record<string, string | number | boolean | {} | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNodeArray | import("react").ReactPortal | Date | import("intl-messageformat").FormatXMLElementFn<import("react").ReactNode, import("react").ReactNode> | null | undefined> | undefined, opts?: import("intl-messageformat").Options | undefined): import("react").ReactNode;
15
- } | undefined;
16
- }) => jsx.JSX.Element;
9
+ prevNode?: PMNode;
10
+ nextNode?: PMNode;
11
+ formatMessage?: IntlShape['formatMessage'];
12
+ };
13
+ export declare const DropTarget: ({ api, id, prevNode, nextNode, formatMessage }: DropTargetProps) => jsx.JSX.Element;