handsontable 15.0.1-next-ab94a4c-20250207 → 15.1.0-next-5e493ee-20250207
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.
- package/3rdparty/walkontable/src/index.js +2 -0
- package/3rdparty/walkontable/src/index.mjs +2 -1
- package/3rdparty/walkontable/src/overlays.js +2 -39
- package/3rdparty/walkontable/src/overlays.mjs +2 -39
- package/3rdparty/walkontable/src/renderer/_base.js +3 -4
- package/3rdparty/walkontable/src/renderer/_base.mjs +2 -2
- package/3rdparty/walkontable/src/renderer/cells.js +7 -11
- package/3rdparty/walkontable/src/renderer/cells.mjs +6 -9
- package/3rdparty/walkontable/src/renderer/colGroup.js +6 -7
- package/3rdparty/walkontable/src/renderer/colGroup.mjs +5 -5
- package/3rdparty/walkontable/src/renderer/columnHeaders.js +4 -5
- package/3rdparty/walkontable/src/renderer/columnHeaders.mjs +3 -3
- package/3rdparty/walkontable/src/renderer/index.js +18 -19
- package/3rdparty/walkontable/src/renderer/index.mjs +6 -6
- package/3rdparty/walkontable/src/renderer/rowHeaders.js +6 -7
- package/3rdparty/walkontable/src/renderer/rowHeaders.mjs +5 -5
- package/3rdparty/walkontable/src/renderer/rows.js +23 -11
- package/3rdparty/walkontable/src/renderer/rows.mjs +23 -10
- package/3rdparty/walkontable/src/renderer/table.js +1 -1
- package/3rdparty/walkontable/src/renderer/table.mjs +1 -1
- package/3rdparty/walkontable/src/selection/border/border.js +10 -2
- package/3rdparty/walkontable/src/selection/border/border.mjs +10 -2
- package/3rdparty/walkontable/src/utils/nodesPool.js +21 -6
- package/3rdparty/walkontable/src/utils/nodesPool.mjs +21 -6
- package/3rdparty/walkontable/src/utils/orderView/index.js +4 -5
- package/3rdparty/walkontable/src/utils/orderView/index.mjs +2 -2
- package/3rdparty/walkontable/src/utils/orderView/sharedView.js +3 -4
- package/3rdparty/walkontable/src/utils/orderView/sharedView.mjs +2 -2
- package/3rdparty/walkontable/src/utils/orderView/view.js +60 -76
- package/3rdparty/walkontable/src/utils/orderView/view.mjs +59 -74
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.js +138 -0
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.mjs +135 -0
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.js +72 -0
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.mjs +68 -0
- package/3rdparty/walkontable/src/utils/orderView/viewSize.js +1 -1
- package/3rdparty/walkontable/src/utils/orderView/viewSize.mjs +1 -1
- package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.js +4 -5
- package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.mjs +3 -3
- package/CHANGELOG.md +48 -2
- package/README.md +3 -3
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/cellTypes/dropdownType/dropdownType.js +4 -2
- package/cellTypes/dropdownType/dropdownType.mjs +4 -2
- package/core.js +39 -38
- package/core.mjs +36 -35
- package/dataMap/dataMap.js +8 -0
- package/dataMap/dataMap.mjs +8 -0
- package/dataMap/dataSource.js +4 -0
- package/dataMap/dataSource.mjs +4 -0
- package/dataMap/metaManager/lazyFactoryMap.js +8 -5
- package/dataMap/metaManager/lazyFactoryMap.mjs +8 -5
- package/dataMap/metaManager/metaSchema.js +24 -9
- package/dataMap/metaManager/metaSchema.mjs +24 -9
- package/dist/handsontable.css +6 -2
- package/dist/handsontable.full.css +6 -2
- package/dist/handsontable.full.js +8026 -6927
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +530 -528
- package/dist/handsontable.js +3833 -2914
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +35 -33
- package/editors/autocompleteEditor/autocompleteEditor.js +1 -3
- package/editors/autocompleteEditor/autocompleteEditor.mjs +1 -3
- package/editors/dateEditor/dateEditor.js +4 -0
- package/editors/dateEditor/dateEditor.mjs +4 -0
- package/editors/dropdownEditor/dropdownEditor.js +3 -16
- package/editors/dropdownEditor/dropdownEditor.mjs +3 -16
- package/editors/handsontableEditor/handsontableEditor.js +4 -4
- package/editors/handsontableEditor/handsontableEditor.mjs +4 -4
- package/focusManager.js +1 -1
- package/focusManager.mjs +1 -1
- package/helpers/dom/element.d.ts +0 -1
- package/helpers/mixed.js +2 -2
- package/helpers/mixed.mjs +2 -2
- package/helpers/object.js +4 -0
- package/helpers/object.mjs +4 -0
- package/package.json +2 -2
- package/plugins/base/base.js +0 -7
- package/plugins/base/base.mjs +0 -7
- package/plugins/comments/comments.js +12 -3
- package/plugins/comments/comments.mjs +12 -3
- package/plugins/contextMenu/contextMenu.js +2 -7
- package/plugins/contextMenu/contextMenu.mjs +2 -7
- package/plugins/contextMenu/menu/menu.js +2 -2
- package/plugins/contextMenu/menu/menu.mjs +2 -2
- package/plugins/contextMenu/predefinedItems/clearColumn.js +15 -4
- package/plugins/contextMenu/predefinedItems/clearColumn.mjs +15 -4
- package/plugins/copyPaste/copyPaste.js +6 -12
- package/plugins/copyPaste/copyPaste.mjs +6 -12
- package/plugins/filters/conditionCollection.js +8 -7
- package/plugins/filters/conditionCollection.mjs +8 -7
- package/plugins/filters/filters.js +26 -16
- package/plugins/filters/filters.mjs +26 -16
- package/plugins/filters/utils.js +7 -24
- package/plugins/filters/utils.mjs +7 -24
- package/plugins/hiddenColumns/hiddenColumns.js +1 -3
- package/plugins/hiddenColumns/hiddenColumns.mjs +1 -3
- package/plugins/hiddenRows/hiddenRows.js +1 -3
- package/plugins/hiddenRows/hiddenRows.mjs +1 -3
- package/plugins/manualRowMove/manualRowMove.js +1 -1
- package/plugins/manualRowMove/manualRowMove.mjs +1 -1
- package/plugins/mergeCells/calculations/autofill.js +60 -44
- package/plugins/mergeCells/calculations/autofill.mjs +60 -44
- package/plugins/mergeCells/cellsCollection.js +25 -8
- package/plugins/mergeCells/cellsCollection.mjs +25 -8
- package/plugins/mergeCells/mergeCells.js +15 -16
- package/plugins/mergeCells/mergeCells.mjs +15 -16
- package/plugins/nestedHeaders/nestedHeaders.js +6 -1
- package/plugins/nestedHeaders/nestedHeaders.mjs +6 -1
- package/plugins/nestedHeaders/stateManager/index.js +1 -2
- package/plugins/nestedHeaders/stateManager/index.mjs +1 -2
- package/plugins/nestedHeaders/utils/ghostTable.js +4 -0
- package/plugins/nestedHeaders/utils/ghostTable.mjs +4 -0
- package/plugins/nestedRows/utils/rowMoveController.js +1 -6
- package/plugins/nestedRows/utils/rowMoveController.mjs +1 -6
- package/plugins/undoRedo/actions/_base.js +19 -0
- package/plugins/undoRedo/actions/_base.mjs +15 -0
- package/plugins/undoRedo/actions/cellAlignment.js +85 -0
- package/plugins/undoRedo/actions/cellAlignment.mjs +81 -0
- package/plugins/undoRedo/actions/columnMove.js +84 -0
- package/plugins/undoRedo/actions/columnMove.mjs +80 -0
- package/plugins/undoRedo/actions/columnSort.js +73 -0
- package/plugins/undoRedo/actions/columnSort.mjs +69 -0
- package/plugins/undoRedo/actions/createColumn.js +60 -0
- package/plugins/undoRedo/actions/createColumn.mjs +56 -0
- package/plugins/undoRedo/actions/createRow.js +65 -0
- package/plugins/undoRedo/actions/createRow.mjs +61 -0
- package/plugins/undoRedo/actions/dataChange.js +123 -0
- package/plugins/undoRedo/actions/dataChange.mjs +119 -0
- package/plugins/undoRedo/actions/filters.js +66 -0
- package/plugins/undoRedo/actions/filters.mjs +62 -0
- package/plugins/undoRedo/actions/index.js +27 -0
- package/plugins/undoRedo/actions/index.mjs +23 -0
- package/plugins/undoRedo/actions/mergeCells.js +63 -0
- package/plugins/undoRedo/actions/mergeCells.mjs +59 -0
- package/plugins/undoRedo/actions/removeColumn.js +176 -0
- package/plugins/undoRedo/actions/removeColumn.mjs +172 -0
- package/plugins/undoRedo/actions/removeRow.js +119 -0
- package/plugins/undoRedo/actions/removeRow.mjs +115 -0
- package/plugins/undoRedo/actions/rowMove.js +84 -0
- package/plugins/undoRedo/actions/rowMove.mjs +80 -0
- package/plugins/undoRedo/actions/unmergeCells.js +56 -0
- package/plugins/undoRedo/actions/unmergeCells.mjs +52 -0
- package/plugins/undoRedo/index.js +3 -4
- package/plugins/undoRedo/index.mjs +1 -2
- package/plugins/undoRedo/undoRedo.js +277 -879
- package/plugins/undoRedo/undoRedo.mjs +277 -880
- package/plugins/undoRedo/utils.js +37 -0
- package/plugins/undoRedo/utils.mjs +33 -0
- package/renderers/checkboxRenderer/checkboxRenderer.js +8 -1
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +8 -1
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +1 -0
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +1 -0
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +2 -1
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +2 -1
- package/styles/handsontable.css +75 -103
- package/styles/handsontable.min.css +3 -3
- package/styles/ht-theme-horizon.css +2 -2
- package/styles/ht-theme-horizon.min.css +2 -2
- package/styles/ht-theme-main.css +2 -2
- package/styles/ht-theme-main.min.css +2 -2
- package/tableView.js +17 -1
- package/tableView.mjs +17 -1
- package/utils/autoResize.js +1 -1
- package/utils/autoResize.mjs +1 -1
- package/utils/parseTable.js +1 -1
- package/utils/parseTable.mjs +1 -1
- package/validators/dateValidator/dateValidator.js +1 -1
- package/validators/dateValidator/dateValidator.mjs +1 -1
@@ -0,0 +1,73 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
5
|
+
var _base = require("./_base");
|
6
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
8
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
9
|
+
/**
|
10
|
+
* Action that tracks column sort changes.
|
11
|
+
*
|
12
|
+
* @class ColumnSortAction
|
13
|
+
* @private
|
14
|
+
*/
|
15
|
+
class ColumnSortAction extends _base.BaseAction {
|
16
|
+
constructor(_ref) {
|
17
|
+
let {
|
18
|
+
currentSortState,
|
19
|
+
newSortState
|
20
|
+
} = _ref;
|
21
|
+
super();
|
22
|
+
/**
|
23
|
+
* @param {Array} currentSortState The current sort state.
|
24
|
+
*/
|
25
|
+
_defineProperty(this, "previousSortState", void 0);
|
26
|
+
/**
|
27
|
+
* @param {Array} newSortState The new sort state.
|
28
|
+
*/
|
29
|
+
_defineProperty(this, "nextSortState", void 0);
|
30
|
+
this.previousSortState = currentSortState;
|
31
|
+
this.nextSortState = newSortState;
|
32
|
+
}
|
33
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
34
|
+
hot.addHook('beforeColumnSort', (currentSortState, newSortState, sortPossible) => {
|
35
|
+
if (!sortPossible) {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
undoRedoPlugin.done(() => new ColumnSortAction({
|
39
|
+
currentSortState,
|
40
|
+
newSortState
|
41
|
+
}));
|
42
|
+
});
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* @param {Core} hot The Handsontable instance.
|
47
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
48
|
+
*/
|
49
|
+
undo(hot, undoneCallback) {
|
50
|
+
const sortPlugin = hot.getPlugin('columnSorting');
|
51
|
+
const multiSortPlugin = hot.getPlugin('multiColumnSorting');
|
52
|
+
const enabledSortPlugin = multiSortPlugin.isEnabled() ? multiSortPlugin : sortPlugin;
|
53
|
+
if (this.previousSortState.length) {
|
54
|
+
enabledSortPlugin.sort(this.previousSortState);
|
55
|
+
} else {
|
56
|
+
enabledSortPlugin.clearSort();
|
57
|
+
}
|
58
|
+
undoneCallback();
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @param {Core} hot The Handsontable instance.
|
63
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
64
|
+
*/
|
65
|
+
redo(hot, redoneCallback) {
|
66
|
+
const sortPlugin = hot.getPlugin('columnSorting');
|
67
|
+
const multiSortPlugin = hot.getPlugin('multiColumnSorting');
|
68
|
+
const enabledSortPlugin = multiSortPlugin.isEnabled() ? multiSortPlugin : sortPlugin;
|
69
|
+
enabledSortPlugin.sort(this.nextSortState);
|
70
|
+
redoneCallback();
|
71
|
+
}
|
72
|
+
}
|
73
|
+
exports.ColumnSortAction = ColumnSortAction;
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import "core-js/modules/es.error.cause.js";
|
2
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
4
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
5
|
+
import { BaseAction } from "./_base.mjs";
|
6
|
+
/**
|
7
|
+
* Action that tracks column sort changes.
|
8
|
+
*
|
9
|
+
* @class ColumnSortAction
|
10
|
+
* @private
|
11
|
+
*/
|
12
|
+
export class ColumnSortAction extends BaseAction {
|
13
|
+
constructor(_ref) {
|
14
|
+
let {
|
15
|
+
currentSortState,
|
16
|
+
newSortState
|
17
|
+
} = _ref;
|
18
|
+
super();
|
19
|
+
/**
|
20
|
+
* @param {Array} currentSortState The current sort state.
|
21
|
+
*/
|
22
|
+
_defineProperty(this, "previousSortState", void 0);
|
23
|
+
/**
|
24
|
+
* @param {Array} newSortState The new sort state.
|
25
|
+
*/
|
26
|
+
_defineProperty(this, "nextSortState", void 0);
|
27
|
+
this.previousSortState = currentSortState;
|
28
|
+
this.nextSortState = newSortState;
|
29
|
+
}
|
30
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
31
|
+
hot.addHook('beforeColumnSort', (currentSortState, newSortState, sortPossible) => {
|
32
|
+
if (!sortPossible) {
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
undoRedoPlugin.done(() => new ColumnSortAction({
|
36
|
+
currentSortState,
|
37
|
+
newSortState
|
38
|
+
}));
|
39
|
+
});
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* @param {Core} hot The Handsontable instance.
|
44
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
45
|
+
*/
|
46
|
+
undo(hot, undoneCallback) {
|
47
|
+
const sortPlugin = hot.getPlugin('columnSorting');
|
48
|
+
const multiSortPlugin = hot.getPlugin('multiColumnSorting');
|
49
|
+
const enabledSortPlugin = multiSortPlugin.isEnabled() ? multiSortPlugin : sortPlugin;
|
50
|
+
if (this.previousSortState.length) {
|
51
|
+
enabledSortPlugin.sort(this.previousSortState);
|
52
|
+
} else {
|
53
|
+
enabledSortPlugin.clearSort();
|
54
|
+
}
|
55
|
+
undoneCallback();
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* @param {Core} hot The Handsontable instance.
|
60
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
61
|
+
*/
|
62
|
+
redo(hot, redoneCallback) {
|
63
|
+
const sortPlugin = hot.getPlugin('columnSorting');
|
64
|
+
const multiSortPlugin = hot.getPlugin('multiColumnSorting');
|
65
|
+
const enabledSortPlugin = multiSortPlugin.isEnabled() ? multiSortPlugin : sortPlugin;
|
66
|
+
enabledSortPlugin.sort(this.nextSortState);
|
67
|
+
redoneCallback();
|
68
|
+
}
|
69
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
5
|
+
var _base = require("./_base");
|
6
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
8
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
9
|
+
/**
|
10
|
+
* Action that tracks column creation.
|
11
|
+
*
|
12
|
+
* @class CreateColumnAction
|
13
|
+
* @private
|
14
|
+
*/
|
15
|
+
class CreateColumnAction extends _base.BaseAction {
|
16
|
+
constructor(_ref) {
|
17
|
+
let {
|
18
|
+
index,
|
19
|
+
amount
|
20
|
+
} = _ref;
|
21
|
+
super();
|
22
|
+
/**
|
23
|
+
* @param {number} index The visual column index.
|
24
|
+
*/
|
25
|
+
_defineProperty(this, "index", void 0);
|
26
|
+
/**
|
27
|
+
* @param {number} amount The number of created columns.
|
28
|
+
*/
|
29
|
+
_defineProperty(this, "amount", void 0);
|
30
|
+
this.index = index;
|
31
|
+
this.amount = amount;
|
32
|
+
}
|
33
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
34
|
+
hot.addHook('afterCreateCol', (index, amount, source) => {
|
35
|
+
undoRedoPlugin.done(() => new CreateColumnAction({
|
36
|
+
index,
|
37
|
+
amount
|
38
|
+
}), source);
|
39
|
+
});
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* @param {Core} hot The Handsontable instance.
|
44
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
45
|
+
*/
|
46
|
+
undo(hot, undoneCallback) {
|
47
|
+
hot.addHookOnce('afterRemoveCol', undoneCallback);
|
48
|
+
hot.alter('remove_col', this.index, this.amount, 'UndoRedo.undo');
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* @param {Core} hot The Handsontable instance.
|
53
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
54
|
+
*/
|
55
|
+
redo(hot, redoneCallback) {
|
56
|
+
hot.addHookOnce('afterCreateCol', redoneCallback);
|
57
|
+
hot.alter('insert_col_start', this.index, this.amount, 'UndoRedo.redo');
|
58
|
+
}
|
59
|
+
}
|
60
|
+
exports.CreateColumnAction = CreateColumnAction;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import "core-js/modules/es.error.cause.js";
|
2
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
4
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
5
|
+
import { BaseAction } from "./_base.mjs";
|
6
|
+
/**
|
7
|
+
* Action that tracks column creation.
|
8
|
+
*
|
9
|
+
* @class CreateColumnAction
|
10
|
+
* @private
|
11
|
+
*/
|
12
|
+
export class CreateColumnAction extends BaseAction {
|
13
|
+
constructor(_ref) {
|
14
|
+
let {
|
15
|
+
index,
|
16
|
+
amount
|
17
|
+
} = _ref;
|
18
|
+
super();
|
19
|
+
/**
|
20
|
+
* @param {number} index The visual column index.
|
21
|
+
*/
|
22
|
+
_defineProperty(this, "index", void 0);
|
23
|
+
/**
|
24
|
+
* @param {number} amount The number of created columns.
|
25
|
+
*/
|
26
|
+
_defineProperty(this, "amount", void 0);
|
27
|
+
this.index = index;
|
28
|
+
this.amount = amount;
|
29
|
+
}
|
30
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
31
|
+
hot.addHook('afterCreateCol', (index, amount, source) => {
|
32
|
+
undoRedoPlugin.done(() => new CreateColumnAction({
|
33
|
+
index,
|
34
|
+
amount
|
35
|
+
}), source);
|
36
|
+
});
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* @param {Core} hot The Handsontable instance.
|
41
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
42
|
+
*/
|
43
|
+
undo(hot, undoneCallback) {
|
44
|
+
hot.addHookOnce('afterRemoveCol', undoneCallback);
|
45
|
+
hot.alter('remove_col', this.index, this.amount, 'UndoRedo.undo');
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @param {Core} hot The Handsontable instance.
|
50
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
51
|
+
*/
|
52
|
+
redo(hot, redoneCallback) {
|
53
|
+
hot.addHookOnce('afterCreateCol', redoneCallback);
|
54
|
+
hot.alter('insert_col_start', this.index, this.amount, 'UndoRedo.redo');
|
55
|
+
}
|
56
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
5
|
+
var _base = require("./_base");
|
6
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
8
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
9
|
+
/**
|
10
|
+
* Action that tracks row creation.
|
11
|
+
*
|
12
|
+
* @class CreateRowAction
|
13
|
+
* @private
|
14
|
+
*/
|
15
|
+
class CreateRowAction extends _base.BaseAction {
|
16
|
+
constructor(_ref) {
|
17
|
+
let {
|
18
|
+
index,
|
19
|
+
amount
|
20
|
+
} = _ref;
|
21
|
+
super();
|
22
|
+
/**
|
23
|
+
* @param {number} index The visual row index.
|
24
|
+
*/
|
25
|
+
_defineProperty(this, "index", void 0);
|
26
|
+
/**
|
27
|
+
* @param {number} amount The number of created rows.
|
28
|
+
*/
|
29
|
+
_defineProperty(this, "amount", void 0);
|
30
|
+
this.index = index;
|
31
|
+
this.amount = amount;
|
32
|
+
}
|
33
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
34
|
+
hot.addHook('afterCreateRow', (index, amount, source) => {
|
35
|
+
undoRedoPlugin.done(() => new CreateRowAction({
|
36
|
+
index,
|
37
|
+
amount
|
38
|
+
}), source);
|
39
|
+
});
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* @param {Core} hot The Handsontable instance.
|
44
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
45
|
+
*/
|
46
|
+
undo(hot, undoneCallback) {
|
47
|
+
const rowCount = hot.countRows();
|
48
|
+
const minSpareRows = hot.getSettings().minSpareRows;
|
49
|
+
if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
|
50
|
+
this.index -= minSpareRows; // work around the situation where the needed row was removed due to an 'undo' of a made change
|
51
|
+
}
|
52
|
+
hot.addHookOnce('afterRemoveRow', undoneCallback);
|
53
|
+
hot.alter('remove_row', this.index, this.amount, 'UndoRedo.undo');
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* @param {Core} hot The Handsontable instance.
|
58
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
59
|
+
*/
|
60
|
+
redo(hot, redoneCallback) {
|
61
|
+
hot.addHookOnce('afterCreateRow', redoneCallback);
|
62
|
+
hot.alter('insert_row_above', this.index, this.amount, 'UndoRedo.redo');
|
63
|
+
}
|
64
|
+
}
|
65
|
+
exports.CreateRowAction = CreateRowAction;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import "core-js/modules/es.error.cause.js";
|
2
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
4
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
5
|
+
import { BaseAction } from "./_base.mjs";
|
6
|
+
/**
|
7
|
+
* Action that tracks row creation.
|
8
|
+
*
|
9
|
+
* @class CreateRowAction
|
10
|
+
* @private
|
11
|
+
*/
|
12
|
+
export class CreateRowAction extends BaseAction {
|
13
|
+
constructor(_ref) {
|
14
|
+
let {
|
15
|
+
index,
|
16
|
+
amount
|
17
|
+
} = _ref;
|
18
|
+
super();
|
19
|
+
/**
|
20
|
+
* @param {number} index The visual row index.
|
21
|
+
*/
|
22
|
+
_defineProperty(this, "index", void 0);
|
23
|
+
/**
|
24
|
+
* @param {number} amount The number of created rows.
|
25
|
+
*/
|
26
|
+
_defineProperty(this, "amount", void 0);
|
27
|
+
this.index = index;
|
28
|
+
this.amount = amount;
|
29
|
+
}
|
30
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
31
|
+
hot.addHook('afterCreateRow', (index, amount, source) => {
|
32
|
+
undoRedoPlugin.done(() => new CreateRowAction({
|
33
|
+
index,
|
34
|
+
amount
|
35
|
+
}), source);
|
36
|
+
});
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* @param {Core} hot The Handsontable instance.
|
41
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
42
|
+
*/
|
43
|
+
undo(hot, undoneCallback) {
|
44
|
+
const rowCount = hot.countRows();
|
45
|
+
const minSpareRows = hot.getSettings().minSpareRows;
|
46
|
+
if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
|
47
|
+
this.index -= minSpareRows; // work around the situation where the needed row was removed due to an 'undo' of a made change
|
48
|
+
}
|
49
|
+
hot.addHookOnce('afterRemoveRow', undoneCallback);
|
50
|
+
hot.alter('remove_row', this.index, this.amount, 'UndoRedo.undo');
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* @param {Core} hot The Handsontable instance.
|
55
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
56
|
+
*/
|
57
|
+
redo(hot, redoneCallback) {
|
58
|
+
hot.addHookOnce('afterCreateRow', redoneCallback);
|
59
|
+
hot.alter('insert_row_above', this.index, this.amount, 'UndoRedo.redo');
|
60
|
+
}
|
61
|
+
}
|
@@ -0,0 +1,123 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
5
|
+
require("core-js/modules/es.array.push.js");
|
6
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
7
|
+
require("core-js/modules/esnext.iterator.find.js");
|
8
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
9
|
+
require("core-js/modules/esnext.iterator.reduce.js");
|
10
|
+
var _base = require("./_base");
|
11
|
+
var _object = require("../../../helpers/object");
|
12
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
14
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
15
|
+
/**
|
16
|
+
* Action that tracks data changes.
|
17
|
+
*
|
18
|
+
* @class DataChangeAction
|
19
|
+
* @private
|
20
|
+
*/
|
21
|
+
class DataChangeAction extends _base.BaseAction {
|
22
|
+
constructor(_ref) {
|
23
|
+
let {
|
24
|
+
changes,
|
25
|
+
selected,
|
26
|
+
countCols,
|
27
|
+
countRows
|
28
|
+
} = _ref;
|
29
|
+
super();
|
30
|
+
/**
|
31
|
+
* @param {Array} changes 2D array containing information about each of the edited cells.
|
32
|
+
*/
|
33
|
+
_defineProperty(this, "changes", void 0);
|
34
|
+
/**
|
35
|
+
* @param {number[]} selected The cell selection.
|
36
|
+
*/
|
37
|
+
_defineProperty(this, "selected", void 0);
|
38
|
+
/**
|
39
|
+
* @param {number} countCols The number of columns before data change.
|
40
|
+
*/
|
41
|
+
_defineProperty(this, "countCols", void 0);
|
42
|
+
/**
|
43
|
+
* @param {number} countRows The number of rows before data change.
|
44
|
+
*/
|
45
|
+
_defineProperty(this, "countRows", void 0);
|
46
|
+
this.changes = changes;
|
47
|
+
this.selected = selected;
|
48
|
+
this.countCols = countCols;
|
49
|
+
this.countRows = countRows;
|
50
|
+
}
|
51
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
52
|
+
hot.addHook('beforeChange', function (changes, source) {
|
53
|
+
const changesLen = changes && changes.length;
|
54
|
+
if (!changesLen) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
const hasDifferences = changes.find(change => {
|
58
|
+
const [,, oldValue, newValue] = change;
|
59
|
+
return oldValue !== newValue;
|
60
|
+
});
|
61
|
+
if (!hasDifferences) {
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
const wrappedAction = () => {
|
65
|
+
const clonedChanges = changes.reduce((arr, change) => {
|
66
|
+
arr.push([...change]);
|
67
|
+
return arr;
|
68
|
+
}, []);
|
69
|
+
clonedChanges.forEach(change => {
|
70
|
+
change[1] = hot.propToCol(change[1]);
|
71
|
+
});
|
72
|
+
const selected = changesLen > 1 ? this.getSelected() : [[clonedChanges[0][0], clonedChanges[0][1]]];
|
73
|
+
return new DataChangeAction({
|
74
|
+
changes: clonedChanges,
|
75
|
+
selected,
|
76
|
+
countCols: hot.countCols(),
|
77
|
+
countRows: hot.countRows()
|
78
|
+
});
|
79
|
+
};
|
80
|
+
undoRedoPlugin.done(wrappedAction, source);
|
81
|
+
});
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* @param {Core} hot The Handsontable instance.
|
86
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
87
|
+
*/
|
88
|
+
undo(hot, undoneCallback) {
|
89
|
+
const data = (0, _object.deepClone)(this.changes);
|
90
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
91
|
+
data[i].splice(3, 1);
|
92
|
+
}
|
93
|
+
hot.addHookOnce('afterChange', undoneCallback);
|
94
|
+
hot.setDataAtCell(data, null, null, 'UndoRedo.undo');
|
95
|
+
const rowsToRemove = hot.countRows() - this.countRows;
|
96
|
+
if (rowsToRemove > 0) {
|
97
|
+
hot.alter('remove_row', null, rowsToRemove, 'UndoRedo.undo');
|
98
|
+
}
|
99
|
+
const columnsToRemove = hot.countCols() - this.countCols;
|
100
|
+
if (columnsToRemove > 0 && hot.isColumnModificationAllowed()) {
|
101
|
+
hot.alter('remove_col', null, columnsToRemove, 'UndoRedo.undo');
|
102
|
+
}
|
103
|
+
hot.scrollToFocusedCell();
|
104
|
+
hot.selectCells(this.selected, false, false);
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* @param {Core} hot The Handsontable instance.
|
109
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
110
|
+
*/
|
111
|
+
redo(hot, redoneCallback) {
|
112
|
+
const data = (0, _object.deepClone)(this.changes);
|
113
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
114
|
+
data[i].splice(2, 1);
|
115
|
+
}
|
116
|
+
hot.addHookOnce('afterChange', redoneCallback);
|
117
|
+
hot.setDataAtCell(data, null, null, 'UndoRedo.redo');
|
118
|
+
if (this.selected) {
|
119
|
+
hot.selectCells(this.selected, false, false);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
exports.DataChangeAction = DataChangeAction;
|
@@ -0,0 +1,119 @@
|
|
1
|
+
import "core-js/modules/es.error.cause.js";
|
2
|
+
import "core-js/modules/es.array.push.js";
|
3
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
4
|
+
import "core-js/modules/esnext.iterator.find.js";
|
5
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
6
|
+
import "core-js/modules/esnext.iterator.reduce.js";
|
7
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
9
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
10
|
+
import { BaseAction } from "./_base.mjs";
|
11
|
+
import { deepClone } from "../../../helpers/object.mjs";
|
12
|
+
/**
|
13
|
+
* Action that tracks data changes.
|
14
|
+
*
|
15
|
+
* @class DataChangeAction
|
16
|
+
* @private
|
17
|
+
*/
|
18
|
+
export class DataChangeAction extends BaseAction {
|
19
|
+
constructor(_ref) {
|
20
|
+
let {
|
21
|
+
changes,
|
22
|
+
selected,
|
23
|
+
countCols,
|
24
|
+
countRows
|
25
|
+
} = _ref;
|
26
|
+
super();
|
27
|
+
/**
|
28
|
+
* @param {Array} changes 2D array containing information about each of the edited cells.
|
29
|
+
*/
|
30
|
+
_defineProperty(this, "changes", void 0);
|
31
|
+
/**
|
32
|
+
* @param {number[]} selected The cell selection.
|
33
|
+
*/
|
34
|
+
_defineProperty(this, "selected", void 0);
|
35
|
+
/**
|
36
|
+
* @param {number} countCols The number of columns before data change.
|
37
|
+
*/
|
38
|
+
_defineProperty(this, "countCols", void 0);
|
39
|
+
/**
|
40
|
+
* @param {number} countRows The number of rows before data change.
|
41
|
+
*/
|
42
|
+
_defineProperty(this, "countRows", void 0);
|
43
|
+
this.changes = changes;
|
44
|
+
this.selected = selected;
|
45
|
+
this.countCols = countCols;
|
46
|
+
this.countRows = countRows;
|
47
|
+
}
|
48
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
49
|
+
hot.addHook('beforeChange', function (changes, source) {
|
50
|
+
const changesLen = changes && changes.length;
|
51
|
+
if (!changesLen) {
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
const hasDifferences = changes.find(change => {
|
55
|
+
const [,, oldValue, newValue] = change;
|
56
|
+
return oldValue !== newValue;
|
57
|
+
});
|
58
|
+
if (!hasDifferences) {
|
59
|
+
return;
|
60
|
+
}
|
61
|
+
const wrappedAction = () => {
|
62
|
+
const clonedChanges = changes.reduce((arr, change) => {
|
63
|
+
arr.push([...change]);
|
64
|
+
return arr;
|
65
|
+
}, []);
|
66
|
+
clonedChanges.forEach(change => {
|
67
|
+
change[1] = hot.propToCol(change[1]);
|
68
|
+
});
|
69
|
+
const selected = changesLen > 1 ? this.getSelected() : [[clonedChanges[0][0], clonedChanges[0][1]]];
|
70
|
+
return new DataChangeAction({
|
71
|
+
changes: clonedChanges,
|
72
|
+
selected,
|
73
|
+
countCols: hot.countCols(),
|
74
|
+
countRows: hot.countRows()
|
75
|
+
});
|
76
|
+
};
|
77
|
+
undoRedoPlugin.done(wrappedAction, source);
|
78
|
+
});
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* @param {Core} hot The Handsontable instance.
|
83
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
84
|
+
*/
|
85
|
+
undo(hot, undoneCallback) {
|
86
|
+
const data = deepClone(this.changes);
|
87
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
88
|
+
data[i].splice(3, 1);
|
89
|
+
}
|
90
|
+
hot.addHookOnce('afterChange', undoneCallback);
|
91
|
+
hot.setDataAtCell(data, null, null, 'UndoRedo.undo');
|
92
|
+
const rowsToRemove = hot.countRows() - this.countRows;
|
93
|
+
if (rowsToRemove > 0) {
|
94
|
+
hot.alter('remove_row', null, rowsToRemove, 'UndoRedo.undo');
|
95
|
+
}
|
96
|
+
const columnsToRemove = hot.countCols() - this.countCols;
|
97
|
+
if (columnsToRemove > 0 && hot.isColumnModificationAllowed()) {
|
98
|
+
hot.alter('remove_col', null, columnsToRemove, 'UndoRedo.undo');
|
99
|
+
}
|
100
|
+
hot.scrollToFocusedCell();
|
101
|
+
hot.selectCells(this.selected, false, false);
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* @param {Core} hot The Handsontable instance.
|
106
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
107
|
+
*/
|
108
|
+
redo(hot, redoneCallback) {
|
109
|
+
const data = deepClone(this.changes);
|
110
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
111
|
+
data[i].splice(2, 1);
|
112
|
+
}
|
113
|
+
hot.addHookOnce('afterChange', redoneCallback);
|
114
|
+
hot.setDataAtCell(data, null, null, 'UndoRedo.redo');
|
115
|
+
if (this.selected) {
|
116
|
+
hot.selectCells(this.selected, false, false);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|