@atlaskit/editor-plugin-block-controls 11.2.9 → 11.2.11

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 +14 -0
  2. package/dist/cjs/editor-commands/move-node.js +12 -32
  3. package/dist/cjs/editor-commands/move-to-layout.js +59 -127
  4. package/dist/cjs/pm-plugins/decorations-drop-target-active.js +11 -16
  5. package/dist/cjs/pm-plugins/decorations-drop-target.js +13 -24
  6. package/dist/cjs/pm-plugins/main.js +51 -88
  7. package/dist/cjs/pm-plugins/utils/analytics.js +1 -2
  8. package/dist/cjs/pm-plugins/utils/remove-from-source.js +4 -14
  9. package/dist/cjs/ui/drag-handle.js +32 -44
  10. package/dist/es2019/editor-commands/move-node.js +9 -31
  11. package/dist/es2019/editor-commands/move-to-layout.js +61 -121
  12. package/dist/es2019/pm-plugins/decorations-drop-target-active.js +11 -16
  13. package/dist/es2019/pm-plugins/decorations-drop-target.js +13 -24
  14. package/dist/es2019/pm-plugins/main.js +55 -91
  15. package/dist/es2019/pm-plugins/utils/analytics.js +1 -2
  16. package/dist/es2019/pm-plugins/utils/remove-from-source.js +4 -14
  17. package/dist/es2019/ui/drag-handle.js +32 -45
  18. package/dist/esm/editor-commands/move-node.js +13 -33
  19. package/dist/esm/editor-commands/move-to-layout.js +59 -127
  20. package/dist/esm/pm-plugins/decorations-drop-target-active.js +11 -16
  21. package/dist/esm/pm-plugins/decorations-drop-target.js +13 -24
  22. package/dist/esm/pm-plugins/main.js +51 -88
  23. package/dist/esm/pm-plugins/utils/analytics.js +1 -2
  24. package/dist/esm/pm-plugins/utils/remove-from-source.js +4 -14
  25. package/dist/esm/ui/drag-handle.js +32 -44
  26. package/dist/types/pm-plugins/main.d.ts +0 -1
  27. package/dist/types/pm-plugins/utils/analytics.d.ts +2 -2
  28. package/dist/types/pm-plugins/utils/remove-from-source.d.ts +1 -1
  29. package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -1
  30. package/dist/types-ts4.5/pm-plugins/utils/analytics.d.ts +2 -2
  31. package/dist/types-ts4.5/pm-plugins/utils/remove-from-source.d.ts +1 -1
  32. package/editor-plugin-block-controls.docs.tsx +38 -0
  33. package/package.json +4 -3
@@ -115,59 +115,49 @@ var destroyFn = function destroyFn(api, editorView) {
115
115
  return;
116
116
  }
