@atlaskit/editor-tables 2.2.4 → 2.2.6

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.
Files changed (158) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/cell-bookmark.js +0 -10
  3. package/dist/cjs/cell-selection.js +37 -102
  4. package/dist/cjs/index.js +0 -4
  5. package/dist/cjs/pm-plugins/input.js +17 -83
  6. package/dist/cjs/pm-plugins/plugin-key.js +0 -2
  7. package/dist/cjs/pm-plugins/table-editing.js +17 -18
  8. package/dist/cjs/pm-plugins.js +0 -2
  9. package/dist/cjs/table-map.js +67 -138
  10. package/dist/cjs/utils/add-column-at.js +0 -9
  11. package/dist/cjs/utils/add-column.js +8 -24
  12. package/dist/cjs/utils/add-row-at.js +8 -37
  13. package/dist/cjs/utils/add-row.js +2 -23
  14. package/dist/cjs/utils/analytics-helpers.js +4 -15
  15. package/dist/cjs/utils/cells.js +0 -12
  16. package/dist/cjs/utils/clone-tr.js +0 -2
  17. package/dist/cjs/utils/colspan.js +2 -18
  18. package/dist/cjs/utils/copy-paste.js +51 -139
  19. package/dist/cjs/utils/create-table.js +14 -28
  20. package/dist/cjs/utils/draw-cell-selection.js +0 -4
  21. package/dist/cjs/utils/empty-cells.js +0 -6
  22. package/dist/cjs/utils/find.js +6 -18
  23. package/dist/cjs/utils/fix-tables.js +13 -56
  24. package/dist/cjs/utils/for-each-cell.js +3 -17
  25. package/dist/cjs/utils/get-cell-selection-ranges.js +2 -9
  26. package/dist/cjs/utils/get-cells-in-column.js +0 -7
  27. package/dist/cjs/utils/get-cells-in-row.js +0 -7
  28. package/dist/cjs/utils/get-cells-in-table.js +0 -8
  29. package/dist/cjs/utils/get-selection-range-in-column.js +6 -27
  30. package/dist/cjs/utils/get-selection-range-in-row.js +6 -27
  31. package/dist/cjs/utils/get-selection-rect.js +0 -7
  32. package/dist/cjs/utils/go-to-next-cell.js +3 -22
  33. package/dist/cjs/utils/handle-paste.js +5 -34
  34. package/dist/cjs/utils/is-selected.js +6 -23
  35. package/dist/cjs/utils/is-selection-type.js +0 -2
  36. package/dist/cjs/utils/move-column.js +0 -12
  37. package/dist/cjs/utils/move-row.js +0 -11
  38. package/dist/cjs/utils/normalize-selection.js +3 -27
  39. package/dist/cjs/utils/remove-column.js +10 -46
  40. package/dist/cjs/utils/remove-row.js +8 -49
  41. package/dist/cjs/utils/remove-table.js +0 -6
  42. package/dist/cjs/utils/reorder-utils.js +13 -37
  43. package/dist/cjs/utils/replace-table.js +0 -8
  44. package/dist/cjs/utils/select-nodes.js +11 -31
  45. package/dist/cjs/utils/selection-cell.js +0 -5
  46. package/dist/cjs/utils/selection-rect.js +0 -10
  47. package/dist/cjs/utils/set-cell-attrs.js +0 -4
  48. package/dist/cjs/utils/split-cell-with-type.js +2 -35
  49. package/dist/cjs/utils/split-cell.js +0 -4
  50. package/dist/cjs/utils/table-node-types.js +4 -8
  51. package/dist/cjs/utils/tables.js +0 -4
  52. package/dist/cjs/utils/test-utils.js +9 -26
  53. package/dist/cjs/utils/toggle-header.js +3 -16
  54. package/dist/cjs/utils/uuid.js +0 -3
  55. package/dist/cjs/utils.js +0 -42
  56. package/dist/cjs/version.json +1 -1
  57. package/dist/es2019/cell-bookmark.js +0 -5
  58. package/dist/es2019/cell-selection.js +37 -81
  59. package/dist/es2019/index.js +1 -0
  60. package/dist/es2019/pm-plugins/input.js +15 -67
  61. package/dist/es2019/pm-plugins/table-editing.js +3 -12
  62. package/dist/es2019/table-map.js +57 -127
  63. package/dist/es2019/utils/add-column-at.js +2 -4
  64. package/dist/es2019/utils/add-column.js +6 -16
  65. package/dist/es2019/utils/add-row-at.js +8 -22
  66. package/dist/es2019/utils/add-row.js +2 -17
  67. package/dist/es2019/utils/analytics-helpers.js +0 -5
  68. package/dist/es2019/utils/cells.js +4 -9
  69. package/dist/es2019/utils/colspan.js +6 -11
  70. package/dist/es2019/utils/copy-paste.js +41 -115
  71. package/dist/es2019/utils/create-table.js +3 -12
  72. package/dist/es2019/utils/draw-cell-selection.js +0 -1
  73. package/dist/es2019/utils/empty-cells.js +2 -3
  74. package/dist/es2019/utils/find.js +8 -8
  75. package/dist/es2019/utils/fix-tables.js +17 -47
  76. package/dist/es2019/utils/for-each-cell.js +6 -11
  77. package/dist/es2019/utils/get-cell-selection-ranges.js +2 -4
  78. package/dist/es2019/utils/get-cells-in-column.js +2 -3
  79. package/dist/es2019/utils/get-cells-in-row.js +2 -3
  80. package/dist/es2019/utils/get-cells-in-table.js +2 -4
  81. package/dist/es2019/utils/get-selection-range-in-column.js +8 -22
  82. package/dist/es2019/utils/get-selection-range-in-row.js +8 -22
  83. package/dist/es2019/utils/get-selection-rect.js +2 -2
  84. package/dist/es2019/utils/go-to-next-cell.js +3 -19
  85. package/dist/es2019/utils/handle-paste.js +3 -14
  86. package/dist/es2019/utils/is-selected.js +8 -10
  87. package/dist/es2019/utils/is-selection-type.js +0 -1
  88. package/dist/es2019/utils/move-column.js +3 -8
  89. package/dist/es2019/utils/move-row.js +3 -7
  90. package/dist/es2019/utils/normalize-selection.js +0 -16
  91. package/dist/es2019/utils/remove-column.js +10 -27
  92. package/dist/es2019/utils/remove-row.js +12 -32
  93. package/dist/es2019/utils/remove-table.js +2 -4
  94. package/dist/es2019/utils/reorder-utils.js +11 -26
  95. package/dist/es2019/utils/replace-table.js +0 -2
  96. package/dist/es2019/utils/select-nodes.js +9 -20
  97. package/dist/es2019/utils/selection-cell.js +0 -2
  98. package/dist/es2019/utils/selection-rect.js +0 -4
  99. package/dist/es2019/utils/set-cell-attrs.js +2 -2
  100. package/dist/es2019/utils/split-cell-with-type.js +8 -28
  101. package/dist/es2019/utils/split-cell.js +3 -2
  102. package/dist/es2019/utils/table-node-types.js +4 -7
  103. package/dist/es2019/utils/tables.js +0 -2
  104. package/dist/es2019/utils/test-utils.js +12 -16
  105. package/dist/es2019/utils/toggle-header.js +3 -10
  106. package/dist/es2019/utils/uuid.js +0 -2
  107. package/dist/es2019/version.json +1 -1
  108. package/dist/esm/cell-bookmark.js +0 -5
  109. package/dist/esm/cell-selection.js +37 -79
  110. package/dist/esm/index.js +1 -0
  111. package/dist/esm/pm-plugins/input.js +17 -71
  112. package/dist/esm/pm-plugins/table-editing.js +8 -13
  113. package/dist/esm/table-map.js +68 -133
  114. package/dist/esm/utils/add-column-at.js +2 -4
  115. package/dist/esm/utils/add-column.js +8 -20
  116. package/dist/esm/utils/add-row-at.js +8 -23
  117. package/dist/esm/utils/add-row.js +2 -21
  118. package/dist/esm/utils/analytics-helpers.js +4 -10
  119. package/dist/esm/utils/cells.js +0 -5
  120. package/dist/esm/utils/colspan.js +2 -14
  121. package/dist/esm/utils/copy-paste.js +44 -125
  122. package/dist/esm/utils/create-table.js +14 -25
  123. package/dist/esm/utils/draw-cell-selection.js +0 -1
  124. package/dist/esm/utils/empty-cells.js +2 -3
  125. package/dist/esm/utils/find.js +8 -8
  126. package/dist/esm/utils/fix-tables.js +13 -49
  127. package/dist/esm/utils/for-each-cell.js +6 -11
  128. package/dist/esm/utils/get-cell-selection-ranges.js +2 -4
  129. package/dist/esm/utils/get-cells-in-column.js +2 -3
  130. package/dist/esm/utils/get-cells-in-row.js +2 -3
  131. package/dist/esm/utils/get-cells-in-table.js +2 -4
  132. package/dist/esm/utils/get-selection-range-in-column.js +8 -24
  133. package/dist/esm/utils/get-selection-range-in-row.js +8 -24
  134. package/dist/esm/utils/get-selection-rect.js +2 -2
  135. package/dist/esm/utils/go-to-next-cell.js +3 -19
  136. package/dist/esm/utils/handle-paste.js +5 -23
  137. package/dist/esm/utils/is-selected.js +8 -10
  138. package/dist/esm/utils/is-selection-type.js +0 -1
  139. package/dist/esm/utils/move-column.js +3 -8
  140. package/dist/esm/utils/move-row.js +3 -7
  141. package/dist/esm/utils/normalize-selection.js +3 -22
  142. package/dist/esm/utils/remove-column.js +10 -31
  143. package/dist/esm/utils/remove-row.js +8 -35
  144. package/dist/esm/utils/remove-table.js +2 -4
  145. package/dist/esm/utils/reorder-utils.js +11 -26
  146. package/dist/esm/utils/replace-table.js +0 -2
  147. package/dist/esm/utils/select-nodes.js +11 -22
  148. package/dist/esm/utils/selection-cell.js +0 -2
  149. package/dist/esm/utils/selection-rect.js +0 -4
  150. package/dist/esm/utils/set-cell-attrs.js +2 -2
  151. package/dist/esm/utils/split-cell-with-type.js +2 -28
  152. package/dist/esm/utils/split-cell.js +3 -2
  153. package/dist/esm/utils/table-node-types.js +4 -7
  154. package/dist/esm/utils/tables.js +0 -2
  155. package/dist/esm/utils/test-utils.js +12 -16
  156. package/dist/esm/utils/toggle-header.js +3 -10
  157. package/dist/esm/version.json +1 -1
  158. package/package.json +6 -4
