@atlaskit/editor-plugin-block-controls 18.2.7 → 18.3.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,34 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 18.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 18.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`cc32ee1bcd20b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cc32ee1bcd20b) -
14
+ Behind the `platform_editor_controls_reliable_anchor` experiment and the
15
+ `platform_editor_controls_reliable_anchor_patch_1` feature gate, reduce active node decoration
16
+ recreation for reliable anchor.
17
+
18
+ Previously every document change scanned the full decoration set to find and recreate the active
19
+ drag handle and quick insert node decorations, which regressed VC90 on Edit and Live pages because
20
+ the scan ran on every keystroke.
21
+
22
+ `DecorationSet.map()` already validates node decorations as it maps them and drops any whose range
23
+ no longer exactly covers a node. This change records those removals via the `onRemove` callback of
24
+ the existing `map()` call, so the decorations are only recreated when they were actually
25
+ invalidated. The full-range scan is still used when the active node itself changes, since no
26
+ mapping runs in that case.
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies
31
+
3
32
  ## 18.2.7
4
33
 
5
34
  ### Patch Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.findHandleDec = exports.findActiveDragHandleNodeDec = exports.emptyParagraphNodeDecorations = exports.dragHandleDecoration = exports.createActiveDragHandleNodeDecoration = void 0;
7
+ exports.findHandleDec = exports.findActiveDragHandleNodeDec = exports.emptyParagraphNodeDecorations = exports.dragHandleDecoration = exports.createActiveDragHandleNodeDecoration = exports.TYPE_ACTIVE_HANDLE_DEC = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("react");
10
10
  var _uuid = require("uuid");
@@ -19,7 +19,7 @@ var _reactRootRegistry = require("./react-root-registry");
19
19
  var _marks = require("./utils/marks");
20
20
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
21
21
 
22
- var TYPE_ACTIVE_HANDLE_DEC = 'active-drag-handle-node';
22
+ var TYPE_ACTIVE_HANDLE_DEC = exports.TYPE_ACTIVE_HANDLE_DEC = 'active-drag-handle-node';
23
23
 
24
24
  /**
25
25
  * Creates a Decoration.node that marks the active node with `data-active-drag-handle="true"`.
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.quickInsertButtonDecoration = exports.findQuickInsertInsertButtonDecoration = exports.findActiveQuickInsertNodeDec = exports.createActiveQuickInsertNodeDecoration = void 0;
7
+ exports.quickInsertButtonDecoration = exports.findQuickInsertInsertButtonDecoration = exports.findActiveQuickInsertNodeDec = exports.createActiveQuickInsertNodeDecoration = exports.TYPE_ACTIVE_QUICK_INSERT_NODE = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("react");
10
10
  var _uuid = require("uuid");
@@ -18,7 +18,7 @@ var _marks = require("./utils/marks");
18
18
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
19
19
 
20
20
  var TYPE_QUICK_INSERT = 'INSERT_BUTTON';
21
- var TYPE_ACTIVE_QUICK_INSERT_NODE = 'active-quick-insert-node';
21
+ var TYPE_ACTIVE_QUICK_INSERT_NODE = exports.TYPE_ACTIVE_QUICK_INSERT_NODE = 'active-quick-insert-node';
22
22
  var findQuickInsertInsertButtonDecoration = exports.findQuickInsertInsertButtonDecoration = function findQuickInsertInsertButtonDecoration(decorations, from, to) {
23
23
  return decorations.find(from, to, function (spec) {
24
24
  return spec.type === TYPE_QUICK_INSERT;
@@ -27,6 +27,7 @@ var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
27
27
  var _combine = require("@atlaskit/pragmatic-drag-and-drop/utils/combine");
28
28
  var _elementAdapter = require("@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter");
29
29
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
30
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
30
31
  var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
31
32
  var _consts = require("../ui/consts");
32
33
  var _domAttrName = require("../ui/utils/dom-attr-name");
@@ -338,9 +339,32 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
338
339
  }
339
340
  }
340
341
 
342
+ // patch_1: DecorationSet.map() validates node decorations as it maps them — one whose range
343
+ // no longer exactly covers a node (e.g. after a split) is dropped rather than left misplaced.
344
+ // Recording that here lets the active-node decoration blocks below re-add only what actually
345
+ // went away, instead of scanning the whole decoration set on every keystroke (VC90).
346
+ // The active-node decorations only exist under the reliable anchor experiment, so the patch is
347
+ // scoped to it as well. No-exposure check as this runs on every document change; the blocks
348
+ // below that consume these flags are already inside an `expValEquals` guard for the same
349
+ // experiment, so the exposure is fired there.
350
+ var activeHandleDecDropped = false;
351
+ var activeQuickInsertDecDropped = false;
352
+
341
353
  // When steps exist, remap existing decorations, activeNode and multi select positions
342
354
  if (tr.docChanged) {
343
- decorations = decorations.map(tr.mapping, tr.doc);
355
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_controls_reliable_anchor', 'isEnabled', true) && (0, _fg.fg)('platform_editor_controls_reliable_anchor_patch_1')) {
356
+ decorations = decorations.map(tr.mapping, tr.doc, {
357
+ onRemove: function onRemove(spec) {
358
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === _decorationsDragHandle.TYPE_ACTIVE_HANDLE_DEC) {
359
+ activeHandleDecDropped = true;
360
+ } else if ((spec === null || spec === void 0 ? void 0 : spec.type) === _decorationsQuickInsertButton.TYPE_ACTIVE_QUICK_INSERT_NODE) {
361
+ activeQuickInsertDecDropped = true;
362
+ }
363
+ }
364
+ });
365
+ } else {
366
+ decorations = decorations.map(tr.mapping, tr.doc);
367
+ }
344
368
 
345
369
  // platform_editor_controls note: enables quick insert
346
370
  // don't remap activeNode if it's being dragged
@@ -597,12 +621,17 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
597
621
  // on that same anchor-name for their own CSS anchor() positioning, so this must still run
598
622
  // when such a consumer exists even if the legacy drag handle itself is disabled.
599
623
  nodeDecorationRegistry.length > 0) && (0, _expValEquals.expValEquals)('platform_editor_controls_reliable_anchor', 'isEnabled', true) && latestActiveNode) {
624
+ // patch_1: a plain doc change no longer forces a rescan — map() above has already
625
+ // either kept the decoration correctly positioned or dropped it as invalid, so we
626
+ // only need to act when it was actually dropped.
627
+ var docChangeInvalidatedNodeDec = (0, _fg.fg)('platform_editor_controls_reliable_anchor_patch_1') ? activeHandleDecDropped : tr.docChanged;
628
+
600
629
  // Recreate the drag handle node decoration when the active node changed,
601
- // its content was modified, or the document changed (e.g. Enter splits a node).
630
+ // its content was modified, or the document changed.
602
631
  // This runs independently of shouldRecreateHandle so that doc changes (like pressing
603
632
  // Enter) correctly refresh the decoration even when the handle widget doesn't move.
604
633
  // DecorationSet.map() can misplace the decoration after node splits/inserts.
605
- var needsNodeDecUpdate = activeNodeChanged || isActiveNodeModified || tr.docChanged;
634
+ var needsNodeDecUpdate = activeNodeChanged || isActiveNodeModified || docChangeInvalidatedNodeDec;
606
635
  if (needsNodeDecUpdate) {
607
636
  var _newState$doc$nodeAt;
608
637
  var nodeSize = (_newState$doc$nodeAt = newState.doc.nodeAt(latestActiveNode.pos)) === null || _newState$doc$nodeAt === void 0 ? void 0 : _newState$doc$nodeAt.nodeSize;
@@ -625,9 +654,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
625
654
  // independently of the edit-mode node — e.g. when only editorSizeChanged fires but
626
655
  // rootActiveNodeChanged is also true. So we use a separate, broader guard that
627
656
  // includes rootActiveNodeChanged to avoid leaving the attribute on a stale root node.
628
- // tr.docChanged is included for the same reason as needsNodeDecUpdate: DecorationSet.map()
629
- // can misplace the decoration after a node split, so we must refresh it on every doc change.
630
- var needsQuickInsertDecUpdate = activeNodeChanged || isActiveNodeModified || rootActiveNodeChanged || tr.docChanged;
657
+ var needsQuickInsertDecUpdate = activeNodeChanged || isActiveNodeModified || rootActiveNodeChanged || ((0, _fg.fg)('platform_editor_controls_reliable_anchor_patch_1') ? activeQuickInsertDecDropped : tr.docChanged);
631
658
  if (needsQuickInsertDecUpdate && latestActiveNode.rootPos !== undefined) {
632
659
  var _newState$doc$nodeAt2;
633
660
  var rootNodeSize = (_newState$doc$nodeAt2 = newState.doc.nodeAt(latestActiveNode.rootPos)) === null || _newState$doc$nodeAt2 === void 0 ? void 0 : _newState$doc$nodeAt2.nodeSize;
@@ -10,7 +10,7 @@ import { DragHandle, DragHandleWithVisibility } from '../ui/drag-handle';
10
10
  import { TYPE_HANDLE_DEC, TYPE_NODE_DEC, unmountDecorations } from './decorations-common';
11
11
  import { renderToMountPoint } from './react-root-registry';
12
12
  import { getMatchingBlockMarks } from './utils/marks';
13
- const TYPE_ACTIVE_HANDLE_DEC = 'active-drag-handle-node';
13
+ export const TYPE_ACTIVE_HANDLE_DEC = 'active-drag-handle-node';
14
14
 
15
15
  /**
16
16
  * Creates a Decoration.node that marks the active node with `data-active-drag-handle="true"`.
@@ -9,7 +9,7 @@ import { ACTIVE_QUICK_INSERT_ATTR } from '../ui/consts';
9
9
  import { QuickInsertWithVisibility } from '../ui/quick-insert-button';
10
10
  import { getMatchingBlockMarks } from './utils/marks';
11
11
  const TYPE_QUICK_INSERT = 'INSERT_BUTTON';
12
- const TYPE_ACTIVE_QUICK_INSERT_NODE = 'active-quick-insert-node';
12
+ export const TYPE_ACTIVE_QUICK_INSERT_NODE = 'active-quick-insert-node';
13
13
  export const findQuickInsertInsertButtonDecoration = (decorations, from, to) => {
14
14
  return decorations.find(from, to, spec => spec.type === TYPE_QUICK_INSERT);
15
15
  };
@@ -19,14 +19,15 @@ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-sc
19
19
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/utils/combine';
20
20
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
21
21
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
22
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
22
23
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
23
24
  import { BLOCK_CONTROLS_SURFACE_SELECTOR } from '../ui/consts';
24
25
  import { getAnchorAttrName } from '../ui/utils/dom-attr-name';
25
26
  import { findNodeDecs, nodeDecorations } from './decorations-anchor';
26
- import { createActiveDragHandleNodeDecoration, dragHandleDecoration, emptyParagraphNodeDecorations, findActiveDragHandleNodeDec, findHandleDec } from './decorations-drag-handle';
27
+ import { createActiveDragHandleNodeDecoration, dragHandleDecoration, emptyParagraphNodeDecorations, findActiveDragHandleNodeDec, findHandleDec, TYPE_ACTIVE_HANDLE_DEC } from './decorations-drag-handle';
27
28
  import { dropTargetDecorations, findDropTargetDecs } from './decorations-drop-target';
28
29
  import { getActiveDropTargetDecorations } from './decorations-drop-target-active';
29
- import { createActiveQuickInsertNodeDecoration, findActiveQuickInsertNodeDec, findQuickInsertInsertButtonDecoration, quickInsertButtonDecoration } from './decorations-quick-insert-button';
30
+ import { createActiveQuickInsertNodeDecoration, findActiveQuickInsertNodeDec, findQuickInsertInsertButtonDecoration, quickInsertButtonDecoration, TYPE_ACTIVE_QUICK_INSERT_NODE } from './decorations-quick-insert-button';
30
31
  import { handleMouseDown } from './handle-mouse-down';
31
32
  import { handleMouseOver } from './handle-mouse-over';
32
33
  import { boundKeydownHandler } from './keymap';
@@ -329,9 +330,32 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
329
330
  }
330
331
  }
331
332
 
333
+ // patch_1: DecorationSet.map() validates node decorations as it maps them — one whose range
334
+ // no longer exactly covers a node (e.g. after a split) is dropped rather than left misplaced.
335
+ // Recording that here lets the active-node decoration blocks below re-add only what actually
336
+ // went away, instead of scanning the whole decoration set on every keystroke (VC90).
337
+ // The active-node decorations only exist under the reliable anchor experiment, so the patch is
338
+ // scoped to it as well. No-exposure check as this runs on every document change; the blocks
339
+ // below that consume these flags are already inside an `expValEquals` guard for the same
340
+ // experiment, so the exposure is fired there.
341
+ let activeHandleDecDropped = false;
342
+ let activeQuickInsertDecDropped = false;
343
+
332
344
  // When steps exist, remap existing decorations, activeNode and multi select positions
333
345
  if (tr.docChanged) {
334
- decorations = decorations.map(tr.mapping, tr.doc);
346
+ if (expValEqualsNoExposure('platform_editor_controls_reliable_anchor', 'isEnabled', true) && fg('platform_editor_controls_reliable_anchor_patch_1')) {
347
+ decorations = decorations.map(tr.mapping, tr.doc, {
348
+ onRemove: spec => {
349
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === TYPE_ACTIVE_HANDLE_DEC) {
350
+ activeHandleDecDropped = true;
351
+ } else if ((spec === null || spec === void 0 ? void 0 : spec.type) === TYPE_ACTIVE_QUICK_INSERT_NODE) {
352
+ activeQuickInsertDecDropped = true;
353
+ }
354
+ }
355
+ });
356
+ } else {
357
+ decorations = decorations.map(tr.mapping, tr.doc);
358
+ }
335
359
 
336
360
  // platform_editor_controls note: enables quick insert
337
361
  // don't remap activeNode if it's being dragged
@@ -558,12 +582,17 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
558
582
  // on that same anchor-name for their own CSS anchor() positioning, so this must still run
559
583
  // when such a consumer exists even if the legacy drag handle itself is disabled.
560
584
  nodeDecorationRegistry.length > 0) && expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) && latestActiveNode) {
585
+ // patch_1: a plain doc change no longer forces a rescan — map() above has already
586
+ // either kept the decoration correctly positioned or dropped it as invalid, so we
587
+ // only need to act when it was actually dropped.
588
+ const docChangeInvalidatedNodeDec = fg('platform_editor_controls_reliable_anchor_patch_1') ? activeHandleDecDropped : tr.docChanged;
589
+
561
590
  // Recreate the drag handle node decoration when the active node changed,
562
- // its content was modified, or the document changed (e.g. Enter splits a node).
591
+ // its content was modified, or the document changed.
563
592
  // This runs independently of shouldRecreateHandle so that doc changes (like pressing
564
593
  // Enter) correctly refresh the decoration even when the handle widget doesn't move.
565
594
  // DecorationSet.map() can misplace the decoration after node splits/inserts.
566
- const needsNodeDecUpdate = activeNodeChanged || isActiveNodeModified || tr.docChanged;
595
+ const needsNodeDecUpdate = activeNodeChanged || isActiveNodeModified || docChangeInvalidatedNodeDec;
567
596
  if (needsNodeDecUpdate) {
568
597
  var _newState$doc$nodeAt;
569
598
  const nodeSize = (_newState$doc$nodeAt = newState.doc.nodeAt(latestActiveNode.pos)) === null || _newState$doc$nodeAt === void 0 ? void 0 : _newState$doc$nodeAt.nodeSize;
@@ -586,9 +615,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
586
615
  // independently of the edit-mode node — e.g. when only editorSizeChanged fires but
587
616
  // rootActiveNodeChanged is also true. So we use a separate, broader guard that
588
617
  // includes rootActiveNodeChanged to avoid leaving the attribute on a stale root node.
589
- // tr.docChanged is included for the same reason as needsNodeDecUpdate: DecorationSet.map()
590
- // can misplace the decoration after a node split, so we must refresh it on every doc change.
591
- const needsQuickInsertDecUpdate = activeNodeChanged || isActiveNodeModified || rootActiveNodeChanged || tr.docChanged;
618
+ const needsQuickInsertDecUpdate = activeNodeChanged || isActiveNodeModified || rootActiveNodeChanged || (fg('platform_editor_controls_reliable_anchor_patch_1') ? activeQuickInsertDecDropped : tr.docChanged);
592
619
  if (needsQuickInsertDecUpdate && latestActiveNode.rootPos !== undefined) {
593
620
  var _newState$doc$nodeAt2;
594
621
  const rootNodeSize = (_newState$doc$nodeAt2 = newState.doc.nodeAt(latestActiveNode.rootPos)) === null || _newState$doc$nodeAt2 === void 0 ? void 0 : _newState$doc$nodeAt2.nodeSize;
@@ -11,7 +11,7 @@ import { DragHandle, DragHandleWithVisibility } from '../ui/drag-handle';
11
11
  import { TYPE_HANDLE_DEC, TYPE_NODE_DEC, unmountDecorations } from './decorations-common';
12
12
  import { renderToMountPoint } from './react-root-registry';
13
13
  import { getMatchingBlockMarks } from './utils/marks';
14
- var TYPE_ACTIVE_HANDLE_DEC = 'active-drag-handle-node';
14
+ export var TYPE_ACTIVE_HANDLE_DEC = 'active-drag-handle-node';
15
15
 
16
16
  /**
17
17
  * Creates a Decoration.node that marks the active node with `data-active-drag-handle="true"`.
@@ -10,7 +10,7 @@ import { ACTIVE_QUICK_INSERT_ATTR } from '../ui/consts';
10
10
  import { QuickInsertWithVisibility } from '../ui/quick-insert-button';
11
11
  import { getMatchingBlockMarks } from './utils/marks';
12
12
  var TYPE_QUICK_INSERT = 'INSERT_BUTTON';
13
- var TYPE_ACTIVE_QUICK_INSERT_NODE = 'active-quick-insert-node';
13
+ export var TYPE_ACTIVE_QUICK_INSERT_NODE = 'active-quick-insert-node';
14
14
  export var findQuickInsertInsertButtonDecoration = function findQuickInsertInsertButtonDecoration(decorations, from, to) {
15
15
  return decorations.find(from, to, function (spec) {
16
16
  return spec.type === TYPE_QUICK_INSERT;
@@ -25,14 +25,15 @@ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-sc
25
25
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/utils/combine';
26
26
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
27
27
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
28
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
28
29
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
29
30
  import { BLOCK_CONTROLS_SURFACE_SELECTOR } from '../ui/consts';
30
31
  import { getAnchorAttrName } from '../ui/utils/dom-attr-name';
31
32
  import { findNodeDecs, nodeDecorations } from './decorations-anchor';
32
- import { createActiveDragHandleNodeDecoration, dragHandleDecoration, emptyParagraphNodeDecorations, findActiveDragHandleNodeDec, findHandleDec } from './decorations-drag-handle';
33
+ import { createActiveDragHandleNodeDecoration, dragHandleDecoration, emptyParagraphNodeDecorations, findActiveDragHandleNodeDec, findHandleDec, TYPE_ACTIVE_HANDLE_DEC } from './decorations-drag-handle';
33
34
  import { dropTargetDecorations, findDropTargetDecs } from './decorations-drop-target';
34
35
  import { getActiveDropTargetDecorations } from './decorations-drop-target-active';
35
- import { createActiveQuickInsertNodeDecoration, findActiveQuickInsertNodeDec, findQuickInsertInsertButtonDecoration, quickInsertButtonDecoration } from './decorations-quick-insert-button';
36
+ import { createActiveQuickInsertNodeDecoration, findActiveQuickInsertNodeDec, findQuickInsertInsertButtonDecoration, quickInsertButtonDecoration, TYPE_ACTIVE_QUICK_INSERT_NODE } from './decorations-quick-insert-button';
36
37
  import { handleMouseDown } from './handle-mouse-down';
37
38
  import { handleMouseOver } from './handle-mouse-over';
38
39
  import { boundKeydownHandler } from './keymap';
@@ -331,9 +332,32 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
331
332
  }
332
333
  }
333
334
 
335
+ // patch_1: DecorationSet.map() validates node decorations as it maps them — one whose range
336
+ // no longer exactly covers a node (e.g. after a split) is dropped rather than left misplaced.
337
+ // Recording that here lets the active-node decoration blocks below re-add only what actually
338
+ // went away, instead of scanning the whole decoration set on every keystroke (VC90).
339
+ // The active-node decorations only exist under the reliable anchor experiment, so the patch is
340
+ // scoped to it as well. No-exposure check as this runs on every document change; the blocks
341
+ // below that consume these flags are already inside an `expValEquals` guard for the same
342
+ // experiment, so the exposure is fired there.
343
+ var activeHandleDecDropped = false;
344
+ var activeQuickInsertDecDropped = false;
345
+
334
346
  // When steps exist, remap existing decorations, activeNode and multi select positions
335
347
  if (tr.docChanged) {
336
- decorations = decorations.map(tr.mapping, tr.doc);
348
+ if (expValEqualsNoExposure('platform_editor_controls_reliable_anchor', 'isEnabled', true) && fg('platform_editor_controls_reliable_anchor_patch_1')) {
349
+ decorations = decorations.map(tr.mapping, tr.doc, {
350
+ onRemove: function onRemove(spec) {
351
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === TYPE_ACTIVE_HANDLE_DEC) {
352
+ activeHandleDecDropped = true;
353
+ } else if ((spec === null || spec === void 0 ? void 0 : spec.type) === TYPE_ACTIVE_QUICK_INSERT_NODE) {
354
+ activeQuickInsertDecDropped = true;
355
+ }
356
+ }
357
+ });
358
+ } else {
359
+ decorations = decorations.map(tr.mapping, tr.doc);
360
+ }
337
361
 
338
362
  // platform_editor_controls note: enables quick insert
339
363
  // don't remap activeNode if it's being dragged
@@ -590,12 +614,17 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
590
614
  // on that same anchor-name for their own CSS anchor() positioning, so this must still run
591
615
  // when such a consumer exists even if the legacy drag handle itself is disabled.
592
616
  nodeDecorationRegistry.length > 0) && expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) && latestActiveNode) {
617
+ // patch_1: a plain doc change no longer forces a rescan — map() above has already
618
+ // either kept the decoration correctly positioned or dropped it as invalid, so we
619
+ // only need to act when it was actually dropped.
620
+ var docChangeInvalidatedNodeDec = fg('platform_editor_controls_reliable_anchor_patch_1') ? activeHandleDecDropped : tr.docChanged;
621
+
593
622
  // Recreate the drag handle node decoration when the active node changed,
594
- // its content was modified, or the document changed (e.g. Enter splits a node).
623
+ // its content was modified, or the document changed.
595
624
  // This runs independently of shouldRecreateHandle so that doc changes (like pressing
596
625
  // Enter) correctly refresh the decoration even when the handle widget doesn't move.
597
626
  // DecorationSet.map() can misplace the decoration after node splits/inserts.
598
- var needsNodeDecUpdate = activeNodeChanged || isActiveNodeModified || tr.docChanged;
627
+ var needsNodeDecUpdate = activeNodeChanged || isActiveNodeModified || docChangeInvalidatedNodeDec;
599
628
  if (needsNodeDecUpdate) {
600
629
  var _newState$doc$nodeAt;
601
630
  var nodeSize = (_newState$doc$nodeAt = newState.doc.nodeAt(latestActiveNode.pos)) === null || _newState$doc$nodeAt === void 0 ? void 0 : _newState$doc$nodeAt.nodeSize;
@@ -618,9 +647,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
618
647
  // independently of the edit-mode node — e.g. when only editorSizeChanged fires but
619
648
  // rootActiveNodeChanged is also true. So we use a separate, broader guard that
620
649
  // includes rootActiveNodeChanged to avoid leaving the attribute on a stale root node.
621
- // tr.docChanged is included for the same reason as needsNodeDecUpdate: DecorationSet.map()
622
- // can misplace the decoration after a node split, so we must refresh it on every doc change.
623
- var needsQuickInsertDecUpdate = activeNodeChanged || isActiveNodeModified || rootActiveNodeChanged || tr.docChanged;
650
+ var needsQuickInsertDecUpdate = activeNodeChanged || isActiveNodeModified || rootActiveNodeChanged || (fg('platform_editor_controls_reliable_anchor_patch_1') ? activeQuickInsertDecDropped : tr.docChanged);
624
651
  if (needsQuickInsertDecUpdate && latestActiveNode.rootPos !== undefined) {
625
652
  var _newState$doc$nodeAt2;
626
653
  var rootNodeSize = (_newState$doc$nodeAt2 = newState.doc.nodeAt(latestActiveNode.rootPos)) === null || _newState$doc$nodeAt2 === void 0 ? void 0 : _newState$doc$nodeAt2.nodeSize;
@@ -6,6 +6,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
7
  import type { BlockControlsPlugin, HandleOptions } from '../blockControlsPluginType';
8
8
  import type { AnchorRectCache } from './utils/anchor-utils';
9
+ export declare const TYPE_ACTIVE_HANDLE_DEC = "active-drag-handle-node";
9
10
  /**
10
11
  * Creates a Decoration.node that marks the active node with `data-active-drag-handle="true"`.
11
12
  * The CSS in staticControlsAnchorStyles then applies `anchor-name` to this attribute,
@@ -6,6 +6,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
7
  import type { BlockControlsPlugin } from '../blockControlsPluginType';
8
8
  import type { AnchorRectCache } from './utils/anchor-utils';
9
+ export declare const TYPE_ACTIVE_QUICK_INSERT_NODE = "active-quick-insert-node";
9
10
  export declare const findQuickInsertInsertButtonDecoration: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
10
11
  type QuickInsertButtonDecorationParams = {
11
12
  anchorName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "18.2.7",
3
+ "version": "18.3.1",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  "@atlaskit/editor-plugin-user-intent": "^15.0.0",
43
43
  "@atlaskit/editor-plugin-width": "^18.0.0",
44
44
  "@atlaskit/editor-prosemirror": "^8.0.0",
45
- "@atlaskit/editor-shared-styles": "^4.1.0",
45
+ "@atlaskit/editor-shared-styles": "^4.2.0",
46
46
  "@atlaskit/editor-tables": "^3.2.0",
47
47
  "@atlaskit/editor-ui-control-model": "^2.9.0",
48
48
  "@atlaskit/icon": "^37.6.0",
@@ -56,8 +56,8 @@
56
56
  "@atlaskit/primitives": "^22.5.0",
57
57
  "@atlaskit/section-message": "^10.2.0",
58
58
  "@atlaskit/theme": "^28.2.0",
59
- "@atlaskit/tmp-editor-statsig": "^185.0.0",
60
- "@atlaskit/tokens": "^16.11.0",
59
+ "@atlaskit/tmp-editor-statsig": "^187.0.0",
60
+ "@atlaskit/tokens": "^16.12.0",
61
61
  "@atlaskit/tooltip": "^24.3.0",
62
62
  "@babel/runtime": "^7.0.0",
63
63
  "@compiled/react": "^1.0.2",
@@ -68,7 +68,7 @@
68
68
  "uuid": "^11.1.1"
69
69
  },
70
70
  "peerDependencies": {
71
- "@atlaskit/editor-common": "^121.3.0",
71
+ "@atlaskit/editor-common": "^121.4.0",
72
72
  "react": "^18.2.0 || ^19.2.0",
73
73
  "react-dom": "^18.2.0 || ^19.2.0",
74
74
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"