@atlaskit/editor-plugin-block-controls 20.0.3 → 20.1.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/blockControlsPlugin.js +53 -17
  3. package/dist/cjs/editor-commands/show-drag-handle.js +17 -5
  4. package/dist/cjs/pm-plugins/decorations-anchor.js +2 -1
  5. package/dist/cjs/pm-plugins/decorations-drop-target-active.js +2 -1
  6. package/dist/cjs/pm-plugins/decorations-drop-target.js +2 -1
  7. package/dist/cjs/pm-plugins/decorations-surface-anchor.js +72 -0
  8. package/dist/cjs/pm-plugins/handle-mouse-down.js +2 -1
  9. package/dist/cjs/pm-plugins/handle-mouse-over.js +3 -2
  10. package/dist/cjs/pm-plugins/handle-sparse-mouse-over.js +125 -0
  11. package/dist/cjs/pm-plugins/main.js +66 -54
  12. package/dist/cjs/pm-plugins/sparse-surfaces.js +49 -0
  13. package/dist/cjs/pm-plugins/utils/sparse-surface-candidates.js +419 -0
  14. package/dist/cjs/pm-plugins/utils/sparse-surfaces-mapping.js +108 -0
  15. package/dist/cjs/pm-plugins/utils/sparse-surfaces-state.js +53 -0
  16. package/dist/cjs/pm-plugins/utils/sparse-surfaces-view.js +134 -0
  17. package/dist/cjs/pm-plugins/utils/surface-viewport.js +223 -0
  18. package/dist/cjs/pm-plugins/utils/transactions.js +5 -0
  19. package/dist/cjs/ui/block-controls-left-surfaces.js +31 -25
  20. package/dist/cjs/ui/block-controls-right-surfaces.js +31 -25
  21. package/dist/cjs/ui/block-controls-surface-context.js +1 -0
  22. package/dist/cjs/ui/block-controls-surface-drag-handle-registration.js +6 -7
  23. package/dist/cjs/ui/block-controls-surface-drag-handle.js +6 -2
  24. package/dist/cjs/ui/drag-handle.js +5 -3
  25. package/dist/cjs/ui/drop-target-layout.js +3 -2
  26. package/dist/cjs/ui/drop-target.js +3 -2
  27. package/dist/cjs/ui/global-styles.js +69 -27
  28. package/dist/cjs/ui/inline-drop-target.js +6 -5
  29. package/dist/cjs/ui/utils/anchor-name.js +2 -1
  30. package/dist/cjs/ui/utils/dom-attr-name.js +3 -2
  31. package/dist/cjs/ui/utils/get-surface-placement.js +2 -1
  32. package/dist/es2019/blockControlsPlugin.js +42 -8
  33. package/dist/es2019/editor-commands/show-drag-handle.js +14 -2
  34. package/dist/es2019/pm-plugins/decorations-anchor.js +2 -1
  35. package/dist/es2019/pm-plugins/decorations-drop-target-active.js +2 -1
  36. package/dist/es2019/pm-plugins/decorations-drop-target.js +2 -1
  37. package/dist/es2019/pm-plugins/decorations-surface-anchor.js +56 -0
  38. package/dist/es2019/pm-plugins/handle-mouse-down.js +2 -1
  39. package/dist/es2019/pm-plugins/handle-mouse-over.js +3 -2
  40. package/dist/es2019/pm-plugins/handle-sparse-mouse-over.js +116 -0
  41. package/dist/es2019/pm-plugins/main.js +70 -54
  42. package/dist/es2019/pm-plugins/sparse-surfaces.js +37 -0
  43. package/dist/es2019/pm-plugins/utils/sparse-surface-candidates.js +305 -0
  44. package/dist/es2019/pm-plugins/utils/sparse-surfaces-mapping.js +78 -0
  45. package/dist/es2019/pm-plugins/utils/sparse-surfaces-state.js +39 -0
  46. package/dist/es2019/pm-plugins/utils/sparse-surfaces-view.js +121 -0
  47. package/dist/es2019/pm-plugins/utils/surface-viewport.js +192 -0
  48. package/dist/es2019/pm-plugins/utils/transactions.js +5 -0
  49. package/dist/es2019/ui/block-controls-left-surfaces.js +21 -14
  50. package/dist/es2019/ui/block-controls-right-surfaces.js +21 -14
  51. package/dist/es2019/ui/block-controls-surface-context.js +1 -0
  52. package/dist/es2019/ui/block-controls-surface-drag-handle-registration.js +4 -5
  53. package/dist/es2019/ui/block-controls-surface-drag-handle.js +6 -2
  54. package/dist/es2019/ui/drag-handle.js +5 -3
  55. package/dist/es2019/ui/drop-target-layout.js +3 -2
  56. package/dist/es2019/ui/drop-target.js +3 -2
  57. package/dist/es2019/ui/global-styles.js +67 -28
  58. package/dist/es2019/ui/inline-drop-target.js +6 -5
  59. package/dist/es2019/ui/utils/anchor-name.js +2 -1
  60. package/dist/es2019/ui/utils/dom-attr-name.js +3 -2
  61. package/dist/es2019/ui/utils/get-surface-placement.js +2 -1
  62. package/dist/esm/blockControlsPlugin.js +53 -17
  63. package/dist/esm/editor-commands/show-drag-handle.js +17 -5
  64. package/dist/esm/pm-plugins/decorations-anchor.js +2 -1
  65. package/dist/esm/pm-plugins/decorations-drop-target-active.js +2 -1
  66. package/dist/esm/pm-plugins/decorations-drop-target.js +2 -1
  67. package/dist/esm/pm-plugins/decorations-surface-anchor.js +65 -0
  68. package/dist/esm/pm-plugins/handle-mouse-down.js +2 -1
  69. package/dist/esm/pm-plugins/handle-mouse-over.js +3 -2
  70. package/dist/esm/pm-plugins/handle-sparse-mouse-over.js +119 -0
  71. package/dist/esm/pm-plugins/main.js +66 -54
  72. package/dist/esm/pm-plugins/sparse-surfaces.js +43 -0
  73. package/dist/esm/pm-plugins/utils/sparse-surface-candidates.js +413 -0
  74. package/dist/esm/pm-plugins/utils/sparse-surfaces-mapping.js +101 -0
  75. package/dist/esm/pm-plugins/utils/sparse-surfaces-state.js +46 -0
  76. package/dist/esm/pm-plugins/utils/sparse-surfaces-view.js +127 -0
  77. package/dist/esm/pm-plugins/utils/surface-viewport.js +217 -0
  78. package/dist/esm/pm-plugins/utils/transactions.js +5 -0
  79. package/dist/esm/ui/block-controls-left-surfaces.js +33 -27
  80. package/dist/esm/ui/block-controls-right-surfaces.js +33 -27
  81. package/dist/esm/ui/block-controls-surface-context.js +1 -0
  82. package/dist/esm/ui/block-controls-surface-drag-handle-registration.js +7 -8
  83. package/dist/esm/ui/block-controls-surface-drag-handle.js +6 -2
  84. package/dist/esm/ui/drag-handle.js +5 -3
  85. package/dist/esm/ui/drop-target-layout.js +3 -2
  86. package/dist/esm/ui/drop-target.js +3 -2
  87. package/dist/esm/ui/global-styles.js +70 -28
  88. package/dist/esm/ui/inline-drop-target.js +6 -5
  89. package/dist/esm/ui/utils/anchor-name.js +2 -1
  90. package/dist/esm/ui/utils/dom-attr-name.js +3 -2
  91. package/dist/esm/ui/utils/get-surface-placement.js +2 -1
  92. package/dist/types/blockControlsPluginType.d.ts +10 -3
  93. package/dist/types/pm-plugins/decorations-surface-anchor.d.ts +22 -0
  94. package/dist/types/pm-plugins/handle-sparse-mouse-over.d.ts +5 -0
  95. package/dist/types/pm-plugins/main.d.ts +2 -9
  96. package/dist/types/pm-plugins/sparse-surfaces.d.ts +8 -0
  97. package/dist/types/pm-plugins/utils/sparse-surface-candidates.d.ts +89 -0
  98. package/dist/types/pm-plugins/utils/sparse-surfaces-mapping.d.ts +20 -0
  99. package/dist/types/pm-plugins/utils/sparse-surfaces-state.d.ts +27 -0
  100. package/dist/types/pm-plugins/utils/sparse-surfaces-view.d.ts +15 -0
  101. package/dist/types/pm-plugins/utils/surface-viewport.d.ts +10 -0
  102. package/dist/types/ui/utils/get-surface-placement.d.ts +3 -2
  103. package/package.json +5 -5
  104. package/dist/cjs/pm-plugins/utils/surface-node-positions.js +0 -100
  105. package/dist/es2019/pm-plugins/utils/surface-node-positions.js +0 -78
  106. package/dist/esm/pm-plugins/utils/surface-node-positions.js +0 -93
  107. package/dist/types/pm-plugins/utils/surface-node-positions.d.ts +0 -14
