@atlaskit/editor-plugin-block-controls 3.1.4 → 3.1.6

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,26 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 3.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#120473](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/120473)
8
+ [`6d0a06b4b6689`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6d0a06b4b6689) -
9
+ Put DnD shift-select behind FG
10
+ - [#119967](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/119967)
11
+ [`9c072f388dcaa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9c072f388dcaa) -
12
+ Add check for selection before triggering quick insert, and move selection if not within target
13
+ node
14
+
15
+ ## 3.1.5
16
+
17
+ ### Patch Changes
18
+
19
+ - [#119444](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/119444)
20
+ [`853538e68d556`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/853538e68d556) -
21
+ Fix cancelled drag causing layout duplication and locked handle
22
+ - Updated dependencies
23
+
3
24
  ## 3.1.4
4
25
 
5
26
  ### Patch Changes
@@ -142,7 +142,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
142
142
  }
143
143
  },
144
144
  getSharedState: function getSharedState(editorState) {
145
- var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7;
145
+ var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7, _key$getState$lastDra, _key$getState8;
146
146
  if (!editorState) {
147
147
  return undefined;
148
148
  }
@@ -153,7 +153,8 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
153
153
  isDragging: (_key$getState$isDragg = (_key$getState4 = _main.key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false,
154
154
  isPMDragging: (_key$getState$isPMDra = (_key$getState5 = _main.key.getState(editorState)) === null || _key$getState5 === void 0 ? void 0 : _key$getState5.isPMDragging) !== null && _key$getState$isPMDra !== void 0 ? _key$getState$isPMDra : false,
155
155
  multiSelectDnD: (_key$getState$multiSe = (_key$getState6 = _main.key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
156
- isShiftDown: (_key$getState$isShift = (_key$getState7 = _main.key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined
156
+ isShiftDown: (_key$getState$isShift = (_key$getState7 = _main.key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined,
157
+ lastDragCancelled: (_key$getState$lastDra = (_key$getState8 = _main.key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false
157
158
  };
158
159
  },
159
160
  contentComponent: function contentComponent(_ref7) {
@@ -13,11 +13,9 @@ var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _browser = require("@atlaskit/editor-common/browser");
14
14
  var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
15
15
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
16
- var _selection2 = require("@atlaskit/editor-common/selection");
17
16
  var _utils = require("@atlaskit/editor-common/utils");
18
17
  var _state = require("@atlaskit/editor-prosemirror/state");
19
18
  var _view2 = require("@atlaskit/editor-prosemirror/view");
20
- var _editorTables = require("@atlaskit/editor-tables");
21
19
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
20
  var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
23
21
  var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
@@ -32,7 +30,8 @@ var _keymap = require("./keymap");
32
30
  var _activeAnchorTracker = require("./utils/active-anchor-tracker");
33
31
  var _analytics2 = require("./utils/analytics");
34
32
  var _anchorUtils = require("./utils/anchor-utils");
35
- var _selection3 = require("./utils/selection");
33
+ var _getSelection = require("./utils/getSelection");
34
+ var _selection2 = require("./utils/selection");
36
35
  var _transactions = require("./utils/transactions");
37
36
  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; }
38
37
  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; }
@@ -96,7 +95,14 @@ var destroyFn = function destroyFn(api, editorView) {
96
95
  // If the TextSelection between the drag start and end has changed, the document has changed, and we should not reapply the last selection
97
96
  var expandedSelectionUnchanged = multiSelectDnD.textAnchor === tr.selection.anchor && multiSelectDnD.textHead === tr.selection.head;
98
97
  if (expandedSelectionUnchanged) {
99
- tr.setSelection(_state.TextSelection.create(tr.doc, multiSelectDnD.userAnchor, multiSelectDnD.userHead));
98
+ var $anchor = tr.doc.resolve(multiSelectDnD.userAnchor);
99
+ var $head = tr.doc.resolve(multiSelectDnD.userHead);
100
+ if ($head.node() === $anchor.node()) {
101
+ var $from = $anchor.min($head);
102
+ (0, _getSelection.selectNode)(tr, $from.pos, $from.node().type.name);
103
+ } else {
104
+ tr.setSelection(_state.TextSelection.create(tr.doc, multiSelectDnD.userAnchor, multiSelectDnD.userHead));
105
+ }
100
106
  }
101
107
  }
102
108
  api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || _api$selection.commands.clearManualSelection()({
@@ -106,11 +112,12 @@ var destroyFn = function destroyFn(api, editorView) {
106
112
  var _ref5 = source.data,
107
113
  start = _ref5.start;
108
114
  // if no drop targets are rendered, assume that drop is invalid
109
- if (location.current.dropTargets.length === 0) {
115
+ var lastDragCancelled = location.current.dropTargets.length === 0;
116
+ if (lastDragCancelled) {
110
117
  var _api$analytics2;
111
118
  var nodeTypes, hasSelectedMultipleNodes;
112
119
  if (isMultiSelect && api) {
113
- var position = (0, _selection3.getSelectedSlicePosition)(start, tr, api);
120
+ var position = (0, _selection2.getSelectedSlicePosition)(start, tr, api);
114
121
  var attributes = (0, _analytics2.getMultiSelectAnalyticsAttributes)(tr, position.from, position.to);
115
122
  nodeTypes = attributes.nodeTypes;
116
123
  hasSelectedMultipleNodes = attributes.hasSelectedMultipleNodes;
@@ -133,7 +140,8 @@ var destroyFn = function destroyFn(api, editorView) {
133
140
  }
134
141
  return tr.setMeta(key, _objectSpread(_objectSpread({}, tr.getMeta(key)), {}, {
135
142
  isDragging: false,
136
- isPMDragging: false
143
+ isPMDragging: false,
144
+ lastDragCancelled: lastDragCancelled
137
145
  }));
138
146
  });
139
147
  }
@@ -151,14 +159,15 @@ var initialState = {
151
159
  isResizerResizing: false,
152
160
  isDocSizeLimitEnabled: null,
153
161
  isPMDragging: false,
154
- multiSelectDnD: undefined
162
+ multiSelectDnD: undefined,
163
+ lastDragCancelled: false
155
164
  };
156
165
  var getDecorations = exports.getDecorations = function getDecorations(state) {
157
166
  var _key$getState;
158
167
  return (_key$getState = key.getState(state)) === null || _key$getState === void 0 ? void 0 : _key$getState.decorations;
159
168
  };
160
169
  var newApply = exports.newApply = function newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
161
- var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown;
170
+ var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
162
171
  var activeNode = currentState.activeNode,
163
172
  decorations = currentState.decorations,
164
173
  isResizerResizing = currentState.isResizerResizing,
@@ -170,7 +179,8 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
170
179
  isMenuOpen = currentState.isMenuOpen,
171
180
  menuTriggerBy = currentState.menuTriggerBy,
172
181
  isPMDragging = currentState.isPMDragging,
173
- isShiftDown = currentState.isShiftDown;
182
+ isShiftDown = currentState.isShiftDown,
183
+ lastDragCancelled = currentState.lastDragCancelled;
174
184
  var isActiveNodeDeleted = false;
175
185
 
176
186
  // When steps exist, remap existing decorations, activeNode and multi select positions
@@ -326,11 +336,12 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
326
336
  isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
327
337
  isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging,
328
338
  multiSelectDnD: multiSelectDnD,
329
- isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown
339
+ isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown,
340
+ lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled
330
341
  };
331
342
  };
332
343
  var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
333
- var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
344
+ var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2, _meta$lastDragCancell2;
334
345
  var isNestedEnabled = flags.isNestedEnabled;
335
346
  var activeNode = currentState.activeNode,
336
347
  isMenuOpen = currentState.isMenuOpen,
@@ -338,7 +349,8 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
338
349
  editorWidthLeft = currentState.editorWidthLeft,
339
350
  editorWidthRight = currentState.editorWidthRight,
340
351
  isDragging = currentState.isDragging,
341
- isPMDragging = currentState.isPMDragging;
352
+ isPMDragging = currentState.isPMDragging,
353
+ lastDragCancelled = currentState.lastDragCancelled;
342
354
  var decorations = currentState.decorations,
343
355
  isResizerResizing = currentState.isResizerResizing;
344
356
 
@@ -488,7 +500,8 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
488
500
  editorWidthRight: (_meta$editorWidthRigh2 = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh2 !== void 0 ? _meta$editorWidthRigh2 : currentState.editorWidthRight,
489
501
  isResizerResizing: isResizerResizing,
490
502
  isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
491
- isPMDragging: (_meta$isPMDragging2 = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging2 !== void 0 ? _meta$isPMDragging2 : isPMDragging
503
+ isPMDragging: (_meta$isPMDragging2 = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging2 !== void 0 ? _meta$isPMDragging2 : isPMDragging,
504
+ lastDragCancelled: (_meta$lastDragCancell2 = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell2 !== void 0 ? _meta$lastDragCancell2 : lastDragCancelled
492
505
  };
493
506
  };
494
507
  var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI) {
@@ -533,26 +546,28 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
533
546
  },
534
547
  handleDOMEvents: {
535
548
  drop: function drop(view, event) {
536
- var _event$target;
537
- // prosemirror has sends a default transaction on drop (meta where uiEvent is 'drop'),
538
- // this duplicates an empty version of the node it was dropping,
539
- // Adding some check here to prevent that if drop position is within activeNode
540
- var state = view.state,
541
- dispatch = view.dispatch,
542
- dragging = view.dragging;
549
+ var _pluginState, _pluginState2, _pluginState3, _event$target;
550
+ // Prevent native DnD from triggering if we are in drag
551
+ var dispatch = view.dispatch,
552
+ dragging = view.dragging,
553
+ state = view.state;
554
+ var tr = state.tr;
543
555
  var pluginState = key.getState(state);
544
- if (pluginState !== null && pluginState !== void 0 && pluginState.isPMDragging) {
545
- dispatch(state.tr.setMeta(key, _objectSpread(_objectSpread({}, state.tr.getMeta(key)), {}, {
546
- isPMDragging: false
556
+ var dndDragCancelled = (_pluginState = pluginState) === null || _pluginState === void 0 ? void 0 : _pluginState.lastDragCancelled;
557
+ if ((_pluginState2 = pluginState) !== null && _pluginState2 !== void 0 && _pluginState2.isPMDragging || dndDragCancelled && isMultiSelectEnabled) {
558
+ dispatch(tr.setMeta(key, _objectSpread(_objectSpread({}, tr.getMeta(key)), {}, {
559
+ isPMDragging: false,
560
+ lastDragCancelled: false
547
561
  })));
548
562
  }
549
- if (!(event.target instanceof HTMLElement) || !(pluginState !== null && pluginState !== void 0 && pluginState.activeNode)) {
563
+ pluginState = key.getState(view.state);
564
+ if (!(event.target instanceof HTMLElement) || !((_pluginState3 = pluginState) !== null && _pluginState3 !== void 0 && _pluginState3.activeNode)) {
550
565
  return false;
551
566
  }
552
567
  // Currently we can only drag one node at a time
553
568
  // so we only need to check first child
554
569
  var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
555
- if ((draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn' && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
570
+ if (dndDragCancelled && isMultiSelectEnabled || (draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn' && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
556
571
  // we prevent native DnD for layoutColumn to prevent single column layout.
557
572
  event.preventDefault();
558
573
  return false;
@@ -566,26 +581,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
566
581
  var domPos = Math.max(view.posAtDOM(nodeElement, 0) - 1, 0);
567
582
  var nodeTarget = state.doc.nodeAt(domPos);
568
583
  var isSameNode = !!(nodeTarget && draggable !== null && draggable !== void 0 && draggable.eq(nodeTarget));
569
-
570
- // CellSelection doesn't expose true from/to positions, we need to query the ranges
571
- var selectionRange = state.selection instanceof _editorTables.CellSelection ? state.selection.ranges.reduce(function (previousValue, currentValue, _currentIndex, _array) {
572
- return {
573
- $from: currentValue.$from.min(previousValue.$from),
574
- $to: currentValue.$to.max(previousValue.$to)
575
- };
576
- }) : {
577
- $from: state.selection.$from,
578
- $to: state.selection.$to
579
- };
580
- var expandedSelection = (0, _selection2.expandSelectionBounds)(selectionRange.$from, selectionRange.$to);
581
- var expandedAnchor = expandedSelection.$anchor;
582
- var expandedHead = expandedSelection.$head;
583
- var expandedSelectionFrom = Math.min(expandedAnchor.pos, expandedHead.pos);
584
- var expandedSelectionTo = Math.max(expandedAnchor.pos, expandedHead.pos);
585
- var isInExpandedSelection = domPos >= expandedSelectionFrom && domPos < expandedSelectionTo;
586
-
587
- // Prevent the default drop behavior if the position is within the activeNode or within the expanded selection when multiselect is on
588
- if (isSameNode || isInExpandedSelection && isMultiSelectEnabled) {
584
+ if (isSameNode) {
589
585
  event.preventDefault();
590
586
  return true;
591
587
  }
@@ -654,11 +650,10 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
654
650
  return true;
655
651
  }
656
652
  }
657
- if (!event.repeat && event.shiftKey) {
653
+ if (!event.repeat && event.shiftKey && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
658
654
  view.dispatch(view.state.tr.setMeta(key, _objectSpread(_objectSpread({}, view.state.tr.getMeta(key)), {}, {
659
655
  isShiftDown: true
660
656
  })));
661
- return true;
662
657
  }
663
658
  return false;
664
659
  } else {
@@ -199,7 +199,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
199
199
  });
200
200
  e.stopPropagation();
201
201
  }
202
- } else if (isTopLevelNode && $anchor.depth <= _consts.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey) {
202
+ } else if (isTopLevelNode && $anchor.depth <= _consts.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
203
203
  var _api$blockControls2;
204
204
  var alignAnchorHeadToSel = (0, _selection.alignAnchorHeadInDirectionOfPos)(tr.selection, startPos);
205
205
  var selectionWithExpandedHead = (0, _selection.expandSelectionHeadToNodeAtPos)(alignAnchorHeadToSel, startPos);
@@ -529,7 +529,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
529
529
  setDragHandleSelected((0, _getSelection.isHandleCorrelatedToSelection)(view.state, selection, start));
530
530
  }, [start, selection, view.state, isMultiSelect]);
531
531
  (0, _react.useEffect)(function () {
532
- if (!isMultiSelect || isShiftDown === undefined || view.state.selection.empty) {
532
+ if (!isMultiSelect || isShiftDown === undefined || view.state.selection.empty || !(0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
533
533
  return;
534
534
  }
535
535
  var $anchor = (multiSelectDnD === null || multiSelectDnD === void 0 ? void 0 : multiSelectDnD.anchor) !== undefined ? view.state.doc.resolve(multiSelectDnD === null || multiSelectDnD === void 0 ? void 0 : multiSelectDnD.anchor) : view.state.selection.$anchor;
@@ -155,6 +155,18 @@ var topLevelNodeMarginStyles = (0, _react.css)({
155
155
  }
156
156
  }
157
157
  });
158
+
159
+ // when quick insert is rendered there are 2 widgets before the first block node
160
+ var topLevelNodeMarginWithQuickInsertStyles = (0, _react.css)({
161
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
162
+ '.ProseMirror': {
163
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
164
+ '> .ProseMirror-widget:nth-child(-n + 2) + .ProseMirror-gapcursor + *:not([data-layout-section="true"]), > .ProseMirror-widget:nth-child(-n + 2) + *:not([data-layout-section="true"])': {
165
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
166
+ marginTop: '0 !important'
167
+ }
168
+ }
169
+ });
158
170
  var withDividerInPanelStyleFix = (0, _react.css)((0, _defineProperty2.default)({}, "".concat(dividerBodiedInCustomPanelWithNoIconSelector), {
159
171
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
160
172
  marginTop: '0 !important'
@@ -216,6 +228,6 @@ var blockCardWithoutLayout = (0, _react.css)({
216
228
  });
217
229
  var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
218
230
  return (0, _react.jsx)(_react.Global, {
219
- styles: [globalStyles(), (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
231
+ styles: [globalStyles(), (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? topLevelNodeMarginWithQuickInsertStyles : topLevelNodeMarginStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
220
232
  });
221
233
  };
@@ -30,7 +30,7 @@ var buttonStyles = (0, _primitives.xcss)({
30
30
  height: "var(--ds-space-300, 24px)",
31
31
  width: "var(--ds-space-300, 24px)",
32
32
  border: 'none',
33
- backgroundColor: 'color.background.neutral',
33
+ backgroundColor: 'color.background.neutral.subtle',
34
34
  borderRadius: '50%',
35
35
  color: 'color.text.accent.gray',
36
36
  zIndex: 'card',
@@ -52,6 +52,18 @@ var containerStaticStyles = (0, _primitives.xcss)({
52
52
 
53
53
  // TODO: Share prop types between DragHandle - generic enough to create a type for block control decoration
54
54
 
55
+ var isSelectionInNode = function isSelectionInNode(start, view) {
56
+ var node = view.state.doc.nodeAt(start);
57
+ if (node === null) {
58
+ return false;
59
+ }
60
+ var endPos = start + node.nodeSize;
61
+ var startPos = start;
62
+ var _view$state$selection = view.state.selection,
63
+ $from = _view$state$selection.$from,
64
+ $to = _view$state$selection.$to;
65
+ return $from.pos >= startPos && endPos >= $to.pos;
66
+ };
55
67
  var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref) {
56
68
  var view = _ref.view,
57
69
  api = _ref.api,
@@ -62,7 +74,9 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
62
74
  rootAnchorName = _ref.rootAnchorName,
63
75
  rootNodeType = _ref.rootNodeType;
64
76
  var macroInteractionUpdates = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'featureFlags.macroInteractionUpdates');
65
- var _useState = (0, _react.useState)({}),
77
+ var _useState = (0, _react.useState)({
78
+ display: 'none'
79
+ }),
66
80
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
67
81
  positionStyles = _useState2[0],
68
82
  setPositionStyles = _useState2[1];
@@ -145,15 +159,23 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
145
159
  "aria-label": formatMessage(_messages.blockControlsMessages.insert),
146
160
  xcss: [buttonStyles],
147
161
  onClick: function onClick() {
148
- var _api$core, _api$quickInsert;
149
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
150
- var tr = _ref2.tr;
151
- var start = getPos();
152
- if (!start) {
153
- return null;
154
- }
155
- return tr.setSelection(_state.TextSelection.create(tr.doc, start));
156
- });
162
+ var _api$quickInsert;
163
+ // if the selection is not within the node this decoration is rendered at
164
+ // then insert a newline and trigger quick insert
165
+ var start = getPos();
166
+ if (start !== undefined && !isSelectionInNode(start, view)) {
167
+ api.core.actions.execute(function (_ref2) {
168
+ var _tr$doc$nodeAt;
169
+ var tr = _ref2.tr;
170
+ var nodeSize = (_tr$doc$nodeAt = tr.doc.nodeAt(start)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.nodeSize;
171
+ if (nodeSize === undefined) {
172
+ return tr;
173
+ }
174
+ var position = start + nodeSize;
175
+ tr.insert(position, tr.doc.type.schema.nodes.paragraph.create());
176
+ return tr.setSelection(_state.TextSelection.create(tr.doc, position));
177
+ });
178
+ }
157
179
  api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
158
180
  }
159
181
  }, /*#__PURE__*/_react.default.createElement(_add.default, {
@@ -133,7 +133,7 @@ export const blockControlsPlugin = ({
133
133
  }
134
134
  },
135
135
  getSharedState(editorState) {
136
- var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7;
136
+ var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7, _key$getState$lastDra, _key$getState8;
137
137
  if (!editorState) {
138
138
  return undefined;
139
139
  }
@@ -144,7 +144,8 @@ export const blockControlsPlugin = ({
144
144
  isDragging: (_key$getState$isDragg = (_key$getState4 = key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false,
145
145
  isPMDragging: (_key$getState$isPMDra = (_key$getState5 = key.getState(editorState)) === null || _key$getState5 === void 0 ? void 0 : _key$getState5.isPMDragging) !== null && _key$getState$isPMDra !== void 0 ? _key$getState$isPMDra : false,
146
146
  multiSelectDnD: (_key$getState$multiSe = (_key$getState6 = key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
147
- isShiftDown: (_key$getState$isShift = (_key$getState7 = key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined
147
+ isShiftDown: (_key$getState$isShift = (_key$getState7 = key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined,
148
+ lastDragCancelled: (_key$getState$lastDra = (_key$getState8 = key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false
148
149
  };
149
150
  },
150
151
  contentComponent({
@@ -4,11 +4,9 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
4
4
  import { browser } from '@atlaskit/editor-common/browser';
5
5
  import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
- import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
8
7
  import { isEmptyDocument, isTextInput } from '@atlaskit/editor-common/utils';
9
8
  import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
10
9
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
11
- import { CellSelection } from '@atlaskit/editor-tables';
12
10
  import { fg } from '@atlaskit/platform-feature-flags';
13
11
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
14
12
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
@@ -23,6 +21,7 @@ import { boundKeydownHandler } from './keymap';
23
21
  import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
24
22
  import { getMultiSelectAnalyticsAttributes } from './utils/analytics';
25
23
  import { AnchorRectCache, isAnchorSupported } from './utils/anchor-utils';
24
+ import { selectNode } from './utils/getSelection';
26
25
  import { getSelectedSlicePosition } from './utils/selection';
27
26
  import { getTrMetadata } from './utils/transactions';
28
27
  export const key = new PluginKey('blockControls');
@@ -89,7 +88,14 @@ const destroyFn = (api, editorView) => {
89
88
  // If the TextSelection between the drag start and end has changed, the document has changed, and we should not reapply the last selection
90
89
  const expandedSelectionUnchanged = multiSelectDnD.textAnchor === tr.selection.anchor && multiSelectDnD.textHead === tr.selection.head;
91
90
  if (expandedSelectionUnchanged) {
92
- tr.setSelection(TextSelection.create(tr.doc, multiSelectDnD.userAnchor, multiSelectDnD.userHead));
91
+ const $anchor = tr.doc.resolve(multiSelectDnD.userAnchor);
92
+ const $head = tr.doc.resolve(multiSelectDnD.userHead);
93
+ if ($head.node() === $anchor.node()) {
94
+ const $from = $anchor.min($head);
95
+ selectNode(tr, $from.pos, $from.node().type.name);
96
+ } else {
97
+ tr.setSelection(TextSelection.create(tr.doc, multiSelectDnD.userAnchor, multiSelectDnD.userHead));
98
+ }
93
99
  }
94
100
  }
95
101
  api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.commands.clearManualSelection()({
@@ -100,7 +106,8 @@ const destroyFn = (api, editorView) => {
100
106
  start
101
107
  } = source.data;
102
108
  // if no drop targets are rendered, assume that drop is invalid
103
- if (location.current.dropTargets.length === 0) {
109
+ const lastDragCancelled = location.current.dropTargets.length === 0;
110
+ if (lastDragCancelled) {
104
111
  var _api$analytics2;
105
112
  let nodeTypes, hasSelectedMultipleNodes;
106
113
  if (isMultiSelect && api) {
@@ -129,7 +136,8 @@ const destroyFn = (api, editorView) => {
129
136
  return tr.setMeta(key, {
130
137
  ...tr.getMeta(key),
131
138
  isDragging: false,
132
- isPMDragging: false
139
+ isPMDragging: false,
140
+ lastDragCancelled
133
141
  });
134
142
  });
135
143
  }
@@ -147,14 +155,15 @@ const initialState = {
147
155
  isResizerResizing: false,
148
156
  isDocSizeLimitEnabled: null,
149
157
  isPMDragging: false,
150
- multiSelectDnD: undefined
158
+ multiSelectDnD: undefined,
159
+ lastDragCancelled: false
151
160
  };
152
161
  export const getDecorations = state => {
153
162
  var _key$getState;
154
163
  return (_key$getState = key.getState(state)) === null || _key$getState === void 0 ? void 0 : _key$getState.decorations;
155
164
  };
156
165
  export const newApply = (api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) => {
157
- var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown;
166
+ var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
158
167
  let {
159
168
  activeNode,
160
169
  decorations,
@@ -169,7 +178,8 @@ export const newApply = (api, formatMessage, tr, currentState, newState, flags,
169
178
  isMenuOpen,
170
179
  menuTriggerBy,
171
180
  isPMDragging,
172
- isShiftDown
181
+ isShiftDown,
182
+ lastDragCancelled
173
183
  } = currentState;
174
184
  let isActiveNodeDeleted = false;
175
185
 
@@ -325,11 +335,12 @@ export const newApply = (api, formatMessage, tr, currentState, newState, flags,
325
335
  isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
326
336
  isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging,
327
337
  multiSelectDnD,
328
- isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown
338
+ isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown,
339
+ lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled
329
340
  };
330
341
  };
331
342
  export const oldApply = (api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) => {
332
- var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
343
+ var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2, _meta$lastDragCancell2;
333
344
  const {
334
345
  isNestedEnabled
335
346
  } = flags;
@@ -340,7 +351,8 @@ export const oldApply = (api, formatMessage, tr, currentState, oldState, newStat
340
351
  editorWidthLeft,
341
352
  editorWidthRight,
342
353
  isDragging,
343
- isPMDragging
354
+ isPMDragging,
355
+ lastDragCancelled
344
356
  } = currentState;
345
357
  let {
346
358
  decorations,
@@ -468,7 +480,8 @@ export const oldApply = (api, formatMessage, tr, currentState, oldState, newStat
468
480
  editorWidthRight: (_meta$editorWidthRigh2 = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh2 !== void 0 ? _meta$editorWidthRigh2 : currentState.editorWidthRight,
469
481
  isResizerResizing: isResizerResizing,
470
482
  isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
471
- isPMDragging: (_meta$isPMDragging2 = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging2 !== void 0 ? _meta$isPMDragging2 : isPMDragging
483
+ isPMDragging: (_meta$isPMDragging2 = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging2 !== void 0 ? _meta$isPMDragging2 : isPMDragging,
484
+ lastDragCancelled: (_meta$lastDragCancell2 = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell2 !== void 0 ? _meta$lastDragCancell2 : lastDragCancelled
472
485
  };
473
486
  };
474
487
  export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
@@ -514,29 +527,31 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
514
527
  },
515
528
  handleDOMEvents: {
516
529
  drop(view, event) {
517
- var _event$target;
518
- // prosemirror has sends a default transaction on drop (meta where uiEvent is 'drop'),
519
- // this duplicates an empty version of the node it was dropping,
520
- // Adding some check here to prevent that if drop position is within activeNode
530
+ var _pluginState, _pluginState2, _pluginState3, _event$target;
531
+ // Prevent native DnD from triggering if we are in drag
521
532
  const {
522
- state,
523
533
  dispatch,
524
- dragging
534
+ dragging,
535
+ state
525
536
  } = view;
526
- const pluginState = key.getState(state);
527
- if (pluginState !== null && pluginState !== void 0 && pluginState.isPMDragging) {
528
- dispatch(state.tr.setMeta(key, {
529
- ...state.tr.getMeta(key),
530
- isPMDragging: false
537
+ const tr = state.tr;
538
+ let pluginState = key.getState(state);
539
+ const dndDragCancelled = (_pluginState = pluginState) === null || _pluginState === void 0 ? void 0 : _pluginState.lastDragCancelled;
540
+ if ((_pluginState2 = pluginState) !== null && _pluginState2 !== void 0 && _pluginState2.isPMDragging || dndDragCancelled && isMultiSelectEnabled) {
541
+ dispatch(tr.setMeta(key, {
542
+ ...tr.getMeta(key),
543
+ isPMDragging: false,
544
+ lastDragCancelled: false
531
545
  }));
532
546
  }
533
- if (!(event.target instanceof HTMLElement) || !(pluginState !== null && pluginState !== void 0 && pluginState.activeNode)) {
547
+ pluginState = key.getState(view.state);
548
+ if (!(event.target instanceof HTMLElement) || !((_pluginState3 = pluginState) !== null && _pluginState3 !== void 0 && _pluginState3.activeNode)) {
534
549
  return false;
535
550
  }
536
551
  // Currently we can only drag one node at a time
537
552
  // so we only need to check first child
538
553
  const draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
539
- if ((draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn' && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
554
+ if (dndDragCancelled && isMultiSelectEnabled || (draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn' && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
540
555
  // we prevent native DnD for layoutColumn to prevent single column layout.
541
556
  event.preventDefault();
542
557
  return false;
@@ -550,26 +565,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
550
565
  const domPos = Math.max(view.posAtDOM(nodeElement, 0) - 1, 0);
551
566
  const nodeTarget = state.doc.nodeAt(domPos);
552
567
  const isSameNode = !!(nodeTarget && draggable !== null && draggable !== void 0 && draggable.eq(nodeTarget));
553
-
554
- // CellSelection doesn't expose true from/to positions, we need to query the ranges
555
- const selectionRange = state.selection instanceof CellSelection ? state.selection.ranges.reduce((previousValue, currentValue, _currentIndex, _array) => {
556
- return {
557
- $from: currentValue.$from.min(previousValue.$from),
558
- $to: currentValue.$to.max(previousValue.$to)
559
- };
560
- }) : {
561
- $from: state.selection.$from,
562
- $to: state.selection.$to
563
- };
564
- const expandedSelection = expandSelectionBounds(selectionRange.$from, selectionRange.$to);
565
- const expandedAnchor = expandedSelection.$anchor;
566
- const expandedHead = expandedSelection.$head;
567
- const expandedSelectionFrom = Math.min(expandedAnchor.pos, expandedHead.pos);
568
- const expandedSelectionTo = Math.max(expandedAnchor.pos, expandedHead.pos);
569
- const isInExpandedSelection = domPos >= expandedSelectionFrom && domPos < expandedSelectionTo;
570
-
571
- // Prevent the default drop behavior if the position is within the activeNode or within the expanded selection when multiselect is on
572
- if (isSameNode || isInExpandedSelection && isMultiSelectEnabled) {
568
+ if (isSameNode) {
573
569
  event.preventDefault();
574
570
  return true;
575
571
  }
@@ -643,12 +639,11 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
643
639
  return true;
644
640
  }
645
641
  }
646
- if (!event.repeat && event.shiftKey) {
642
+ if (!event.repeat && event.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
647
643
  view.dispatch(view.state.tr.setMeta(key, {
648
644
  ...view.state.tr.getMeta(key),
649
645
  isShiftDown: true
650
646
  }));
651
- return true;
652
647
  }
653
648
  return false;
654
649
  } else {
@@ -180,7 +180,7 @@ export const DragHandle = ({
180
180
  });
181
181
  e.stopPropagation();
182
182
  }
183
- } else if (isTopLevelNode && $anchor.depth <= DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey) {
183
+ } else if (isTopLevelNode && $anchor.depth <= DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
184
184
  var _api$blockControls2;
185
185
  const alignAnchorHeadToSel = alignAnchorHeadInDirectionOfPos(tr.selection, startPos);
186
186
  const selectionWithExpandedHead = expandSelectionHeadToNodeAtPos(alignAnchorHeadToSel, startPos);
@@ -513,7 +513,7 @@ export const DragHandle = ({
513
513
  setDragHandleSelected(isHandleCorrelatedToSelection(view.state, selection, start));
514
514
  }, [start, selection, view.state, isMultiSelect]);
515
515
  useEffect(() => {
516
- if (!isMultiSelect || isShiftDown === undefined || view.state.selection.empty) {
516
+ if (!isMultiSelect || isShiftDown === undefined || view.state.selection.empty || !fg('platform_editor_elements_dnd_shift_click_select')) {
517
517
  return;
518
518
  }
519
519
  const $anchor = (multiSelectDnD === null || multiSelectDnD === void 0 ? void 0 : multiSelectDnD.anchor) !== undefined ? view.state.doc.resolve(multiSelectDnD === null || multiSelectDnD === void 0 ? void 0 : multiSelectDnD.anchor) : view.state.selection.$anchor;
@@ -178,6 +178,18 @@ const topLevelNodeMarginStyles = css({
178
178
  }
179
179
  }
180
180
  });
181
+
182
+ // when quick insert is rendered there are 2 widgets before the first block node
183
+ const topLevelNodeMarginWithQuickInsertStyles = css({
184
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
185
+ '.ProseMirror': {
186
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
187
+ '> .ProseMirror-widget:nth-child(-n + 2) + .ProseMirror-gapcursor + *:not([data-layout-section="true"]), > .ProseMirror-widget:nth-child(-n + 2) + *:not([data-layout-section="true"])': {
188
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
189
+ marginTop: '0 !important'
190
+ }
191
+ }
192
+ });
181
193
  const withDividerInPanelStyleFix = css({
182
194
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
183
195
  [`${dividerBodiedInCustomPanelWithNoIconSelector}`]: {
@@ -260,6 +272,6 @@ const blockCardWithoutLayout = css({
260
272
  });
261
273
  export const GlobalStylesWrapper = () => {
262
274
  return jsx(Global, {
263
- styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
275
+ styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, editorExperiment('platform_editor_controls', 'variant1') ? topLevelNodeMarginWithQuickInsertStyles : topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
264
276
  });
265
277
  };
@@ -19,7 +19,7 @@ const buttonStyles = xcss({
19
19
  height: "var(--ds-space-300, 24px)",
20
20
  width: "var(--ds-space-300, 24px)",
21
21
  border: 'none',
22
- backgroundColor: 'color.background.neutral',
22
+ backgroundColor: 'color.background.neutral.subtle',
23
23
  borderRadius: '50%',
24
24
  color: 'color.text.accent.gray',
25
25
  zIndex: 'card',
@@ -41,6 +41,19 @@ const containerStaticStyles = xcss({
41
41
 
42
42
  // TODO: Share prop types between DragHandle - generic enough to create a type for block control decoration
43
43
 
44
+ const isSelectionInNode = (start, view) => {
45
+ const node = view.state.doc.nodeAt(start);
46
+ if (node === null) {
47
+ return false;
48
+ }
49
+ const endPos = start + node.nodeSize;
50
+ const startPos = start;
51
+ const {
52
+ $from,
53
+ $to
54
+ } = view.state.selection;
55
+ return $from.pos >= startPos && endPos >= $to.pos;
56
+ };
44
57
  export const TypeAheadControl = ({
45
58
  view,
46
59
  api,
@@ -52,7 +65,9 @@ export const TypeAheadControl = ({
52
65
  rootNodeType
53
66
  }) => {
54
67
  const macroInteractionUpdates = useSharedPluginStateSelector(api, 'featureFlags.macroInteractionUpdates');
55
- const [positionStyles, setPositionStyles] = useState({});
68
+ const [positionStyles, setPositionStyles] = useState({
69
+ display: 'none'
70
+ });
56
71
 
57
72
  // Adapted from `src/ui/drag-handle.tsx` as positioning logic is similar
58
73
  // CHANGES - added an offset so quick insert button can be positioned beside drag handle
@@ -132,16 +147,24 @@ export const TypeAheadControl = ({
132
147
  "aria-label": formatMessage(messages.insert),
133
148
  xcss: [buttonStyles],
134
149
  onClick: () => {
135
- var _api$core, _api$quickInsert;
136
- api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
137
- tr
138
- }) => {
139
- const start = getPos();
140
- if (!start) {
141
- return null;
142
- }
143
- return tr.setSelection(TextSelection.create(tr.doc, start));
144
- });
150
+ var _api$quickInsert;
151
+ // if the selection is not within the node this decoration is rendered at
152
+ // then insert a newline and trigger quick insert
153
+ const start = getPos();
154
+ if (start !== undefined && !isSelectionInNode(start, view)) {
155
+ api.core.actions.execute(({
156
+ tr
157
+ }) => {
158
+ var _tr$doc$nodeAt;
159
+ const nodeSize = (_tr$doc$nodeAt = tr.doc.nodeAt(start)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.nodeSize;
160
+ if (nodeSize === undefined) {
161
+ return tr;
162
+ }
163
+ const position = start + nodeSize;
164
+ tr.insert(position, tr.doc.type.schema.nodes.paragraph.create());
165
+ return tr.setSelection(TextSelection.create(tr.doc, position));
166
+ });
167
+ }
145
168
  api === null || api === void 0 ? void 0 : (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.actions.openTypeAhead('blockControl');
146
169
  }
147
170
  }, /*#__PURE__*/React.createElement(EditorAddIcon, {
@@ -135,7 +135,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
135
135
  }
136
136
  },
137
137
  getSharedState: function getSharedState(editorState) {
138
- var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7;
138
+ var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7, _key$getState$lastDra, _key$getState8;
139
139
  if (!editorState) {
140
140
  return undefined;
141
141
  }
@@ -146,7 +146,8 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
146
146
  isDragging: (_key$getState$isDragg = (_key$getState4 = key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false,
147
147
  isPMDragging: (_key$getState$isPMDra = (_key$getState5 = key.getState(editorState)) === null || _key$getState5 === void 0 ? void 0 : _key$getState5.isPMDragging) !== null && _key$getState$isPMDra !== void 0 ? _key$getState$isPMDra : false,
148
148
  multiSelectDnD: (_key$getState$multiSe = (_key$getState6 = key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
149
- isShiftDown: (_key$getState$isShift = (_key$getState7 = key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined
149
+ isShiftDown: (_key$getState$isShift = (_key$getState7 = key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined,
150
+ lastDragCancelled: (_key$getState$lastDra = (_key$getState8 = key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false
150
151
  };
151
152
  },
152
153
  contentComponent: function contentComponent(_ref7) {
@@ -8,11 +8,9 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
8
8
  import { browser } from '@atlaskit/editor-common/browser';
9
9
  import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
10
10
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
11
- import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
12
11
  import { isEmptyDocument, isTextInput } from '@atlaskit/editor-common/utils';
13
12
  import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
14
13
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
15
- import { CellSelection } from '@atlaskit/editor-tables';
16
14
  import { fg } from '@atlaskit/platform-feature-flags';
17
15
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
18
16
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
@@ -27,6 +25,7 @@ import { boundKeydownHandler } from './keymap';
27
25
  import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
28
26
  import { getMultiSelectAnalyticsAttributes } from './utils/analytics';
29
27
  import { AnchorRectCache, isAnchorSupported } from './utils/anchor-utils';
28
+ import { selectNode } from './utils/getSelection';
30
29
  import { getSelectedSlicePosition } from './utils/selection';
31
30
  import { getTrMetadata } from './utils/transactions';
32
31
  export var key = new PluginKey('blockControls');
@@ -89,7 +88,14 @@ var destroyFn = function destroyFn(api, editorView) {
89
88
  // If the TextSelection between the drag start and end has changed, the document has changed, and we should not reapply the last selection
90
89
  var expandedSelectionUnchanged = multiSelectDnD.textAnchor === tr.selection.anchor && multiSelectDnD.textHead === tr.selection.head;
91
90
  if (expandedSelectionUnchanged) {
92
- tr.setSelection(TextSelection.create(tr.doc, multiSelectDnD.userAnchor, multiSelectDnD.userHead));
91
+ var $anchor = tr.doc.resolve(multiSelectDnD.userAnchor);
92
+ var $head = tr.doc.resolve(multiSelectDnD.userHead);
93
+ if ($head.node() === $anchor.node()) {
94
+ var $from = $anchor.min($head);
95
+ selectNode(tr, $from.pos, $from.node().type.name);
96
+ } else {
97
+ tr.setSelection(TextSelection.create(tr.doc, multiSelectDnD.userAnchor, multiSelectDnD.userHead));
98
+ }
93
99
  }
94
100
  }
95
101
  api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || _api$selection.commands.clearManualSelection()({
@@ -99,7 +105,8 @@ var destroyFn = function destroyFn(api, editorView) {
99
105
  var _ref5 = source.data,
100
106
  start = _ref5.start;
101
107
  // if no drop targets are rendered, assume that drop is invalid
102
- if (location.current.dropTargets.length === 0) {
108
+ var lastDragCancelled = location.current.dropTargets.length === 0;
109
+ if (lastDragCancelled) {
103
110
  var _api$analytics2;
104
111
  var nodeTypes, hasSelectedMultipleNodes;
105
112
  if (isMultiSelect && api) {
@@ -126,7 +133,8 @@ var destroyFn = function destroyFn(api, editorView) {
126
133
  }
127
134
  return tr.setMeta(key, _objectSpread(_objectSpread({}, tr.getMeta(key)), {}, {
128
135
  isDragging: false,
129
- isPMDragging: false
136
+ isPMDragging: false,
137
+ lastDragCancelled: lastDragCancelled
130
138
  }));
131
139
  });
132
140
  }
@@ -144,14 +152,15 @@ var initialState = {
144
152
  isResizerResizing: false,
145
153
  isDocSizeLimitEnabled: null,
146
154
  isPMDragging: false,
147
- multiSelectDnD: undefined
155
+ multiSelectDnD: undefined,
156
+ lastDragCancelled: false
148
157
  };
149
158
  export var getDecorations = function getDecorations(state) {
150
159
  var _key$getState;
151
160
  return (_key$getState = key.getState(state)) === null || _key$getState === void 0 ? void 0 : _key$getState.decorations;
152
161
  };
153
162
  export var newApply = function newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
154
- var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown;
163
+ var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
155
164
  var activeNode = currentState.activeNode,
156
165
  decorations = currentState.decorations,
157
166
  isResizerResizing = currentState.isResizerResizing,
@@ -163,7 +172,8 @@ export var newApply = function newApply(api, formatMessage, tr, currentState, ne
163
172
  isMenuOpen = currentState.isMenuOpen,
164
173
  menuTriggerBy = currentState.menuTriggerBy,
165
174
  isPMDragging = currentState.isPMDragging,
166
- isShiftDown = currentState.isShiftDown;
175
+ isShiftDown = currentState.isShiftDown,
176
+ lastDragCancelled = currentState.lastDragCancelled;
167
177
  var isActiveNodeDeleted = false;
168
178
 
169
179
  // When steps exist, remap existing decorations, activeNode and multi select positions
@@ -319,11 +329,12 @@ export var newApply = function newApply(api, formatMessage, tr, currentState, ne
319
329
  isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
320
330
  isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging,
321
331
  multiSelectDnD: multiSelectDnD,
322
- isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown
332
+ isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown,
333
+ lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled
323
334
  };
324
335
  };
325
336
  export var oldApply = function oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
326
- var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
337
+ var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2, _meta$lastDragCancell2;
327
338
  var isNestedEnabled = flags.isNestedEnabled;
328
339
  var activeNode = currentState.activeNode,
329
340
  isMenuOpen = currentState.isMenuOpen,
@@ -331,7 +342,8 @@ export var oldApply = function oldApply(api, formatMessage, tr, currentState, ol
331
342
  editorWidthLeft = currentState.editorWidthLeft,
332
343
  editorWidthRight = currentState.editorWidthRight,
333
344
  isDragging = currentState.isDragging,
334
- isPMDragging = currentState.isPMDragging;
345
+ isPMDragging = currentState.isPMDragging,
346
+ lastDragCancelled = currentState.lastDragCancelled;
335
347
  var decorations = currentState.decorations,
336
348
  isResizerResizing = currentState.isResizerResizing;
337
349
 
@@ -481,7 +493,8 @@ export var oldApply = function oldApply(api, formatMessage, tr, currentState, ol
481
493
  editorWidthRight: (_meta$editorWidthRigh2 = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh2 !== void 0 ? _meta$editorWidthRigh2 : currentState.editorWidthRight,
482
494
  isResizerResizing: isResizerResizing,
483
495
  isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
484
- isPMDragging: (_meta$isPMDragging2 = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging2 !== void 0 ? _meta$isPMDragging2 : isPMDragging
496
+ isPMDragging: (_meta$isPMDragging2 = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging2 !== void 0 ? _meta$isPMDragging2 : isPMDragging,
497
+ lastDragCancelled: (_meta$lastDragCancell2 = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell2 !== void 0 ? _meta$lastDragCancell2 : lastDragCancelled
485
498
  };
486
499
  };
487
500
  export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI) {
@@ -526,26 +539,28 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
526
539
  },
527
540
  handleDOMEvents: {
528
541
  drop: function drop(view, event) {
529
- var _event$target;
530
- // prosemirror has sends a default transaction on drop (meta where uiEvent is 'drop'),
531
- // this duplicates an empty version of the node it was dropping,
532
- // Adding some check here to prevent that if drop position is within activeNode
533
- var state = view.state,
534
- dispatch = view.dispatch,
535
- dragging = view.dragging;
542
+ var _pluginState, _pluginState2, _pluginState3, _event$target;
543
+ // Prevent native DnD from triggering if we are in drag
544
+ var dispatch = view.dispatch,
545
+ dragging = view.dragging,
546
+ state = view.state;
547
+ var tr = state.tr;
536
548
  var pluginState = key.getState(state);
537
- if (pluginState !== null && pluginState !== void 0 && pluginState.isPMDragging) {
538
- dispatch(state.tr.setMeta(key, _objectSpread(_objectSpread({}, state.tr.getMeta(key)), {}, {
539
- isPMDragging: false
549
+ var dndDragCancelled = (_pluginState = pluginState) === null || _pluginState === void 0 ? void 0 : _pluginState.lastDragCancelled;
550
+ if ((_pluginState2 = pluginState) !== null && _pluginState2 !== void 0 && _pluginState2.isPMDragging || dndDragCancelled && isMultiSelectEnabled) {
551
+ dispatch(tr.setMeta(key, _objectSpread(_objectSpread({}, tr.getMeta(key)), {}, {
552
+ isPMDragging: false,
553
+ lastDragCancelled: false
540
554
  })));
541
555
  }
542
- if (!(event.target instanceof HTMLElement) || !(pluginState !== null && pluginState !== void 0 && pluginState.activeNode)) {
556
+ pluginState = key.getState(view.state);
557
+ if (!(event.target instanceof HTMLElement) || !((_pluginState3 = pluginState) !== null && _pluginState3 !== void 0 && _pluginState3.activeNode)) {
543
558
  return false;
544
559
  }
545
560
  // Currently we can only drag one node at a time
546
561
  // so we only need to check first child
547
562
  var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
548
- if ((draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn' && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
563
+ if (dndDragCancelled && isMultiSelectEnabled || (draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn' && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
549
564
  // we prevent native DnD for layoutColumn to prevent single column layout.
550
565
  event.preventDefault();
551
566
  return false;
@@ -559,26 +574,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
559
574
  var domPos = Math.max(view.posAtDOM(nodeElement, 0) - 1, 0);
560
575
  var nodeTarget = state.doc.nodeAt(domPos);
561
576
  var isSameNode = !!(nodeTarget && draggable !== null && draggable !== void 0 && draggable.eq(nodeTarget));
562
-
563
- // CellSelection doesn't expose true from/to positions, we need to query the ranges
564
- var selectionRange = state.selection instanceof CellSelection ? state.selection.ranges.reduce(function (previousValue, currentValue, _currentIndex, _array) {
565
- return {
566
- $from: currentValue.$from.min(previousValue.$from),
567
- $to: currentValue.$to.max(previousValue.$to)
568
- };
569
- }) : {
570
- $from: state.selection.$from,
571
- $to: state.selection.$to
572
- };
573
- var expandedSelection = expandSelectionBounds(selectionRange.$from, selectionRange.$to);
574
- var expandedAnchor = expandedSelection.$anchor;
575
- var expandedHead = expandedSelection.$head;
576
- var expandedSelectionFrom = Math.min(expandedAnchor.pos, expandedHead.pos);
577
- var expandedSelectionTo = Math.max(expandedAnchor.pos, expandedHead.pos);
578
- var isInExpandedSelection = domPos >= expandedSelectionFrom && domPos < expandedSelectionTo;
579
-
580
- // Prevent the default drop behavior if the position is within the activeNode or within the expanded selection when multiselect is on
581
- if (isSameNode || isInExpandedSelection && isMultiSelectEnabled) {
577
+ if (isSameNode) {
582
578
  event.preventDefault();
583
579
  return true;
584
580
  }
@@ -647,11 +643,10 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
647
643
  return true;
648
644
  }
649
645
  }
650
- if (!event.repeat && event.shiftKey) {
646
+ if (!event.repeat && event.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
651
647
  view.dispatch(view.state.tr.setMeta(key, _objectSpread(_objectSpread({}, view.state.tr.getMeta(key)), {}, {
652
648
  isShiftDown: true
653
649
  })));
654
- return true;
655
650
  }
656
651
  return false;
657
652
  } else {
@@ -194,7 +194,7 @@ export var DragHandle = function DragHandle(_ref) {
194
194
  });
195
195
  e.stopPropagation();
196
196
  }
197
- } else if (isTopLevelNode && $anchor.depth <= DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey) {
197
+ } else if (isTopLevelNode && $anchor.depth <= DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
198
198
  var _api$blockControls2;
199
199
  var alignAnchorHeadToSel = alignAnchorHeadInDirectionOfPos(tr.selection, startPos);
200
200
  var selectionWithExpandedHead = expandSelectionHeadToNodeAtPos(alignAnchorHeadToSel, startPos);
@@ -524,7 +524,7 @@ export var DragHandle = function DragHandle(_ref) {
524
524
  setDragHandleSelected(isHandleCorrelatedToSelection(view.state, selection, start));
525
525
  }, [start, selection, view.state, isMultiSelect]);
526
526
  useEffect(function () {
527
- if (!isMultiSelect || isShiftDown === undefined || view.state.selection.empty) {
527
+ if (!isMultiSelect || isShiftDown === undefined || view.state.selection.empty || !fg('platform_editor_elements_dnd_shift_click_select')) {
528
528
  return;
529
529
  }
530
530
  var $anchor = (multiSelectDnD === null || multiSelectDnD === void 0 ? void 0 : multiSelectDnD.anchor) !== undefined ? view.state.doc.resolve(multiSelectDnD === null || multiSelectDnD === void 0 ? void 0 : multiSelectDnD.anchor) : view.state.selection.$anchor;
@@ -148,6 +148,18 @@ var topLevelNodeMarginStyles = css({
148
148
  }
149
149
  }
150
150
  });
151
+
152
+ // when quick insert is rendered there are 2 widgets before the first block node
153
+ var topLevelNodeMarginWithQuickInsertStyles = css({
154
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
155
+ '.ProseMirror': {
156
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
157
+ '> .ProseMirror-widget:nth-child(-n + 2) + .ProseMirror-gapcursor + *:not([data-layout-section="true"]), > .ProseMirror-widget:nth-child(-n + 2) + *:not([data-layout-section="true"])': {
158
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
159
+ marginTop: '0 !important'
160
+ }
161
+ }
162
+ });
151
163
  var withDividerInPanelStyleFix = css(_defineProperty({}, "".concat(dividerBodiedInCustomPanelWithNoIconSelector), {
152
164
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
153
165
  marginTop: '0 !important'
@@ -209,6 +221,6 @@ var blockCardWithoutLayout = css({
209
221
  });
210
222
  export var GlobalStylesWrapper = function GlobalStylesWrapper() {
211
223
  return jsx(Global, {
212
- styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
224
+ styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, editorExperiment('platform_editor_controls', 'variant1') ? topLevelNodeMarginWithQuickInsertStyles : topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
213
225
  });
214
226
  };
@@ -20,7 +20,7 @@ var buttonStyles = xcss({
20
20
  height: "var(--ds-space-300, 24px)",
21
21
  width: "var(--ds-space-300, 24px)",
22
22
  border: 'none',
23
- backgroundColor: 'color.background.neutral',
23
+ backgroundColor: 'color.background.neutral.subtle',
24
24
  borderRadius: '50%',
25
25
  color: 'color.text.accent.gray',
26
26
  zIndex: 'card',
@@ -42,6 +42,18 @@ var containerStaticStyles = xcss({
42
42
 
43
43
  // TODO: Share prop types between DragHandle - generic enough to create a type for block control decoration
44
44
 
45
+ var isSelectionInNode = function isSelectionInNode(start, view) {
46
+ var node = view.state.doc.nodeAt(start);
47
+ if (node === null) {
48
+ return false;
49
+ }
50
+ var endPos = start + node.nodeSize;
51
+ var startPos = start;
52
+ var _view$state$selection = view.state.selection,
53
+ $from = _view$state$selection.$from,
54
+ $to = _view$state$selection.$to;
55
+ return $from.pos >= startPos && endPos >= $to.pos;
56
+ };
45
57
  export var TypeAheadControl = function TypeAheadControl(_ref) {
46
58
  var view = _ref.view,
47
59
  api = _ref.api,
@@ -52,7 +64,9 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
52
64
  rootAnchorName = _ref.rootAnchorName,
53
65
  rootNodeType = _ref.rootNodeType;
54
66
  var macroInteractionUpdates = useSharedPluginStateSelector(api, 'featureFlags.macroInteractionUpdates');
55
- var _useState = useState({}),
67
+ var _useState = useState({
68
+ display: 'none'
69
+ }),
56
70
  _useState2 = _slicedToArray(_useState, 2),
57
71
  positionStyles = _useState2[0],
58
72
  setPositionStyles = _useState2[1];
@@ -135,15 +149,23 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
135
149
  "aria-label": formatMessage(messages.insert),
136
150
  xcss: [buttonStyles],
137
151
  onClick: function onClick() {
138
- var _api$core, _api$quickInsert;
139
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
140
- var tr = _ref2.tr;
141
- var start = getPos();
142
- if (!start) {
143
- return null;
144
- }
145
- return tr.setSelection(TextSelection.create(tr.doc, start));
146
- });
152
+ var _api$quickInsert;
153
+ // if the selection is not within the node this decoration is rendered at
154
+ // then insert a newline and trigger quick insert
155
+ var start = getPos();
156
+ if (start !== undefined && !isSelectionInNode(start, view)) {
157
+ api.core.actions.execute(function (_ref2) {
158
+ var _tr$doc$nodeAt;
159
+ var tr = _ref2.tr;
160
+ var nodeSize = (_tr$doc$nodeAt = tr.doc.nodeAt(start)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.nodeSize;
161
+ if (nodeSize === undefined) {
162
+ return tr;
163
+ }
164
+ var position = start + nodeSize;
165
+ tr.insert(position, tr.doc.type.schema.nodes.paragraph.create());
166
+ return tr.setSelection(TextSelection.create(tr.doc, position));
167
+ });
168
+ }
147
169
  api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
148
170
  }
149
171
  }, /*#__PURE__*/React.createElement(EditorAddIcon, {
@@ -47,6 +47,7 @@ export interface PluginState {
47
47
  isPMDragging: boolean;
48
48
  multiSelectDnD?: MultiSelectDnD;
49
49
  isShiftDown?: boolean;
50
+ lastDragCancelled: boolean;
50
51
  }
51
52
  export type ReleaseHiddenDecoration = () => boolean | undefined;
52
53
  export type BlockControlsSharedState = {
@@ -27,6 +27,7 @@ export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> |
27
27
  isPMDragging: any;
28
28
  multiSelectDnD: import("../blockControlsPluginType").MultiSelectDnD | undefined;
29
29
  isShiftDown: any;
30
+ lastDragCancelled: any;
30
31
  };
31
32
  export declare const oldApply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, oldState: EditorState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
32
33
  decorations: DecorationSet;
@@ -39,5 +40,6 @@ export declare const oldApply: (api: ExtractInjectionAPI<BlockControlsPlugin> |
39
40
  isResizerResizing: boolean;
40
41
  isDocSizeLimitEnabled: boolean | null;
41
42
  isPMDragging: any;
43
+ lastDragCancelled: any;
42
44
  };
43
45
  export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI) => SafePlugin<PluginState>;
@@ -47,6 +47,7 @@ export interface PluginState {
47
47
  isPMDragging: boolean;
48
48
  multiSelectDnD?: MultiSelectDnD;
49
49
  isShiftDown?: boolean;
50
+ lastDragCancelled: boolean;
50
51
  }
51
52
  export type ReleaseHiddenDecoration = () => boolean | undefined;
52
53
  export type BlockControlsSharedState = {
@@ -27,6 +27,7 @@ export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> |
27
27
  isPMDragging: any;
28
28
  multiSelectDnD: import("../blockControlsPluginType").MultiSelectDnD | undefined;
29
29
  isShiftDown: any;
30
+ lastDragCancelled: any;
30
31
  };
31
32
  export declare const oldApply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, oldState: EditorState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
32
33
  decorations: DecorationSet;
@@ -39,5 +40,6 @@ export declare const oldApply: (api: ExtractInjectionAPI<BlockControlsPlugin> |
39
40
  isResizerResizing: boolean;
40
41
  isDocSizeLimitEnabled: boolean | null;
41
42
  isPMDragging: any;
43
+ lastDragCancelled: any;
42
44
  };
43
45
  export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI) => SafePlugin<PluginState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -40,7 +40,7 @@
40
40
  "@atlaskit/editor-plugin-selection": "^2.0.0",
41
41
  "@atlaskit/editor-plugin-width": "^3.0.0",
42
42
  "@atlaskit/editor-prosemirror": "7.0.0",
43
- "@atlaskit/editor-shared-styles": "^3.3.0",
43
+ "@atlaskit/editor-shared-styles": "^3.4.0",
44
44
  "@atlaskit/editor-tables": "^2.9.0",
45
45
  "@atlaskit/icon": "^24.1.0",
46
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^2.0.0",
50
50
  "@atlaskit/primitives": "^14.1.0",
51
51
  "@atlaskit/theme": "^17.0.0",
52
- "@atlaskit/tmp-editor-statsig": "^3.2.0",
52
+ "@atlaskit/tmp-editor-statsig": "^3.3.0",
53
53
  "@atlaskit/tokens": "^4.2.0",
54
54
  "@atlaskit/tooltip": "^20.0.0",
55
55
  "@babel/runtime": "^7.0.0",
@@ -151,6 +151,9 @@
151
151
  },
152
152
  "platform_editor_disable_drag_handle_nested_tables": {
153
153
  "type": "boolean"
154
+ },
155
+ "platform_editor_elements_dnd_shift_click_select": {
156
+ "type": "boolean"
154
157
  }
155
158
  }
156
159
  }