@atlaskit/editor-plugin-block-controls 20.0.0 → 20.0.2

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 (33) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/blockControlsPlugin.js +12 -16
  3. package/dist/cjs/editor-commands/move-node-with-block-menu.js +0 -4
  4. package/dist/cjs/editor-commands/move-node.js +2 -2
  5. package/dist/cjs/editor-commands/utils/move-node-utils.js +6 -9
  6. package/dist/cjs/pm-plugins/handle-mouse-down.js +5 -13
  7. package/dist/cjs/pm-plugins/handle-mouse-over.js +17 -26
  8. package/dist/cjs/pm-plugins/main.js +11 -15
  9. package/dist/cjs/pm-plugins/utils/expand-and-update-selection.js +1 -5
  10. package/dist/cjs/pm-plugins/utils/getSelection.js +11 -95
  11. package/dist/cjs/ui/drag-handle.js +49 -127
  12. package/dist/es2019/blockControlsPlugin.js +12 -16
  13. package/dist/es2019/editor-commands/move-node-with-block-menu.js +0 -4
  14. package/dist/es2019/editor-commands/move-node.js +2 -2
  15. package/dist/es2019/editor-commands/utils/move-node-utils.js +6 -9
  16. package/dist/es2019/pm-plugins/handle-mouse-down.js +5 -13
  17. package/dist/es2019/pm-plugins/handle-mouse-over.js +17 -26
  18. package/dist/es2019/pm-plugins/main.js +11 -15
  19. package/dist/es2019/pm-plugins/utils/expand-and-update-selection.js +1 -5
  20. package/dist/es2019/pm-plugins/utils/getSelection.js +7 -93
  21. package/dist/es2019/ui/drag-handle.js +31 -109
  22. package/dist/esm/blockControlsPlugin.js +12 -16
  23. package/dist/esm/editor-commands/move-node-with-block-menu.js +0 -4
  24. package/dist/esm/editor-commands/move-node.js +2 -2
  25. package/dist/esm/editor-commands/utils/move-node-utils.js +6 -9
  26. package/dist/esm/pm-plugins/handle-mouse-down.js +5 -13
  27. package/dist/esm/pm-plugins/handle-mouse-over.js +17 -26
  28. package/dist/esm/pm-plugins/main.js +11 -15
  29. package/dist/esm/pm-plugins/utils/expand-and-update-selection.js +1 -5
  30. package/dist/esm/pm-plugins/utils/getSelection.js +11 -95
  31. package/dist/esm/ui/drag-handle.js +49 -127
  32. package/dist/types/pm-plugins/utils/getSelection.d.ts +1 -1
  33. package/package.json +3 -3
@@ -1,6 +1,5 @@
1
1
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
3
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
4
3
  import { createPreservedSelection } from '../../pm-plugins/utils/selection';
5
4
 
