@atlaskit/editor-plugin-block-controls 3.3.1 → 3.3.3

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,19 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 3.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#122983](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/122983)
8
+ [`ac18d90e27592`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ac18d90e27592) -
9
+ Update transformSourceSlice to search entire slice
10
+
11
+ ## 3.3.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 3.3.1
4
18
 
5
19
  ### Patch Changes
@@ -38,14 +38,48 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
38
38
  function transformSourceSlice(nodeCopy, destType) {
39
39
  var srcNode = nodeCopy.content.firstChild;
40
40
  var schema = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.schema;
41
- if (srcNode && schema) {
41
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1')) {
42
+ if (!schema) {
43
+ return nodeCopy;
44
+ }
42
45
  var _schema$nodes = schema.nodes,
43
46
  doc = _schema$nodes.doc,
44
47
  layoutColumn = _schema$nodes.layoutColumn;
45
- if (srcNode.type === schema.nodes.nestedExpand && [doc, layoutColumn].includes(destType)) {
46
- return (0, _transforms.transformSliceNestedExpandToExpand)(nodeCopy, schema);
47
- } else if (srcNode.type === schema.nodes.expand && (0, _validation.isInsideTable)(destType)) {
48
+ var destTypeInTable = (0, _validation.isInsideTable)(destType);
49
+ var destTypeInDocOrLayoutCol = [doc, layoutColumn].includes(destType);
50
+
51
+ // No need to loop over slice content if destination requires no transformations
52
+ if (!destTypeInTable && !destTypeInDocOrLayoutCol) {
53
+ return nodeCopy;
54
+ }
55
+ var containsExpand = false;
56
+ var containsNestedExpand = false;
57
+ for (var i = 0; i < nodeCopy.content.childCount; i++) {
58
+ var node = nodeCopy.content.child(i);
59
+ if (node.type === schema.nodes.expand) {
60
+ containsExpand = true;
61
+ } else if (node.type === schema.nodes.nestedExpand) {
62
+ containsNestedExpand = true;
63
+ }
64
+ if (containsExpand && containsNestedExpand) {
65
+ break;
66
+ }
67
+ }
68
+ if (containsExpand && destTypeInTable) {
48
69
  return (0, _validation.transformSliceExpandToNestedExpand)(nodeCopy);
70
+ } else if (containsNestedExpand && destTypeInDocOrLayoutCol) {
71
+ return (0, _transforms.transformSliceNestedExpandToExpand)(nodeCopy, schema);
72
+ }
73
+ } else {
74
+ if (srcNode && schema) {
75
+ var _schema$nodes2 = schema.nodes,
76
+ _doc = _schema$nodes2.doc,
77
+ _layoutColumn = _schema$nodes2.layoutColumn;
78
+ if (srcNode.type === schema.nodes.nestedExpand && [_doc, _layoutColumn].includes(destType)) {
79
+ return (0, _transforms.transformSliceNestedExpandToExpand)(nodeCopy, schema);
80
+ } else if (srcNode.type === schema.nodes.expand && (0, _validation.isInsideTable)(destType)) {
81
+ return (0, _validation.transformSliceExpandToNestedExpand)(nodeCopy);
82
+ }
49
83
  }
50
84
  }
51
85
  return nodeCopy;
@@ -29,15 +29,50 @@ import { canMoveNodeToIndex, isInsideTable, transformSliceExpandToNestedExpand }
29
29
  function transformSourceSlice(nodeCopy, destType) {
30
30
  const srcNode = nodeCopy.content.firstChild;
31
31
  const schema = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.schema;
32
- if (srcNode && schema) {
32
+ if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
33
+ if (!schema) {
34
+ return nodeCopy;
35
+ }
33
36
  const {
34
37
  doc,
35
38
  layoutColumn
36
39
  } = schema.nodes;
37
- if (srcNode.type === schema.nodes.nestedExpand && [doc, layoutColumn].includes(destType)) {
38
- return transformSliceNestedExpandToExpand(nodeCopy, schema);
39
- } else if (srcNode.type === schema.nodes.expand && isInsideTable(destType)) {
40
+ const destTypeInTable = isInsideTable(destType);
41
+ const destTypeInDocOrLayoutCol = [doc, layoutColumn].includes(destType);
42
+
43
+ // No need to loop over slice content if destination requires no transformations
44
+ if (!destTypeInTable && !destTypeInDocOrLayoutCol) {
45
+ return nodeCopy;
46
+ }
47
+ let containsExpand = false;
48
+ let containsNestedExpand = false;
49
+ for (let i = 0; i < nodeCopy.content.childCount; i++) {
50
+ const node = nodeCopy.content.child(i);
51
+ if (node.type === schema.nodes.expand) {
52
+ containsExpand = true;
53
+ } else if (node.type === schema.nodes.nestedExpand) {
54
+ containsNestedExpand = true;
55
+ }
56
+ if (containsExpand && containsNestedExpand) {
57
+ break;
58
+ }
59
+ }
60
+ if (containsExpand && destTypeInTable) {
40
61
  return transformSliceExpandToNestedExpand(nodeCopy);
62
+ } else if (containsNestedExpand && destTypeInDocOrLayoutCol) {
63
+ return transformSliceNestedExpandToExpand(nodeCopy, schema);
64
+ }
65
+ } else {
66
+ if (srcNode && schema) {
67
+ const {
68
+ doc,
69
+ layoutColumn
70
+ } = schema.nodes;
71
+ if (srcNode.type === schema.nodes.nestedExpand && [doc, layoutColumn].includes(destType)) {
72
+ return transformSliceNestedExpandToExpand(nodeCopy, schema);
73
+ } else if (srcNode.type === schema.nodes.expand && isInsideTable(destType)) {
74
+ return transformSliceExpandToNestedExpand(nodeCopy);
75
+ }
41
76
  }
42
77
  }
43
78
  return nodeCopy;
@@ -32,14 +32,48 @@ import { canMoveNodeToIndex, isInsideTable, transformSliceExpandToNestedExpand }
32
32
  function transformSourceSlice(nodeCopy, destType) {
33
33
  var srcNode = nodeCopy.content.firstChild;
34
34
  var schema = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.schema;
35
- if (srcNode && schema) {
35
+ if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
36
+ if (!schema) {
37
+ return nodeCopy;
38
+ }
36
39
  var _schema$nodes = schema.nodes,
37
40
  doc = _schema$nodes.doc,
38
41
  layoutColumn = _schema$nodes.layoutColumn;
39
- if (srcNode.type === schema.nodes.nestedExpand && [doc, layoutColumn].includes(destType)) {
40
- return transformSliceNestedExpandToExpand(nodeCopy, schema);
41
- } else if (srcNode.type === schema.nodes.expand && isInsideTable(destType)) {
42
+ var destTypeInTable = isInsideTable(destType);
43
+ var destTypeInDocOrLayoutCol = [doc, layoutColumn].includes(destType);
44
+
45
+ // No need to loop over slice content if destination requires no transformations
46
+ if (!destTypeInTable && !destTypeInDocOrLayoutCol) {
47
+ return nodeCopy;
48
+ }
49
+ var containsExpand = false;
50
+ var containsNestedExpand = false;
51
+ for (var i = 0; i < nodeCopy.content.childCount; i++) {
52
+ var node = nodeCopy.content.child(i);
53
+ if (node.type === schema.nodes.expand) {
54
+ containsExpand = true;
55
+ } else if (node.type === schema.nodes.nestedExpand) {
56
+ containsNestedExpand = true;
57
+ }
58
+ if (containsExpand && containsNestedExpand) {
59
+ break;
60
+ }
61
+ }
62
+ if (containsExpand && destTypeInTable) {
42
63
  return transformSliceExpandToNestedExpand(nodeCopy);
64
+ } else if (containsNestedExpand && destTypeInDocOrLayoutCol) {
65
+ return transformSliceNestedExpandToExpand(nodeCopy, schema);
66
+ }
67
+ } else {
68
+ if (srcNode && schema) {
69
+ var _schema$nodes2 = schema.nodes,
70
+ _doc = _schema$nodes2.doc,
71
+ _layoutColumn = _schema$nodes2.layoutColumn;
72
+ if (srcNode.type === schema.nodes.nestedExpand && [_doc, _layoutColumn].includes(destType)) {
73
+ return transformSliceNestedExpandToExpand(nodeCopy, schema);
74
+ } else if (srcNode.type === schema.nodes.expand && isInsideTable(destType)) {
75
+ return transformSliceExpandToNestedExpand(nodeCopy);
76
+ }
43
77
  }
44
78
  }
45
79
  return nodeCopy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "3.3.1",
3
+ "version": "3.3.3",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -51,7 +51,7 @@
51
51
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
52
52
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^2.1.0",
53
53
  "@atlaskit/primitives": "^14.1.0",
54
- "@atlaskit/theme": "^17.0.0",
54
+ "@atlaskit/theme": "^18.0.0",
55
55
  "@atlaskit/tmp-editor-statsig": "^3.4.0",
56
56
  "@atlaskit/tokens": "^4.3.0",
57
57
  "@atlaskit/tooltip": "^20.0.0",