@atlaskit/editor-tables 2.8.2 → 2.8.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/afm-cc/tsconfig.json +5 -1
  3. package/afm-jira/tsconfig.json +5 -1
  4. package/afm-post-office/tsconfig.json +5 -1
  5. package/dist/cjs/cell-bookmark.js +3 -2
  6. package/dist/cjs/cell-selection.js +17 -8
  7. package/dist/cjs/pm-plugins/input.js +23 -4
  8. package/dist/cjs/table-map.js +21 -9
  9. package/dist/cjs/utils/add-column.js +2 -0
  10. package/dist/cjs/utils/add-row.js +2 -0
  11. package/dist/cjs/utils/clone-column.js +7 -0
  12. package/dist/cjs/utils/clone-row.js +2 -0
  13. package/dist/cjs/utils/copy-paste.js +29 -1
  14. package/dist/cjs/utils/find.js +5 -1
  15. package/dist/cjs/utils/fix-tables.js +8 -1
  16. package/dist/cjs/utils/get-cells-in-column.js +2 -0
  17. package/dist/cjs/utils/get-cells-in-row.js +2 -0
  18. package/dist/cjs/utils/move-column.js +9 -1
  19. package/dist/cjs/utils/move-row.js +2 -0
  20. package/dist/cjs/utils/normalize-selection.js +2 -0
  21. package/dist/cjs/utils/reorder-utils.js +20 -4
  22. package/dist/cjs/utils/split-cell-with-type.js +3 -3
  23. package/dist/cjs/utils/uuid.js +8 -4
  24. package/dist/es2019/cell-bookmark.js +3 -0
  25. package/dist/es2019/cell-selection.js +14 -1
  26. package/dist/es2019/index.js +3 -0
  27. package/dist/es2019/pm-plugins/input.js +23 -4
  28. package/dist/es2019/pm-plugins.js +3 -0
  29. package/dist/es2019/table-map.js +53 -41
  30. package/dist/es2019/utils/add-column.js +2 -0
  31. package/dist/es2019/utils/add-row-at.js +4 -4
  32. package/dist/es2019/utils/add-row.js +2 -0
  33. package/dist/es2019/utils/clone-column.js +11 -1
  34. package/dist/es2019/utils/clone-row.js +7 -2
  35. package/dist/es2019/utils/copy-paste.js +29 -1
  36. package/dist/es2019/utils/find.js +4 -1
  37. package/dist/es2019/utils/fix-tables.js +8 -1
  38. package/dist/es2019/utils/get-cells-in-column.js +2 -0
  39. package/dist/es2019/utils/get-cells-in-row.js +2 -0
  40. package/dist/es2019/utils/get-selection-range-in-column.js +2 -2
  41. package/dist/es2019/utils/get-selection-range-in-row.js +2 -2
  42. package/dist/es2019/utils/move-column.js +13 -2
  43. package/dist/es2019/utils/move-row.js +7 -2
  44. package/dist/es2019/utils/normalize-selection.js +2 -0
  45. package/dist/es2019/utils/remove-row.js +3 -3
  46. package/dist/es2019/utils/remove-table.js +1 -1
  47. package/dist/es2019/utils/reorder-utils.js +21 -5
  48. package/dist/es2019/utils/replace-table.js +1 -1
  49. package/dist/es2019/utils/split-cell-with-type.js +6 -6
  50. package/dist/es2019/utils/toggle-header.js +6 -6
  51. package/dist/es2019/utils/uuid.js +4 -1
  52. package/dist/es2019/utils.js +3 -0
  53. package/dist/esm/cell-bookmark.js +4 -2
  54. package/dist/esm/cell-selection.js +18 -7
  55. package/dist/esm/index.js +3 -0
  56. package/dist/esm/pm-plugins/input.js +23 -4
  57. package/dist/esm/pm-plugins.js +3 -0
  58. package/dist/esm/table-map.js +21 -9
  59. package/dist/esm/utils/add-column.js +2 -0
  60. package/dist/esm/utils/add-row.js +2 -0
  61. package/dist/esm/utils/clone-column.js +7 -0
  62. package/dist/esm/utils/clone-row.js +2 -0
  63. package/dist/esm/utils/copy-paste.js +29 -1
  64. package/dist/esm/utils/find.js +5 -1
  65. package/dist/esm/utils/fix-tables.js +8 -1
  66. package/dist/esm/utils/get-cells-in-column.js +2 -0
  67. package/dist/esm/utils/get-cells-in-row.js +2 -0
  68. package/dist/esm/utils/move-column.js +9 -1
  69. package/dist/esm/utils/move-row.js +2 -0
  70. package/dist/esm/utils/normalize-selection.js +2 -0
  71. package/dist/esm/utils/reorder-utils.js +20 -4
  72. package/dist/esm/utils/split-cell-with-type.js +3 -3
  73. package/dist/esm/utils/uuid.js +8 -4
  74. package/dist/esm/utils.js +3 -0
  75. package/package.json +8 -2
  76. package/tsconfig.json +0 -1