6
5
  /**
@@ -28,7 +27,7 @@ export var getNodeBoundsFromSelection = function getNodeBoundsFromSelection(sele
28
27
  // Special case: if a media node (file) is selected, we need to get the parent mediaGroup
29
28
  // This handles the case where clicking on a file creates a NodeSelection of the media node
30
29
  // but we want to move the entire mediaGroup that wraps it
31
- if (selection instanceof NodeSelection && selection.node.type.name === 'media' && selection.node.attrs.type === 'file' && editorExperiment('platform_editor_block_menu', true)) {
30
+ if (selection instanceof NodeSelection && selection.node.type.name === 'media' && selection.node.attrs.type === 'file') {
32
31
  // The media node is wrapped in a mediaGroup, so we need to get the parent position
33
32
  var mediaGroupPos = selection.$from.pos - 1;
34
33
  var mediaGroupNode = selection.$from.doc.nodeAt(mediaGroupPos);
@@ -53,7 +52,7 @@ export var getNodeBoundsFromSelection = function getNodeBoundsFromSelection(sele
53
52
  export var getPosWhenMoveNodeUp = function getPosWhenMoveNodeUp($currentNodePos, currentNodePos) {
54
53
  var nodeIndex = $currentNodePos.index();
55
54
  var nodeBefore = $currentNodePos.depth > 1 && nodeIndex === 0 ? $currentNodePos.node($currentNodePos.depth) : $currentNodePos.nodeBefore;
56
- if ((nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name) === 'layoutColumn' && editorExperiment('platform_editor_block_menu', true)) {
55
+ if ((nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name) === 'layoutColumn') {
57
56
  return -1;
58
57
  }
59
58
  return nodeBefore ? currentNodePos - nodeBefore.nodeSize : -1;
@@ -67,12 +66,10 @@ export var getPosWhenMoveNodeDown = function getPosWhenMoveNodeDown(_ref) {
67
66
  return -1;
68
67
  }
69
68
  var nodeAfter = tr.doc.nodeAt(nodeAfterPos);
70
- if (editorExperiment('platform_editor_block_menu', true)) {
71
- var nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
72
- // if move empty line down to another empty line, move to the position of the next empty line
73
- if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
74
- return nodeAfterPos;
75
- }
69
+ var nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
70
+ // if move empty line down to another empty line, move to the position of the next empty line
71
+ if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
72
+ return nodeAfterPos;
76
73
  }
77
74
 
78
75
  // if not the last node, move to the end of the next node
@@ -1,6 +1,5 @@
1
1
  import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
2
2
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
4
3
  export var handleMouseDown = function handleMouseDown(api) {
5
4
  return function (view, event) {
6
5
  if (!(event.target instanceof HTMLElement)) {
@@ -28,7 +27,7 @@ export var handleMouseDown = function handleMouseDown(api) {
28
27
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name3 = rootNode.type.name) !== null && _rootNode$type$name3 !== void 0 ? _rootNode$type$name3 : '', undefined, rootPos, '', (_rootNode$type$name4 = rootNode.type.name) !== null && _rootNode$type$name4 !== void 0 ? _rootNode$type$name4 : ''));
29
28
  }
30
29
  } else {
31
- var isDragHandle = event.target.closest(editorExperiment('platform_editor_block_menu', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
30
+ var isDragHandle = event.target.closest(DRAG_HANDLE_SELECTOR) !== null;
32
31
  api === null || api === void 0 || api.core.actions.execute(function (_ref) {
33
32
  var tr = _ref.tr;
34
33
  api === null || api === void 0 || api.blockControls.commands.setSelectedViaDragHandle(isDragHandle)({
@@ -38,17 +37,10 @@ export var handleMouseDown = function handleMouseDown(api) {
38
37
  * When block menu is enabled, reset intent back to 'default' as editor-plugin-block-menu sets the user intent to 'blockMenuOpen', and setting here
39
38
  * causes flickering as this runs before editor-plugin-block-menu.
40
39
  */
