handsontable 0.0.0-next-c8116f8-20240920 → 0.0.0-next-fad35d5-20240924

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

Files changed (113) hide show
  1. package/3rdparty/walkontable/src/calculator/calculationType/renderedColumns.js +23 -0
  2. package/3rdparty/walkontable/src/calculator/calculationType/renderedColumns.mjs +23 -0
  3. package/3rdparty/walkontable/src/calculator/calculationType/renderedRows.js +23 -0
  4. package/3rdparty/walkontable/src/calculator/calculationType/renderedRows.mjs +23 -0
  5. package/3rdparty/walkontable/src/core/_base.js +7 -0
  6. package/3rdparty/walkontable/src/core/_base.mjs +7 -0
  7. package/3rdparty/walkontable/src/facade/core.js +3 -0
  8. package/3rdparty/walkontable/src/facade/core.mjs +3 -0
  9. package/3rdparty/walkontable/src/overlay/_base.js +3 -0
  10. package/3rdparty/walkontable/src/overlay/_base.mjs +3 -0
  11. package/3rdparty/walkontable/src/selection/border/border.js +32 -44
  12. package/3rdparty/walkontable/src/selection/border/border.mjs +32 -44
  13. package/3rdparty/walkontable/src/selection/scanner.js +46 -11
  14. package/3rdparty/walkontable/src/selection/scanner.mjs +46 -11
  15. package/3rdparty/walkontable/src/settings.js +8 -0
  16. package/3rdparty/walkontable/src/settings.mjs +8 -0
  17. package/3rdparty/walkontable/src/table.js +6 -3
  18. package/3rdparty/walkontable/src/table.mjs +6 -3
  19. package/3rdparty/walkontable/src/viewport.js +26 -4
  20. package/3rdparty/walkontable/src/viewport.mjs +26 -4
  21. package/base.js +4 -4
  22. package/base.mjs +3 -3
  23. package/core/hooks/bucket.js +180 -0
  24. package/core/hooks/bucket.mjs +176 -0
  25. package/{pluginHooks.mjs → core/hooks/constants.js} +20 -486
  26. package/{pluginHooks.js → core/hooks/constants.mjs} +16 -489
  27. package/{pluginHooks.d.ts → core/hooks/index.d.ts} +17 -21
  28. package/core/hooks/index.js +385 -0
  29. package/core/hooks/index.mjs +381 -0
  30. package/core.d.ts +1 -1
  31. package/core.js +13 -12
  32. package/core.mjs +5 -4
  33. package/dataMap/metaManager/metaSchema.js +68 -2
  34. package/dataMap/metaManager/metaSchema.mjs +68 -2
  35. package/dataMap/metaManager/mods/dynamicCellMeta.js +2 -3
  36. package/dataMap/metaManager/mods/dynamicCellMeta.mjs +1 -1
  37. package/dist/handsontable.css +2 -2
  38. package/dist/handsontable.full.css +2 -2
  39. package/dist/handsontable.full.js +3009 -2582
  40. package/dist/handsontable.full.min.css +2 -2
  41. package/dist/handsontable.full.min.js +60 -60
  42. package/dist/handsontable.js +3011 -2584
  43. package/dist/handsontable.min.css +2 -2
  44. package/dist/handsontable.min.js +18 -18
  45. package/editorManager.js +2 -2
  46. package/editorManager.mjs +2 -2
  47. package/editors/baseEditor/baseEditor.js +23 -16
  48. package/editors/baseEditor/baseEditor.mjs +23 -16
  49. package/editors/dropdownEditor/dropdownEditor.js +2 -3
  50. package/editors/dropdownEditor/dropdownEditor.mjs +1 -1
  51. package/editors/registry.js +2 -2
  52. package/editors/registry.mjs +1 -1
  53. package/helpers/mixed.js +1 -1
  54. package/helpers/mixed.mjs +1 -1
  55. package/index.d.ts +2 -1
  56. package/package.json +1 -1
  57. package/plugins/autoColumnSize/autoColumnSize.js +18 -27
  58. package/plugins/autoColumnSize/autoColumnSize.mjs +18 -27
  59. package/plugins/autoRowSize/autoRowSize.js +16 -22
  60. package/plugins/autoRowSize/autoRowSize.mjs +17 -23
  61. package/plugins/autofill/autofill.js +4 -5
  62. package/plugins/autofill/autofill.mjs +1 -1
  63. package/plugins/base/base.d.ts +1 -1
  64. package/plugins/base/base.js +39 -0
  65. package/plugins/base/base.mjs +40 -1
  66. package/plugins/base/index.js +2 -1
  67. package/plugins/base/index.mjs +1 -1
  68. package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.js +2 -5
  69. package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.mjs +2 -5
  70. package/plugins/columnSorting/columnSorting.js +3 -4
  71. package/plugins/columnSorting/columnSorting.mjs +1 -1
  72. package/plugins/comments/comments.js +7 -15
  73. package/plugins/comments/comments.mjs +8 -16
  74. package/plugins/contextMenu/contextMenu.js +6 -7
  75. package/plugins/contextMenu/contextMenu.mjs +1 -1
  76. package/plugins/copyPaste/copyPaste.js +29 -23
  77. package/plugins/copyPaste/copyPaste.mjs +21 -15
  78. package/plugins/dropdownMenu/dropdownMenu.js +6 -7
  79. package/plugins/dropdownMenu/dropdownMenu.mjs +1 -1
  80. package/plugins/formulas/formulas.js +7 -7
  81. package/plugins/formulas/formulas.mjs +1 -1
  82. package/plugins/hiddenColumns/hiddenColumns.js +19 -30
  83. package/plugins/hiddenColumns/hiddenColumns.mjs +15 -26
  84. package/plugins/hiddenRows/hiddenRows.js +18 -29
  85. package/plugins/hiddenRows/hiddenRows.mjs +14 -25
  86. package/plugins/manualColumnFreeze/manualColumnFreeze.js +5 -5
  87. package/plugins/manualColumnFreeze/manualColumnFreeze.mjs +1 -1
  88. package/plugins/manualColumnMove/manualColumnMove.js +3 -3
  89. package/plugins/manualColumnMove/manualColumnMove.mjs +1 -1
  90. package/plugins/manualRowMove/manualRowMove.js +5 -5
  91. package/plugins/manualRowMove/manualRowMove.mjs +3 -3
  92. package/plugins/mergeCells/cellsCollection.js +15 -3
  93. package/plugins/mergeCells/cellsCollection.mjs +16 -4
  94. package/plugins/mergeCells/mergeCells.d.ts +6 -2
  95. package/plugins/mergeCells/mergeCells.js +78 -55
  96. package/plugins/mergeCells/mergeCells.mjs +76 -53
  97. package/plugins/mergeCells/renderer.js +13 -3
  98. package/plugins/mergeCells/renderer.mjs +13 -3
  99. package/plugins/persistentState/persistentState.js +4 -4
  100. package/plugins/persistentState/persistentState.mjs +1 -1
  101. package/plugins/undoRedo/undoRedo.js +4 -5
  102. package/plugins/undoRedo/undoRedo.mjs +3 -3
  103. package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
  104. package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
  105. package/settings.d.ts +3 -1
  106. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +1 -1
  107. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +1 -1
  108. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +1 -1
  109. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +1 -1
  110. package/shortcutContexts/commands/scrollToFocusedCell.js +4 -4
  111. package/shortcutContexts/commands/scrollToFocusedCell.mjs +4 -4
  112. package/tableView.js +40 -9
  113. package/tableView.mjs +40 -9