@@ -33,7 +33,11 @@ var _tableMap = require("../table-map");
33
33
  // ['a3', 'b3', 'c3', 'd3'],
34
34
  // ]
35
35
  // ```
36
+ // Ignored via go/ees005
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
38
  var transpose = exports.transpose = function transpose(array) {
39
+ // Ignored via go/ees005
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
41
  return array[0].map(function (_, i) {
38
42
  return array.map(function (column) {
39
43
  return column[i];
@@ -91,7 +95,10 @@ var convertArrayOfRowsToTableNode = exports.convertArrayOfRowsToTableNode = func
91
95
  var newTable = tableNode.type.createChecked(tableNode.attrs, rowsPM, tableNode.marks);
92
96
  return newTable;
93
97
  };
94
- var moveRowInArrayOfRows = function moveRowInArrayOfRows(arrayOfNodes, indexesOrigin, indexesTarget, directionOverride) {
98
+ var moveRowInArrayOfRows = function moveRowInArrayOfRows(arrayOfNodes, indexesOrigin, indexesTarget, directionOverride
99
+ // Ignored via go/ees005
100
+ // eslint-disable-next-line @typescript-eslint/max-params
101
+ ) {
95
102
  var direction = indexesOrigin[0] > indexesTarget[0] ? -1 : 1;
96
103
  var rowsExtracted = arrayOfNodes.splice(indexesOrigin[0], indexesOrigin.length);
97
104
  var positionOffset = rowsExtracted.length % 2 === 0 ? 1 : 0;
@@ -156,18 +163,27 @@ var convertTableNodeToArrayOfRows = exports.convertTableNodeToArrayOfRows = func
156
163
  }
157
164
  return rows;
158
165
  };
159
- var moveTableRow = exports.moveTableRow = function moveTableRow(table, indexesOrigin, indexesTarget, direction) {
166
+ var moveTableRow = exports.moveTableRow = function moveTableRow(table, indexesOrigin, indexesTarget, direction
167
+ // Ignored via go/ees005
168
+ // eslint-disable-next-line @typescript-eslint/max-params
169
+ ) {
160
170
  var rows = convertTableNodeToArrayOfRows(table.node);
161
171
  rows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction);
162
172
  return convertArrayOfRowsToTableNode(table.node, rows);
163
173
  };
164
- var moveTableColumn = exports.moveTableColumn = function moveTableColumn(table, indexesOrigin, indexesTarget, direction) {
174
+ var moveTableColumn = exports.moveTableColumn = function moveTableColumn(table, indexesOrigin, indexesTarget, direction
175
+ // Ignored via go/ees005
176
+ // eslint-disable-next-line @typescript-eslint/max-params
177
+ ) {
165
178
  var rows = transpose(convertTableNodeToArrayOfRows(table.node));
166
179
  rows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction);
167
180
  rows = transpose(rows);
168
181
  return convertArrayOfRowsToTableNode(table.node, rows);
169
182
  };
170
- var isValidReorder = exports.isValidReorder = function isValidReorder(originIndex, targetIndex, targets, type) {
183
+ var isValidReorder = exports.isValidReorder = function isValidReorder(originIndex, targetIndex, targets, type
184
+ // Ignored via go/ees005
185
+ // eslint-disable-next-line @typescript-eslint/max-params
186
+ ) {
171
187
  var direction = originIndex > targetIndex ? -1 : 1;
172
188
  var errorMessage = "Target position is invalid, you can't move the ".concat(type, " ").concat(originIndex, " to ").concat(targetIndex, ", the target can't be split. You could use tryToFit option.");
173
189
  if (direction === 1) {
@@ -47,9 +47,9 @@ function splitCellWithType(getCellType) {
47
47
  return false;
48
48
  }
49
49
  if (cellNode && dispatch) {
50
- var cellAttrs = cellNode.attrs,
51
- attrs = [],
52
- colwidth = cellAttrs.colwidth;
50
+ var cellAttrs = cellNode.attrs;
51
+ var attrs = [];
52
+ var colwidth = cellAttrs.colwidth;
53
53
  if (cellAttrs.rowspan && cellAttrs.rowspan > 1) {
54
54
  cellAttrs = _objectSpread(_objectSpread({}, cellAttrs), {}, {
55
55
  rowspan: 1
@@ -11,10 +11,14 @@ exports.uuid = exports.generateUuid = void 0;
11
11
 
12
12
  /* eslint-disable no-bitwise */
13
13
  var generateUuid = exports.generateUuid = function generateUuid() {
14
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
15
- var r = Math.random() * 16 | 0;
16
- return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
17
- });
14
+ return (
15
+ // Ignored via go/ees005
16
+ // eslint-disable-next-line require-unicode-regexp
17
+ 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
18
+ var r = Math.random() * 16 | 0;
19
+ return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
20
+ })
21
+ );
18
22
  };
19
23
  /* eslint-enable no-bitwise */
20
24
 
@@ -1,3 +1,6 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ // Entry file in package.json
3
+
1
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
2
5
  import { inSameTable } from './utils/tables';
3
6
  export class CellBookmark {
@@ -1,3 +1,6 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ // Entry file in package.json
3
+
1
4
  // Was copied from https://github.com/ProseMirror/prosemirror-tables/blob/master/src/cellselection.js
2
5
 
3
6
  // This file defines a ProseMirror selection subclass that models
@@ -89,6 +92,8 @@ export class CellSelection extends Selection {
89
92
  attrs = removeColSpan(attrs, 0, extraLeft);
90
93
  }
91
94
  if (extraRight > 0) {
95
+ // Ignored via go/ees005
96
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
92
97
  attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);
93
98
  }
94
99
  if (cellRect.left < rect.left) {
@@ -169,7 +174,11 @@ export class CellSelection extends Selection {
169
174
  if (Math.min(anchorTop, headTop) > 0) {
170
175
  return false;
171
176
  }
177
+ // Ignored via go/ees005
178
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
172
179
  const anchorBot = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;
180
+ // Ignored via go/ees005
181
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
173
182
  const headBot = headTop + this.$headCell.nodeAfter.attrs.rowspan;
174
183
  return Math.max(anchorBot, headBot) === this.$headCell.node(-1).childCount;
175
184
  }
@@ -218,7 +227,7 @@ export class CellSelection extends Selection {
218
227
 
219
228
  // if anchor and head in the same line, counting how many cells
220
229
  // should be in the row except merged cell
221
- let maxColumnInSelectedRow = map.getMaxColInRow(this.$anchorCell);
230
+ const maxColumnInSelectedRow = map.getMaxColInRow(this.$anchorCell);
222
231
 
223
232
  // if selected cells less than table max column amount, and
224
233
  // the anchor/head not in a merged cell
@@ -234,7 +243,11 @@ export class CellSelection extends Selection {
234
243
  if (Math.min(anchorLeft, headLeft) > 0) {
235
244
  return false;
236
245
  }
246
+ // Ignored via go/ees005
247
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
237
248
  const anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;
249
+ // Ignored via go/ees005
250
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
238
251
  const headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
239
252
  return Math.max(anchorRight, headRight) === map.width;
240
253
  }
@@ -1,3 +1,6 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ // Entry file in package.json
3
+
1
4
  /**
2
5
  This package is based on prosemirror-tables, https://github.com/ProseMirror/prosemirror-tables
3
6
 
@@ -107,6 +107,8 @@ function deleteCellSelection(state, dispatch) {
107
107
  const {
108
108
  tr
109
109
  } = state;
110
+ // Ignored via go/ees005
111
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
110
112
  const baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;
111
113
  sel.forEachCell((cell, pos) => {
112
114
  if (!cell.content.eq(baseContent)) {
@@ -137,18 +139,23 @@ export function handleMouseDown(view, event, dragAndDropEnabled) {
137
139
  ) {
138
140
  return false;
139
141
  }
142
+
143
+ // Ignored via go/ees005
144
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
140
145
  const startDOMCell = domInCell(view, startEvent.target);
141
146
  const $anchor = cellAround(view.state.selection.$anchor);
142
147
  if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
143
- let isDragHandleElement;
144
148
  const targetElement = event.target instanceof HTMLElement || event.target instanceof SVGElement ? event.target : null;
145
- isDragHandleElement = !!targetElement && !!targetElement.closest('button.pm-table-drag-handle-button-container, button.pm-table-drag-handle-button-clickable-zone');
149
+ const isDragHandleElement = !!targetElement && !!targetElement.closest('button.pm-table-drag-handle-button-container, button.pm-table-drag-handle-button-clickable-zone');
146
150
  if (dragAndDropEnabled && isDragHandleElement) {
147
151
  return false;
148
152
  }
149
153
  setCellSelection(view.state.selection.$anchorCell, startEvent);
150
154
  startEvent.preventDefault();
151
- } else if (startEvent.shiftKey && startDOMCell && $anchor !== null && cellUnderMouse(view, startEvent).pos !== $anchor.pos) {
155
+ } else if (startEvent.shiftKey && startDOMCell && $anchor !== null &&
156
+ // Ignored via go/ees005
157
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
158
+ cellUnderMouse(view, startEvent).pos !== $anchor.pos) {
152
159
  // Adding to a selection that starts in another cell (causing a
153
160
  // cell selection to be created).
154
161
  setCellSelection($anchor, startEvent);
@@ -182,8 +189,14 @@ export function handleMouseDown(view, event, dragAndDropEnabled) {
182
189
 
183
190
  // Stop listening to mouse motion events.
184
191
  function stop() {
192
+ // Ignored via go/ees005
193
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
185
194
  view.root.removeEventListener('mouseup', stop);
195
+ // Ignored via go/ees005
196
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
186
197
  view.root.removeEventListener('dragstart', stop);
198
+ // Ignored via go/ees005
199
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
187
200
  view.root.removeEventListener('mousemove', move);
188
201
  if (tableEditingKey.getState(view.state) != null) {
189
202
  view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
@@ -195,6 +208,8 @@ export function handleMouseDown(view, event, dragAndDropEnabled) {
195
208
  if (anchor != null) {
196
209
  // Continuing an existing cross-cell selection
197
210
  $moveAnchor = view.state.doc.resolve(anchor);
211
+ // Ignored via go/ees005
212
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
198
213
  } else if (domInCell(view, event.target) !== startDOMCell) {
199
214
  // Moving out of the initial cell -- start a new cell selection
200
215
  $moveAnchor = cellUnderMouse(view, startEvent);
@@ -207,9 +222,13 @@ export function handleMouseDown(view, event, dragAndDropEnabled) {
207
222
  setCellSelection($moveAnchor, event);
208
223
  }
209
224
  }
225
+ // Ignored via go/ees005
226
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
210
227
  view.root.addEventListener('mouseup', stop);
211
- // eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
228
+ // eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop, @repo/internal/dom-events/no-unsafe-event-listeners
212
229
  view.root.addEventListener('dragstart', stop);
230
+ // Ignored via go/ees005
231
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
213
232
  view.root.addEventListener('mousemove', move);
214
233
  return false;
215
234
  }
@@ -1,2 +1,5 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ // Entry file in package.json
3
+
1
4
  export { tableEditing } from './pm-plugins/table-editing';
2
5
  export { tableEditingKey } from './pm-plugins/plugin-key';
@@ -1,4 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ /* eslint-disable @atlaskit/editor/no-re-export */
3
+ // Entry file in package.json
4
+
2
5
  // Because working with row and column-spanning cells is not quite
3
6
  // trivial, this code builds up a descriptive structure for a given
4
7
  // table node. The structures are cached with the (persistent) table
@@ -14,15 +17,17 @@ let readFromCache, addToCache;
14
17
  // Prefer using a weak map to cache table maps. Fall back on a
15
18
  // fixed-size cache if that's not supported.
16
19
  if (typeof WeakMap !== 'undefined') {
17
- let cache = new WeakMap();
20
+ const cache = new WeakMap();
18
21
  readFromCache = key => cache.get(key);
19
22
  addToCache = (key, value) => {
20
23
  cache.set(key, value);
21
24
  return value;
22
25
  };
23
26
  } else {
24
- let cache = [];
25
- let cacheSize = 10;
27
+ // Ignored via go/ees005
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ const cache = [];
30
+ const cacheSize = 10;
26
31
  let cachePos = 0;
27
32
  readFromCache = key => {
28
33
  for (let i = 0; i < cache.length; i += 2) {
@@ -40,6 +45,8 @@ if (typeof WeakMap !== 'undefined') {
40
45
  };
41
46
  }
42
47
  export class Rect {
48
+ // Ignored via go/ees005
49
+ // eslint-disable-next-line @typescript-eslint/max-params
43
50
  constructor(left, top, right, bottom) {
44
51
  this.left = left;
45
52
  this.top = top;
@@ -65,6 +72,8 @@ export const tableNewColumnMinWidth = 140;
65
72
  // be able to do that, positions saved in the map are relative to the
66
73
  // start of the table, rather than the start of the document.
67
74
  export class TableMap {
75
+ // Ignored via go/ees005
76
+ // eslint-disable-next-line @typescript-eslint/max-params
68
77
  constructor(width, height, map, problems, mapByColumn, mapByRow) {
69
78
  // The width of the table
70
79
  // The table's height
@@ -86,12 +95,12 @@ export class TableMap {
86
95
  // Find the dimensions of the cell at the given position.
87
96
  findCell(pos) {
88
97
  for (let i = 0; i < this.map.length; i++) {
89
- let curPos = this.map[i];
98
+ const curPos = this.map[i];
90
99
  if (curPos !== pos) {
91
100
  continue;
92
101
  }
93
- let left = i % this.width;
94
- let top = i / this.width | 0;
102
+ const left = i % this.width;
103
+ const top = i / this.width | 0;
95
104
  let right = left + 1;
96
105
  let bottom = top + 1;
97
106
  for (let j = 1; right < this.width && this.map[i + j] === curPos; j++) {
@@ -156,7 +165,7 @@ export class TableMap {
156
165
  // Find the next cell in the given direction, starting from the cell
157
166
  // at `pos`, if any.
158
167
  nextCell(pos, axis, dir) {
159
- let {
168
+ const {
160
169
  left,
161
170
  right,
162
171
  top,
@@ -178,13 +187,13 @@ export class TableMap {
178
187
  // :: (number, number) → Rect
179
188
  // Get the rectangle spanning the two given cells.
180
189
  rectBetween(a, b) {
181
- let {
190
+ const {
182
191
  left: leftA,
183
192
  right: rightA,
184
193
  top: topA,
185
194
  bottom: bottomA
186
195
  } = this.findCell(a);
187
- let {
196
+ const {
188
197
  left: leftB,
189
198
  right: rightB,
190
199
  top: topB,
@@ -197,12 +206,12 @@ export class TableMap {
197
206
  // Return the position of all cells that have the top left corner in
198
207
  // the given rectangle.
199
208
  cellsInRect(rect) {
200
- let result = [];
201
- let seen = {};
209
+ const result = [];
210
+ const seen = {};
202
211
  for (let row = rect.top; row < rect.bottom; row++) {
203
212
  for (let col = rect.left; col < rect.right; col++) {
204
- let index = row * this.width + col;
205
- let pos = this.map[index];
213
+ const index = row * this.width + col;
214
+ const pos = this.map[index];
206
215
  if (seen[pos]) {
207
216
  continue;
208
217
  }
@@ -220,10 +229,10 @@ export class TableMap {
220
229
  // starts, or would start, if a cell started there.
221
230
  positionAt(row, col, table) {
222
231
  for (let i = 0, rowStart = 0;; i++) {
223
- let rowEnd = rowStart + table.child(i).nodeSize;
232
+ const rowEnd = rowStart + table.child(i).nodeSize;
224
233
  if (i === row) {
225
234
  let index = col + row * this.width;
226
- let rowEndIndex = (row + 1) * this.width;
235
+ const rowEndIndex = (row + 1) * this.width;
227
236
  // Skip past cells from previous rows (via rowspan)
228
237
  while (index < rowEndIndex && this.map[index] < rowStart) {
229
238
  index++;
@@ -234,7 +243,7 @@ export class TableMap {
234
243
  }
235
244
  }
236
245
  getMaxColInRow(pos) {
237
- let parentRowNode = pos.parent;
246
+ const parentRowNode = pos.parent;
238
247
  if (parentRowNode.type.name === 'tableRow') {
239
248
  return parentRowNode.childCount;
240
249
  }
@@ -256,17 +265,17 @@ function computeMap(table) {
256
265
  if (table.type.spec.tableRole !== 'table') {
257
266
  throw new RangeError('Not a table node: ' + table.type.name);
258
267
  }
259
- let width = findWidth(table);
260
- let height = table.childCount;
261
- let map = [],
262
- mapPos = 0,
263
- problems = null,
264
- colWidths = [];
268
+ const width = findWidth(table);
269
+ const height = table.childCount;
270
+ const map = [];
271
+ const colWidths = [];
272
+ let mapPos = 0,
273
+ problems = null;
265
274
  for (let i = 0, e = width * height; i < e; i++) {
266
275
  map[i] = 0;
267
276
  }
268
277
  for (let row = 0, pos = 0; row < height; row++) {
269
- let rowNode = table.child(row);
278
+ const rowNode = table.child(row);
270
279
  pos++;
271
280
  for (let i = 0;; i++) {
272
281
  while (mapPos < map.length && map[mapPos] !== 0) {
@@ -275,7 +284,7 @@ function computeMap(table) {
275
284
  if (i === rowNode.childCount) {
276
285
  break;
277
286
  }
278
- let cellNode = rowNode.child(i),
287
+ const cellNode = rowNode.child(i),
279
288
  {
280
289
  colspan,
281
290
  rowspan,
@@ -290,7 +299,7 @@ function computeMap(table) {
290
299
  });
291
300
  break;
292
301
  }
293
- let start = mapPos + h * width;
302
+ const start = mapPos + h * width;
294
303
  for (let w = 0; w < colspan; w++) {
295
304
  if (map[start + w] === 0) {
296
305
  map[start + w] = pos;
@@ -302,9 +311,9 @@ function computeMap(table) {
302
311
  n: colspan - w
303
312
  });
304
313
  }
305
- let colW = colwidth && colwidth[w];
314
+ const colW = colwidth && colwidth[w];
306
315
  if (colW) {
307
- let widthIndex = (start + w) % width * 2,
316
+ const widthIndex = (start + w) % width * 2,
308
317
  prev = colWidths[widthIndex];
309
318
  if (prev == null || prev !== colW && colWidths[widthIndex + 1] === 1) {
310
319
  colWidths[widthIndex] = colW;
@@ -318,7 +327,7 @@ function computeMap(table) {
318
327
  mapPos += colspan;
319
328
  pos += cellNode.nodeSize;
320
329
  }
321
- let expectedPos = (row + 1) * width;
330
+ const expectedPos = (row + 1) * width;
322
331
  let missing = 0;
323
332
  while (mapPos < expectedPos) {
324
333
  if (map[mapPos++] === 0) {
@@ -334,8 +343,8 @@ function computeMap(table) {
334
343
  }
335
344
  pos++;
336
345
  }
337
- let mapByRow = Array(height);
338
- let mapByColumn = Array(width);
346
+ const mapByRow = Array(height);
347
+ const mapByColumn = Array(width);
339
348
  for (let i = 0; i < map.length; i++) {
340
349
  var _mapByColumn$columnIn, _mapByRow$rowIndex;
341
350
  const columnIndex = i % width;
@@ -345,7 +354,7 @@ function computeMap(table) {
345
354
  mapByRow[rowIndex] = (_mapByRow$rowIndex = mapByRow[rowIndex]) !== null && _mapByRow$rowIndex !== void 0 ? _mapByRow$rowIndex : [];
346
355
  mapByRow[rowIndex].push(map[i]);
347
356
  }
348
- let tableMap = new TableMap(width, height, map, problems, mapByColumn, mapByRow);
357
+ const tableMap = new TableMap(width, height, map, problems, mapByColumn, mapByRow);
349
358
  let badWidths = false;
350
359
 
351
360
  // For columns that have defined widths, but whose widths disagree
@@ -377,13 +386,13 @@ function findWidth(table) {
377
386
  let width = -1;
378
387
  let hasRowSpan = false;
379
388
  for (let row = 0; row < table.childCount; row++) {
380
- let rowNode = table.child(row);
389
+ const rowNode = table.child(row);
381
390
  let rowWidth = 0;
382
391
  if (hasRowSpan) {
383
392
  for (let j = 0; j < row; j++) {
384
- let prevRow = table.child(j);
393
+ const prevRow = table.child(j);
385
394
  for (let i = 0; i < prevRow.childCount; i++) {
386
- let cell = prevRow.child(i);
395
+ const cell = prevRow.child(i);
387
396
  if (j + cell.attrs.rowspan > row) {
388
397
  rowWidth += cell.attrs.colspan;
389
398
  }
@@ -391,7 +400,7 @@ function findWidth(table) {
391
400
  }
392
401
  }
393
402
  for (let i = 0; i < rowNode.childCount; i++) {
394
- let cell = rowNode.child(i);
403
+ const cell = rowNode.child(i);
395
404
  rowWidth += cell.attrs.colspan;
396
405
  if (cell.attrs.rowspan > 1) {
397
406
  hasRowSpan = true;
@@ -409,17 +418,17 @@ function findBadColWidths(map, colWidths, table) {
409
418
  if (!map.problems) {
410
419
  map.problems = [];
411
420
  }
412
- let seen = {};
421
+ const seen = {};
413
422
  for (let i = 0; i < map.map.length; i++) {
414
- let pos = map.map[i];
423
+ const pos = map.map[i];
415
424
  if (seen[pos]) {
416
425
  continue;
417
426
  }
418
427
  seen[pos] = true;
419
- let node = table.nodeAt(pos),
420
- updated = null;
428
+ const node = table.nodeAt(pos);
429
+ let updated = null;
421
430
  for (let j = 0; j < node.attrs.colspan; j++) {
422
- let col = (i + j) % map.width,
431
+ const col = (i + j) % map.width,
423
432
  colWidth = colWidths[col * 2];
424
433
  if (colWidth != null && (!node.attrs.colwidth || node.attrs.colwidth[j] !== colWidth)) {
425
434
  (updated || (updated = freshColWidth(node.attrs)))[j] = colWidth;
@@ -434,11 +443,14 @@ function findBadColWidths(map, colWidths, table) {
434
443
  }
435
444
  }
436
445
  }
446
+
447
+ // Ignored via go/ees005
448
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
437
449
  function freshColWidth(attrs) {
438
450
  if (attrs.colwidth) {
439
451
  return attrs.colwidth.slice();
440
452
  }
441
- let result = [];
453
+ const result = [];
442
454
  for (let i = 0; i < attrs.colspan; i++) {
443
455
  result.push(0);
444
456
  }
@@ -55,6 +55,8 @@ export function addColumn(tr, {
55
55
  }
56
56
  }
57
57
  const pos = map.positionAt(row, col, table);
58
+ // Ignored via go/ees005
59
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
58
60
  tr.insert(tr.mapping.map(tableStart + pos), type.createAndFill(attrs));
59
61
  }
60
62
  }
@@ -7,7 +7,7 @@ import { getCellsInRow } from './get-cells-in-row';
7
7
  import { setCellAttrs } from './set-cell-attrs';
8
8
  import { tableNodeTypes } from './table-node-types';
9
9
  const filterCellsInRow = (rowIndex, predicate) => tr => {
10
- let foundCells = [];
10
+ const foundCells = [];
11
11
  const cells = getCellsInRow(rowIndex)(tr.selection);
12
12
  if (cells) {
13
13
  for (let j = cells.length - 1; j >= 0; j--) {
@@ -33,7 +33,7 @@ export const cloneRowAt = rowIndex => tr => {
33
33
  }
34
34
  const cloneRow = tableNode.child(rowIndex);
35
35
  // Re-create the same nodes with same attrs, dropping the node content.
36
- let cells = [];
36
+ const cells = [];
37
37
  let rowWidth = 0;
38
38
  cloneRow.forEach(cell => {
39
39
  // If we're copying a row with rowspan somewhere, we dont want to copy that cell
@@ -49,9 +49,9 @@ export const cloneRowAt = rowIndex => tr => {
49
49
 
50
50
  // If a higher row spans past our clone row, bump the higher row to cover this new row too.
51
51
  if (rowWidth < map.width) {
52
- let rowSpanCells = [];
52
+ const rowSpanCells = [];
53
53
  for (let i = rowIndex; i >= 0; i--) {
54
- let foundCells = filterCellsInRow(i, (cell, tr) => {
54
+ const foundCells = filterCellsInRow(i, (cell, tr) => {
55
55
  const rowspan = cell.node.attrs.rowspan;
56
56
  const spanRange = i + rowspan;
57
57
  return rowspan > 1 && spanRange > rowIndex;
@@ -57,6 +57,8 @@ export function addRow(tr, {
57
57
  };
58
58
  }
59
59
  }
60
+ // Ignored via go/ees005
61
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
60
62
  cells.push(type.createAndFill(attrs));
61
63
  }
62
64
  }
@@ -15,7 +15,10 @@ export const cloneColumn = (state, originColumnIndex, targetColumnIndex, targetD
15
15
  tryToFit: false,
16
16
  direction: 0,
17
17
  selectAfterClone: false
18
- }) => tr => {
18
+ }
19
+ // Ignored via go/ees005
20
+ // eslint-disable-next-line @typescript-eslint/max-params
21
+ ) => tr => {
19
22
  var _originalColumnRanges, _targetColumnRanges$i;
20
23
  const table = findTable(tr.selection);
21
24
  if (!table) {
@@ -80,6 +83,8 @@ export const cloneColumn = (state, originColumnIndex, targetColumnIndex, targetD
80
83
  // The actual target index needs to be translated per row, this is because row/col spans can affect the amount of
81
84
  // cells each row contains.
82
85
  const rowTargetPosition = translateTargetPosition(y, actualTargetIndex, tableMap);
86
+ // Ignored via go/ees005
87
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
83
88
  const node = table.node.nodeAt(rowTargetPosition);
84
89
  const pos = table.start + rowTargetPosition;
85
90
  const insertPos = direction === 'end' ? newTr.mapping.map(pos + node.nodeSize, 1) : newTr.mapping.map(pos, -1);
@@ -96,12 +101,17 @@ export const cloneColumn = (state, originColumnIndex, targetColumnIndex, targetD
96
101
  }
97
102
  return newTr;
98
103
  };
104
+
105
+ // Ignored via go/ees005
106
+ // eslint-disable-next-line @typescript-eslint/max-params
99
107
  function normalizeCellNode(cellNode, rowHeaderEnabled, columnHeaderEnabled, types) {
100
108
  const newTargetType = rowHeaderEnabled || columnHeaderEnabled ? types.header_cell : types.cell;
101
109
  return cellNode.type !== newTargetType ? newTargetType.create(cellNode.attrs, cellNode.content, cellNode.marks) : cellNode;
102
110
  }
103
111
  function createContentNodeFactory(table) {
104
112
  return nodePos => {
113
+ // Ignored via go/ees005
114
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
105
115
  const node = table.node.nodeAt(nodePos);
106
116
  const pos = nodePos + table.start;
107
117
  return {
@@ -15,7 +15,10 @@ export const cloneRow = (state, originRowIndex, targetRowIndex, targetDirection,
15
15
  tryToFit: false,
16
16
  direction: 0,
17
17
  selectAfterClone: false
18
- }) => tr => {
18
+ }
19
+ // Ignored via go/ees005
20
+ // eslint-disable-next-line @typescript-eslint/max-params
21
+ ) => tr => {
19
22
  const table = findTable(tr.selection);
20
23
  if (!table) {
21
24
  return tr;
@@ -94,8 +97,10 @@ export const cloneRow = (state, originRowIndex, targetRowIndex, targetDirection,
94
97
  * This ensures the row node cell type correctly reflect what they should be.
95
98
  * @returns A copy of the rowNode
96
99
  */
100
+ // Ignored via go/ees005
101
+ // eslint-disable-next-line @typescript-eslint/max-params
97
102
  function normalizeRowNode(rowNode, rowHeaderEnabled, columnHeaderEnabled, types) {
98
- let content = [];
103
+ const content = [];
99
104
  rowNode.forEach((node, offset, index) => {
100
105
  const newTargetType = rowHeaderEnabled || columnHeaderEnabled && index === 0 ? types.header_cell : types.cell;
101
106
  content.push(node.type !== newTargetType ? newTargetType.create(node.attrs, node.content, node.marks) : node);