41
- if (editorExperiment('platform_editor_block_menu', true)) {
42
- // if target is drag handle, block menu will be opened
43
- if (!isDragHandle) {
44
- var _api$userIntent;
45
- api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('default')({
46
- tr: tr
47
- });
48
- }
49
- } else {
50
- var _api$userIntent2;
51
- (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent(isDragHandle ? 'dragHandleSelected' : 'default')({
40
+ // if target is drag handle, block menu will be opened
41
+ if (!isDragHandle) {
42
+ var _api$userIntent;
43
+ api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('default')({
52
44
  tr: tr
53
45
  });
54
46
  }
@@ -120,9 +120,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
120
120
  }
121
121
 
122
122
  // If the editor view is not in focus when the block menu is open, do not update the drag handle
123
- if (!view.hasFocus() && isMenuOpen && editorExperiment('platform_editor_block_menu', true, {
124
- exposure: true
125
- })) {
123
+ if (!view.hasFocus() && isMenuOpen) {
126
124
  return false;
127
125
  }
128
126
 
@@ -272,35 +270,28 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
272
270
  var nodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : // Fallback for table nodes: tr has data-prosemirror-node-name but not data-drag-handler-node-type.
273
271
  (_rootElement$getAttri2 = rootElement.getAttribute('data-drag-handler-node-type')) !== null && _rootElement$getAttri2 !== void 0 ? _rootElement$getAttri2 : getTypeNameFromDom(rootElement);
274
272
  if (nodeType) {
273
+ var _api$userIntent2;
275
274
  // platform_editor_controls note: enables quick insert
276
275
  if (toolbarFlagsEnabled) {
277
- if (editorExperiment('platform_editor_block_menu', true)) {
278
- var _selectionPreservatio;
279
- var preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
280
- var selection = preservedSelection || view.state.selection;
281
- var isMultipleSelected = selection && isMultiBlockSelection(selection);
276
+ var _selectionPreservatio;
277
+ var preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
278
+ var selection = preservedSelection || view.state.selection;
279
+ var isMultipleSelected = selection && isMultiBlockSelection(selection);
282
280
 
283
- // Only execute when selection is not a multi-selection, block menu is open, and menu is opened via keyboard
284
- // as when it is a multi-selection, the showDragHandleAt command interfere with selection
285
- // sometimes makes the multi-selection not continous after block menu is opened with keyboard
286
- if (!(isMultipleSelected && isMenuOpen && blockMenuOptions !== null && blockMenuOptions !== void 0 && blockMenuOptions.openedViaKeyboard)) {
287
- var _api$core, _api$blockControls3;
288
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, rootPos !== null && rootPos !== void 0 ? rootPos : targetPos, rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : anchorName, rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType));
289
- }
290
- } else {
291
- var _api$core2, _api$blockControls4;
292
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, rootPos !== null && rootPos !== void 0 ? rootPos : targetPos, rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : anchorName, rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType));
281
+ // Only execute when selection is not a multi-selection, block menu is open, and menu is opened via keyboard
282
+ // as when it is a multi-selection, the showDragHandleAt command interfere with selection
283
+ // sometimes makes the multi-selection not continous after block menu is opened with keyboard
284
+ if (!(isMultipleSelected && isMenuOpen && blockMenuOptions !== null && blockMenuOptions !== void 0 && blockMenuOptions.openedViaKeyboard)) {
285
+ var _api$core, _api$blockControls3;
286
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, rootPos !== null && rootPos !== void 0 ? rootPos : targetPos, rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : anchorName, rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType));
293
287
  }
294
288
  } else {
295
- var _api$core3, _api$blockControls5;
296
- api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.showDragHandleAt(targetPos, anchorName, nodeType));
289
+ var _api$core2, _api$blockControls4;
290
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.showDragHandleAt(targetPos, anchorName, nodeType));
297
291
  }
298
- if (editorExperiment('platform_editor_block_menu', true)) {
299
- var _api$userIntent2;
300
- if (isMenuOpen && originalAnchorName && (api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || (_api$userIntent2 = _api$userIntent2.sharedState.currentState()) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.currentUserIntent) === 'blockMenuOpen') {
301
- var _api$core4, _api$blockControls6;
302
- api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 ? void 0 : _api$blockControls6.commands.toggleBlockMenu());
303
- }
292
+ if (isMenuOpen && originalAnchorName && (api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || (_api$userIntent2 = _api$userIntent2.sharedState.currentState()) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.currentUserIntent) === 'blockMenuOpen') {
293
+ var _api$core3, _api$blockControls5;
294
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.toggleBlockMenu());
304
295
  }
305
296
  }
306
297
  }
@@ -381,7 +381,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
381
381
  // Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
382
382
  // This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
383
383
  // This is likely a prosemirror and safari integration bug, but to unblock the issue, we are going to use mappedPos.deleted in safari for now
384
- if (browser.webkit && editorExperiment('platform_editor_block_menu', true)) {
384
+ if (browser.webkit) {
385
385
  _mappedPos = tr.mapping.mapResult(activeNode.pos);
386
386
  isActiveNodeDeleted = _mappedPos.deleted;
387
387
  } else {
@@ -896,7 +896,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
896
896
  // handle - so findHandleDec is always empty. Don't clear activeNode in that case.
897
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;
898
898
  // Keep the registry surface mounted while its Block Menu owns focus.
899
- var keepActiveNodeForOpenBlockMenu = !flags.legacyDragHandleEnabled && isMenuOpen && editorExperiment('platform_editor_block_menu', true);
899
+ var keepActiveNodeForOpenBlockMenu = !flags.legacyDragHandleEnabled && isMenuOpen;
900
900
  newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
901
901
  } else {
902
902
  var _latestActiveNode13, _latestActiveNode14;
@@ -915,15 +915,11 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
915
915
  });
916
916
  }
917
917
  var isMenuOpenNew = isMenuOpen;
