handsontable 0.0.0-next-d96e9b5-20240220 → 0.0.0-next-d4816a9-20240221

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 (89) hide show
  1. package/3rdparty/walkontable/src/cell/range.d.ts +0 -1
  2. package/3rdparty/walkontable/src/cell/range.js +0 -12
  3. package/3rdparty/walkontable/src/cell/range.mjs +0 -12
  4. package/base.js +2 -2
  5. package/base.mjs +2 -2
  6. package/core/viewportScroll/index.js +1 -4
  7. package/core/viewportScroll/index.mjs +1 -4
  8. package/core.js +0 -14
  9. package/core.mjs +0 -14
  10. package/dist/handsontable.css +2 -2
  11. package/dist/handsontable.full.css +2 -2
  12. package/dist/handsontable.full.js +1328 -1606
  13. package/dist/handsontable.full.min.css +2 -2
  14. package/dist/handsontable.full.min.js +151 -151
  15. package/dist/handsontable.js +1328 -1606
  16. package/dist/handsontable.min.css +2 -2
  17. package/dist/handsontable.min.js +19 -19
  18. package/editorManager.js +8 -12
  19. package/editorManager.mjs +8 -12
  20. package/helpers/mixed.js +1 -1
  21. package/helpers/mixed.mjs +1 -1
  22. package/package.json +1 -1
  23. package/pluginHooks.d.ts +0 -1
  24. package/pluginHooks.js +1 -43
  25. package/pluginHooks.mjs +1 -43
  26. package/plugins/collapsibleColumns/collapsibleColumns.js +1 -7
  27. package/plugins/collapsibleColumns/collapsibleColumns.mjs +1 -7
  28. package/plugins/columnSorting/columnSorting.js +0 -6
  29. package/plugins/columnSorting/columnSorting.mjs +0 -6
  30. package/plugins/contextMenu/menu/defaultShortcutsList.js +10 -26
  31. package/plugins/contextMenu/menu/defaultShortcutsList.mjs +10 -26
  32. package/plugins/mergeCells/calculations/selection.js +70 -1
  33. package/plugins/mergeCells/calculations/selection.mjs +70 -1
  34. package/plugins/mergeCells/contextMenuItem/toggleMerge.js +1 -11
  35. package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +1 -11
  36. package/plugins/mergeCells/mergeCells.js +207 -182
  37. package/plugins/mergeCells/mergeCells.mjs +207 -182
  38. package/plugins/multiColumnSorting/multiColumnSorting.js +0 -6
  39. package/plugins/multiColumnSorting/multiColumnSorting.mjs +0 -6
  40. package/plugins/nestedHeaders/nestedHeaders.js +0 -1
  41. package/plugins/nestedHeaders/nestedHeaders.mjs +0 -1
  42. package/plugins/nestedRows/nestedRows.js +1 -7
  43. package/plugins/nestedRows/nestedRows.mjs +1 -7
  44. package/renderers/checkboxRenderer/checkboxRenderer.js +4 -4
  45. package/renderers/checkboxRenderer/checkboxRenderer.mjs +4 -4
  46. package/selection/highlight/visualSelection.js +0 -2
  47. package/selection/highlight/visualSelection.mjs +0 -2
  48. package/selection/selection.js +34 -195
  49. package/selection/selection.mjs +33 -194
  50. package/selection/transformation.js +30 -45
  51. package/selection/transformation.mjs +30 -45
  52. package/shortcutContexts/commands/editor/closeAndSave.js +2 -2
  53. package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -2
  54. package/shortcutContexts/commands/editor/open.js +3 -18
  55. package/shortcutContexts/commands/editor/open.mjs +3 -18
  56. package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
  57. package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
  58. package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
  59. package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
  60. package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
  61. package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
  62. package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
  63. package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
  64. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +1 -3
  65. package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +1 -3
  66. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +3 -9
  67. package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +3 -9
  68. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +3 -10
  69. package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +3 -10
  70. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +1 -3
  71. package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +1 -3
  72. package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +1 -3
  73. package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +1 -3
  74. package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +1 -3
  75. package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +1 -3
  76. package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
  77. package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
  78. package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
  79. package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
  80. package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +1 -6
  81. package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +1 -6
  82. package/shortcutContexts/commands/moveCellSelection/inlineStart.js +1 -6
  83. package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +1 -6
  84. package/shortcutContexts/grid.js +2 -2
  85. package/shortcutContexts/grid.mjs +2 -2
  86. package/shortcuts/context.js +1 -2
  87. package/shortcuts/context.mjs +1 -2
  88. package/core/viewportScroll/scrollStrategies/focusScroll.js +0 -15
  89. package/core/viewportScroll/scrollStrategies/focusScroll.mjs +0 -11
@@ -25,17 +25,7 @@ function toggleMergeItem(plugin) {
25
25
  return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_MERGE_CELLS);
26
26
  },
27
27
  callback() {
28
- const currentRange = this.getSelectedRangeLast();
29
- if (!currentRange) {
30
- return;
31
- }
32
- currentRange.setDirection(this.isRtl() ? 'NE-SW' : 'NW-SE');
33
- const {
34
- from,
35
- to
36
- } = currentRange;
37
- plugin.toggleMerge(currentRange);
38
- this.selectCell(from.row, from.col, to.row, to.col, false);
28
+ plugin.toggleMergeOnSelection();
39
29
  },
