@atlaskit/editor-plugin-block-controls 6.3.3 → 6.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 6.3.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`d5e5b25fe885a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d5e5b25fe885a) -
8
+ [ux] ED-29226 Open block menu when drag handle is focussed and space or enter key is pressed
9
+ - Updated dependencies
10
+
11
+ ## 6.3.4
12
+
13
+ ### Patch Changes
14
+
15
+ - [`d278f35b3fb0f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d278f35b3fb0f) -
16
+ Cleaned up platform_editor_element_drag_and_drop_ed_23873
17
+ - Updated dependencies
18
+
3
19
  ## 6.3.3
4
20
 
5
21
  ### Patch Changes
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.moveNodeWithBlockMenu = void 0;
7
7
  var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _types = require("@atlaskit/editor-common/types");
9
+ var _state = require("@atlaskit/editor-prosemirror/state");
10
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
9
11
  var _moveNode = require("./move-node");
10
12
  var _moveNodeUtils = require("./utils/move-node-utils");
11
13
  var moveNodeWithBlockMenu = exports.moveNodeWithBlockMenu = function moveNodeWithBlockMenu(api, direction) {
@@ -36,6 +38,13 @@ var moveNodeWithBlockMenu = exports.moveNodeWithBlockMenu = function moveNodeWit
36
38
  (0, _moveNode.moveNode)(api)(currentNodePos, moveToPos, _analytics.INPUT_METHOD.BLOCK_MENU)({
37
39
  tr: tr
38
40
  });
41
+ if (tr.selection.empty && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
42
+ var nodeAtCurrentPos = tr.doc.nodeAt(currentNodePos);
43
+ var nodeAfter = tr.doc.nodeAt(moveToPos);
44
+ var isConsecutiveEmptyLineMove = (nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0;
45
+ var cursorPos = direction === _types.DIRECTION.UP || direction === _types.DIRECTION.DOWN && isConsecutiveEmptyLineMove ? moveToPos : moveToPos - 1;
46
+ tr.setSelection(_state.TextSelection.create(tr.doc, cursorPos));
47
+ }
39
48
  tr.scrollIntoView();
40
49
  }
41
50
  }
@@ -341,7 +341,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
341
341
  var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _analytics.INPUT_METHOD.DRAG_AND_DROP;
342
342
  var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
343
343
  return function (_ref7) {
344
- var _api$blockControls$co;
344
+ var _api$blockControls$co, _api$accessibilityUti;
345
345
  var tr = _ref7.tr;
346
346
  if (!api || (start < 0 || to < 0) && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_2')) {
347
347
  return tr;
@@ -453,26 +453,22 @@ var moveNode = exports.moveNode = function moveNode(api) {
453
453
  action: _analytics.ACTION.MOVED,
454
454
  actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
455
455
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
456
- attributes: _objectSpread(_objectSpread({
456
+ attributes: _objectSpread({
457
457
  nodeDepth: $handlePos.depth,
458
458
  nodeType: handleNode.type.name,
459
459
  destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
460
- destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name
461
- }, (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') && {
460
+ destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name,
462
461
  inputMethod: inputMethod
463
- }), isMultiSelect && {
462
+ }, isMultiSelect && {
464
463
  sourceNodeTypes: sourceNodeTypes,
465
464
  hasSelectedMultipleNodes: hasSelectedMultipleNodes
466
465
  })
467
466
  })(tr);
468
467
  }
469
- if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
470
- var _api$accessibilityUti;
471
- var movedMessage = to > sliceFrom ? _messages.blockControlsMessages.movedDown : _messages.blockControlsMessages.movedup;
472
- api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 || _api$accessibilityUti.actions.ariaNotify(formatMessage ? formatMessage(movedMessage) : movedMessage.defaultMessage, {
473
- priority: 'important'
474
- });
475
- }
468
+ var movedMessage = to > sliceFrom ? _messages.blockControlsMessages.movedDown : _messages.blockControlsMessages.movedup;
469
+ api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 || _api$accessibilityUti.actions.ariaNotify(formatMessage ? formatMessage(movedMessage) : movedMessage.defaultMessage, {
470
+ priority: 'important'
471
+ });
476
472
  return tr;
477
473
  };
478
474
  };
@@ -6,12 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getShouldMoveNode = exports.getPosWhenMoveNodeUp = exports.getPosWhenMoveNodeDown = exports.getCurrentNodePosFromDragHandleSelection = exports.canMoveNodeUpOrDown = void 0;
7
7
  var _selection = require("@atlaskit/editor-common/selection");
8
8
  var _utils = require("@atlaskit/editor-tables/utils");
9
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
9
10
  var _getNestedNodePosition = require("../../pm-plugins/utils/getNestedNodePosition");
10
11
  var getCurrentNodePosFromDragHandleSelection = exports.getCurrentNodePosFromDragHandleSelection = function getCurrentNodePosFromDragHandleSelection(_ref) {
11
12
  var selection = _ref.selection,
12
13
  schema = _ref.schema,
13
14
  resolve = _ref.resolve;
14
15
  var currentNodePos = -1;
16
+ if (selection.empty && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
17
+ currentNodePos = selection.$from.pos;
18
+ }
15
19
  if ((0, _utils.isTableSelected)(selection)) {
16
20
  var _findTable$pos, _findTable;
17
21
  // We only move table node if it's fully selected
@@ -45,6 +49,13 @@ var getPosWhenMoveNodeDown = exports.getPosWhenMoveNodeDown = function getPosWhe
45
49
  return -1;
46
50
  }
47
51
  var nodeAfter = tr.doc.nodeAt(nodeAfterPos);
52
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
53
+ var nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
54
+ // if move empty line down to another empty line, move to the position of the next empty line
55
+ 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') {
56
+ return nodeAfterPos;
57
+ }
58
+ }
48
59
 
49
60
  // if not the last node, move to the end of the next node
50
61
  return nodeAfter ? nodeAfterPos + nodeAfter.nodeSize : -1;
@@ -7,12 +7,11 @@ exports.boundKeydownHandler = void 0;
7
7
  var _keymaps = require("@atlaskit/editor-common/keymaps");
8
8
  var _types = require("@atlaskit/editor-common/types");
9
9
  var _keymap = require("@atlaskit/editor-prosemirror/keymap");
10
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
10
  var _moveNode = require("../editor-commands/move-node");
12
11
  var _showDragHandle = require("../editor-commands/show-drag-handle");
