handsontable 0.0.0-next-e2b07e5-20231213 → 0.0.0-next-9327dd7-20231213
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/base.js +2 -2
- package/base.mjs +2 -2
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +260 -11
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +5 -5
- package/dist/handsontable.js +260 -11
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +17 -17
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/undoRedo/undoRedo.js +38 -5
- package/plugins/undoRedo/undoRedo.mjs +38 -5
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-
|
137
|
+
const hotVersion = "0.0.0-next-9327dd7-20231213";
|
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-
|
127
|
+
const hotVersion = "0.0.0-next-9327dd7-20231213";
|
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-
|
13
|
+
"version": "0.0.0-next-9327dd7-20231213",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
@@ -2,6 +2,7 @@
|
|
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");
|
5
6
|
var _pluginHooks = _interopRequireDefault(require("../../pluginHooks"));
|
6
7
|
var _array = require("../../helpers/array");
|
7
8
|
var _number = require("../../helpers/number");
|
@@ -59,11 +60,30 @@ function UndoRedo(instance) {
|
|
59
60
|
instance.addHook('afterCreateRow', (index, amount, source) => {
|
60
61
|
plugin.done(() => new UndoRedo.CreateRowAction(index, amount), source);
|
61
62
|
});
|
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
|
+
};
|
62
81
|
instance.addHook('beforeRemoveRow', (index, amount, logicRows, source) => {
|
63
82
|
const wrappedAction = () => {
|
64
83
|
const physicalRowIndex = instance.toPhysicalRow(index);
|
84
|
+
const lastRowIndex = physicalRowIndex + amount - 1;
|
65
85
|
const removedData = (0, _object.deepClone)(plugin.instance.getSourceData(physicalRowIndex, 0, physicalRowIndex + amount - 1, plugin.instance.countSourceCols() - 1));
|
66
|
-
return new UndoRedo.RemoveRowAction(physicalRowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop, instance.rowIndexMapper.getIndexesSequence());
|
86
|
+
return new UndoRedo.RemoveRowAction(physicalRowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop, instance.rowIndexMapper.getIndexesSequence(), getCellMetas(physicalRowIndex, lastRowIndex, 0, instance.countCols() - 1));
|
67
87
|
};
|
68
88
|
plugin.done(wrappedAction, source);
|
69
89
|
});
|
@@ -74,13 +94,14 @@ function UndoRedo(instance) {
|
|
74
94
|
const wrappedAction = () => {
|
75
95
|
const originalData = plugin.instance.getSourceDataArray();
|
76
96
|
const columnIndex = (plugin.instance.countCols() + index) % plugin.instance.countCols();
|
97
|
+
const lastColumnIndex = columnIndex + amount - 1;
|
77
98
|
const removedData = [];
|
78
99
|
const headers = [];
|
79
100
|
const indexes = [];
|
80
101
|
(0, _number.rangeEach)(originalData.length - 1, i => {
|
81
102
|
const column = [];
|
82
103
|
const origRow = originalData[i];
|
83
|
-
(0, _number.rangeEach)(columnIndex,
|
104
|
+
(0, _number.rangeEach)(columnIndex, lastColumnIndex, j => {
|
84
105
|
column.push(origRow[instance.toPhysicalColumn(j)]);
|
85
106
|
});
|
86
107
|
removedData.push(column);
|
@@ -95,7 +116,7 @@ function UndoRedo(instance) {
|
|
95
116
|
}
|
96
117
|
const columnsMap = instance.columnIndexMapper.getIndexesSequence();
|
97
118
|
const rowsMap = instance.rowIndexMapper.getIndexesSequence();
|
98
|
-
return new UndoRedo.RemoveColumnAction(columnIndex, indexes, removedData, headers, columnsMap, rowsMap, instance.getSettings().fixedColumnsStart);
|
119
|
+
return new UndoRedo.RemoveColumnAction(columnIndex, indexes, removedData, headers, columnsMap, rowsMap, instance.getSettings().fixedColumnsStart, getCellMetas(0, instance.countRows(), columnIndex, lastColumnIndex));
|
99
120
|
};
|
100
121
|
plugin.done(wrappedAction, source);
|
101
122
|
});
|
@@ -413,14 +434,16 @@ UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
|
|
413
434
|
* @param {number} fixedRowsBottom Number of fixed rows on the bottom. Remove row action change it sometimes.
|
414
435
|
* @param {number} fixedRowsTop Number of fixed rows on the top. Remove row action change it sometimes.
|
415
436
|
* @param {Array} rowIndexesSequence Row index sequence taken from the row index mapper.
|
437
|
+
* @param {Array} removedCellMetas List of removed cell metas.
|
416
438
|
*/
|
417
|
-
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence) {
|
439
|
+
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence, removedCellMetas) {
|
418
440
|
this.index = index;
|
419
441
|
this.data = data;
|
420
442
|
this.actionType = 'remove_row';
|
421
443
|
this.fixedRowsBottom = fixedRowsBottom;
|
422
444
|
this.fixedRowsTop = fixedRowsTop;
|
423
445
|
this.rowIndexesSequence = rowIndexesSequence;
|
446
|
+
this.removedCellMetas = removedCellMetas;
|
424
447
|
};
|
425
448
|
(0, _object.inherit)(UndoRedo.RemoveRowAction, UndoRedo.Action);
|
426
449
|
UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
|
@@ -439,6 +462,10 @@ UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
|
|
439
462
|
});
|
440
463
|
});
|
441
464
|
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
|
+
});
|
442
469
|
instance.addHookOnce('afterViewRender', undoneCallback);
|
443
470
|
instance.setSourceDataAtCell(changes, null, null, 'UndoRedo.undo');
|
444
471
|
instance.rowIndexMapper.setIndexesSequence(this.rowIndexesSequence);
|
@@ -481,8 +508,9 @@ UndoRedo.CreateColumnAction.prototype.redo = function (instance, redoneCallback)
|
|
481
508
|
* @param {number[]} columnPositions The column position.
|
482
509
|
* @param {number[]} rowPositions The row position.
|
483
510
|
* @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.
|
484
512
|
*/
|
485
|
-
UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart) {
|
513
|
+
UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart, removedCellMetas) {
|
486
514
|
// eslint-disable-line max-len
|
487
515
|
this.index = index;
|
488
516
|
this.indexes = indexes;
|
@@ -493,6 +521,7 @@ UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPos
|
|
493
521
|
this.rowPositions = rowPositions.slice(0);
|
494
522
|
this.actionType = 'remove_col';
|
495
523
|
this.fixedColumnsStart = fixedColumnsStart;
|
524
|
+
this.removedCellMetas = removedCellMetas;
|
496
525
|
};
|
497
526
|
(0, _object.inherit)(UndoRedo.RemoveColumnAction, UndoRedo.Action);
|
498
527
|
UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
|
@@ -522,6 +551,10 @@ UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback)
|
|
522
551
|
instance.getSettings().colHeaders[ascendingIndexes[columnIndex]] = headerData;
|
523
552
|
});
|
524
553
|
}
|
554
|
+
this.removedCellMetas.forEach(_ref3 => {
|
555
|
+
let [rowIndex, columnIndex, cellMeta] = _ref3;
|
556
|
+
instance.setCellMetaObject(rowIndex, columnIndex, cellMeta);
|
557
|
+
});
|
525
558
|
instance.batchExecution(() => {
|
526
559
|
// Restore row sequence in a case when all columns are removed. the original
|
527
560
|
// row sequence is lost in that case.
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import "core-js/modules/es.array.push.js";
|
2
|
+
import "core-js/modules/es.object.from-entries.js";
|
2
3
|
import Hooks from "../../pluginHooks.mjs";
|
3
4
|
import { arrayMap, arrayEach } from "../../helpers/array.mjs";
|
4
5
|
import { rangeEach } from "../../helpers/number.mjs";
|
@@ -55,11 +56,30 @@ function UndoRedo(instance) {
|
|
55
56
|
instance.addHook('afterCreateRow', (index, amount, source) => {
|
56
57
|
plugin.done(() => new UndoRedo.CreateRowAction(index, amount), source);
|
57
58
|
});
|
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
|
+
};
|
58
77
|
instance.addHook('beforeRemoveRow', (index, amount, logicRows, source) => {
|
59
78
|
const wrappedAction = () => {
|
60
79
|
const physicalRowIndex = instance.toPhysicalRow(index);
|
80
|
+
const lastRowIndex = physicalRowIndex + amount - 1;
|
61
81
|
const removedData = deepClone(plugin.instance.getSourceData(physicalRowIndex, 0, physicalRowIndex + amount - 1, plugin.instance.countSourceCols() - 1));
|
62
|
-
return new UndoRedo.RemoveRowAction(physicalRowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop, instance.rowIndexMapper.getIndexesSequence());
|
82
|
+
return new UndoRedo.RemoveRowAction(physicalRowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop, instance.rowIndexMapper.getIndexesSequence(), getCellMetas(physicalRowIndex, lastRowIndex, 0, instance.countCols() - 1));
|
63
83
|
};
|
64
84
|
plugin.done(wrappedAction, source);
|
65
85
|
});
|
@@ -70,13 +90,14 @@ function UndoRedo(instance) {
|
|
70
90
|
const wrappedAction = () => {
|
71
91
|
const originalData = plugin.instance.getSourceDataArray();
|
72
92
|
const columnIndex = (plugin.instance.countCols() + index) % plugin.instance.countCols();
|
93
|
+
const lastColumnIndex = columnIndex + amount - 1;
|
73
94
|
const removedData = [];
|
74
95
|
const headers = [];
|
75
96
|
const indexes = [];
|
76
97
|
rangeEach(originalData.length - 1, i => {
|
77
98
|
const column = [];
|
78
99
|
const origRow = originalData[i];
|
79
|
-
rangeEach(columnIndex,
|
100
|
+
rangeEach(columnIndex, lastColumnIndex, j => {
|
80
101
|
column.push(origRow[instance.toPhysicalColumn(j)]);
|
81
102
|
});
|
82
103
|
removedData.push(column);
|
@@ -91,7 +112,7 @@ function UndoRedo(instance) {
|
|
91
112
|
}
|
92
113
|
const columnsMap = instance.columnIndexMapper.getIndexesSequence();
|
93
114
|
const rowsMap = instance.rowIndexMapper.getIndexesSequence();
|
94
|
-
return new UndoRedo.RemoveColumnAction(columnIndex, indexes, removedData, headers, columnsMap, rowsMap, instance.getSettings().fixedColumnsStart);
|
115
|
+
return new UndoRedo.RemoveColumnAction(columnIndex, indexes, removedData, headers, columnsMap, rowsMap, instance.getSettings().fixedColumnsStart, getCellMetas(0, instance.countRows(), columnIndex, lastColumnIndex));
|
95
116
|
};
|
96
117
|
plugin.done(wrappedAction, source);
|
97
118
|
});
|
@@ -409,14 +430,16 @@ UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
|
|
409
430
|
* @param {number} fixedRowsBottom Number of fixed rows on the bottom. Remove row action change it sometimes.
|
410
431
|
* @param {number} fixedRowsTop Number of fixed rows on the top. Remove row action change it sometimes.
|
411
432
|
* @param {Array} rowIndexesSequence Row index sequence taken from the row index mapper.
|
433
|
+
* @param {Array} removedCellMetas List of removed cell metas.
|
412
434
|
*/
|
413
|
-
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence) {
|
435
|
+
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence, removedCellMetas) {
|
414
436
|
this.index = index;
|
415
437
|
this.data = data;
|
416
438
|
this.actionType = 'remove_row';
|
417
439
|
this.fixedRowsBottom = fixedRowsBottom;
|
418
440
|
this.fixedRowsTop = fixedRowsTop;
|
419
441
|
this.rowIndexesSequence = rowIndexesSequence;
|
442
|
+
this.removedCellMetas = removedCellMetas;
|
420
443
|
};
|
421
444
|
inherit(UndoRedo.RemoveRowAction, UndoRedo.Action);
|
422
445
|
UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
|
@@ -435,6 +458,10 @@ UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
|
|
435
458
|
});
|
436
459
|
});
|
437
460
|
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
|
+
});
|
438
465
|
instance.addHookOnce('afterViewRender', undoneCallback);
|
439
466
|
instance.setSourceDataAtCell(changes, null, null, 'UndoRedo.undo');
|
440
467
|
instance.rowIndexMapper.setIndexesSequence(this.rowIndexesSequence);
|
@@ -477,8 +504,9 @@ UndoRedo.CreateColumnAction.prototype.redo = function (instance, redoneCallback)
|
|
477
504
|
* @param {number[]} columnPositions The column position.
|
478
505
|
* @param {number[]} rowPositions The row position.
|
479
506
|
* @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.
|
480
508
|
*/
|
481
|
-
UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart) {
|
509
|
+
UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart, removedCellMetas) {
|
482
510
|
// eslint-disable-line max-len
|
483
511
|
this.index = index;
|
484
512
|
this.indexes = indexes;
|
@@ -489,6 +517,7 @@ UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPos
|
|
489
517
|
this.rowPositions = rowPositions.slice(0);
|
490
518
|
this.actionType = 'remove_col';
|
491
519
|
this.fixedColumnsStart = fixedColumnsStart;
|
520
|
+
this.removedCellMetas = removedCellMetas;
|
492
521
|
};
|
493
522
|
inherit(UndoRedo.RemoveColumnAction, UndoRedo.Action);
|
494
523
|
UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
|
@@ -518,6 +547,10 @@ UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback)
|
|
518
547
|
instance.getSettings().colHeaders[ascendingIndexes[columnIndex]] = headerData;
|
519
548
|
});
|
520
549
|
}
|
550
|
+
this.removedCellMetas.forEach(_ref3 => {
|
551
|
+
let [rowIndex, columnIndex, cellMeta] = _ref3;
|
552
|
+
instance.setCellMetaObject(rowIndex, columnIndex, cellMeta);
|
553
|
+
});
|
521
554
|
instance.batchExecution(() => {
|
522
555
|
// Restore row sequence in a case when all columns are removed. the original
|
523
556
|
// row sequence is lost in that case.
|