handsontable 0.0.0-next-be250b6-20230621 → 0.0.0-next-d1c8e0e-20230621
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +3023 -2833
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +77 -77
- package/dist/handsontable.js +2944 -2754
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +4 -4
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/comments/comments.js +11 -4
- package/plugins/comments/comments.mjs +11 -4
- package/plugins/contextMenu/contextMenu.d.ts +1 -1
- package/plugins/contextMenu/contextMenu.js +80 -29
- package/plugins/contextMenu/contextMenu.mjs +81 -30
- package/plugins/contextMenu/predefinedItems/alignment.js +7 -0
- package/plugins/contextMenu/predefinedItems/alignment.mjs +7 -0
- package/plugins/contextMenu/predefinedItems/clearColumn.js +5 -3
- package/plugins/contextMenu/predefinedItems/clearColumn.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/columnLeft.js +5 -3
- package/plugins/contextMenu/predefinedItems/columnLeft.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/columnRight.js +5 -3
- package/plugins/contextMenu/predefinedItems/columnRight.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/readOnly.js +7 -0
- package/plugins/contextMenu/predefinedItems/readOnly.mjs +7 -0
- package/plugins/contextMenu/predefinedItems/removeColumn.js +7 -5
- package/plugins/contextMenu/predefinedItems/removeColumn.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/removeRow.js +7 -5
- package/plugins/contextMenu/predefinedItems/removeRow.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/rowAbove.js +5 -3
- package/plugins/contextMenu/predefinedItems/rowAbove.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/rowBelow.js +5 -3
- package/plugins/contextMenu/predefinedItems/rowBelow.mjs +5 -3
- package/plugins/contextMenu/utils.js +25 -16
- package/plugins/contextMenu/utils.mjs +24 -15
- package/plugins/copyPaste/contextMenuItem/copy.js +7 -0
- package/plugins/copyPaste/contextMenuItem/copy.mjs +7 -0
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +9 -1
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +9 -1
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +9 -1
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +9 -1
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +9 -1
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +9 -1
- package/plugins/copyPaste/contextMenuItem/cut.js +7 -0
- package/plugins/copyPaste/contextMenuItem/cut.mjs +7 -0
- package/plugins/customBorders/customBorders.js +7 -0
- package/plugins/customBorders/customBorders.mjs +7 -0
- package/plugins/dropdownMenu/dropdownMenu.d.ts +1 -1
- package/plugins/dropdownMenu/dropdownMenu.js +94 -30
- package/plugins/dropdownMenu/dropdownMenu.mjs +94 -30
- package/plugins/filters/filters.js +62 -42
- package/plugins/filters/filters.mjs +61 -41
- package/shortcutContexts/commands/index.js +1 -2
- package/shortcutContexts/commands/index.mjs +1 -2
- package/shortcutContexts/grid.js +0 -5
- package/shortcutContexts/grid.mjs +0 -5
- package/shortcuts/recorder.js +2 -2
- package/shortcuts/recorder.mjs +2 -2
- package/shortcuts/utils.js +21 -5
- package/shortcuts/utils.mjs +20 -4
- package/shortcutContexts/commands/scrollToFocusedCell.js +0 -38
- package/shortcutContexts/commands/scrollToFocusedCell.mjs +0 -33
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-d1c8e0e-20230621";
|
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-d1c8e0e-20230621";
|
146
146
|
var keyValidityDate;
|
147
147
|
var consoleMessageState = 'invalid';
|
148
148
|
var 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-d1c8e0e-20230621",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
@@ -835,7 +835,14 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
835
835
|
key: "addToContextMenu",
|
836
836
|
value: function addToContextMenu(defaultOptions) {
|
837
837
|
var _this6 = this;
|
838
|
-
var
|
838
|
+
var isThereAnySelectedCellToProcess = function isThereAnySelectedCellToProcess() {
|
839
|
+
var range = _this6.hot.getSelectedRangeLast();
|
840
|
+
if (!range) {
|
841
|
+
return false;
|
842
|
+
}
|
843
|
+
if (range.isSingleHeader() || range.highlight.isHeader()) {
|
844
|
+
return false;
|
845
|
+
}
|
839
846
|
return _this6.hot.rowIndexMapper.getRenderableIndexesLength() > 0 && _this6.hot.columnIndexMapper.getRenderableIndexesLength() > 0;
|
840
847
|
};
|
841
848
|
defaultOptions.items.push({
|
@@ -852,7 +859,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
852
859
|
return _this6.onContextMenuAddComment();
|
853
860
|
},
|
854
861
|
disabled: function disabled() {
|
855
|
-
if (!
|
862
|
+
if (!isThereAnySelectedCellToProcess()) {
|
856
863
|
return true;
|
857
864
|
}
|
858
865
|
return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
|
@@ -866,7 +873,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
866
873
|
return _this6.onContextMenuRemoveComment();
|
867
874
|
},
|
868
875
|
disabled: function disabled() {
|
869
|
-
if (!
|
876
|
+
if (!isThereAnySelectedCellToProcess()) {
|
870
877
|
return true;
|
871
878
|
}
|
872
879
|
return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
|
@@ -894,7 +901,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
894
901
|
return _this6.onContextMenuMakeReadOnly();
|
895
902
|
},
|
896
903
|
disabled: function disabled() {
|
897
|
-
if (!
|
904
|
+
if (!isThereAnySelectedCellToProcess()) {
|
898
905
|
return true;
|
899
906
|
}
|
900
907
|
return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner()) || !_this6.checkSelectionCommentsConsistency();
|
@@ -826,7 +826,14 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
826
826
|
key: "addToContextMenu",
|
827
827
|
value: function addToContextMenu(defaultOptions) {
|
828
828
|
var _this6 = this;
|
829
|
-
var
|
829
|
+
var isThereAnySelectedCellToProcess = function isThereAnySelectedCellToProcess() {
|
830
|
+
var range = _this6.hot.getSelectedRangeLast();
|
831
|
+
if (!range) {
|
832
|
+
return false;
|
833
|
+
}
|
834
|
+
if (range.isSingleHeader() || range.highlight.isHeader()) {
|
835
|
+
return false;
|
836
|
+
}
|
830
837
|
return _this6.hot.rowIndexMapper.getRenderableIndexesLength() > 0 && _this6.hot.columnIndexMapper.getRenderableIndexesLength() > 0;
|
831
838
|
};
|
832
839
|
defaultOptions.items.push({
|
@@ -843,7 +850,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
843
850
|
return _this6.onContextMenuAddComment();
|
844
851
|
},
|
845
852
|
disabled: function disabled() {
|
846
|
-
if (!
|
853
|
+
if (!isThereAnySelectedCellToProcess()) {
|
847
854
|
return true;
|
848
855
|
}
|
849
856
|
return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
|
@@ -857,7 +864,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
857
864
|
return _this6.onContextMenuRemoveComment();
|
858
865
|
},
|
859
866
|
disabled: function disabled() {
|
860
|
-
if (!
|
867
|
+
if (!isThereAnySelectedCellToProcess()) {
|
861
868
|
return true;
|
862
869
|
}
|
863
870
|
return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
|
@@ -885,7 +892,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
|
|
885
892
|
return _this6.onContextMenuMakeReadOnly();
|
886
893
|
},
|
887
894
|
disabled: function disabled() {
|
888
|
-
if (!
|
895
|
+
if (!isThereAnySelectedCellToProcess()) {
|
889
896
|
return true;
|
890
897
|
}
|
891
898
|
return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner()) || !_this6.checkSelectionCommentsConsistency();
|
@@ -60,7 +60,7 @@ export class ContextMenu extends BasePlugin {
|
|
60
60
|
|
61
61
|
constructor(hotInstance: Core);
|
62
62
|
isEnabled(): boolean;
|
63
|
-
open(
|
63
|
+
open(position: { left: number, top: number } | Event, offset?: { above?: number, below?: number, left?: number, right?: number }): void;
|
64
64
|
close(): void;
|
65
65
|
executeCommand(commandName: string, ...params: any): void;
|
66
66
|
}
|
@@ -22,10 +22,12 @@ require("core-js/modules/es.object.get-prototype-of.js");
|
|
22
22
|
var _base = require("../base");
|
23
23
|
var _pluginHooks = _interopRequireDefault(require("../../pluginHooks"));
|
24
24
|
var _array = require("../../helpers/array");
|
25
|
+
var _object = require("../../helpers/object");
|
25
26
|
var _commandExecutor = _interopRequireDefault(require("./commandExecutor"));
|
26
27
|
var _eventManager = _interopRequireDefault(require("../../eventManager"));
|
27
28
|
var _itemsFactory = _interopRequireDefault(require("./itemsFactory"));
|
28
29
|
var _menu = _interopRequireDefault(require("./menu"));
|
30
|
+
var _utils = require("./utils");
|
29
31
|
var _element = require("../../helpers/dom/element");
|
30
32
|
var _predefinedItems = require("./predefinedItems");
|
31
33
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -47,6 +49,7 @@ var PLUGIN_KEY = 'contextMenu';
|
|
47
49
|
exports.PLUGIN_KEY = PLUGIN_KEY;
|
48
50
|
var PLUGIN_PRIORITY = 70;
|
49
51
|
exports.PLUGIN_PRIORITY = PLUGIN_PRIORITY;
|
52
|
+
var SHORTCUTS_GROUP = PLUGIN_KEY;
|
50
53
|
_pluginHooks.default.getSingleton().register('afterContextMenuDefaultOptions');
|
51
54
|
_pluginHooks.default.getSingleton().register('beforeContextMenuShow');
|
52
55
|
_pluginHooks.default.getSingleton().register('afterContextMenuShow');
|
@@ -168,6 +171,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
168
171
|
this.addHook('afterOnCellContextMenu', function (event) {
|
169
172
|
return _this2.onAfterOnCellContextMenu(event);
|
170
173
|
});
|
174
|
+
this.registerShortcuts();
|
171
175
|
_get(_getPrototypeOf(ContextMenu.prototype), "enablePlugin", this).call(this);
|
172
176
|
}
|
173
177
|
|
@@ -182,6 +186,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
182
186
|
value: function updatePlugin() {
|
183
187
|
this.disablePlugin();
|
184
188
|
this.enablePlugin();
|
189
|
+
this.unregisterShortcuts();
|
185
190
|
_get(_getPrototypeOf(ContextMenu.prototype), "updatePlugin", this).call(this);
|
186
191
|
}
|
187
192
|
|
@@ -199,39 +204,83 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
199
204
|
_get(_getPrototypeOf(ContextMenu.prototype), "disablePlugin", this).call(this);
|
200
205
|
}
|
201
206
|
|
207
|
+
/**
|
208
|
+
* Register shortcuts responsible for toggling context menu.
|
209
|
+
*
|
210
|
+
* @private
|
211
|
+
*/
|
212
|
+
}, {
|
213
|
+
key: "registerShortcuts",
|
214
|
+
value: function registerShortcuts() {
|
215
|
+
var _this3 = this;
|
216
|
+
this.hot.getShortcutManager().getContext('grid').addShortcut({
|
217
|
+
keys: [['Control/Meta', 'Shift', '\\'], ['Shift', 'F10']],
|
218
|
+
callback: function callback() {
|
219
|
+
var _this3$hot$getSelecte = _this3.hot.getSelectedRangeLast(),
|
220
|
+
highlight = _this3$hot$getSelecte.highlight;
|
221
|
+
var rect = _this3.hot.getCell(highlight.row, highlight.col, true).getBoundingClientRect();
|
222
|
+
var offset = (0, _utils.getDocumentOffsetByElement)(_this3.menu.container, _this3.hot.rootDocument);
|
223
|
+
_this3.open({
|
224
|
+
left: rect.left + offset.left,
|
225
|
+
top: rect.top + offset.top - 1 + rect.height
|
226
|
+
}, {
|
227
|
+
left: rect.width,
|
228
|
+
above: -rect.height
|
229
|
+
});
|
230
|
+
_this3.hot._registerTimeout(function () {
|
231
|
+
_this3.menu.selectFirstCell();
|
232
|
+
});
|
233
|
+
},
|
234
|
+
runOnlyIf: function runOnlyIf() {
|
235
|
+
return _this3.hot.getSelectedRangeLast() && !_this3.menu.isOpened();
|
236
|
+
},
|
237
|
+
group: SHORTCUTS_GROUP
|
238
|
+
});
|
239
|
+
}
|
240
|
+
|
241
|
+
/**
|
242
|
+
* Unregister shortcuts responsible for toggling context menu.
|
243
|
+
*
|
244
|
+
* @private
|
245
|
+
*/
|
246
|
+
}, {
|
247
|
+
key: "unregisterShortcuts",
|
248
|
+
value: function unregisterShortcuts() {
|
249
|
+
this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
|
250
|
+
}
|
251
|
+
|
202
252
|
/**
|
203
253
|
* Opens menu and re-position it based on the passed coordinates.
|
204
254
|
*
|
205
|
-
* @param {Event}
|
255
|
+
* @param {{ top: number, left: number }|Event} position An object with `top` and `left` properties
|
256
|
+
* which contains coordinates relative to the browsers viewport (without included scroll offsets).
|
257
|
+
* Or if the native event is passed the menu will be positioned based on the `pageX` and `pageY`
|
258
|
+
* coordinates.
|
259
|
+
* @param {{ above: number, below: number, left: number, right: number }} offset An object allows applying
|
260
|
+
* the offset to the menu position.
|
261
|
+
* @fires Hooks#beforeContextMenuShow
|
262
|
+
* @fires Hooks#afterContextMenuShow
|
206
263
|
*/
|
207
264
|
}, {
|
208
265
|
key: "open",
|
209
|
-
value: function open(
|
210
|
-
|
266
|
+
value: function open(position) {
|
267
|
+
var _this$menu,
|
268
|
+
_this4 = this;
|
269
|
+
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
270
|
+
above: 0,
|
271
|
+
below: 0,
|
272
|
+
left: 0,
|
273
|
+
right: 0
|
274
|
+
};
|
275
|
+
if ((_this$menu = this.menu) !== null && _this$menu !== void 0 && _this$menu.isOpened()) {
|
211
276
|
return;
|
212
277
|
}
|
213
278
|
this.prepareMenuItems();
|
214
279
|
this.menu.open();
|
215
|
-
|
216
|
-
|
217
|
-
}
|
218
|
-
var offsetTop = 0;
|
219
|
-
var offsetLeft = 0;
|
220
|
-
if (this.hot.rootDocument !== this.menu.container.ownerDocument) {
|
221
|
-
var frameElement = this.hot.rootWindow.frameElement;
|
222
|
-
var _frameElement$getBoun = frameElement.getBoundingClientRect(),
|
223
|
-
top = _frameElement$getBoun.top,
|
224
|
-
left = _frameElement$getBoun.left;
|
225
|
-
offsetTop = top - (0, _element.getWindowScrollTop)(event.view);
|
226
|
-
offsetLeft = left - (0, _element.getWindowScrollLeft)(event.view);
|
227
|
-
} else {
|
228
|
-
offsetTop = -1 * (0, _element.getWindowScrollTop)(this.menu.hotMenu.rootWindow);
|
229
|
-
offsetLeft = -1 * (0, _element.getWindowScrollLeft)(this.menu.hotMenu.rootWindow);
|
230
|
-
}
|
231
|
-
this.menu.setPosition({
|
232
|
-
top: parseInt(event.pageY, 10) + offsetTop,
|
233
|
-
left: parseInt(event.pageX, 10) + offsetLeft
|
280
|
+
(0, _object.objectEach)(offset, function (value, key) {
|
281
|
+
_this4.menu.setOffset(key, value);
|
234
282
|
});
|
283
|
+
this.menu.setPosition(position);
|
235
284
|
}
|
236
285
|
|
237
286
|
/**
|
@@ -240,10 +289,8 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
240
289
|
}, {
|
241
290
|
key: "close",
|
242
291
|
value: function close() {
|
243
|
-
|
244
|
-
|
245
|
-
}
|
246
|
-
this.menu.close();
|
292
|
+
var _this$menu2;
|
293
|
+
(_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
|
247
294
|
this.itemsFactory = null;
|
248
295
|
}
|
249
296
|
|
@@ -300,7 +347,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
300
347
|
}, {
|
301
348
|
key: "prepareMenuItems",
|
302
349
|
value: function prepareMenuItems() {
|
303
|
-
var
|
350
|
+
var _this5 = this;
|
304
351
|
this.itemsFactory = new _itemsFactory.default(this.hot, ContextMenu.DEFAULT_ITEMS);
|
305
352
|
var settings = this.hot.getSettings()[PLUGIN_KEY];
|
306
353
|
var predefinedItems = {
|
@@ -314,7 +361,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
314
361
|
|
315
362
|
// Register all commands. Predefined and added by user or by plugins
|
316
363
|
(0, _array.arrayEach)(menuItems, function (command) {
|
317
|
-
return
|
364
|
+
return _this5.commandExecutor.registerCommand(command.key, command);
|
318
365
|
});
|
319
366
|
}
|
320
367
|
|
@@ -351,7 +398,11 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
351
398
|
return;
|
352
399
|
}
|
353
400
|
}
|
354
|
-
this.
|
401
|
+
var offset = (0, _utils.getDocumentOffsetByElement)(this.menu.container, this.hot.rootDocument);
|
402
|
+
this.open({
|
403
|
+
top: event.clientY + offset.top,
|
404
|
+
left: event.clientX + offset.left
|
405
|
+
});
|
355
406
|
}
|
356
407
|
|
357
408
|
/**
|
@@ -32,14 +32,17 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
32
32
|
import { BasePlugin } from "../base/index.mjs";
|
33
33
|
import Hooks from "../../pluginHooks.mjs";
|
34
34
|
import { arrayEach } from "../../helpers/array.mjs";
|
35
|
+
import { objectEach } from "../../helpers/object.mjs";
|
35
36
|
import CommandExecutor from "./commandExecutor.mjs";
|
36
37
|
import EventManager from "../../eventManager.mjs";
|
37
38
|
import ItemsFactory from "./itemsFactory.mjs";
|
38
39
|
import Menu from "./menu.mjs";
|
39
|
-
import {
|
40
|
+
import { getDocumentOffsetByElement } from "./utils.mjs";
|
41
|
+
import { hasClass } from "../../helpers/dom/element.mjs";
|
40
42
|
import { ROW_ABOVE, ROW_BELOW, COLUMN_LEFT, COLUMN_RIGHT, REMOVE_ROW, REMOVE_COLUMN, UNDO, REDO, READ_ONLY, ALIGNMENT, SEPARATOR } from "./predefinedItems.mjs";
|
41
43
|
export var PLUGIN_KEY = 'contextMenu';
|
42
44
|
export var PLUGIN_PRIORITY = 70;
|
45
|
+
var SHORTCUTS_GROUP = PLUGIN_KEY;
|
43
46
|
Hooks.getSingleton().register('afterContextMenuDefaultOptions');
|
44
47
|
Hooks.getSingleton().register('beforeContextMenuShow');
|
45
48
|
Hooks.getSingleton().register('afterContextMenuShow');
|
@@ -161,6 +164,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
161
164
|
this.addHook('afterOnCellContextMenu', function (event) {
|
162
165
|
return _this2.onAfterOnCellContextMenu(event);
|
163
166
|
});
|
167
|
+
this.registerShortcuts();
|
164
168
|
_get(_getPrototypeOf(ContextMenu.prototype), "enablePlugin", this).call(this);
|
165
169
|
}
|
166
170
|
|
@@ -175,6 +179,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
175
179
|
value: function updatePlugin() {
|
176
180
|
this.disablePlugin();
|
177
181
|
this.enablePlugin();
|
182
|
+
this.unregisterShortcuts();
|
178
183
|
_get(_getPrototypeOf(ContextMenu.prototype), "updatePlugin", this).call(this);
|
179
184
|
}
|
180
185
|
|
@@ -192,39 +197,83 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
192
197
|
_get(_getPrototypeOf(ContextMenu.prototype), "disablePlugin", this).call(this);
|
193
198
|
}
|
194
199
|
|
200
|
+
/**
|
201
|
+
* Register shortcuts responsible for toggling context menu.
|
202
|
+
*
|
203
|
+
* @private
|
204
|
+
*/
|
205
|
+
}, {
|
206
|
+
key: "registerShortcuts",
|
207
|
+
value: function registerShortcuts() {
|
208
|
+
var _this3 = this;
|
209
|
+
this.hot.getShortcutManager().getContext('grid').addShortcut({
|
210
|
+
keys: [['Control/Meta', 'Shift', '\\'], ['Shift', 'F10']],
|
211
|
+
callback: function callback() {
|
212
|
+
var _this3$hot$getSelecte = _this3.hot.getSelectedRangeLast(),
|
213
|
+
highlight = _this3$hot$getSelecte.highlight;
|
214
|
+
var rect = _this3.hot.getCell(highlight.row, highlight.col, true).getBoundingClientRect();
|
215
|
+
var offset = getDocumentOffsetByElement(_this3.menu.container, _this3.hot.rootDocument);
|
216
|
+
_this3.open({
|
217
|
+
left: rect.left + offset.left,
|
218
|
+
top: rect.top + offset.top - 1 + rect.height
|
219
|
+
}, {
|
220
|
+
left: rect.width,
|
221
|
+
above: -rect.height
|
222
|
+
});
|
223
|
+
_this3.hot._registerTimeout(function () {
|
224
|
+
_this3.menu.selectFirstCell();
|
225
|
+
});
|
226
|
+
},
|
227
|
+
runOnlyIf: function runOnlyIf() {
|
228
|
+
return _this3.hot.getSelectedRangeLast() && !_this3.menu.isOpened();
|
229
|
+
},
|
230
|
+
group: SHORTCUTS_GROUP
|
231
|
+
});
|
232
|
+
}
|
233
|
+
|
234
|
+
/**
|
235
|
+
* Unregister shortcuts responsible for toggling context menu.
|
236
|
+
*
|
237
|
+
* @private
|
238
|
+
*/
|
239
|
+
}, {
|
240
|
+
key: "unregisterShortcuts",
|
241
|
+
value: function unregisterShortcuts() {
|
242
|
+
this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
|
243
|
+
}
|
244
|
+
|
195
245
|
/**
|
196
246
|
* Opens menu and re-position it based on the passed coordinates.
|
197
247
|
*
|
198
|
-
* @param {Event}
|
248
|
+
* @param {{ top: number, left: number }|Event} position An object with `top` and `left` properties
|
249
|
+
* which contains coordinates relative to the browsers viewport (without included scroll offsets).
|
250
|
+
* Or if the native event is passed the menu will be positioned based on the `pageX` and `pageY`
|
251
|
+
* coordinates.
|
252
|
+
* @param {{ above: number, below: number, left: number, right: number }} offset An object allows applying
|
253
|
+
* the offset to the menu position.
|
254
|
+
* @fires Hooks#beforeContextMenuShow
|
255
|
+
* @fires Hooks#afterContextMenuShow
|
199
256
|
*/
|
200
257
|
}, {
|
201
258
|
key: "open",
|
202
|
-
value: function open(
|
203
|
-
|
259
|
+
value: function open(position) {
|
260
|
+
var _this$menu,
|
261
|
+
_this4 = this;
|
262
|
+
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
263
|
+
above: 0,
|
264
|
+
below: 0,
|
265
|
+
left: 0,
|
266
|
+
right: 0
|
267
|
+
};
|
268
|
+
if ((_this$menu = this.menu) !== null && _this$menu !== void 0 && _this$menu.isOpened()) {
|
204
269
|
return;
|
205
270
|
}
|
206
271
|
this.prepareMenuItems();
|
207
272
|
this.menu.open();
|
208
|
-
|
209
|
-
|
210
|
-
}
|
211
|
-
var offsetTop = 0;
|
212
|
-
var offsetLeft = 0;
|
213
|
-
if (this.hot.rootDocument !== this.menu.container.ownerDocument) {
|
214
|
-
var frameElement = this.hot.rootWindow.frameElement;
|
215
|
-
var _frameElement$getBoun = frameElement.getBoundingClientRect(),
|
216
|
-
top = _frameElement$getBoun.top,
|
217
|
-
left = _frameElement$getBoun.left;
|
218
|
-
offsetTop = top - getWindowScrollTop(event.view);
|
219
|
-
offsetLeft = left - getWindowScrollLeft(event.view);
|
220
|
-
} else {
|
221
|
-
offsetTop = -1 * getWindowScrollTop(this.menu.hotMenu.rootWindow);
|
222
|
-
offsetLeft = -1 * getWindowScrollLeft(this.menu.hotMenu.rootWindow);
|
223
|
-
}
|
224
|
-
this.menu.setPosition({
|
225
|
-
top: parseInt(event.pageY, 10) + offsetTop,
|
226
|
-
left: parseInt(event.pageX, 10) + offsetLeft
|
273
|
+
objectEach(offset, function (value, key) {
|
274
|
+
_this4.menu.setOffset(key, value);
|
227
275
|
});
|
276
|
+
this.menu.setPosition(position);
|
228
277
|
}
|
229
278
|
|
230
279
|
/**
|
@@ -233,10 +282,8 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
233
282
|
}, {
|
234
283
|
key: "close",
|
235
284
|
value: function close() {
|
236
|
-
|
237
|
-
|
238
|
-
}
|
239
|
-
this.menu.close();
|
285
|
+
var _this$menu2;
|
286
|
+
(_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
|
240
287
|
this.itemsFactory = null;
|
241
288
|
}
|
242
289
|
|
@@ -293,7 +340,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
293
340
|
}, {
|
294
341
|
key: "prepareMenuItems",
|
295
342
|
value: function prepareMenuItems() {
|
296
|
-
var
|
343
|
+
var _this5 = this;
|
297
344
|
this.itemsFactory = new ItemsFactory(this.hot, ContextMenu.DEFAULT_ITEMS);
|
298
345
|
var settings = this.hot.getSettings()[PLUGIN_KEY];
|
299
346
|
var predefinedItems = {
|
@@ -307,7 +354,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
307
354
|
|
308
355
|
// Register all commands. Predefined and added by user or by plugins
|
309
356
|
arrayEach(menuItems, function (command) {
|
310
|
-
return
|
357
|
+
return _this5.commandExecutor.registerCommand(command.key, command);
|
311
358
|
});
|
312
359
|
}
|
313
360
|
|
@@ -344,7 +391,11 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
|
|
344
391
|
return;
|
345
392
|
}
|
346
393
|
}
|
347
|
-
this.
|
394
|
+
var offset = getDocumentOffsetByElement(this.menu.container, this.hot.rootDocument);
|
395
|
+
this.open({
|
396
|
+
top: event.clientY + offset.top,
|
397
|
+
left: event.clientX + offset.left
|
398
|
+
});
|
348
399
|
}
|
349
400
|
|
350
401
|
/**
|
@@ -35,6 +35,13 @@ function alignmentItem() {
|
|
35
35
|
if (this.countRows() === 0 || this.countCols() === 0) {
|
36
36
|
return true;
|
37
37
|
}
|
38
|
+
var range = this.getSelectedRangeLast();
|
39
|
+
if (!range) {
|
40
|
+
return true;
|
41
|
+
}
|
42
|
+
if (range.isSingleHeader()) {
|
43
|
+
return true;
|
44
|
+
}
|
38
45
|
return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
|
39
46
|
},
|
40
47
|
submenu: {
|
@@ -17,6 +17,13 @@ export default function alignmentItem() {
|
|
17
17
|
if (this.countRows() === 0 || this.countCols() === 0) {
|
18
18
|
return true;
|
19
19
|
}
|
20
|
+
var range = this.getSelectedRangeLast();
|
21
|
+
if (!range) {
|
22
|
+
return true;
|
23
|
+
}
|
24
|
+
if (range.isSingleHeader()) {
|
25
|
+
return true;
|
26
|
+
}
|
20
27
|
return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
|
21
28
|
},
|
22
29
|
submenu: {
|
@@ -13,7 +13,6 @@ require("core-js/modules/es.symbol.iterator.js");
|
|
13
13
|
exports.__esModule = true;
|
14
14
|
exports.KEY = void 0;
|
15
15
|
exports.default = clearColumnItem;
|
16
|
-
var _utils = require("../utils");
|
17
16
|
var C = _interopRequireWildcard(require("../../../i18n/constants"));
|
18
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
19
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -37,8 +36,11 @@ function clearColumnItem() {
|
|
37
36
|
}
|
38
37
|
},
|
39
38
|
disabled: function disabled() {
|
40
|
-
var
|
41
|
-
if (!
|
39
|
+
var range = this.getSelectedRangeLast();
|
40
|
+
if (!range) {
|
41
|
+
return true;
|
42
|
+
}
|
43
|
+
if (range.isSingleHeader() && range.highlight.col < 0) {
|
42
44
|
return true;
|
43
45
|
}
|
44
46
|
return !this.selection.isSelectedByColumnHeader();
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { getValidSelection } from "../utils.mjs";
|
2
1
|
import * as C from "../../../i18n/constants.mjs";
|
3
2
|
export var KEY = 'clear_column';
|
4
3
|
|
@@ -19,8 +18,11 @@ export default function clearColumnItem() {
|
|
19
18
|
}
|
20
19
|
},
|
21
20
|
disabled: function disabled() {
|
22
|
-
var
|
23
|
-
if (!
|
21
|
+
var range = this.getSelectedRangeLast();
|
22
|
+
if (!range) {
|
23
|
+
return true;
|
24
|
+
}
|
25
|
+
if (range.isSingleHeader() && range.highlight.col < 0) {
|
24
26
|
return true;
|
25
27
|
}
|
26
28
|
return !this.selection.isSelectedByColumnHeader();
|
@@ -13,7 +13,6 @@ require("core-js/modules/es.symbol.iterator.js");
|
|
13
13
|
exports.__esModule = true;
|
14
14
|
exports.KEY = void 0;
|
15
15
|
exports.default = columnLeftItem;
|
16
|
-
var _utils = require("../utils");
|
17
16
|
var C = _interopRequireWildcard(require("../../../i18n/constants"));
|
18
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
19
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -38,8 +37,11 @@ function columnLeftItem() {
|
|
38
37
|
if (!this.isColumnModificationAllowed()) {
|
39
38
|
return true;
|
40
39
|
}
|
41
|
-
var
|
42
|
-
if (!
|
40
|
+
var range = this.getSelectedRangeLast();
|
41
|
+
if (!range) {
|
42
|
+
return true;
|
43
|
+
}
|
44
|
+
if (range.isSingleHeader() && range.highlight.col < 0) {
|
43
45
|
return true;
|
44
46
|
}
|
45
47
|
if (this.selection.isSelectedByCorner()) {
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { getValidSelection } from "../utils.mjs";
|
2
1
|
import * as C from "../../../i18n/constants.mjs";
|
3
2
|
export var KEY = 'col_left';
|
4
3
|
|
@@ -20,8 +19,11 @@ export default function columnLeftItem() {
|
|
20
19
|
if (!this.isColumnModificationAllowed()) {
|
21
20
|
return true;
|
22
21
|
}
|
23
|
-
var
|
24
|
-
if (!
|
22
|
+
var range = this.getSelectedRangeLast();
|
23
|
+
if (!range) {
|
24
|
+
return true;
|
25
|
+
}
|
26
|
+
if (range.isSingleHeader() && range.highlight.col < 0) {
|
25
27
|
return true;
|
26
28
|
}
|
27
29
|
if (this.selection.isSelectedByCorner()) {
|
@@ -13,7 +13,6 @@ require("core-js/modules/es.symbol.iterator.js");
|
|
13
13
|
exports.__esModule = true;
|
14
14
|
exports.KEY = void 0;
|
15
15
|
exports.default = columnRightItem;
|
16
|
-
var _utils = require("../utils");
|
17
16
|
var C = _interopRequireWildcard(require("../../../i18n/constants"));
|
18
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
19
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -38,8 +37,11 @@ function columnRightItem() {
|
|
38
37
|
if (!this.isColumnModificationAllowed()) {
|
39
38
|
return true;
|
40
39
|
}
|
41
|
-
var
|
42
|
-
if (!
|
40
|
+
var range = this.getSelectedRangeLast();
|
41
|
+
if (!range) {
|
42
|
+
return true;
|
43
|
+
}
|
44
|
+
if (range.isSingleHeader() && range.highlight.col < 0) {
|
43
45
|
return true;
|
44
46
|
}
|
45
47
|
if (this.selection.isSelectedByCorner()) {
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { getValidSelection } from "../utils.mjs";
|
2
1
|
import * as C from "../../../i18n/constants.mjs";
|
3
2
|
export var KEY = 'col_right';
|
4
3
|
|
@@ -20,8 +19,11 @@ export default function columnRightItem() {
|
|
20
19
|
if (!this.isColumnModificationAllowed()) {
|
21
20
|
return true;
|
22
21
|
}
|
23
|
-
var
|
24
|
-
if (!
|
22
|
+
var range = this.getSelectedRangeLast();
|
23
|
+
if (!range) {
|
24
|
+
return true;
|
25
|
+
}
|
26
|
+
if (range.isSingleHeader() && range.highlight.col < 0) {
|
25
27
|
return true;
|
26
28
|
}
|
27
29
|
if (this.selection.isSelectedByCorner()) {
|
@@ -54,6 +54,13 @@ function readOnlyItem() {
|
|
54
54
|
this.render();
|
55
55
|
},
|
56
56
|
disabled: function disabled() {
|
57
|
+
var range = this.getSelectedRangeLast();
|
58
|
+
if (!range) {
|
59
|
+
return true;
|
60
|
+
}
|
61
|
+
if (range.isSingleHeader()) {
|
62
|
+
return true;
|
63
|
+
}
|
57
64
|
if (this.selection.isSelectedByCorner()) {
|
58
65
|
return true;
|
59
66
|
}
|