handsontable 0.0.0-next-6812ce6-20221122 → 0.0.0-next-1b1acbd-20221123
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/core.js +2 -2
- package/core.mjs +2 -2
- package/dataMap/dataMap.js +30 -2
- package/dataMap/dataMap.mjs +30 -2
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +392 -350
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +42 -42
- package/dist/handsontable.js +340 -298
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +3 -3
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/helpers/object.js +8 -7
- package/helpers/object.mjs +3 -2
- package/package.json +1 -1
- package/plugins/undoRedo/undoRedo.js +43 -30
- package/plugins/undoRedo/undoRedo.mjs +43 -30
package/helpers/mixed.js
CHANGED
@@ -152,7 +152,7 @@ var domMessages = {
|
|
152
152
|
function _injectProductInfo(key, element) {
|
153
153
|
var hasValidType = !isEmpty(key);
|
154
154
|
var isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
155
|
-
var hotVersion = "0.0.0-next-
|
155
|
+
var hotVersion = "0.0.0-next-1b1acbd-20221123";
|
156
156
|
var keyValidityDate;
|
157
157
|
var consoleMessageState = 'invalid';
|
158
158
|
var domMessageState = 'invalid';
|
package/helpers/mixed.mjs
CHANGED
@@ -142,7 +142,7 @@ var domMessages = {
|
|
142
142
|
export function _injectProductInfo(key, element) {
|
143
143
|
var hasValidType = !isEmpty(key);
|
144
144
|
var isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
145
|
-
var hotVersion = "0.0.0-next-
|
145
|
+
var hotVersion = "0.0.0-next-1b1acbd-20221123";
|
146
146
|
var keyValidityDate;
|
147
147
|
var consoleMessageState = 'invalid';
|
148
148
|
var domMessageState = 'invalid';
|
package/helpers/object.js
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
require("core-js/modules/es.symbol.js");
|
4
|
+
require("core-js/modules/es.symbol.description.js");
|
5
|
+
require("core-js/modules/es.symbol.iterator.js");
|
6
|
+
require("core-js/modules/es.array.iterator.js");
|
7
|
+
require("core-js/modules/es.string.iterator.js");
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
3
9
|
exports.__esModule = true;
|
4
10
|
exports.clone = clone;
|
5
11
|
exports.createObjectPropListener = createObjectPropListener;
|
@@ -17,16 +23,11 @@ exports.isObjectEqual = isObjectEqual;
|
|
17
23
|
exports.mixin = mixin;
|
18
24
|
exports.objectEach = objectEach;
|
19
25
|
exports.setProperty = setProperty;
|
26
|
+
require("core-js/modules/es.array.fill.js");
|
20
27
|
require("core-js/modules/es.array.includes.js");
|
21
28
|
require("core-js/modules/es.string.includes.js");
|
22
29
|
require("core-js/modules/es.object.to-string.js");
|
23
30
|
require("core-js/modules/web.dom-collections.for-each.js");
|
24
|
-
require("core-js/modules/es.symbol.js");
|
25
|
-
require("core-js/modules/es.symbol.description.js");
|
26
|
-
require("core-js/modules/es.symbol.iterator.js");
|
27
|
-
require("core-js/modules/es.array.iterator.js");
|
28
|
-
require("core-js/modules/es.string.iterator.js");
|
29
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
30
31
|
var _array = require("./array");
|
31
32
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
32
33
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
@@ -39,7 +40,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
39
40
|
function duckSchema(object) {
|
40
41
|
var schema;
|
41
42
|
if (Array.isArray(object)) {
|
42
|
-
schema = [];
|
43
|
+
schema = object.length ? new Array(object.length).fill(null) : [];
|
43
44
|
} else {
|
44
45
|
schema = {};
|
45
46
|
objectEach(object, function (value, key) {
|
package/helpers/object.mjs
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
3
|
+
import "core-js/modules/es.array.fill.js";
|
2
4
|
import "core-js/modules/es.array.includes.js";
|
3
5
|
import "core-js/modules/es.string.includes.js";
|
4
6
|
import "core-js/modules/es.object.to-string.js";
|
@@ -9,7 +11,6 @@ import "core-js/modules/es.symbol.iterator.js";
|
|
9
11
|
import "core-js/modules/es.array.iterator.js";
|
10
12
|
import "core-js/modules/es.string.iterator.js";
|
11
13
|
import "core-js/modules/web.dom-collections.iterator.js";
|
12
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
13
14
|
import { arrayEach } from "./array.mjs";
|
14
15
|
/**
|
15
16
|
* Generate schema for passed object.
|
@@ -20,7 +21,7 @@ import { arrayEach } from "./array.mjs";
|
|
20
21
|
export function duckSchema(object) {
|
21
22
|
var schema;
|
22
23
|
if (Array.isArray(object)) {
|
23
|
-
schema = [];
|
24
|
+
schema = object.length ? new Array(object.length).fill(null) : [];
|
24
25
|
} else {
|
25
26
|
schema = {};
|
26
27
|
objectEach(object, function (value, key) {
|
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-1b1acbd-20221123",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
@@ -20,6 +20,8 @@ require("core-js/modules/es.object.to-string.js");
|
|
20
20
|
require("core-js/modules/es.array.reduce.js");
|
21
21
|
require("core-js/modules/es.array.slice.js");
|
22
22
|
require("core-js/modules/es.array.splice.js");
|
23
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
24
|
+
require("core-js/modules/es.object.keys.js");
|
23
25
|
require("core-js/modules/es.array.sort.js");
|
24
26
|
require("core-js/modules/es.array.index-of.js");
|
25
27
|
require("core-js/modules/es.array.filter.js");
|
@@ -109,11 +111,9 @@ function UndoRedo(instance) {
|
|
109
111
|
});
|
110
112
|
instance.addHook('beforeRemoveRow', function (index, amount, logicRows, source) {
|
111
113
|
var wrappedAction = function wrappedAction() {
|
112
|
-
var
|
113
|
-
var
|
114
|
-
|
115
|
-
var removedData = (0, _object.deepClone)(originalData.slice(physicalRowIndex, physicalRowIndex + amount));
|
116
|
-
return new UndoRedo.RemoveRowAction(rowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop);
|
114
|
+
var physicalRowIndex = instance.toPhysicalRow(index);
|
115
|
+
var removedData = (0, _object.deepClone)(plugin.instance.getSourceData(physicalRowIndex, 0, physicalRowIndex + amount - 1, plugin.instance.countSourceCols() - 1));
|
116
|
+
return new UndoRedo.RemoveRowAction(physicalRowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop, instance.rowIndexMapper.getIndexesSequence());
|
117
117
|
};
|
118
118
|
plugin.done(wrappedAction, source);
|
119
119
|
});
|
@@ -477,24 +477,37 @@ UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
|
|
477
477
|
* @param {Array} data The removed data.
|
478
478
|
* @param {number} fixedRowsBottom Number of fixed rows on the bottom. Remove row action change it sometimes.
|
479
479
|
* @param {number} fixedRowsTop Number of fixed rows on the top. Remove row action change it sometimes.
|
480
|
+
* @param {Array} rowIndexesSequence Row index sequence taken from the row index mapper.
|
480
481
|
*/
|
481
|
-
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop) {
|
482
|
+
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence) {
|
482
483
|
this.index = index;
|
483
484
|
this.data = data;
|
484
485
|
this.actionType = 'remove_row';
|
485
486
|
this.fixedRowsBottom = fixedRowsBottom;
|
486
487
|
this.fixedRowsTop = fixedRowsTop;
|
488
|
+
this.rowIndexesSequence = rowIndexesSequence;
|
487
489
|
};
|
488
490
|
(0, _object.inherit)(UndoRedo.RemoveRowAction, UndoRedo.Action);
|
489
491
|
UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
|
492
|
+
var _this2 = this;
|
490
493
|
var settings = instance.getSettings();
|
494
|
+
var changes = [];
|
491
495
|
|
492
496
|
// Changing by the reference as `updateSettings` doesn't work the best.
|
493
497
|
settings.fixedRowsBottom = this.fixedRowsBottom;
|
494
498
|
settings.fixedRowsTop = this.fixedRowsTop;
|
499
|
+
|
500
|
+
// Prepare the change list to fill the source data.
|
501
|
+
this.data.forEach(function (dataRow, rowIndexDelta) {
|
502
|
+
Object.keys(dataRow).forEach(function (columnProp) {
|
503
|
+
var columnIndex = parseInt(columnProp, 10);
|
504
|
+
changes.push([_this2.index + rowIndexDelta, isNaN(columnIndex) ? columnProp : columnIndex, dataRow[columnProp]]);
|
505
|
+
});
|
506
|
+
});
|
495
507
|
instance.alter('insert_row_above', this.index, this.data.length, 'UndoRedo.undo');
|
496
508
|
instance.addHookOnce('afterViewRender', undoneCallback);
|
497
|
-
instance.
|
509
|
+
instance.setSourceDataAtCell(changes, null, null, 'UndoRedo.undo');
|
510
|
+
instance.rowIndexMapper.setIndexesSequence(this.rowIndexesSequence);
|
498
511
|
};
|
499
512
|
UndoRedo.RemoveRowAction.prototype.redo = function (instance, redoneCallback) {
|
500
513
|
instance.addHookOnce('afterRemoveRow', redoneCallback);
|
@@ -549,14 +562,14 @@ UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPos
|
|
549
562
|
};
|
550
563
|
(0, _object.inherit)(UndoRedo.RemoveColumnAction, UndoRedo.Action);
|
551
564
|
UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
|
552
|
-
var
|
565
|
+
var _this3 = this;
|
553
566
|
var settings = instance.getSettings();
|
554
567
|
|
555
568
|
// Changing by the reference as `updateSettings` doesn't work the best.
|
556
569
|
settings.fixedColumnsStart = this.fixedColumnsStart;
|
557
570
|
var ascendingIndexes = this.indexes.slice(0).sort();
|
558
571
|
var sortByIndexes = function sortByIndexes(elem, j, arr) {
|
559
|
-
return arr[
|
572
|
+
return arr[_this3.indexes.indexOf(ascendingIndexes[j])];
|
560
573
|
};
|
561
574
|
var removedDataLength = this.data.length;
|
562
575
|
var sortedData = [];
|
@@ -582,8 +595,8 @@ UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback)
|
|
582
595
|
instance.batchExecution(function () {
|
583
596
|
// Restore row sequence in a case when all columns are removed. the original
|
584
597
|
// row sequence is lost in that case.
|
585
|
-
instance.rowIndexMapper.setIndexesSequence(
|
586
|
-
instance.columnIndexMapper.setIndexesSequence(
|
598
|
+
instance.rowIndexMapper.setIndexesSequence(_this3.rowPositions);
|
599
|
+
instance.columnIndexMapper.setIndexesSequence(_this3.columnPositions);
|
587
600
|
}, true);
|
588
601
|
instance.addHookOnce('afterViewRender', undoneCallback);
|
589
602
|
instance.render();
|
@@ -609,12 +622,12 @@ UndoRedo.CellAlignmentAction = function (stateBefore, range, type, alignment) {
|
|
609
622
|
this.alignment = alignment;
|
610
623
|
};
|
611
624
|
UndoRedo.CellAlignmentAction.prototype.undo = function (instance, undoneCallback) {
|
612
|
-
var
|
625
|
+
var _this4 = this;
|
613
626
|
(0, _array.arrayEach)(this.range, function (range) {
|
614
627
|
range.forAll(function (row, col) {
|
615
628
|
// Alignment classes should only collected within cell ranges. We skip header coordinates.
|
616
629
|
if (row >= 0 && col >= 0) {
|
617
|
-
instance.setCellMeta(row, col, 'className',
|
630
|
+
instance.setCellMeta(row, col, 'className', _this4.stateBefore[row][col] || ' htLeft');
|
618
631
|
}
|
619
632
|
});
|
620
633
|
});
|
@@ -664,14 +677,14 @@ var MergeCellsAction = /*#__PURE__*/function (_UndoRedo$Action) {
|
|
664
677
|
_inherits(MergeCellsAction, _UndoRedo$Action);
|
665
678
|
var _super = _createSuper(MergeCellsAction);
|
666
679
|
function MergeCellsAction(instance, cellRange) {
|
667
|
-
var
|
680
|
+
var _this5;
|
668
681
|
_classCallCheck(this, MergeCellsAction);
|
669
|
-
|
670
|
-
|
671
|
-
var topStartCorner =
|
672
|
-
var bottomEndCorner =
|
673
|
-
|
674
|
-
return
|
682
|
+
_this5 = _super.call(this);
|
683
|
+
_this5.cellRange = cellRange;
|
684
|
+
var topStartCorner = _this5.cellRange.getTopStartCorner();
|
685
|
+
var bottomEndCorner = _this5.cellRange.getBottomEndCorner();
|
686
|
+
_this5.rangeData = instance.getData(topStartCorner.row, topStartCorner.col, bottomEndCorner.row, bottomEndCorner.col);
|
687
|
+
return _this5;
|
675
688
|
}
|
676
689
|
_createClass(MergeCellsAction, [{
|
677
690
|
key: "undo",
|
@@ -703,11 +716,11 @@ var UnmergeCellsAction = /*#__PURE__*/function (_UndoRedo$Action2) {
|
|
703
716
|
_inherits(UnmergeCellsAction, _UndoRedo$Action2);
|
704
717
|
var _super2 = _createSuper(UnmergeCellsAction);
|
705
718
|
function UnmergeCellsAction(instance, cellRange) {
|
706
|
-
var
|
719
|
+
var _this6;
|
707
720
|
_classCallCheck(this, UnmergeCellsAction);
|
708
|
-
|
709
|
-
|
710
|
-
return
|
721
|
+
_this6 = _super2.call(this);
|
722
|
+
_this6.cellRange = cellRange;
|
723
|
+
return _this6;
|
711
724
|
}
|
712
725
|
_createClass(UnmergeCellsAction, [{
|
713
726
|
key: "undo",
|
@@ -744,14 +757,14 @@ UndoRedo.RowMoveAction = function (rows, finalIndex) {
|
|
744
757
|
};
|
745
758
|
(0, _object.inherit)(UndoRedo.RowMoveAction, UndoRedo.Action);
|
746
759
|
UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
|
747
|
-
var
|
760
|
+
var _this7 = this;
|
748
761
|
var manualRowMove = instance.getPlugin('manualRowMove');
|
749
762
|
var copyOfRows = [].concat(this.rows);
|
750
763
|
var rowsMovedUp = copyOfRows.filter(function (a) {
|
751
|
-
return a >
|
764
|
+
return a > _this7.finalIndex;
|
752
765
|
});
|
753
766
|
var rowsMovedDown = copyOfRows.filter(function (a) {
|
754
|
-
return a <=
|
767
|
+
return a <= _this7.finalIndex;
|
755
768
|
});
|
756
769
|
var allMovedRows = rowsMovedUp.sort(function (a, b) {
|
757
770
|
return b - a;
|
@@ -803,7 +816,7 @@ UndoRedo.prototype.init = function () {
|
|
803
816
|
* @private
|
804
817
|
*/
|
805
818
|
UndoRedo.prototype.registerShortcuts = function () {
|
806
|
-
var
|
819
|
+
var _this8 = this;
|
807
820
|
var shortcutManager = this.instance.getShortcutManager();
|
808
821
|
var gridContext = shortcutManager.getContext('grid');
|
809
822
|
var runOnlyIf = function runOnlyIf(event) {
|
@@ -817,12 +830,12 @@ UndoRedo.prototype.registerShortcuts = function () {
|
|
817
830
|
gridContext.addShortcuts([{
|
818
831
|
keys: [['Control/Meta', 'z']],
|
819
832
|
callback: function callback() {
|
820
|
-
|
833
|
+
_this8.undo();
|
821
834
|
}
|
822
835
|
}, {
|
823
836
|
keys: [['Control/Meta', 'y'], ['Control/Meta', 'Shift', 'z']],
|
824
837
|
callback: function callback() {
|
825
|
-
|
838
|
+
_this8.redo();
|
826
839
|
}
|
827
840
|
}], config);
|
828
841
|
};
|
@@ -24,6 +24,8 @@ import "core-js/modules/es.object.to-string.js";
|
|
24
24
|
import "core-js/modules/es.array.reduce.js";
|
25
25
|
import "core-js/modules/es.array.slice.js";
|
26
26
|
import "core-js/modules/es.array.splice.js";
|
27
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
28
|
+
import "core-js/modules/es.object.keys.js";
|
27
29
|
import "core-js/modules/es.array.sort.js";
|
28
30
|
import "core-js/modules/es.array.index-of.js";
|
29
31
|
import "core-js/modules/es.array.filter.js";
|
@@ -103,11 +105,9 @@ function UndoRedo(instance) {
|
|
103
105
|
});
|
104
106
|
instance.addHook('beforeRemoveRow', function (index, amount, logicRows, source) {
|
105
107
|
var wrappedAction = function wrappedAction() {
|
106
|
-
var
|
107
|
-
var
|
108
|
-
|
109
|
-
var removedData = deepClone(originalData.slice(physicalRowIndex, physicalRowIndex + amount));
|
110
|
-
return new UndoRedo.RemoveRowAction(rowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop);
|
108
|
+
var physicalRowIndex = instance.toPhysicalRow(index);
|
109
|
+
var removedData = deepClone(plugin.instance.getSourceData(physicalRowIndex, 0, physicalRowIndex + amount - 1, plugin.instance.countSourceCols() - 1));
|
110
|
+
return new UndoRedo.RemoveRowAction(physicalRowIndex, removedData, instance.getSettings().fixedRowsBottom, instance.getSettings().fixedRowsTop, instance.rowIndexMapper.getIndexesSequence());
|
111
111
|
};
|
112
112
|
plugin.done(wrappedAction, source);
|
113
113
|
});
|
@@ -471,24 +471,37 @@ UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
|
|
471
471
|
* @param {Array} data The removed data.
|
472
472
|
* @param {number} fixedRowsBottom Number of fixed rows on the bottom. Remove row action change it sometimes.
|
473
473
|
* @param {number} fixedRowsTop Number of fixed rows on the top. Remove row action change it sometimes.
|
474
|
+
* @param {Array} rowIndexesSequence Row index sequence taken from the row index mapper.
|
474
475
|
*/
|
475
|
-
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop) {
|
476
|
+
UndoRedo.RemoveRowAction = function (index, data, fixedRowsBottom, fixedRowsTop, rowIndexesSequence) {
|
476
477
|
this.index = index;
|
477
478
|
this.data = data;
|
478
479
|
this.actionType = 'remove_row';
|
479
480
|
this.fixedRowsBottom = fixedRowsBottom;
|
480
481
|
this.fixedRowsTop = fixedRowsTop;
|
482
|
+
this.rowIndexesSequence = rowIndexesSequence;
|
481
483
|
};
|
482
484
|
inherit(UndoRedo.RemoveRowAction, UndoRedo.Action);
|
483
485
|
UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
|
486
|
+
var _this2 = this;
|
484
487
|
var settings = instance.getSettings();
|
488
|
+
var changes = [];
|
485
489
|
|
486
490
|
// Changing by the reference as `updateSettings` doesn't work the best.
|
487
491
|
settings.fixedRowsBottom = this.fixedRowsBottom;
|
488
492
|
settings.fixedRowsTop = this.fixedRowsTop;
|
493
|
+
|
494
|
+
// Prepare the change list to fill the source data.
|
495
|
+
this.data.forEach(function (dataRow, rowIndexDelta) {
|
496
|
+
Object.keys(dataRow).forEach(function (columnProp) {
|
497
|
+
var columnIndex = parseInt(columnProp, 10);
|
498
|
+
changes.push([_this2.index + rowIndexDelta, isNaN(columnIndex) ? columnProp : columnIndex, dataRow[columnProp]]);
|
499
|
+
});
|
500
|
+
});
|
489
501
|
instance.alter('insert_row_above', this.index, this.data.length, 'UndoRedo.undo');
|
490
502
|
instance.addHookOnce('afterViewRender', undoneCallback);
|
491
|
-
instance.
|
503
|
+
instance.setSourceDataAtCell(changes, null, null, 'UndoRedo.undo');
|
504
|
+
instance.rowIndexMapper.setIndexesSequence(this.rowIndexesSequence);
|
492
505
|
};
|
493
506
|
UndoRedo.RemoveRowAction.prototype.redo = function (instance, redoneCallback) {
|
494
507
|
instance.addHookOnce('afterRemoveRow', redoneCallback);
|
@@ -543,14 +556,14 @@ UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPos
|
|
543
556
|
};
|
544
557
|
inherit(UndoRedo.RemoveColumnAction, UndoRedo.Action);
|
545
558
|
UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
|
546
|
-
var
|
559
|
+
var _this3 = this;
|
547
560
|
var settings = instance.getSettings();
|
548
561
|
|
549
562
|
// Changing by the reference as `updateSettings` doesn't work the best.
|
550
563
|
settings.fixedColumnsStart = this.fixedColumnsStart;
|
551
564
|
var ascendingIndexes = this.indexes.slice(0).sort();
|
552
565
|
var sortByIndexes = function sortByIndexes(elem, j, arr) {
|
553
|
-
return arr[
|
566
|
+
return arr[_this3.indexes.indexOf(ascendingIndexes[j])];
|
554
567
|
};
|
555
568
|
var removedDataLength = this.data.length;
|
556
569
|
var sortedData = [];
|
@@ -576,8 +589,8 @@ UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback)
|
|
576
589
|
instance.batchExecution(function () {
|
577
590
|
// Restore row sequence in a case when all columns are removed. the original
|
578
591
|
// row sequence is lost in that case.
|
579
|
-
instance.rowIndexMapper.setIndexesSequence(
|
580
|
-
instance.columnIndexMapper.setIndexesSequence(
|
592
|
+
instance.rowIndexMapper.setIndexesSequence(_this3.rowPositions);
|
593
|
+
instance.columnIndexMapper.setIndexesSequence(_this3.columnPositions);
|
581
594
|
}, true);
|
582
595
|
instance.addHookOnce('afterViewRender', undoneCallback);
|
583
596
|
instance.render();
|
@@ -603,12 +616,12 @@ UndoRedo.CellAlignmentAction = function (stateBefore, range, type, alignment) {
|
|
603
616
|
this.alignment = alignment;
|
604
617
|
};
|
605
618
|
UndoRedo.CellAlignmentAction.prototype.undo = function (instance, undoneCallback) {
|
606
|
-
var
|
619
|
+
var _this4 = this;
|
607
620
|
arrayEach(this.range, function (range) {
|
608
621
|
range.forAll(function (row, col) {
|
609
622
|
// Alignment classes should only collected within cell ranges. We skip header coordinates.
|
610
623
|
if (row >= 0 && col >= 0) {
|
611
|
-
instance.setCellMeta(row, col, 'className',
|
624
|
+
instance.setCellMeta(row, col, 'className', _this4.stateBefore[row][col] || ' htLeft');
|
612
625
|
}
|
613
626
|
});
|
614
627
|
});
|
@@ -658,14 +671,14 @@ var MergeCellsAction = /*#__PURE__*/function (_UndoRedo$Action) {
|
|
658
671
|
_inherits(MergeCellsAction, _UndoRedo$Action);
|
659
672
|
var _super = _createSuper(MergeCellsAction);
|
660
673
|
function MergeCellsAction(instance, cellRange) {
|
661
|
-
var
|
674
|
+
var _this5;
|
662
675
|
_classCallCheck(this, MergeCellsAction);
|
663
|
-
|
664
|
-
|
665
|
-
var topStartCorner =
|
666
|
-
var bottomEndCorner =
|
667
|
-
|
668
|
-
return
|
676
|
+
_this5 = _super.call(this);
|
677
|
+
_this5.cellRange = cellRange;
|
678
|
+
var topStartCorner = _this5.cellRange.getTopStartCorner();
|
679
|
+
var bottomEndCorner = _this5.cellRange.getBottomEndCorner();
|
680
|
+
_this5.rangeData = instance.getData(topStartCorner.row, topStartCorner.col, bottomEndCorner.row, bottomEndCorner.col);
|
681
|
+
return _this5;
|
669
682
|
}
|
670
683
|
_createClass(MergeCellsAction, [{
|
671
684
|
key: "undo",
|
@@ -697,11 +710,11 @@ var UnmergeCellsAction = /*#__PURE__*/function (_UndoRedo$Action2) {
|
|
697
710
|
_inherits(UnmergeCellsAction, _UndoRedo$Action2);
|
698
711
|
var _super2 = _createSuper(UnmergeCellsAction);
|
699
712
|
function UnmergeCellsAction(instance, cellRange) {
|
700
|
-
var
|
713
|
+
var _this6;
|
701
714
|
_classCallCheck(this, UnmergeCellsAction);
|
702
|
-
|
703
|
-
|
704
|
-
return
|
715
|
+
_this6 = _super2.call(this);
|
716
|
+
_this6.cellRange = cellRange;
|
717
|
+
return _this6;
|
705
718
|
}
|
706
719
|
_createClass(UnmergeCellsAction, [{
|
707
720
|
key: "undo",
|
@@ -738,14 +751,14 @@ UndoRedo.RowMoveAction = function (rows, finalIndex) {
|
|
738
751
|
};
|
739
752
|
inherit(UndoRedo.RowMoveAction, UndoRedo.Action);
|
740
753
|
UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
|
741
|
-
var
|
754
|
+
var _this7 = this;
|
742
755
|
var manualRowMove = instance.getPlugin('manualRowMove');
|
743
756
|
var copyOfRows = [].concat(this.rows);
|
744
757
|
var rowsMovedUp = copyOfRows.filter(function (a) {
|
745
|
-
return a >
|
758
|
+
return a > _this7.finalIndex;
|
746
759
|
});
|
747
760
|
var rowsMovedDown = copyOfRows.filter(function (a) {
|
748
|
-
return a <=
|
761
|
+
return a <= _this7.finalIndex;
|
749
762
|
});
|
750
763
|
var allMovedRows = rowsMovedUp.sort(function (a, b) {
|
751
764
|
return b - a;
|
@@ -797,7 +810,7 @@ UndoRedo.prototype.init = function () {
|
|
797
810
|
* @private
|
798
811
|
*/
|
799
812
|
UndoRedo.prototype.registerShortcuts = function () {
|
800
|
-
var
|
813
|
+
var _this8 = this;
|
801
814
|
var shortcutManager = this.instance.getShortcutManager();
|
802
815
|
var gridContext = shortcutManager.getContext('grid');
|
803
816
|
var runOnlyIf = function runOnlyIf(event) {
|
@@ -811,12 +824,12 @@ UndoRedo.prototype.registerShortcuts = function () {
|
|
811
824
|
gridContext.addShortcuts([{
|
812
825
|
keys: [['Control/Meta', 'z']],
|
813
826
|
callback: function callback() {
|
814
|
-
|
827
|
+
_this8.undo();
|
815
828
|
}
|
816
829
|
}, {
|
817
830
|
keys: [['Control/Meta', 'y'], ['Control/Meta', 'Shift', 'z']],
|
818
831
|
callback: function callback() {
|
819
|
-
|
832
|
+
_this8.redo();
|
820
833
|
}
|
821
834
|
}], config);
|
822
835
|
};
|