handsontable 0.0.0-next-221e46b-20240307 → 0.0.0-next-200799f-20240311

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.

Potentially problematic release.


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

Files changed (98) hide show
  1. package/3rdparty/walkontable/src/cell/range.d.ts +1 -0
  2. package/3rdparty/walkontable/src/cell/range.js +22 -5
  3. package/3rdparty/walkontable/src/cell/range.mjs +22 -5
  4. package/base.js +2 -2
  5. package/base.mjs +2 -2
  6. package/core/viewportScroll/index.js +4 -1
  7. package/core/viewportScroll/index.mjs +4 -1
  8. package/core/viewportScroll/scrollStrategies/focusScroll.js +15 -0
  9. package/core/viewportScroll/scrollStrategies/focusScroll.mjs +11 -0
  10. package/core.d.ts +4 -3
  11. package/core.js +78 -21
  12. package/core.mjs +78 -21
  13. package/dist/handsontable.css +2 -2
  14. package/dist/handsontable.full.css +2 -2
  15. package/dist/handsontable.full.js +2645 -1363
  16. package/dist/handsontable.full.min.css +2 -2
  17. package/dist/handsontable.full.min.js +152 -152
  18. package/dist/handsontable.js +2645 -1363
  19. package/dist/handsontable.min.css +2 -2
  20. package/dist/handsontable.min.js +32 -32
  21. package/editorManager.js +12 -8
  22. package/editorManager.mjs +12 -8
  23. package/helpers/mixed.js +1 -1
  24. package/helpers/mixed.mjs +1 -1
  25. package/package.json +1 -1
  26. package/pluginHooks.d.ts +1 -0
  27. package/pluginHooks.js +43 -1
  28. package/pluginHooks.mjs +43 -1
  29. package/plugins/collapsibleColumns/collapsibleColumns.js +7 -1
  30. package/plugins/collapsibleColumns/collapsibleColumns.mjs +7 -1
  31. package/plugins/columnSorting/columnSorting.js +6 -0
  32. package/plugins/columnSorting/columnSorting.mjs +6 -0
  33. package/plugins/contextMenu/menu/defaultShortcutsList.js +26 -10
  34. package/plugins/contextMenu/menu/defaultShortcutsList.mjs +26 -10
  35. package/plugins/mergeCells/calculations/selection.js +1 -70
  36. package/plugins/mergeCells/calculations/selection.mjs +1 -70
  37. package/plugins/mergeCells/cellsCollection.js +116 -0
  38. package/plugins/mergeCells/cellsCollection.mjs +116 -0
  39. package/plugins/mergeCells/contextMenuItem/toggleMerge.js +11 -1
  40. package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +11 -1
  41. package/plugins/mergeCells/focusOrder.js +258 -0
  42. package/plugins/mergeCells/focusOrder.mjs +253 -0
  43. package/plugins/mergeCells/mergeCells.js +394 -199
  44. package/plugins/mergeCells/mergeCells.mjs +394 -199
  45. package/plugins/multiColumnSorting/multiColumnSorting.js +6 -0
  46. package/plugins/multiColumnSorting/multiColumnSorting.mjs +6 -0
  47. package/plugins/nestedHeaders/nestedHeaders.js +1 -0
  48. package/plugins/nestedHeaders/nestedHeaders.mjs +1 -0
  49. package/plugins/nestedRows/nestedRows.js +7 -1
  50. package/plugins/nestedRows/nestedRows.mjs +7 -1
  51. package/renderers/checkboxRenderer/checkboxRenderer.js +4 -4
  52. package/renderers/checkboxRenderer/checkboxRenderer.mjs +4 -4
  53. package/selection/highlight/visualSelection.js +16 -2
  54. package/selection/highlight/visualSelection.mjs +16 -2
  55. package/selection/selection.js +225 -44
  56. package/selection/selection.mjs +224 -43
  57. package/selection/transformation.js +86 -32
  58. package/selection/transformation.mjs +86 -32
  59. package/shortcutContexts/commands/editor/closeAndSave.js +2 -2
  60. package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -2
  61. package/shortcutContexts/commands/editor/open.js +18 -3
  62. package/shortcutContexts/commands/editor/open.mjs +18 -3
  63. package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
  64. package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
  65. package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
  66. package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
  67. package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
  68. package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
  69. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
  70. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
  71. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +3 -1
  72. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +3 -1
  73. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +9 -3
  74. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +9 -3
  75. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +10 -3
  76. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +10 -3
  77. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +3 -1
  78. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +3 -1
  79. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +3 -1
  80. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +3 -1
  81. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +3 -1
  82. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +3 -1
  83. package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
  84. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
  85. package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
  86. package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
  87. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +6 -1
  88. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +6 -1
  89. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +6 -1
  90. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +6 -1
  91. package/shortcutContexts/grid.js +2 -2
  92. package/shortcutContexts/grid.mjs +2 -2
  93. package/shortcuts/context.js +2 -1
  94. package/shortcuts/context.mjs +2 -1
  95. package/tableView.js +20 -0
  96. package/tableView.mjs +20 -0
  97. package/utils/dataStructures/linkedList.js +6 -1
  98. package/utils/dataStructures/linkedList.mjs +6 -1
@@ -26,6 +26,7 @@ import { rangeEach } from "../../helpers/number.mjs";
26
26
  import { applySpanProperties } from "./utils.mjs";
27
27
  import { getStyle } from "../../helpers/dom/element.mjs";
28
28
  import { isChrome } from "../../helpers/browser.mjs";
29
+ import { FocusOrder } from "./focusOrder.mjs";
29
30
  Hooks.getSingleton().register('beforeMergeCells');
30
31
  Hooks.getSingleton().register('afterMergeCells');
31
32
  Hooks.getSingleton().register('beforeUnmergeCells');