@@ -7,12 +7,10 @@ import { findTable } from './find';
7
7
  import { getCellsInRow } from './get-cells-in-row';
8
8
  import { setCellAttrs } from './set-cell-attrs';
9
9
  import { tableNodeTypes } from './table-node-types';
10
-
11
10
  var filterCellsInRow = function filterCellsInRow(rowIndex, predicate) {
12
11
  return function (tr) {
13
12
  var foundCells = [];
14
13
  var cells = getCellsInRow(rowIndex)(tr.selection);
15
-
16
14
  if (cells) {
17
15
  for (var j = cells.length - 1; j >= 0; j--) {
18
16
  if (predicate(cells[j], tr)) {
@@ -20,30 +18,25 @@ var filterCellsInRow = function filterCellsInRow(rowIndex, predicate) {
20
18
  }
21
19
  }
22
20
  }
23
-
24
21
  return foundCells;
25
22
  };
26
- }; // Returns a new transaction that adds a new row after `cloneRowIndex`, cloning the row attributes at `cloneRowIndex`.
27
-
23
+ };
28
24
 
25
+ // Returns a new transaction that adds a new row after `cloneRowIndex`, cloning the row attributes at `cloneRowIndex`.
29
26
  export var cloneRowAt = function cloneRowAt(rowIndex) {
30
27
  return function (tr) {
31
28
  var table = findTable(tr.selection);
32
-
33
29
  if (table) {
34
30
  var map = TableMap.get(table.node);
35
-
36
31
  if (rowIndex >= 0 && rowIndex <= map.height) {
37
32
  var tableNode = table.node;
38
33
  var tableNodes = tableNodeTypes(tableNode.type.schema);
39
34
  var rowPos = table.start;
40
-
41
35
  for (var i = 0; i < rowIndex + 1; i++) {
42
36
  rowPos += tableNode.child(i).nodeSize;
43
37
  }
44
-
45
- var cloneRow = tableNode.child(rowIndex); // Re-create the same nodes with same attrs, dropping the node content.
46
-
38
+ var cloneRow = tableNode.child(rowIndex);
39
+ // Re-create the same nodes with same attrs, dropping the node content.
47
40
  var cells = [];
48
41
  var rowWidth = 0;
49
42
  cloneRow.forEach(function (cell) {
@@ -52,16 +45,15 @@ export var cloneRowAt = function cloneRowAt(rowIndex) {
52
45
  if (cell.attrs.rowspan === 1) {
53
46
  rowWidth += cell.attrs.colspan;
54
47
  var node = tableNodes[cell.type.spec.tableRole].createAndFill(cell.attrs, [], cell.marks);
55
-
56
48
  if (node) {
57
49
  cells.push(node);
58
50
  }
59
51
  }
60
- }); // If a higher row spans past our clone row, bump the higher row to cover this new row too.
52
+ });
61
53
 
54
+ // If a higher row spans past our clone row, bump the higher row to cover this new row too.
62
55
  if (rowWidth < map.width) {
63
56
  var rowSpanCells = [];
64
-
65
57
  var _loop = function _loop(_i) {
66
58
  var foundCells = filterCellsInRow(_i, function (cell, tr) {
67
59
  var rowspan = cell.node.attrs.rowspan;
@@ -70,11 +62,9 @@ export var cloneRowAt = function cloneRowAt(rowIndex) {
70
62
  })(tr);
71
63
  rowSpanCells.push.apply(rowSpanCells, _toConsumableArray(foundCells));
72
64
  };
73
-
74
65
  for (var _i = rowIndex; _i >= 0; _i--) {
75
66
  _loop(_i);
76
67
  }
77
-
78
68
  if (rowSpanCells.length) {
79
69
  rowSpanCells.forEach(function (cell) {
80
70
  tr = setCellAttrs(cell, {
@@ -83,27 +73,23 @@ export var cloneRowAt = function cloneRowAt(rowIndex) {
83
73
  });
84
74
  }
85
75
  }
86
-
87
76
  return safeInsert(tableNodes.row.create(cloneRow.attrs, cells), rowPos)(tr);
88
77
  }
89
78
  }
90
-
91
79
  return tr;
92
80
  };
93
- }; // Returns a new transaction that adds a new row at index `rowIndex`. Optionally clone the previous row.
81
+ };
94
82
 
83
+ // Returns a new transaction that adds a new row at index `rowIndex`. Optionally clone the previous row.
95
84
  export var addRowAt = function addRowAt(rowIndex, clonePreviousRow) {
96
85
  return function (tr) {
97
86
  var table = findTable(tr.selection);
98
-
99
87
  if (table) {
100
88
  var map = TableMap.get(table.node);
101
89
  var cloneRowIndex = rowIndex - 1;
102
-
103
90
  if (clonePreviousRow && cloneRowIndex >= 0) {
104
91
  return cloneTr(cloneRowAt(cloneRowIndex)(tr));
105
92
  }
106
-
107
93
  if (rowIndex >= 0 && rowIndex <= map.height) {
108
94
  return cloneTr(addRow(tr, {
109
95
  map: map,
@@ -112,7 +98,6 @@ export var addRowAt = function addRowAt(rowIndex, clonePreviousRow) {
112
98
  }, rowIndex));
113
99
  }
114
100
  }
115
-
116
101
  return tr;
117
102
  };
118
103
  };
@@ -1,52 +1,38 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
4
  import { tableNodeTypes } from './table-node-types';
8
-
9
5
  function rowIsHeader(map, table, row) {
10
6
  var headerCell = tableNodeTypes(table.type.schema).header_cell;
11
-
12
7
  for (var col = 0; col < map.width; col++) {
13
8
  var cell = table.nodeAt(map.map[col + row * map.width]);
14
-
15
9
  if (cell && cell.type !== headerCell) {
16
10
  return false;
17
11
  }
18
12
  }
19
-
20
13
  return true;
21
14
  }
22
-
23
15
  export function addRow(tr, _ref, row) {
24
16
  var map = _ref.map,
25
- tableStart = _ref.tableStart,
26
- table = _ref.table;
17
+ tableStart = _ref.tableStart,
18
+ table = _ref.table;
27
19
  var rowPos = tableStart;
28
-
29
20
  for (var i = 0; i < row; i++) {
30
21
  rowPos += table.child(i).nodeSize;
31
22
  }
32
-
33
23
  var cells = [];
34
24
  var refRow = row > 0 ? -1 : 0;
35
-
36
25
  if (rowIsHeader(map, table, row + refRow)) {
37
26
  refRow = row === 0 || row === map.height ? null : 0;
38
27
  }
39
-
40
28
  for (var col = 0, index = map.width * row; col < map.width; col++, index++) {
41
29
  // Covered by a rowspan cell
42
30
  if (row > 0 && row < map.height && map.map[index] === map.map[index - map.width]) {
43
31
  var pos = map.map[index];
44
32
  var node = table.nodeAt(pos);
45
-
46
33
  if (!node) {
47
34
  throw new Error("addRow: node not found at pos ".concat(pos));
48
35
  }
49
-
50
36
  var attrs = node.attrs;
51
37
  tr.setNodeMarkup(tableStart + pos, undefined, _objectSpread(_objectSpread({}, attrs), {}, {
52
38
  rowspan: attrs.rowspan + 1
@@ -54,24 +40,19 @@ export function addRow(tr, _ref, row) {
54
40
  col += attrs.colspan - 1;
55
41
  } else {
56
42
  var type = void 0;
57
-
58
43
  if (refRow == null) {
59
44
  type = tableNodeTypes(table.type.schema).cell;
60
45
  } else {
61
46
  var mappedPos = map.map[index + refRow * map.width];
62
47
  var cell = table.nodeAt(mappedPos);
63
-
64
48
  if (!cell) {
65
49
  throw new Error("addRow: invalid node at mapped pos ".concat(mappedPos));
66
50
  }
67
-
68
51
  type = cell.type;
69
52
  }
70
-
71
53
  cells.push(type.createAndFill());
72
54
  }
73
55
  }
74
-
75
56
  var rowType = tableNodeTypes(table.type.schema).row;
76
57
  var rowCells = rowType.create(null, cells);
77
58
  tr.insert(rowPos, rowCells);
@@ -6,13 +6,11 @@ export function getSelectedTableInfo(selection) {
6
6
  var totalRowCount = 0;
7
7
  var totalColumnCount = 0;
8
8
  var table = findTable(selection);
9
-
10
9
  if (table) {
11
10
  map = TableMap.get(table.node);
12
11
  totalRowCount = map.height;
13
12
  totalColumnCount = map.width;
14
13
  }
15
-
16
14
  return {
17
15
  table: table,
18
16
  map: map,
@@ -24,23 +22,19 @@ export function getSelectedCellInfo(selection) {
24
22
  var horizontalCells = 1;
25
23
  var verticalCells = 1;
26
24
  var totalCells = 1;
27
-
28
25
  var _getSelectedTableInfo = getSelectedTableInfo(selection),
29
- table = _getSelectedTableInfo.table,
30
- map = _getSelectedTableInfo.map,
31
- totalRowCount = _getSelectedTableInfo.totalRowCount,
32
- totalColumnCount = _getSelectedTableInfo.totalColumnCount;
33
-
26
+ table = _getSelectedTableInfo.table,
27
+ map = _getSelectedTableInfo.map,
28
+ totalRowCount = _getSelectedTableInfo.totalRowCount,
29
+ totalColumnCount = _getSelectedTableInfo.totalColumnCount;
34
30
  if (table && map) {
35
31
  var rect = getSelectionRect(selection);
36
-
37
32
  if (rect) {
38
33
  totalCells = map.cellsInRect(rect).length;
39
34
  horizontalCells = rect.right - rect.left;
40
35
  verticalCells = rect.bottom - rect.top;
41
36
  }
42
37
  }
43
-
44
38
  return {
45
39
  totalRowCount: totalRowCount,
46
40
  totalColumnCount: totalColumnCount,
@@ -5,20 +5,16 @@ export function pointsAtCell($pos) {
5
5
  export function cellNear($pos) {
6
6
  for (var after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {
7
7
  var role = after.type.spec.tableRole;
8
-
9
8
  if (role === 'cell' || role === 'header_cell') {
10
9
  return $pos.doc.resolve(pos);
11
10
  }
12
11
  }
13
-
14
12
  for (var before = $pos.nodeBefore, _pos = $pos.pos; before; before = before.lastChild, _pos--) {
15
13
  var _role = before.type.spec.tableRole;
16
-
17
14
  if (_role === 'cell' || _role === 'header_cell') {
18
15
  return $pos.doc.resolve(_pos - before.nodeSize);
19
16
  }
20
17
  }
21
-
22
18
  return null;
23
19
  }
24
20
  export function cellAround($pos) {
@@ -27,7 +23,6 @@ export function cellAround($pos) {
27
23
  return $pos.node(0).resolve($pos.before(d + 1));
28
24
  }
29
25
  }
30
-
31
26
  return null;
32
27
  }
33
28
  export function nextCell($pos, axis, dir) {
@@ -1,58 +1,46 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
4
  export function removeColSpan(attrs, pos) {
8
5
  var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
9
-
10
6
  if (!attrs.colspan) {
11
7
  throw new Error('removeColSpan(): attrs.colspan not defined');
12
8
  }
13
-
14
9
  var result = _objectSpread(_objectSpread({}, attrs), {}, {
15
10
  colspan: attrs.colspan - n
16
11
  });
17
-
18
12
  if (result.colwidth) {
19
13
  result.colwidth = result.colwidth.slice();
20
14
  result.colwidth.splice(pos, n);
21
-
22
15
  if (!result.colwidth.some(function (w) {
23
16
  return w > 0;
24
17
  })) {
25
18
  result.colwidth = undefined;
26
19
  }
27
20
  }
28
-
29
21
  return result;
30
22
  }
31
23
  export function assertColspan(attrs) {
32
24
  if (typeof attrs.colspan === 'undefined') {
33
25
  throw new Error('addColSpan: attrs.colspan is not defined');
34
26
  }
35
-
36
27
  if (typeof attrs.colspan !== 'number' || Number.isNaN(attrs.colspan) || attrs.colspan < 1) {
37
28
  throw new Error("addColSpan: attrs.colspan must be number >= 1, received: ".concat(attrs.colspan));
38
29
  }
39
- } // TODO: replace "addColSpan" from table plugin with this function
30
+ }
40
31
 
32
+ // TODO: replace "addColSpan" from table plugin with this function
41
33
  export function addColSpan(attrs, pos) {
42
34
  var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
43
35
  assertColspan(attrs);
44
-
45
36
  var result = _objectSpread(_objectSpread({}, attrs), {}, {
46
37
  colspan: attrs.colspan + n
47
38
  });
48
-
49
39
  if (result.colwidth) {
50
40
  result.colwidth = result.colwidth.slice();
51
-
52
41
  for (var i = 0; i < n; i++) {
53
42
  result.colwidth.splice(pos, 0, 0);
54
43
  }
55
44
  }
56
-
57
45
  return result;
58
46
  }