918
- if (editorExperiment('platform_editor_block_menu', true)) {
919
- if (meta !== null && meta !== void 0 && meta.closeMenu) {
920
- isMenuOpenNew = false;
921
- } else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
922
- var isSameAnchor = (meta === null || meta === void 0 ? void 0 : meta.toggleMenu.anchorName) === menuTriggerBy;
923
- isMenuOpenNew = menuTriggerBy === undefined || isSameAnchor || !isMenuOpen && !isSameAnchor ? !isMenuOpen : isMenuOpen;
924
- }
918
+ if (meta !== null && meta !== void 0 && meta.closeMenu) {
919
+ isMenuOpenNew = false;
925
920
  } else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
926
- isMenuOpenNew = !isMenuOpen;
921
+ var isSameAnchor = (meta === null || meta === void 0 ? void 0 : meta.toggleMenu.anchorName) === menuTriggerBy;
922
+ isMenuOpenNew = menuTriggerBy === undefined || isSameAnchor || !isMenuOpen && !isSameAnchor ? !isMenuOpen : isMenuOpen;
927
923
  }
928
924
  var isSelectedViaDragHandleNew;
929
925
  if (flags.toolbarFlagsEnabled) {
@@ -938,13 +934,13 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
938
934
  activeDropTargetNode: currentActiveDropTargetNode,
939
935
  isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
940
936
  isMenuOpen: isMenuOpenNew,
941
- menuTriggerBy: flags.toolbarFlagsEnabled || editorExperiment('platform_editor_block_menu', true) ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
937
+ menuTriggerBy: (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy,
942
938
  menuTriggerByNode: (meta === null || meta === void 0 || (_meta$toggleMenu2 = meta.toggleMenu) === null || _meta$toggleMenu2 === void 0 ? void 0 : _meta$toggleMenu2.triggerByNode) || menuTriggerByNode,
943
- blockMenuOptions: editorExperiment('platform_editor_block_menu', true) ? {
939
+ blockMenuOptions: {
944
940
  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,
945
941
  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,
946
942
  openedViaKeyboard: (meta === null || meta === void 0 || (_meta$toggleMenu7 = meta.toggleMenu) === null || _meta$toggleMenu7 === void 0 ? void 0 : _meta$toggleMenu7.openedViaKeyboard) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu8 = meta.toggleMenu) === null || _meta$toggleMenu8 === void 0 ? void 0 : _meta$toggleMenu8.openedViaKeyboard : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.openedViaKeyboard
947
- } : undefined,
943
+ },
948
944
  editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : editorHeight,
949
945
  editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : editorWidthLeft,
950
946
  editorWidthRight: (_meta$editorWidthRigh = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh !== void 0 ? _meta$editorWidthRigh : editorWidthRight,
@@ -1190,12 +1186,12 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1190
1186
  }
1191
1187
  }
1192
1188
  if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1')) {