117
117
  (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
118
- var _api$userIntent;
118
+ var _api$blockControls, _api$selection, _api$userIntent;
119
119
  var tr = _ref3.tr;
120
- var isMultiSelect = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true);
121
- if (isMultiSelect) {
122
- var _api$blockControls, _api$selection;
123
- var _ref4 = ((_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
124
- multiSelectDnD = _ref4.multiSelectDnD;
125
- // Restore the users initial Editor selection when the drop completes
126
- if (multiSelectDnD) {
127
- // If the TextSelection between the drag start and end has changed, the document has changed, and we should not reapply the last selection
128
- var expandedSelectionUnchanged = multiSelectDnD.textAnchor === tr.selection.anchor && multiSelectDnD.textHead === tr.selection.head;
129
- if (expandedSelectionUnchanged) {
130
- var $anchor = tr.doc.resolve(multiSelectDnD.userAnchor);
131
- var $head = tr.doc.resolve(multiSelectDnD.userHead);
132
- if ($head.node() === $anchor.node()) {
133
- var $from = $anchor.min($head);
134
- (0, _getSelection.selectNode)(tr, $from.pos, $from.node().type.name, api);
135
- } else {
136
- tr.setSelection(_state.TextSelection.create(tr.doc, multiSelectDnD.userAnchor, multiSelectDnD.userHead));
137
- }
120
+ var _ref4 = ((_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
121
+ multiSelectDnD = _ref4.multiSelectDnD;
122
+ // Restore the users initial Editor selection when the drop completes
123
+ if (multiSelectDnD) {
124
+ // If the TextSelection between the drag start and end has changed, the document has changed, and we should not reapply the last selection
125
+ var expandedSelectionUnchanged = multiSelectDnD.textAnchor === tr.selection.anchor && multiSelectDnD.textHead === tr.selection.head;
126
+ if (expandedSelectionUnchanged) {
127
+ var $anchor = tr.doc.resolve(multiSelectDnD.userAnchor);
128
+ var $head = tr.doc.resolve(multiSelectDnD.userHead);
129
+ if ($head.node() === $anchor.node()) {
130
+ var $from = $anchor.min($head);
131
+ (0, _getSelection.selectNode)(tr, $from.pos, $from.node().type.name, api);
132
+ } else {
133
+ tr.setSelection(_state.TextSelection.create(tr.doc, multiSelectDnD.userAnchor, multiSelectDnD.userHead));
138
134
  }
139
135
  }
140
- (_api$selection = api.selection) === null || _api$selection === void 0 || _api$selection.commands.clearManualSelection()({
141
- tr: tr
142
- });
143
136
  }
137
+ (_api$selection = api.selection) === null || _api$selection === void 0 || _api$selection.commands.clearManualSelection()({
138
+ tr: tr
139
+ });
144
140
  var _ref5 = source.data,
145
141
  start = _ref5.start;
146
142
  // if no drop targets are rendered, assume that drop is invalid
147
143
  var lastDragCancelled = location.current.dropTargets.length === 0;
148
144
  if (lastDragCancelled) {
149
145
  var _api$analytics2;
150
- var nodeTypes, hasSelectedMultipleNodes;
151
- if (isMultiSelect) {
152
- var position = (0, _selection.getSelectedSlicePosition)(start, tr, api);
153
- var attributes = (0, _analytics2.getMultiSelectAnalyticsAttributes)(tr, position.from, position.to);
154
- nodeTypes = attributes.nodeTypes;
146
+ var position = (0, _selection.getSelectedSlicePosition)(start, tr, api);
147
+ var attributes = (0, _analytics2.getMultiSelectAnalyticsAttributes)(tr, position.from, position.to);
148
+ var nodeTypes = attributes.nodeTypes,
155
149
  hasSelectedMultipleNodes = attributes.hasSelectedMultipleNodes;
156
- }
157
150
  var resolvedMovingNode = tr.doc.resolve(start);
158
- var maybeNode = resolvedMovingNode.nodeAfter;
159
151
  (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
160
152
  eventType: _analytics.EVENT_TYPE.UI,
161
153
  action: _analytics.ACTION.CANCELLED,
162
154
  actionSubject: _analytics.ACTION_SUBJECT.DRAG,
163
155
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
164
- attributes: _objectSpread({
156
+ attributes: {
165
157
  nodeDepth: resolvedMovingNode.depth,
166
- nodeType: (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name) || ''
167
- }, isMultiSelect && {
168
- nodeTypes: nodeTypes,
158
+ nodeTypes: nodeTypes || '',
169
159
  hasSelectedMultipleNodes: hasSelectedMultipleNodes
170
- })
160
+ }
171
161
  })(tr);
172
162
  }
173
163
  if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
@@ -337,7 +327,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
337
327
  };
338
328
  }
339
329
  }
340
- if (multiSelectDnD && flags.isMultiSelectEnabled) {
330
+ if (multiSelectDnD) {
341
331
  multiSelectDnD.anchor = tr.mapping.map(multiSelectDnD.anchor);
342
332
  multiSelectDnD.head = tr.mapping.map(multiSelectDnD.head);
343
333
  }
@@ -346,7 +336,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
346
336
  isResizerResizing = resizerMeta !== null && resizerMeta !== void 0 ? resizerMeta : isResizerResizing;
347
337
  var hasJustFinishedResizing = resizerMeta === false;
348
338
  multiSelectDnD = (_meta$multiSelectDnD = meta === null || meta === void 0 ? void 0 : meta.multiSelectDnD) !== null && _meta$multiSelectDnD !== void 0 ? _meta$multiSelectDnD : multiSelectDnD;
349
- if (multiSelectDnD && flags.isMultiSelectEnabled) {
339
+ if (multiSelectDnD) {
350
340
  var _meta$isDragging;
351
341
  if (((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) && (0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
352
342
  // When dragging, we want to keep the multiSelectDnD object unless both document and selection
@@ -795,12 +785,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
795
785
  var isAdvancedLayoutEnabled = (0, _experiments.editorExperiment)('advanced_layouts', true, {
796
786
  exposure: true
797
787
  });
798
- var isMultiSelectEnabled = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true, {
799
- exposure: true
800
- });
801
788
  var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
802
789
  var flags = {
803
- isMultiSelectEnabled: isMultiSelectEnabled,
804
790
  toolbarFlagsEnabled: toolbarFlagsEnabled
805
791
  };
806
792
  var anchorRectCache;
@@ -855,7 +841,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
855
841
  var tr = state.tr;
856
842
  var pluginState = key.getState(state);
857
843
  var dndDragCancelled = (_pluginState = pluginState) === null || _pluginState === void 0 ? void 0 : _pluginState.lastDragCancelled;
858
- if ((_pluginState2 = pluginState) !== null && _pluginState2 !== void 0 && _pluginState2.isPMDragging || dndDragCancelled && isMultiSelectEnabled) {
844
+ if ((_pluginState2 = pluginState) !== null && _pluginState2 !== void 0 && _pluginState2.isPMDragging || dndDragCancelled) {
859
845
  if ((0, _platformFeatureFlags.fg)('platform_editor_ease_of_use_metrics')) {
860
846
  var _api$metrics2;
861
847
  api === null || api === void 0 || (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 || _api$metrics2.commands.startActiveSessionTimer()({
@@ -874,7 +860,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
874
860
  // Currently we can only drag one node at a time
875
861
  // so we only need to check first child
876
862
  var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
877
- if (dndDragCancelled && isMultiSelectEnabled || (draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn') {
863
+ if (dndDragCancelled || (draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn') {
878
864
  // we prevent native DnD for layoutColumn to prevent single column layout.
879
865
  event.preventDefault();
880
866
  return false;
@@ -1001,55 +987,32 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
1001
987
  if (api !== null && api !== void 0 && (_api$limitedMode8 = api.limitedMode) !== null && _api$limitedMode8 !== void 0 && (_api$limitedMode8 = _api$limitedMode8.sharedState.currentState()) !== null && _api$limitedMode8 !== void 0 && _api$limitedMode8.enabled) {
1002
988
  return;
1003
989
  }
1004
- if (isMultiSelectEnabled) {
1005
- if (event.shiftKey && event.ctrlKey) {
1006
- //prevent holding down key combo from firing repeatedly
1007
- if (!event.repeat && (0, _keymap.boundKeydownHandler)(api, formatMessage)(view, event)) {
1008
- event.preventDefault();
1009
- return true;
1010
- }
1011
- }
1012
- if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
1013
- var isDragHandle = event.target.closest((0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? _styles.DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
1014
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
1015
- }
1016
- if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
1017
- var _api$blockControls$sh2, _api$blockControls$sh3;
1018
- 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) && (0, _experiments.editorExperiment)('platform_editor_block_menu', true);
1019
- // when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
1020
- // in this scenario, isSelectedViaDragHandle should not be set to false
1021
- if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
1022
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
1023
- }
990
+ if (event.shiftKey && event.ctrlKey) {
991
+ //prevent holding down key combo from firing repeatedly
992
+ if (!event.repeat && (0, _keymap.boundKeydownHandler)(api, formatMessage)(view, event)) {
993
+ event.preventDefault();
994
+ return true;
1024
995
  }
1025
- if (!event.repeat && event.shiftKey && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
1026
- view.dispatch(view.state.tr.setMeta(key, _objectSpread(_objectSpread({}, view.state.tr.getMeta(key)), {}, {
1027
- isShiftDown: true
1028
- })));
1029
- }
1030
- return false;
1031
- } else {
1032
- if (event.shiftKey && event.ctrlKey) {
1033
- //prevent holding down key combo from firing repeatedly
1034
- if (!event.repeat && (0, _keymap.boundKeydownHandler)(api, formatMessage)(view, event)) {
1035
- event.preventDefault();
1036
- return true;
1037
- }
1038
- }
1039
- if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
1040
- var _isDragHandle = event.target.closest((0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? _styles.DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
1041
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(_isDragHandle));
1042
- }
1043
- if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
1044
- var _api$blockControls$sh4, _api$blockControls$sh5;
1045
- var _isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh4 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh4 === void 0 ? void 0 : _api$blockControls$sh4.isMenuOpen) && (0, _experiments.editorExperiment)('platform_editor_block_menu', true);
1046
- // when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
1047
- // in this scenario, isSelectedViaDragHandle should not be set to false
1048
- if (api !== null && api !== void 0 && (_api$blockControls$sh5 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh5 !== void 0 && _api$blockControls$sh5.isSelectedViaDragHandle && !_isBlockMenuOpen) {
1049
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
1050
- }
996
+ }
997
+ if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
998
+ var isDragHandle = event.target.closest((0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? _styles.DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
999
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
1000
+ }
1001
+ if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
1002
+ var _api$blockControls$sh2, _api$blockControls$sh3;
1003
+ 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) && (0, _experiments.editorExperiment)('platform_editor_block_menu', true);
1004
+ // when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
1005
+ // in this scenario, isSelectedViaDragHandle should not be set to false
1006
+ if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
1007
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
1051
1008
  }
1052
1009
  }
1010
+ if (!event.repeat && event.shiftKey && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
1011
+ view.dispatch(view.state.tr.setMeta(key, _objectSpread(_objectSpread({}, view.state.tr.getMeta(key)), {}, {
1012
+ isShiftDown: true
1013
+ })));
1014
+ }
1015
+ return false;
1053
1016
  },
1054
1017
  keyup: function keyup(view, event) {
1055
1018
  var _api$limitedMode9;
@@ -8,7 +8,7 @@ exports.getMultiSelectAnalyticsAttributes = exports.fireInsertLayoutAnalytics =
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
- var attachMoveNodeAnalytics = exports.attachMoveNodeAnalytics = function attachMoveNodeAnalytics(tr, inputMethod, fromDepth, fromNodeType, toDepth, toNodeType, isSameParent, api, fromNodeTypes, hasSelectedMultipleNodes) {
11
+ var attachMoveNodeAnalytics = exports.attachMoveNodeAnalytics = function attachMoveNodeAnalytics(tr, inputMethod, fromDepth, fromNodeTypes, toDepth, toNodeType, isSameParent, api, hasSelectedMultipleNodes) {
12
12
  var _api$analytics;
13
13
  return api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.attachAnalyticsEvent({
14
14
  eventType: _analytics.EVENT_TYPE.TRACK,
@@ -17,7 +17,6 @@ var attachMoveNodeAnalytics = exports.attachMoveNodeAnalytics = function attachM
17
17
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
18
18
  attributes: {
19
19
  nodeDepth: fromDepth,
20
- nodeType: fromNodeType,
21
20
  nodeTypes: fromNodeTypes,
22
21
  hasSelectedMultipleNodes: hasSelectedMultipleNodes,
23
22
  destinationNodeDepth: toDepth,
@@ -11,18 +11,8 @@ var _checkFragment = require("./check-fragment");
11
11
  var _consts = require("./consts");
12
12
  var _updateColumnWidths = require("./update-column-widths");
13
13
  var removeFromSource = exports.removeFromSource = function removeFromSource(tr, $from, to) {
14
- var _sourceContent, _sourceContent2;
15
- var sourceContent = $from.nodeAfter;
16
- var isLayoutColumn = ((_sourceContent = sourceContent) === null || _sourceContent === void 0 ? void 0 : _sourceContent.type.name) === 'layoutColumn';
17
- var sourceNodeEndPos = $from.pos + (((_sourceContent2 = sourceContent) === null || _sourceContent2 === void 0 ? void 0 : _sourceContent2.nodeSize) || 1);
18
- if ((0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true)) {
19
- sourceContent = tr.doc.slice($from.pos, to).content;
20
- isLayoutColumn = (0, _checkFragment.isFragmentOfType)(sourceContent, 'layoutColumn');
21
- sourceNodeEndPos = to === undefined ? $from.pos + sourceContent.size : to;
22
- }
23
- if (!sourceContent) {
24
- return tr;
25
- }
14
+ var sourceContent = tr.doc.slice($from.pos, to).content;
15
+ var isLayoutColumn = (0, _checkFragment.isFragmentOfType)(sourceContent, 'layoutColumn');
26
16
 
27
17
  /**
28
18
  * This logic is used to handle the case when a user tries to delete a layout column
@@ -35,7 +25,7 @@ var removeFromSource = exports.removeFromSource = function removeFromSource(tr,
35
25
  // Only delete the layout content, but keep the layout column itself
36
26
  // This logic should be remove when we clean up the code for single column layouts.
37
27
  // since this step has no effect on the layout column, because the parent node is removed in the later step.
38
- tr.delete($from.pos + 1, sourceNodeEndPos - 1);
28
+ tr.delete($from.pos + 1, to - 1);
39
29
 
40
30
  // This check should be remove when clean up the code for single column layouts.
41
31
  // since it has been checked in the previous step.
@@ -58,6 +48,6 @@ var removeFromSource = exports.removeFromSource = function removeFromSource(tr,
58
48
  (0, _updateColumnWidths.updateColumnWidths)(tr, $from.parent, $from.before($from.depth), sourceParent.childCount - 1);
59
49
  }
60
50
  }
61
- tr.delete($from.pos, sourceNodeEndPos);
51
+ tr.delete($from.pos, to);
62
52
  return tr;
63
53
  };
@@ -390,7 +390,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
390
390
  interactionState = _useSharedPluginState.interactionState;
391
391
  var start = getPos();
392
392
  var isLayoutColumn = nodeType === 'layoutColumn';
393
- var isMultiSelect = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true);
394
393
 
395
394
  // Dynamically calculate if node is top-level based on current position (gated by experiment)
396
395
  var isTopLevelNodeDynamic = (0, _react.useMemo)(function () {
@@ -474,7 +473,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
474
473
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
475
474
  attributes: {
476
475
  nodeDepth: resolvedStartPos.depth,
477
- nodeType: ((_resolvedStartPos$nod = resolvedStartPos.nodeAfter) === null || _resolvedStartPos$nod === void 0 ? void 0 : _resolvedStartPos$nod.type.name) || ''
476
+ nodeTypes: ((_resolvedStartPos$nod = resolvedStartPos.nodeAfter) === null || _resolvedStartPos$nod === void 0 ? void 0 : _resolvedStartPos$nod.type.name) || ''
478
477
  }
479
478
  })(tr);
480
479
  (0, _expandAndUpdateSelection.expandAndUpdateSelection)({
@@ -506,9 +505,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
506
505
  }, [api, view, getPos, nodeType, anchorName]);
507
506
  var handleOnClick = (0, _react.useCallback)(function (e) {
508
507
  var _api$core2;
509
- if (!isMultiSelect) {
510
- setDragHandleSelected(!dragHandleSelected);
511
- }
512
508
  api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
513
509
  var _api$blockControls$sh, _api$analytics2;
514
510
  var tr = _ref3.tr;
@@ -518,7 +514,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
518
514
  }
519
515
  var mSelect = api === null || api === void 0 || (_api$blockControls$sh = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.multiSelectDnD;
520
516
  var $anchor = (mSelect === null || mSelect === void 0 ? void 0 : mSelect.anchor) !== undefined ? tr.doc.resolve(mSelect === null || mSelect === void 0 ? void 0 : mSelect.anchor) : tr.selection.$anchor;
521
- if (!isMultiSelect || tr.selection.empty || !e.shiftKey) {
517
+ if (tr.selection.empty || !e.shiftKey) {
522
518
  tr = (0, _getSelection.selectNode)(tr, startPos, nodeType, api);
523
519
  } else if (isTopLevelNodeValue && $anchor.depth <= _consts2.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
524
520
  var _api$blockControls3;
@@ -539,13 +535,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
539
535
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
540
536
  attributes: {
541
537
  nodeDepth: resolvedMovingNode.depth,
542
- nodeType: (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name) || ''
538
+ nodeTypes: (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name) || ''
543
539
  }
544
540
  })(tr);
545
541
  return tr;
546
542
  });
547
543
  view.focus();
548
- }, [isMultiSelect, api, view, dragHandleSelected, getPos, isTopLevelNodeValue, nodeType]);
544
+ }, [api, view, getPos, isTopLevelNodeValue, nodeType]);
549
545
  var handleKeyDown = (0, _react.useCallback)(function (e) {
550
546
  // allow user to use spacebar to select the node
551
547
  if (!e.repeat && e.key === ' ') {
@@ -563,9 +559,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
563
559
  var $startPos = tr.doc.resolve(startPos + node.nodeSize);
564
560
  var selection = new _state.TextSelection($startPos);
565
561
  tr.setSelection(selection);
566
- !isMultiSelect && tr.setMeta(_main.key, {
567
- pos: startPos
568
- });
569
562
  return tr;
570
563
  });
571
564
  } else if (![e.altKey, e.ctrlKey, e.shiftKey].some(function (pressed) {
@@ -575,7 +568,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
575
568
  // return focus to editor to resume editing from caret position
576
569
  view.focus();
577
570
  }
578
- }, [getPos, api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, isMultiSelect, view]);
571
+ }, [getPos, api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, view]);
579
572
  var handleKeyDownNew = (0, _react.useCallback)(function (e) {
580
573
  // allow user to use spacebar to select the node
581
574
  if (e.key === 'Enter' || !e.repeat && e.key === ' ') {
@@ -645,28 +638,25 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
645
638
  };
646
639
  },
647
640
  onGenerateDragPreview: function onGenerateDragPreview(_ref6) {
648
- var _api$blockControls$sh2;
641
+ var _api$core6, _api$blockControls$sh2;
649
642
  var nativeSetDragImage = _ref6.nativeSetDragImage;
650
- if (isMultiSelect) {
651
- var _api$core6;
652
- api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref7) {
653
- var tr = _ref7.tr;
654
- var handlePos = getPos();
655
- if (typeof handlePos !== 'number') {
656
- return tr;
657
- }
658
- var newHandlePosCheck = (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos);
659
- if (!tr.selection.empty && newHandlePosCheck) {
660
- var _api$blockControls6;
661
- api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setMultiSelectPositions()({
662
- tr: tr
663
- });
664
- } else {
665
- tr = (0, _getSelection.selectNode)(tr, handlePos, nodeType, api);
666
- }
643
+ api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref7) {
644
+ var tr = _ref7.tr;
645
+ var handlePos = getPos();
646
+ if (typeof handlePos !== 'number') {
667
647
  return tr;
668
- });
669
- }
648
+ }
649
+ var newHandlePosCheck = (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos);
650
+ if (!tr.selection.empty && newHandlePosCheck) {
651
+ var _api$blockControls6;
652
+ api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setMultiSelectPositions()({
653
+ tr: tr
654
+ });
655
+ } else {
656
+ tr = (0, _getSelection.selectNode)(tr, handlePos, nodeType, api);
657
+ }
658
+ return tr;
659
+ });
670
660
  var startPos = getPos();
671
661
  var state = view.state;
672
662
  var doc = state.doc,
@@ -681,7 +671,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
681
671
  sliceTo = Math.max(anchor, head);
682
672
  }
683
673
  var expandedSlice = doc.slice(sliceFrom, sliceTo);
684
- var isDraggingMultiLine = isMultiSelect && startPos !== undefined && startPos >= sliceFrom && startPos < sliceTo && expandedSlice.content.childCount > 1;
674
+ var isDraggingMultiLine = startPos !== undefined && startPos >= sliceFrom && startPos < sliceTo && expandedSlice.content.childCount > 1;
685
675
  (0, _setCustomNativeDragPreview.setCustomNativeDragPreview)({
686
676
  getOffset: function getOffset() {
687
677
  if (!isDraggingMultiLine) {
@@ -789,20 +779,18 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
789
779
  action: _analytics.ACTION.DRAGGED,
790
780
  actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
791
781
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
792
- attributes: _objectSpread({
782
+ attributes: {
793
783
  nodeDepth: resolvedMovingNode.depth,
794
- nodeType: (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name) || ''
795
- }, isMultiSelect && {
796
- nodeTypes: nodeTypes,
784
+ nodeTypes: nodeTypes || '',
797
785
  hasSelectedMultipleNodes: hasSelectedMultipleNodes
798
- })
786
+ }
799
787
  })(tr);
800
788
  return tr;
801
789
  });
802
790
  view.focus();
803
791
  }
804
792
  });
805
- }, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
793
+ }, [anchorName, api, getPos, nodeType, start, view]);
806
794
  var calculatePositionOld = (0, _react.useCallback)(function () {
807
795
  var pos = getPos();
808
796
  var $pos = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
@@ -885,14 +873,14 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
885
873
  }
886
874
  }, [buttonRef, handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused, view]);
887
875
  (0, _react.useEffect)(function () {
888
- if (!isMultiSelect || typeof start !== 'number' || !selection) {
876
+ if (typeof start !== 'number' || !selection) {
889
877
  return;
890
878
  }
891
879
  setDragHandleSelected((0, _getSelection.isHandleCorrelatedToSelection)(view.state, selection, start));
892
- }, [start, selection, view, isMultiSelect]);
880
+ }, [start, selection, view]);
893
881
  (0, _react.useEffect)(function () {
894
882
  var _api$blockControls$sh4;
895
- if (!isMultiSelect || isShiftDown === undefined || view.state.selection.empty || !(0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
883
+ if (isShiftDown === undefined || view.state.selection.empty || !(0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
896
884
  return;
897
885
  }
898
886
  var mSelect = api === null || api === void 0 || (_api$blockControls$sh4 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh4 === void 0 ? void 0 : _api$blockControls$sh4.multiSelectDnD;
@@ -902,7 +890,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
902
890
  } else {
903
891
  setDragHandleDisabled(false);
904
892
  }
905
- }, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isMultiSelect, isShiftDown, isTopLevelNodeValue, view]);
893
+ }, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isShiftDown, isTopLevelNodeValue, view]);
906
894
  var dragHandleMessage = (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? formatMessage(_messages.blockControlsMessages.dragToMoveClickToOpen, {
907
895
  br: (0, _react2.jsx)("br", null)
908
896
  }) : formatMessage(_messages.blockControlsMessages.dragToMove);
@@ -980,7 +968,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
980
968
  return descriptor.keymap ? [descriptor.description, (0, _keymaps.getAriaKeyshortcuts)(descriptor.keymap)] : [descriptor.description];
981
969
  }).join('. ');
982
970
  var handleOnDrop = function handleOnDrop(event) {
983
- (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true) && event.stopPropagation();
971
+ event.stopPropagation();
984
972
  };
985
973
  var hasHadInteraction = interactionState !== 'hasNotHadInteraction';
986
974
  var browser = (0, _browser.getBrowserInfo)();
@@ -15,7 +15,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
15
  import { key } from '../pm-plugins/main';
16
16
  import { attachMoveNodeAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
17
17
  import { getNestedNodePosition } from '../pm-plugins/utils/getNestedNodePosition';
18
- import { selectNode, setCursorPositionAtMovedNode } from '../pm-plugins/utils/getSelection';
18
+ import { setCursorPositionAtMovedNode } from '../pm-plugins/utils/getSelection';
19
19
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
20
20
  import { getSelectedSlicePosition } from '../pm-plugins/utils/selection';
21
21
  import { getInsertLayoutStep, updateSelection } from '../pm-plugins/utils/update-selection';
@@ -124,7 +124,6 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
124
124
  selection
125
125
  } = state;
126
126
  const isParentNodeOfTypeLayout = !!findParentNodeOfType([state.schema.nodes.layoutSection])(state.selection);
127
- const isMultiSelectEnabled = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
128
127
  const expandedSelection = expandSelectionBounds(selection.$anchor, selection.$head);
129
128
  const expandedAnchor = expandedSelection.$anchor.pos;
130
129
  const expandedHead = expandedSelection.$head.pos;
@@ -135,11 +134,11 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
135
134
  const LAYOUT_COL_DEPTH = 3;
136
135
  hoistedPos = state.doc.resolve(from).before(LAYOUT_COL_DEPTH);
137
136
  }
138
- const currentNodePos = isMultiSelectEnabled && !getFocusedHandle(state) && !selection.empty ? (_hoistedPos = hoistedPos) !== null && _hoistedPos !== void 0 ? _hoistedPos : from : getCurrentNodePos(state);
137
+ const currentNodePos = !getFocusedHandle(state) && !selection.empty ? (_hoistedPos = hoistedPos) !== null && _hoistedPos !== void 0 ? _hoistedPos : from : getCurrentNodePos(state);
139
138
  if (currentNodePos > -1) {
140
139
  var _state$doc$nodeAt;
141
140
  const $currentNodePos = state.doc.resolve(currentNodePos);
142
- const nodeAfterPos = isMultiSelectEnabled && !getFocusedHandle(state) ? Math.max(expandedAnchor, expandedHead) : $currentNodePos.posAtIndex($currentNodePos.index() + 1);
141
+ const nodeAfterPos = !getFocusedHandle(state) ? Math.max(expandedAnchor, expandedHead) : $currentNodePos.posAtIndex($currentNodePos.index() + 1);
143
142
  const isTopLevelNode = $currentNodePos.depth === 0;
144
143
  let moveToPos = -1;
145
144
  const isLayoutColumnSelected = selection instanceof NodeSelection && selection.node.type.name === 'layoutColumn';
@@ -284,21 +283,10 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
284
283
  return tr;
285
284
  });
286
285
  return true;
287
- } else if (nodeType && !isMultiSelectEnabled) {
286
+ } else {
288
287
  var _api$core8;
289
- // If the node is first/last one, only select the node
290
288
  api === null || api === void 0 ? void 0 : (_api$core8 = api.core) === null || _api$core8 === void 0 ? void 0 : _api$core8.actions.execute(({
291
289
  tr
292
- }) => {
293
- selectNode(tr, currentNodePos, nodeType, api);
294
- tr.scrollIntoView();
295
- return tr;
296
- });
297
- return true;
298
- } else if (isMultiSelectEnabled) {
299
- var _api$core9;
300
- api === null || api === void 0 ? void 0 : (_api$core9 = api.core) === null || _api$core9 === void 0 ? void 0 : _api$core9.actions.execute(({
301
- tr
302
290
  }) => {
303
291
  api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
304
292
  tr
@@ -326,7 +314,6 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
326
314
  let sliceFrom = start;
327
315
  let sliceTo;
328
316
  let sourceNodeTypes, hasSelectedMultipleNodes;
329
- const isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
330
317
  if (fg('platform_editor_ease_of_use_metrics')) {
331
318
  var _api$metrics;
332
319
  api === null || api === void 0 ? void 0 : (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.setContentMoved()({
@@ -342,17 +329,13 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
342
329
  const attributes = getMultiSelectAnalyticsAttributes(tr, sliceFrom, sliceTo);
343
330
  hasSelectedMultipleNodes = attributes.hasSelectedMultipleNodes;
344
331
  sourceNodeTypes = attributes.nodeTypes;
345
- } else if (isMultiSelect) {
332
+ } else {
346
333
  const slicePosition = getSelectedSlicePosition(start, tr, api);
347
334
  sliceFrom = slicePosition.from;
348
335
  sliceTo = slicePosition.to;
349
336
  const attributes = getMultiSelectAnalyticsAttributes(tr, sliceFrom, sliceTo);
350
337
  hasSelectedMultipleNodes = attributes.hasSelectedMultipleNodes;
351
338
  sourceNodeTypes = attributes.nodeTypes;
352
- } else {
353
- var _handleNode$nodeSize;
354
- const size = (_handleNode$nodeSize = handleNode === null || handleNode === void 0 ? void 0 : handleNode.nodeSize) !== null && _handleNode$nodeSize !== void 0 ? _handleNode$nodeSize : 1;
355
- sliceTo = sliceFrom + size;
356
339
  }
357
340
  const {
358
341
  expand,
@@ -429,13 +412,11 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
429
412
  ...currMeta,
430
413
  preservedSelectionMapping: new Mapping([new StepMap([0, 0, nodeMovedOffset])])
431
414
  });
432
- } else if (isMultiSelect) {
415
+ } else {
433
416
  var _api$blockControls$co2;
434
417
  tr = (_api$blockControls$co2 = api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(mappedTo, mappedTo + sliceSize)({
435
418
  tr
436
419
  })) !== null && _api$blockControls$co2 !== void 0 ? _api$blockControls$co2 : tr;
437
- } else {
438
- tr = selectNode(tr, mappedTo, handleNode.type.name, api);
439
420
  }
440
421
  const currMeta = tr.getMeta(key);
441
422
  tr.setMeta(key, {
@@ -457,7 +438,7 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
457
438
  }
458
439
  }
459
440
  if (editorExperiment('advanced_layouts', true)) {
460
- attachMoveNodeAnalytics(tr, inputMethod, $handlePos.depth, handleNode.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $handlePos.sameParent($mappedTo), api, sourceNodeTypes, hasSelectedMultipleNodes);
441
+ attachMoveNodeAnalytics(tr, inputMethod, $handlePos.depth, sourceNodeTypes, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $handlePos.sameParent($mappedTo), api, hasSelectedMultipleNodes);
461
442
  } else {
462
443
  var _api$analytics;
463
444
  api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
@@ -467,14 +448,11 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
467
448
  actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
468
449
  attributes: {
469
450
  nodeDepth: $handlePos.depth,
470
- nodeType: handleNode.type.name,
451
+ nodeTypes: sourceNodeTypes,
471
452
  destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
472
453
  destinationNodeType: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name,
473
454
  inputMethod,
474
- ...(isMultiSelect && {
475
- sourceNodeTypes,
476
- hasSelectedMultipleNodes
477
- })
455
+ hasSelectedMultipleNodes
478
456
  }
479
457
  })(tr);
480
458
  }