13
12
  function keymapList(api, formatMessage) {
14
13
  var keymapList = {};
15
- if (api && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
14
+ if (api) {
16
15
  (0, _keymaps.bindKeymapWithCommand)(
17
16
  // Ignored via go/ees005
18
17
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -37,7 +37,7 @@ var _activeAnchorTracker = require("./utils/active-anchor-tracker");
37
37
  var _analytics2 = require("./utils/analytics");
38
38
  var _anchorUtils = require("./utils/anchor-utils");
39
39
  var _getSelection = require("./utils/getSelection");
40
- var _selection2 = require("./utils/selection");
40
+ var _selection = require("./utils/selection");
41
41
  var _transactions = require("./utils/transactions");
42
42
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
43
43
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -144,7 +144,7 @@ var destroyFn = function destroyFn(api, editorView) {
144
144
  var _api$analytics2;
145
145
  var nodeTypes, hasSelectedMultipleNodes;
146
146
  if (isMultiSelect) {
147
- var position = (0, _selection2.getSelectedSlicePosition)(start, tr, api);
147
+ var position = (0, _selection.getSelectedSlicePosition)(start, tr, api);
148
148
  var attributes = (0, _analytics2.getMultiSelectAnalyticsAttributes)(tr, position.from, position.to);
149
149
  nodeTypes = attributes.nodeTypes;
150
150
  hasSelectedMultipleNodes = attributes.hasSelectedMultipleNodes;
@@ -759,20 +759,6 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
759
759
  return true;
760
760
  }
761
761
  }
762
-
763
- // Command + Shift + ArrowUp to select was broken with the plugin enabled so this manually sets the selection
764
- var _view$state = view.state,
765
- selection = _view$state.selection,
766
- doc = _view$state.doc,
767
- tr = _view$state.tr;
768
- var metaKey = _browser.browser.mac ? event.metaKey : event.ctrlKey;
769
- if (event.key === 'ArrowUp' && event.shiftKey && metaKey) {
770
- if (selection instanceof _state.TextSelection || selection instanceof _state.NodeSelection) {
771
- var newSelection = _state.TextSelection.create(doc, selection.head, 1);
772
- view.dispatch(tr.setSelection(newSelection));
773
- return true;
774
- }
775
- }
776
762
  if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
777
763
  var isDragHandle = event.target.closest((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? _styles.DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
778
764
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
@@ -790,19 +776,6 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
790
776
  }
791
777
  return false;
792
778
  } else {
793
- // Command + Shift + ArrowUp to select was broken with the plugin enabled so this manually sets the selection
794
- var _view$state2 = view.state,
795
- _selection = _view$state2.selection,
796
- _doc = _view$state2.doc,
797
- _tr = _view$state2.tr;
798
- var _metaKey = _browser.browser.mac ? event.metaKey : event.ctrlKey;
799
- if (event.key === 'ArrowUp' && event.shiftKey && _metaKey) {
800
- if (_selection instanceof _state.TextSelection || _selection instanceof _state.NodeSelection) {
801
- var _newSelection = _state.TextSelection.create(_doc, _selection.head, 1);
802
- view.dispatch(_tr.setSelection(_newSelection));
803
- return true;
804
- }
805
- }
806
779
  if (event.shiftKey && event.ctrlKey) {
807
780
  //prevent holding down key combo from firing repeatedly
808
781
  if (!event.repeat && (0, _keymap.boundKeydownHandler)(api, formatMessage)(view, event)) {
@@ -77,11 +77,28 @@ var newGetSelection = function newGetSelection(tr, start) {
77
77
  var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
78
78
  var nodeSize = node ? node.nodeSize : 1;
79
79
  var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
80
+ var blockMenuEnabled = (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true);
81
+ var blockMenuEmptyLineEnabled = (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true);
80
82
 
81
83
  // this is a fix for empty paragraph selection - put first to avoid any extra work
82
- if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
84
+ if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !blockMenuEnabled) {
83
85
  return false;
84
86
  }
87
+ var isParagraphHeadingEmpty = ['paragraph', 'heading'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0;
88
+ var isBlockQuoteEmpty = nodeName === 'blockquote' && (node === null || node === void 0 ? void 0 : node.textContent) === '';
89
+ var isListEmpty = ['orderedList', 'bulletList', 'taskList'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.textContent) === '';
90
+
91
+ // if block menu and empty line format menu are enabled,
92
+ // we want to set the selection to avoid the selection goes to the top of the document
93
+ if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && blockMenuEnabled && blockMenuEmptyLineEnabled) {
94
+ return _state.TextSelection.create(tr.doc, start + 1, start + 1);
95
+ }
96
+
97
+ // if block menu and empty line format menu are enabled,
98
+ // we want to set the selection to avoid the selection goes to the top of the document
99
+ if (['paragraph', 'heading', 'orderedList', 'bulletList', 'taskList', 'blockquote'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && blockMenuEnabled && blockMenuEmptyLineEnabled) {
100
+ return _state.TextSelection.create(tr.doc, start + 1, start + 1);
101
+ }
85
102
  var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
86
103
  var isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr, start, nodeSize);
87
104
  if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension || isBlockQuoteWithMediaOrExtension ||
@@ -275,7 +275,7 @@ var getNodeMargins = function getNodeMargins(node) {
275
275
  return _consts2.nodeMargins[nodeTypeName] || _consts2.nodeMargins['default'];
276
276
  };
277
277
  var DragHandle = exports.DragHandle = function DragHandle(_ref) {
278
- var _api$core2, _api$blockControls4, _api$analytics2, _api$core4;
278
+ var _api$core2, _api$blockControls4, _api$analytics2, _api$core5, _api$userIntent2;
279
279
  var view = _ref.view,
280
280
  api = _ref.api,
281
281
  formatMessage = _ref.formatMessage,
@@ -416,37 +416,64 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
416
416
  }
417
417
  }, [isLayoutColumn]);
418
418
  var handleKeyDown = (0, _react.useCallback)(function (e) {
419
- if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
420
- // allow user to use spacebar to select the node
421
- if (!e.repeat && e.key === ' ') {
422
- var _api$core3;
423
- var startPos = getPos();
424
- api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
425
- var tr = _ref3.tr;
426
- if (startPos === undefined) {
427
- return tr;
428
- }
429
- var node = tr.doc.nodeAt(startPos);
430
- if (!node) {
431
- return tr;
432
- }
433
- var $startPos = tr.doc.resolve(startPos + node.nodeSize);
434
- var selection = new _state.TextSelection($startPos);
435
- tr.setSelection(selection);
436
- !isMultiSelect && tr.setMeta(_main.key, {
437
- pos: startPos
438
- });
419
+ // allow user to use spacebar to select the node
420
+ if (!e.repeat && e.key === ' ') {
421
+ var _api$core3;
422
+ var startPos = getPos();
423
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
424
+ var tr = _ref3.tr;
425
+ if (startPos === undefined) {
439
426
  return tr;
427
+ }
428
+ var node = tr.doc.nodeAt(startPos);
429
+ if (!node) {
430
+ return tr;
431
+ }
432
+ var $startPos = tr.doc.resolve(startPos + node.nodeSize);
433
+ var selection = new _state.TextSelection($startPos);
434
+ tr.setSelection(selection);
435
+ !isMultiSelect && tr.setMeta(_main.key, {
436
+ pos: startPos
440
437
  });
441
- } else if (![e.altKey, e.ctrlKey, e.shiftKey].some(function (pressed) {
442
- return pressed;
443
- })) {
444
- // If not trying to press shortcut keys,
445
- // return focus to editor to resume editing from caret position
446
- view.focus();
438
+ return tr;
439
+ });
440
+ } else if ((e.key === 'Enter' || e.key === ' ') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true)) {
441
+ var _api$core4;
442
+ if (document.activeElement !== buttonRef.current) {
443
+ return;
447
444
  }
445
+ e.preventDefault();
446
+ e.stopPropagation();
447
+ setDragHandleSelected(!dragHandleSelected);
448
+ api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref4) {
449
+ var _api$blockControls5, _api$userIntent;
450
+ var tr = _ref4.tr;
451
+ var startPos = getPos();
452
+ if (startPos === undefined) {
453
+ return tr;
454
+ }
455
+ tr = (0, _getSelection.selectNode)(tr, startPos, nodeType);
456
+ api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.toggleBlockMenu({
457
+ anchorName: anchorName
458
+ })({
459
+ tr: tr
460
+ });
461
+ api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen')({
462
+ tr: tr
463
+ });
464
+ api === null || api === void 0 || api.blockControls.commands.setSelectedViaDragHandle(true)({
465
+ tr: tr
466
+ });
467
+ return tr;
468
+ });
469
+ } else if (![e.altKey, e.ctrlKey, e.shiftKey].some(function (pressed) {
470
+ return pressed;
471
+ })) {
472
+ // If not trying to press shortcut keys,
473
+ // return focus to editor to resume editing from caret position
474
+ view.focus();
448
475
  }
449
- }, [getPos, api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, isMultiSelect, view]);
476
+ }, [getPos, api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions, api === null || api === void 0 ? void 0 : api.blockControls.commands, api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands, isMultiSelect, view, anchorName, dragHandleSelected, nodeType]);
450
477
  (0, _react.useEffect)(function () {
451
478
  var element = buttonRef.current;
452
479
  if (!element) {
@@ -460,13 +487,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
460
487
  start: start
461
488
  };
462
489
  },
463
- onGenerateDragPreview: function onGenerateDragPreview(_ref4) {
490
+ onGenerateDragPreview: function onGenerateDragPreview(_ref5) {
464
491
  var _api$blockControls$sh2;
465
- var nativeSetDragImage = _ref4.nativeSetDragImage;
492
+ var nativeSetDragImage = _ref5.nativeSetDragImage;
466
493
  if (isMultiSelect) {
467
- var _api$core5;
468
- api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref5) {
469
- var tr = _ref5.tr;
494
+ var _api$core6;
495
+ api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref6) {
496
+ var tr = _ref6.tr;
470
497
  var handlePos = getPos();
471
498
  if (typeof handlePos !== 'number') {
472
499
  return tr;
@@ -474,8 +501,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
474
501
  var oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
475
502
  var newHandlePosCheck = (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos);
476
503
  if (!tr.selection.empty && ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
477
- var _api$blockControls5;
478
- api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
504
+ var _api$blockControls6;
505
+ api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setMultiSelectPositions()({
479
506
  tr: tr
480
507
  });
481
508
  } else if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_select_node_on_drag')) {
@@ -545,8 +572,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
545
572
  };
546
573
  }
547
574
  },
548
- render: function render(_ref6) {
549
- var container = _ref6.container;
575
+ render: function render(_ref7) {
576
+ var container = _ref7.container;
550
577
  var dom = view.dom.querySelector("[".concat((0, _domAttrName.getAnchorAttrName)(), "=\"").concat(anchorName, "\"]"));
551
578
  if (!dom) {
552
579
  return;
@@ -578,13 +605,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
578
605
  });
579
606
  },
580
607
  onDragStart: function onDragStart() {
581
- var _api$core6;
608
+ var _api$core7;
582
609
  if (start === undefined) {
583
610
  return;
584
611
  }
585
- api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref7) {
586
- var _api$blockControls$sh3, _api$blockControls6, _api$analytics3;
587
- var tr = _ref7.tr;
612
+ api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref8) {
613
+ var _api$blockControls$sh3, _api$blockControls7, _api$analytics3;
614
+ var tr = _ref8.tr;
588
615
  var nodeTypes, hasSelectedMultipleNodes;
589
616
  var resolvedMovingNode = tr.doc.resolve(start);
590
617
  var maybeNode = resolvedMovingNode.nodeAfter;
@@ -597,7 +624,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
597
624
  nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
598
625
  hasSelectedMultipleNodes = false;
599
626
  }
600
- api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
627
+ api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 || _api$blockControls7.commands.setNodeDragged(getPos, anchorName, nodeType)({
601
628
  tr: tr
602
629
  });
603
630
  tr.setMeta('scrollIntoView', false);
@@ -769,7 +796,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
769
796
  };
770
797
  }, [view, anchorName, nodeType, recalculatePosition]);