1193
- var isDragHandle = event.target.closest(editorExperiment('platform_editor_block_menu', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
1189
+ var isDragHandle = event.target.closest(DRAG_HANDLE_SELECTOR) !== null;
1194
1190
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
1195
1191
  }
1196
1192
  if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1')) {
1197
1193
  var _api$blockControls$sh2, _api$blockControls$sh3;
1198
- var isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen) && editorExperiment('platform_editor_block_menu', true);
1194
+ var isBlockMenuOpen = api === null || api === void 0 || (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen;
1199
1195
  // when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
1200
1196
  // in this scenario, isSelectedViaDragHandle should not be set to false
1201
1197
  if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
@@ -1,10 +1,8 @@
1
1
  import { selectNodeAtPos } from '@atlaskit/editor-common/node-selection';
2
2
  import { expandToBlockRange, isMultiBlockRange } from '@atlaskit/editor-common/selection';
3
- import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
4
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
4
  import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
6
5
  import { fg } from '@atlaskit/platform-feature-flags/fg';
7
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
8
6
  import { selectNode } from './getSelection';
9
7
  import { adjustSelectionBoundsForEdgePositions } from './selection';
10
8
  var isPosWithinRange = function isPosWithinRange(pos, range) {
@@ -58,9 +56,7 @@ export var expandAndUpdateSelection = function expandAndUpdateSelection(_ref2) {
58
56
  if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && isMultiBlockRange(expandedRange.range)) {
59
57
  // Then create a selection from the start of the first node to the end of the last node
60
58
  tr.setSelection(TextSelection.create(tr.doc, Math.min(selection.from, expandedRange.$from.pos), Math.max(selection.to, expandedRange.$to.pos)));
61
- } else if (
62
- // eslint-disable-next-line @atlaskit/platform/no-preconditioning
63
- fg('platform_editor_maui_jira_updates') && (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || editorExperiment('platform_editor_block_menu', true))) {
59
+ } else if (fg('platform_editor_maui_jira_updates')) {
64
60
  // Under the gate (and when on the simplified newGetSelection path), use
65
61
  // the platform-level composer — same path as open-remix-modal, no drift.
66
62
  selectNodeAtPos(tr, startPos, nodeType);
@@ -5,7 +5,6 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
5
5
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
7
7
  import { fg } from '@atlaskit/platform-feature-flags/fg';
8
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
9
8
  export var getInlineNodePos = function getInlineNodePos(doc, start, nodeSize) {
10
9
  var $startPos = doc.resolve(start);
11
10
  // To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
@@ -38,45 +37,6 @@ export var isNodeWithCodeBlock = function isNodeWithCodeBlock(tr, start, nodeSiz
38
37
  });
39
38
  return hasCodeBlock;
40
39
  };
41
- var isNodeWithMediaOrExtension = function isNodeWithMediaOrExtension(doc, start, nodeSize) {
42
- var $startPos = doc.resolve(start);
43
- var hasMediaOrExtension = false;
44
- doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n) {
45
- if (['media', 'extension'].includes(n.type.name)) {
46
- hasMediaOrExtension = true;
47
- }
48
- });
49
- return hasMediaOrExtension;
50
- };
51
- var oldGetSelection = function oldGetSelection(tr, start) {
52
- var node = tr.doc.nodeAt(start);
53
- var isNodeSelection = node && NodeSelection.isSelectable(node);
54
- var nodeSize = node ? node.nodeSize : 1;
55
- var $startPos = tr.doc.resolve(start);
56
- var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
57
- var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr.doc, start, nodeSize);
58
- var isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr.doc, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr.doc, start, nodeSize);
59
- if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension || isBlockQuoteWithMediaOrExtension ||
60
- // decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
61
- ['decisionList', 'layoutColumn'].includes(nodeName || '')) {
62
- return new NodeSelection($startPos);
63
- } else if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
64
- var $mediaStartPos = tr.doc.resolve(start + 1);
65
- return new NodeSelection($mediaStartPos);
66
- } else if (
67
- // Even though mediaGroup is not selectable,
68
- // we need a quick way to make all child media nodes appear as selected without the need for a custom selection
69
- nodeName === 'mediaGroup') {
70
- return new NodeSelection($startPos);
71
- } else if (nodeName === 'taskList') {
72
- return TextSelection.create(tr.doc, start, start + nodeSize);
73
- } else {
74
- var _getInlineNodePos = getInlineNodePos(tr.doc, start, nodeSize),
75
- inlineNodePos = _getInlineNodePos.inlineNodePos,
76
- inlineNodeEndPos = _getInlineNodePos.inlineNodeEndPos;
77
- return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(inlineNodeEndPos));
78
- }
79
- };
80
40
 
81
41
  /**
82
42
  * Gets the appropriate selection for the node at the given start position.
@@ -87,75 +47,31 @@ var oldGetSelection = function oldGetSelection(tr, start) {
87
47
  * @returns The appropriate selection for the node.
88
48
  */