@@ -0,0 +1,119 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
4
+ import { getNodeTypeWithLevel } from './decorations-common';
5
+ var OPAQUE_BLOCKS = new Set(['table', 'bulletList', 'orderedList', 'taskList', 'decisionList', 'mediaSingle']);
6
+ var EXCLUDED_BLOCKS = new Set(['listItem', 'tableRow', 'tableCell', 'tableHeader', 'caption']);
7
+ var isPanelNodeTypeName = function isPanelNodeTypeName(nodeTypeName) {
8
+ return nodeTypeName === 'panel' || nodeTypeName === 'panel_c1' && expValEqualsNoExposure('platform_editor_controls_reliable_anchor', 'isEnabled', true) && fg('platform_editor_controls_reliable_anchor_patch_1');
9
+ };
10
+ var redirectParagraphToWrappedMedia = function redirectParagraphToWrappedMedia(view, $target, targetPosition) {
11
+ var node = view.state.doc.nodeAt(targetPosition);
12
+ if (!node || node.type.name !== 'paragraph') {
13
+ return {
14
+ position: targetPosition,
15
+ node: node
16
+ };
17
+ }
18
+ var index = $target.index();
19
+ for (var _i = 0, _arr = [index - 1, index + 1]; _i < _arr.length; _i++) {
20
+ var siblingIndex = _arr[_i];
21
+ if (siblingIndex < 0 || siblingIndex >= $target.parent.childCount) {
22
+ continue;
23
+ }
24
+ var sibling = $target.parent.child(siblingIndex);
25
+ if ((sibling.type.name === 'mediaSingle' || sibling.type.name === 'embedCard') && (sibling.attrs.layout === 'wrap-left' || sibling.attrs.layout === 'wrap-right')) {
26
+ return {
27
+ position: siblingIndex < index ? targetPosition - sibling.nodeSize : targetPosition + node.nodeSize,
28
+ node: sibling
29
+ };
30
+ }
31
+ }
32
+ return {
33
+ position: targetPosition,
34
+ node: node
35
+ };
36
+ };
37
+
38
+ /** Resolves hover from PM structure so the first hover can create its sparse candidate. */
39
+ export var handleSparseMouseOver = function handleSparseMouseOver(view, event, api) {
40
+ var _api$editorDisabled$s, _api$editorDisabled, _api$editorViewMode, _api$showDiff$sharedS, _api$showDiff, _api$userIntent, _$pos$nodeAfter, _controls$activeNode, _anchors$get, _anchors$get2;
41
+ var controls = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
42
+ if (!api || controls !== null && controls !== void 0 && controls.isDragging || !(event.target instanceof Element) || event.target === view.dom) {
43
+ return false;
44
+ }
45
+ var editorDisabled = (_api$editorDisabled$s = (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled) !== null && _api$editorDisabled$s !== void 0 ? _api$editorDisabled$s : false;
46
+ var editorViewMode = (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode;
47
+ if (editorDisabled && (editorViewMode !== 'view' || !(controls !== null && controls !== void 0 && controls.rightSideControlsEnabled))) {
48
+ return false;
49
+ }
50
+ var isDisplayingDiff = (_api$showDiff$sharedS = (_api$showDiff = api.showDiff) === null || _api$showDiff === void 0 || (_api$showDiff = _api$showDiff.sharedState.currentState()) === null || _api$showDiff === void 0 ? void 0 : _api$showDiff.isDisplayingChanges) !== null && _api$showDiff$sharedS !== void 0 ? _api$showDiff$sharedS : false;
51
+ var currentUserIntent = (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent;
52
+ if ((isDisplayingDiff || currentUserIntent === 'reviewing') && expValEqualsNoExposure('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
53
+ return false;
54
+ }
55
+ var position;
56
+ try {
57
+ position = view.posAtDOM(event.target, 0);
58
+ } catch (_unused) {
59
+ return false;
60
+ }
61
+ var $pos = view.state.doc.resolve(position);
62
+ var targetPosition;
63
+ var opaque = false;
64
+ for (var depth = 1; depth <= $pos.depth; depth++) {
65
+ var _node = $pos.node(depth);
66
+ if (!_node.isBlock || EXCLUDED_BLOCKS.has(_node.type.name)) {
67
+ continue;
68
+ }
69
+ targetPosition = $pos.before(depth);
70
+ if (OPAQUE_BLOCKS.has(_node.type.name)) {
71
+ opaque = true;
72
+ break;
73
+ }
74
+ }
75
+ if (!opaque && (_$pos$nodeAfter = $pos.nodeAfter) !== null && _$pos$nodeAfter !== void 0 && _$pos$nodeAfter.isBlock && !EXCLUDED_BLOCKS.has($pos.nodeAfter.type.name)) {
76
+ // Browser positions over non-editable node chrome can resolve to the first editable child.
77
+ // Keep the ancestor unless that child actually owns the hovered DOM target.
78
+ var nodeAfterDOM = view.nodeDOM(position);
79
+ if (nodeAfterDOM instanceof Element && nodeAfterDOM.contains(event.target)) {
80
+ targetPosition = position;
81
+ }
82
+ }
83
+ if (targetPosition === undefined) {
84
+ return false;
85
+ }
86
+ var initialNode = view.state.doc.nodeAt(targetPosition);
87
+ if (!initialNode) {
88
+ return false;
89
+ }
90
+ var target = redirectParagraphToWrappedMedia(view, view.state.doc.resolve(targetPosition), targetPosition);
91
+ targetPosition = target.position;
92
+ var node = target.node;
93
+ if (!node || (controls === null || controls === void 0 || (_controls$activeNode = controls.activeNode) === null || _controls$activeNode === void 0 ? void 0 : _controls$activeNode.pos) === targetPosition) {
94
+ return false;
95
+ }
96
+ var $target = view.state.doc.resolve(targetPosition);
97
+ if ($target.depth > 0 && (node.type.name === 'paragraph' || node.type.name === 'heading') && node.content.size === 0) {
98
+ return false;
99
+ }
100
+ var parentNode = $target.parent;
101
+ var parentPosition = $target.depth > 0 ? $target.before($target.depth) : undefined;
102
+ var parentDOM = parentPosition === undefined ? undefined : view.nodeDOM(parentPosition);
103
+ if (isPanelNodeTypeName(parentNode.type.name) && !(parentDOM instanceof HTMLElement && parentDOM.classList.contains('ak-editor-panel__no-icon')) && $target.index() === 0) {
104
+ return false;
105
+ }
106
+ if (node.type.name === 'layoutColumn' && parentNode.type.name === 'layoutSection' && parentNode.childCount === 1 && expValEqualsNoExposure('advanced_layouts', 'isEnabled', true) && !expValEquals('platform_editor_layout_column_menu', 'isEnabled', true)) {
107
+ return false;
108
+ }
109
+ var anchors = controls === null || controls === void 0 ? void 0 : controls.surfaceAnchors;
110
+ var anchorName = (_anchors$get = anchors === null || anchors === void 0 ? void 0 : anchors.get(targetPosition)) !== null && _anchors$get !== void 0 ? _anchors$get : api.core.actions.getAnchorIdForNode(node, targetPosition);
111
+ var rootPos = $target.depth > 0 ? $target.before(1) : targetPosition;
112
+ var rootNode = view.state.doc.nodeAt(rootPos);
113
+ var rootAnchorName = (_anchors$get2 = anchors === null || anchors === void 0 ? void 0 : anchors.get(rootPos)) !== null && _anchors$get2 !== void 0 ? _anchors$get2 : rootNode ? api.core.actions.getAnchorIdForNode(rootNode, rootPos) : undefined;
114
+ if (!anchorName || !rootNode) {
115
+ return false;
116
+ }
117
+ api.core.actions.execute(api.blockControls.commands.showDragHandleAt(targetPosition, anchorName, getNodeTypeWithLevel(node), undefined, rootPos, rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : anchorName, getNodeTypeWithLevel(rootNode)));
118
+ return false;
119
+ };
@@ -7,7 +7,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import rafSchedule from 'raf-schd';
8
8
  import { getDocument } from '@atlaskit/browser-apis';
9
9
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
10
- import { BLOCK_CONTROLS_LEFT_SURFACE, BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
11
10
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
12
11
  import { getNodeIdProvider } from '@atlaskit/editor-common/node-anchor';
13
12
  import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
@@ -18,7 +17,6 @@ import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
18
17
  import { isEmptyDocument } from '@atlaskit/editor-common/utils';
19
18
  import { PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
20
19
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
21
- import { resolveSurface } from '@atlaskit/editor-ui-control-model/surface-renderer';
22
20
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
23
21
  import { fg } from '@atlaskit/platform-feature-flags/fg';
24
22
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
@@ -30,19 +28,20 @@ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equ
30
28
  import { BLOCK_CONTROLS_SURFACE_SELECTOR } from '../ui/consts';
31
29
  import { getAnchorAttrName } from '../ui/utils/dom-attr-name';
32
30
  import { findNodeDecs, nodeDecorations } from './decorations-anchor';
31
+ import { getNodeTypeWithLevel } from './decorations-common';
33
32
  import { createActiveDragHandleNodeDecoration, dragHandleDecoration, emptyParagraphNodeDecorations, findActiveDragHandleNodeDec, findHandleDec, TYPE_ACTIVE_HANDLE_DEC } from './decorations-drag-handle';
34
33
  import { dropTargetDecorations, findDropTargetDecs } from './decorations-drop-target';
35
34
  import { getActiveDropTargetDecorations } from './decorations-drop-target-active';
36
35
  import { createActiveQuickInsertNodeDecoration, findActiveQuickInsertNodeDec, findQuickInsertInsertButtonDecoration, quickInsertButtonDecoration, TYPE_ACTIVE_QUICK_INSERT_NODE } from './decorations-quick-insert-button';
37
36
  import { handleMouseDown } from './handle-mouse-down';
38
37
  import { handleMouseOver } from './handle-mouse-over';
38
+ import { handleSparseMouseOver } from './handle-sparse-mouse-over';
39
39
  import { boundKeydownHandler } from './keymap';
40
40
  import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
41
41
  import { getMultiSelectAnalyticsAttributes } from './utils/analytics';
42
42
  import { AnchorRectCache, isAnchorSupported } from './utils/anchor-utils';
43
43
  import { selectNode } from './utils/getSelection';
44
44
  import { getSelectedSlicePosition } from './utils/selection';
45
- import { getSurfaceNodePositions, updateSurfaceNodePositions } from './utils/surface-node-positions';
46
45
  import { getTrMetadata } from './utils/transactions';
47
46
  export var key = new PluginKey('blockControls');
48
47
  var EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
@@ -235,20 +234,18 @@ var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to
235
234
  return nodeDecAtActivePos;
236
235
  };
237
236
  var _apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
238
- var _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$isDragging3, _meta$toggleMenu, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
237
+ var _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$toggleMenu, _meta$isDragging3, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
239
238
  var rightSideControlsEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
240
239
  var quickInsertButtonEnabled = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : true;
241
240
  var anchorRectCache = arguments.length > 10 ? arguments[10] : undefined;
242
241
  var resizeObserverWidth = arguments.length > 11 ? arguments[11] : undefined;
243
242
  var pragmaticCleanup = arguments.length > 12 ? arguments[12] : undefined;
244
- var resolvedSurfaces = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : [];
245
- var limitedModeTeardown = arguments.length > 14 ? arguments[14] : undefined;
243
+ var limitedModeTeardown = arguments.length > 13 ? arguments[13] : undefined;
246
244
  var activeNode = currentState.activeNode,
247
245
  decorations = currentState.decorations,
248
246
  isResizerResizing = currentState.isResizerResizing,
249
- multiSelectDnD = currentState.multiSelectDnD,
250
- surfaceNodePositions = currentState.surfaceNodePositions;
251
- var previousActiveNode = activeNode;
247
+ multiSelectDnD = currentState.multiSelectDnD;
248
+ var surfaceNodePositions = currentState.surfaceNodePositions;
252
249
  var editorHeight = currentState.editorHeight,
253
250
  editorWidthLeft = currentState.editorWidthLeft,
254
251
  editorWidthRight = currentState.editorWidthRight,
@@ -393,13 +390,28 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
393
390
  if (activeNode.rootPos !== undefined) {
394
391
  mappedRootPos = tr.mapping.mapResult(activeNode.rootPos, -1);
395
392
  }
393
+ var mappedNodeType = activeNode.nodeType;
394
+ var mappedRootNodeType = activeNode.rootNodeType;
395
+ // Sparse mode does not redraw the old decorations. A block-type transaction may report
396
+ // a text range that excludes the active block position, so always refresh the already
397
+ // active node and root from the new document (for example, paragraph → heading-1).
398
+ if (isExperimentEnabled('platform_editor_block_control_migration')) {
399
+ var mappedNode = newState.doc.nodeAt(_mappedPos.pos);
400
+ if (mappedNode !== null && mappedNode !== void 0 && mappedNode.isBlock) {
401
+ mappedNodeType = getNodeTypeWithLevel(mappedNode);
402
+ }
403
+ var mappedRootNode = mappedRootPos ? mappedRootPos.pos === _mappedPos.pos && mappedNode ? mappedNode : newState.doc.nodeAt(mappedRootPos.pos) : undefined;
404
+ if (mappedRootNode !== null && mappedRootNode !== void 0 && mappedRootNode.isBlock) {
405
+ mappedRootNodeType = getNodeTypeWithLevel(mappedRootNode);
406
+ }
407
+ }
396
408
  activeNode = {
397
409
  pos: _mappedPos.pos,
398
410
  anchorName: activeNode.anchorName,
399
- nodeType: activeNode.nodeType,
411
+ nodeType: mappedNodeType,
400
412
  rootPos: (_mappedRootPos$pos = (_mappedRootPos = mappedRootPos) === null || _mappedRootPos === void 0 ? void 0 : _mappedRootPos.pos) !== null && _mappedRootPos$pos !== void 0 ? _mappedRootPos$pos : activeNode.rootPos,
401
413
  rootAnchorName: activeNode.rootAnchorName,
402
- rootNodeType: activeNode.rootNodeType
414
+ rootNodeType: mappedRootNodeType
403
415
  };
404
416
  }
405
417
  }
@@ -435,7 +447,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
435
447
  var isNodeDecsMissing = isDecSetEmpty || maybeNodeCountChanged || editorExperiment('platform_editor_breakout_resizing', true) && hasJustFinishedResizing;
436
448
  var shouldRedrawNodeDecs = !isResizerResizing && (isNodeDecsMissing || (meta === null || meta === void 0 ? void 0 : meta.isDragging)) &&
437
449
  // Skip expensive anchor node decoration recalculations when native anchor support is enabled
438
- !expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
450
+ !(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration'));
439
451
  var isActiveNodeModified = false;
440
452
  if (api && shouldRedrawNodeDecs) {
441
453
  var oldNodeDecs = findNodeDecs(newState, decorations, from, to);
@@ -511,14 +523,14 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
511
523
  // In view mode with right-side controls, remove any lingering drag handle decorations
512
524
  // (they may carry over from edit mode). Only remove drag handles specifically, not
513
525
  // the remix button decorations (those are managed separately via showInViewMode).
514
- if (flags.legacyDragHandleEnabled && isViewMode && rightSideControlsEnabled) {
526
+ if (!isExperimentEnabled('platform_editor_block_control_migration') && isViewMode && rightSideControlsEnabled) {
515
527
  var allHandleDecs = findHandleDec(decorations, 0, newState.doc.content.size);
516
528
  if (allHandleDecs.length > 0) {
517
529
  decorations = decorations.remove(allHandleDecs);
518
530
  }
519
531
  }
520
532
  if (shouldRemoveHandle) {
521
- if (flags.legacyDragHandleEnabled) {
533
+ if (!isExperimentEnabled('platform_editor_block_control_migration')) {
522
534
  var _activeNode5, _activeNode6;
523
535
  var oldHandle = findHandleDec(decorations, (_activeNode5 = activeNode) === null || _activeNode5 === void 0 ? void 0 : _activeNode5.pos, (_activeNode6 = activeNode) === null || _activeNode6 === void 0 ? void 0 : _activeNode6.pos);
524
536
  decorations = decorations.remove(oldHandle);
@@ -530,7 +542,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
530
542
  // after a doc change (e.g. pressing Enter splits a node), DecorationSet.map() can shift the
531
543
  // decoration to a different position, so a point-range search would miss it and leave a stale
532
544
  // attribute on the wrong DOM node.
533
- if ((flags.legacyDragHandleEnabled || nodeDecorationRegistry.length > 0) && expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true)) {
545
+ if ((!isExperimentEnabled('platform_editor_block_control_migration') || nodeDecorationRegistry.length > 0) && expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true)) {
534
546
  var oldActiveNodeDec = findActiveDragHandleNodeDec(decorations, 0, newState.doc.content.size);
535
547
  decorations = decorations.remove(oldActiveNodeDec);
536
548
  var oldActiveQuickInsertDec = findActiveQuickInsertNodeDec(decorations, 0, newState.doc.content.size);
@@ -592,7 +604,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
592
604
  } else if (api) {
593
605
  var _latestActiveNode5, _latestActiveNode10;
594
606
  // The registry surface replaces the legacy drag-handle decorations during migration.
595
- if (flags.legacyDragHandleEnabled && shouldRecreateHandle && (!rightSideControlsEnabled || !isViewMode)) {
607
+ if (!isExperimentEnabled('platform_editor_block_control_migration') && shouldRecreateHandle && (!rightSideControlsEnabled || !isViewMode)) {
596
608
  var _activeNode11, _activeNode12, _latestActiveNode, _latestActiveNode2, _latestActiveNode3, _latestActiveNode4;
597
609
  var _oldHandle = findHandleDec(decorations, (_activeNode11 = activeNode) === null || _activeNode11 === void 0 ? void 0 : _activeNode11.pos, (_activeNode12 = activeNode) === null || _activeNode12 === void 0 ? void 0 : _activeNode12.pos);
598
610
  decorations = decorations.remove(_oldHandle);
@@ -609,7 +621,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
609
621
  });
610
622
  decorations = decorations.add(newState.doc, [handleDec]);
611
623
  }
612
- if ((flags.legacyDragHandleEnabled ||
624
+ if ((!isExperimentEnabled('platform_editor_block_control_migration') ||
613
625
  // nodeDecorationRegistry consumers (e.g. the legacy Remix button) rely
614
626
  // on that same anchor-name for their own CSS anchor() positioning, so this must still run
615
627
  // when such a consumer exists even if the legacy drag handle itself is disabled.
@@ -881,7 +893,10 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
881
893
  }
882
894
  }
883
895
  var isEmptyDoc = isEmptyDocument(newState.doc);
884
- if (isEmptyDoc && !expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
896
+ if (isExperimentEnabled('platform_editor_block_control_migration') && (meta === null || meta === void 0 ? void 0 : meta.isDragging) === false) {
897
+ decorations = decorations.remove(findNodeDecs(newState, decorations));
898
+ }
899
+ if (isEmptyDoc && !(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration'))) {
885
900
  var hasNodeDecoration = !!findNodeDecs(newState, decorations).length;
886
901
  if (!hasNodeDecoration) {
887
902
  decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
@@ -894,27 +909,30 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
894
909
  // remove isEmptyDoc check and let decorations render and determine their own visibility
895
910
  // In view mode with right-side controls we render node decorations (right-edge button), not the
896
911
  // handle - so findHandleDec is always empty. Don't clear activeNode in that case.
897
- var hasHandleOrViewModeControls = !flags.legacyDragHandleEnabled || isViewMode && rightSideControlsEnabled || findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0;
912
+ var hasHandleOrViewModeControls = isExperimentEnabled('platform_editor_block_control_migration') || isViewMode && rightSideControlsEnabled || findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0;
898
913
  // Keep the registry surface mounted while its Block Menu owns focus.
899
- var keepActiveNodeForOpenBlockMenu = !flags.legacyDragHandleEnabled && isMenuOpen;
914
+ var keepActiveNodeForOpenBlockMenu = isExperimentEnabled('platform_editor_block_control_migration') && isMenuOpen;
900
915
  newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
901
916
  } else {
902
917
  var _latestActiveNode13, _latestActiveNode14;
903
- newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && flags.legacyDragHandleEnabled && findHandleDec(decorations, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos, (_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.pos).length === 0 ? null : latestActiveNode;
904
- }
905
- if (flags.surfaceNodePositionsEnabled && resolvedSurfaces.length > 0) {
906
- surfaceNodePositions = updateSurfaceNodePositions({
907
- activeNode: newActiveNode,
908
- currentPositions: surfaceNodePositions,
909
- from: from,
910
- newState: newState,
911
- previousActiveNode: previousActiveNode,
912
- resolvedSurfaces: resolvedSurfaces,
913
- to: to,
914
- tr: tr
915
- });
918
+ newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && !isExperimentEnabled('platform_editor_block_control_migration') && findHandleDec(decorations, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos, (_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.pos).length === 0 ? null : latestActiveNode;
916
919
  }
917
920
  var isMenuOpenNew = isMenuOpen;
921
+ var nextMenuTriggerByNode = (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.triggerByNode) || menuTriggerByNode;
922
+ if (isExperimentEnabled('platform_editor_block_control_migration') && tr.docChanged && menuTriggerByNode && !(meta !== null && meta !== void 0 && meta.toggleMenu)) {
923
+ var _menuTriggerByNode$ro, _newState$doc$nodeAt4;
924
+ var mapped = tr.mapping.mapResult(menuTriggerByNode.pos, 1);
925
+ var mappedRoot = tr.mapping.mapResult((_menuTriggerByNode$ro = menuTriggerByNode.rootPos) !== null && _menuTriggerByNode$ro !== void 0 ? _menuTriggerByNode$ro : menuTriggerByNode.pos, 1);
926
+ if (mapped.deleted || mappedRoot.deleted || !((_newState$doc$nodeAt4 = newState.doc.nodeAt(mapped.pos)) !== null && _newState$doc$nodeAt4 !== void 0 && _newState$doc$nodeAt4.isBlock)) {
927
+ nextMenuTriggerByNode = undefined;
928
+ isMenuOpenNew = false;
929
+ } else {
930
+ nextMenuTriggerByNode = _objectSpread(_objectSpread({}, menuTriggerByNode), {}, {
931
+ pos: mapped.pos,
932
+ rootPos: mappedRoot.pos
933
+ });
934
+ }
935
+ }
918
936
  if (meta !== null && meta !== void 0 && meta.closeMenu) {
919
937
  isMenuOpenNew = false;
920
938
  } else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
@@ -934,8 +952,8 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
934
952
  activeDropTargetNode: currentActiveDropTargetNode,
935
953
  isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
936
954
  isMenuOpen: isMenuOpenNew,
937
- menuTriggerBy: (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy,
938
- menuTriggerByNode: (meta === null || meta === void 0 || (_meta$toggleMenu2 = meta.toggleMenu) === null || _meta$toggleMenu2 === void 0 ? void 0 : _meta$toggleMenu2.triggerByNode) || menuTriggerByNode,
955
+ menuTriggerBy: (meta === null || meta === void 0 || (_meta$toggleMenu2 = meta.toggleMenu) === null || _meta$toggleMenu2 === void 0 ? void 0 : _meta$toggleMenu2.anchorName) || menuTriggerBy,
956
+ menuTriggerByNode: nextMenuTriggerByNode,
939
957
  blockMenuOptions: {
940
958
  canMoveUp: (meta === null || meta === void 0 || (_meta$toggleMenu3 = meta.toggleMenu) === null || _meta$toggleMenu3 === void 0 ? void 0 : _meta$toggleMenu3.moveUp) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu4 = meta.toggleMenu) === null || _meta$toggleMenu4 === void 0 ? void 0 : _meta$toggleMenu4.moveUp : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveUp,
941
959
  canMoveDown: (meta === null || meta === void 0 || (_meta$toggleMenu5 = meta.toggleMenu) === null || _meta$toggleMenu5 === void 0 ? void 0 : _meta$toggleMenu5.moveDown) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu6 = meta.toggleMenu) === null || _meta$toggleMenu6 === void 0 ? void 0 : _meta$toggleMenu6.moveDown : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveDown,
@@ -955,25 +973,17 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
955
973
  };
956
974
  export { _apply as apply };
957
975
  export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
958
- var _api$uiControlRegistr, _api$uiControlRegistr2, _api$uiControlRegistr3, _api$uiControlRegistr4;
959
976
  var rightSideControlsEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
960
977
  var quickInsertButtonEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
961
- var legacyDragHandleEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
962
978
  var _getIntl = getIntl(),
963
979
  formatMessage = _getIntl.formatMessage;
964
980
  var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
965
981
  exposure: true
966
982
  });
967
983
  var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
968
- // Mirrors `registryBlockControlsEnabled` in blockControlsPlugin.tsx: `legacyDragHandleEnabled` is
969
- // only false once that gate is on.
970
- var surfaceNodePositionsEnabled = !legacyDragHandleEnabled;
971
984
  var flags = {
972
- legacyDragHandleEnabled: legacyDragHandleEnabled,
973
- surfaceNodePositionsEnabled: surfaceNodePositionsEnabled,
974
985
  toolbarFlagsEnabled: toolbarFlagsEnabled
975
986
  };
976
- var resolvedSurfaces = surfaceNodePositionsEnabled ? [resolveSurface((_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(BLOCK_CONTROLS_LEFT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [], BLOCK_CONTROLS_LEFT_SURFACE), resolveSurface((_api$uiControlRegistr3 = api === null || api === void 0 || (_api$uiControlRegistr4 = api.uiControlRegistry) === null || _api$uiControlRegistr4 === void 0 ? void 0 : _api$uiControlRegistr4.actions.getComponents(BLOCK_CONTROLS_RIGHT_SURFACE)) !== null && _api$uiControlRegistr3 !== void 0 ? _api$uiControlRegistr3 : [], BLOCK_CONTROLS_RIGHT_SURFACE)] : [];
977
987
  var anchorRectCache;
978
988
  if (!isAnchorSupported()) {
979
989
  anchorRectCache = new AnchorRectCache();
@@ -987,13 +997,11 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
987
997
  return new SafePlugin({
988
998
  key: key,
989
999
  state: {
990
- init: function init(_config, editorState) {
991
- return _objectSpread(_objectSpread({}, initialState), {}, {
992
- surfaceNodePositions: resolvedSurfaces.length > 0 ? getSurfaceNodePositions(editorState, resolvedSurfaces) : []
993
- });
1000
+ init: function init() {
1001
+ return _objectSpread({}, initialState);
994
1002
  },
995
1003
  apply: function apply(tr, currentState, _, newState) {
996
- return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces, limitedModeTeardown);
1004
+ return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, limitedModeTeardown);
997
1005
  }
998
1006
  },
999
1007
  props: {
@@ -1014,7 +1022,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1014
1022
  var decorationSet = (_key$getState2 = key.getState(state)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.decorations;
1015
1023
  // In view mode with right-side controls, remove any lingering drag-handle decorations
1016
1024
  // (created in edit mode) that may not have been cleaned up on mode switch.
1017
- if (decorationSet && legacyDragHandleEnabled && rightSideControlsEnabled && (api === null || api === void 0 || (_api$editorViewMode3 = api.editorViewMode) === null || _api$editorViewMode3 === void 0 || (_api$editorViewMode3 = _api$editorViewMode3.sharedState.currentState()) === null || _api$editorViewMode3 === void 0 ? void 0 : _api$editorViewMode3.mode) === 'view') {
1025
+ if (decorationSet && !isExperimentEnabled('platform_editor_block_control_migration') && rightSideControlsEnabled && (api === null || api === void 0 || (_api$editorViewMode3 = api.editorViewMode) === null || _api$editorViewMode3 === void 0 || (_api$editorViewMode3 = _api$editorViewMode3.sharedState.currentState()) === null || _api$editorViewMode3 === void 0 ? void 0 : _api$editorViewMode3.mode) === 'view') {
1018
1026
  var handleDecs = findHandleDec(decorationSet, 0, state.doc.content.size);
1019
1027
  if (handleDecs.length > 0) {
1020
1028
  decorationSet = decorationSet.remove(handleDecs);
@@ -1160,10 +1168,14 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1160
1168
  // another layer of protection to prevent handling mouseover
1161
1169
  // when native anchor with dnd is enabled in limited mode
1162
1170
  // in case there are descripancies between getNodeIdProvider limited mode state
1163
- if ((_getNodeIdProvider = getNodeIdProvider(view)) !== null && _getNodeIdProvider !== void 0 && _getNodeIdProvider.isLimitedMode() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
1171
+ if ((_getNodeIdProvider = getNodeIdProvider(view)) !== null && _getNodeIdProvider !== void 0 && _getNodeIdProvider.isLimitedMode() && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration'))) {
1164
1172
  return;
1165
1173
  }
1166
- handleMouseOver(view, event, api);
1174
+ if (isExperimentEnabled('platform_editor_block_control_migration')) {
1175
+ handleSparseMouseOver(view, event, api);
1176
+ } else {
1177
+ handleMouseOver(view, event, api);
1178
+ }
1167
1179
  return false;
1168
1180
  },
1169
1181
  mousedown: function mousedown(view, event) {
@@ -1224,7 +1236,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1224
1236
  if (editorExperiment('platform_editor_controls', 'variant1')) {
1225
1237
  var _api$core2;
1226
1238
  // Focus moving into the registry surface remains inside the editor experience.
1227
- var isChildOfSurface = !flags.legacyDragHandleEnabled && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest(BLOCK_CONTROLS_SURFACE_SELECTOR) !== null;
1239
+ var isChildOfSurface = isExperimentEnabled('platform_editor_block_control_migration') && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest(BLOCK_CONTROLS_SURFACE_SELECTOR) !== null;
1228
1240
  var shouldPreserveRemixInlineDropdownFocus = event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[data-editor-remix-inline-dropdown-preserve-focus]') !== null;
1229
1241
  var isChildOfEditor = event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest("#".concat(EDIT_AREA_ID)) !== null;
1230
1242
 
@@ -1264,7 +1276,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1264
1276
 
1265
1277
  // Registry surfaces have their own ResizeObservers and absolute placement.
1266
1278
  // Width metadata only drives legacy widget recreation.
1267
- if (legacyDragHandleEnabled && !isResizerResizing) {
1279
+ if (!isExperimentEnabled('platform_editor_block_control_migration') && !isResizerResizing) {
1268
1280
  var _editorContentArea2 = entries[0].target;
1269
1281
  // Ignored via go/ees005
1270
1282
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -1283,7 +1295,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1283
1295
  }
1284
1296
  }
1285
1297
  }));
1286
- var shouldObserve = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? !isAnchorSupported() : true;
1298
+ var shouldObserve = !(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration')) || !isAnchorSupported();
1287
1299
  if (editorContentArea && shouldObserve) {
1288
1300
  resizeObserverWidth.observe(editorContentArea);
1289
1301
  }
@@ -0,0 +1,43 @@
1
+ import { BLOCK_CONTROLS_SURFACE_INVALIDATION } from '@atlaskit/editor-common/block-controls/surface-candidate-invalidation';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
+ import { key as blockControlsKey } from './main';
6
+ import { emptySparseSurfaceCandidateState } from './utils/sparse-surface-candidates';
7
+ import { applySparseSurfacesTransaction, createInitialSparseSurfacesState } from './utils/sparse-surfaces-state';
8
+ import { createSparseSurfacesView } from './utils/sparse-surfaces-view';
9
+ export var sparseSurfacesKey = new PluginKey('blockControlsSparseSurfaces');
10
+
11
+ /** Owns sparse anchors independently of drag/drop decorations and their lifecycle. */
12
+ export var createSparseSurfacesPlugin = function createSparseSurfacesPlugin(api) {
13
+ return new SafePlugin({
14
+ key: sparseSurfacesKey,
15
+ state: {
16
+ init: function init() {
17
+ return createInitialSparseSurfacesState(emptySparseSurfaceCandidateState);
18
+ },
19
+ apply: function apply(tr, previous, _oldState, newState) {
20
+ return applySparseSurfacesTransaction({
21
+ invalidation: tr.getMeta(BLOCK_CONTROLS_SURFACE_INVALIDATION),
22
+ meta: tr.getMeta(sparseSurfacesKey),
23
+ newState: newState,
24
+ previous: previous,
25
+ tr: tr
26
+ });
27
+ }
28
+ },
29
+ props: {
30
+ decorations: function decorations(state) {
31
+ var _api$limitedMode, _blockControlsKey$get, _sparseSurfacesKey$ge;
32
+ return api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode !== void 0 && _api$limitedMode.enabled || (_blockControlsKey$get = blockControlsKey.getState(state)) !== null && _blockControlsKey$get !== void 0 && _blockControlsKey$get.isDragging ? DecorationSet.empty : (_sparseSurfacesKey$ge = sparseSurfacesKey.getState(state)) === null || _sparseSurfacesKey$ge === void 0 ? void 0 : _sparseSurfacesKey$ge.decorations;
33
+ }
34
+ },
35
+ view: function view(_view) {
36
+ return createSparseSurfacesView({
37
+ api: api,
38
+ pluginKey: sparseSurfacesKey,
39
+ view: _view
40
+ });
41
+ }
42
+ });
43
+ };