@atlaskit/editor-plugin-block-controls 7.6.0 → 7.7.1

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,23 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 7.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`27d4ba93d0702`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/27d4ba93d0702) -
8
+ EDITOR-3201 disable layout drop targets for sync blocks
9
+
10
+ ## 7.7.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`1bfde822534e5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1bfde822534e5) -
15
+ EDITOR-2749 fix drag and drop issue in bodied sync block
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 7.6.0
4
22
 
5
23
  ### Minor Changes
@@ -18,12 +18,17 @@ var _validation = require("./utils/validation");
18
18
  * List of parent node types that can have child nodes
19
19
  */
20
20
  var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
21
+ var PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK = [].concat(PARENT_WITH_END_DROP_TARGET, ['bodiedSyncBlock']);
21
22
 
22
23
  /**
23
24
  * List of node types that does not allow drop targets at before or after the node.
24
25
  */
25
26
  var NODE_WITH_NO_PARENT_POS = ['tableCell', 'tableHeader', 'layoutColumn'];
27
+ var UNSUPPORTED_LAYOUT_CONTENT = ['syncBlock', 'bodiedSyncBlock'];
26
28
  var isContainerNode = function isContainerNode(node) {
29
+ if ((0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true)) {
30
+ return PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK.includes(node.type.name);
31
+ }
27
32
  return PARENT_WITH_END_DROP_TARGET.includes(node.type.name);
28
33
  };
29
34
  var canMoveNodeOrSliceToPos = exports.canMoveNodeOrSliceToPos = function canMoveNodeOrSliceToPos(state, node, parent, index, $toPos, activeNode) {
@@ -208,7 +213,8 @@ var getActiveDropTargetDecorations = exports.getActiveDropTargetDecorations = fu
208
213
  }
209
214
  if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
