@atlaskit/editor-tables 2.1.2 → 2.1.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,11 @@
1
1
  # @atlaskit/editor-tables
2
2
 
3
+ ## 2.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`cbfbaab61bb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cbfbaab61bb) - [ux][ed-14300] Remove column width from table cells being pasted into another table as it should take the formatting of the destination table.
8
+
3
9
  ## 2.1.2
4
10
 
5
11
  ### Patch Changes
@@ -42,7 +42,7 @@ function handlePaste(view, event, slice) {
42
42
  var rect = _tableMap.TableMap.get(table).rectBetween(sel.$anchorCell.pos - start, sel.$headCell.pos - start);
43
43
 
44
44
  cells = (0, _copyPaste.clipCells)(cells, rect.right - rect.left, rect.bottom - rect.top);
45
- (0, _copyPaste.insertCells)(view.state, view.dispatch, start, rect, cells);
45
+ (0, _copyPaste.insertCells)(view.state, view.dispatch, start, rect, clearColumnWidthOfCells(cells));
46
46
  return true;
47
47
  }
48
48
 
@@ -55,9 +55,20 @@ function handlePaste(view, event, slice) {
55
55
 
56
56
  var _start = $cell.start(-1);
57
57
 
58
- (0, _copyPaste.insertCells)(view.state, view.dispatch, _start, _tableMap.TableMap.get($cell.node(-1)).findCell($cell.pos - _start), cells);
58
+ (0, _copyPaste.insertCells)(view.state, view.dispatch, _start, _tableMap.TableMap.get($cell.node(-1)).findCell($cell.pos - _start), clearColumnWidthOfCells(cells));
59
59
  return true;
60
60
  }
61
61
 
62
62
  return false;
63
- }
63
+ } // Clear the pasted cells column widths so that it maintains
64
+ // the column widths of the destination table
65
+
66
+
67
+ var clearColumnWidthOfCells = function clearColumnWidthOfCells(cells) {
68
+ cells.rows.forEach(function (row) {
69
+ for (var i = 0; i < row.childCount; i++) {
70
+ row.child(i).attrs.colwidth = null;
71
+ }
72
+ });
73
+ return cells;
74
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "sideEffects": false
5
5
  }
@@ -26,7 +26,7 @@ export function handlePaste(view, event, slice) {
26
26
  const start = sel.$anchorCell.start(-1);
27
27
  const rect = TableMap.get(table).rectBetween(sel.$anchorCell.pos - start, sel.$headCell.pos - start);
28
28
  cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);
29
- insertCells(view.state, view.dispatch, start, rect, cells);
29
+ insertCells(view.state, view.dispatch, start, rect, clearColumnWidthOfCells(cells));
30
30
  return true;
31
31
  }
32
32
 
@@ -38,9 +38,19 @@ export function handlePaste(view, event, slice) {
38
38
  }
39
39
 
40
40
  const start = $cell.start(-1);
41
- insertCells(view.state, view.dispatch, start, TableMap.get($cell.node(-1)).findCell($cell.pos - start), cells);
41
+ insertCells(view.state, view.dispatch, start, TableMap.get($cell.node(-1)).findCell($cell.pos - start), clearColumnWidthOfCells(cells));
42
42
  return true;
43
43
  }
44
44
 
45
45
  return false;
46
- }
46
+ } // Clear the pasted cells column widths so that it maintains
47
+ // the column widths of the destination table
48
+
49
+ const clearColumnWidthOfCells = cells => {
50
+ cells.rows.forEach(row => {
51
+ for (let i = 0; i < row.childCount; i++) {
52
+ row.child(i).attrs.colwidth = null;
53
+ }
54
+ });
55
+ return cells;
56
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "sideEffects": false
5
5
  }
@@ -26,7 +26,7 @@ export function handlePaste(view, event, slice) {
26
26
  var start = sel.$anchorCell.start(-1);
27
27
  var rect = TableMap.get(table).rectBetween(sel.$anchorCell.pos - start, sel.$headCell.pos - start);
28
28
  cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);
29
- insertCells(view.state, view.dispatch, start, rect, cells);
29
+ insertCells(view.state, view.dispatch, start, rect, clearColumnWidthOfCells(cells));
30
30
  return true;
31
31
  }
32
32
 
@@ -39,9 +39,19 @@ export function handlePaste(view, event, slice) {
39
39
 
40
40
  var _start = $cell.start(-1);
41
41
 
42
- insertCells(view.state, view.dispatch, _start, TableMap.get($cell.node(-1)).findCell($cell.pos - _start), cells);
42
+ insertCells(view.state, view.dispatch, _start, TableMap.get($cell.node(-1)).findCell($cell.pos - _start), clearColumnWidthOfCells(cells));
43
43
  return true;
44
44
  }
45
45
 
46
46
  return false;
47
- }
47
+ } // Clear the pasted cells column widths so that it maintains
48
+ // the column widths of the destination table
49
+
50
+ var clearColumnWidthOfCells = function clearColumnWidthOfCells(cells) {
51
+ cells.rows.forEach(function (row) {
52
+ for (var i = 0; i < row.childCount; i++) {
53
+ row.child(i).attrs.colwidth = null;
54
+ }
55
+ });
56
+ return cells;
57
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "A package that contains common classes and utility functions for editor tables",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,8 +29,8 @@
29
29
  "prosemirror-view": "1.23.2"
30
30
  },
31
31
  "devDependencies": {
32
- "@atlaskit/adf-schema": "^22.0.0",
33
- "@atlaskit/editor-test-helpers": "^16.1.0",
32
+ "@atlaskit/adf-schema": "^22.1.0",
33
+ "@atlaskit/editor-test-helpers": "^17.0.0",
34
34
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1"
35
35
  },
36
36
  "techstack": {