@atlaskit/editor-plugin-block-controls 2.17.4 → 2.18.1

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 CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#100915](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/100915)
8
+ [`8c10232e0f242`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8c10232e0f242) -
9
+ ED-24615 Fixed expand not remembering expand state when a node is moved into it
10
+
11
+ ## 2.18.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#102069](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102069)
16
+ [`3d4c9e1a85d9c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3d4c9e1a85d9c) -
17
+ Clean up platform_editor_dnd_input_performance_optimisation experiment
18
+
19
+ ### Patch Changes
20
+
21
+ - [#101814](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101814)
22
+ [`d8fc81718b517`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d8fc81718b517) -
23
+ [ED-26177] Remove code reference for FG platform_editor_element_dnd_nested_type_error_fix
24
+ - Updated dependencies
25
+
3
26
  ## 2.17.4
4
27
 
5
28
  ### Patch Changes
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.moveNodeViaShortcut = exports.moveNode = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
+ var _expand = require("@atlaskit/editor-common/expand");
10
11
  var _messages = require("@atlaskit/editor-common/messages");
11
12
  var _selection = require("@atlaskit/editor-common/selection");
12
13
  var _transforms = require("@atlaskit/editor-common/transforms");
@@ -171,13 +172,16 @@ var moveNode = exports.moveNode = function moveNode(api) {
171
172
  if (!node) {
172
173
  return tr;
173
174
  }
175
+ var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
176
+ expand = _tr$doc$type$schema$n.expand,
177
+ nestedExpand = _tr$doc$type$schema$n.nestedExpand;
174
178
  var size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
175
179
  var end = start + size;
176
180
  var $from = tr.doc.resolve(start);
181
+ var $to = tr.doc.resolve(to);
177
182
  var mappedTo;
178
183
  if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
179
184
  var nodeCopy = tr.doc.slice(start, end, false); // cut the content
180
- var $to = tr.doc.resolve(to);
181
185
  var destType = $to.node().type;
182
186
  var destParent = $to.node($to.depth);
183
187
  var sourceNode = $from.nodeAfter;
@@ -221,6 +225,14 @@ var moveNode = exports.moveNode = function moveNode(api) {
221
225
  });
222
226
  api === null || api === void 0 || api.core.actions.focus();
223
227
  var $mappedTo = tr.doc.resolve(mappedTo);
228
+ var expandAncestor = (0, _utils2.findParentNodeOfTypeClosestToPos)($to, [expand, nestedExpand]);
229
+ if (expandAncestor && (0, _experiments.editorExperiment)('nested-dnd', true) && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_6')) {
230
+ var wasExpandExpanded = _expand.expandedState.get(expandAncestor.node);
231
+ var updatedExpandAncestor = (0, _utils2.findParentNodeOfTypeClosestToPos)($mappedTo, [expand, nestedExpand]);
232
+ if (wasExpandExpanded !== undefined && updatedExpandAncestor) {
233
+ _expand.expandedState.set(updatedExpandAncestor.node, wasExpandExpanded);
234
+ }
235
+ }
224
236
  if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
225
237
  (0, _fireAnalytics.attachMoveNodeAnalytics)(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
226
238
  } else {
@@ -256,7 +256,7 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
256
256
  // Ignored via go/ees005
257
257
  // eslint-disable-next-line @typescript-eslint/max-params
258
258
  ) {
259
- var _meta$activeNode2, _meta$activeNode$hand2, _activeNodeWithNewNod, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
259
+ var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
260
260
  var isNestedEnabled = flags.isNestedEnabled;
261
261
  var activeNode = currentState.activeNode,
262
262
  isMenuOpen = currentState.isMenuOpen,
@@ -273,10 +273,6 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
273
273
  decorations = decorations.map(tr.mapping, tr.doc);
274
274
  }
275
275
  var meta = tr.getMeta(key);
276
- var isPerformanceFix = isNestedEnabled || (0, _experiments.editorExperiment)('dnd-input-performance-optimisation', true, {
277
- exposure: true
278
- });
279
- var activeNodeWithNewNodeType = null;
280
276
 
281
277
  // If tables or media are being resized, we want to hide the drag handle
282
278
  var resizerMeta = tr.getMeta('is-resizer-resizing');
@@ -339,6 +335,7 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
339
335
  var newNodeDecs = (0, _decorationsAnchor.nodeDecorations)(newState);
340
336
  decorations = decorations.add(newState.doc, (0, _toConsumableArray2.default)(newNodeDecs));
341
337
  if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
338
+ var _meta$activeNode$pos, _meta$activeNode3, _ref6, _meta$activeNode$anch, _meta$activeNode4, _decAtPos$spec, _ref7, _meta$activeNode$node, _meta$activeNode5, _decAtPos$spec2, _meta$activeNode6;
342
339
  var mappedPosisiton = tr.mapping.map(activeNode.pos);
343
340
  var prevMappedPos = oldState.tr.mapping.map(activeNode.pos);
344
341
 
@@ -348,33 +345,16 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
348
345
  mappedPosisiton = prevMappedPos;
349
346
  }
350
347
  var _newActiveNode = tr.doc.nodeAt(mappedPosisiton);
351
- var draghandleDec;
352
- if (isPerformanceFix) {
353
- var _meta$activeNode$pos, _meta$activeNode3, _ref6, _meta$activeNode$anch, _meta$activeNode4, _decAtPos$spec, _ref7, _meta$activeNode$node, _meta$activeNode5, _decAtPos$spec2, _meta$activeNode6;
354
- if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
355
- var _oldHandle2 = decorations.find(undefined, undefined, function (spec) {
356
- return spec.type === 'drag-handle';
357
- });
358
- decorations = decorations.remove(_oldHandle2);
359
- }
360
- var decAtPos = newNodeDecs.find(function (dec) {
361
- return dec.from === mappedPosisiton;
348
+ if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
349
+ var _oldHandle2 = decorations.find(undefined, undefined, function (spec) {
350
+ return spec.type === 'drag-handle';
362
351
  });
363
- draghandleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === void 0 || (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.pos) !== null && _meta$activeNode$pos !== void 0 ? _meta$activeNode$pos : mappedPosisiton, (_ref6 = (_meta$activeNode$anch = meta === null || meta === void 0 || (_meta$activeNode4 = meta.activeNode) === null || _meta$activeNode4 === void 0 ? void 0 : _meta$activeNode4.anchorName) !== null && _meta$activeNode$anch !== void 0 ? _meta$activeNode$anch : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref6 !== void 0 ? _ref6 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref7 = (_meta$activeNode$node = meta === null || meta === void 0 || (_meta$activeNode5 = meta.activeNode) === null || _meta$activeNode5 === void 0 ? void 0 : _meta$activeNode5.nodeType) !== null && _meta$activeNode$node !== void 0 ? _meta$activeNode$node : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref7 !== void 0 ? _ref7 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, nodeViewPortalProviderAPI, meta === null || meta === void 0 || (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
364
- } else {
365
- var nodeType = activeNode.nodeType;
366
- var anchorName = activeNode.anchorName;
367
- if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
368
- nodeType = _newActiveNode.type.name;
369
- anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
370
- activeNodeWithNewNodeType = {
371
- pos: prevMappedPos,
372
- nodeType: nodeType,
373
- anchorName: anchorName
374
- };
375
- }
376
- draghandleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, activeNode.pos, anchorName, nodeType, nodeViewPortalProviderAPI);
352
+ decorations = decorations.remove(_oldHandle2);
377
353
  }
354
+ var decAtPos = newNodeDecs.find(function (dec) {
355
+ return dec.from === mappedPosisiton;
356
+ });
357
+ var draghandleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === void 0 || (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.pos) !== null && _meta$activeNode$pos !== void 0 ? _meta$activeNode$pos : mappedPosisiton, (_ref6 = (_meta$activeNode$anch = meta === null || meta === void 0 || (_meta$activeNode4 = meta.activeNode) === null || _meta$activeNode4 === void 0 ? void 0 : _meta$activeNode4.anchorName) !== null && _meta$activeNode$anch !== void 0 ? _meta$activeNode$anch : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref6 !== void 0 ? _ref6 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref7 = (_meta$activeNode$node = meta === null || meta === void 0 || (_meta$activeNode5 = meta.activeNode) === null || _meta$activeNode5 === void 0 ? void 0 : _meta$activeNode5.nodeType) !== null && _meta$activeNode$node !== void 0 ? _meta$activeNode$node : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref7 !== void 0 ? _ref7 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, nodeViewPortalProviderAPI, meta === null || meta === void 0 || (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
378
358
  decorations = decorations.add(newState.doc, [draghandleDec]);
379
359
  }
380
360
  }
@@ -388,16 +368,6 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
388
368
  var decs = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, nodeViewPortalProviderAPI, meta.activeNode.handleOptions);
389
369
  decorations = decorations.add(newState.doc, [decs]);
390
370
  }
391
-
392
- // Remove previous drag handle widget and draw new drag handle widget when node type changes
393
- if (!isPerformanceFix && activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
394
- var _oldHandle4 = decorations.find(undefined, undefined, function (spec) {
395
- return spec.type === 'drag-handle';
396
- });
397
- decorations = decorations.remove(_oldHandle4);
398
- var _decs = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, nodeViewPortalProviderAPI);
399
- decorations = decorations.add(newState.doc, [_decs]);
400
- }
401
371
  if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
402
372
  // Remove drop target decoration when dragging stops
403
373
  var dropTargetDecs = decorations.find(undefined, undefined, function (spec) {
@@ -407,7 +377,7 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
407
377
  }
408
378
 
409
379
  // Map active node position when the document changes
410
- var mappedActiveNodePos = tr.docChanged && activeNode ? !isPerformanceFix && activeNodeWithNewNodeType || {
380
+ var mappedActiveNodePos = tr.docChanged && activeNode ? {
411
381
  pos: tr.mapping.map(activeNode.pos),
412
382
  anchorName: activeNode.anchorName,
413
383
  nodeType: activeNode.nodeType
@@ -418,8 +388,8 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
418
388
  // if the transaction is only for analytics and user is dragging, continue to draw drop targets
419
389
  if (shouldCreateDropTargets || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
420
390
  var _meta$activeNode7;
421
- var _decs2 = (0, _decorationsDropTarget.dropTargetDecorations)(newState, api, formatMessage, nodeViewPortalProviderAPI, isNestedEnabled ? (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode, anchorRectCache);
422
- decorations = decorations.add(newState.doc, _decs2);
391
+ var _decs = (0, _decorationsDropTarget.dropTargetDecorations)(newState, api, formatMessage, nodeViewPortalProviderAPI, isNestedEnabled ? (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode, anchorRectCache);
392
+ decorations = decorations.add(newState.doc, _decs);
423
393
  }
424
394
  }
425
395
  var isEmptyDoc = isNestedEnabled ? newState.doc.childCount === 1 && newState.doc.nodeSize <= 4 && (newState.doc.firstChild === null || newState.doc.firstChild.nodeSize <= 2) : newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
@@ -320,9 +320,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
320
320
  positionStyles = _useState6[0],
321
321
  setPositionStyles = _useState6[1];
322
322
  (0, _react.useEffect)(function () {
323
- if ((0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_type_error_fix')) {
324
- return;
325
- }
326
323
  var cleanUpTransitionListener;
327
324
  if (nodeType === 'extension' || nodeType === 'embedCard') {
328
325
  var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
@@ -345,32 +342,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
345
342
  (_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
346
343
  };
347
344
  }, [calculatePosition, view.dom, anchorName, nodeType]);
348
- (0, _react.useLayoutEffect)(function () {
349
- if (!(0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_type_error_fix')) {
350
- return;
351
- }
352
- var cleanUpTransitionListener;
353
- if (nodeType === 'extension' || nodeType === 'embedCard') {
354
- var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
355
- if (!dom) {
356
- return;
357
- }
358
- cleanUpTransitionListener = (0, _bindEventListener.bind)(dom, {
359
- type: 'transitionend',
360
- listener: function listener() {
361
- setPositionStyles(calculatePosition());
362
- }
363
- });
364
- }
365
- var calcPos = requestAnimationFrame(function () {
366
- setPositionStyles(calculatePosition());
367
- });
368
- return function () {
369
- var _cleanUpTransitionLis2;
370
- cancelAnimationFrame(calcPos);
371
- (_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 || _cleanUpTransitionLis2();
372
- };
373
- }, [calculatePosition, view.dom, anchorName, nodeType]);
374
345
  (0, _react.useEffect)(function () {
375
346
  if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
376
347
  var id = requestAnimationFrame(function () {
@@ -1,11 +1,12 @@
1
1
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import { expandedState } from '@atlaskit/editor-common/expand';
2
3
  import { blockControlsMessages } from '@atlaskit/editor-common/messages';
3
4
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
4
5
  import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
5
6
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
6
7
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
7
8
  import { Selection } from '@atlaskit/editor-prosemirror/state';
8
- import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
9
+ import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
9
10
  import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
10
11
  import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -165,13 +166,17 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
165
166
  if (!node) {
166
167
  return tr;
167
168
  }
169
+ const {
170
+ expand,
171
+ nestedExpand
172
+ } = tr.doc.type.schema.nodes;
168
173
  const size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
169
174
  const end = start + size;
170
175
  const $from = tr.doc.resolve(start);
176
+ const $to = tr.doc.resolve(to);
171
177
  let mappedTo;
172
178
  if (editorExperiment('nested-dnd', true)) {
173
179
  const nodeCopy = tr.doc.slice(start, end, false); // cut the content
174
- const $to = tr.doc.resolve(to);
175
180
  const destType = $to.node().type;
176
181
  const destParent = $to.node($to.depth);
177
182
  const sourceNode = $from.nodeAfter;
@@ -215,6 +220,14 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
215
220
  });
216
221
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
217
222
  const $mappedTo = tr.doc.resolve(mappedTo);
223
+ const expandAncestor = findParentNodeOfTypeClosestToPos($to, [expand, nestedExpand]);
224
+ if (expandAncestor && editorExperiment('nested-dnd', true) && fg('platform_editor_element_dnd_nested_fix_patch_6')) {
225
+ const wasExpandExpanded = expandedState.get(expandAncestor.node);
226
+ const updatedExpandAncestor = findParentNodeOfTypeClosestToPos($mappedTo, [expand, nestedExpand]);
227
+ if (wasExpandExpanded !== undefined && updatedExpandAncestor) {
228
+ expandedState.set(updatedExpandAncestor.node, wasExpandExpanded);
229
+ }
230
+ }
218
231
  if (editorExperiment('advanced_layouts', true)) {
219
232
  attachMoveNodeAnalytics(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
220
233
  } else {
@@ -256,7 +256,7 @@ export const oldApply = (api, formatMessage, tr, currentState, oldState, newStat
256
256
  // Ignored via go/ees005
257
257
  // eslint-disable-next-line @typescript-eslint/max-params
258
258
  ) => {
259
- var _meta$activeNode2, _meta$activeNode$hand2, _activeNodeWithNewNod, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
259
+ var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
260
260
  const {
261
261
  isNestedEnabled
262
262
  } = flags;
@@ -279,10 +279,6 @@ export const oldApply = (api, formatMessage, tr, currentState, oldState, newStat
279
279
  decorations = decorations.map(tr.mapping, tr.doc);
280
280
  }
281
281
  const meta = tr.getMeta(key);
282
- const isPerformanceFix = isNestedEnabled || editorExperiment('dnd-input-performance-optimisation', true, {
283
- exposure: true
284
- });
285
- let activeNodeWithNewNodeType = null;
286
282
 
287
283
  // If tables or media are being resized, we want to hide the drag handle
288
284
  const resizerMeta = tr.getMeta('is-resizer-resizing');
@@ -332,6 +328,7 @@ export const oldApply = (api, formatMessage, tr, currentState, oldState, newStat
332
328
  const newNodeDecs = nodeDecorations(newState);
333
329
  decorations = decorations.add(newState.doc, [...newNodeDecs]);
334
330
  if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
331
+ var _meta$activeNode$pos, _meta$activeNode3, _ref, _meta$activeNode$anch, _meta$activeNode4, _decAtPos$spec, _ref2, _meta$activeNode$node, _meta$activeNode5, _decAtPos$spec2, _meta$activeNode6;
335
332
  let mappedPosisiton = tr.mapping.map(activeNode.pos);
336
333
  const prevMappedPos = oldState.tr.mapping.map(activeNode.pos);
337
334
 
@@ -341,29 +338,12 @@ export const oldApply = (api, formatMessage, tr, currentState, oldState, newStat
341
338
  mappedPosisiton = prevMappedPos;
342
339
  }
343
340
  const newActiveNode = tr.doc.nodeAt(mappedPosisiton);
344
- let draghandleDec;
345
- if (isPerformanceFix) {
346
- var _meta$activeNode$pos, _meta$activeNode3, _ref, _meta$activeNode$anch, _meta$activeNode4, _decAtPos$spec, _ref2, _meta$activeNode$node, _meta$activeNode5, _decAtPos$spec2, _meta$activeNode6;
347
- if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType) {
348
- const oldHandle = decorations.find(undefined, undefined, spec => spec.type === 'drag-handle');
349
- decorations = decorations.remove(oldHandle);
350
- }
351
- const decAtPos = newNodeDecs.find(dec => dec.from === mappedPosisiton);
352
- draghandleDec = dragHandleDecoration(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === void 0 ? void 0 : (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.pos) !== null && _meta$activeNode$pos !== void 0 ? _meta$activeNode$pos : mappedPosisiton, (_ref = (_meta$activeNode$anch = meta === null || meta === void 0 ? void 0 : (_meta$activeNode4 = meta.activeNode) === null || _meta$activeNode4 === void 0 ? void 0 : _meta$activeNode4.anchorName) !== null && _meta$activeNode$anch !== void 0 ? _meta$activeNode$anch : decAtPos === null || decAtPos === void 0 ? void 0 : (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref !== void 0 ? _ref : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref2 = (_meta$activeNode$node = meta === null || meta === void 0 ? void 0 : (_meta$activeNode5 = meta.activeNode) === null || _meta$activeNode5 === void 0 ? void 0 : _meta$activeNode5.nodeType) !== null && _meta$activeNode$node !== void 0 ? _meta$activeNode$node : decAtPos === null || decAtPos === void 0 ? void 0 : (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref2 !== void 0 ? _ref2 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, nodeViewPortalProviderAPI, meta === null || meta === void 0 ? void 0 : (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
353
- } else {
354
- let nodeType = activeNode.nodeType;
355
- let anchorName = activeNode.anchorName;
356
- if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType) {
357
- nodeType = newActiveNode.type.name;
358
- anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
359
- activeNodeWithNewNodeType = {
360
- pos: prevMappedPos,
361
- nodeType,
362
- anchorName
363
- };
364
- }
365
- draghandleDec = dragHandleDecoration(api, formatMessage, activeNode.pos, anchorName, nodeType, nodeViewPortalProviderAPI);
341
+ if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType) {
342
+ const oldHandle = decorations.find(undefined, undefined, spec => spec.type === 'drag-handle');
343
+ decorations = decorations.remove(oldHandle);
366
344
  }
345
+ const decAtPos = newNodeDecs.find(dec => dec.from === mappedPosisiton);
346
+ const draghandleDec = dragHandleDecoration(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === void 0 ? void 0 : (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.pos) !== null && _meta$activeNode$pos !== void 0 ? _meta$activeNode$pos : mappedPosisiton, (_ref = (_meta$activeNode$anch = meta === null || meta === void 0 ? void 0 : (_meta$activeNode4 = meta.activeNode) === null || _meta$activeNode4 === void 0 ? void 0 : _meta$activeNode4.anchorName) !== null && _meta$activeNode$anch !== void 0 ? _meta$activeNode$anch : decAtPos === null || decAtPos === void 0 ? void 0 : (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref !== void 0 ? _ref : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref2 = (_meta$activeNode$node = meta === null || meta === void 0 ? void 0 : (_meta$activeNode5 = meta.activeNode) === null || _meta$activeNode5 === void 0 ? void 0 : _meta$activeNode5.nodeType) !== null && _meta$activeNode$node !== void 0 ? _meta$activeNode$node : decAtPos === null || decAtPos === void 0 ? void 0 : (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref2 !== void 0 ? _ref2 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, nodeViewPortalProviderAPI, meta === null || meta === void 0 ? void 0 : (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
367
347
  decorations = decorations.add(newState.doc, [draghandleDec]);
368
348
  }
369
349
  }
@@ -375,14 +355,6 @@ export const oldApply = (api, formatMessage, tr, currentState, oldState, newStat
375
355
  const decs = dragHandleDecoration(api, formatMessage, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, nodeViewPortalProviderAPI, meta.activeNode.handleOptions);
376
356
  decorations = decorations.add(newState.doc, [decs]);
377
357
  }
378
-
379
- // Remove previous drag handle widget and draw new drag handle widget when node type changes
380
- if (!isPerformanceFix && activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
381
- const oldHandle = decorations.find(undefined, undefined, spec => spec.type === 'drag-handle');
382
- decorations = decorations.remove(oldHandle);
383
- const decs = dragHandleDecoration(api, formatMessage, activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, nodeViewPortalProviderAPI);
384
- decorations = decorations.add(newState.doc, [decs]);
385
- }
386
358
  if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing || isBlocksDragTargetDebug()) {
387
359
  // Remove drop target decoration when dragging stops
388
360
  const dropTargetDecs = decorations.find(undefined, undefined, spec => spec.type === 'drop-target-decoration');
@@ -390,7 +362,7 @@ export const oldApply = (api, formatMessage, tr, currentState, oldState, newStat
390
362
  }
391
363
 
392
364
  // Map active node position when the document changes
393
- const mappedActiveNodePos = tr.docChanged && activeNode ? !isPerformanceFix && activeNodeWithNewNodeType || {
365
+ const mappedActiveNodePos = tr.docChanged && activeNode ? {
394
366
  pos: tr.mapping.map(activeNode.pos),
395
367
  anchorName: activeNode.anchorName,
396
368
  nodeType: activeNode.nodeType
@@ -2,7 +2,7 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
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';
@@ -301,9 +301,6 @@ export const DragHandle = ({
301
301
  display: 'none'
302
302
  });
303
303
  useEffect(() => {
304
- if (fg('platform_editor_element_dnd_nested_type_error_fix')) {
305
- return;
306
- }
307
304
  let cleanUpTransitionListener;
308
305
  if (nodeType === 'extension' || nodeType === 'embedCard') {
309
306
  const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
@@ -326,32 +323,6 @@ export const DragHandle = ({
326
323
  (_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 ? void 0 : _cleanUpTransitionLis();
327
324
  };
328
325
  }, [calculatePosition, view.dom, anchorName, nodeType]);
329
- useLayoutEffect(() => {
330
- if (!fg('platform_editor_element_dnd_nested_type_error_fix')) {
331
- return;
332
- }
333
- let cleanUpTransitionListener;
334
- if (nodeType === 'extension' || nodeType === 'embedCard') {
335
- const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
336
- if (!dom) {
337
- return;
338
- }
339
- cleanUpTransitionListener = bind(dom, {
340
- type: 'transitionend',
341
- listener: () => {
342
- setPositionStyles(calculatePosition());
343
- }
344
- });
345
- }
346
- const calcPos = requestAnimationFrame(() => {
347
- setPositionStyles(calculatePosition());
348
- });
349
- return () => {
350
- var _cleanUpTransitionLis2;
351
- cancelAnimationFrame(calcPos);
352
- (_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 ? void 0 : _cleanUpTransitionLis2();
353
- };
354
- }, [calculatePosition, view.dom, anchorName, nodeType]);
355
326
  useEffect(() => {
356
327
  if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
357
328
  const id = requestAnimationFrame(() => {
@@ -2,13 +2,14 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { expandedState } from '@atlaskit/editor-common/expand';
5
6
  import { blockControlsMessages } from '@atlaskit/editor-common/messages';
6
7
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
7
8
  import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
8
9
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
9
10
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
10
11
  import { Selection } from '@atlaskit/editor-prosemirror/state';
11
- import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
12
+ import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
12
13
  import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
13
14
  import { fg } from '@atlaskit/platform-feature-flags';
14
15
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -165,13 +166,16 @@ export var moveNode = function moveNode(api) {
165
166
  if (!node) {
166
167
  return tr;
167
168
  }
169
+ var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
170
+ expand = _tr$doc$type$schema$n.expand,
171
+ nestedExpand = _tr$doc$type$schema$n.nestedExpand;
168
172
  var size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
169
173
  var end = start + size;
170
174
  var $from = tr.doc.resolve(start);
175
+ var $to = tr.doc.resolve(to);
171
176
  var mappedTo;
172
177
  if (editorExperiment('nested-dnd', true)) {
173
178
  var nodeCopy = tr.doc.slice(start, end, false); // cut the content
174
- var $to = tr.doc.resolve(to);
175
179
  var destType = $to.node().type;
176
180
  var destParent = $to.node($to.depth);
177
181
  var sourceNode = $from.nodeAfter;
@@ -215,6 +219,14 @@ export var moveNode = function moveNode(api) {
215
219
  });
216
220
  api === null || api === void 0 || api.core.actions.focus();
217
221
  var $mappedTo = tr.doc.resolve(mappedTo);
222
+ var expandAncestor = findParentNodeOfTypeClosestToPos($to, [expand, nestedExpand]);
223
+ if (expandAncestor && editorExperiment('nested-dnd', true) && fg('platform_editor_element_dnd_nested_fix_patch_6')) {
224
+ var wasExpandExpanded = expandedState.get(expandAncestor.node);
225
+ var updatedExpandAncestor = findParentNodeOfTypeClosestToPos($mappedTo, [expand, nestedExpand]);
226
+ if (wasExpandExpanded !== undefined && updatedExpandAncestor) {
227
+ expandedState.set(updatedExpandAncestor.node, wasExpandExpanded);
228
+ }
229
+ }
218
230
  if (editorExperiment('advanced_layouts', true)) {
219
231
  attachMoveNodeAnalytics(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
220
232
  } else {
@@ -249,7 +249,7 @@ export var oldApply = function oldApply(api, formatMessage, tr, currentState, ol
249
249
  // Ignored via go/ees005
250
250
  // eslint-disable-next-line @typescript-eslint/max-params
251
251
  ) {
252
- var _meta$activeNode2, _meta$activeNode$hand2, _activeNodeWithNewNod, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
252
+ var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
253
253
  var isNestedEnabled = flags.isNestedEnabled;
254
254
  var activeNode = currentState.activeNode,
255
255
  isMenuOpen = currentState.isMenuOpen,
@@ -266,10 +266,6 @@ export var oldApply = function oldApply(api, formatMessage, tr, currentState, ol
266
266
  decorations = decorations.map(tr.mapping, tr.doc);
267
267
  }
268
268
  var meta = tr.getMeta(key);
269
- var isPerformanceFix = isNestedEnabled || editorExperiment('dnd-input-performance-optimisation', true, {
270
- exposure: true
271
- });
272
- var activeNodeWithNewNodeType = null;
273
269
 
274
270
  // If tables or media are being resized, we want to hide the drag handle
275
271
  var resizerMeta = tr.getMeta('is-resizer-resizing');
@@ -332,6 +328,7 @@ export var oldApply = function oldApply(api, formatMessage, tr, currentState, ol
332
328
  var newNodeDecs = nodeDecorations(newState);
333
329
  decorations = decorations.add(newState.doc, _toConsumableArray(newNodeDecs));
334
330
  if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
331
+ var _meta$activeNode$pos, _meta$activeNode3, _ref6, _meta$activeNode$anch, _meta$activeNode4, _decAtPos$spec, _ref7, _meta$activeNode$node, _meta$activeNode5, _decAtPos$spec2, _meta$activeNode6;
335
332
  var mappedPosisiton = tr.mapping.map(activeNode.pos);
336
333
  var prevMappedPos = oldState.tr.mapping.map(activeNode.pos);
337
334
 
@@ -341,33 +338,16 @@ export var oldApply = function oldApply(api, formatMessage, tr, currentState, ol
341
338
  mappedPosisiton = prevMappedPos;
342
339
  }
343
340
  var _newActiveNode = tr.doc.nodeAt(mappedPosisiton);
344
- var draghandleDec;
345
- if (isPerformanceFix) {
346
- var _meta$activeNode$pos, _meta$activeNode3, _ref6, _meta$activeNode$anch, _meta$activeNode4, _decAtPos$spec, _ref7, _meta$activeNode$node, _meta$activeNode5, _decAtPos$spec2, _meta$activeNode6;
347
- if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
348
- var _oldHandle2 = decorations.find(undefined, undefined, function (spec) {
349
- return spec.type === 'drag-handle';
350
- });
351
- decorations = decorations.remove(_oldHandle2);
352
- }
353
- var decAtPos = newNodeDecs.find(function (dec) {
354
- return dec.from === mappedPosisiton;
341
+ if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
342
+ var _oldHandle2 = decorations.find(undefined, undefined, function (spec) {
343
+ return spec.type === 'drag-handle';
355
344
  });
356
- draghandleDec = dragHandleDecoration(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === void 0 || (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.pos) !== null && _meta$activeNode$pos !== void 0 ? _meta$activeNode$pos : mappedPosisiton, (_ref6 = (_meta$activeNode$anch = meta === null || meta === void 0 || (_meta$activeNode4 = meta.activeNode) === null || _meta$activeNode4 === void 0 ? void 0 : _meta$activeNode4.anchorName) !== null && _meta$activeNode$anch !== void 0 ? _meta$activeNode$anch : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref6 !== void 0 ? _ref6 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref7 = (_meta$activeNode$node = meta === null || meta === void 0 || (_meta$activeNode5 = meta.activeNode) === null || _meta$activeNode5 === void 0 ? void 0 : _meta$activeNode5.nodeType) !== null && _meta$activeNode$node !== void 0 ? _meta$activeNode$node : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref7 !== void 0 ? _ref7 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, nodeViewPortalProviderAPI, meta === null || meta === void 0 || (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
357
- } else {
358
- var nodeType = activeNode.nodeType;
359
- var anchorName = activeNode.anchorName;
360
- if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
361
- nodeType = _newActiveNode.type.name;
362
- anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
363
- activeNodeWithNewNodeType = {
364
- pos: prevMappedPos,
365
- nodeType: nodeType,
366
- anchorName: anchorName
367
- };
368
- }
369
- draghandleDec = dragHandleDecoration(api, formatMessage, activeNode.pos, anchorName, nodeType, nodeViewPortalProviderAPI);
345
+ decorations = decorations.remove(_oldHandle2);
370
346
  }
347
+ var decAtPos = newNodeDecs.find(function (dec) {
348
+ return dec.from === mappedPosisiton;
349
+ });
350
+ var draghandleDec = dragHandleDecoration(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === void 0 || (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.pos) !== null && _meta$activeNode$pos !== void 0 ? _meta$activeNode$pos : mappedPosisiton, (_ref6 = (_meta$activeNode$anch = meta === null || meta === void 0 || (_meta$activeNode4 = meta.activeNode) === null || _meta$activeNode4 === void 0 ? void 0 : _meta$activeNode4.anchorName) !== null && _meta$activeNode$anch !== void 0 ? _meta$activeNode$anch : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref6 !== void 0 ? _ref6 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref7 = (_meta$activeNode$node = meta === null || meta === void 0 || (_meta$activeNode5 = meta.activeNode) === null || _meta$activeNode5 === void 0 ? void 0 : _meta$activeNode5.nodeType) !== null && _meta$activeNode$node !== void 0 ? _meta$activeNode$node : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref7 !== void 0 ? _ref7 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, nodeViewPortalProviderAPI, meta === null || meta === void 0 || (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
371
351
  decorations = decorations.add(newState.doc, [draghandleDec]);
372
352
  }
373
353
  }
@@ -381,16 +361,6 @@ export var oldApply = function oldApply(api, formatMessage, tr, currentState, ol
381
361
  var decs = dragHandleDecoration(api, formatMessage, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, nodeViewPortalProviderAPI, meta.activeNode.handleOptions);
382
362
  decorations = decorations.add(newState.doc, [decs]);
383
363
  }
384
-
385
- // Remove previous drag handle widget and draw new drag handle widget when node type changes
386
- if (!isPerformanceFix && activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
387
- var _oldHandle4 = decorations.find(undefined, undefined, function (spec) {
388
- return spec.type === 'drag-handle';
389
- });
390
- decorations = decorations.remove(_oldHandle4);
391
- var _decs = dragHandleDecoration(api, formatMessage, activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, nodeViewPortalProviderAPI);
392
- decorations = decorations.add(newState.doc, [_decs]);
393
- }
394
364
  if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing || isBlocksDragTargetDebug()) {
395
365
  // Remove drop target decoration when dragging stops
396
366
  var dropTargetDecs = decorations.find(undefined, undefined, function (spec) {
@@ -400,7 +370,7 @@ export var oldApply = function oldApply(api, formatMessage, tr, currentState, ol
400
370
  }
401
371
 
402
372
  // Map active node position when the document changes
403
- var mappedActiveNodePos = tr.docChanged && activeNode ? !isPerformanceFix && activeNodeWithNewNodeType || {
373
+ var mappedActiveNodePos = tr.docChanged && activeNode ? {
404
374
  pos: tr.mapping.map(activeNode.pos),
405
375
  anchorName: activeNode.anchorName,
406
376
  nodeType: activeNode.nodeType
@@ -411,8 +381,8 @@ export var oldApply = function oldApply(api, formatMessage, tr, currentState, ol
411
381
  // if the transaction is only for analytics and user is dragging, continue to draw drop targets
412
382
  if (shouldCreateDropTargets || isBlocksDragTargetDebug()) {
413
383
  var _meta$activeNode7;
414
- var _decs2 = dropTargetDecorations(newState, api, formatMessage, nodeViewPortalProviderAPI, isNestedEnabled ? (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode, anchorRectCache);
415
- decorations = decorations.add(newState.doc, _decs2);
384
+ var _decs = dropTargetDecorations(newState, api, formatMessage, nodeViewPortalProviderAPI, isNestedEnabled ? (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode, anchorRectCache);
385
+ decorations = decorations.add(newState.doc, _decs);
416
386
  }
417
387
  }
418
388
  var isEmptyDoc = isNestedEnabled ? newState.doc.childCount === 1 && newState.doc.nodeSize <= 4 && (newState.doc.firstChild === null || newState.doc.firstChild.nodeSize <= 2) : newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  * @jsxRuntime classic
5
5
  * @jsx jsx
6
6
  */
7
- import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
7
+ import { useCallback, useEffect, 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 { bind } from 'bind-event-listener';
@@ -311,9 +311,6 @@ export var DragHandle = function DragHandle(_ref) {
311
311
  positionStyles = _useState6[0],
312
312
  setPositionStyles = _useState6[1];
313
313
  useEffect(function () {
314
- if (fg('platform_editor_element_dnd_nested_type_error_fix')) {
315
- return;
316
- }
317
314
  var cleanUpTransitionListener;
318
315
  if (nodeType === 'extension' || nodeType === 'embedCard') {
319
316
  var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
@@ -336,32 +333,6 @@ export var DragHandle = function DragHandle(_ref) {
336
333
  (_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
337
334
  };
338
335
  }, [calculatePosition, view.dom, anchorName, nodeType]);
339
- useLayoutEffect(function () {
340
- if (!fg('platform_editor_element_dnd_nested_type_error_fix')) {
341
- return;
342
- }
343
- var cleanUpTransitionListener;
344
- if (nodeType === 'extension' || nodeType === 'embedCard') {
345
- var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
346
- if (!dom) {
347
- return;
348
- }
349
- cleanUpTransitionListener = bind(dom, {
350
- type: 'transitionend',
351
- listener: function listener() {
352
- setPositionStyles(calculatePosition());
353
- }
354
- });
355
- }
356
- var calcPos = requestAnimationFrame(function () {
357
- setPositionStyles(calculatePosition());
358
- });
359
- return function () {
360
- var _cleanUpTransitionLis2;
361
- cancelAnimationFrame(calcPos);
362
- (_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 || _cleanUpTransitionLis2();
363
- };
364
- }, [calculatePosition, view.dom, anchorName, nodeType]);
365
336
  useEffect(function () {
366
337
  if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
367
338
  var id = requestAnimationFrame(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.17.4",
3
+ "version": "2.18.1",
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,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^46.1.0",
34
- "@atlaskit/editor-common": "^98.2.0",
34
+ "@atlaskit/editor-common": "^99.0.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/primitives": "^13.3.0",
50
50
  "@atlaskit/theme": "^14.0.0",
51
51
  "@atlaskit/tmp-editor-statsig": "^2.33.0",
52
- "@atlaskit/tokens": "^2.5.0",
52
+ "@atlaskit/tokens": "^3.0.0",
53
53
  "@atlaskit/tooltip": "^19.0.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@emotion/react": "^11.7.1",
@@ -124,7 +124,7 @@
124
124
  "platform_editor_element_dnd_nested_fix_patch_3": {
125
125
  "type": "boolean"
126
126
  },
127
- "platform_editor_element_dnd_nested_type_error_fix": {
127
+ "platform_editor_element_dnd_nested_fix_patch_6": {
128
128
  "type": "boolean"
129
129
  },
130
130
  "platform_editor_element_dnd_nested_a11y": {