@@ -1,11 +1,30 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
+ require("core-js/modules/es.error.cause.js");
4
5
  var _partiallyVisibleColumns = require("./partiallyVisibleColumns");
6
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
9
  /**
6
10
  * @class RenderedColumnsCalculationType
7
11
  */
8
12
  class RenderedColumnsCalculationType extends _partiallyVisibleColumns.PartiallyVisibleColumnsCalculationType {
13
+ constructor() {
14
+ super(...arguments);
15
+ /**
16
+ * The property holds the offset applied in the `overrideFn` function to the `startColumn` value.
17
+ *
18
+ * @type {number}
19
+ */
20
+ _defineProperty(this, "columnStartOffset", 0);
21
+ /**
22
+ * The property holds the offset applied in the `overrideFn` function to the `endColumn` value.
23
+ *
24
+ * @type {number}
25
+ */
26
+ _defineProperty(this, "columnEndOffset", 0);
27
+ }
9
28
  /**
10
29
  * Finalizes the calculation.
11
30
  *
@@ -20,7 +39,11 @@ class RenderedColumnsCalculationType extends _partiallyVisibleColumns.PartiallyV
20
39
  startPositions
21
40
  } = viewportCalculator;
22
41
  if (this.startColumn !== null && typeof overrideFn === 'function') {
42
+ const startColumn = this.startColumn;
43
+ const endColumn = this.endColumn;
23
44
  overrideFn(this);
45
+ this.columnStartOffset = startColumn - this.startColumn;
46
+ this.columnEndOffset = this.endColumn - endColumn;
24
47
  }
25
48
  if (this.startColumn < 0) {
26
49
  this.startColumn = 0;
@@ -1,8 +1,27 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
4
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
5
  import { PartiallyVisibleColumnsCalculationType } from "./partiallyVisibleColumns.mjs";
2
6
  /**
3
7
  * @class RenderedColumnsCalculationType
4
8
  */
5
9
  export class RenderedColumnsCalculationType extends PartiallyVisibleColumnsCalculationType {
10
+ constructor() {
11
+ super(...arguments);
12
+ /**
13
+ * The property holds the offset applied in the `overrideFn` function to the `startColumn` value.
14
+ *
15
+ * @type {number}
16
+ */
17
+ _defineProperty(this, "columnStartOffset", 0);
18
+ /**
19
+ * The property holds the offset applied in the `overrideFn` function to the `endColumn` value.
20
+ *
21
+ * @type {number}
22
+ */
23
+ _defineProperty(this, "columnEndOffset", 0);
24
+ }
6
25
  /**
7
26
  * Finalizes the calculation.
8
27
  *
@@ -17,7 +36,11 @@ export class RenderedColumnsCalculationType extends PartiallyVisibleColumnsCalcu
17
36
  startPositions
18
37
  } = viewportCalculator;
19
38
  if (this.startColumn !== null && typeof overrideFn === 'function') {
39
+ const startColumn = this.startColumn;
40
+ const endColumn = this.endColumn;
20
41
  overrideFn(this);
42
+ this.columnStartOffset = startColumn - this.startColumn;
43
+ this.columnEndOffset = this.endColumn - endColumn;
21
44
  }
22
45
  if (this.startColumn < 0) {
23
46
  this.startColumn = 0;
@@ -1,11 +1,30 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
+ require("core-js/modules/es.error.cause.js");
4
5
  var _partiallyVisibleRows = require("./partiallyVisibleRows");
6
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
9
  /**
6
10
  * @class RenderedRowsCalculationType
7
11
  */
8
12
  class RenderedRowsCalculationType extends _partiallyVisibleRows.PartiallyVisibleRowsCalculationType {
13
+ constructor() {
14
+ super(...arguments);
15
+ /**
16
+ * The property holds the offset applied in the `overrideFn` function to the `startColumn` value.
17
+ *
18
+ * @type {number}
19
+ */
20
+ _defineProperty(this, "rowStartOffset", 0);
21
+ /**
22
+ * The property holds the offset applied in the `overrideFn` function to the `endColumn` value.
23
+ *
24
+ * @type {number}
25
+ */
26
+ _defineProperty(this, "rowEndOffset", 0);
27
+ }
9
28
  /**
10
29
  * Finalizes the calculation.
11
30
  *
@@ -20,7 +39,11 @@ class RenderedRowsCalculationType extends _partiallyVisibleRows.PartiallyVisible
20
39
  startPositions
21
40
  } = viewportCalculator;
22
41
  if (this.startRow !== null && typeof overrideFn === 'function') {
42
+ const startRow = this.startRow;
43
+ const endRow = this.endRow;
23
44
  overrideFn(this);
45
+ this.rowStartOffset = startRow - this.startRow;
46
+ this.rowEndOffset = this.endRow - endRow;
24
47
  }
25
48
  if (this.startRow < 0) {
26
49
  this.startRow = 0;
@@ -1,8 +1,27 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
4
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
5
  import { PartiallyVisibleRowsCalculationType } from "./partiallyVisibleRows.mjs";
2
6
  /**
3
7
  * @class RenderedRowsCalculationType
4
8
  */
5
9
  export class RenderedRowsCalculationType extends PartiallyVisibleRowsCalculationType {
10
+ constructor() {
11
+ super(...arguments);
12
+ /**
13
+ * The property holds the offset applied in the `overrideFn` function to the `startColumn` value.
14
+ *
15
+ * @type {number}
16
+ */
17
+ _defineProperty(this, "rowStartOffset", 0);
18
+ /**
19
+ * The property holds the offset applied in the `overrideFn` function to the `endColumn` value.
20
+ *
21
+ * @type {number}
22
+ */
23
+ _defineProperty(this, "rowEndOffset", 0);
24
+ }
6
25
  /**
7
26
  * Finalizes the calculation.
8
27
  *
@@ -17,7 +36,11 @@ export class RenderedRowsCalculationType extends PartiallyVisibleRowsCalculation
17
36
  startPositions
18
37
  } = viewportCalculator;
19
38
  if (this.startRow !== null && typeof overrideFn === 'function') {
39
+ const startRow = this.startRow;
40
+ const endRow = this.endRow;
20
41
  overrideFn(this);
42
+ this.rowStartOffset = startRow - this.startRow;
43
+ this.rowEndOffset = this.endRow - endRow;
21
44
  }
22
45
  if (this.startRow < 0) {
23
46
  this.startRow = 0;
@@ -42,6 +42,13 @@ class CoreAbstract {
42
42
  _defineProperty(this, "guid", `wt_${(0, _string.randomString)()}`);
43
43
  _defineProperty(this, "drawInterrupted", false);
44
44
  _defineProperty(this, "drawn", false);
45
+ /**
46
+ * The name of the overlay that currently renders the table.
47
+ *
48
+ * @public
49
+ * @type {string}
50
+ */
51
+ _defineProperty(this, "activeOverlayName", 'master');
45
52
  /**
46
53
  * The DOM bindings.
47
54
  *
@@ -38,6 +38,13 @@ export default class CoreAbstract {
38
38
  _defineProperty(this, "guid", `wt_${randomString()}`);
39
39
  _defineProperty(this, "drawInterrupted", false);
40
40
  _defineProperty(this, "drawn", false);
41
+ /**
42
+ * The name of the overlay that currently renders the table.
43
+ *
44
+ * @public
45
+ * @type {string}
46
+ */
47
+ _defineProperty(this, "activeOverlayName", 'master');
41
48
  /**
42
49
  * The DOM bindings.
43
50
  *
@@ -71,6 +71,9 @@ class WalkontableFacade {
71
71
  set drawn(value) {
72
72
  this._wot.drawn = value;
73
73
  }
74
+ get activeOverlayName() {
75
+ return this._wot.activeOverlayName;
76
+ }
74
77
  get drawInterrupted() {
75
78
  return this._wot.drawInterrupted;
76
79
  }
@@ -67,6 +67,9 @@ export default class WalkontableFacade {
67
67
  set drawn(value) {
68
68
  this._wot.drawn = value;
69
69
  }
70
+ get activeOverlayName() {
71
+ return this._wot.activeOverlayName;
72
+ }
70
73
  get drawInterrupted() {
71
74
  return this._wot.drawInterrupted;
72
75
  }
@@ -316,7 +316,10 @@ class Overlay {
316
316
  refresh() {
317
317
  let fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
318
318
  if (this.needFullRender) {
319
+ const cloneSource = this.clone.cloneSource;
320
+ cloneSource.activeOverlayName = this.clone.wtTable.name;
319
321
  this.clone.draw(fastDraw);
322
+ cloneSource.activeOverlayName = 'master';
320
323
  }
321
324
  }
322
325
 
@@ -312,7 +312,10 @@ export class Overlay {
312
312
  refresh() {
313
313
  let fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
314
314
  if (this.needFullRender) {
315
+ const cloneSource = this.clone.cloneSource;
316
+ cloneSource.activeOverlayName = this.clone.wtTable.name;
315
317
  this.clone.draw(fastDraw);
318
+ cloneSource.activeOverlayName = 'master';
316
319
  }
317
320
  }
318
321
 
@@ -322,66 +322,52 @@ class Border {
322
322
  if (this.disabled) {
323
323
  return;
324
324
  }
325
+ let [fromRow, fromColumn, toRow, toColumn] = corners;
326
+
327
+ // borders can not be rendered on headers so hide them
328
+ if (fromRow < 0 && toRow < 0 || fromColumn < 0 && toColumn < 0) {
329
+ this.disappear();
330
+ return;
331
+ }
325
332
  const {
326
333
  wtTable,
327
334
  rootDocument,
328
335
  rootWindow
329
- } = this.wot; // todo refactoring: consider about using internal facade (it is given by external code)
330
- let fromRow;
331
- let toRow;
332
- let fromColumn;
333
- let toColumn;
334
- let rowHeader;
335
- let columnHeader;
336
- const rowsCount = wtTable.getRenderedRowsCount();
337
- for (let i = 0; i < rowsCount; i += 1) {
338
- const s = wtTable.rowFilter.renderedToSource(i);
339
- if (s >= corners[0] && s <= corners[2]) {
340
- fromRow = s;
341
- rowHeader = corners[0];
342
- break;
343
- }
344
- }
345
- for (let i = rowsCount - 1; i >= 0; i -= 1) {
346
- const s = wtTable.rowFilter.renderedToSource(i);
347
- if (s >= corners[0] && s <= corners[2]) {
348
- toRow = s;
349
- break;
350
- }
351
- }
352
- const columnsCount = wtTable.getRenderedColumnsCount();
353
- for (let i = 0; i < columnsCount; i += 1) {
354
- const s = wtTable.columnFilter.renderedToSource(i);
355
- if (s >= corners[1] && s <= corners[3]) {
356
- fromColumn = s;
357
- columnHeader = corners[1];
358
- break;
336
+ } = this.wot;
337
+ const isMultiple = fromRow !== toRow || fromColumn !== toColumn;
338
+ const firstRenderedRow = wtTable.getFirstRenderedRow();
339
+ const lastRenderedRow = wtTable.getLastRenderedRow();
340
+ const firstRenderedColumn = wtTable.getFirstRenderedColumn();
341
+ const lastRenderedColumn = wtTable.getLastRenderedColumn();
342
+ let fromTD;
343
+ if (isMultiple) {
344
+ fromColumn = Math.max(fromColumn, firstRenderedColumn);
345
+ toColumn = Math.min(toColumn, lastRenderedColumn);
346
+ fromRow = Math.max(fromRow, firstRenderedRow);
347
+ toRow = Math.min(toRow, lastRenderedRow);
348
+ if (toColumn < fromColumn || toRow < fromRow) {
349
+ this.disappear();
350
+ return;
359
351
  }
360
- }
361
- for (let i = columnsCount - 1; i >= 0; i -= 1) {
362
- const s = wtTable.columnFilter.renderedToSource(i);
363
- if (s >= corners[1] && s <= corners[3]) {
364
- toColumn = s;
365
- break;
352
+ fromTD = wtTable.getCell(this.wot.createCellCoords(fromRow, fromColumn));
353
+ } else {
354
+ fromTD = wtTable.getCell(this.wot.createCellCoords(fromRow, fromColumn));
355
+ if (!(fromTD instanceof HTMLElement)) {
356
+ this.disappear();
357
+ return;
366
358
  }
367
359
  }
368
- if (fromRow === undefined || fromColumn === undefined) {
369
- this.disappear();
370
- return;
371
- }
372
- let fromTD = wtTable.getCell(this.wot.createCellCoords(fromRow, fromColumn));
373
- const isMultiple = fromRow !== toRow || fromColumn !== toColumn;
374
360
  const toTD = isMultiple ? wtTable.getCell(this.wot.createCellCoords(toRow, toColumn)) : fromTD;
375
361
  const fromOffset = (0, _element.offset)(fromTD);
376
362
  const toOffset = isMultiple ? (0, _element.offset)(toTD) : fromOffset;
377
363
  const containerOffset = (0, _element.offset)(wtTable.TABLE);
378
- const containerWidth = (0, _element.outerWidth)(wtTable.TABLE);
379
364
  const minTop = fromOffset.top;
380
365
  const minLeft = fromOffset.left;
381
366
  const isRtl = this.wot.wtSettings.getSetting('rtlMode');
382
367
  let inlineStartPos = 0;
383
368
  let width = 0;
384
369
  if (isRtl) {
370
+ const containerWidth = (0, _element.outerWidth)(wtTable.TABLE);
385
371
  const fromWidth = (0, _element.outerWidth)(fromTD);
386
372
  const gridRightPos = rootWindow.innerWidth - containerOffset.left - containerWidth;
387
373
  width = minLeft + fromWidth - toOffset.left;
@@ -391,6 +377,7 @@ class Border {
391
377
  inlineStartPos = minLeft - containerOffset.left - 1;
392
378
  }
393
379
  if (this.isEntireColumnSelected(fromRow, toRow)) {
380
+ const rowHeader = fromRow;
394
381
  const modifiedValues = this.getDimensionsFromHeader('columns', fromColumn, toColumn, rowHeader, containerOffset);
395
382
  let fromTH = null;
396
383
  if (modifiedValues) {
@@ -403,6 +390,7 @@ class Border {
403
390
  let top = minTop - containerOffset.top - 1;
404
391
  let height = toOffset.top + (0, _element.outerHeight)(toTD) - minTop;
405
392
  if (this.isEntireRowSelected(fromColumn, toColumn)) {
393
+ const columnHeader = fromColumn;
406
394
  const modifiedValues = this.getDimensionsFromHeader('rows', fromRow, toRow, columnHeader, containerOffset);
407
395
  let fromTH = null;
408
396
  if (modifiedValues) {
@@ -441,7 +429,7 @@ class Border {
441
429
  this.endStyle.display = 'block';
442
430
  let cornerVisibleSetting = this.settings.border.cornerVisible;
443
431
  cornerVisibleSetting = typeof cornerVisibleSetting === 'function' ? cornerVisibleSetting(this.settings.layerLevel) : cornerVisibleSetting;
444
- const hookResult = this.wot.getSetting('onModifyGetCellCoords', toRow, toColumn);
432
+ const hookResult = this.wot.getSetting('onModifyGetCellCoords', toRow, toColumn, false, 'render');
445
433
  let [checkRow, checkCol] = [toRow, toColumn];
446
434
  if (hookResult && Array.isArray(hookResult)) {
447
435
  [,, checkRow, checkCol] = hookResult;
@@ -319,66 +319,52 @@ class Border {
319
319
  if (this.disabled) {
320
320
  return;
321
321
  }
322
+ let [fromRow, fromColumn, toRow, toColumn] = corners;
323
+
324
+ // borders can not be rendered on headers so hide them
325
+ if (fromRow < 0 && toRow < 0 || fromColumn < 0 && toColumn < 0) {
326
+ this.disappear();
327
+ return;
328
+ }
322
329
  const {
323
330
  wtTable,
324
331
  rootDocument,
325
332
  rootWindow
326
- } = this.wot; // todo refactoring: consider about using internal facade (it is given by external code)
327
- let fromRow;
328
- let toRow;
329
- let fromColumn;
330
- let toColumn;
331
- let rowHeader;
332
- let columnHeader;
333
- const rowsCount = wtTable.getRenderedRowsCount();
334
- for (let i = 0; i < rowsCount; i += 1) {
335
- const s = wtTable.rowFilter.renderedToSource(i);
336
- if (s >= corners[0] && s <= corners[2]) {
337
- fromRow = s;
338
- rowHeader = corners[0];
339
- break;
340
- }
341
- }
342
- for (let i = rowsCount - 1; i >= 0; i -= 1) {
343
- const s = wtTable.rowFilter.renderedToSource(i);
344
- if (s >= corners[0] && s <= corners[2]) {
345
- toRow = s;
346
- break;
347
- }
348
- }
349
- const columnsCount = wtTable.getRenderedColumnsCount();
350
- for (let i = 0; i < columnsCount; i += 1) {
351
- const s = wtTable.columnFilter.renderedToSource(i);
352
- if (s >= corners[1] && s <= corners[3]) {
353
- fromColumn = s;
354
- columnHeader = corners[1];
355
- break;
333
+ } = this.wot;
334
+ const isMultiple = fromRow !== toRow || fromColumn !== toColumn;
335
+ const firstRenderedRow = wtTable.getFirstRenderedRow();
336
+ const lastRenderedRow = wtTable.getLastRenderedRow();
337
+ const firstRenderedColumn = wtTable.getFirstRenderedColumn();
338
+ const lastRenderedColumn = wtTable.getLastRenderedColumn();
339
+ let fromTD;
340
+ if (isMultiple) {
341
+ fromColumn = Math.max(fromColumn, firstRenderedColumn);
342
+ toColumn = Math.min(toColumn, lastRenderedColumn);
343
+ fromRow = Math.max(fromRow, firstRenderedRow);
344
+ toRow = Math.min(toRow, lastRenderedRow);
345
+ if (toColumn < fromColumn || toRow < fromRow) {
346
+ this.disappear();
347
+ return;
356
348
  }
357
- }
358
- for (let i = columnsCount - 1; i >= 0; i -= 1) {
359
- const s = wtTable.columnFilter.renderedToSource(i);
360
- if (s >= corners[1] && s <= corners[3]) {
361
- toColumn = s;
362
- break;
349
+ fromTD = wtTable.getCell(this.wot.createCellCoords(fromRow, fromColumn));
350
+ } else {
351
+ fromTD = wtTable.getCell(this.wot.createCellCoords(fromRow, fromColumn));
352
+ if (!(fromTD instanceof HTMLElement)) {
353
+ this.disappear();
354
+ return;
363
355
  }
364
356
  }
365
- if (fromRow === undefined || fromColumn === undefined) {
366
- this.disappear();
367
- return;
368
- }
369
- let fromTD = wtTable.getCell(this.wot.createCellCoords(fromRow, fromColumn));
370
- const isMultiple = fromRow !== toRow || fromColumn !== toColumn;
371
357
  const toTD = isMultiple ? wtTable.getCell(this.wot.createCellCoords(toRow, toColumn)) : fromTD;
372
358
  const fromOffset = offset(fromTD);
373
359
  const toOffset = isMultiple ? offset(toTD) : fromOffset;
374
360
  const containerOffset = offset(wtTable.TABLE);
375
- const containerWidth = outerWidth(wtTable.TABLE);
376
361
  const minTop = fromOffset.top;
377
362
  const minLeft = fromOffset.left;
378
363
  const isRtl = this.wot.wtSettings.getSetting('rtlMode');
379
364
  let inlineStartPos = 0;
380
365
  let width = 0;
381
366
  if (isRtl) {
367
+ const containerWidth = outerWidth(wtTable.TABLE);
382
368
  const fromWidth = outerWidth(fromTD);
383
369
  const gridRightPos = rootWindow.innerWidth - containerOffset.left - containerWidth;
384
370
  width = minLeft + fromWidth - toOffset.left;
@@ -388,6 +374,7 @@ class Border {
388
374
  inlineStartPos = minLeft - containerOffset.left - 1;
389
375
  }
390
376
  if (this.isEntireColumnSelected(fromRow, toRow)) {
377
+ const rowHeader = fromRow;
391
378
  const modifiedValues = this.getDimensionsFromHeader('columns', fromColumn, toColumn, rowHeader, containerOffset);
392
379
  let fromTH = null;
393
380
  if (modifiedValues) {
@@ -400,6 +387,7 @@ class Border {
400
387
  let top = minTop - containerOffset.top - 1;
401
388
  let height = toOffset.top + outerHeight(toTD) - minTop;
402
389
  if (this.isEntireRowSelected(fromColumn, toColumn)) {
390
+ const columnHeader = fromColumn;
403
391
  const modifiedValues = this.getDimensionsFromHeader('rows', fromRow, toRow, columnHeader, containerOffset);
404
392
  let fromTH = null;
405
393
  if (modifiedValues) {
@@ -438,7 +426,7 @@ class Border {
438
426
  this.endStyle.display = 'block';
439
427
  let cornerVisibleSetting = this.settings.border.cornerVisible;
440
428
  cornerVisibleSetting = typeof cornerVisibleSetting === 'function' ? cornerVisibleSetting(this.settings.layerLevel) : cornerVisibleSetting;
441
- const hookResult = this.wot.getSetting('onModifyGetCellCoords', toRow, toColumn);
429
+ const hookResult = this.wot.getSetting('onModifyGetCellCoords', toRow, toColumn, false, 'render');
442
430
  let [checkRow, checkCol] = [toRow, toColumn];
443
431
  if (hookResult && Array.isArray(hookResult)) {
444
432
  [,, checkRow, checkCol] = hookResult;
@@ -195,21 +195,18 @@ class SelectionScanner {
195
195
  * @param {function(HTMLTableElement): void} callback The callback function to trigger.
196
196
  */
197
197
  scanCellsRange(callback) {
198
- const [topRow, topColumn, bottomRow, bottomColumn] = _classPrivateFieldGet(_selection, this).getCorners();
199
198
  const {
200
199
  wtTable
201
200
  } = _classPrivateFieldGet(_activeOverlaysWot, this);
202
201
  _assertClassBrand(_SelectionScanner_brand, this, _scanCellsRange).call(this, (sourceRow, sourceColumn) => {
203
- if (sourceRow >= topRow && sourceRow <= bottomRow && sourceColumn >= topColumn && sourceColumn <= bottomColumn) {
204
- const cell = wtTable.getCell(_classPrivateFieldGet(_activeOverlaysWot, this).createCellCoords(sourceRow, sourceColumn));
202
+ const cell = wtTable.getCell(_classPrivateFieldGet(_activeOverlaysWot, this).createCellCoords(sourceRow, sourceColumn));
205
203
 
206
- // support for old API
207
- const additionalSelectionClass = _classPrivateFieldGet(_activeOverlaysWot, this).getSetting('onAfterDrawSelection', sourceRow, sourceColumn, _classPrivateFieldGet(_selection, this).settings.layerLevel);
208
- if (typeof additionalSelectionClass === 'string') {
209
- (0, _element.addClass)(cell, additionalSelectionClass);
210
- }
211
- callback(cell);
204
+ // support for old API
205
+ const additionalSelectionClass = _classPrivateFieldGet(_activeOverlaysWot, this).getSetting('onAfterDrawSelection', sourceRow, sourceColumn, _classPrivateFieldGet(_selection, this).settings.layerLevel);
206
+ if (typeof additionalSelectionClass === 'string') {
207
+ (0, _element.addClass)(cell, additionalSelectionClass);
212
208
  }
209
+ callback(cell);
213
210
  });
214
211
  }
215
212
 
@@ -225,7 +222,7 @@ class SelectionScanner {
225
222
  const {
226
223
  wtTable
227
224
  } = _classPrivateFieldGet(_activeOverlaysWot, this);
228
- _assertClassBrand(_SelectionScanner_brand, this, _scanCellsRange).call(this, (sourceRow, sourceColumn) => {
225
+ _assertClassBrand(_SelectionScanner_brand, this, _scanViewportRange).call(this, (sourceRow, sourceColumn) => {
229
226
  if (sourceRow >= topRow && sourceRow <= bottomRow) {
230
227
  const cell = wtTable.getCell(_classPrivateFieldGet(_activeOverlaysWot, this).createCellCoords(sourceRow, sourceColumn));
231
228
  callback(cell);
@@ -244,7 +241,7 @@ class SelectionScanner {
244
241
  const {
245
242
  wtTable
246
243
  } = _classPrivateFieldGet(_activeOverlaysWot, this);
247
- _assertClassBrand(_SelectionScanner_brand, this, _scanCellsRange).call(this, (sourceRow, sourceColumn) => {
244
+ _assertClassBrand(_SelectionScanner_brand, this, _scanViewportRange).call(this, (sourceRow, sourceColumn) => {
248
245
  if (sourceColumn >= topColumn && sourceColumn <= bottomColumn) {
249
246
  const cell = wtTable.getCell(_classPrivateFieldGet(_activeOverlaysWot, this).createCellCoords(sourceRow, sourceColumn));
250
247
  callback(cell);
@@ -254,6 +251,44 @@ class SelectionScanner {
254
251
  }
255
252
  exports.SelectionScanner = SelectionScanner;
256
253
  function _scanCellsRange(callback) {
254
+ let [topRow, startColumn, bottomRow, endColumn] = _classPrivateFieldGet(_selection, this).getCorners();
255
+ if (topRow < 0 && bottomRow < 0 || startColumn < 0 && endColumn < 0) {
256
+ return;
257
+ }
258
+ const {
259
+ wtTable
260
+ } = _classPrivateFieldGet(_activeOverlaysWot, this);
261
+ const isMultiple = topRow !== bottomRow || startColumn !== endColumn;
262
+ startColumn = Math.max(startColumn, 0);
263
+ endColumn = Math.max(endColumn, 0);
264
+ topRow = Math.max(topRow, 0);
265
+ bottomRow = Math.max(bottomRow, 0);
266
+ if (isMultiple) {
267
+ startColumn = Math.max(startColumn, wtTable.getFirstRenderedColumn());
268
+ endColumn = Math.min(endColumn, wtTable.getLastRenderedColumn());
269
+ topRow = Math.max(topRow, wtTable.getFirstRenderedRow());
270
+ bottomRow = Math.min(bottomRow, wtTable.getLastRenderedRow());
271
+ if (endColumn < startColumn || bottomRow < topRow) {
272
+ return;
273
+ }
274
+ } else {
275
+ const cell = wtTable.getCell(_classPrivateFieldGet(_activeOverlaysWot, this).createCellCoords(topRow, startColumn));
276
+ if (!(cell instanceof HTMLElement)) {
277
+ return;
278
+ }
279
+ }
280
+ for (let row = topRow; row <= bottomRow; row += 1) {
281
+ for (let column = startColumn; column <= endColumn; column += 1) {
282
+ callback(row, column);
283
+ }
284
+ }
285
+ }
286
+ /**
287
+ * The method triggers a callback for each rendered cell including headers.
288
+ *
289
+ * @param {function(number, number): void} callback The callback function to trigger.
290
+ */
291
+ function _scanViewportRange(callback) {
257
292
  const {
258
293
  wtTable
259
294
  } = _classPrivateFieldGet(_activeOverlaysWot, this);