89
49
  export var newGetSelection = function newGetSelection(doc, selectionEmpty, start) {
90
- // Under the gate, delegate to getNodeSelectionForPos only when
91
- // platform_editor_block_menu is on — getNodeSelectionForPos matches that
92
- // simplified path (NodeSelection for all nodes). When block_menu is off,
93
- // fall through to the oldGetSelection branch which handles expand/taskList/
94
- // inline nodes correctly with TextSelection.
95
- if (
96
- // eslint-disable-next-line @atlaskit/platform/no-preconditioning
97
- fg('platform_editor_maui_jira_updates') && editorExperiment('platform_editor_block_menu', true)) {
50
+ if (fg('platform_editor_maui_jira_updates')) {
98
51
  return getNodeSelectionForPos(doc, start) || false;
99
52
  }
100
53
  var node = doc.nodeAt(start);
101
- var isNodeSelection = node && NodeSelection.isSelectable(node);
102
- var nodeSize = node ? node.nodeSize : 1;
103
54
  var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
104
- if (editorExperiment('platform_editor_block_menu', true)) {
105
- // if mediaGroup only has a single child, we want to select the child
106
- if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
107
- var $mediaStartPos = doc.resolve(start + 1);
108
- return new NodeSelection($mediaStartPos);
109
- }
110
- return new NodeSelection(doc.resolve(start));
111
- }
112
-
113
- // this is a fix for empty paragraph selection - put first to avoid any extra work
114
- if (nodeName === 'paragraph' && selectionEmpty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
115
- return false;
116
- }
117
- var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(doc, start, nodeSize);
118
- var isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(doc, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(doc, start, nodeSize);
119
- if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension || isBlockQuoteWithMediaOrExtension ||
120
- // decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
121
- ['decisionList', 'layoutColumn'].includes(nodeName || '') || nodeName === 'mediaGroup' && typeof (node === null || node === void 0 ? void 0 : node.childCount) === 'number' && (node === null || node === void 0 ? void 0 : node.childCount) > 1) {
122
- return new NodeSelection(doc.resolve(start));
123
- }
124
55
 
125
56
  // if mediaGroup only has a single child, we want to select the child
126
- if (nodeName === 'mediaGroup') {
127
- var _$mediaStartPos = doc.resolve(start + 1);
128
- return new NodeSelection(_$mediaStartPos);
129
- }
130
- if (nodeName === 'taskList') {
131
- return TextSelection.create(doc, start, start + nodeSize);
57
+ if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
58
+ var $mediaStartPos = doc.resolve(start + 1);
59
+ return new NodeSelection($mediaStartPos);
132
60
  }
133
- var _getInlineNodePos2 = getInlineNodePos(doc, start, nodeSize),
134
- inlineNodePos = _getInlineNodePos2.inlineNodePos,
135
- inlineNodeEndPos = _getInlineNodePos2.inlineNodeEndPos;
136
- return new TextSelection(doc.resolve(inlineNodePos), doc.resolve(inlineNodeEndPos));
61
+ return new NodeSelection(doc.resolve(start));
137
62
  };
138
- export var getSelection = function getSelection(tr, start, api) {
139
- if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || editorExperiment('platform_editor_block_menu', true)) {
140
- return newGetSelection(tr.doc, tr.selection.empty, start);
141
- }
142
- return oldGetSelection(tr, start);
63
+ export var getSelection = function getSelection(tr, start) {
64
+ return newGetSelection(tr.doc, tr.selection.empty, start);
143
65
  };
144
66
  export var selectNode = function selectNode(tr, start, nodeType, api) {
145
- // Only use the platform path when already on the simplified newGetSelection
146
- // branch — i.e. when platform_editor_block_menu is on or toolbar flags are
147
- // enabled. This preserves oldGetSelection behaviour (e.g. taskList →
148
- // TextSelection) in legacy contexts where those flags are off.
149
- if (
150
- // eslint-disable-next-line @atlaskit/platform/no-preconditioning
151
- fg('platform_editor_maui_jira_updates') && editorExperiment('platform_editor_block_menu', true)) {
67
+ if (fg('platform_editor_maui_jira_updates')) {
152
68
  return selectNodeAtPos(tr, start, nodeType);
153
69
  }
154
70
  if (nodeType === 'table') {
155
71
  tr = selectTableClosestToPos(tr, tr.doc.resolve(start + 1));
156
72
  return tr;
157
73
  }
158
- var selection = getSelection(tr, start, api);
74
+ var selection = getSelection(tr, start);
159
75
  if (selection) {
160
76
  tr.setSelection(selection);
161
77
  }
@@ -180,8 +96,8 @@ export var setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(
180
96
  tr.setSelection(_selection);
181
97
  return tr;
182
98
  }
183
- var _getInlineNodePos3 = getInlineNodePos(tr.doc, start, nodeSize),
184
- inlineNodeEndPos = _getInlineNodePos3.inlineNodeEndPos;
99
+ var _getInlineNodePos = getInlineNodePos(tr.doc, start, nodeSize),
100
+ inlineNodeEndPos = _getInlineNodePos.inlineNodeEndPos;
185
101
  selection = new TextSelection(tr.doc.resolve(inlineNodeEndPos));
186
102
  tr.setSelection(selection);
187
103
  return tr;