@atlaskit/editor-plugin-block-controls 3.3.2 → 3.3.4

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,22 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 3.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#122078](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/122078)
8
+ [`b0ffa0b719b38`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b0ffa0b719b38) -
9
+ [ux] ED-26811 fixing the copy and paste issue for copy and paste
10
+ - Updated dependencies
11
+
12
+ ## 3.3.3
13
+
14
+ ### Patch Changes
15
+
16
+ - [#122983](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/122983)
17
+ [`ac18d90e27592`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ac18d90e27592) -
18
+ Update transformSourceSlice to search entire slice
19
+
3
20
  ## 3.3.2
4
21
 
5
22
  ### 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;
@@ -41,6 +41,16 @@ var isNodeWithMedia = function isNodeWithMedia(tr, start, nodeSize) {
41
41
  });
42
42
  return hasMedia;
43
43
  };
44
+ var isNodeWithMediaOrExtension = function isNodeWithMediaOrExtension(tr, start, nodeSize) {
45
+ var $startPos = tr.doc.resolve(start);
46
+ var hasMediaOrExtension = false;
47
+ tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n) {
48
+ if (['media', 'extension'].includes(n.type.name)) {
49
+ hasMediaOrExtension = true;
50
+ }
51
+ });
52
+ return hasMediaOrExtension;
53
+ };
44
54
  var getSelection = exports.getSelection = function getSelection(tr, start) {
45
55
  var node = tr.doc.nodeAt(start);
46
56
  var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
@@ -48,7 +58,8 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
48
58
  var $startPos = tr.doc.resolve(start);
49
59
  var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
50
60
  var isBlockQuoteWithMedia = nodeName === 'blockquote' && isNodeWithMedia(tr, start, nodeSize);
51
- if (isNodeSelection && nodeName !== 'blockquote' || isBlockQuoteWithMedia ||
61
+ var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
62
+ if (isNodeSelection && nodeName !== 'blockquote' || ((0, _platformFeatureFlags.fg)('platform_editor_non_macros_copy_and_paste_fix') ? isBlockQuoteWithMediaOrExtension : isBlockQuoteWithMedia) ||
52
63
  // decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
53
64
  ['decisionList', 'layoutColumn'].includes(nodeName || '')) {
54
65
  return new _state.NodeSelection($startPos);
@@ -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;
@@ -35,6 +35,16 @@ const isNodeWithMedia = (tr, start, nodeSize) => {
35
35
  });
36
36
  return hasMedia;
37
37
  };
38
+ const isNodeWithMediaOrExtension = (tr, start, nodeSize) => {
39
+ const $startPos = tr.doc.resolve(start);
40
+ let hasMediaOrExtension = false;
41
+ tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, n => {
42
+ if (['media', 'extension'].includes(n.type.name)) {
43
+ hasMediaOrExtension = true;
44
+ }
45
+ });
46
+ return hasMediaOrExtension;
47
+ };
38
48
  export const getSelection = (tr, start) => {
39
49
  const node = tr.doc.nodeAt(start);
40
50
  const isNodeSelection = node && NodeSelection.isSelectable(node);
@@ -42,7 +52,8 @@ export const getSelection = (tr, start) => {
42
52
  const $startPos = tr.doc.resolve(start);
43
53
  const nodeName = node === null || node === void 0 ? void 0 : node.type.name;
44
54
  const isBlockQuoteWithMedia = nodeName === 'blockquote' && isNodeWithMedia(tr, start, nodeSize);
45
- if (isNodeSelection && nodeName !== 'blockquote' || isBlockQuoteWithMedia ||
55
+ const isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
56
+ if (isNodeSelection && nodeName !== 'blockquote' || (fg('platform_editor_non_macros_copy_and_paste_fix') ? isBlockQuoteWithMediaOrExtension : isBlockQuoteWithMedia) ||
46
57
  // decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
47
58
  ['decisionList', 'layoutColumn'].includes(nodeName || '')) {
48
59
  return new NodeSelection($startPos);
@@ -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;
@@ -35,6 +35,16 @@ var isNodeWithMedia = function isNodeWithMedia(tr, start, nodeSize) {
35
35
  });
36
36
  return hasMedia;
37
37
  };
38
+ var isNodeWithMediaOrExtension = function isNodeWithMediaOrExtension(tr, start, nodeSize) {
39
+ var $startPos = tr.doc.resolve(start);
40
+ var hasMediaOrExtension = false;
41
+ tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n) {
42
+ if (['media', 'extension'].includes(n.type.name)) {
43
+ hasMediaOrExtension = true;
44
+ }
45
+ });
46
+ return hasMediaOrExtension;
47
+ };
38
48
  export var getSelection = function getSelection(tr, start) {
39
49
  var node = tr.doc.nodeAt(start);
40
50
  var isNodeSelection = node && NodeSelection.isSelectable(node);
@@ -42,7 +52,8 @@ export var getSelection = function getSelection(tr, start) {
42
52
  var $startPos = tr.doc.resolve(start);
43
53
  var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
44
54
  var isBlockQuoteWithMedia = nodeName === 'blockquote' && isNodeWithMedia(tr, start, nodeSize);
45
- if (isNodeSelection && nodeName !== 'blockquote' || isBlockQuoteWithMedia ||
55
+ var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
56
+ if (isNodeSelection && nodeName !== 'blockquote' || (fg('platform_editor_non_macros_copy_and_paste_fix') ? isBlockQuoteWithMediaOrExtension : isBlockQuoteWithMedia) ||
46
57
  // decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
47
58
  ['decisionList', 'layoutColumn'].includes(nodeName || '')) {
48
59
  return new NodeSelection($startPos);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -166,6 +166,9 @@
166
166
  },
167
167
  "platform_editor_ease_of_use_metrics": {
168
168
  "type": "boolean"
169
+ },
170
+ "platform_editor_non_macros_copy_and_paste_fix": {
171
+ "type": "boolean"
169
172
  }
170
173
  }
171
174
  }