handsontable 0.0.0-next-ae2e00f-20231213 → 0.0.0-next-0416ebd-20231214

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

Potentially problematic release.


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

package/eventManager.js CHANGED
@@ -19,6 +19,7 @@ let listenersCounter = 0;
19
19
  * Event DOM manager for internal use in Handsontable.
20
20
  *
21
21
  * @class EventManager
22
+ * @util
22
23
  */
23
24
  class EventManager {
24
25
  /**
@@ -51,7 +52,6 @@ class EventManager {
51
52
  addEventListener(element, eventName, callback) {
52
53
  let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
53
54
  /**
54
- * @private
55
55
  * @param {Event} event The event object.
56
56
  */
57
57
  function callbackProxy(event) {
@@ -211,7 +211,6 @@ function extendEvent(event) {
211
211
  }
212
212
  var _default = exports.default = EventManager;
213
213
  /**
214
- * @private
215
214
  * @returns {number}
216
215
  */
217
216
  function getListenersCounter() {
package/eventManager.mjs CHANGED
@@ -15,6 +15,7 @@ let listenersCounter = 0;
15
15
  * Event DOM manager for internal use in Handsontable.
16
16
  *
17
17
  * @class EventManager
18
+ * @util
18
19
  */
19
20
  class EventManager {
20
21
  /**
@@ -47,7 +48,6 @@ class EventManager {
47
48
  addEventListener(element, eventName, callback) {
48
49
  let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
49
50
  /**
50
- * @private
51
51
  * @param {Event} event The event object.
52
52
  */
53
53
  function callbackProxy(event) {
@@ -208,7 +208,6 @@ function extendEvent(event) {
208
208
  export default EventManager;
209
209
 
210
210
  /**
211
- * @private
212
211
  * @returns {number}
213
212
  */
214
213
  export function getListenersCounter() {
package/helpers/mixed.js CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
134
134
  function _injectProductInfo(key, element) {
135
135
  const hasValidType = !isEmpty(key);
136
136
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
137
- const hotVersion = "0.0.0-next-ae2e00f-20231213";
137
+ const hotVersion = "0.0.0-next-0416ebd-20231214";
138
138
  let keyValidityDate;
139
139
  let consoleMessageState = 'invalid';
140
140
  let domMessageState = 'invalid';
package/helpers/mixed.mjs CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
124
124
  export function _injectProductInfo(key, element) {
125
125
  const hasValidType = !isEmpty(key);
126
126
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
127
- const hotVersion = "0.0.0-next-ae2e00f-20231213";
127
+ const hotVersion = "0.0.0-next-0416ebd-20231214";
128
128
  let keyValidityDate;
129
129
  let consoleMessageState = 'invalid';
130
130
  let domMessageState = 'invalid';
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/handsontable/handsontable/issues"
11
11
  },
12
12
  "author": "Handsoncode <hello@handsontable.com>",
13
- "version": "0.0.0-next-ae2e00f-20231213",
13
+ "version": "0.0.0-next-0416ebd-20231214",
14
14
  "main": "index",
15
15
  "module": "index.mjs",
16
16
  "jsnext:main": "index.mjs",
@@ -2,7 +2,6 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  require("core-js/modules/es.array.push.js");
5
- require("core-js/modules/es.object.from-entries.js");
6
5
  var _pluginHooks = _interopRequireDefault(require("../../pluginHooks"));
7
6
  var _array = require("../../helpers/array");
8
7
  var _number = require("../../helpers/number");
@@ -60,30 +59,11 @@ function UndoRedo(instance) {
60
59
  instance.addHook('afterCreateRow', (index, amount, source) => {
61
60
  plugin.done(() => new UndoRedo.CreateRowAction(index, amount), source);
62
61
  });
63
- const getCellMetas = (fromRow, toRow, fromColumn, toColumn) => {
64
- const genericKeys = ['visualRow', 'visualCol', 'row', 'col', 'prop'];
65
- const genericKeysLength = genericKeys.length;
66
- const cellMetas = [];
67
- (0, _number.rangeEach)(fromColumn, toColumn, columnIndex => {
68
- (0, _number.rangeEach)(fromRow, toRow, rowIndex => {
69
- const cellMeta = instance.getCellMeta(rowIndex, columnIndex);
70
- if (Object.keys(cellMeta).length !== genericKeysLength) {
71
- const uniqueMeta = Object.fromEntries(Object.entries(cellMeta).filter(_ref => {
72
- let [key] = _ref;
73
- return genericKeys.includes(key) === false;
74
- }));
75
- cellMetas.push([cellMeta.visualRow, cellMeta.visualCol, uniqueMeta]);
76
- }
77
- });
78
- });
79
- return cellMetas;
80
- };
81
62
  instance.addHook('beforeRemoveRow', (index, amount, logicRows, source) => {
82
63
  const wrappedAction = () => {
83
64
  const physicalRowIndex = instance.toPhysicalRow(index);
84
- const lastRowIndex = physicalRowIndex + amount - 1;
85
65
  const removedData = (0, _object.deepClone)(plugin.instance.getSourceData(physicalRowIndex, 0, physicalRowIndex + amount - 1, plugin.instance.countSourceCols() - 1));
86
- return new UndoRedo.RemoveRowAction(physicalRowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop, instance.rowIndexMapper.getIndexesSequence(), getCellMetas(physicalRowIndex, lastRowIndex, 0, instance.countCols() - 1));
66
+ return new UndoRedo.RemoveRowAction(physicalRowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop, instance.rowIndexMapper.getIndexesSequence());
87
67
  };
88
68
  plugin.done(wrappedAction, source);
89
69
  });
@@ -94,14 +74,13 @@ function UndoRedo(instance) {
94
74
  const wrappedAction = () => {
95
75
  const originalData = plugin.instance.getSourceDataArray();
96
76
  const columnIndex = (plugin.instance.countCols() + index) % plugin.instance.countCols();
97
- const lastColumnIndex = columnIndex + amount - 1;
98
77
  const removedData = [];
99
78
  const headers = [];
100
79
  const indexes = [];
101
80
  (0, _number.rangeEach)(originalData.length - 1, i => {
102
81
  const column = [];
103
82
  const origRow = originalData[i];
104
- (0, _number.rangeEach)(columnIndex, lastColumnIndex, j => {
83
+ (0, _number.rangeEach)(columnIndex, columnIndex + (amount - 1), j => {
105
84
  column.push(origRow[instance.toPhysicalColumn(j)]);
106
85
  });
107
86
  removedData.push(column);
@@ -116,7 +95,7 @@ function UndoRedo(instance) {
116
95
  }
117
96
  const columnsMap = instance.columnIndexMapper.getIndexesSequence();
118
97
  const rowsMap = instance.rowIndexMapper.getIndexesSequence();
119
- return new UndoRedo.RemoveColumnAction(columnIndex, indexes, removedData, headers, columnsMap, rowsMap, instance.getSettings().fixedColumnsStart, getCellMetas(0, instance.countRows(), columnIndex, lastColumnIndex));
98
+ return new UndoRedo.RemoveColumnAction(columnIndex, indexes, removedData, headers, columnsMap, rowsMap, instance.getSettings().fixedColumnsStart);
120
99
  };
121
100
  plugin.done(wrappedAction, source);
122
101
  });
@@ -384,6 +363,32 @@ UndoRedo.ChangeAction.prototype.undo = function (instance, undoneCallback) {
384
363
  instance.undoRedo.doneActions.pop();
385
364
  }
386
365
  }
366
+ const selectedLast = instance.getSelectedLast();
367
+ if (selectedLast !== undefined) {
368
+ const [changedRow, changedColumn] = data[0];
369
+ const [selectedRow, selectedColumn] = selectedLast;
370
+ const firstFullyVisibleRow = instance.view.getFirstFullyVisibleRow();
371
+ const firstFullyVisibleColumn = instance.view.getFirstFullyVisibleColumn();
372
+ const isInVerticalViewPort = changedRow >= firstFullyVisibleRow;
373
+ const isInHorizontalViewPort = changedColumn >= firstFullyVisibleColumn;
374
+ const isInViewport = isInVerticalViewPort && isInHorizontalViewPort;
375
+ const isChangedSelection = selectedRow !== changedRow || selectedColumn !== changedColumn;
376
+
377
+ // Performing scroll only when selection has been changed right after editing a cell.
378
+ if (isInViewport === false && isChangedSelection === true) {
379
+ const scrollConfig = {
380
+ row: changedRow,
381
+ col: changedColumn
382
+ };
383
+ if (isInVerticalViewPort === false) {
384
+ scrollConfig.verticalSnap = 'top';
385
+ }
386
+ if (isInHorizontalViewPort === false) {
387
+ scrollConfig.horizontalSnap = 'start';
388
+ }
389
+ instance.scrollViewportTo(scrollConfig);
390
+ }
391
+ }
387
392
  instance.selectCells(this.selected, false, false);
388
393
  };
389
394
  UndoRedo.ChangeAction.prototype.redo = function (instance, onFinishCallback) {
@@ -434,16 +439,14 @@ UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
434
439
  * @param {number} fixedRowsBottom Number of fixed rows on the bottom. Remove row action change it sometimes.
435
440
  * @param {number} fixedRowsTop Number of fixed rows on the top. Remove row action change it sometimes.
436
441
  * @param {Array} rowIndexesSequence Row index sequence taken from the row index mapper.
437
- * @param {Array} removedCellMetas List of removed cell metas.
438
442
  */
439
- UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence, removedCellMetas) {
443
+ UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence) {
440
444
  this.index = index;
441
445
  this.data = data;
442
446
  this.actionType = 'remove_row';
443
447
  this.fixedRowsBottom = fixedRowsBottom;
444
448
  this.fixedRowsTop = fixedRowsTop;
445
449
  this.rowIndexesSequence = rowIndexesSequence;
446
- this.removedCellMetas = removedCellMetas;
447
450
  };
448
451
  (0, _object.inherit)(UndoRedo.RemoveRowAction, UndoRedo.Action);
449
452
  UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
@@ -462,10 +465,6 @@ UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
462
465
  });
463
466
  });
464
467
  instance.alter('insert_row_above', this.index, this.data.length, 'UndoRedo.undo');
465
- this.removedCellMetas.forEach(_ref2 => {
466
- let [rowIndex, columnIndex, cellMeta] = _ref2;
467
- instance.setCellMetaObject(rowIndex, columnIndex, cellMeta);
468
- });
469
468
  instance.addHookOnce('afterViewRender', undoneCallback);
470
469
  instance.setSourceDataAtCell(changes, null, null, 'UndoRedo.undo');
471
470
  instance.rowIndexMapper.setIndexesSequence(this.rowIndexesSequence);
@@ -508,9 +507,8 @@ UndoRedo.CreateColumnAction.prototype.redo = function (instance, redoneCallback)
508
507
  * @param {number[]} columnPositions The column position.
509
508
  * @param {number[]} rowPositions The row position.
510
509
  * @param {number} fixedColumnsStart Number of fixed columns on the left. Remove column action change it sometimes.
511
- * @param {Array} removedCellMetas List of removed cell metas.
512
510
  */
513
- UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart, removedCellMetas) {
511
+ UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart) {
514
512
  // eslint-disable-line max-len
515
513
  this.index = index;
516
514
  this.indexes = indexes;
@@ -521,7 +519,6 @@ UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPos
521
519
  this.rowPositions = rowPositions.slice(0);
522
520
  this.actionType = 'remove_col';
523
521
  this.fixedColumnsStart = fixedColumnsStart;
524
- this.removedCellMetas = removedCellMetas;
525
522
  };
526
523
  (0, _object.inherit)(UndoRedo.RemoveColumnAction, UndoRedo.Action);
527
524
  UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
@@ -551,10 +548,6 @@ UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback)
551
548
  instance.getSettings().colHeaders[ascendingIndexes[columnIndex]] = headerData;
552
549
  });
553
550
  }
554
- this.removedCellMetas.forEach(_ref3 => {
555
- let [rowIndex, columnIndex, cellMeta] = _ref3;
556
- instance.setCellMetaObject(rowIndex, columnIndex, cellMeta);
557
- });
558
551
  instance.batchExecution(() => {
559
552
  // Restore row sequence in a case when all columns are removed. the original
560
553
  // row sequence is lost in that case.
@@ -1,5 +1,4 @@
1
1
  import "core-js/modules/es.array.push.js";
2
- import "core-js/modules/es.object.from-entries.js";
3
2
  import Hooks from "../../pluginHooks.mjs";
4
3
  import { arrayMap, arrayEach } from "../../helpers/array.mjs";
5
4
  import { rangeEach } from "../../helpers/number.mjs";
@@ -56,30 +55,11 @@ function UndoRedo(instance) {
56
55
  instance.addHook('afterCreateRow', (index, amount, source) => {
57
56
  plugin.done(() => new UndoRedo.CreateRowAction(index, amount), source);
58
57
  });
59
- const getCellMetas = (fromRow, toRow, fromColumn, toColumn) => {
60
- const genericKeys = ['visualRow', 'visualCol', 'row', 'col', 'prop'];
61
- const genericKeysLength = genericKeys.length;
62
- const cellMetas = [];
63
- rangeEach(fromColumn, toColumn, columnIndex => {
64
- rangeEach(fromRow, toRow, rowIndex => {
65
- const cellMeta = instance.getCellMeta(rowIndex, columnIndex);
66
- if (Object.keys(cellMeta).length !== genericKeysLength) {
67
- const uniqueMeta = Object.fromEntries(Object.entries(cellMeta).filter(_ref => {
68
- let [key] = _ref;
69
- return genericKeys.includes(key) === false;
70
- }));
71
- cellMetas.push([cellMeta.visualRow, cellMeta.visualCol, uniqueMeta]);
72
- }
73
- });
74
- });
75
- return cellMetas;
76
- };
77
58
  instance.addHook('beforeRemoveRow', (index, amount, logicRows, source) => {
78
59
  const wrappedAction = () => {
79
60
  const physicalRowIndex = instance.toPhysicalRow(index);
80
- const lastRowIndex = physicalRowIndex + amount - 1;
81
61
  const removedData = deepClone(plugin.instance.getSourceData(physicalRowIndex, 0, physicalRowIndex + amount - 1, plugin.instance.countSourceCols() - 1));
82
- return new UndoRedo.RemoveRowAction(physicalRowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop, instance.rowIndexMapper.getIndexesSequence(), getCellMetas(physicalRowIndex, lastRowIndex, 0, instance.countCols() - 1));
62
+ return new UndoRedo.RemoveRowAction(physicalRowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop, instance.rowIndexMapper.getIndexesSequence());
83
63
  };
84
64
  plugin.done(wrappedAction, source);
85
65
  });
@@ -90,14 +70,13 @@ function UndoRedo(instance) {
90
70
  const wrappedAction = () => {
91
71
  const originalData = plugin.instance.getSourceDataArray();
92
72
  const columnIndex = (plugin.instance.countCols() + index) % plugin.instance.countCols();
93
- const lastColumnIndex = columnIndex + amount - 1;
94
73
  const removedData = [];
95
74
  const headers = [];
96
75
  const indexes = [];
97
76
  rangeEach(originalData.length - 1, i => {
98
77
  const column = [];
99
78
  const origRow = originalData[i];
100
- rangeEach(columnIndex, lastColumnIndex, j => {
79
+ rangeEach(columnIndex, columnIndex + (amount - 1), j => {
101
80
  column.push(origRow[instance.toPhysicalColumn(j)]);
102
81
  });
103
82
  removedData.push(column);
@@ -112,7 +91,7 @@ function UndoRedo(instance) {
112
91
  }
113
92
  const columnsMap = instance.columnIndexMapper.getIndexesSequence();
114
93
  const rowsMap = instance.rowIndexMapper.getIndexesSequence();
115
- return new UndoRedo.RemoveColumnAction(columnIndex, indexes, removedData, headers, columnsMap, rowsMap, instance.getSettings().fixedColumnsStart, getCellMetas(0, instance.countRows(), columnIndex, lastColumnIndex));
94
+ return new UndoRedo.RemoveColumnAction(columnIndex, indexes, removedData, headers, columnsMap, rowsMap, instance.getSettings().fixedColumnsStart);
116
95
  };
117
96
  plugin.done(wrappedAction, source);
118
97
  });
@@ -380,6 +359,32 @@ UndoRedo.ChangeAction.prototype.undo = function (instance, undoneCallback) {
380
359
  instance.undoRedo.doneActions.pop();
381
360
  }
382
361
  }
362
+ const selectedLast = instance.getSelectedLast();
363
+ if (selectedLast !== undefined) {
364
+ const [changedRow, changedColumn] = data[0];
365
+ const [selectedRow, selectedColumn] = selectedLast;
366
+ const firstFullyVisibleRow = instance.view.getFirstFullyVisibleRow();
367
+ const firstFullyVisibleColumn = instance.view.getFirstFullyVisibleColumn();
368
+ const isInVerticalViewPort = changedRow >= firstFullyVisibleRow;
369
+ const isInHorizontalViewPort = changedColumn >= firstFullyVisibleColumn;
370
+ const isInViewport = isInVerticalViewPort && isInHorizontalViewPort;
371
+ const isChangedSelection = selectedRow !== changedRow || selectedColumn !== changedColumn;
372
+
373
+ // Performing scroll only when selection has been changed right after editing a cell.
374
+ if (isInViewport === false && isChangedSelection === true) {
375
+ const scrollConfig = {
376
+ row: changedRow,
377
+ col: changedColumn
378
+ };
379
+ if (isInVerticalViewPort === false) {
380
+ scrollConfig.verticalSnap = 'top';
381
+ }
382
+ if (isInHorizontalViewPort === false) {
383
+ scrollConfig.horizontalSnap = 'start';
384
+ }
385
+ instance.scrollViewportTo(scrollConfig);
386
+ }
387
+ }
383
388
  instance.selectCells(this.selected, false, false);
384
389
  };
385
390
  UndoRedo.ChangeAction.prototype.redo = function (instance, onFinishCallback) {
@@ -430,16 +435,14 @@ UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
430
435
  * @param {number} fixedRowsBottom Number of fixed rows on the bottom. Remove row action change it sometimes.
431
436
  * @param {number} fixedRowsTop Number of fixed rows on the top. Remove row action change it sometimes.
432
437
  * @param {Array} rowIndexesSequence Row index sequence taken from the row index mapper.
433
- * @param {Array} removedCellMetas List of removed cell metas.
434
438
  */
435
- UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence, removedCellMetas) {
439
+ UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence) {
436
440
  this.index = index;
437
441
  this.data = data;
438
442
  this.actionType = 'remove_row';
439
443
  this.fixedRowsBottom = fixedRowsBottom;
440
444
  this.fixedRowsTop = fixedRowsTop;
441
445
  this.rowIndexesSequence = rowIndexesSequence;
442
- this.removedCellMetas = removedCellMetas;
443
446
  };
444
447
  inherit(UndoRedo.RemoveRowAction, UndoRedo.Action);
445
448
  UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
@@ -458,10 +461,6 @@ UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
458
461
  });
459
462
  });
460
463
  instance.alter('insert_row_above', this.index, this.data.length, 'UndoRedo.undo');
461
- this.removedCellMetas.forEach(_ref2 => {
462
- let [rowIndex, columnIndex, cellMeta] = _ref2;
463
- instance.setCellMetaObject(rowIndex, columnIndex, cellMeta);
464
- });
465
464
  instance.addHookOnce('afterViewRender', undoneCallback);
466
465
  instance.setSourceDataAtCell(changes, null, null, 'UndoRedo.undo');
467
466
  instance.rowIndexMapper.setIndexesSequence(this.rowIndexesSequence);
@@ -504,9 +503,8 @@ UndoRedo.CreateColumnAction.prototype.redo = function (instance, redoneCallback)
504
503
  * @param {number[]} columnPositions The column position.
505
504
  * @param {number[]} rowPositions The row position.
506
505
  * @param {number} fixedColumnsStart Number of fixed columns on the left. Remove column action change it sometimes.
507
- * @param {Array} removedCellMetas List of removed cell metas.
508
506
  */
509
- UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart, removedCellMetas) {
507
+ UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart) {
510
508
  // eslint-disable-line max-len
511
509
  this.index = index;
512
510
  this.indexes = indexes;
@@ -517,7 +515,6 @@ UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPos
517
515
  this.rowPositions = rowPositions.slice(0);
518
516
  this.actionType = 'remove_col';
519
517
  this.fixedColumnsStart = fixedColumnsStart;
520
- this.removedCellMetas = removedCellMetas;
521
518
  };
522
519
  inherit(UndoRedo.RemoveColumnAction, UndoRedo.Action);
523
520
  UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
@@ -547,10 +544,6 @@ UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback)
547
544
  instance.getSettings().colHeaders[ascendingIndexes[columnIndex]] = headerData;
548
545
  });
549
546
  }
550
- this.removedCellMetas.forEach(_ref3 => {
551
- let [rowIndex, columnIndex, cellMeta] = _ref3;
552
- instance.setCellMetaObject(rowIndex, columnIndex, cellMeta);
553
- });
554
547
  instance.batchExecution(() => {
555
548
  // Restore row sequence in a case when all columns are removed. the original
556
549
  // row sequence is lost in that case.