771
798
  (0, _react.useEffect)(function () {
772
- if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
799
+ if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current) {
773
800
  var id = requestAnimationFrame(function () {
774
801
  var _buttonRef$current2;
775
802
  (_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 || _buttonRef$current2.focus();
@@ -964,20 +991,20 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
964
991
  }
965
992
  }, renderButton());
966
993
  };
967
- var isTooltip = !dragHandleDisabled && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873');
994
+ var isTooltip = !dragHandleDisabled;
968
995
  var stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
969
996
  var render = isTooltip ? buttonWithTooltip() : renderButton();
970
997
  return (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? stickyRender : render;
971
998
  };
972
- var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragHandleWithVisibility(_ref8) {
973
- var view = _ref8.view,
974
- api = _ref8.api,
975
- formatMessage = _ref8.formatMessage,
976
- getPos = _ref8.getPos,
977
- anchorName = _ref8.anchorName,
978
- nodeType = _ref8.nodeType,
979
- handleOptions = _ref8.handleOptions,
980
- anchorRectCache = _ref8.anchorRectCache;
999
+ var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragHandleWithVisibility(_ref9) {
1000
+ var view = _ref9.view,
1001
+ api = _ref9.api,
1002
+ formatMessage = _ref9.formatMessage,
1003
+ getPos = _ref9.getPos,
1004
+ anchorName = _ref9.anchorName,
1005
+ nodeType = _ref9.nodeType,
1006
+ handleOptions = _ref9.handleOptions,
1007
+ anchorRectCache = _ref9.anchorRectCache;
981
1008
  return (0, _react2.jsx)(_visibilityContainer.VisibilityContainer, {
982
1009
  api: api
983
1010
  }, (0, _react2.jsx)(DragHandle, {
@@ -1,5 +1,7 @@
1
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { DIRECTION } from '@atlaskit/editor-common/types';
3
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
3
5
  import { moveNode } from './move-node';
4
6
  import { getCurrentNodePosFromDragHandleSelection, getPosWhenMoveNodeDown, getPosWhenMoveNodeUp, getShouldMoveNode } from './utils/move-node-utils';
5
7
  export const moveNodeWithBlockMenu = (api, direction) => {
@@ -31,6 +33,13 @@ export const moveNodeWithBlockMenu = (api, direction) => {
31
33
  moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.BLOCK_MENU)({
32
34
  tr
33
35
  });
36
+ if (tr.selection.empty && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
37
+ const nodeAtCurrentPos = tr.doc.nodeAt(currentNodePos);
38
+ const nodeAfter = tr.doc.nodeAt(moveToPos);
39
+ const isConsecutiveEmptyLineMove = (nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0;
40
+ const cursorPos = direction === DIRECTION.UP || direction === DIRECTION.DOWN && isConsecutiveEmptyLineMove ? moveToPos : moveToPos - 1;
41
+ tr.setSelection(TextSelection.create(tr.doc, cursorPos));
42
+ }
34
43
  tr.scrollIntoView();
35
44
  }
36
45
  }
@@ -344,7 +344,7 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
344
344
  export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_DROP, formatMessage) => ({
345
345
  tr
346
346
  }) => {
347
- var _api$blockControls$co2;
347
+ var _api$blockControls$co2, _api$accessibilityUti;
348
348
  if (!api || (start < 0 || to < 0) && fg('platform_editor_elements_dnd_multi_select_patch_2')) {
349
349
  return tr;
350
350
  }
@@ -462,9 +462,7 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
462
462
  nodeType: handleNode.type.name,
463
463
  destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
464
464
  destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name,
465
- ...(fg('platform_editor_element_drag_and_drop_ed_23873') && {
466
- inputMethod
467
- }),
465
+ inputMethod,
468
466
  ...(isMultiSelect && {
469
467
  sourceNodeTypes,
470
468
  hasSelectedMultipleNodes
@@ -472,12 +470,9 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
472
470
  }
473
471
  })(tr);
474
472
  }
475
- if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
476
- var _api$accessibilityUti;
477
- const movedMessage = to > sliceFrom ? blockControlsMessages.movedDown : blockControlsMessages.movedup;
478
- api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify(formatMessage ? formatMessage(movedMessage) : movedMessage.defaultMessage, {
479
- priority: 'important'
480
- });
481
- }
473
+ const movedMessage = to > sliceFrom ? blockControlsMessages.movedDown : blockControlsMessages.movedup;
474
+ api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify(formatMessage ? formatMessage(movedMessage) : movedMessage.defaultMessage, {
475
+ priority: 'important'
476
+ });
482
477
  return tr;
483
478
  };
@@ -1,5 +1,6 @@
1
1
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
2
2
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
3
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
3
4
  import { getNestedNodePosition } from '../../pm-plugins/utils/getNestedNodePosition';
4
5
  export const getCurrentNodePosFromDragHandleSelection = ({
5
6
  selection,
@@ -7,6 +8,9 @@ export const getCurrentNodePosFromDragHandleSelection = ({
7
8
  resolve
8
9
  }) => {
9
10
  let currentNodePos = -1;
11
+ if (selection.empty && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
12
+ currentNodePos = selection.$from.pos;
13
+ }
10
14
  if (isTableSelected(selection)) {
11
15
  var _findTable$pos, _findTable;
12
16
  // We only move table node if it's fully selected
@@ -41,6 +45,13 @@ export const getPosWhenMoveNodeDown = ({
41
45
  return -1;
42
46
  }
43
47
  const nodeAfter = tr.doc.nodeAt(nodeAfterPos);
48
+ if (expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
49
+ const nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
50
+ // if move empty line down to another empty line, move to the position of the next empty line
51
+ 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') {
52
+ return nodeAfterPos;
53
+ }
54
+ }
44
55
 
45
56
  // if not the last node, move to the end of the next node
46
57
  return nodeAfter ? nodeAfterPos + nodeAfter.nodeSize : -1;
@@ -1,12 +1,11 @@
1
1
  import { bindKeymapWithCommand, dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, showElementDragHandle } from '@atlaskit/editor-common/keymaps';
2
2
  import { DIRECTION } from '@atlaskit/editor-common/types';
3
3
  import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { moveNodeViaShortcut } from '../editor-commands/move-node';
6
5
  import { showDragHandleAtSelection } from '../editor-commands/show-drag-handle';
7
6
  function keymapList(api, formatMessage) {
8
7
  const keymapList = {};
9
- if (api && fg('platform_editor_element_drag_and_drop_ed_23873')) {
8
+ if (api) {
10
9
  bindKeymapWithCommand(
11
10
  // Ignored via go/ees005
12
11
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -6,7 +6,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
7
7
  import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
8
8
  import { isEmptyDocument } from '@atlaskit/editor-common/utils';
9
- import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
+ import { PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
10
10
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
11
11
  import { fg } from '@atlaskit/platform-feature-flags';
12
12
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
@@ -763,21 +763,6 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
763
763
  return true;
764
764
  }
765
765
  }
766
-
767
- // Command + Shift + ArrowUp to select was broken with the plugin enabled so this manually sets the selection
768
- const {
769
- selection,
770
- doc,
771
- tr
772
- } = view.state;
773
- const metaKey = browser.mac ? event.metaKey : event.ctrlKey;
774
- if (event.key === 'ArrowUp' && event.shiftKey && metaKey) {
775
- if (selection instanceof TextSelection || selection instanceof NodeSelection) {
776
- const newSelection = TextSelection.create(doc, selection.head, 1);
777
- view.dispatch(tr.setSelection(newSelection));
778
- return true;
779
- }
780
- }
781
766
  if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1')) {
782
767
  const isDragHandle = event.target.closest(expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
783
768
  api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
@@ -796,20 +781,6 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
796
781
  }
797
782
  return false;
798
783
  } else {
799
- // Command + Shift + ArrowUp to select was broken with the plugin enabled so this manually sets the selection
800
- const {
801
- selection,
802
- doc,
803
- tr
804
- } = view.state;
805
- const metaKey = browser.mac ? event.metaKey : event.ctrlKey;
806
- if (event.key === 'ArrowUp' && event.shiftKey && metaKey) {
807
- if (selection instanceof TextSelection || selection instanceof NodeSelection) {
808
- const newSelection = TextSelection.create(doc, selection.head, 1);
809
- view.dispatch(tr.setSelection(newSelection));
810
- return true;
811
- }
812
- }
813
784
  if (event.shiftKey && event.ctrlKey) {
814
785
  //prevent holding down key combo from firing repeatedly
815
786
  if (!event.repeat && boundKeydownHandler(api, formatMessage)(view, event)) {
@@ -72,11 +72,28 @@ const newGetSelection = (tr, start) => {
72
72
  const isNodeSelection = node && NodeSelection.isSelectable(node);
73
73
  const nodeSize = node ? node.nodeSize : 1;
74
74
  const nodeName = node === null || node === void 0 ? void 0 : node.type.name;
75
+ const blockMenuEnabled = expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true);
76
+ const blockMenuEmptyLineEnabled = expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true);
75
77
 
76
78
  // this is a fix for empty paragraph selection - put first to avoid any extra work
77
- if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
79
+ if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !blockMenuEnabled) {
78
80
  return false;
79
81
  }
82
+ const isParagraphHeadingEmpty = ['paragraph', 'heading'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0;
83
+ const isBlockQuoteEmpty = nodeName === 'blockquote' && (node === null || node === void 0 ? void 0 : node.textContent) === '';
84
+ const isListEmpty = ['orderedList', 'bulletList', 'taskList'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.textContent) === '';
85
+
86
+ // if block menu and empty line format menu are enabled,
87
+ // we want to set the selection to avoid the selection goes to the top of the document
88
+ if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && blockMenuEnabled && blockMenuEmptyLineEnabled) {
89
+ return TextSelection.create(tr.doc, start + 1, start + 1);
90
+ }
91
+
92
+ // if block menu and empty line format menu are enabled,
93
+ // we want to set the selection to avoid the selection goes to the top of the document
94
+ if (['paragraph', 'heading', 'orderedList', 'bulletList', 'taskList', 'blockquote'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && blockMenuEnabled && blockMenuEmptyLineEnabled) {
95
+ return TextSelection.create(tr.doc, start + 1, start + 1);
96
+ }
80
97
  const isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
81
98
  const isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr, start, nodeSize);
82
99
  if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension || isBlockQuoteWithMediaOrExtension ||
@@ -280,7 +280,7 @@ export const DragHandle = ({
280
280
  isTopLevelNode = true,
281
281
  anchorRectCache
282
282
  }) => {
283
- var _api$core2, _api$blockControls4, _api$analytics2, _api$core4;
283
+ var _api$core2, _api$blockControls4, _api$analytics2, _api$core5, _api$userIntent2;
284
284
  const buttonRef = useRef(null);
285
285
  const [dragHandleSelected, setDragHandleSelected] = useState(false);
286
286
  const [dragHandleDisabled, setDragHandleDisabled] = useState(false);
@@ -396,36 +396,64 @@ export const DragHandle = ({
396
396
  }
397
397
  }, [isLayoutColumn]);
398
398
  const handleKeyDown = useCallback(e => {
399
- if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
400
- // allow user to use spacebar to select the node
401
- if (!e.repeat && e.key === ' ') {
402
- var _api$core3;
403
- const startPos = getPos();
404
- api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
405
- tr
406
- }) => {
407
- if (startPos === undefined) {
408
- return tr;
409
- }
410
- const node = tr.doc.nodeAt(startPos);
411
- if (!node) {
412
- return tr;
413
- }
414
- const $startPos = tr.doc.resolve(startPos + node.nodeSize);
415
- const selection = new TextSelection($startPos);
416
- tr.setSelection(selection);
417
- !isMultiSelect && tr.setMeta(key, {
418
- pos: startPos
419
- });
399
+ // allow user to use spacebar to select the node
400
+ if (!e.repeat && e.key === ' ') {
401
+ var _api$core3;
402
+ const startPos = getPos();
403
+ api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
404
+ tr
405
+ }) => {
406
+ if (startPos === undefined) {
407
+ return tr;
408
+ }
409
+ const node = tr.doc.nodeAt(startPos);
410
+ if (!node) {
420
411
  return tr;
412
+ }
413
+ const $startPos = tr.doc.resolve(startPos + node.nodeSize);
414
+ const selection = new TextSelection($startPos);
415
+ tr.setSelection(selection);
416
+ !isMultiSelect && tr.setMeta(key, {
417
+ pos: startPos
421
418
  });
422
- } else if (![e.altKey, e.ctrlKey, e.shiftKey].some(pressed => pressed)) {
423
- // If not trying to press shortcut keys,
424
- // return focus to editor to resume editing from caret position
425
- view.focus();
419
+ return tr;
420
+ });
421
+ } else if ((e.key === 'Enter' || e.key === ' ') && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true)) {
422
+ var _api$core4;
423
+ if (document.activeElement !== buttonRef.current) {
424
+ return;
426
425
  }
426
+ e.preventDefault();
427
+ e.stopPropagation();
428
+ setDragHandleSelected(!dragHandleSelected);
429
+ api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions.execute(({
430
+ tr
431
+ }) => {
432
+ var _api$blockControls5, _api$userIntent;
433
+ const startPos = getPos();
434
+ if (startPos === undefined) {
435
+ return tr;
436
+ }
437
+ tr = selectNode(tr, startPos, nodeType);
438
+ api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.toggleBlockMenu({
439
+ anchorName
440
+ })({
441
+ tr
442
+ });
443
+ api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen')({
444
+ tr
445
+ });
446
+ api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(true)({
447
+ tr
448
+ });
449
+ return tr;
450
+ });
451
+ } else if (![e.altKey, e.ctrlKey, e.shiftKey].some(pressed => pressed)) {
452
+ // If not trying to press shortcut keys,
453
+ // return focus to editor to resume editing from caret position
454
+ view.focus();
427
455
  }
428
- }, [getPos, api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, isMultiSelect, view]);
456
+ }, [getPos, api === null || api === void 0 ? void 0 : (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions, api === null || api === void 0 ? void 0 : api.blockControls.commands, api === null || api === void 0 ? void 0 : (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands, isMultiSelect, view, anchorName, dragHandleSelected, nodeType]);
429
457
  useEffect(() => {
430
458
  const element = buttonRef.current;
431
459
  if (!element) {
@@ -442,8 +470,8 @@ export const DragHandle = ({
442
470
  }) => {
443
471
  var _api$blockControls$sh2;
444
472
  if (isMultiSelect) {
445
- var _api$core5;
446
- api === null || api === void 0 ? void 0 : (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions.execute(({
473
+ var _api$core6;
474
+ api === null || api === void 0 ? void 0 : (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions.execute(({
447
475
  tr
448
476
  }) => {
449
477
  const handlePos = getPos();
@@ -453,8 +481,8 @@ export const DragHandle = ({
453
481
  const oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
454
482
  const newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
455
483
  if (!tr.selection.empty && (fg('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
456
- var _api$blockControls5;
457
- api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.setMultiSelectPositions()({
484
+ var _api$blockControls6;
485
+ api === null || api === void 0 ? void 0 : (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 ? void 0 : _api$blockControls6.commands.setMultiSelectPositions()({
458
486
  tr
459
487
  });
460
488
  } else if (fg('platform_editor_elements_dnd_select_node_on_drag')) {
@@ -562,14 +590,14 @@ export const DragHandle = ({
562
590
  });
563
591
  },
564
592
  onDragStart() {
565
- var _api$core6;
593
+ var _api$core7;
566
594
  if (start === undefined) {
567
595
  return;
568
596
  }
569
- api === null || api === void 0 ? void 0 : (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions.execute(({
597
+ api === null || api === void 0 ? void 0 : (_api$core7 = api.core) === null || _api$core7 === void 0 ? void 0 : _api$core7.actions.execute(({
570
598
  tr
571
599
  }) => {
572
- var _api$blockControls$sh3, _api$blockControls6, _api$analytics3;
600
+ var _api$blockControls$sh3, _api$blockControls7, _api$analytics3;
573
601
  let nodeTypes, hasSelectedMultipleNodes;
574
602
  const resolvedMovingNode = tr.doc.resolve(start);
575
603
  const maybeNode = resolvedMovingNode.nodeAfter;
@@ -582,7 +610,7 @@ export const DragHandle = ({
582
610
  nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
583
611
  hasSelectedMultipleNodes = false;
584
612
  }
585
- api === null || api === void 0 ? void 0 : (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 ? void 0 : _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
613
+ api === null || api === void 0 ? void 0 : (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 ? void 0 : _api$blockControls7.commands.setNodeDragged(getPos, anchorName, nodeType)({
586
614
  tr
587
615
  });
588
616
  tr.setMeta('scrollIntoView', false);
@@ -759,7 +787,7 @@ export const DragHandle = ({
759
787
  };
760
788
  }, [view, anchorName, nodeType, recalculatePosition]);
761
789
  useEffect(() => {
762
- if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
790
+ if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current) {
763
791
  const id = requestAnimationFrame(() => {
764
792
  var _buttonRef$current2;
765
793
  (_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 ? void 0 : _buttonRef$current2.focus();
@@ -945,7 +973,7 @@ export const DragHandle = ({
945
973
  });
946
974
  }
947
975
  }, renderButton());
948
- const isTooltip = !dragHandleDisabled && fg('platform_editor_element_drag_and_drop_ed_23873');
976
+ const isTooltip = !dragHandleDisabled;
949
977
  const stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
950
978
  const render = isTooltip ? buttonWithTooltip() : renderButton();
951
979
  return editorExperiment('platform_editor_controls', 'variant1') ? stickyRender : render;
@@ -1,5 +1,7 @@
1
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { DIRECTION } from '@atlaskit/editor-common/types';
3
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
3
5
  import { moveNode } from './move-node';
4
6
  import { getCurrentNodePosFromDragHandleSelection, getPosWhenMoveNodeDown, getPosWhenMoveNodeUp, getShouldMoveNode } from './utils/move-node-utils';
5
7
  export var moveNodeWithBlockMenu = function moveNodeWithBlockMenu(api, direction) {
@@ -30,6 +32,13 @@ export var moveNodeWithBlockMenu = function moveNodeWithBlockMenu(api, direction
30
32
  moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.BLOCK_MENU)({
31
33
  tr: tr
32
34
  });
35
+ if (tr.selection.empty && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
36
+ var nodeAtCurrentPos = tr.doc.nodeAt(currentNodePos);
37
+ var nodeAfter = tr.doc.nodeAt(moveToPos);
38
+ var isConsecutiveEmptyLineMove = (nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0;
39
+ var cursorPos = direction === DIRECTION.UP || direction === DIRECTION.DOWN && isConsecutiveEmptyLineMove ? moveToPos : moveToPos - 1;
40
+ tr.setSelection(TextSelection.create(tr.doc, cursorPos));
41
+ }
33
42
  tr.scrollIntoView();
34
43
  }
35
44
  }
@@ -335,7 +335,7 @@ export var moveNode = function moveNode(api) {
335
335
  var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INPUT_METHOD.DRAG_AND_DROP;
336
336
  var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
337
337
  return function (_ref7) {
338
- var _api$blockControls$co;
338
+ var _api$blockControls$co, _api$accessibilityUti;
339
339
  var tr = _ref7.tr;
340
340
  if (!api || (start < 0 || to < 0) && fg('platform_editor_elements_dnd_multi_select_patch_2')) {
341
341
  return tr;
@@ -447,26 +447,22 @@ export var moveNode = function moveNode(api) {
447
447
  action: ACTION.MOVED,
448
448
  actionSubject: ACTION_SUBJECT.ELEMENT,
449
449
  actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
450
- attributes: _objectSpread(_objectSpread({
450
+ attributes: _objectSpread({
451
451
  nodeDepth: $handlePos.depth,
452
452
  nodeType: handleNode.type.name,
453
453
  destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
454
- destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name
455
- }, fg('platform_editor_element_drag_and_drop_ed_23873') && {
454
+ destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name,
456
455
  inputMethod: inputMethod
457
- }), isMultiSelect && {
456
+ }, isMultiSelect && {
458
457
  sourceNodeTypes: sourceNodeTypes,
459
458
  hasSelectedMultipleNodes: hasSelectedMultipleNodes
460
459
  })
461
460
  })(tr);
462
461
  }
463
- if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
464
- var _api$accessibilityUti;
465
- var movedMessage = to > sliceFrom ? blockControlsMessages.movedDown : blockControlsMessages.movedup;
466
- api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 || _api$accessibilityUti.actions.ariaNotify(formatMessage ? formatMessage(movedMessage) : movedMessage.defaultMessage, {
467
- priority: 'important'
468
- });
469
- }
462
+ var movedMessage = to > sliceFrom ? blockControlsMessages.movedDown : blockControlsMessages.movedup;
463
+ api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 || _api$accessibilityUti.actions.ariaNotify(formatMessage ? formatMessage(movedMessage) : movedMessage.defaultMessage, {
464
+ priority: 'important'
465
+ });
470
466
  return tr;
471
467
  };
472
468
  };
@@ -1,11 +1,15 @@
1
1
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
2
2
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
3
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
3
4
  import { getNestedNodePosition } from '../../pm-plugins/utils/getNestedNodePosition';
4
5
  export var getCurrentNodePosFromDragHandleSelection = function getCurrentNodePosFromDragHandleSelection(_ref) {
5
6
  var selection = _ref.selection,
6
7
  schema = _ref.schema,
7
8
  resolve = _ref.resolve;
8
9
  var currentNodePos = -1;
10
+ if (selection.empty && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
11
+ currentNodePos = selection.$from.pos;
12
+ }
9
13
  if (isTableSelected(selection)) {
10
14
  var _findTable$pos, _findTable;
11
15
  // We only move table node if it's fully selected
@@ -39,6 +43,13 @@ export var getPosWhenMoveNodeDown = function getPosWhenMoveNodeDown(_ref2) {
39
43
  return -1;
40
44
  }
41
45
  var nodeAfter = tr.doc.nodeAt(nodeAfterPos);
46
+ if (expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
47
+ var nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
48
+ // if move empty line down to another empty line, move to the position of the next empty line
49
+ 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') {
50
+ return nodeAfterPos;
51
+ }
52
+ }
42
53
 
43
54
  // if not the last node, move to the end of the next node
44
55
  return nodeAfter ? nodeAfterPos + nodeAfter.nodeSize : -1;
@@ -1,12 +1,11 @@
1
1
  import { bindKeymapWithCommand, dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, showElementDragHandle } from '@atlaskit/editor-common/keymaps';
2
2
  import { DIRECTION } from '@atlaskit/editor-common/types';
3
3
  import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { moveNodeViaShortcut } from '../editor-commands/move-node';
6
5
  import { showDragHandleAtSelection } from '../editor-commands/show-drag-handle';
7
6
  function keymapList(api, formatMessage) {
8
7
  var keymapList = {};
9
- if (api && fg('platform_editor_element_drag_and_drop_ed_23873')) {
8
+ if (api) {
10
9
  bindKeymapWithCommand(
11
10
  // Ignored via go/ees005
12
11
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -9,7 +9,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
9
  import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
10
10
  import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
11
11
  import { isEmptyDocument } from '@atlaskit/editor-common/utils';
12
- import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
12
+ import { PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
13
13
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
@@ -753,20 +753,6 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
753
753
  return true;
754
754
  }
755
755
  }
756
-
757
- // Command + Shift + ArrowUp to select was broken with the plugin enabled so this manually sets the selection
758
- var _view$state = view.state,
759
- selection = _view$state.selection,
760
- doc = _view$state.doc,
761
- tr = _view$state.tr;
762
- var metaKey = browser.mac ? event.metaKey : event.ctrlKey;
763
- if (event.key === 'ArrowUp' && event.shiftKey && metaKey) {
764
- if (selection instanceof TextSelection || selection instanceof NodeSelection) {
765
- var newSelection = TextSelection.create(doc, selection.head, 1);
766
- view.dispatch(tr.setSelection(newSelection));
767
- return true;
768
- }
769
- }
770
756
  if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1')) {
771
757
  var isDragHandle = event.target.closest(expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
772
758
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
@@ -784,19 +770,6 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
784
770
  }
785
771
  return false;
786
772
  } else {
787
- // Command + Shift + ArrowUp to select was broken with the plugin enabled so this manually sets the selection
788
- var _view$state2 = view.state,
789
- _selection = _view$state2.selection,
790
- _doc = _view$state2.doc,
791
- _tr = _view$state2.tr;
792
- var _metaKey = browser.mac ? event.metaKey : event.ctrlKey;
793
- if (event.key === 'ArrowUp' && event.shiftKey && _metaKey) {
794
- if (_selection instanceof TextSelection || _selection instanceof NodeSelection) {
795
- var _newSelection = TextSelection.create(_doc, _selection.head, 1);
796
- view.dispatch(_tr.setSelection(_newSelection));
797
- return true;
798
- }
799
- }
800
773
  if (event.shiftKey && event.ctrlKey) {
801
774
  //prevent holding down key combo from firing repeatedly
802
775
  if (!event.repeat && boundKeydownHandler(api, formatMessage)(view, event)) {
@@ -71,11 +71,28 @@ var newGetSelection = function newGetSelection(tr, start) {
71
71
  var isNodeSelection = node && NodeSelection.isSelectable(node);
72
72
  var nodeSize = node ? node.nodeSize : 1;
73
73
  var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
74
+ var blockMenuEnabled = expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true);
75
+ var blockMenuEmptyLineEnabled = expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true);
74
76
 
75
77
  // this is a fix for empty paragraph selection - put first to avoid any extra work
76
- if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
78
+ if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !blockMenuEnabled) {
77
79
  return false;
78
80
  }
81
+ var isParagraphHeadingEmpty = ['paragraph', 'heading'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0;
82
+ var isBlockQuoteEmpty = nodeName === 'blockquote' && (node === null || node === void 0 ? void 0 : node.textContent) === '';
83
+ var isListEmpty = ['orderedList', 'bulletList', 'taskList'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.textContent) === '';
84
+
85
+ // if block menu and empty line format menu are enabled,
86
+ // we want to set the selection to avoid the selection goes to the top of the document
87
+ if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && blockMenuEnabled && blockMenuEmptyLineEnabled) {
88
+ return TextSelection.create(tr.doc, start + 1, start + 1);
89
+ }
90
+
91
+ // if block menu and empty line format menu are enabled,
92
+ // we want to set the selection to avoid the selection goes to the top of the document
93
+ if (['paragraph', 'heading', 'orderedList', 'bulletList', 'taskList', 'blockquote'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && blockMenuEnabled && blockMenuEmptyLineEnabled) {
94
+ return TextSelection.create(tr.doc, start + 1, start + 1);
95
+ }
79
96
  var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
80
97
  var isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr, start, nodeSize);
81
98
  if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension || isBlockQuoteWithMediaOrExtension ||
@@ -272,7 +272,7 @@ var getNodeMargins = function getNodeMargins(node) {
272
272
  return nodeMargins[nodeTypeName] || nodeMargins['default'];
273
273
  };
274
274
  export var DragHandle = function DragHandle(_ref) {
275
- var _api$core2, _api$blockControls4, _api$analytics2, _api$core4;
275
+ var _api$core2, _api$blockControls4, _api$analytics2, _api$core5, _api$userIntent2;
276
276
  var view = _ref.view,
277
277
  api = _ref.api,
278
278
  formatMessage = _ref.formatMessage,
@@ -413,37 +413,64 @@ export var DragHandle = function DragHandle(_ref) {
413
413
  }
414
414
  }, [isLayoutColumn]);
415
415
  var handleKeyDown = useCallback(function (e) {
416
- if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
417
- // allow user to use spacebar to select the node
418
- if (!e.repeat && e.key === ' ') {
419
- var _api$core3;
420
- var startPos = getPos();
421
- api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
422
- var tr = _ref3.tr;
423
- if (startPos === undefined) {
424
- return tr;
425
- }
426
- var node = tr.doc.nodeAt(startPos);
427
- if (!node) {
428
- return tr;
429
- }
430
- var $startPos = tr.doc.resolve(startPos + node.nodeSize);
431
- var selection = new TextSelection($startPos);
432
- tr.setSelection(selection);
433
- !isMultiSelect && tr.setMeta(key, {
434
- pos: startPos
435
- });
416
+ // allow user to use spacebar to select the node
417
+ if (!e.repeat && e.key === ' ') {
418
+ var _api$core3;
419
+ var startPos = getPos();
420
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
421
+ var tr = _ref3.tr;
422
+ if (startPos === undefined) {
436
423
  return tr;
424
+ }
425
+ var node = tr.doc.nodeAt(startPos);
426
+ if (!node) {
427
+ return tr;
428
+ }
429
+ var $startPos = tr.doc.resolve(startPos + node.nodeSize);
430
+ var selection = new TextSelection($startPos);
431
+ tr.setSelection(selection);
432
+ !isMultiSelect && tr.setMeta(key, {
433
+ pos: startPos
437
434
  });
438
- } else if (![e.altKey, e.ctrlKey, e.shiftKey].some(function (pressed) {
439
- return pressed;
440
- })) {
441
- // If not trying to press shortcut keys,
442
- // return focus to editor to resume editing from caret position
443
- view.focus();
435
+ return tr;
436
+ });
437
+ } else if ((e.key === 'Enter' || e.key === ' ') && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true)) {
438
+ var _api$core4;
439
+ if (document.activeElement !== buttonRef.current) {
440
+ return;
444
441
  }
442
+ e.preventDefault();
443
+ e.stopPropagation();
444
+ setDragHandleSelected(!dragHandleSelected);
445
+ api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref4) {
446
+ var _api$blockControls5, _api$userIntent;
447
+ var tr = _ref4.tr;
448
+ var startPos = getPos();
449
+ if (startPos === undefined) {
450
+ return tr;
451
+ }
452
+ tr = selectNode(tr, startPos, nodeType);
453
+ api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.toggleBlockMenu({
454
+ anchorName: anchorName
455
+ })({
456
+ tr: tr
457
+ });
458
+ api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen')({
459
+ tr: tr
460
+ });
461
+ api === null || api === void 0 || api.blockControls.commands.setSelectedViaDragHandle(true)({
462
+ tr: tr
463
+ });
464
+ return tr;
465
+ });
466
+ } else if (![e.altKey, e.ctrlKey, e.shiftKey].some(function (pressed) {
467
+ return pressed;
468
+ })) {
469
+ // If not trying to press shortcut keys,
470
+ // return focus to editor to resume editing from caret position
471
+ view.focus();
445
472
  }
446
- }, [getPos, api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, isMultiSelect, view]);
473
+ }, [getPos, api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions, api === null || api === void 0 ? void 0 : api.blockControls.commands, api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands, isMultiSelect, view, anchorName, dragHandleSelected, nodeType]);
447
474
  useEffect(function () {
448
475
  var element = buttonRef.current;
449
476
  if (!element) {
@@ -457,13 +484,13 @@ export var DragHandle = function DragHandle(_ref) {
457
484
  start: start
458
485
  };
459
486
  },
460
- onGenerateDragPreview: function onGenerateDragPreview(_ref4) {
487
+ onGenerateDragPreview: function onGenerateDragPreview(_ref5) {
461
488
  var _api$blockControls$sh2;
462
- var nativeSetDragImage = _ref4.nativeSetDragImage;
489
+ var nativeSetDragImage = _ref5.nativeSetDragImage;
463
490
  if (isMultiSelect) {
464
- var _api$core5;
465
- api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref5) {
466
- var tr = _ref5.tr;
491
+ var _api$core6;
492
+ api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref6) {
493
+ var tr = _ref6.tr;
467
494
  var handlePos = getPos();
468
495
  if (typeof handlePos !== 'number') {
469
496
  return tr;
@@ -471,8 +498,8 @@ export var DragHandle = function DragHandle(_ref) {
471
498
  var oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
472
499
  var newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
473
500
  if (!tr.selection.empty && (fg('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
474
- var _api$blockControls5;
475
- api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
501
+ var _api$blockControls6;
502
+ api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setMultiSelectPositions()({
476
503
  tr: tr
477
504
  });
478
505
  } else if (fg('platform_editor_elements_dnd_select_node_on_drag')) {
@@ -542,8 +569,8 @@ export var DragHandle = function DragHandle(_ref) {
542
569
  };
543
570
  }
544
571
  },
545
- render: function render(_ref6) {
546
- var container = _ref6.container;
572
+ render: function render(_ref7) {
573
+ var container = _ref7.container;
547
574
  var dom = view.dom.querySelector("[".concat(getAnchorAttrName(), "=\"").concat(anchorName, "\"]"));
548
575
  if (!dom) {
549
576
  return;
@@ -575,13 +602,13 @@ export var DragHandle = function DragHandle(_ref) {
575
602
  });
576
603
  },
577
604
  onDragStart: function onDragStart() {
578
- var _api$core6;
605
+ var _api$core7;
579
606
  if (start === undefined) {
580
607
  return;
581
608
  }
582
- api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref7) {
583
- var _api$blockControls$sh3, _api$blockControls6, _api$analytics3;
584
- var tr = _ref7.tr;
609
+ api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref8) {
610
+ var _api$blockControls$sh3, _api$blockControls7, _api$analytics3;
611
+ var tr = _ref8.tr;
585
612
  var nodeTypes, hasSelectedMultipleNodes;
586
613
  var resolvedMovingNode = tr.doc.resolve(start);
587
614
  var maybeNode = resolvedMovingNode.nodeAfter;
@@ -594,7 +621,7 @@ export var DragHandle = function DragHandle(_ref) {
594
621
  nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
595
622
  hasSelectedMultipleNodes = false;
596
623
  }
597
- api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
624
+ api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 || _api$blockControls7.commands.setNodeDragged(getPos, anchorName, nodeType)({
598
625
  tr: tr
599
626
  });
600
627
  tr.setMeta('scrollIntoView', false);
@@ -766,7 +793,7 @@ export var DragHandle = function DragHandle(_ref) {
766
793
  };
767
794
  }, [view, anchorName, nodeType, recalculatePosition]);
768
795
  useEffect(function () {
769
- if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
796
+ if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current) {
770
797
  var id = requestAnimationFrame(function () {
771
798
  var _buttonRef$current2;
772
799
  (_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 || _buttonRef$current2.focus();
@@ -961,20 +988,20 @@ export var DragHandle = function DragHandle(_ref) {
961
988
  }
962
989
  }, renderButton());
963
990
  };
964
- var isTooltip = !dragHandleDisabled && fg('platform_editor_element_drag_and_drop_ed_23873');
991
+ var isTooltip = !dragHandleDisabled;
965
992
  var stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
966
993
  var render = isTooltip ? buttonWithTooltip() : renderButton();
967
994
  return editorExperiment('platform_editor_controls', 'variant1') ? stickyRender : render;
968
995
  };
969
- export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref8) {
970
- var view = _ref8.view,
971
- api = _ref8.api,
972
- formatMessage = _ref8.formatMessage,
973
- getPos = _ref8.getPos,
974
- anchorName = _ref8.anchorName,
975
- nodeType = _ref8.nodeType,
976
- handleOptions = _ref8.handleOptions,
977
- anchorRectCache = _ref8.anchorRectCache;
996
+ export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref9) {
997
+ var view = _ref9.view,
998
+ api = _ref9.api,
999
+ formatMessage = _ref9.formatMessage,
1000
+ getPos = _ref9.getPos,
1001
+ anchorName = _ref9.anchorName,
1002
+ nodeType = _ref9.nodeType,
1003
+ handleOptions = _ref9.handleOptions,
1004
+ anchorRectCache = _ref9.anchorRectCache;
978
1005
  return jsx(VisibilityContainer, {
979
1006
  api: api
980
1007
  }, jsx(DragHandle, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "6.3.3",
3
+ "version": "6.3.5",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -50,9 +50,9 @@
50
50
  "@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
51
51
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
52
52
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
53
- "@atlaskit/primitives": "^14.14.0",
53
+ "@atlaskit/primitives": "^14.15.0",
54
54
  "@atlaskit/theme": "^21.0.0",
55
- "@atlaskit/tmp-editor-statsig": "^12.25.0",
55
+ "@atlaskit/tmp-editor-statsig": "^12.27.0",
56
56
  "@atlaskit/tokens": "^6.3.0",
57
57
  "@atlaskit/tooltip": "^20.4.0",
58
58
  "@babel/runtime": "^7.0.0",
@@ -64,7 +64,7 @@
64
64
  "uuid": "^3.1.0"
65
65
  },
66
66
  "peerDependencies": {
67
- "@atlaskit/editor-common": "^109.10.0",
67
+ "@atlaskit/editor-common": "^109.11.0",
68
68
  "react": "^18.2.0",
69
69
  "react-dom": "^18.2.0",
70
70
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -108,9 +108,6 @@
108
108
  }
109
109
  },
110
110
  "platform-feature-flags": {
111
- "platform_editor_element_drag_and_drop_ed_23873": {
112
- "type": "boolean"
113
- },
114
111
  "platform_editor_use_nested_table_pm_nodes": {
115
112
  "type": "boolean"
116
113
  },