210
215
  var _isSameLayout = $activeNodePos && (0, _validation.isInSameLayout)($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
211
- 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) {
212
218
  var layoutSectionNode = rootNodeWithPos.node;
213
219
  if (layoutSectionNode.childCount < (0, _consts.maxLayoutColumnSupported)() || _isSameLayout) {
214
220
  layoutSectionNode.descendants(function (childNode, childPos, parent, index) {
@@ -493,7 +493,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
493
493
  if (api) {
494
494
  if ((0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
495
495
  // If page is updated while dragging (likely by remote updates), we simply remove the drop targets
496
- // and add them back when the use interacts with the editor again
496
+ // and add them back when the user interacts with the editor again
497
497
  if (isDropTargetsMissing) {
498
498
  var oldDropTargetDecs = (0, _decorationsDropTarget.findDropTargetDecs)(decorations);
499
499
  decorations = decorations.remove(oldDropTargetDecs);
@@ -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
  }
@@ -13,12 +13,17 @@ import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils
13
13
  * List of parent node types that can have child nodes
14
14
  */
15
15
  const PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
16
+ const PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK = [...PARENT_WITH_END_DROP_TARGET, 'bodiedSyncBlock'];
16
17
 
17
18
  /**
18
19
  * List of node types that does not allow drop targets at before or after the node.
19
20
  */
20
21
  const NODE_WITH_NO_PARENT_POS = ['tableCell', 'tableHeader', 'layoutColumn'];
22
+ const UNSUPPORTED_LAYOUT_CONTENT = ['syncBlock', 'bodiedSyncBlock'];
21
23
  const isContainerNode = node => {
24
+ if (expValEquals('platform_synced_block', 'isEnabled', true)) {
25
+ return PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK.includes(node.type.name);
26
+ }
22
27
  return PARENT_WITH_END_DROP_TARGET.includes(node.type.name);
23
28
  };
24
29
  export const canMoveNodeOrSliceToPos = (state, node, parent, index, $toPos, activeNode) => {
@@ -191,7 +196,8 @@ export const getActiveDropTargetDecorations = (activeDropTargetNode, state, api,
191
196
  }
192
197
  if (editorExperiment('advanced_layouts', true)) {
193
198
  const isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
194
- 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) {
195
201
  const layoutSectionNode = rootNodeWithPos.node;
196
202
  if (layoutSectionNode.childCount < maxLayoutColumnSupported() || isSameLayout) {
197
203
  layoutSectionNode.descendants((childNode, childPos, parent, index) => {
@@ -490,7 +490,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
490
490
  if (api) {
491
491
  if (expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
492
492
  // If page is updated while dragging (likely by remote updates), we simply remove the drop targets
493
- // and add them back when the use interacts with the editor again
493
+ // and add them back when the user interacts with the editor again
494
494
  if (isDropTargetsMissing) {
495
495
  const oldDropTargetDecs = findDropTargetDecs(decorations);
496
496
  decorations = decorations.remove(oldDropTargetDecs);
@@ -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,12 +13,17 @@ import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils
13
13
  * List of parent node types that can have child nodes
14
14
  */
15
15
  var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
16
+ var PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK = [].concat(PARENT_WITH_END_DROP_TARGET, ['bodiedSyncBlock']);
16
17
 
17
18
  /**
18
19
  * List of node types that does not allow drop targets at before or after the node.
19
20
  */
20
21
  var NODE_WITH_NO_PARENT_POS = ['tableCell', 'tableHeader', 'layoutColumn'];
22
+ var UNSUPPORTED_LAYOUT_CONTENT = ['syncBlock', 'bodiedSyncBlock'];
21
23
  var isContainerNode = function isContainerNode(node) {
24
+ if (expValEquals('platform_synced_block', 'isEnabled', true)) {
25
+ return PARENT_WITH_END_DROP_TARGET_SYNC_BLOCK.includes(node.type.name);
26
+ }
22
27
  return PARENT_WITH_END_DROP_TARGET.includes(node.type.name);
23
28
  };
24
29
  export var canMoveNodeOrSliceToPos = function canMoveNodeOrSliceToPos(state, node, parent, index, $toPos, activeNode) {
@@ -203,7 +208,8 @@ export var getActiveDropTargetDecorations = function getActiveDropTargetDecorati
203
208
  }
204
209
  if (editorExperiment('advanced_layouts', true)) {
205
210
  var _isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
206
- 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) {
207
213
  var layoutSectionNode = rootNodeWithPos.node;
208
214
  if (layoutSectionNode.childCount < maxLayoutColumnSupported() || _isSameLayout) {
209
215
  layoutSectionNode.descendants(function (childNode, childPos, parent, index) {
@@ -486,7 +486,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
486
486
  if (api) {
487
487
  if (expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
488
488
  // If page is updated while dragging (likely by remote updates), we simply remove the drop targets
489
- // and add them back when the use interacts with the editor again
489
+ // and add them back when the user interacts with the editor again
490
490
  if (isDropTargetsMissing) {
491
491
  var oldDropTargetDecs = findDropTargetDecs(decorations);
492
492
  decorations = decorations.remove(oldDropTargetDecs);
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "7.6.0",
3
+ "version": "7.7.1",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -55,7 +55,7 @@
55
55
  "@atlaskit/theme": "^21.0.0",
56
56
  "@atlaskit/tmp-editor-statsig": "^13.38.0",
57
57
  "@atlaskit/tokens": "^8.0.0",
58
- "@atlaskit/tooltip": "^20.8.0",
58
+ "@atlaskit/tooltip": "^20.9.0",
59
59
  "@babel/runtime": "^7.0.0",
60
60
  "@emotion/react": "^11.7.1",
61
61
  "@popperjs/core": "^2.11.8",
@@ -65,7 +65,7 @@
65
65
  "uuid": "^3.1.0"
66
66
  },
67
67
  "peerDependencies": {
68
- "@atlaskit/editor-common": "^110.30.0",
68
+ "@atlaskit/editor-common": "^110.31.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"