40
30
  disabled() {
41
31
  const sel = this.getSelectedLast();
@@ -18,17 +18,7 @@ export default function toggleMergeItem(plugin) {
18
18
  return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_MERGE_CELLS);
19
19
  },
20
20
  callback() {
21
- const currentRange = this.getSelectedRangeLast();
22
- if (!currentRange) {
23
- return;
24
- }
25
- currentRange.setDirection(this.isRtl() ? 'NE-SW' : 'NW-SE');
26
- const {
27
- from,
28
- to
29
- } = currentRange;
30
- plugin.toggleMerge(currentRange);
31
- this.selectCell(from.row, from.col, to.row, to.col, false);
21
+ plugin.toggleMergeOnSelection();
32
22
  },
33
23
  disabled() {
34
24
  const sel = this.getSelectedLast();
@@ -75,16 +75,16 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
75
75
  * ```
76
76
  * :::
77
77
  */
78
- var _lastSelectedCoords = /*#__PURE__*/new WeakMap();
78
+ var _lastDesiredCoords = /*#__PURE__*/new WeakMap();
79
79
  var _onAfterInit = /*#__PURE__*/new WeakSet();
80
80
  var _onAfterIsMultipleSelection = /*#__PURE__*/new WeakSet();
81
81
  var _onModifyTransformStart = /*#__PURE__*/new WeakSet();
82
82
  var _onModifyTransformEnd = /*#__PURE__*/new WeakSet();
83
- var _onBeforeSelectionHighlightSet = /*#__PURE__*/new WeakSet();
84
83
  var _onModifyGetCellCoords = /*#__PURE__*/new WeakSet();
85
84
  var _addMergeActionsToContextMenu = /*#__PURE__*/new WeakSet();
86
85
  var _onAfterRenderer = /*#__PURE__*/new WeakSet();
87
86
  var _onBeforeSetRangeStart = /*#__PURE__*/new WeakSet();
87
+ var _onBeforeSetRangeEnd = /*#__PURE__*/new WeakSet();
88
88
  var _onAfterGetCellMeta = /*#__PURE__*/new WeakSet();
89
89
  var _onAfterViewportRowCalculatorOverride = /*#__PURE__*/new WeakSet();
90
90
  var _onAfterViewportColumnCalculatorOverride = /*#__PURE__*/new WeakSet();
@@ -95,6 +95,7 @@ var _onAfterCreateRow = /*#__PURE__*/new WeakSet();
95
95
  var _onAfterRemoveRow = /*#__PURE__*/new WeakSet();
96
96
  var _onAfterChange = /*#__PURE__*/new WeakSet();
97
97
  var _onBeforeDrawAreaBorders = /*#__PURE__*/new WeakSet();
98
+ var _onAfterModifyTransformStart = /*#__PURE__*/new WeakSet();
98
99
  var _onAfterDrawSelection = /*#__PURE__*/new WeakSet();
99
100
  var _onBeforeRemoveCellClassNames = /*#__PURE__*/new WeakSet();
100
101
  var _onBeforeBeginEditing = /*#__PURE__*/new WeakSet();
@@ -130,6 +131,17 @@ class MergeCells extends _base.BasePlugin {
130
131
  * processed cell.
131
132
  */
132
133
  _classPrivateMethodInitSpec(this, _onAfterDrawSelection);
134
+ /**
135
+ * `afterModifyTransformStart` hook callback. Fixes a problem with navigating through merged cells at the edges of
136
+ * the table with the <kbd>**Enter**</kbd>/<kbd>**Shift**</kbd>+<kbd>**Enter**</kbd>/<kbd>**Tab**</kbd>/<kbd>**Shift**</kbd>+<kbd>**Tab**</kbd> keys.
137
+ *
138
+ * @param {CellCoords} coords Coordinates of the to-be-selected cell.
139
+ * @param {number} rowTransformDir Row transformation direction (negative value = up, 0 = none, positive value =
140
+ * down).
141
+ * @param {number} colTransformDir Column transformation direction (negative value = up, 0 = none, positive value =
142
+ * down).
143
+ */
144
+ _classPrivateMethodInitSpec(this, _onAfterModifyTransformStart);
133
145
  /**
134
146
  * `beforeDrawAreaBorders` hook callback.
135
147
  *
@@ -202,7 +214,20 @@ class MergeCells extends _base.BasePlugin {
202
214
  */
203
215
  _classPrivateMethodInitSpec(this, _onAfterGetCellMeta);
204
216
  /**
205
- * Clears the last selected coordinates before setting a new selection range.
217
+ * `beforeSetRangeEnd` hook callback.
218
+ * While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the
219
+ * merged cell.
220
+ *
221
+ * Note: Please keep in mind that callback may modify both start and end range coordinates by the reference.
222
+ *
223
+ * @param {object} coords Cell coords.
224
+ */
225
+ _classPrivateMethodInitSpec(this, _onBeforeSetRangeEnd);
226
+ /**
227
+ * `beforeSetRangeStart` and `beforeSetRangeStartOnly` hook callback.
228
+ * A selection within merge area should be rewritten to the start of merge area.
229
+ *
230
+ * @param {object} coords Cell coords.
206
231
  */
207
232
  _classPrivateMethodInitSpec(this, _onBeforeSetRangeStart);
208
233
  /**
@@ -227,11 +252,6 @@ class MergeCells extends _base.BasePlugin {
227
252
  * @returns {Array|undefined} Visual coordinates of the merge.
228
253
  */
229
254
  _classPrivateMethodInitSpec(this, _onModifyGetCellCoords);
230
- /**
231
- * The hook corrects the range (before drawing it) after the selection was made on the merged cells.
232
- * It expands the range to cover the entire area of the selected merged cells.
233
- */
234
- _classPrivateMethodInitSpec(this, _onBeforeSelectionHighlightSet);
235
255
  /**
236
256
  * `modifyTransformEnd` hook callback. Needed to handle "jumping over" merged merged cells, while selecting.
237
257
  *
@@ -278,12 +298,9 @@ class MergeCells extends _base.BasePlugin {
278
298
  */
279
299
  _defineProperty(this, "selectionCalculations", null);
280
300
  /**
281
- * The holder for the last selected coordinates. This allows keeping the correct coordinates in cases after the
282
- * focus is moved out of the merged cell.
283
- *
284
301
  * @type {CellCoords}
285
302
  */
286
- _classPrivateFieldInitSpec(this, _lastSelectedCoords, {
303
+ _classPrivateFieldInitSpec(this, _lastDesiredCoords, {
287
304
  writable: true,
288
305
  value: null
289
306
  });
@@ -327,130 +344,136 @@ class MergeCells extends _base.BasePlugin {
327
344
  }
328
345
  return _classPrivateMethodGet(_this, _onModifyTransformStart, _onModifyTransformStart2).call(_this, ...args);
329
346
  });
330
- this.addHook('modifyTransformEnd', function () {
347
+ this.addHook('afterModifyTransformStart', function () {
331
348
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
332
349
  args[_key3] = arguments[_key3];
333
350
  }
334
- return _classPrivateMethodGet(_this, _onModifyTransformEnd, _onModifyTransformEnd2).call(_this, ...args);
351
+ return _classPrivateMethodGet(_this, _onAfterModifyTransformStart, _onAfterModifyTransformStart2).call(_this, ...args);
335
352
  });
336
- this.addHook('beforeSelectionHighlightSet', function () {
353
+ this.addHook('modifyTransformEnd', function () {
337
354
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
338
355
  args[_key4] = arguments[_key4];
339
356
  }
340
- return _classPrivateMethodGet(_this, _onBeforeSelectionHighlightSet, _onBeforeSelectionHighlightSet2).call(_this, ...args);
357
+ return _classPrivateMethodGet(_this, _onModifyTransformEnd, _onModifyTransformEnd2).call(_this, ...args);
341
358
  });
342
- this.addHook('beforeSetRangeStart', function () {
359
+ this.addHook('modifyGetCellCoords', function () {
343
360
  for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
344
361
  args[_key5] = arguments[_key5];
345
362
  }
346
- return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
363
+ return _classPrivateMethodGet(_this, _onModifyGetCellCoords, _onModifyGetCellCoords2).call(_this, ...args);
347
364
  });
348
- this.addHook('beforeSetRangeStartOnly', function () {
365
+ this.addHook('beforeSetRangeStart', function () {
349
366
  for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
350
367
  args[_key6] = arguments[_key6];
351
368
  }
352
369
  return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
353
370
  });
354
- this.addHook('modifyGetCellCoords', function () {
371
+ this.addHook('beforeSetRangeStartOnly', function () {
355
372
  for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
356
373
  args[_key7] = arguments[_key7];
357
374
  }
358
- return _classPrivateMethodGet(_this, _onModifyGetCellCoords, _onModifyGetCellCoords2).call(_this, ...args);
375
+ return _classPrivateMethodGet(_this, _onBeforeSetRangeStart, _onBeforeSetRangeStart2).call(_this, ...args);
359
376
  });
360
- this.addHook('afterIsMultipleSelection', function () {
377
+ this.addHook('beforeSetRangeEnd', function () {
361
378
  for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
362
379
  args[_key8] = arguments[_key8];
363
380
  }
364
- return _classPrivateMethodGet(_this, _onAfterIsMultipleSelection, _onAfterIsMultipleSelection2).call(_this, ...args);
381
+ return _classPrivateMethodGet(_this, _onBeforeSetRangeEnd, _onBeforeSetRangeEnd2).call(_this, ...args);
365
382
  });
366
- this.addHook('afterRenderer', function () {
383
+ this.addHook('afterIsMultipleSelection', function () {
367
384
  for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
368
385
  args[_key9] = arguments[_key9];
369
386
  }
370
- return _classPrivateMethodGet(_this, _onAfterRenderer, _onAfterRenderer2).call(_this, ...args);
387
+ return _classPrivateMethodGet(_this, _onAfterIsMultipleSelection, _onAfterIsMultipleSelection2).call(_this, ...args);
371
388
  });
372
- this.addHook('afterContextMenuDefaultOptions', function () {
389
+ this.addHook('afterRenderer', function () {
373
390
  for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
374
391
  args[_key10] = arguments[_key10];
375
392
  }
376
- return _classPrivateMethodGet(_this, _addMergeActionsToContextMenu, _addMergeActionsToContextMenu2).call(_this, ...args);
393
+ return _classPrivateMethodGet(_this, _onAfterRenderer, _onAfterRenderer2).call(_this, ...args);
377
394
  });
378
- this.addHook('afterGetCellMeta', function () {
395
+ this.addHook('afterContextMenuDefaultOptions', function () {
379
396
  for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
380
397
  args[_key11] = arguments[_key11];
381
398
  }
382
- return _classPrivateMethodGet(_this, _onAfterGetCellMeta, _onAfterGetCellMeta2).call(_this, ...args);
399
+ return _classPrivateMethodGet(_this, _addMergeActionsToContextMenu, _addMergeActionsToContextMenu2).call(_this, ...args);
383
400
  });
384
- this.addHook('afterViewportRowCalculatorOverride', function () {
401
+ this.addHook('afterGetCellMeta', function () {
385
402
  for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
386
403
  args[_key12] = arguments[_key12];
387
404
  }
388
- return _classPrivateMethodGet(_this, _onAfterViewportRowCalculatorOverride, _onAfterViewportRowCalculatorOverride2).call(_this, ...args);
405
+ return _classPrivateMethodGet(_this, _onAfterGetCellMeta, _onAfterGetCellMeta2).call(_this, ...args);
389
406
  });
390
- this.addHook('afterViewportColumnCalculatorOverride', function () {
407
+ this.addHook('afterViewportRowCalculatorOverride', function () {
391
408
  for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
392
409
  args[_key13] = arguments[_key13];
393
410
  }
394
- return _classPrivateMethodGet(_this, _onAfterViewportColumnCalculatorOverride, _onAfterViewportColumnCalculatorOverride2).call(_this, ...args);
411
+ return _classPrivateMethodGet(_this, _onAfterViewportRowCalculatorOverride, _onAfterViewportRowCalculatorOverride2).call(_this, ...args);
395
412
  });
396
- this.addHook('modifyAutofillRange', function () {
413
+ this.addHook('afterViewportColumnCalculatorOverride', function () {
397
414
  for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
398
415
  args[_key14] = arguments[_key14];
399
416
  }
400
- return _classPrivateMethodGet(_this, _onModifyAutofillRange, _onModifyAutofillRange2).call(_this, ...args);
417
+ return _classPrivateMethodGet(_this, _onAfterViewportColumnCalculatorOverride, _onAfterViewportColumnCalculatorOverride2).call(_this, ...args);
401
418
  });
402
- this.addHook('afterCreateCol', function () {
419
+ this.addHook('modifyAutofillRange', function () {
403
420
  for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
404
421
  args[_key15] = arguments[_key15];
405
422
  }
406
- return _classPrivateMethodGet(_this, _onAfterCreateCol, _onAfterCreateCol2).call(_this, ...args);
423
+ return _classPrivateMethodGet(_this, _onModifyAutofillRange, _onModifyAutofillRange2).call(_this, ...args);
407
424
  });
408
- this.addHook('afterRemoveCol', function () {
425
+ this.addHook('afterCreateCol', function () {
409
426
  for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
410
427
  args[_key16] = arguments[_key16];
411
428
  }
412
- return _classPrivateMethodGet(_this, _onAfterRemoveCol, _onAfterRemoveCol2).call(_this, ...args);
429
+ return _classPrivateMethodGet(_this, _onAfterCreateCol, _onAfterCreateCol2).call(_this, ...args);
413
430
  });
414
- this.addHook('afterCreateRow', function () {
431
+ this.addHook('afterRemoveCol', function () {
415
432
  for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
416
433
  args[_key17] = arguments[_key17];
417
434
  }
418
- return _classPrivateMethodGet(_this, _onAfterCreateRow, _onAfterCreateRow2).call(_this, ...args);
435
+ return _classPrivateMethodGet(_this, _onAfterRemoveCol, _onAfterRemoveCol2).call(_this, ...args);
419
436
  });
420
- this.addHook('afterRemoveRow', function () {
437
+ this.addHook('afterCreateRow', function () {
421
438
  for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
422
439
  args[_key18] = arguments[_key18];
423
440
  }
424
- return _classPrivateMethodGet(_this, _onAfterRemoveRow, _onAfterRemoveRow2).call(_this, ...args);
441
+ return _classPrivateMethodGet(_this, _onAfterCreateRow, _onAfterCreateRow2).call(_this, ...args);
425
442
  });
426
- this.addHook('afterChange', function () {
443
+ this.addHook('afterRemoveRow', function () {
427
444
  for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
428
445
  args[_key19] = arguments[_key19];
429
446
  }
430
- return _classPrivateMethodGet(_this, _onAfterChange, _onAfterChange2).call(_this, ...args);
447
+ return _classPrivateMethodGet(_this, _onAfterRemoveRow, _onAfterRemoveRow2).call(_this, ...args);
431
448
  });
432
- this.addHook('beforeDrawBorders', function () {
449
+ this.addHook('afterChange', function () {
433
450
  for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
434
451
  args[_key20] = arguments[_key20];
435
452
  }
436
- return _classPrivateMethodGet(_this, _onBeforeDrawAreaBorders, _onBeforeDrawAreaBorders2).call(_this, ...args);
453
+ return _classPrivateMethodGet(_this, _onAfterChange, _onAfterChange2).call(_this, ...args);
437
454
  });
438
- this.addHook('afterDrawSelection', function () {
455
+ this.addHook('beforeDrawBorders', function () {
439
456
  for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
440
457
  args[_key21] = arguments[_key21];
441
458
  }
442
- return _classPrivateMethodGet(_this, _onAfterDrawSelection, _onAfterDrawSelection2).call(_this, ...args);
459
+ return _classPrivateMethodGet(_this, _onBeforeDrawAreaBorders, _onBeforeDrawAreaBorders2).call(_this, ...args);
443
460
  });
444
- this.addHook('beforeRemoveCellClassNames', function () {
461
+ this.addHook('afterDrawSelection', function () {
445
462
  for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
446
463
  args[_key22] = arguments[_key22];
447
464
  }
448
- return _classPrivateMethodGet(_this, _onBeforeRemoveCellClassNames, _onBeforeRemoveCellClassNames2).call(_this, ...args);
465
+ return _classPrivateMethodGet(_this, _onAfterDrawSelection, _onAfterDrawSelection2).call(_this, ...args);
449
466
  });
450
- this.addHook('beforeBeginEditing', function () {
467
+ this.addHook('beforeRemoveCellClassNames', function () {
451
468
  for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
452
469
  args[_key23] = arguments[_key23];
453
470
  }
471
+ return _classPrivateMethodGet(_this, _onBeforeRemoveCellClassNames, _onBeforeRemoveCellClassNames2).call(_this, ...args);
472
+ });
473
+ this.addHook('beforeBeginEditing', function () {
474
+ for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
475
+ args[_key24] = arguments[_key24];
476
+ }
454
477
  return _classPrivateMethodGet(_this, _onBeforeBeginEditing, _onBeforeBeginEditing2).call(_this, ...args);
455
478
  });
456
479
  this.addHook('beforeUndoStackChange', (action, source) => {
@@ -619,6 +642,25 @@ class MergeCells extends _base.BasePlugin {
619
642
  return auto ? true : this.validateSetting(newMergedCellInfo);
620
643
  }
621
644
 
645
+ /**
646
+ * Merge or unmerge, based on last selected range.
647
+ *
648
+ * @private
649
+ */
650
+ toggleMergeOnSelection() {
651
+ const currentRange = this.hot.getSelectedRangeLast();
652
+ if (!currentRange) {
653
+ return;
654
+ }
655
+ currentRange.setDirection(this.hot.isRtl() ? 'NE-SW' : 'NW-SE');
656
+ const {
657
+ from,
658
+ to
659
+ } = currentRange;
660
+ this.toggleMerge(currentRange);
661
+ this.hot.selectCell(from.row, from.col, to.row, to.col, false);
662
+ }
663
+
622
664
  /**
623
665
  * Merges the selection provided as a cell range.
624
666
  *
@@ -989,10 +1031,8 @@ function _onAfterIsMultipleSelection2(isMultiple) {
989
1031
  if (isMultiple) {
990
1032
  const mergedCells = this.mergedCellsCollection.mergedCells;
991
1033
  const selectionRange = this.hot.getSelectedRangeLast();
992
- const topStartCoords = selectionRange.getTopStartCorner();
993
- const bottomEndCoords = selectionRange.getBottomEndCorner();
994
1034
  for (let group = 0; group < mergedCells.length; group += 1) {
995
- 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) {
1035
+ 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) {
996
1036
  return false;
997
1037
  }
998
1038
  }
@@ -1000,140 +1040,75 @@ function _onAfterIsMultipleSelection2(isMultiple) {
1000
1040
  return isMultiple;
1001
1041
  }
1002
1042
  function _onModifyTransformStart2(delta) {
1003
- const selectedRange = this.hot.getSelectedRangeLast();
1004
- const {
1005
- highlight
1006
- } = selectedRange;
1007
- if (_classPrivateFieldGet(this, _lastSelectedCoords)) {
1008
- highlight.assign(_classPrivateFieldGet(this, _lastSelectedCoords));
1009
- _classPrivateFieldSet(this, _lastSelectedCoords, null);
1043
+ const currentlySelectedRange = this.hot.getSelectedRangeLast();
1044
+ let newDelta = {
1045
+ row: delta.row,
1046
+ col: delta.col
1047
+ };
1048
+ let nextPosition = null;
1049
+ const currentPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row, currentlySelectedRange.highlight.col);
1050
+ const mergedParent = this.mergedCellsCollection.get(currentPosition.row, currentPosition.col);
1051
+ if (!_classPrivateFieldGet(this, _lastDesiredCoords)) {
1052
+ _classPrivateFieldSet(this, _lastDesiredCoords, this.hot._createCellCoords(null, null));
1010
1053
  }
1011
- const mergedParent = this.mergedCellsCollection.get(highlight.row, highlight.col);
1012
- if (!mergedParent) {
1013
- return;
1014
- }
1015
- const visualColumnIndexStart = mergedParent.col;
1016
- const visualColumnIndexEnd = mergedParent.col + mergedParent.colspan - 1;
1017
- if (delta.col < 0) {
1018
- const nextColumn = highlight.col >= visualColumnIndexStart && highlight.col <= visualColumnIndexEnd ? visualColumnIndexStart - 1 : visualColumnIndexEnd;
1019
- const notHiddenColumnIndex = this.hot.columnIndexMapper.getNearestNotHiddenIndex(nextColumn, -1);
1020
- if (notHiddenColumnIndex === null) {
1021
- // There are no visible columns anymore, so move the selection out of the table edge. This will
1022
- // be processed by the selection Transformer class as a move selection to the previous row (if autoWrapRow is enabled).
1023
- delta.col = -this.hot.view.countRenderableColumnsInRange(0, highlight.col);
1024
- } else {
1025
- delta.col = -Math.max(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, highlight.col) - 1, 1);
1026
- }
1027
- } else if (delta.col > 0) {
1028
- const nextColumn = highlight.col >= visualColumnIndexStart && highlight.col <= visualColumnIndexEnd ? visualColumnIndexEnd + 1 : visualColumnIndexStart;
1029
- const notHiddenColumnIndex = this.hot.columnIndexMapper.getNearestNotHiddenIndex(nextColumn, 1);
1030
- if (notHiddenColumnIndex === null) {
1031
- // There are no visible columns anymore, so move the selection out of the table edge. This will
1032
- // be processed by the selection Transformer class as a move selection to the next row (if autoWrapRow is enabled).
1033
- delta.col = this.hot.view.countRenderableColumnsInRange(highlight.col, this.hot.countCols());
1034
- } else {
1035
- delta.col = Math.max(this.hot.view.countRenderableColumnsInRange(highlight.col, notHiddenColumnIndex) - 1, 1);
1054
+ if (mergedParent) {
1055
+ // only merge selected
1056
+ const mergeTopLeft = this.hot._createCellCoords(mergedParent.row, mergedParent.col);
1057
+ const mergeBottomRight = this.hot._createCellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1);
1058
+ const mergeRange = this.hot._createCellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
1059
+ if (!mergeRange.includes(_classPrivateFieldGet(this, _lastDesiredCoords))) {
1060
+ _classPrivateFieldSet(this, _lastDesiredCoords, this.hot._createCellCoords(null, null)); // reset outdated version of lastDesiredCoords
1036
1061
  }
1037
- }
1038
- const visualRowIndexStart = mergedParent.row;
1039
- const visualRowIndexEnd = mergedParent.row + mergedParent.rowspan - 1;
1040
- if (delta.row < 0) {
1041
- const nextRow = highlight.row >= visualRowIndexStart && highlight.row <= visualRowIndexEnd ? visualRowIndexStart - 1 : visualRowIndexEnd;
1042
- const notHiddenRowIndex = this.hot.rowIndexMapper.getNearestNotHiddenIndex(nextRow, -1);
1043
- if (notHiddenRowIndex === null) {
1044
- // There are no visible rows anymore, so move the selection out of the table edge. This will
1045
- // be processed by the selection Transformer class as a move selection to the previous column (if autoWrapCol is enabled).
1046
- delta.row = -this.hot.view.countRenderableRowsInRange(0, highlight.row);
1047
- } else {
1048
- delta.row = -Math.max(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, highlight.row) - 1, 1);
1062
+ newDelta.row = _classPrivateFieldGet(this, _lastDesiredCoords).row ? _classPrivateFieldGet(this, _lastDesiredCoords).row - currentPosition.row : newDelta.row;
1063
+ newDelta.col = _classPrivateFieldGet(this, _lastDesiredCoords).col ? _classPrivateFieldGet(this, _lastDesiredCoords).col - currentPosition.col : newDelta.col;
1064
+ if (delta.row > 0) {
1065
+ // moving down
1066
+ newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
1067
+ } else if (delta.row < 0) {
1068
+ // moving up
1069
+ newDelta.row = currentPosition.row - mergedParent.row + delta.row;
1049
1070
  }
1050
- } else if (delta.row > 0) {
1051
- const nextRow = highlight.row >= visualRowIndexStart && highlight.row <= visualRowIndexEnd ? visualRowIndexEnd + 1 : visualRowIndexStart;
1052
- const notHiddenRowIndex = this.hot.rowIndexMapper.getNearestNotHiddenIndex(nextRow, 1);
1053
- if (notHiddenRowIndex === null) {
1054
- // There are no visible rows anymore, so move the selection out of the table edge. This will
1055
- // be processed by the selection Transformer class as a move selection to the next column (if autoWrapCol is enabled).
1056
- delta.row = this.hot.view.countRenderableRowsInRange(highlight.row, this.hot.countRows());
1057
- } else {
1058
- delta.row = Math.max(this.hot.view.countRenderableRowsInRange(highlight.row, notHiddenRowIndex) - 1, 1);
1071
+ if (delta.col > 0) {
1072
+ // moving right
1073
+ newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
1074
+ } else if (delta.col < 0) {
1075
+ // moving left
1076
+ newDelta.col = currentPosition.col - mergedParent.col + delta.col;
1059
1077
  }
1060
1078
  }
1061
- }
1062
- function _onModifyTransformEnd2(delta) {
1063
- const selectedRange = this.hot.getSelectedRangeLast();
1064
- const {
1065
- to
1066
- } = selectedRange;
1067
- const nextTo = this.hot._createCellCoords(to.row + delta.row, to.col + delta.col);
1068
- const mergedParentCurrent = this.mergedCellsCollection.get(to.row, to.col);
1069
- const mergedParentNext = this.mergedCellsCollection.get(nextTo.row, nextTo.col);
1070
- if (!(mergedParentCurrent && mergedParentNext && mergedParentCurrent === mergedParentNext)) {
1071
- return;
1079
+ nextPosition = this.hot._createCellCoords(currentlySelectedRange.highlight.row + newDelta.row, currentlySelectedRange.highlight.col + newDelta.col);
1080
+ const nextPositionMergedCell = this.mergedCellsCollection.get(nextPosition.row, nextPosition.col);
1081
+ if (nextPositionMergedCell) {
1082
+ // skipping the invisible cells in the merge range
1083
+ const firstRenderableCoords = this.mergedCellsCollection.getFirstRenderableCoords(nextPositionMergedCell.row, nextPositionMergedCell.col);
1084
+ _classPrivateFieldSet(this, _lastDesiredCoords, nextPosition);
1085
+ newDelta = {
1086
+ row: firstRenderableCoords.row - currentPosition.row,
1087
+ col: firstRenderableCoords.col - currentPosition.col
1088
+ };
1072
1089
  }
1073
- const visualColumnIndexStart = mergedParentCurrent.col;
1074
- const visualColumnIndexEnd = mergedParentCurrent.col + mergedParentCurrent.colspan - 1;
1075
- if (delta.col < 0) {
1076
- const nextColumn = nextTo.col >= visualColumnIndexStart && nextTo.col <= visualColumnIndexEnd ? visualColumnIndexStart - 1 : visualColumnIndexEnd;
1077
- const notHiddenColumnIndex = this.hot.columnIndexMapper.getNearestNotHiddenIndex(nextColumn, -1);
1078
- if (notHiddenColumnIndex === null) {
1079
- // There are no visible columns anymore, so move the selection out of the table edge. This will
1080
- // be processed by the selection Transformer class as a move selection to the previous row (if autoWrapRow is enabled).
1081
- delta.col = -this.hot.view.countRenderableColumnsInRange(0, to.col);
1082
- } else {
1083
- delta.col = -Math.max(this.hot.view.countRenderableColumnsInRange(notHiddenColumnIndex, to.col) - 1, 1);
1084
- }
1085
- } else if (delta.col > 0) {
1086
- const nextColumn = nextTo.col >= visualColumnIndexStart && nextTo.col <= visualColumnIndexEnd ? visualColumnIndexEnd + 1 : visualColumnIndexStart;
1087
- const notHiddenColumnIndex = this.hot.columnIndexMapper.getNearestNotHiddenIndex(nextColumn, 1);
1088
- if (notHiddenColumnIndex === null) {
1089
- // There are no visible columns anymore, so move the selection out of the table edge. This will
1090
- // be processed by the selection Transformer class as a move selection to the next row (if autoWrapRow is enabled).
1091
- delta.col = this.hot.view.countRenderableColumnsInRange(to.col, this.hot.countCols());
1092
- } else {
1093
- delta.col = Math.max(this.hot.view.countRenderableColumnsInRange(to.col, notHiddenColumnIndex) - 1, 1);
1094
- }
1090
+ if (newDelta.row !== 0) {
1091
+ delta.row = newDelta.row;
1095
1092
  }
1096
- const visualRowIndexStart = mergedParentCurrent.row;
1097
- const visualRowIndexEnd = mergedParentCurrent.row + mergedParentCurrent.rowspan - 1;
1098
- if (delta.row < 0) {
1099
- const nextRow = nextTo.row >= visualRowIndexStart && nextTo.row <= visualRowIndexEnd ? visualRowIndexStart - 1 : visualRowIndexEnd;
1100
- const notHiddenRowIndex = this.hot.rowIndexMapper.getNearestNotHiddenIndex(nextRow, -1);
1101
- if (notHiddenRowIndex === null) {
1102
- // There are no visible rows anymore, so move the selection out of the table edge. This will
1103
- // be processed by the selection Transformer class as a move selection to the previous column (if autoWrapCol is enabled).
1104
- delta.row = -this.hot.view.countRenderableRowsInRange(0, to.row);
1105
- } else {
1106
- delta.row = -Math.max(this.hot.view.countRenderableRowsInRange(notHiddenRowIndex, to.row) - 1, 1);
1107
- }
1108
- } else if (delta.row > 0) {
1109
- const nextRow = nextTo.row >= visualRowIndexStart && nextTo.row <= visualRowIndexEnd ? visualRowIndexEnd + 1 : visualRowIndexStart;
1110
- const notHiddenRowIndex = this.hot.rowIndexMapper.getNearestNotHiddenIndex(nextRow, 1);
1111
- if (notHiddenRowIndex === null) {
1112
- // There are no visible rows anymore, so move the selection out of the table edge. This will
1113
- // be processed by the selection Transformer class as a move selection to the next column (if autoWrapCol is enabled).
1114
- delta.row = this.hot.view.countRenderableRowsInRange(to.row, this.hot.countRows());
1115
- } else {
1116
- delta.row = Math.max(this.hot.view.countRenderableRowsInRange(to.row, notHiddenRowIndex) - 1, 1);
1117
- }
1093
+ if (newDelta.col !== 0) {
1094
+ delta.col = newDelta.col;
1118
1095
  }
1119
1096
  }
1120
- function _onBeforeSelectionHighlightSet2() {
1121
- if (this.hot.selection.isSelectedByColumnHeader() || this.hot.selection.isSelectedByRowHeader()) {
1122
- return;
1123
- }
1124
- const selectedRange = this.hot.getSelectedRangeLast();
1125
- const {
1126
- highlight
1127
- } = selectedRange;
1128
- for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1129
- const cellInfo = this.mergedCellsCollection.mergedCells[i];
1130
- selectedRange.expandByRange(cellInfo.getRange());
1131
- }
1132
- const mergedParent = this.mergedCellsCollection.get(highlight.row, highlight.col);
1133
- _classPrivateFieldSet(this, _lastSelectedCoords, highlight.clone());
1134
- if (mergedParent) {
1135
- highlight.assign(mergedParent);
1136
- }
1097
+ function _onModifyTransformEnd2(delta) {
1098
+ const currentSelectionRange = this.hot.getSelectedRangeLast();
1099
+ const newDelta = (0, _object.clone)(delta);
1100
+ const newSelectionRange = this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, delta);
1101
+ let tempDelta = (0, _object.clone)(newDelta);
1102
+ const mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(newSelectionRange, true);
1103
+ do {
1104
+ tempDelta = (0, _object.clone)(newDelta);
1105
+ this.selectionCalculations.getUpdatedSelectionRange(currentSelectionRange, newDelta);
1106
+ (0, _array.arrayEach)(mergedCellsWithinRange, mergedCell => {
1107
+ this.selectionCalculations.snapDelta(newDelta, currentSelectionRange, mergedCell);
1108
+ });
1109
+ } while (newDelta.row !== tempDelta.row || newDelta.col !== tempDelta.col);
1110
+ delta.row = newDelta.row;
1111
+ delta.col = newDelta.col;
1137
1112
  }
1138
1113
  function _onModifyGetCellCoords2(row, column) {
1139
1114
  if (row < 0 || column < 0) {
@@ -1192,8 +1167,37 @@ function _onAfterRenderer2(TD, row, col) {
1192
1167
  }
1193
1168
  (0, _utils.applySpanProperties)(TD, mergedCellCopy, row, col);
1194
1169
  }
1195
- function _onBeforeSetRangeStart2() {
1196
- _classPrivateFieldSet(this, _lastSelectedCoords, null);
1170
+ function _onBeforeSetRangeStart2(coords) {
1171
+ // TODO: It is a workaround, but probably this hook may be needed. Every selection on the merge area
1172
+ // could set start point of the selection to the start of the merge area. However, logic inside `expandByRange` need
1173
+ // an initial start point. Click on the merge cell when there are some hidden indexes break the logic in some cases.
1174
+ // Please take a look at #7010 for more information. I'm not sure if selection directions are calculated properly
1175
+ // and what was idea for flipping direction inside `expandByRange` method.
1176
+ if (this.mergedCellsCollection.isFirstRenderableMergedCell(coords.row, coords.col)) {
1177
+ const mergeParent = this.mergedCellsCollection.get(coords.row, coords.col);
1178
+ [coords.row, coords.col] = [mergeParent.row, mergeParent.col];
1179
+ }
1180
+ }
1181
+ function _onBeforeSetRangeEnd2(coords) {
1182
+ const selRange = this.hot.getSelectedRangeLast();
1183
+ selRange.highlight = this.hot._createCellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference
1184
+ selRange.to = coords;
1185
+ let rangeExpanded = false;
1186
+ if (this.hot.selection.isSelectedByColumnHeader() || this.hot.selection.isSelectedByRowHeader()) {
1187
+ return;
1188
+ }
1189
+ do {
1190
+ rangeExpanded = false;
1191
+ for (let i = 0; i < this.mergedCellsCollection.mergedCells.length; i += 1) {
1192
+ const cellInfo = this.mergedCellsCollection.mergedCells[i];
1193
+ const mergedCellRange = cellInfo.getRange();
1194
+ if (selRange.expandByRange(mergedCellRange)) {
1195
+ coords.row = selRange.to.row;
1196
+ coords.col = selRange.to.col;
1197
+ rangeExpanded = true;
1198
+ }
1199
+ }
1200
+ } while (rangeExpanded);
1197
1201
  }
1198
1202
  function _onAfterGetCellMeta2(row, col, cellProperties) {
1199
1203
  const mergeParent = this.mergedCellsCollection.get(row, col);
@@ -1273,6 +1277,27 @@ function _onBeforeDrawAreaBorders2(corners, className) {
1273
1277
  });
1274
1278
  }
1275
1279
  }
1280
+ function _onAfterModifyTransformStart2(coords, rowTransformDir, colTransformDir) {
1281
+ if (!this.enabled) {
1282
+ return;
1283
+ }
1284
+ const mergedCellAtCoords = this.mergedCellsCollection.get(coords.row, coords.col);
1285
+ if (!mergedCellAtCoords) {
1286
+ return;
1287
+ }
1288
+ const goingDown = rowTransformDir > 0;
1289
+ const goingUp = rowTransformDir < 0;
1290
+ const goingLeft = colTransformDir < 0;
1291
+ const goingRight = colTransformDir > 0;
1292
+ const mergedCellOnBottomEdge = mergedCellAtCoords.row + mergedCellAtCoords.rowspan - 1 === this.hot.countRows() - 1;
1293
+ const mergedCellOnTopEdge = mergedCellAtCoords.row === 0;
1294
+ const mergedCellOnRightEdge = mergedCellAtCoords.col + mergedCellAtCoords.colspan - 1 === this.hot.countCols() - 1;
1295
+ const mergedCellOnLeftEdge = mergedCellAtCoords.col === 0;
1296
+ if (goingDown && mergedCellOnBottomEdge || goingUp && mergedCellOnTopEdge || goingRight && mergedCellOnRightEdge || goingLeft && mergedCellOnLeftEdge) {
1297
+ coords.row = mergedCellAtCoords.row;
1298
+ coords.col = mergedCellAtCoords.col;
1299
+ }
1300
+ }
1276
1301
  function _onAfterDrawSelection2(currentRow, currentColumn, cornersOfSelection, layerLevel) {
1277
1302
  // Nothing's selected (hook might be triggered by the custom borders)
1278
1303
  if (!cornersOfSelection) {