@@ -71,16 +72,21 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
71
72
  * ```
72
73
  * :::
73
74
  */
74
- var _lastDesiredCoords = /*#__PURE__*/new WeakMap();
75
+ var _lastSelectedCoords = /*#__PURE__*/new WeakMap();
76
+ var _focusOrder = /*#__PURE__*/new WeakMap();
75
77
  var _onAfterInit = /*#__PURE__*/new WeakSet();
76
78
  var _onAfterIsMultipleSelection = /*#__PURE__*/new WeakSet();
79
+ var _onModifyTransformFocus = /*#__PURE__*/new WeakSet();
77
80
  var _onModifyTransformStart = /*#__PURE__*/new WeakSet();
78
81
  var _onModifyTransformEnd = /*#__PURE__*/new WeakSet();
82
+ var _onModifyTransformEndRestDelta = /*#__PURE__*/new WeakSet();
83
+ var _onBeforeSelectionHighlightSet = /*#__PURE__*/new WeakSet();
79
84
  var _onModifyGetCellCoords = /*#__PURE__*/new WeakSet();
80
85
  var _addMergeActionsToContextMenu = /*#__PURE__*/new WeakSet();
81
86
  var _onAfterRenderer = /*#__PURE__*/new WeakSet();
82
87
  var _onBeforeSetRangeStart = /*#__PURE__*/new WeakSet();
83
- var _onBeforeSetRangeEnd = /*#__PURE__*/new WeakSet();
88
+ var _onAfterSelectionFocusSet = /*#__PURE__*/new WeakSet();
89
+ var _onAfterSelectionEnd = /*#__PURE__*/new WeakSet();
84
90
  var _onAfterGetCellMeta = /*#__PURE__*/new WeakSet();
85
91
  var _onAfterViewportRowCalculatorOverride = /*#__PURE__*/new WeakSet();
86
92
  var _onAfterViewportColumnCalculatorOverride = /*#__PURE__*/new WeakSet();
@@ -91,7 +97,6 @@ var _onAfterCreateRow = /*#__PURE__*/new WeakSet();
91
97
  var _onAfterRemoveRow = /*#__PURE__*/new WeakSet();
92
98
  var _onAfterChange = /*#__PURE__*/new WeakSet();
93
99
  var _onBeforeDrawAreaBorders = /*#__PURE__*/new WeakSet();
94
- var _onAfterModifyTransformStart = /*#__PURE__*/new WeakSet();
95
100
  var _onAfterDrawSelection = /*#__PURE__*/new WeakSet();
96
101
  var _onBeforeRemoveCellClassNames = /*#__PURE__*/new WeakSet();
97
102
  var _onBeforeBeginEditing = /*#__PURE__*/new WeakSet();
@@ -127,17 +132,6 @@ export class MergeCells extends BasePlugin {
127
132
  * processed cell.
128
133
  */
129
134
  _classPrivateMethodInitSpec(this, _onAfterDrawSelection);
130
- /**
131
- * `afterModifyTransformStart` hook callback. Fixes a problem with navigating through merged cells at the edges of
132
- * the table with the <kbd>**Enter**</kbd>/<kbd>**Shift**</kbd>+<kbd>**Enter**</kbd>/<kbd>**Tab**</kbd>/<kbd>**Shift**</kbd>+<kbd>**Tab**</kbd> keys.
133
- *
134
- * @param {CellCoords} coords Coordinates of the to-be-selected cell.
135
- * @param {number} rowTransformDir Row transformation direction (negative value = up, 0 = none, positive value =
136
- * down).
137
- * @param {number} colTransformDir Column transformation direction (negative value = up, 0 = none, positive value =
138
- * down).
139
- */
140
- _classPrivateMethodInitSpec(this, _onAfterModifyTransformStart);
141
135
  /**
142
136
  * `beforeDrawAreaBorders` hook callback.
143
137
  *
@@ -210,20 +204,18 @@ export class MergeCells extends BasePlugin {
210
204
  */
211
205
  _classPrivateMethodInitSpec(this, _onAfterGetCellMeta);
212
206
  /**
213
- * `beforeSetRangeEnd` hook callback.
214
- * While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the
215
- * merged cell.
216
- *
217
- * Note: Please keep in mind that callback may modify both start and end range coordinates by the reference.
218
- *
219
- * @param {object} coords Cell coords.
207
+ * Creates the horizontal and vertical cells order matrix (linked lists) for focused cell.
220
208
  */
221
- _classPrivateMethodInitSpec(this, _onBeforeSetRangeEnd);
209
+ _classPrivateMethodInitSpec(this, _onAfterSelectionEnd);
222
210
  /**
223
- * `beforeSetRangeStart` and `beforeSetRangeStartOnly` hook callback.
224
- * A selection within merge area should be rewritten to the start of merge area.
211
+ * Searches for the node that is currently focused within the vertical and horizontal linked lists.
225
212
  *
226
- * @param {object} coords Cell coords.
213
+ * @param {number} row Visual row index.
214
+ * @param {number} column Visual column index.
215
+ */
216
+ _classPrivateMethodInitSpec(this, _onAfterSelectionFocusSet);
217
+ /**
218
+ * Clears the last selected coordinates before setting a new selection range.
227
219
  */
228
220
  _classPrivateMethodInitSpec(this, _onBeforeSetRangeStart);
229
221
  /**
@@ -249,9 +241,23 @@ export class MergeCells extends BasePlugin {
249
241
  */
250
242
  _classPrivateMethodInitSpec(this, _onModifyGetCellCoords);
251
243
  /**
252
- * `modifyTransformEnd` hook callback. Needed to handle "jumping over" merged merged cells, while selecting.
244
+ * The hook corrects the range (before drawing it) after the selection was made on the merged cells.
245
+ * It expands the range to cover the entire area of the selected merged cells.
246
+ */
247
+ _classPrivateMethodInitSpec(this, _onBeforeSelectionHighlightSet);
248
+ /**
249
+ * The hooks allows to modify the delta transformation object necessary for correct selection end transformations.
253
250
  *
254
- * @param {object} delta The transformation delta.
251
+ * @param {{ row: number, col: number }} restDelta The transformation delta for the rest of the selection.
252
+ * @param {{ row: number, col: number }} delta The general transformation delta.
253
+ * @param {CellCoords} coords The coordinates of the next position of the end selection.
254
+ */
255
+ _classPrivateMethodInitSpec(this, _onModifyTransformEndRestDelta);
256
+ /**
257
+ * The hook allows to modify the delta transformation object necessary for correct selection end transformations.
258
+ * The logic here handles "jumping over" merged merged cells, while selecting.
259
+ *
260
+ * @param {{ row: number, col: number }} delta The transformation delta.
255
261
  */
256
262
  _classPrivateMethodInitSpec(this, _onModifyTransformEnd);
257
263
  /**
@@ -260,6 +266,13 @@ export class MergeCells extends BasePlugin {
260
266
  * @param {object} delta The transformation delta.
261
267
  */
262
268
  _classPrivateMethodInitSpec(this, _onModifyTransformStart);
269
+ /**
270
+ * The hook controls the position of the focus position. For merge cells there is need to shift the focus to the
271
+ * next merged cell not to the next hidden cell (overlapped by merged cell).
272
+ *
273
+ * @param {object} delta The transformation delta.
274
+ */
275
+ _classPrivateMethodInitSpec(this, _onModifyTransformFocus);
263
276
  /**
264
277
  * Modifies the information on whether the current selection contains multiple cells. The `afterIsMultipleSelection`
265
278
  * hook callback.
@@ -294,12 +307,25 @@ export class MergeCells extends BasePlugin {
294
307
  */
295
308
  _defineProperty(this, "selectionCalculations", null);
296
309
  /**
310
+ * The holder for the last selected coordinates. This allows keeping the correct coordinates in cases after the
311
+ * focus is moved out of the merged cell.
312
+ *
297
313
  * @type {CellCoords}
298
314
  */
299
- _classPrivateFieldInitSpec(this, _lastDesiredCoords, {
315
+ _classPrivateFieldInitSpec(this, _lastSelectedCoords, {
300
316
  writable: true,
301
317
  value: null
302
318
  });
319
+ /**
320
+ * The module responsible for providing the correct focus order (vertical and horizontal) within a selection that
321
+ * contains merged cells.
322
+ *
323
+ * @type {FocusOrder}
324
+ */
325
+ _classPrivateFieldInitSpec(this, _focusOrder, {
326
+ writable: true,
327
+ value: new FocusOrder((row, column) => this.mergedCellsCollection.get(row, column))
328
+ });
303
329
  }
304
330
  static get PLUGIN_KEY() {
305
331
  return PLUGIN_KEY;
@@ -334,17 +360,17 @@ export class MergeCells extends BasePlugin {
334
360
  }
335
361
  return _classPrivateMethodGet(_this, _onAfterInit, _onAfterInit2).call(_this, ...args);
336
362
  });
337
- this.addHook('modifyTransformStart', function () {
363
+ this.addHook('modifyTransformFocus', function () {
338
364
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
339
365
  args[_key2] = arguments[_key2];
340
366
  }
341
- return _classPrivateMethodGet(_this, _onModifyTransformStart, _onModifyTransformStart2).call(_this, ...args);
367
+ return _classPrivateMethodGet(_this, _onModifyTransformFocus, _onModifyTransformFocus2).call(_this, ...args);
342
368
  });
343
- this.addHook('afterModifyTransformStart', function () {
369
+ this.addHook('modifyTransformStart', function () {
344
370
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
345
371
  args[_key3] = arguments[_key3];
346
372
  }
347
- return _classPrivateMethodGet(_this, _onAfterModifyTransformStart, _onAfterModifyTransformStart2).call(_this, ...args);
373
+ return _classPrivateMethodGet(_this, _onModifyTransformStart, _onModifyTransformStart2).call(_this, ...args);
348
374
  });
349
375
  this.addHook('modifyTransformEnd', function () {
350
376
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
@@ -352,124 +378,142 @@ export class MergeCells extends BasePlugin {
352
378
  }
353
379
  return _classPrivateMethodGet(_this, _onModifyTransformEnd, _onModifyTransformEnd2).call(_this, ...args);
354
380
  });
355
- this.addHook('modifyGetCellCoords', function () {
381
+ this.addHook('modifyTransformEndRestDelta', function () {
356
382
  for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
357
383
  args[_key5] = arguments[_key5];
358
384
  }
359
- return _classPrivateMethodGet(_this, _onModifyGetCellCoords, _onModifyGetCellCoords2).call(_this, ...args);
385
+ return _classPrivateMethodGet(_this, _onModifyTransformEndRestDelta, _onModifyTransformEndRestDelta2).call(_this, ...args);
360
386
  });
361
- this.addHook('beforeSetRangeStart', function () {
387
+ this.addHook('beforeSelectionHighlightSet', function () {
362
388
  for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
363
389
  args[_key6] = arguments[_key6];
364
390
  }
365
- return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
391
+ return _classPrivateMethodGet(_this, _onBeforeSelectionHighlightSet, _onBeforeSelectionHighlightSet2).call(_this, ...args);
366
392
  });
367
- this.addHook('beforeSetRangeStartOnly', function () {
393
+ this.addHook('beforeSetRangeStart', function () {
368
394
  for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
369
395
  args[_key7] = arguments[_key7];
370
396
  }
371
397
  return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
372
398
  });
373
- this.addHook('beforeSetRangeEnd', function () {
399
+ this.addHook('beforeSetRangeStartOnly', function () {
374
400
  for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
375
401
  args[_key8] = arguments[_key8];
376
402
  }
377
- return _classPrivateMethodGet(_this, _onBeforeSetRangeEnd, _onBeforeSetRangeEnd2).call(_this, ...args);
403
+ return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
378
404
  });
379
- this.addHook('afterIsMultipleSelection', function () {
405
+ this.addHook('afterSelectionFocusSet', function () {
380
406
  for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
381
407
  args[_key9] = arguments[_key9];
382
408
  }
383
- return _classPrivateMethodGet(_this, _onAfterIsMultipleSelection, _onAfterIsMultipleSelection2).call(_this, ...args);
409
+ return _classPrivateMethodGet(_this, _onAfterSelectionFocusSet, _onAfterSelectionFocusSet2).call(_this, ...args);
384
410
  });
385
- this.addHook('afterRenderer', function () {
411
+ this.addHook('afterSelectionEnd', function () {
386
412
  for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
387
413
  args[_key10] = arguments[_key10];
388
414
  }
389
- return _classPrivateMethodGet(_this, _onAfterRenderer, _onAfterRenderer2).call(_this, ...args);
415
+ return _classPrivateMethodGet(_this, _onAfterSelectionEnd, _onAfterSelectionEnd2).call(_this, ...args);
390
416
  });
391
- this.addHook('afterContextMenuDefaultOptions', function () {
417
+ this.addHook('modifyGetCellCoords', function () {
392
418
  for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
393
419
  args[_key11] = arguments[_key11];
394
420
  }
395
- return _classPrivateMethodGet(_this, _addMergeActionsToContextMenu, _addMergeActionsToContextMenu2).call(_this, ...args);
421
+ return _classPrivateMethodGet(_this, _onModifyGetCellCoords, _onModifyGetCellCoords2).call(_this, ...args);
396
422
  });
397
- this.addHook('afterGetCellMeta', function () {
423
+ this.addHook('afterIsMultipleSelection', function () {
398
424
  for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
399
425
  args[_key12] = arguments[_key12];
400
426
  }
401
- return _classPrivateMethodGet(_this, _onAfterGetCellMeta, _onAfterGetCellMeta2).call(_this, ...args);
427
+ return _classPrivateMethodGet(_this, _onAfterIsMultipleSelection, _onAfterIsMultipleSelection2).call(_this, ...args);
402
428
  });
403
- this.addHook('afterViewportRowCalculatorOverride', function () {
429
+ this.addHook('afterRenderer', function () {
404
430
  for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
405
431
  args[_key13] = arguments[_key13];
406
432
  }
407
- return _classPrivateMethodGet(_this, _onAfterViewportRowCalculatorOverride, _onAfterViewportRowCalculatorOverride2).call(_this, ...args);
433
+ return _classPrivateMethodGet(_this, _onAfterRenderer, _onAfterRenderer2).call(_this, ...args);
408
434
  });
409
- this.addHook('afterViewportColumnCalculatorOverride', function () {
435
+ this.addHook('afterContextMenuDefaultOptions', function () {
410
436
  for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
411
437
  args[_key14] = arguments[_key14];
412
438
  }
413
- return _classPrivateMethodGet(_this, _onAfterViewportColumnCalculatorOverride, _onAfterViewportColumnCalculatorOverride2).call(_this, ...args);
439
+ return _classPrivateMethodGet(_this, _addMergeActionsToContextMenu, _addMergeActionsToContextMenu2).call(_this, ...args);
414
440
  });
415
- this.addHook('modifyAutofillRange', function () {
441
+ this.addHook('afterGetCellMeta', function () {
416
442
  for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
417
443
  args[_key15] = arguments[_key15];
418
444
  }
419
- return _classPrivateMethodGet(_this, _onModifyAutofillRange, _onModifyAutofillRange2).call(_this, ...args);
445
+ return _classPrivateMethodGet(_this, _onAfterGetCellMeta, _onAfterGetCellMeta2).call(_this, ...args);
420
446
  });
421
- this.addHook('afterCreateCol', function () {
447
+ this.addHook('afterViewportRowCalculatorOverride', function () {
422
448
  for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
423
449
  args[_key16] = arguments[_key16];
424
450
  }
425
- return _classPrivateMethodGet(_this, _onAfterCreateCol, _onAfterCreateCol2).call(_this, ...args);
451
+ return _classPrivateMethodGet(_this, _onAfterViewportRowCalculatorOverride, _onAfterViewportRowCalculatorOverride2).call(_this, ...args);
426
452
  });
427
- this.addHook('afterRemoveCol', function () {
453
+ this.addHook('afterViewportColumnCalculatorOverride', function () {
428
454
  for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
429
455
  args[_key17] = arguments[_key17];
430
456
  }
431
- return _classPrivateMethodGet(_this, _onAfterRemoveCol, _onAfterRemoveCol2).call(_this, ...args);
457
+ return _classPrivateMethodGet(_this, _onAfterViewportColumnCalculatorOverride, _onAfterViewportColumnCalculatorOverride2).call(_this, ...args);
432
458
  });
433
- this.addHook('afterCreateRow', function () {
459
+ this.addHook('modifyAutofillRange', function () {
434
460
  for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
435
461
  args[_key18] = arguments[_key18];
436
462
  }
437
- return _classPrivateMethodGet(_this, _onAfterCreateRow, _onAfterCreateRow2).call(_this, ...args);
463
+ return _classPrivateMethodGet(_this, _onModifyAutofillRange, _onModifyAutofillRange2).call(_this, ...args);
438
464
  });
439
- this.addHook('afterRemoveRow', function () {
465
+ this.addHook('afterCreateCol', function () {
440
466
  for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
441
467
  args[_key19] = arguments[_key19];
442
468
  }
443
- return _classPrivateMethodGet(_this, _onAfterRemoveRow, _onAfterRemoveRow2).call(_this, ...args);
469
+ return _classPrivateMethodGet(_this, _onAfterCreateCol, _onAfterCreateCol2).call(_this, ...args);
444
470
  });
445
- this.addHook('afterChange', function () {
471
+ this.addHook('afterRemoveCol', function () {
446
472
  for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
447
473
  args[_key20] = arguments[_key20];
448
474
  }
449
- return _classPrivateMethodGet(_this, _onAfterChange, _onAfterChange2).call(_this, ...args);
475
+ return _classPrivateMethodGet(_this, _onAfterRemoveCol, _onAfterRemoveCol2).call(_this, ...args);
450
476
  });
451
- this.addHook('beforeDrawBorders', function () {
477
+ this.addHook('afterCreateRow', function () {
452
478
  for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
453
479
  args[_key21] = arguments[_key21];
454
480
  }
455
- return _classPrivateMethodGet(_this, _onBeforeDrawAreaBorders, _onBeforeDrawAreaBorders2).call(_this, ...args);
481
+ return _classPrivateMethodGet(_this, _onAfterCreateRow, _onAfterCreateRow2).call(_this, ...args);
456
482
  });
457
- this.addHook('afterDrawSelection', function () {
483
+ this.addHook('afterRemoveRow', function () {
458
484
  for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
459
485
  args[_key22] = arguments[_key22];
460
486
  }
461
- return _classPrivateMethodGet(_this, _onAfterDrawSelection, _onAfterDrawSelection2).call(_this, ...args);
487
+ return _classPrivateMethodGet(_this, _onAfterRemoveRow, _onAfterRemoveRow2).call(_this, ...args);
462
488
  });
463
- this.addHook('beforeRemoveCellClassNames', function () {
489
+ this.addHook('afterChange', function () {
464
490
  for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
465
491
  args[_key23] = arguments[_key23];
466
492
  }
467
- return _classPrivateMethodGet(_this, _onBeforeRemoveCellClassNames, _onBeforeRemoveCellClassNames2).call(_this, ...args);
493
+ return _classPrivateMethodGet(_this, _onAfterChange, _onAfterChange2).call(_this, ...args);
468
494
  });
469
- this.addHook('beforeBeginEditing', function () {
495
+ this.addHook('beforeDrawBorders', function () {
470
496
  for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
471
497
  args[_key24] = arguments[_key24];
472
498
  }
499
+ return _classPrivateMethodGet(_this, _onBeforeDrawAreaBorders, _onBeforeDrawAreaBorders2).call(_this, ...args);
500
+ });
501
+ this.addHook('afterDrawSelection', function () {
502
+ for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
503
+ args[_key25] = arguments[_key25];
504
+ }
505
+ return _classPrivateMethodGet(_this, _onAfterDrawSelection, _onAfterDrawSelection2).call(_this, ...args);
506
+ });
507
+ this.addHook('beforeRemoveCellClassNames', function () {
508
+ for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
509
+ args[_key26] = arguments[_key26];
510
+ }
511
+ return _classPrivateMethodGet(_this, _onBeforeRemoveCellClassNames, _onBeforeRemoveCellClassNames2).call(_this, ...args);
512
+ });
513
+ this.addHook('beforeBeginEditing', function () {
514
+ for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
515
+ args[_key27] = arguments[_key27];
516
+ }
473
517
  return _classPrivateMethodGet(_this, _onBeforeBeginEditing, _onBeforeBeginEditing2).call(_this, ...args);
474
518
  });
475
519
  this.addHook('beforeUndoStackChange', (action, source) => {
@@ -638,25 +682,6 @@ export class MergeCells extends BasePlugin {
638
682
  return auto ? true : this.validateSetting(newMergedCellInfo);
639
683
  }
640
684
 
641
- /**
642
- * Merge or unmerge, based on last selected range.
643
- *
644
- * @private
645
- */
646
- toggleMergeOnSelection() {
647
- const currentRange = this.hot.getSelectedRangeLast();
648
- if (!currentRange) {
649
- return;
650
- }
651
- currentRange.setDirection(this.hot.isRtl() ? 'NE-SW' : 'NW-SE');
652
- const {
653
- from,
654
- to
655
- } = currentRange;
656
- this.toggleMerge(currentRange);
657
- this.hot.selectCell(from.row, from.col, to.row, to.col, false);
658
- }
659
-
660
685
  /**
661
686
  * Merges the selection provided as a cell range.
662
687
  *
@@ -1026,84 +1051,295 @@ function _onAfterIsMultipleSelection2(isMultiple) {
1026
1051
  if (isMultiple) {
1027
1052
  const mergedCells = this.mergedCellsCollection.mergedCells;
1028
1053
  const selectionRange = this.hot.getSelectedRangeLast();
1054
+ const topStartCoords = selectionRange.getTopStartCorner();
1055
+ const bottomEndCoords = selectionRange.getBottomEndCorner();
1029
1056
  for (let group = 0; group < mergedCells.length; group += 1) {
1030
- if (selectionRange.from.row === mergedCells[group].row && selectionRange.from.col === mergedCells[group].col && selectionRange.to.row === mergedCells[group].row + mergedCells[group].rowspan - 1 && selectionRange.to.col === mergedCells[group].col + mergedCells[group].colspan - 1) {
1057
+ if (topStartCoords.row === mergedCells[group].row && topStartCoords.col === mergedCells[group].col && bottomEndCoords.row === mergedCells[group].row + mergedCells[group].rowspan - 1 && bottomEndCoords.col === mergedCells[group].col + mergedCells[group].colspan - 1) {
1031
1058
  return false;
1032
1059
  }
1033
1060
  }
1034
1061
  }
1035
1062
  return isMultiple;
1036
1063
  }
1037
- function _onModifyTransformStart2(delta) {
1038
- const currentlySelectedRange = this.hot.getSelectedRangeLast();
1039
- let newDelta = {
1040
- row: delta.row,
1041
- col: delta.col
1064
+ function _onModifyTransformFocus2(delta) {
1065
+ const selectedRange = this.hot.getSelectedRangeLast();
1066
+ const {
1067
+ highlight
1068
+ } = selectedRange;
1069
+ const {
1070
+ columnIndexMapper,
1071
+ rowIndexMapper
1072
+ } = this.hot;
1073
+ const deltaCorrection = {
1074
+ row: 0,
1075
+ col: 0
1042
1076
  };
1043
- let nextPosition = null;
1044
- const currentPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row, currentlySelectedRange.highlight.col);
1045
- const mergedParent = this.mergedCellsCollection.get(currentPosition.row, currentPosition.col);
1046
- if (!_classPrivateFieldGet(this, _lastDesiredCoords)) {
1047
- _classPrivateFieldSet(this, _lastDesiredCoords, this.hot._createCellCoords(null, null));
1077
+ if (delta.col < 0) {
1078
+ const {
1079
+ rowStart,
1080
+ colEnd
1081
+ } = _classPrivateFieldGet(this, _focusOrder).getPrevHorizontalNode();
1082
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(colEnd, -1);
1083
+ const notHiddenRowStart = rowIndexMapper.getNearestNotHiddenIndex(rowStart, -1);
1084
+ if (notHiddenRowStart > highlight.row) {
1085
+ delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1;
1086
+ deltaCorrection.row = this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowStart) - 1;
1087
+ } else if (notHiddenRowStart < highlight.row) {
1088
+ delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1;
1089
+ deltaCorrection.row = -(this.hot.view.countRenderableRowsInRange(notHiddenRowStart, highlight.row) - 1);
1090
+ } else if (notHiddenColumnIndex === null) {
1091
+ delta.col = -this.hot.view.countRenderableColumnsInRange(0, highlight.col);
1092
+ } else if (notHiddenColumnIndex <= highlight.col) {
1093
+ delta.col = -Math.max(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1, 1);
1094
+ } else {
1095
+ delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1;
1096
+ }
1097
+ } else if (delta.col > 0) {
1098
+ const {
1099
+ rowStart,
1100
+ colStart
1101
+ } = _classPrivateFieldGet(this, _focusOrder).getNextHorizontalNode();
1102
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(colStart, 1);
1103
+ const notHiddenRowStart = rowIndexMapper.getNearestNotHiddenIndex(rowStart, 1);
1104
+ if (notHiddenRowStart > highlight.row) {
1105
+ delta.col = -(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1);
1106
+ deltaCorrection.row = this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowStart) - 1;
1107
+ } else if (notHiddenRowStart < highlight.row) {
1108
+ delta.col = -(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1);
1109
+ deltaCorrection.row = -(this.hot.view.countRenderableRowsInRange(notHiddenRowStart, highlight.row) - 1);
1110
+ } else if (notHiddenColumnIndex === null) {
1111
+ delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, this.hot.countCols());
1112
+ } else if (highlight.col <= notHiddenColumnIndex) {
1113
+ delta.col = Math.max(this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1, 1);
1114
+ } else {
1115
+ delta.col = -(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1);
1116
+ }
1048
1117
  }
1049
- if (mergedParent) {
1050
- // only merge selected
1051
- const mergeTopLeft = this.hot._createCellCoords(mergedParent.row, mergedParent.col);
1052
- const mergeBottomRight = this.hot._createCellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1);
1053
- const mergeRange = this.hot._createCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
1054
- if (!mergeRange.includes(_classPrivateFieldGet(this, _lastDesiredCoords))) {
1055
- _classPrivateFieldSet(this, _lastDesiredCoords, this.hot._createCellCoords(null, null)); // reset outdated version of lastDesiredCoords
1118
+ if (delta.row < 0) {
1119
+ const {
1120
+ colStart,
1121
+ rowEnd
1122
+ } = _classPrivateFieldGet(this, _focusOrder).getPrevVerticalNode();
1123
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(rowEnd, -1);
1124
+ const notHiddenColumnStart = columnIndexMapper.getNearestNotHiddenIndex(colStart, -1);
1125
+ if (notHiddenColumnStart > highlight.col) {
1126
+ delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1;
1127
+ deltaCorrection.col = this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnStart) - 1;
1128
+ } else if (notHiddenColumnStart < highlight.col) {
1129
+ delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1;
1130
+ deltaCorrection.col = -(this.hot.view.countRenderableColumnsInRange(notHiddenColumnStart, highlight.col) - 1);
1131
+ } else if (notHiddenRowIndex === null) {
1132
+ delta.row = -this.hot.view.countRenderableRowsInRange(0, highlight.row);
1133
+ } else if (notHiddenRowIndex <= highlight.row) {
1134
+ delta.row = -Math.max(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1, 1);
1135
+ } else {
1136
+ delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1;
1056
1137
  }
1057
- newDelta.row = _classPrivateFieldGet(this, _lastDesiredCoords).row ? _classPrivateFieldGet(this, _lastDesiredCoords).row - currentPosition.row : newDelta.row;
1058
- newDelta.col = _classPrivateFieldGet(this, _lastDesiredCoords).col ? _classPrivateFieldGet(this, _lastDesiredCoords).col - currentPosition.col : newDelta.col;
1059
- if (delta.row > 0) {
1060
- // moving down
1061
- newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
1062
- } else if (delta.row < 0) {
1063
- // moving up
1064
- newDelta.row = currentPosition.row - mergedParent.row + delta.row;
1138
+ } else if (delta.row > 0) {
1139
+ const {
1140
+ colStart,
1141
+ rowStart
1142
+ } = _classPrivateFieldGet(this, _focusOrder).getNextVerticalNode();
1143
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(rowStart, 1);
1144
+ const notHiddenColumnStart = columnIndexMapper.getNearestNotHiddenIndex(colStart, 1);
1145
+ if (notHiddenColumnStart > highlight.col) {
1146
+ delta.row = -(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1);
1147
+ deltaCorrection.col = this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnStart) - 1;
1148
+ } else if (notHiddenColumnStart < highlight.col) {
1149
+ delta.row = -(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1);
1150
+ deltaCorrection.col = -(this.hot.view.countRenderableColumnsInRange(notHiddenColumnStart, highlight.col) - 1);
1151
+ } else if (notHiddenRowIndex === null) {
1152
+ delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, this.hot.countRows());
1153
+ } else if (highlight.row <= notHiddenRowIndex) {
1154
+ delta.row = Math.max(this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1, 1);
1155
+ } else {
1156
+ delta.row = -(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1);
1157
+ }
1158
+ }
1159
+ if (deltaCorrection.row !== 0) {
1160
+ delta.row = deltaCorrection.row;
1161
+ }
1162
+ if (deltaCorrection.col !== 0) {
1163
+ delta.col = deltaCorrection.col;
1164
+ }
1165
+ }
1166
+ function _onModifyTransformStart2(delta) {
1167
+ const selectedRange = this.hot.getSelectedRangeLast();
1168
+ const {
1169
+ highlight
1170
+ } = selectedRange;
1171
+ const {
1172
+ columnIndexMapper,
1173
+ rowIndexMapper
1174
+ } = this.hot;
1175
+ if (_classPrivateFieldGet(this, _lastSelectedCoords)) {
1176
+ if (rowIndexMapper.getRenderableFromVisualIndex(_classPrivateFieldGet(this, _lastSelectedCoords).row) !== null) {
1177
+ highlight.row = _classPrivateFieldGet(this, _lastSelectedCoords).row;
1065
1178
  }
1066
- if (delta.col > 0) {
1067
- // moving right
1068
- newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
1069
- } else if (delta.col < 0) {
1070
- // moving left
1071
- newDelta.col = currentPosition.col - mergedParent.col + delta.col;
1179
+ if (columnIndexMapper.getRenderableFromVisualIndex(_classPrivateFieldGet(this, _lastSelectedCoords).col) !== null) {
1180
+ highlight.col = _classPrivateFieldGet(this, _lastSelectedCoords).col;
1072
1181
  }
1182
+ _classPrivateFieldSet(this, _lastSelectedCoords, null);
1073
1183
  }
1074
- nextPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row + newDelta.row, currentlySelectedRange.highlight.col + newDelta.col);
1075
- const nextPositionMergedCell = this.mergedCellsCollection.get(nextPosition.row, nextPosition.col);
1076
- if (nextPositionMergedCell) {
1077
- // skipping the invisible cells in the merge range
1078
- const firstRenderableCoords = this.mergedCellsCollection.getFirstRenderableCoords(nextPositionMergedCell.row, nextPositionMergedCell.col);
1079
- _classPrivateFieldSet(this, _lastDesiredCoords, nextPosition);
1080
- newDelta = {
1081
- row: firstRenderableCoords.row - currentPosition.row,
1082
- col: firstRenderableCoords.col - currentPosition.col
1083
- };
1184
+ const mergedParent = this.mergedCellsCollection.get(highlight.row, highlight.col);
1185
+ if (!mergedParent) {
1186
+ return;
1084
1187
  }
1085
- if (newDelta.row !== 0) {
1086
- delta.row = newDelta.row;
1188
+ const visualColumnIndexStart = mergedParent.col;
1189
+ const visualColumnIndexEnd = mergedParent.col + mergedParent.colspan - 1;
1190
+ if (delta.col < 0) {
1191
+ const nextColumn = highlight.col >= visualColumnIndexStart && highlight.col <= visualColumnIndexEnd ? visualColumnIndexStart - 1 : visualColumnIndexEnd;
1192
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, -1);
1193
+ if (notHiddenColumnIndex === null) {
1194
+ // There are no visible columns anymore, so move the selection out of the table edge. This will
1195
+ // be processed by the selection Transformer class as a move selection to the previous row (if autoWrapRow is enabled).
1196
+ delta.col = -this.hot.view.countRenderableColumnsInRange(0, highlight.col);
1197
+ } else {
1198
+ delta.col = -Math.max(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1, 1);
1199
+ }
1200
+ } else if (delta.col > 0) {
1201
+ const nextColumn = highlight.col >= visualColumnIndexStart && highlight.col <= visualColumnIndexEnd ? visualColumnIndexEnd + 1 : visualColumnIndexStart;
1202
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, 1);
1203
+ if (notHiddenColumnIndex === null) {
1204
+ // There are no visible columns anymore, so move the selection out of the table edge. This will
1205
+ // be processed by the selection Transformer class as a move selection to the next row (if autoWrapRow is enabled).
1206
+ delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, this.hot.countCols());
1207
+ } else {
1208
+ delta.col = Math.max(this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1, 1);
1209
+ }
1087
1210
  }
1088
- if (newDelta.col !== 0) {
1089
- delta.col = newDelta.col;
1211
+ const visualRowIndexStart = mergedParent.row;
1212
+ const visualRowIndexEnd = mergedParent.row + mergedParent.rowspan - 1;
1213
+ if (delta.row < 0) {
1214
+ const nextRow = highlight.row >= visualRowIndexStart && highlight.row <= visualRowIndexEnd ? visualRowIndexStart - 1 : visualRowIndexEnd;
1215
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, -1);
1216
+ if (notHiddenRowIndex === null) {
1217
+ // There are no visible rows anymore, so move the selection out of the table edge. This will
1218
+ // be processed by the selection Transformer class as a move selection to the previous column (if autoWrapCol is enabled).
1219
+ delta.row = -this.hot.view.countRenderableRowsInRange(0, highlight.row);
1220
+ } else {
1221
+ delta.row = -Math.max(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1, 1);
1222
+ }
1223
+ } else if (delta.row > 0) {
1224
+ const nextRow = highlight.row >= visualRowIndexStart && highlight.row <= visualRowIndexEnd ? visualRowIndexEnd + 1 : visualRowIndexStart;
1225
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, 1);
1226
+ if (notHiddenRowIndex === null) {
1227
+ // There are no visible rows anymore, so move the selection out of the table edge. This will
1228
+ // be processed by the selection Transformer class as a move selection to the next column (if autoWrapCol is enabled).
1229
+ delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, this.hot.countRows());
1230
+ } else {
1231
+ delta.row = Math.max(this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1, 1);
1232
+ }
1090
1233
  }
1091
1234
  }
1092
1235
  function _onModifyTransformEnd2(delta) {
1093
- const currentSelectionRange = this.hot.getSelectedRangeLast();
1094
- const newDelta = clone(delta);
1095
- const newSelectionRange = this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, delta);
1096
- let tempDelta = clone(newDelta);
1097
- const mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(newSelectionRange, true);
1098
- do {
1099
- tempDelta = clone(newDelta);
1100
- this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, newDelta);
1101
- arrayEach(mergedCellsWithinRange, mergedCell => {
1102
- this.selectionCalculations.snapDelta(newDelta, currentSelectionRange, mergedCell);
1103
- });
1104
- } while (newDelta.row !== tempDelta.row || newDelta.col !== tempDelta.col);
1105
- delta.row = newDelta.row;
1106
- delta.col = newDelta.col;
1236
+ const selectedRange = this.hot.getSelectedRangeLast();
1237
+ const cloneRange = selectedRange.clone();
1238
+ const {
1239
+ to
1240
+ } = selectedRange;
1241
+ const {
1242
+ columnIndexMapper,
1243
+ rowIndexMapper
1244
+ } = this.hot;
1245
+ const expandCloneRange = (row, col) => {
1246
+ cloneRange.expand(this.hot._createCellCoords(row, col));
1247
+ for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1248
+ cloneRange.expandByRange(this.mergedCellsCollection.mergedCells[i].getRange());
1249
+ }
1250
+ };
1251
+ if (delta.col < 0) {
1252
+ let nextColumn = this.mergedCellsCollection.getStartMostColumnIndex(selectedRange, to.col) + delta.col;
1253
+ expandCloneRange(to.row, nextColumn);
1254
+ if (selectedRange.getHorizontalDirection() === 'E-W' && cloneRange.getHorizontalDirection() === 'E-W') {
1255
+ nextColumn = cloneRange.getTopStartCorner().col;
1256
+ }
1257
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, 1);
1258
+ if (notHiddenColumnIndex !== null) {
1259
+ delta.col = -Math.max(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, to.col) - 1, 1);
1260
+ }
1261
+ } else if (delta.col > 0) {
1262
+ let nextColumn = this.mergedCellsCollection.getEndMostColumnIndex(selectedRange, to.col) + delta.col;
1263
+ expandCloneRange(to.row, nextColumn);
1264
+ if (selectedRange.getHorizontalDirection() === 'W-E' && cloneRange.getHorizontalDirection() === 'W-E') {
1265
+ nextColumn = cloneRange.getBottomEndCorner().col;
1266
+ }
1267
+ const notHiddenColumnIndex = columnIndexMapper.getNearestNotHiddenIndex(nextColumn, -1);
1268
+ if (notHiddenColumnIndex !== null) {
1269
+ delta.col = Math.max(this.hot.view.countRenderableColumnsInRange(to.col, notHiddenColumnIndex) - 1, 1);
1270
+ }
1271
+ }
1272
+ if (delta.row < 0) {
1273
+ let nextRow = this.mergedCellsCollection.getTopMostRowIndex(selectedRange, to.row) + delta.row;
1274
+ expandCloneRange(nextRow, to.col);
1275
+ if (selectedRange.getVerticalDirection() === 'S-N' && cloneRange.getVerticalDirection() === 'S-N') {
1276
+ nextRow = cloneRange.getTopStartCorner().row;
1277
+ }
1278
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, 1);
1279
+ if (notHiddenRowIndex !== null) {
1280
+ delta.row = -Math.max(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, to.row) - 1, 1);
1281
+ }
1282
+ } else if (delta.row > 0) {
1283
+ let nextRow = this.mergedCellsCollection.getBottomMostRowIndex(selectedRange, to.row) + delta.row;
1284
+ expandCloneRange(nextRow, to.col);
1285
+ if (selectedRange.getVerticalDirection() === 'N-S' && cloneRange.getVerticalDirection() === 'N-S') {
1286
+ nextRow = cloneRange.getBottomStartCorner().row;
1287
+ }
1288
+ const notHiddenRowIndex = rowIndexMapper.getNearestNotHiddenIndex(nextRow, -1);
1289
+ if (notHiddenRowIndex !== null) {
1290
+ delta.row = Math.max(this.hot.view.countRenderableRowsInRange(to.row, notHiddenRowIndex) - 1, 1);
1291
+ }
1292
+ }
1293
+ }
1294
+ function _onModifyTransformEndRestDelta2(restDelta, delta, coords) {
1295
+ const selectedRange = this.hot.getSelectedRangeLast();
1296
+ const {
1297
+ highlight
1298
+ } = selectedRange;
1299
+ const mergeParent = this.mergedCellsCollection.get(highlight.row, highlight.col);
1300
+ if (!mergeParent) {
1301
+ return;
1302
+ }
1303
+ const topStartCorner = selectedRange.getTopStartCorner();
1304
+ const topEndCorner = selectedRange.getTopEndCorner();
1305
+ const bottomEndCorner = selectedRange.getBottomEndCorner();
1306
+ if (delta.col > 0) {
1307
+ const renderableColumns = this.hot.view.countRenderableColumnsInRange(topEndCorner.col, coords.col) - 1;
1308
+ restDelta.col = Math.max(renderableColumns, 1);
1309
+ } else if (delta.col < 0) {
1310
+ const renderableColumns = this.hot.view.countRenderableColumnsInRange(coords.col, topStartCorner.col) - 1;
1311
+ restDelta.col = -Math.max(renderableColumns, 1);
1312
+ }
1313
+ if (delta.row > 0) {
1314
+ const renderableRows = this.hot.view.countRenderableRowsInRange(bottomEndCorner.row, coords.row) - 1;
1315
+ restDelta.row = Math.max(renderableRows, 1);
1316
+ } else if (delta.row < 0) {
1317
+ const renderableRows = this.hot.view.countRenderableRowsInRange(coords.row, topStartCorner.row) - 1;
1318
+ restDelta.row = -Math.max(renderableRows, 1);
1319
+ }
1320
+ }
1321
+ function _onBeforeSelectionHighlightSet2() {
1322
+ if (this.hot.selection.isSelectedByColumnHeader() || this.hot.selection.isSelectedByRowHeader()) {
1323
+ return;
1324
+ }
1325
+ const selectedRange = this.hot.getSelectedRangeLast();
1326
+ const {
1327
+ highlight
1328
+ } = selectedRange;
1329
+ for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1330
+ selectedRange.expandByRange(this.mergedCellsCollection.mergedCells[i].getRange(), false);
1331
+ }
1332
+ // TODO: This is a workaround for an issue with the selection not being extended properly.
1333
+ // In some cases when the merge cells are defined in random order the selection is not
1334
+ // extended in that way that it covers all overlapped merge cells.
1335
+ for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1336
+ selectedRange.expandByRange(this.mergedCellsCollection.mergedCells[i].getRange(), false);
1337
+ }
1338
+ const mergedParent = this.mergedCellsCollection.get(highlight.row, highlight.col);
1339
+ _classPrivateFieldSet(this, _lastSelectedCoords, highlight.clone());
1340
+ if (mergedParent) {
1341
+ highlight.assign(mergedParent);
1342
+ }
1107
1343
  }
1108
1344
  function _onModifyGetCellCoords2(row, column) {
1109
1345
  if (row < 0 || column < 0) {
@@ -1162,37 +1398,17 @@ function _onAfterRenderer2(TD, row, col) {
1162
1398
  }
1163
1399
  applySpanProperties(TD, mergedCellCopy, row, col);
1164
1400
  }
1165
- function _onBeforeSetRangeStart2(coords) {
1166
- // TODO: It is a workaround, but probably this hook may be needed. Every selection on the merge area
1167
- // could set start point of the selection to the start of the merge area. However, logic inside `expandByRange` need
1168
- // an initial start point. Click on the merge cell when there are some hidden indexes break the logic in some cases.
1169
- // Please take a look at #7010 for more information. I'm not sure if selection directions are calculated properly
1170
- // and what was idea for flipping direction inside `expandByRange` method.
1171
- if (this.mergedCellsCollection.isFirstRenderableMergedCell(coords.row, coords.col)) {
1172
- const mergeParent = this.mergedCellsCollection.get(coords.row, coords.col);
1173
- [coords.row, coords.col] = [mergeParent.row, mergeParent.col];
1174
- }
1401
+ function _onBeforeSetRangeStart2() {
1402
+ _classPrivateFieldSet(this, _lastSelectedCoords, null);
1175
1403
  }
1176
- function _onBeforeSetRangeEnd2(coords) {
1177
- const selRange = this.hot.getSelectedRangeLast();
1178
- selRange.highlight = this.hot._createCellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference
1179
- selRange.to = coords;
1180
- let rangeExpanded = false;
1181
- if (this.hot.selection.isSelectedByColumnHeader() || this.hot.selection.isSelectedByRowHeader()) {
1182
- return;
1404
+ function _onAfterSelectionFocusSet2(row, column) {
1405
+ _classPrivateFieldGet(this, _focusOrder).setActiveNode(row, column);
1406
+ }
1407
+ function _onAfterSelectionEnd2() {
1408
+ const selection = this.hot.getSelectedRangeLast();
1409
+ if (!selection.isHeader()) {
1410
+ _classPrivateFieldGet(this, _focusOrder).buildFocusOrder(this.hot.getSelectedRangeLast());
1183
1411
  }
1184
- do {
1185
- rangeExpanded = false;
1186
- for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1187
- const cellInfo = this.mergedCellsCollection.mergedCells[i];
1188
- const mergedCellRange = cellInfo.getRange();
1189
- if (selRange.expandByRange(mergedCellRange)) {
1190
- coords.row = selRange.to.row;
1191
- coords.col = selRange.to.col;
1192
- rangeExpanded = true;
1193
- }
1194
- }
1195
- } while (rangeExpanded);
1196
1412
  }
1197
1413
  function _onAfterGetCellMeta2(row, col, cellProperties) {
1198
1414
  const mergeParent = this.mergedCellsCollection.get(row, col);
@@ -1272,27 +1488,6 @@ function _onBeforeDrawAreaBorders2(corners, className) {
1272
1488
  });
1273
1489
  }
1274
1490
  }
1275
- function _onAfterModifyTransformStart2(coords, rowTransformDir, colTransformDir) {
1276
- if (!this.enabled) {
1277
- return;
1278
- }
1279
- const mergedCellAtCoords = this.mergedCellsCollection.get(coords.row, coords.col);
1280
- if (!mergedCellAtCoords) {
1281
- return;
1282
- }
1283
- const goingDown = rowTransformDir > 0;
1284
- const goingUp = rowTransformDir < 0;
1285
- const goingLeft = colTransformDir < 0;
1286
- const goingRight = colTransformDir > 0;
1287
- const mergedCellOnBottomEdge = mergedCellAtCoords.row + mergedCellAtCoords.rowspan - 1 === this.hot.countRows() - 1;
1288
- const mergedCellOnTopEdge = mergedCellAtCoords.row === 0;
1289
- const mergedCellOnRightEdge = mergedCellAtCoords.col + mergedCellAtCoords.colspan - 1 === this.hot.countCols() - 1;
1290
- const mergedCellOnLeftEdge = mergedCellAtCoords.col === 0;
1291
- if (goingDown && mergedCellOnBottomEdge || goingUp && mergedCellOnTopEdge || goingRight && mergedCellOnRightEdge || goingLeft && mergedCellOnLeftEdge) {
1292
- coords.row = mergedCellAtCoords.row;
1293
- coords.col = mergedCellAtCoords.col;
1294
- }
1295
- }
1296
1491
  function _onAfterDrawSelection2(currentRow, currentColumn, cornersOfSelection, layerLevel) {
1297
1492
  // Nothing's selected (hook might be triggered by the custom borders)
1298
1493
  if (!cornersOfSelection) {