@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 20.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`fc26bfc51dd5c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fc26bfc51dd5c) -
8
+ Add sparse block-control surface anchors, intersection-driven candidates, and explicit visibility
9
+ invalidation for registry-backed block controls. Expose registration change subscriptions from the
10
+ UI control registry model, and refresh cached visibility from suggestion and collapse transaction
11
+ metadata. Under `platform_editor_block_control_migration`, use native node-anchor identity across
12
+ Editor and Block Controls, and route expand keyboard focus through the shared Block Controls
13
+ command. Preserve Show Diff visibility checks in both migration cohorts so block controls stay
14
+ hidden while a diff is displayed. Keep the block menu closed when a migrated layout-column handle
15
+ opens the layout menu, and close the layout menu when the selection moves away from its selected
16
+ columns.
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 20.0.3
4
23
 
5
24
  ### Patch Changes
@@ -23,12 +23,14 @@ var _moveNode = require("./editor-commands/move-node");
23
23
  var _moveNodeWithBlockMenu2 = require("./editor-commands/move-node-with-block-menu");
24
24
  var _moveToLayout = require("./editor-commands/move-to-layout");
25
25
  var _moveNodeUtils = require("./editor-commands/utils/move-node-utils");
26
+ var _decorationsCommon = require("./pm-plugins/decorations-common");
26
27
  var _firstNodeDecPlugin = require("./pm-plugins/first-node-dec-plugin");
27
28
  var _pmPlugin = require("./pm-plugins/interaction-tracking/pm-plugin");
28
29
  var _main = require("./pm-plugins/main");
29
30
  var _editorCommands = require("./pm-plugins/selection-preservation/editor-commands");
30
31
  var _pluginKey = require("./pm-plugins/selection-preservation/plugin-key");
31
32
  var _pmPlugin2 = require("./pm-plugins/selection-preservation/pm-plugin");
33
+ var _sparseSurfaces = require("./pm-plugins/sparse-surfaces");
32
34
  var _expandAndUpdateSelection2 = require("./pm-plugins/utils/expand-and-update-selection");
33
35
  var _getSelection = require("./pm-plugins/utils/getSelection");
34
36
  var _blockControlsLeftSurfaces = require("./ui/block-controls-left-surfaces");
@@ -46,7 +48,6 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
46
48
  var rightSideControlsEnabled = (_config$rightSideCont = config === null || config === void 0 ? void 0 : config.rightSideControlsEnabled) !== null && _config$rightSideCont !== void 0 ? _config$rightSideCont : false;
47
49
  var quickInsertButtonEnabled = (_config$quickInsertBu = config === null || config === void 0 ? void 0 : config.quickInsertButtonEnabled) !== null && _config$quickInsertBu !== void 0 ? _config$quickInsertBu : true;
48
50
  var registryBlockControlsEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration');
49
- var legacyBlockControlsEnabled = !registryBlockControlsEnabled;
50
51
  if (registryBlockControlsEnabled) {
51
52
  var _api$uiControlRegistr, _api$uiControlRegistr2;
52
53
  api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register([_surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE, _objectSpread(_objectSpread({}, _surfaceKeys.BLOCK_CONTROLS_LEFT_SECTION), {}, {
@@ -142,9 +143,17 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
142
143
  plugin: function plugin(_ref2) {
143
144
  var getIntl = _ref2.getIntl,
144
145
  nodeViewPortalProviderAPI = _ref2.nodeViewPortalProviderAPI;
145
- return (0, _main.createPlugin)(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled);
146
+ return (0, _main.createPlugin)(api, getIntl, nodeViewPortalProviderAPI, registryBlockControlsEnabled ? [] : nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && !registryBlockControlsEnabled);
146
147
  }
147
148
  }];
149
+ if (registryBlockControlsEnabled) {
150
+ pmPlugins.push({
151
+ name: 'blockControlsSparseSurfaces',
152
+ plugin: function plugin() {
153
+ return (0, _sparseSurfaces.createSparseSurfacesPlugin)(api);
154
+ }
155
+ });
156
+ }
148
157
  if ((0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')) {
149
158
  pmPlugins.push({
150
159
  name: 'blockControlsInteractionTrackingPlugin',
@@ -163,7 +172,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
163
172
  // Not registered under the registry migration: the decoration puts an inline
164
173
  // `margin-top: 0` on the first document node, which fights features that render their own
165
174
  // content above it — a leading show-diff widget is left flush against the node below.
166
- if ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) && legacyBlockControlsEnabled) {
175
+ if ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) && !registryBlockControlsEnabled) {
167
176
  pmPlugins.push({
168
177
  name: 'firstNodeDec',
169
178
  plugin: _firstNodeDecPlugin.firstNodeDecPlugin
@@ -210,10 +219,34 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
210
219
  return tr;
211
220
  };
212
221
  },
213
- toggleBlockMenu: function toggleBlockMenu(options) {
222
+ showControlAtPosition: function showControlAtPosition(pos, control, options) {
214
223
  return function (_ref6) {
215
- var _api$userIntent, _api$blockControls2, _options$anchorName, _api$blockControls3;
216
224
  var tr = _ref6.tr;
225
+ var node = tr.doc.nodeAt(pos);
226
+ if (!node) {
227
+ return tr;
228
+ }
229
+ var anchorName = api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos);
230
+ if (!anchorName) {
231
+ return tr;
232
+ }
233
+ var currMeta = tr.getMeta(_main.key);
234
+ tr.setMeta(_main.key, _objectSpread(_objectSpread({}, currMeta), {}, {
235
+ activeNode: {
236
+ pos: pos,
237
+ anchorName: anchorName,
238
+ controlKey: control.key,
239
+ nodeType: (0, _decorationsCommon.getNodeTypeWithLevel)(node),
240
+ handleOptions: options
241
+ }
242
+ }));
243
+ return tr;
244
+ };
245
+ },
246
+ toggleBlockMenu: function toggleBlockMenu(options) {
247
+ return function (_ref7) {
248
+ var _api$userIntent, _api$blockControls2, _options$triggerByNod, _options$anchorName, _api$blockControls3;
249
+ var tr = _ref7.tr;
217
250
  var currMeta = tr.getMeta(_main.key);
218
251
  var currentUserIntent = api === null || api === void 0 || (_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;
219
252
  var isMenuCurrentlyOpen = api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.isMenuOpen;
@@ -238,8 +271,9 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
238
271
  return tr;
239
272
  }
240
273
 
241
- // Do not open menu on layoutColumn and close opened menu when layoutColumn drag handle is clicked
242
- if (options !== null && options !== void 0 && (_options$anchorName = options.anchorName) !== null && _options$anchorName !== void 0 && _options$anchorName.includes('layoutColumn')) {
274
+ // Do not open the block menu for layout columns. Anchor resolution can lag behind
275
+ // a migrated surface click, so prefer the explicit node metadata when available.
276
+ if ((options === null || options === void 0 || (_options$triggerByNod = options.triggerByNode) === null || _options$triggerByNod === void 0 ? void 0 : _options$triggerByNod.nodeType) === 'layoutColumn' || options !== null && options !== void 0 && (_options$anchorName = options.anchorName) !== null && _options$anchorName !== void 0 && _options$anchorName.includes('layoutColumn')) {
243
277
  if (currentUserIntent === 'blockMenuOpen') {
244
278
  var _api$userIntent3;
245
279
  api === null || api === void 0 || (_api$userIntent3 = api.userIntent) === null || _api$userIntent3 === void 0 || _api$userIntent3.commands.setCurrentUserIntent('default')({
@@ -315,9 +349,9 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
315
349
  };
316
350
  },
317
351
  setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
318
- return function (_ref7) {
352
+ return function (_ref8) {
319
353
  var _api$userIntent6;
320
- var tr = _ref7.tr;
354
+ var tr = _ref8.tr;
321
355
  var pos = getPos();
322
356
  if (pos === undefined) {
323
357
  return tr;
@@ -347,9 +381,9 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
347
381
  };
348
382
  },
349
383
  setMultiSelectPositions: function setMultiSelectPositions(anchor, head) {
350
- return function (_ref8) {
384
+ return function (_ref9) {
351
385
  var _api$selection, _$to$nodeBefore, _$from$nodeAfter;
352
- var tr = _ref8.tr;
386
+ var tr = _ref9.tr;
353
387
  var _tr$selection = tr.selection,
354
388
  userAnchor = _tr$selection.anchor,
355
389
  userHead = _tr$selection.head;
@@ -401,8 +435,8 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
401
435
  };
402
436
  },
403
437
  setSelectedViaDragHandle: function setSelectedViaDragHandle(isSelectedViaDragHandle) {
404
- return function (_ref9) {
405
- var tr = _ref9.tr;
438
+ return function (_ref0) {
439
+ var tr = _ref0.tr;
406
440
  var currMeta = tr.getMeta(_main.key);
407
441
  return tr.setMeta(_main.key, _objectSpread(_objectSpread({}, currMeta), {}, {
408
442
  isSelectedViaDragHandle: isSelectedViaDragHandle
@@ -444,8 +478,10 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
444
478
  isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState10 = _main.key.getState(editorState)) === null || _key$getState10 === void 0 ? void 0 : _key$getState10.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
445
479
  };
446
480
  if (registryBlockControlsEnabled) {
447
- var _key$getState$surface, _key$getState11;
448
- sharedState.surfaceNodePositions = (_key$getState$surface = (_key$getState11 = _main.key.getState(editorState)) === null || _key$getState11 === void 0 ? void 0 : _key$getState11.surfaceNodePositions) !== null && _key$getState$surface !== void 0 ? _key$getState$surface : [];
481
+ var surfaces = _sparseSurfaces.sparseSurfacesKey.getState(editorState);
482
+ sharedState.surfaceNodePositions = surfaces === null || surfaces === void 0 ? void 0 : surfaces.candidates.positions;
483
+ sharedState.surfaceAnchors = surfaces === null || surfaces === void 0 ? void 0 : surfaces.anchors;
484
+ sharedState.surfaceActiveNodes = surfaces === null || surfaces === void 0 ? void 0 : surfaces.activeNodesByPosition;
449
485
  }
450
486
  if ((0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')) {
451
487
  var _interactionTrackingP2, _interactionTrackingP3, _interactionTrackingP4;
@@ -457,8 +493,8 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
457
493
  sharedState.preservedSelection = (_selectionPreservatio = _pluginKey.selectionPreservationPluginKey.getState(editorState)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
458
494
  return sharedState;
459
495
  },
460
- contentComponent: function contentComponent(_ref0) {
461
- var editorView = _ref0.editorView;
496
+ contentComponent: function contentComponent(_ref1) {
497
+ var editorView = _ref1.editorView;
462
498
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, {
463
499
  api: api
464
500
  }), registryBlockControlsEnabled && editorView && api ? /*#__PURE__*/_react.default.createElement(_surfaceEditorViewContext.SurfaceEditorViewContext.Provider, {
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.showDragHandleAtSelection = void 0;
7
7
  var _utils = require("@atlaskit/editor-prosemirror/utils");
8
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
8
9
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
10
  var _decorationsAnchor = require("../pm-plugins/decorations-anchor");
11
+ var _decorationsCommon = require("../pm-plugins/decorations-common");
10
12
  var _main = require("../pm-plugins/main");
11
13
  var _getNestedNodePosition = require("../pm-plugins/utils/getNestedNodePosition");
12
14
  var _domAttrName = require("../ui/utils/dom-attr-name");
@@ -15,7 +17,6 @@ var findParentPosForHandle = function findParentPosForHandle(state) {
15
17
  var $from = state.selection.$from;
16
18
  var _ref = _main.key.getState(state) || {},
17
19
  activeNode = _ref.activeNode;
18
-
19
20
  // if a node handle is already focused, return the parent pos of that node (with focused handle)
20
21
  if (activeNode && (_activeNode$handleOpt = activeNode.handleOptions) !== null && _activeNode$handleOpt !== void 0 && _activeNode$handleOpt.isFocused) {
21
22
  var $activeNodePos = state.doc.resolve(activeNode.pos);
@@ -39,7 +40,7 @@ var findParentPosForHandle = function findParentPosForHandle(state) {
39
40
  }
40
41
 
41
42
  // else find closest parent node
42
- return (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ?
43
+ return (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ?
43
44
  // With native anchor enabled, all nodes have anchor name attribute despite no drag handle support, e.g. listItem, caption,
44
45
  // as opposed to old approach, node decoration is only added to the node that have drag handle,
45
46
  // hence, we need to return the exact position of the node that can have drag handle
@@ -113,13 +114,24 @@ var findNextAnchorNode = function findNextAnchorNode(view) {
113
114
  };
114
115
  var showDragHandleAtSelection = exports.showDragHandleAtSelection = function showDragHandleAtSelection(api) {
115
116
  return function (state, _, view) {
117
+ if (api && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
118
+ var pos = findParentPosForHandle(state);
119
+ var node = pos === undefined ? undefined : state.doc.nodeAt(pos);
120
+ var anchorName = node && pos !== undefined ? api.core.actions.getAnchorIdForNode(node, pos) : undefined;
121
+ if (!node || pos === undefined || !anchorName) {
122
+ return false;
123
+ }
124
+ return api.core.actions.execute(api.blockControls.commands.showDragHandleAt(pos, anchorName, (0, _decorationsCommon.getNodeTypeWithLevel)(node), {
125
+ isFocused: true
126
+ }));
127
+ }
116
128
  if (view && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
117
129
  var anchorNode = findNextAnchorNode(view);
118
130
  if (api && anchorNode) {
119
- var pos = anchorNode.pos,
120
- anchorName = anchorNode.anchorName,
131
+ var _pos = anchorNode.pos,
132
+ _anchorName = anchorNode.anchorName,
121
133
  nodeType = anchorNode.nodeType;
122
- api.core.actions.execute(api.blockControls.commands.showDragHandleAt(pos, anchorName, nodeType, {
134
+ api.core.actions.execute(api.blockControls.commands.showDragHandleAt(_pos, _anchorName, nodeType, {
123
135
  isFocused: true
124
136
  }));
125
137
  return true;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.shouldDescendIntoNode = exports.nodeDecorations = exports.findNodeDecs = exports.IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT = exports.IGNORE_NODES_NEXT = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _view = require("@atlaskit/editor-prosemirror/view");
10
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
10
11
  var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
11
12
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
12
13
  var _decorationsCommon = require("./decorations-common");
@@ -77,7 +78,7 @@ var findNodeDecs = exports.findNodeDecs = function findNodeDecs(state, decoratio
77
78
  };
78
79
  var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newState, from, to) {
79
80
  var decs = [];
80
- if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
81
+ if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
81
82
  return [];
82
83
  }
83
84
  var docFrom = from === undefined || from < 0 ? 0 : from;
@@ -11,6 +11,7 @@ var _selection = require("@atlaskit/editor-common/selection");
11
11
  var _utils = require("@atlaskit/editor-common/utils");
12
12
  var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
13
13
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
14
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
14
15
  var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
15
16
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
16
17
  var _decorationsCommon = require("./decorations-common");
@@ -257,7 +258,7 @@ var getActiveDropTargetDecorations = exports.getActiveDropTargetDecorations = fu
257
258
  }
258
259
  }
259
260
  }
260
- _activeAnchorTracker.defaultActiveAnchorTracker.emit((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(anchorEmitNodeWithPos.node, anchorEmitNodeWithPos.pos) || '' : (0, _decorationsCommon.getNodeAnchor)(anchorEmitNodeWithPos.node));
261
+ _activeAnchorTracker.defaultActiveAnchorTracker.emit((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? api.core.actions.getAnchorIdForNode(anchorEmitNodeWithPos.node, anchorEmitNodeWithPos.pos) || '' : (0, _decorationsCommon.getNodeAnchor)(anchorEmitNodeWithPos.node));
261
262
  return {
262
263
  decsToAdd: decsToAdd,
263
264
  decsToRemove: decsToRemove
@@ -14,6 +14,7 @@ var _selection = require("@atlaskit/editor-common/selection");
14
14
  var _utils = require("@atlaskit/editor-common/utils");
15
15
  var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
16
16
  var _view = require("@atlaskit/editor-prosemirror/view");
17
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
17
18
  var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
18
19
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
19
20
  var _consts = require("../ui/consts");
@@ -152,7 +153,7 @@ var createLayoutDropTargetDecoration = exports.createLayoutDropTargetDecoration
152
153
  element.setAttribute('data-blocks-drop-target-container', 'true');
153
154
  element.setAttribute('data-blocks-drop-target-key', key);
154
155
  element.style.clear = 'unset';
155
- var DropTargetLayoutComponent = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? _dropTargetLayout.DropTargetLayoutNativeAnchorSupport : _dropTargetLayout.DropTargetLayout;
156
+ var DropTargetLayoutComponent = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? _dropTargetLayout.DropTargetLayoutNativeAnchorSupport : _dropTargetLayout.DropTargetLayout;
156
157
  nodeViewPortalProviderAPI.render(function () {
157
158
  return /*#__PURE__*/(0, _react.createElement)(DropTargetLayoutComponent, _objectSpread(_objectSpread({}, props), {}, {
158
159
  getPos: getPos,
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createSurfaceAnchorDecorations = exports.TYPE_SURFACE_ANCHOR_DEC = exports.SURFACE_NODE_TYPE_ATTR = exports.SURFACE_ANCHOR_VARIABLE = exports.SURFACE_ANCHOR_ATTR = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _view = require("@atlaskit/editor-prosemirror/view");
10
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
11
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
13
+ var TYPE_SURFACE_ANCHOR_DEC = exports.TYPE_SURFACE_ANCHOR_DEC = 'block-controls-surface-anchor';
14
+ var SURFACE_ANCHOR_ATTR = exports.SURFACE_ANCHOR_ATTR = 'data-block-controls-surface-anchor';
15
+ var SURFACE_NODE_TYPE_ATTR = exports.SURFACE_NODE_TYPE_ATTR = 'data-block-controls-surface-node-type';
16
+ var SURFACE_ANCHOR_VARIABLE = exports.SURFACE_ANCHOR_VARIABLE = '--block-controls-surface-anchor-name';
17
+
18
+ /**
19
+ * These node views expose the box used by the measured placement fallback rather than their
20
+ * ProseMirror node wrapper. The marker carries the name through a custom property so sparse CSS
21
+ * can name that inner box without adding a widget or changing the node view.
22
+ */
23
+ var INNER_CONTENT_NODE_TYPES = new Set(['blockCard', 'bodiedExtension', 'embedCard', 'extension', 'mediaSingle', 'multiBodiedExtension', 'table']);
24
+ var getMarkerStyle = function getMarkerStyle(nodeType, anchorName) {
25
+ var inheritedName = "".concat(SURFACE_ANCHOR_VARIABLE, ": ").concat(anchorName, ";");
26
+
27
+ // Inner boxes get their anchor from the sparse global selector. Naming only the node wrapper
28
+ // would position media/table/extension controls against the wrapper instead of visible content.
29
+ return INNER_CONTENT_NODE_TYPES.has(nodeType) ? inheritedName : "".concat(inheritedName, " anchor-name: ").concat(anchorName, ";");
30
+ };
31
+
32
+ /**
33
+ * Builds sparse CSS anchor decorations from already-qualified cached positions. Anchor identity is
34
+ * supplied by the editor's native node-anchor provider so sparse surfaces and consumers share the
35
+ * same `data-node-anchor`.
36
+ */
37
+ var createSurfaceAnchorDecorations = exports.createSurfaceAnchorDecorations = function createSurfaceAnchorDecorations(state, positions, resolveAnchorName, previousAnchors) {
38
+ var anchors = new Map();
39
+ var decorations = [];
40
+ var _iterator = _createForOfIteratorHelper(positions),
41
+ _step;
42
+ try {
43
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
44
+ var position = _step.value;
45
+ if (anchors.has(position)) {
46
+ continue;
47
+ }
48
+ var node = state.doc.nodeAt(position);
49
+ if (!(node !== null && node !== void 0 && node.isBlock)) {
50
+ continue;
51
+ }
52
+ var anchorName = resolveAnchorName(node, position, previousAnchors === null || previousAnchors === void 0 ? void 0 : previousAnchors.get(position));
53
+ if (!anchorName) {
54
+ continue;
55
+ }
56
+ anchors.set(position, anchorName);
57
+ decorations.push(_view.Decoration.node(position, position + node.nodeSize, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, SURFACE_ANCHOR_ATTR, anchorName), SURFACE_NODE_TYPE_ATTR, node.type.name), "style", getMarkerStyle(node.type.name, anchorName)), {
58
+ type: TYPE_SURFACE_ANCHOR_DEC,
59
+ anchorName: anchorName,
60
+ nodeType: node.type.name
61
+ }));
62
+ }
63
+ } catch (err) {
64
+ _iterator.e(err);
65
+ } finally {
66
+ _iterator.f();
67
+ }
68
+ return {
69
+ anchors: anchors,
70
+ decorations: _view.DecorationSet.create(state.doc, decorations)
71
+ };
72
+ };
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.handleMouseDown = void 0;
7
7
  var _styles = require("@atlaskit/editor-common/styles");
8
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
8
9
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
10
  var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
10
11
  return function (view, event) {
@@ -19,7 +20,7 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
19
20
  if (!rootNode) {
20
21
  return false;
21
22
  }
22
- if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
23
+ if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
23
24
  var _rootNode$type$name, _rootNode$type$name2;
24
25
  var anchorName = api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(rootNode, rootPos);
25
26
 
@@ -9,6 +9,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
9
9
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
10
10
  var _selection = require("@atlaskit/editor-common/selection");
11
11
  var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
12
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
12
13
  var _fg = require("@atlaskit/platform-feature-flags/fg");
13
14
  var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
14
15
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
@@ -140,7 +141,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
140
141
  // Ignored via go/ees005
141
142
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
142
143
  var target = event.target;
143
- var isNativeAnchorSupported = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
144
+ var isNativeAnchorSupported = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration');
144
145
  if (target !== null && target !== void 0 && (_target$classList = target.classList) !== null && _target$classList !== void 0 && _target$classList.contains('ProseMirror')) {
145
146
  return false;
146
147
  }
@@ -212,7 +213,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
212
213
  // This must happen before anchorName is read so the correct node's handle is shown.
213
214
  rootElement = redirectParagraphToWrappedMedia(rootElement, isNativeAnchorSupported);
214
215
  var anchorName;
215
- if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
216
+ if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
216
217
  anchorName = rootElement.getAttribute((0, _domAttrName.getAnchorAttrName)());
217
218
 
218
219
  // don't show handles if we can't find an anchor
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.handleSparseMouseOver = void 0;
7
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
8
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
10
+ var _decorationsCommon = require("./decorations-common");
11
+ var OPAQUE_BLOCKS = new Set(['table', 'bulletList', 'orderedList', 'taskList', 'decisionList', 'mediaSingle']);
12
+ var EXCLUDED_BLOCKS = new Set(['listItem', 'tableRow', 'tableCell', 'tableHeader', 'caption']);
13
+ var isPanelNodeTypeName = function isPanelNodeTypeName(nodeTypeName) {
14
+ return nodeTypeName === 'panel' || nodeTypeName === 'panel_c1' && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_controls_reliable_anchor', 'isEnabled', true) && (0, _fg.fg)('platform_editor_controls_reliable_anchor_patch_1');
15
+ };
16
+ var redirectParagraphToWrappedMedia = function redirectParagraphToWrappedMedia(view, $target, targetPosition) {
17
+ var node = view.state.doc.nodeAt(targetPosition);
18
+ if (!node || node.type.name !== 'paragraph') {
19
+ return {
20
+ position: targetPosition,
21
+ node: node
22
+ };
23
+ }
24
+ var index = $target.index();
25
+ for (var _i = 0, _arr = [index - 1, index + 1]; _i < _arr.length; _i++) {
26
+ var siblingIndex = _arr[_i];
27
+ if (siblingIndex < 0 || siblingIndex >= $target.parent.childCount) {
28
+ continue;
29
+ }
30
+ var sibling = $target.parent.child(siblingIndex);
31
+ if ((sibling.type.name === 'mediaSingle' || sibling.type.name === 'embedCard') && (sibling.attrs.layout === 'wrap-left' || sibling.attrs.layout === 'wrap-right')) {
32
+ return {
33
+ position: siblingIndex < index ? targetPosition - sibling.nodeSize : targetPosition + node.nodeSize,
34
+ node: sibling
35
+ };
36
+ }
37
+ }
38
+ return {
39
+ position: targetPosition,
40
+ node: node
41
+ };
42
+ };
43
+
44
+ /** Resolves hover from PM structure so the first hover can create its sparse candidate. */
45
+ var handleSparseMouseOver = exports.handleSparseMouseOver = function handleSparseMouseOver(view, event, api) {
46
+ var _api$editorDisabled$s, _api$editorDisabled, _api$editorViewMode, _api$showDiff$sharedS, _api$showDiff, _api$userIntent, _$pos$nodeAfter, _controls$activeNode, _anchors$get, _anchors$get2;
47
+ var controls = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
48
+ if (!api || controls !== null && controls !== void 0 && controls.isDragging || !(event.target instanceof Element) || event.target === view.dom) {
49
+ return false;
50
+ }
51
+ 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;
52
+ 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;
53
+ if (editorDisabled && (editorViewMode !== 'view' || !(controls !== null && controls !== void 0 && controls.rightSideControlsEnabled))) {
54
+ return false;
55
+ }
56
+ 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;
57
+ 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;
58
+ if ((isDisplayingDiff || currentUserIntent === 'reviewing') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
59
+ return false;
60
+ }
61
+ var position;
62
+ try {
63
+ position = view.posAtDOM(event.target, 0);
64
+ } catch (_unused) {
65
+ return false;
66
+ }
67
+ var $pos = view.state.doc.resolve(position);
68
+ var targetPosition;
69
+ var opaque = false;
70
+ for (var depth = 1; depth <= $pos.depth; depth++) {
71
+ var _node = $pos.node(depth);
72
+ if (!_node.isBlock || EXCLUDED_BLOCKS.has(_node.type.name)) {
73
+ continue;
74
+ }
75
+ targetPosition = $pos.before(depth);
76
+ if (OPAQUE_BLOCKS.has(_node.type.name)) {
77
+ opaque = true;
78
+ break;
79
+ }
80
+ }
81
+ if (!opaque && (_$pos$nodeAfter = $pos.nodeAfter) !== null && _$pos$nodeAfter !== void 0 && _$pos$nodeAfter.isBlock && !EXCLUDED_BLOCKS.has($pos.nodeAfter.type.name)) {
82
+ // Browser positions over non-editable node chrome can resolve to the first editable child.
83
+ // Keep the ancestor unless that child actually owns the hovered DOM target.
84
+ var nodeAfterDOM = view.nodeDOM(position);
85
+ if (nodeAfterDOM instanceof Element && nodeAfterDOM.contains(event.target)) {
86
+ targetPosition = position;
87
+ }
88
+ }
89
+ if (targetPosition === undefined) {
90
+ return false;
91
+ }
92
+ var initialNode = view.state.doc.nodeAt(targetPosition);
93
+ if (!initialNode) {
94
+ return false;
95
+ }
96
+ var target = redirectParagraphToWrappedMedia(view, view.state.doc.resolve(targetPosition), targetPosition);
97
+ targetPosition = target.position;
98
+ var node = target.node;
99
+ if (!node || (controls === null || controls === void 0 || (_controls$activeNode = controls.activeNode) === null || _controls$activeNode === void 0 ? void 0 : _controls$activeNode.pos) === targetPosition) {
100
+ return false;
101
+ }
102
+ var $target = view.state.doc.resolve(targetPosition);
103
+ if ($target.depth > 0 && (node.type.name === 'paragraph' || node.type.name === 'heading') && node.content.size === 0) {
104
+ return false;
105
+ }
106
+ var parentNode = $target.parent;
107
+ var parentPosition = $target.depth > 0 ? $target.before($target.depth) : undefined;
108
+ var parentDOM = parentPosition === undefined ? undefined : view.nodeDOM(parentPosition);
109
+ if (isPanelNodeTypeName(parentNode.type.name) && !(parentDOM instanceof HTMLElement && parentDOM.classList.contains('ak-editor-panel__no-icon')) && $target.index() === 0) {
110
+ return false;
111
+ }
112
+ if (node.type.name === 'layoutColumn' && parentNode.type.name === 'layoutSection' && parentNode.childCount === 1 && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('advanced_layouts', 'isEnabled', true) && !(0, _expValEquals.expValEquals)('platform_editor_layout_column_menu', 'isEnabled', true)) {
113
+ return false;
114
+ }
115
+ var anchors = controls === null || controls === void 0 ? void 0 : controls.surfaceAnchors;
116
+ 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);
117
+ var rootPos = $target.depth > 0 ? $target.before(1) : targetPosition;
118
+ var rootNode = view.state.doc.nodeAt(rootPos);
119
+ 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;
120
+ if (!anchorName || !rootNode) {
121
+ return false;
122
+ }
123
+ api.core.actions.execute(api.blockControls.commands.showDragHandleAt(targetPosition, anchorName, (0, _decorationsCommon.getNodeTypeWithLevel)(node), undefined, rootPos, rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : anchorName, (0, _decorationsCommon.getNodeTypeWithLevel)(rootNode)));
124
+ return false;
125
+ };