handsontable 0.0.0-next-0416ebd-20231214 → 0.0.0-next-a7e8ff6-20231215
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 +5 -5
- package/dist/handsontable.full.css +5 -5
- package/dist/handsontable.full.js +275 -42
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +55 -55
- package/dist/handsontable.js +275 -42
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +18 -18
- package/eventManager.js +2 -1
- package/eventManager.mjs +2 -1
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/customBorders/customBorders.d.ts +17 -8
- package/plugins/formulas/formulas.d.ts +1 -0
- package/plugins/manualColumnResize/manualColumnResize.js +6 -1
- package/plugins/manualColumnResize/manualColumnResize.mjs +6 -1
- package/plugins/manualRowResize/manualRowResize.js +7 -3
- package/plugins/manualRowResize/manualRowResize.mjs +7 -3
- package/plugins/undoRedo/undoRedo.js +38 -31
- package/plugins/undoRedo/undoRedo.mjs +38 -31
package/eventManager.js
CHANGED
@@ -19,7 +19,6 @@ let listenersCounter = 0;
|
|
19
19
|
* Event DOM manager for internal use in Handsontable.
|
20
20
|
*
|
21
21
|
* @class EventManager
|
22
|
-
* @util
|
23
22
|
*/
|
24
23
|
class EventManager {
|
25
24
|
/**
|
@@ -52,6 +51,7 @@ class EventManager {
|
|
52
51
|
addEventListener(element, eventName, callback) {
|
53
52
|
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
54
53
|
/**
|
54
|
+
* @private
|
55
55
|
* @param {Event} event The event object.
|
56
56
|
*/
|
57
57
|
function callbackProxy(event) {
|
@@ -211,6 +211,7 @@ function extendEvent(event) {
|
|
211
211
|
}
|
212
212
|
var _default = exports.default = EventManager;
|
213
213
|
/**
|
214
|
+
* @private
|
214
215
|
* @returns {number}
|
215
216
|
*/
|
216
217
|
function getListenersCounter() {
|
package/eventManager.mjs
CHANGED
@@ -15,7 +15,6 @@ let listenersCounter = 0;
|
|
15
15
|
* Event DOM manager for internal use in Handsontable.
|
16
16
|
*
|
17
17
|
* @class EventManager
|
18
|
-
* @util
|
19
18
|
*/
|
20
19
|
class EventManager {
|
21
20
|
/**
|
@@ -48,6 +47,7 @@ class EventManager {
|
|
48
47
|
addEventListener(element, eventName, callback) {
|
49
48
|
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
50
49
|
/**
|
50
|
+
* @private
|
51
51
|
* @param {Event} event The event object.
|
52
52
|
*/
|
53
53
|
function callbackProxy(event) {
|
@@ -208,6 +208,7 @@ function extendEvent(event) {
|
|
208
208
|
export default EventManager;
|
209
209
|
|
210
210
|
/**
|
211
|
+
* @private
|
211
212
|
* @returns {number}
|
212
213
|
*/
|
213
214
|
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-
|
137
|
+
const hotVersion = "0.0.0-next-a7e8ff6-20231215";
|
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-a7e8ff6-20231215";
|
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-a7e8ff6-20231215",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import CellRange from '../../3rdparty/walkontable/src/cell/range';
|
1
2
|
import Core from '../../core';
|
2
3
|
import { BasePlugin } from '../base';
|
3
4
|
import { SimpleCellCoords } from "../../common";
|
@@ -13,6 +14,14 @@ export interface BorderRange {
|
|
13
14
|
to: SimpleCellCoords;
|
14
15
|
};
|
15
16
|
}
|
17
|
+
export interface BorderDescriptor {
|
18
|
+
start?: BorderOptions;
|
19
|
+
end?: BorderOptions;
|
20
|
+
left?: BorderOptions;
|
21
|
+
right?: BorderOptions;
|
22
|
+
top?: BorderOptions;
|
23
|
+
bottom?: BorderOptions;
|
24
|
+
}
|
16
25
|
export type DetailedSettings = (SimpleCellCoords | BorderRange) & {
|
17
26
|
start?: BorderOptions | string;
|
18
27
|
end?: BorderOptions | string;
|
@@ -24,17 +33,17 @@ export type DetailedSettings = (SimpleCellCoords | BorderRange) & {
|
|
24
33
|
|
25
34
|
export type Settings = boolean | DetailedSettings[];
|
26
35
|
|
27
|
-
export interface
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
36
|
+
export interface ComputedBorder extends BorderDescriptor {
|
37
|
+
id: string;
|
38
|
+
row: number;
|
39
|
+
col: number;
|
40
|
+
border?: BorderOptions;
|
32
41
|
}
|
33
42
|
|
34
43
|
export class CustomBorders extends BasePlugin {
|
35
44
|
constructor(hotInstance: Core);
|
36
45
|
isEnabled(): boolean;
|
37
|
-
setBorders(selectionRanges:
|
38
|
-
getBorders(selectionRanges
|
39
|
-
clearBorders(selectionRanges
|
46
|
+
setBorders(selectionRanges: CellRange[] | Array<[number, number, number, number]>, borderObject: BorderDescriptor): void;
|
47
|
+
getBorders(selectionRanges?: CellRange[] | Array<[number, number, number, number]>): ComputedBorder[];
|
48
|
+
clearBorders(selectionRanges?: CellRange[] | Array<[number, number, number, number]>): void;
|
40
49
|
}
|
@@ -467,7 +467,12 @@ class ManualColumnResize extends _base.BasePlugin {
|
|
467
467
|
* @returns {boolean}
|
468
468
|
*/
|
469
469
|
checkIfColumnHeader(element) {
|
470
|
-
|
470
|
+
const thead = (0, _element.closest)(element, ['THEAD'], this.hot.rootElement);
|
471
|
+
const {
|
472
|
+
topOverlay,
|
473
|
+
topInlineStartCornerOverlay
|
474
|
+
} = this.hot.view._wt.wtOverlays;
|
475
|
+
return [topOverlay.clone.wtTable.THEAD, topInlineStartCornerOverlay.clone.wtTable.THEAD].includes(thead);
|
471
476
|
}
|
472
477
|
|
473
478
|
/**
|
@@ -462,7 +462,12 @@ export class ManualColumnResize extends BasePlugin {
|
|
462
462
|
* @returns {boolean}
|
463
463
|
*/
|
464
464
|
checkIfColumnHeader(element) {
|
465
|
-
|
465
|
+
const thead = closest(element, ['THEAD'], this.hot.rootElement);
|
466
|
+
const {
|
467
|
+
topOverlay,
|
468
|
+
topInlineStartCornerOverlay
|
469
|
+
} = this.hot.view._wt.wtOverlays;
|
470
|
+
return [topOverlay.clone.wtTable.THEAD, topInlineStartCornerOverlay.clone.wtTable.THEAD].includes(thead);
|
466
471
|
}
|
467
472
|
|
468
473
|
/**
|
@@ -446,9 +446,13 @@ class ManualRowResize extends _base.BasePlugin {
|
|
446
446
|
* @returns {boolean}
|
447
447
|
*/
|
448
448
|
checkIfRowHeader(element) {
|
449
|
-
|
450
|
-
const
|
451
|
-
|
449
|
+
const tbody = (0, _element.closest)(element, ['TBODY'], this.hot.rootElement);
|
450
|
+
const {
|
451
|
+
inlineStartOverlay,
|
452
|
+
topInlineStartCornerOverlay,
|
453
|
+
bottomInlineStartCornerOverlay
|
454
|
+
} = this.hot.view._wt.wtOverlays;
|
455
|
+
return [inlineStartOverlay.clone.wtTable.TBODY, topInlineStartCornerOverlay.clone.wtTable.TBODY, bottomInlineStartCornerOverlay.clone.wtTable.TBODY].includes(tbody);
|
452
456
|
}
|
453
457
|
|
454
458
|
/**
|
@@ -441,9 +441,13 @@ export class ManualRowResize extends BasePlugin {
|
|
441
441
|
* @returns {boolean}
|
442
442
|
*/
|
443
443
|
checkIfRowHeader(element) {
|
444
|
-
|
445
|
-
const
|
446
|
-
|
444
|
+
const tbody = closest(element, ['TBODY'], this.hot.rootElement);
|
445
|
+
const {
|
446
|
+
inlineStartOverlay,
|
447
|
+
topInlineStartCornerOverlay,
|
448
|
+
bottomInlineStartCornerOverlay
|
449
|
+
} = this.hot.view._wt.wtOverlays;
|
450
|
+
return [inlineStartOverlay.clone.wtTable.TBODY, topInlineStartCornerOverlay.clone.wtTable.TBODY, bottomInlineStartCornerOverlay.clone.wtTable.TBODY].includes(tbody);
|
447
451
|
}
|
448
452
|
|
449
453
|
/**
|
@@ -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
|
});
|
@@ -363,32 +384,6 @@ UndoRedo.ChangeAction.prototype.undo = function (instance, undoneCallback) {
|
|
363
384
|
instance.undoRedo.doneActions.pop();
|
364
385
|
}
|
365
386
|
}
|
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
|
-
}
|
392
387
|
instance.selectCells(this.selected, false, false);
|
393
388
|
};
|
394
389
|
UndoRedo.ChangeAction.prototype.redo = function (instance, onFinishCallback) {
|
@@ -439,14 +434,16 @@ UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
|
|
439
434
|
* @param {number} fixedRowsBottom Number of fixed rows on the bottom. Remove row action change it sometimes.
|
440
435
|
* @param {number} fixedRowsTop Number of fixed rows on the top. Remove row action change it sometimes.
|
441
436
|
* @param {Array} rowIndexesSequence Row index sequence taken from the row index mapper.
|
437
|
+
* @param {Array} removedCellMetas List of removed cell metas.
|
442
438
|
*/
|
443
|
-
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence) {
|
439
|
+
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence, removedCellMetas) {
|
444
440
|
this.index = index;
|
445
441
|
this.data = data;
|
446
442
|
this.actionType = 'remove_row';
|
447
443
|
this.fixedRowsBottom = fixedRowsBottom;
|
448
444
|
this.fixedRowsTop = fixedRowsTop;
|
449
445
|
this.rowIndexesSequence = rowIndexesSequence;
|
446
|
+
this.removedCellMetas = removedCellMetas;
|
450
447
|
};
|
451
448
|
(0, _object.inherit)(UndoRedo.RemoveRowAction, UndoRedo.Action);
|
452
449
|
UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
|
@@ -465,6 +462,10 @@ UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
|
|
465
462
|
});
|
466
463
|
});
|
467
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
|
+
});
|
468
469
|
instance.addHookOnce('afterViewRender', undoneCallback);
|
469
470
|
instance.setSourceDataAtCell(changes, null, null, 'UndoRedo.undo');
|
470
471
|
instance.rowIndexMapper.setIndexesSequence(this.rowIndexesSequence);
|
@@ -507,8 +508,9 @@ UndoRedo.CreateColumnAction.prototype.redo = function (instance, redoneCallback)
|
|
507
508
|
* @param {number[]} columnPositions The column position.
|
508
509
|
* @param {number[]} rowPositions The row position.
|
509
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.
|
510
512
|
*/
|
511
|
-
UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart) {
|
513
|
+
UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart, removedCellMetas) {
|
512
514
|
// eslint-disable-line max-len
|
513
515
|
this.index = index;
|
514
516
|
this.indexes = indexes;
|
@@ -519,6 +521,7 @@ UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPos
|
|
519
521
|
this.rowPositions = rowPositions.slice(0);
|
520
522
|
this.actionType = 'remove_col';
|
521
523
|
this.fixedColumnsStart = fixedColumnsStart;
|
524
|
+
this.removedCellMetas = removedCellMetas;
|
522
525
|
};
|
523
526
|
(0, _object.inherit)(UndoRedo.RemoveColumnAction, UndoRedo.Action);
|
524
527
|
UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
|
@@ -548,6 +551,10 @@ UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback)
|
|
548
551
|
instance.getSettings().colHeaders[ascendingIndexes[columnIndex]] = headerData;
|
549
552
|
});
|
550
553
|
}
|
554
|
+
this.removedCellMetas.forEach(_ref3 => {
|
555
|
+
let [rowIndex, columnIndex, cellMeta] = _ref3;
|
556
|
+
instance.setCellMetaObject(rowIndex, columnIndex, cellMeta);
|
557
|
+
});
|
551
558
|
instance.batchExecution(() => {
|
552
559
|
// Restore row sequence in a case when all columns are removed. the original
|
553
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
|
});
|
@@ -359,32 +380,6 @@ UndoRedo.ChangeAction.prototype.undo = function (instance, undoneCallback) {
|
|
359
380
|
instance.undoRedo.doneActions.pop();
|
360
381
|
}
|
361
382
|
}
|
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
|
-
}
|
388
383
|
instance.selectCells(this.selected, false, false);
|
389
384
|
};
|
390
385
|
UndoRedo.ChangeAction.prototype.redo = function (instance, onFinishCallback) {
|
@@ -435,14 +430,16 @@ UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
|
|
435
430
|
* @param {number} fixedRowsBottom Number of fixed rows on the bottom. Remove row action change it sometimes.
|
436
431
|
* @param {number} fixedRowsTop Number of fixed rows on the top. Remove row action change it sometimes.
|
437
432
|
* @param {Array} rowIndexesSequence Row index sequence taken from the row index mapper.
|
433
|
+
* @param {Array} removedCellMetas List of removed cell metas.
|
438
434
|
*/
|
439
|
-
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence) {
|
435
|
+
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence, removedCellMetas) {
|
440
436
|
this.index = index;
|
441
437
|
this.data = data;
|
442
438
|
this.actionType = 'remove_row';
|
443
439
|
this.fixedRowsBottom = fixedRowsBottom;
|
444
440
|
this.fixedRowsTop = fixedRowsTop;
|
445
441
|
this.rowIndexesSequence = rowIndexesSequence;
|
442
|
+
this.removedCellMetas = removedCellMetas;
|
446
443
|
};
|
447
444
|
inherit(UndoRedo.RemoveRowAction, UndoRedo.Action);
|
448
445
|
UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
|
@@ -461,6 +458,10 @@ UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
|
|
461
458
|
});
|
462
459
|
});
|
463
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
|
+
});
|
464
465
|
instance.addHookOnce('afterViewRender', undoneCallback);
|
465
466
|
instance.setSourceDataAtCell(changes, null, null, 'UndoRedo.undo');
|
466
467
|
instance.rowIndexMapper.setIndexesSequence(this.rowIndexesSequence);
|
@@ -503,8 +504,9 @@ UndoRedo.CreateColumnAction.prototype.redo = function (instance, redoneCallback)
|
|
503
504
|
* @param {number[]} columnPositions The column position.
|
504
505
|
* @param {number[]} rowPositions The row position.
|
505
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.
|
506
508
|
*/
|
507
|
-
UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart) {
|
509
|
+
UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions, rowPositions, fixedColumnsStart, removedCellMetas) {
|
508
510
|
// eslint-disable-line max-len
|
509
511
|
this.index = index;
|
510
512
|
this.indexes = indexes;
|
@@ -515,6 +517,7 @@ UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPos
|
|
515
517
|
this.rowPositions = rowPositions.slice(0);
|
516
518
|
this.actionType = 'remove_col';
|
517
519
|
this.fixedColumnsStart = fixedColumnsStart;
|
520
|
+
this.removedCellMetas = removedCellMetas;
|
518
521
|
};
|
519
522
|
inherit(UndoRedo.RemoveColumnAction, UndoRedo.Action);
|
520
523
|
UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
|
@@ -544,6 +547,10 @@ UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback)
|
|
544
547
|
instance.getSettings().colHeaders[ascendingIndexes[columnIndex]] = headerData;
|
545
548
|
});
|
546
549
|
}
|
550
|
+
this.removedCellMetas.forEach(_ref3 => {
|
551
|
+
let [rowIndex, columnIndex, cellMeta] = _ref3;
|
552
|
+
instance.setCellMetaObject(rowIndex, columnIndex, cellMeta);
|
553
|
+
});
|
547
554
|
instance.batchExecution(() => {
|
548
555
|
// Restore row sequence in a case when all columns are removed. the original
|
549
556
|
// row sequence is lost in that case.
|