handsontable 0.0.0-next-442b0cf-20241209 → 0.0.0-next-aa821c7-20241209
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 +1 -7
- package/core.mjs +1 -7
- package/dataMap/metaManager/metaSchema.js +2 -3
- package/dataMap/metaManager/metaSchema.mjs +2 -3
- package/dist/handsontable.css +12 -2
- package/dist/handsontable.full.css +12 -2
- package/dist/handsontable.full.js +1438 -864
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +9 -7
- package/dist/handsontable.js +1437 -863
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +35 -33
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/base/base.js +0 -7
- package/plugins/base/base.mjs +0 -7
- 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 +114 -0
- package/plugins/undoRedo/actions/dataChange.mjs +110 -0
- package/plugins/undoRedo/actions/filters.js +68 -0
- package/plugins/undoRedo/actions/filters.mjs +64 -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/styles/handsontable.css +9 -2
- 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/utils/ghostTable.js +1 -5
- package/utils/ghostTable.mjs +1 -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-aa821c7-20241209";
|
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-aa821c7-20241209";
|
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-aa821c7-20241209",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
package/plugins/base/base.js
CHANGED
@@ -142,13 +142,6 @@ class BasePlugin {
|
|
142
142
|
if (!initializedPlugins) {
|
143
143
|
initializedPlugins = (0, _registry.getPluginsNames)();
|
144
144
|
}
|
145
|
-
|
146
|
-
// Workaround for the UndoRedo plugin which, currently doesn't follow the plugin architecture.
|
147
|
-
// Without this line the `callOnPluginsReady` callback won't be triggered after all plugin
|
148
|
-
// initialization.
|
149
|
-
if (initializedPlugins.indexOf('UndoRedo') >= 0) {
|
150
|
-
initializedPlugins.splice(initializedPlugins.indexOf('UndoRedo'), 1);
|
151
|
-
}
|
152
145
|
if (initializedPlugins.indexOf(this.pluginName) >= 0) {
|
153
146
|
initializedPlugins.splice(initializedPlugins.indexOf(this.pluginName), 1);
|
154
147
|
}
|
package/plugins/base/base.mjs
CHANGED
@@ -138,13 +138,6 @@ export class BasePlugin {
|
|
138
138
|
if (!initializedPlugins) {
|
139
139
|
initializedPlugins = getPluginsNames();
|
140
140
|
}
|
141
|
-
|
142
|
-
// Workaround for the UndoRedo plugin which, currently doesn't follow the plugin architecture.
|
143
|
-
// Without this line the `callOnPluginsReady` callback won't be triggered after all plugin
|
144
|
-
// initialization.
|
145
|
-
if (initializedPlugins.indexOf('UndoRedo') >= 0) {
|
146
|
-
initializedPlugins.splice(initializedPlugins.indexOf('UndoRedo'), 1);
|
147
|
-
}
|
148
141
|
if (initializedPlugins.indexOf(this.pluginName) >= 0) {
|
149
142
|
initializedPlugins.splice(initializedPlugins.indexOf(this.pluginName), 1);
|
150
143
|
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
5
|
+
/**
|
6
|
+
* An abstract class that defines the structure of an undo/redo action.
|
7
|
+
*
|
8
|
+
* @class BaseAction
|
9
|
+
* @private
|
10
|
+
*/
|
11
|
+
class BaseAction {
|
12
|
+
undo() {
|
13
|
+
throw new Error('Not implemented');
|
14
|
+
}
|
15
|
+
redo() {
|
16
|
+
throw new Error('Not implemented');
|
17
|
+
}
|
18
|
+
}
|
19
|
+
exports.BaseAction = BaseAction;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import "core-js/modules/es.error.cause.js";
|
2
|
+
/**
|
3
|
+
* An abstract class that defines the structure of an undo/redo action.
|
4
|
+
*
|
5
|
+
* @class BaseAction
|
6
|
+
* @private
|
7
|
+
*/
|
8
|
+
export class BaseAction {
|
9
|
+
undo() {
|
10
|
+
throw new Error('Not implemented');
|
11
|
+
}
|
12
|
+
redo() {
|
13
|
+
throw new Error('Not implemented');
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
5
|
+
var _base = require("./_base");
|
6
|
+
var _utils = require("../../contextMenu/utils");
|
7
|
+
var _array = require("../../../helpers/array");
|
8
|
+
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; }
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
10
|
+
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); }
|
11
|
+
/**
|
12
|
+
* Action that tracks cell alignment changes.
|
13
|
+
*
|
14
|
+
* @class CellAlignmentAction
|
15
|
+
* @private
|
16
|
+
*/
|
17
|
+
class CellAlignmentAction extends _base.BaseAction {
|
18
|
+
constructor(_ref) {
|
19
|
+
let {
|
20
|
+
stateBefore,
|
21
|
+
range,
|
22
|
+
type,
|
23
|
+
alignment
|
24
|
+
} = _ref;
|
25
|
+
super();
|
26
|
+
/**
|
27
|
+
* @param {Array} stateBefore The previous state.
|
28
|
+
*/
|
29
|
+
_defineProperty(this, "stateBefore", void 0);
|
30
|
+
/**
|
31
|
+
* @param {object} range The cell range.
|
32
|
+
*/
|
33
|
+
_defineProperty(this, "range", void 0);
|
34
|
+
/**
|
35
|
+
* @param {string} type The type of the alignment ("top", "left", "bottom" or "right").
|
36
|
+
*/
|
37
|
+
_defineProperty(this, "type", void 0);
|
38
|
+
/**
|
39
|
+
* @param {string} alignment The alignment CSS class.
|
40
|
+
*/
|
41
|
+
_defineProperty(this, "alignment", void 0);
|
42
|
+
this.stateBefore = stateBefore;
|
43
|
+
this.range = range;
|
44
|
+
this.type = type;
|
45
|
+
this.alignment = alignment;
|
46
|
+
}
|
47
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
48
|
+
hot.addHook('beforeCellAlignment', (stateBefore, range, type, alignment) => {
|
49
|
+
undoRedoPlugin.done(() => new CellAlignmentAction({
|
50
|
+
stateBefore,
|
51
|
+
range,
|
52
|
+
type,
|
53
|
+
alignment
|
54
|
+
}));
|
55
|
+
});
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* @param {Core} hot The Handsontable instance.
|
60
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
61
|
+
*/
|
62
|
+
undo(hot, undoneCallback) {
|
63
|
+
(0, _array.arrayEach)(this.range, range => {
|
64
|
+
range.forAll((row, col) => {
|
65
|
+
// Alignment classes should only collected within cell ranges. We skip header coordinates.
|
66
|
+
if (row >= 0 && col >= 0) {
|
67
|
+
hot.setCellMeta(row, col, 'className', this.stateBefore[row][col] || ' htLeft');
|
68
|
+
}
|
69
|
+
});
|
70
|
+
});
|
71
|
+
hot.addHookOnce('afterViewRender', undoneCallback);
|
72
|
+
hot.render();
|
73
|
+
}
|
74
|
+
|
75
|
+
/**
|
76
|
+
* @param {Core} hot The Handsontable instance.
|
77
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
78
|
+
*/
|
79
|
+
redo(hot, redoneCallback) {
|
80
|
+
(0, _utils.align)(this.range, this.type, this.alignment, (row, col) => hot.getCellMeta(row, col), (row, col, key, value) => hot.setCellMeta(row, col, key, value));
|
81
|
+
hot.addHookOnce('afterViewRender', redoneCallback);
|
82
|
+
hot.render();
|
83
|
+
}
|
84
|
+
}
|
85
|
+
exports.CellAlignmentAction = CellAlignmentAction;
|
@@ -0,0 +1,81 @@
|
|
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
|
+
import { align } from "../../contextMenu/utils.mjs";
|
7
|
+
import { arrayEach } from "../../../helpers/array.mjs";
|
8
|
+
/**
|
9
|
+
* Action that tracks cell alignment changes.
|
10
|
+
*
|
11
|
+
* @class CellAlignmentAction
|
12
|
+
* @private
|
13
|
+
*/
|
14
|
+
export class CellAlignmentAction extends BaseAction {
|
15
|
+
constructor(_ref) {
|
16
|
+
let {
|
17
|
+
stateBefore,
|
18
|
+
range,
|
19
|
+
type,
|
20
|
+
alignment
|
21
|
+
} = _ref;
|
22
|
+
super();
|
23
|
+
/**
|
24
|
+
* @param {Array} stateBefore The previous state.
|
25
|
+
*/
|
26
|
+
_defineProperty(this, "stateBefore", void 0);
|
27
|
+
/**
|
28
|
+
* @param {object} range The cell range.
|
29
|
+
*/
|
30
|
+
_defineProperty(this, "range", void 0);
|
31
|
+
/**
|
32
|
+
* @param {string} type The type of the alignment ("top", "left", "bottom" or "right").
|
33
|
+
*/
|
34
|
+
_defineProperty(this, "type", void 0);
|
35
|
+
/**
|
36
|
+
* @param {string} alignment The alignment CSS class.
|
37
|
+
*/
|
38
|
+
_defineProperty(this, "alignment", void 0);
|
39
|
+
this.stateBefore = stateBefore;
|
40
|
+
this.range = range;
|
41
|
+
this.type = type;
|
42
|
+
this.alignment = alignment;
|
43
|
+
}
|
44
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
45
|
+
hot.addHook('beforeCellAlignment', (stateBefore, range, type, alignment) => {
|
46
|
+
undoRedoPlugin.done(() => new CellAlignmentAction({
|
47
|
+
stateBefore,
|
48
|
+
range,
|
49
|
+
type,
|
50
|
+
alignment
|
51
|
+
}));
|
52
|
+
});
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* @param {Core} hot The Handsontable instance.
|
57
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
58
|
+
*/
|
59
|
+
undo(hot, undoneCallback) {
|
60
|
+
arrayEach(this.range, range => {
|
61
|
+
range.forAll((row, col) => {
|
62
|
+
// Alignment classes should only collected within cell ranges. We skip header coordinates.
|
63
|
+
if (row >= 0 && col >= 0) {
|
64
|
+
hot.setCellMeta(row, col, 'className', this.stateBefore[row][col] || ' htLeft');
|
65
|
+
}
|
66
|
+
});
|
67
|
+
});
|
68
|
+
hot.addHookOnce('afterViewRender', undoneCallback);
|
69
|
+
hot.render();
|
70
|
+
}
|
71
|
+
|
72
|
+
/**
|
73
|
+
* @param {Core} hot The Handsontable instance.
|
74
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
75
|
+
*/
|
76
|
+
redo(hot, redoneCallback) {
|
77
|
+
align(this.range, this.type, this.alignment, (row, col) => hot.getCellMeta(row, col), (row, col, key, value) => hot.setCellMeta(row, col, key, value));
|
78
|
+
hot.addHookOnce('afterViewRender', redoneCallback);
|
79
|
+
hot.render();
|
80
|
+
}
|
81
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
5
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
6
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
7
|
+
var _base = require("./_base");
|
8
|
+
var _moves = require("../../../helpers/moves");
|
9
|
+
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; }
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
11
|
+
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); }
|
12
|
+
/**
|
13
|
+
* Action that tracks column move changes.
|
14
|
+
*
|
15
|
+
* @class ColumnMoveAction
|
16
|
+
* @private
|
17
|
+
*/
|
18
|
+
class ColumnMoveAction extends _base.BaseAction {
|
19
|
+
constructor(_ref) {
|
20
|
+
let {
|
21
|
+
columns,
|
22
|
+
finalIndex
|
23
|
+
} = _ref;
|
24
|
+
super();
|
25
|
+
/**
|
26
|
+
* @param {number[]} columns An array with moved columns.
|
27
|
+
*/
|
28
|
+
_defineProperty(this, "columns", void 0);
|
29
|
+
/**
|
30
|
+
* @param {number} finalIndex The destination index.
|
31
|
+
*/
|
32
|
+
_defineProperty(this, "finalColumnIndex", void 0);
|
33
|
+
this.columns = columns.slice();
|
34
|
+
this.finalColumnIndex = finalIndex;
|
35
|
+
}
|
36
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
37
|
+
hot.addHook('beforeColumnMove', (columns, finalIndex) => {
|
38
|
+
if (columns === false) {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
undoRedoPlugin.done(() => new ColumnMoveAction({
|
42
|
+
columns,
|
43
|
+
finalIndex
|
44
|
+
}));
|
45
|
+
});
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @param {Core} hot The Handsontable instance.
|
50
|
+
* @param {function(): void} undoneCallback The callback to be called after the action is undone.
|
51
|
+
*/
|
52
|
+
undo(hot, undoneCallback) {
|
53
|
+
const manualColumnMove = hot.getPlugin('manualColumnMove');
|
54
|
+
hot.addHookOnce('afterViewRender', undoneCallback);
|
55
|
+
const columnMoves = (0, _moves.getMoves)(this.columns, this.finalColumnIndex, hot.columnIndexMapper.getNumberOfIndexes());
|
56
|
+
columnMoves.reverse().forEach(_ref2 => {
|
57
|
+
let {
|
58
|
+
from,
|
59
|
+
to
|
60
|
+
} = _ref2;
|
61
|
+
if (from < to) {
|
62
|
+
to -= 1;
|
63
|
+
}
|
64
|
+
manualColumnMove.moveColumn(to, from);
|
65
|
+
});
|
66
|
+
hot.render();
|
67
|
+
hot.deselectCell();
|
68
|
+
hot.selectColumns(this.columns[0], this.columns[0] + this.columns.length - 1);
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* @param {Core} hot The Handsontable instance.
|
73
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
74
|
+
*/
|
75
|
+
redo(hot, redoneCallback) {
|
76
|
+
const manualColumnMove = hot.getPlugin('manualColumnMove');
|
77
|
+
hot.addHookOnce('afterViewRender', redoneCallback);
|
78
|
+
manualColumnMove.moveColumns(this.columns.slice(), this.finalColumnIndex);
|
79
|
+
hot.render();
|
80
|
+
hot.deselectCell();
|
81
|
+
hot.selectColumns(this.finalColumnIndex, this.finalColumnIndex + this.columns.length - 1);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
exports.ColumnMoveAction = ColumnMoveAction;
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import "core-js/modules/es.error.cause.js";
|
2
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
3
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
4
|
+
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; }
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
6
|
+
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); }
|
7
|
+
import { BaseAction } from "./_base.mjs";
|
8
|
+
import { getMoves } from "../../../helpers/moves.mjs";
|
9
|
+
/**
|
10
|
+
* Action that tracks column move changes.
|
11
|
+
*
|
12
|
+
* @class ColumnMoveAction
|
13
|
+
* @private
|
14
|
+
*/
|
15
|
+
export class ColumnMoveAction extends BaseAction {
|
16
|
+
constructor(_ref) {
|
17
|
+
let {
|
18
|
+
columns,
|
19
|
+
finalIndex
|
20
|
+
} = _ref;
|
21
|
+
super();
|
22
|
+
/**
|
23
|
+
* @param {number[]} columns An array with moved columns.
|
24
|
+
*/
|
25
|
+
_defineProperty(this, "columns", void 0);
|
26
|
+
/**
|
27
|
+
* @param {number} finalIndex The destination index.
|
28
|
+
*/
|
29
|
+
_defineProperty(this, "finalColumnIndex", void 0);
|
30
|
+
this.columns = columns.slice();
|
31
|
+
this.finalColumnIndex = finalIndex;
|
32
|
+
}
|
33
|
+
static startRegisteringEvents(hot, undoRedoPlugin) {
|
34
|
+
hot.addHook('beforeColumnMove', (columns, finalIndex) => {
|
35
|
+
if (columns === false) {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
undoRedoPlugin.done(() => new ColumnMoveAction({
|
39
|
+
columns,
|
40
|
+
finalIndex
|
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 manualColumnMove = hot.getPlugin('manualColumnMove');
|
51
|
+
hot.addHookOnce('afterViewRender', undoneCallback);
|
52
|
+
const columnMoves = getMoves(this.columns, this.finalColumnIndex, hot.columnIndexMapper.getNumberOfIndexes());
|
53
|
+
columnMoves.reverse().forEach(_ref2 => {
|
54
|
+
let {
|
55
|
+
from,
|
56
|
+
to
|
57
|
+
} = _ref2;
|
58
|
+
if (from < to) {
|
59
|
+
to -= 1;
|
60
|
+
}
|
61
|
+
manualColumnMove.moveColumn(to, from);
|
62
|
+
});
|
63
|
+
hot.render();
|
64
|
+
hot.deselectCell();
|
65
|
+
hot.selectColumns(this.columns[0], this.columns[0] + this.columns.length - 1);
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* @param {Core} hot The Handsontable instance.
|
70
|
+
* @param {function(): void} redoneCallback The callback to be called after the action is redone.
|
71
|
+
*/
|
72
|
+
redo(hot, redoneCallback) {
|
73
|
+
const manualColumnMove = hot.getPlugin('manualColumnMove');
|
74
|
+
hot.addHookOnce('afterViewRender', redoneCallback);
|
75
|
+
manualColumnMove.moveColumns(this.columns.slice(), this.finalColumnIndex);
|
76
|
+
hot.render();
|
77
|
+
hot.deselectCell();
|
78
|
+
hot.selectColumns(this.finalColumnIndex, this.finalColumnIndex + this.columns.length - 1);
|
79
|
+
}
|
80
|
+
}
|
@@ -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;
|