@atlaskit/editor-plugin-block-controls 7.7.0 → 7.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 7.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a05464ea42678`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a05464ea42678) -
8
+ EDITOR-2791 bump adf-schema
9
+ - Updated dependencies
10
+
11
+ ## 7.7.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`27d4ba93d0702`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/27d4ba93d0702) -
16
+ EDITOR-3201 disable layout drop targets for sync blocks
17
+
3
18
  ## 7.7.0
4
19
 
5
20
  ### Minor Changes
@@ -24,6 +24,7 @@ var PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK = [].concat(PARENT_WITH_END_DROP_TARG
24
24
  * List of node types that does not allow drop targets at before or after the node.
25
25
  */
26
26
  var NODE_WITH_NO_PARENT_POS = ['tableCell', 'tableHeader', 'layoutColumn'];
27
+ var UNSUPPORTED_LAYOUT_CONTENT = ['syncBlock', 'bodiedSyncBlock'];
27
28
  var isContainerNode = function isContainerNode(node) {
28
29
  if ((0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true)) {
29
30
  return PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK.includes(node.type.name);
@@ -212,7 +213,8 @@ var getActiveDropTargetDecorations = exports.getActiveDropTargetDecorations = fu
212
213
  }
213
214
  if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
214
215
  var _isSameLayout = $activeNodePos && (0, _validation.isInSameLayout)($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
215
- if (rootNodeWithPos.node.type.name === 'layoutSection') {
216
+ var hasUnsupportedContent = UNSUPPORTED_LAYOUT_CONTENT.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') && (0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true);
217
+ if (rootNodeWithPos.node.type.name === 'layoutSection' && !hasUnsupportedContent) {
216
218
  var layoutSectionNode = rootNodeWithPos.node;
217
219
  if (layoutSectionNode.childCount < (0, _consts.maxLayoutColumnSupported)() || _isSameLayout) {
218
220
  layoutSectionNode.descendants(function (childNode, childPos, parent, index) {
@@ -771,8 +771,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
771
771
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
772
772
  }
773
773
  if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
774
- var _api$blockControls$sh2;
775
- if (api !== null && api !== void 0 && (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh2 !== void 0 && _api$blockControls$sh2.isSelectedViaDragHandle) {
774
+ var _api$blockControls$sh2, _api$blockControls$sh3;
775
+ 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, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
776
+ // when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
777
+ // in this scenario, isSelectedViaDragHandle should not be set to false
778
+ if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
776
779
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
777
780
  }
778
781
  }
@@ -795,8 +798,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
795
798
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(_isDragHandle));
796
799
  }
797
800
  if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
798
- var _api$blockControls$sh3;
799
- if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle) {
801
+ var _api$blockControls$sh4, _api$blockControls$sh5;
802
+ 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, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
803
+ // when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
804
+ // in this scenario, isSelectedViaDragHandle should not be set to false
805
+ if (api !== null && api !== void 0 && (_api$blockControls$sh5 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh5 !== void 0 && _api$blockControls$sh5.isSelectedViaDragHandle && !_isBlockMenuOpen) {
800
806
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
801
807
  }
802
808
  }
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.shouldAllowInlineDropTarget = void 0;
7
7
  var _utils = require("@atlaskit/editor-common/utils");
8
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
8
9
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
9
10
  var _checkMediaLayout = require("./check-media-layout");
10
11
  var _consts = require("./consts");
12
+ var syncedBlockTypes = ['syncBlock', 'bodiedSyncBlock'];
11
13
  var shouldAllowInlineDropTarget = exports.shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(isNested, node) {
12
14
  var isSameLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
13
15
  var activeNode = arguments.length > 3 ? arguments[3] : undefined;
@@ -20,6 +22,9 @@ var shouldAllowInlineDropTarget = exports.shouldAllowInlineDropTarget = function
20
22
  if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
21
23
  return false;
22
24
  }
25
+ if ((syncedBlockTypes.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') || syncedBlockTypes.includes((node === null || node === void 0 ? void 0 : node.type.name) || '')) && (0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true)) {
26
+ return false;
27
+ }
23
28
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
24
29
  return node.childCount < (0, _consts.maxLayoutColumnSupported)() || isSameLayout;
25
30
  }
@@ -16,6 +16,7 @@ var _browser = require("@atlaskit/editor-common/browser");
16
16
  var _hooks = require("@atlaskit/editor-common/hooks");
17
17
  var _keymaps = require("@atlaskit/editor-common/keymaps");
18
18
  var _messages = require("@atlaskit/editor-common/messages");
19
+ var _selection2 = require("@atlaskit/editor-common/selection");
19
20
  var _styles = require("@atlaskit/editor-common/styles");
20
21
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
21
22
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -36,7 +37,7 @@ var _main = require("../pm-plugins/main");
36
37
  var _analytics2 = require("../pm-plugins/utils/analytics");
37
38
  var _dragHandlePositions = require("../pm-plugins/utils/drag-handle-positions");
38
39
  var _getSelection = require("../pm-plugins/utils/getSelection");
39
- var _selection2 = require("../pm-plugins/utils/selection");
40
+ var _selection3 = require("../pm-plugins/utils/selection");
40
41
  var _consts2 = require("./consts");
41
42
  var _dragPreview = require("./drag-preview");
42
43
  var _anchorName = require("./utils/anchor-name");
@@ -425,8 +426,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
425
426
  }
426
427
  } else if (isTopLevelNode && $anchor.depth <= _consts2.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
427
428
  var _api$blockControls3;
428
- var alignAnchorHeadToSel = (0, _selection2.alignAnchorHeadInDirectionOfPos)(tr.selection, startPos);
429
- var selectionWithExpandedHead = (0, _selection2.expandSelectionHeadToNodeAtPos)(alignAnchorHeadToSel, startPos);
429
+ var alignAnchorHeadToSel = (0, _selection3.alignAnchorHeadInDirectionOfPos)(tr.selection, startPos);
430
+ var selectionWithExpandedHead = (0, _selection3.expandSelectionHeadToNodeAtPos)(alignAnchorHeadToSel, startPos);
430
431
  tr.setSelection(selectionWithExpandedHead);
431
432
  api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.setMultiSelectPositions()({
432
433
  tr: tr
@@ -517,6 +518,20 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
517
518
  });
518
519
  return tr;
519
520
  });
521
+ } else if (e.key === 'Backspace' || e.key === 'Delete') {
522
+ e.preventDefault();
523
+ e.stopPropagation();
524
+ api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
525
+ var _api$blockControls5;
526
+ var tr = _ref5.tr;
527
+ (0, _selection2.deleteSelectedRange)(tr);
528
+ api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.toggleBlockMenu({
529
+ closeMenu: true
530
+ })({
531
+ tr: tr
532
+ });
533
+ return tr;
534
+ });
520
535
  } else if (![e.altKey, e.ctrlKey, e.shiftKey].some(function (pressed) {
521
536
  return pressed;
522
537
  })) {
@@ -538,21 +553,21 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
538
553
  start: start
539
554
  };
540
555
  },
541
- onGenerateDragPreview: function onGenerateDragPreview(_ref5) {
556
+ onGenerateDragPreview: function onGenerateDragPreview(_ref6) {
542
557
  var _api$blockControls$sh2;
543
- var nativeSetDragImage = _ref5.nativeSetDragImage;
558
+ var nativeSetDragImage = _ref6.nativeSetDragImage;
544
559
  if (isMultiSelect) {
545
560
  var _api$core5;
546
- api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
547
- var tr = _ref6.tr;
561
+ api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref7) {
562
+ var tr = _ref7.tr;
548
563
  var handlePos = getPos();
549
564
  if (typeof handlePos !== 'number') {
550
565
  return tr;
551
566
  }
552
567
  var newHandlePosCheck = (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos);
553
568
  if (!tr.selection.empty && newHandlePosCheck) {
554
- var _api$blockControls5;
555
- api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
569
+ var _api$blockControls6;
570
+ api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setMultiSelectPositions()({
556
571
  tr: tr
557
572
  });
558
573
  } else if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_select_node_on_drag')) {
@@ -622,8 +637,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
622
637
  };
623
638
  }
624
639
  },
625
- render: function render(_ref7) {
626
- var container = _ref7.container;
640
+ render: function render(_ref8) {
641
+ var container = _ref8.container;
627
642
  var dom = view.dom.querySelector("[".concat((0, _domAttrName.getAnchorAttrName)(), "=\"").concat(anchorName, "\"]"));
628
643
  if (!dom) {
629
644
  return;
@@ -659,9 +674,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
659
674
  if (start === undefined) {
660
675
  return;
661
676
  }
662
- api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref8) {
663
- var _api$blockControls$sh3, _api$blockControls6, _api$analytics2;
664
- var tr = _ref8.tr;
677
+ api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref9) {
678
+ var _api$blockControls$sh3, _api$blockControls7, _api$analytics2;
679
+ var tr = _ref9.tr;
665
680
  var nodeTypes, hasSelectedMultipleNodes;
666
681
  var resolvedMovingNode = tr.doc.resolve(start);
667
682
  var maybeNode = resolvedMovingNode.nodeAfter;
@@ -674,7 +689,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
674
689
  nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
675
690
  hasSelectedMultipleNodes = false;
676
691
  }
677
- api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
692
+ api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 || _api$blockControls7.commands.setNodeDragged(getPos, anchorName, nodeType)({
678
693
  tr: tr
679
694
  });
680
695
  tr.setMeta('scrollIntoView', false);
@@ -1057,15 +1072,15 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
1057
1072
  var render = isTooltip ? buttonWithTooltip() : renderButton();
1058
1073
  return (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? stickyRender : render;
1059
1074
  };
1060
- var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragHandleWithVisibility(_ref9) {
1061
- var view = _ref9.view,
1062
- api = _ref9.api,
1063
- formatMessage = _ref9.formatMessage,
1064
- getPos = _ref9.getPos,
1065
- anchorName = _ref9.anchorName,
1066
- nodeType = _ref9.nodeType,
1067
- handleOptions = _ref9.handleOptions,
1068
- anchorRectCache = _ref9.anchorRectCache;
1075
+ var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragHandleWithVisibility(_ref0) {
1076
+ var view = _ref0.view,
1077
+ api = _ref0.api,
1078
+ formatMessage = _ref0.formatMessage,
1079
+ getPos = _ref0.getPos,
1080
+ anchorName = _ref0.anchorName,
1081
+ nodeType = _ref0.nodeType,
1082
+ handleOptions = _ref0.handleOptions,
1083
+ anchorRectCache = _ref0.anchorRectCache;
1069
1084
  return (0, _react2.jsx)(_visibilityContainer.VisibilityContainer, {
1070
1085
  api: api
1071
1086
  }, (0, _react2.jsx)(DragHandle, {
@@ -19,6 +19,7 @@ const PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK = [...PARENT_WITH_END_DROP_TARGET,
19
19
  * List of node types that does not allow drop targets at before or after the node.
20
20
  */
21
21
  const NODE_WITH_NO_PARENT_POS = ['tableCell', 'tableHeader', 'layoutColumn'];
22
+ const UNSUPPORTED_LAYOUT_CONTENT = ['syncBlock', 'bodiedSyncBlock'];
22
23
  const isContainerNode = node => {
23
24
  if (expValEquals('platform_synced_block', 'isEnabled', true)) {
24
25
  return PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK.includes(node.type.name);
@@ -195,7 +196,8 @@ export const getActiveDropTargetDecorations = (activeDropTargetNode, state, api,
195
196
  }
196
197
  if (editorExperiment('advanced_layouts', true)) {
197
198
  const isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
198
- if (rootNodeWithPos.node.type.name === 'layoutSection') {
199
+ const hasUnsupportedContent = UNSUPPORTED_LAYOUT_CONTENT.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') && expValEquals('platform_synced_block', 'isEnabled', true);
200
+ if (rootNodeWithPos.node.type.name === 'layoutSection' && !hasUnsupportedContent) {
199
201
  const layoutSectionNode = rootNodeWithPos.node;
200
202
  if (layoutSectionNode.childCount < maxLayoutColumnSupported() || isSameLayout) {
201
203
  layoutSectionNode.descendants((childNode, childPos, parent, index) => {
@@ -775,8 +775,11 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
775
775
  api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
776
776
  }
777
777
  if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1')) {
778
- var _api$blockControls$sh2;
779
- if (api !== null && api !== void 0 && (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh2 !== void 0 && _api$blockControls$sh2.isSelectedViaDragHandle) {
778
+ var _api$blockControls$sh2, _api$blockControls$sh3;
779
+ const isBlockMenuOpen = (api === null || api === void 0 ? void 0 : (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen) && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
780
+ // when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
781
+ // in this scenario, isSelectedViaDragHandle should not be set to false
782
+ if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
780
783
  api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
781
784
  }
782
785
  }
@@ -800,8 +803,11 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
800
803
  api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
801
804
  }
802
805
  if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1')) {
803
- var _api$blockControls$sh3;
804
- if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle) {
806
+ var _api$blockControls$sh4, _api$blockControls$sh5;
807
+ const isBlockMenuOpen = (api === null || api === void 0 ? void 0 : (_api$blockControls$sh4 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh4 === void 0 ? void 0 : _api$blockControls$sh4.isMenuOpen) && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
808
+ // when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
809
+ // in this scenario, isSelectedViaDragHandle should not be set to false
810
+ if (api !== null && api !== void 0 && (_api$blockControls$sh5 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh5 !== void 0 && _api$blockControls$sh5.isSelectedViaDragHandle && !isBlockMenuOpen) {
805
811
  api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
806
812
  }
807
813
  }
@@ -1,7 +1,9 @@
1
1
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
4
  import { isWrappedMedia } from './check-media-layout';
4
5
  import { maxLayoutColumnSupported } from './consts';
6
+ const syncedBlockTypes = ['syncBlock', 'bodiedSyncBlock'];
5
7
  export const shouldAllowInlineDropTarget = (isNested, node,
6
8
  /**
7
9
  * Is the active node in the same layout as the target node
@@ -16,6 +18,9 @@ isSameLayout = false, activeNode) => {
16
18
  if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
17
19
  return false;
18
20
  }
21
+ if ((syncedBlockTypes.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') || syncedBlockTypes.includes((node === null || node === void 0 ? void 0 : node.type.name) || '')) && expValEquals('platform_synced_block', 'isEnabled', true)) {
22
+ return false;
23
+ }
19
24
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
20
25
  return node.childCount < maxLayoutColumnSupported() || isSameLayout;
21
26
  }
@@ -13,6 +13,7 @@ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-commo
13
13
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
14
14
  import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
15
15
  import { blockControlsMessages } from '@atlaskit/editor-common/messages';
16
+ import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
16
17
  import { tableControlsSpacing, DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles';
17
18
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
18
19
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -494,6 +495,21 @@ export const DragHandle = ({
494
495
  });
495
496
  return tr;
496
497
  });
498
+ } else if (e.key === 'Backspace' || e.key === 'Delete') {
499
+ e.preventDefault();
500
+ e.stopPropagation();
501
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(({
502
+ tr
503
+ }) => {
504
+ var _api$blockControls5;
505
+ deleteSelectedRange(tr);
506
+ api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.toggleBlockMenu({
507
+ closeMenu: true
508
+ })({
509
+ tr
510
+ });
511
+ return tr;
512
+ });
497
513
  } else if (![e.altKey, e.ctrlKey, e.shiftKey].some(pressed => pressed)) {
498
514
  // If not trying to press shortcut keys,
499
515
  // return focus to editor to resume editing from caret position
@@ -526,8 +542,8 @@ export const DragHandle = ({
526
542
  }
527
543
  const newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
528
544
  if (!tr.selection.empty && newHandlePosCheck) {
529
- var _api$blockControls5;
530
- api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.setMultiSelectPositions()({
545
+ var _api$blockControls6;
546
+ api === null || api === void 0 ? void 0 : (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 ? void 0 : _api$blockControls6.commands.setMultiSelectPositions()({
531
547
  tr
532
548
  });
533
549
  } else if (fg('platform_editor_elements_dnd_select_node_on_drag')) {
@@ -642,7 +658,7 @@ export const DragHandle = ({
642
658
  api === null || api === void 0 ? void 0 : (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions.execute(({
643
659
  tr
644
660
  }) => {
645
- var _api$blockControls$sh3, _api$blockControls6, _api$analytics2;
661
+ var _api$blockControls$sh3, _api$blockControls7, _api$analytics2;
646
662
  let nodeTypes, hasSelectedMultipleNodes;
647
663
  const resolvedMovingNode = tr.doc.resolve(start);
648
664
  const maybeNode = resolvedMovingNode.nodeAfter;
@@ -655,7 +671,7 @@ export const DragHandle = ({
655
671
  nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
656
672
  hasSelectedMultipleNodes = false;
657
673
  }
658
- api === null || api === void 0 ? void 0 : (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 ? void 0 : _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
674
+ api === null || api === void 0 ? void 0 : (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 ? void 0 : _api$blockControls7.commands.setNodeDragged(getPos, anchorName, nodeType)({
659
675
  tr
660
676
  });
661
677
  tr.setMeta('scrollIntoView', false);
@@ -19,6 +19,7 @@ var PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK = [].concat(PARENT_WITH_END_DROP_TARG
19
19
  * List of node types that does not allow drop targets at before or after the node.
20
20
  */
21
21
  var NODE_WITH_NO_PARENT_POS = ['tableCell', 'tableHeader', 'layoutColumn'];
22
+ var UNSUPPORTED_LAYOUT_CONTENT = ['syncBlock', 'bodiedSyncBlock'];
22
23
  var isContainerNode = function isContainerNode(node) {
23
24
  if (expValEquals('platform_synced_block', 'isEnabled', true)) {
24
25
  return PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK.includes(node.type.name);
@@ -207,7 +208,8 @@ export var getActiveDropTargetDecorations = function getActiveDropTargetDecorati
207
208
  }
208
209
  if (editorExperiment('advanced_layouts', true)) {
209
210
  var _isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
210
- if (rootNodeWithPos.node.type.name === 'layoutSection') {
211
+ var hasUnsupportedContent = UNSUPPORTED_LAYOUT_CONTENT.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') && expValEquals('platform_synced_block', 'isEnabled', true);
212
+ if (rootNodeWithPos.node.type.name === 'layoutSection' && !hasUnsupportedContent) {
211
213
  var layoutSectionNode = rootNodeWithPos.node;
212
214
  if (layoutSectionNode.childCount < maxLayoutColumnSupported() || _isSameLayout) {
213
215
  layoutSectionNode.descendants(function (childNode, childPos, parent, index) {
@@ -765,8 +765,11 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
765
765
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
766
766
  }
767
767
  if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1')) {
768
- var _api$blockControls$sh2;
769
- if (api !== null && api !== void 0 && (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh2 !== void 0 && _api$blockControls$sh2.isSelectedViaDragHandle) {
768
+ var _api$blockControls$sh2, _api$blockControls$sh3;
769
+ 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) && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
770
+ // when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
771
+ // in this scenario, isSelectedViaDragHandle should not be set to false
772
+ if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
770
773
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
771
774
  }
772
775
  }
@@ -789,8 +792,11 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
789
792
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(_isDragHandle));
790
793
  }
791
794
  if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1')) {
792
- var _api$blockControls$sh3;
793
- if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle) {
795
+ var _api$blockControls$sh4, _api$blockControls$sh5;
796
+ 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) && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
797
+ // when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
798
+ // in this scenario, isSelectedViaDragHandle should not be set to false
799
+ if (api !== null && api !== void 0 && (_api$blockControls$sh5 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh5 !== void 0 && _api$blockControls$sh5.isSelectedViaDragHandle && !_isBlockMenuOpen) {
794
800
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
795
801
  }
796
802
  }
@@ -1,7 +1,9 @@
1
1
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
4
  import { isWrappedMedia } from './check-media-layout';
4
5
  import { maxLayoutColumnSupported } from './consts';
6
+ var syncedBlockTypes = ['syncBlock', 'bodiedSyncBlock'];
5
7
  export var shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(isNested, node) {
6
8
  var isSameLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
7
9
  var activeNode = arguments.length > 3 ? arguments[3] : undefined;
@@ -14,6 +16,9 @@ export var shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(is
14
16
  if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
15
17
  return false;
16
18
  }
19
+ if ((syncedBlockTypes.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') || syncedBlockTypes.includes((node === null || node === void 0 ? void 0 : node.type.name) || '')) && expValEquals('platform_synced_block', 'isEnabled', true)) {
20
+ return false;
21
+ }
17
22
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
18
23
  return node.childCount < maxLayoutColumnSupported() || isSameLayout;
19
24
  }
@@ -18,6 +18,7 @@ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-commo
18
18
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
19
19
  import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
20
20
  import { blockControlsMessages } from '@atlaskit/editor-common/messages';
21
+ import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
21
22
  import { tableControlsSpacing, DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles';
22
23
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
23
24
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -514,6 +515,20 @@ export var DragHandle = function DragHandle(_ref) {
514
515
  });
515
516
  return tr;
516
517
  });
518
+ } else if (e.key === 'Backspace' || e.key === 'Delete') {
519
+ e.preventDefault();
520
+ e.stopPropagation();
521
+ api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
522
+ var _api$blockControls5;
523
+ var tr = _ref5.tr;
524
+ deleteSelectedRange(tr);
525
+ api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.toggleBlockMenu({
526
+ closeMenu: true
527
+ })({
528
+ tr: tr
529
+ });
530
+ return tr;
531
+ });
517
532
  } else if (![e.altKey, e.ctrlKey, e.shiftKey].some(function (pressed) {
518
533
  return pressed;
519
534
  })) {
@@ -535,21 +550,21 @@ export var DragHandle = function DragHandle(_ref) {
535
550
  start: start
536
551
  };
537
552
  },
538
- onGenerateDragPreview: function onGenerateDragPreview(_ref5) {
553
+ onGenerateDragPreview: function onGenerateDragPreview(_ref6) {
539
554
  var _api$blockControls$sh2;
540
- var nativeSetDragImage = _ref5.nativeSetDragImage;
555
+ var nativeSetDragImage = _ref6.nativeSetDragImage;
541
556
  if (isMultiSelect) {
542
557
  var _api$core5;
543
- api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
544
- var tr = _ref6.tr;
558
+ api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref7) {
559
+ var tr = _ref7.tr;
545
560
  var handlePos = getPos();
546
561
  if (typeof handlePos !== 'number') {
547
562
  return tr;
548
563
  }
549
564
  var newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
550
565
  if (!tr.selection.empty && newHandlePosCheck) {
551
- var _api$blockControls5;
552
- api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
566
+ var _api$blockControls6;
567
+ api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setMultiSelectPositions()({
553
568
  tr: tr
554
569
  });
555
570
  } else if (fg('platform_editor_elements_dnd_select_node_on_drag')) {
@@ -619,8 +634,8 @@ export var DragHandle = function DragHandle(_ref) {
619
634
  };
620
635
  }
621
636
  },
622
- render: function render(_ref7) {
623
- var container = _ref7.container;
637
+ render: function render(_ref8) {
638
+ var container = _ref8.container;
624
639
  var dom = view.dom.querySelector("[".concat(getAnchorAttrName(), "=\"").concat(anchorName, "\"]"));
625
640
  if (!dom) {
626
641
  return;
@@ -656,9 +671,9 @@ export var DragHandle = function DragHandle(_ref) {
656
671
  if (start === undefined) {
657
672
  return;
658
673
  }
659
- api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref8) {
660
- var _api$blockControls$sh3, _api$blockControls6, _api$analytics2;
661
- var tr = _ref8.tr;
674
+ api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref9) {
675
+ var _api$blockControls$sh3, _api$blockControls7, _api$analytics2;
676
+ var tr = _ref9.tr;
662
677
  var nodeTypes, hasSelectedMultipleNodes;
663
678
  var resolvedMovingNode = tr.doc.resolve(start);
664
679
  var maybeNode = resolvedMovingNode.nodeAfter;
@@ -671,7 +686,7 @@ export var DragHandle = function DragHandle(_ref) {
671
686
  nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
672
687
  hasSelectedMultipleNodes = false;
673
688
  }
674
- api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
689
+ api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 || _api$blockControls7.commands.setNodeDragged(getPos, anchorName, nodeType)({
675
690
  tr: tr
676
691
  });
677
692
  tr.setMeta('scrollIntoView', false);
@@ -1054,15 +1069,15 @@ export var DragHandle = function DragHandle(_ref) {
1054
1069
  var render = isTooltip ? buttonWithTooltip() : renderButton();
1055
1070
  return editorExperiment('platform_editor_controls', 'variant1') ? stickyRender : render;
1056
1071
  };
1057
- export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref9) {
1058
- var view = _ref9.view,
1059
- api = _ref9.api,
1060
- formatMessage = _ref9.formatMessage,
1061
- getPos = _ref9.getPos,
1062
- anchorName = _ref9.anchorName,
1063
- nodeType = _ref9.nodeType,
1064
- handleOptions = _ref9.handleOptions,
1065
- anchorRectCache = _ref9.anchorRectCache;
1072
+ export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref0) {
1073
+ var view = _ref0.view,
1074
+ api = _ref0.api,
1075
+ formatMessage = _ref0.formatMessage,
1076
+ getPos = _ref0.getPos,
1077
+ anchorName = _ref0.anchorName,
1078
+ nodeType = _ref0.nodeType,
1079
+ handleOptions = _ref0.handleOptions,
1080
+ anchorRectCache = _ref0.anchorRectCache;
1066
1081
  return jsx(VisibilityContainer, {
1067
1082
  api: api
1068
1083
  }, jsx(DragHandle, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "7.7.0",
3
+ "version": "7.7.2",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^51.3.2",
31
+ "@atlaskit/adf-schema": "^51.4.0",
32
32
  "@atlaskit/editor-plugin-accessibility-utils": "^6.0.0",
33
33
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
34
34
  "@atlaskit/editor-plugin-editor-disabled": "^6.1.0",
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
44
44
  "@atlaskit/editor-plugin-width": "^7.0.0",
45
45
  "@atlaskit/editor-prosemirror": "7.0.0",
46
- "@atlaskit/editor-shared-styles": "^3.9.0",
46
+ "@atlaskit/editor-shared-styles": "^3.10.0",
47
47
  "@atlaskit/editor-tables": "^2.9.0",
48
48
  "@atlaskit/icon": "^29.0.0",
49
49
  "@atlaskit/link": "^3.2.0",
@@ -65,7 +65,7 @@
65
65
  "uuid": "^3.1.0"
66
66
  },
67
67
  "peerDependencies": {
68
- "@atlaskit/editor-common": "^110.31.0",
68
+ "@atlaskit/editor-common": "^110.32.0",
69
69
  "react": "^18.2.0",
70
70
  "react-dom": "^18.2.0",
71
71
  "react-intl-next": "npm:react-intl@^5.18.1"