handsontable 0.0.0-next-6d7bdba-20230620 → 0.0.0-next-af5139c-20230620

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.

Files changed (57) hide show
  1. package/base.js +2 -2
  2. package/base.mjs +2 -2
  3. package/dist/handsontable.css +2 -2
  4. package/dist/handsontable.full.css +2 -2
  5. package/dist/handsontable.full.js +2066 -2286
  6. package/dist/handsontable.full.min.css +2 -2
  7. package/dist/handsontable.full.min.js +77 -77
  8. package/dist/handsontable.js +1982 -2202
  9. package/dist/handsontable.min.css +2 -2
  10. package/dist/handsontable.min.js +4 -4
  11. package/helpers/mixed.js +1 -1
  12. package/helpers/mixed.mjs +1 -1
  13. package/package.json +1 -1
  14. package/plugins/comments/comments.js +4 -11
  15. package/plugins/comments/comments.mjs +4 -11
  16. package/plugins/contextMenu/contextMenu.d.ts +1 -1
  17. package/plugins/contextMenu/contextMenu.js +29 -80
  18. package/plugins/contextMenu/contextMenu.mjs +30 -81
  19. package/plugins/contextMenu/predefinedItems/alignment.js +0 -7
  20. package/plugins/contextMenu/predefinedItems/alignment.mjs +0 -7
  21. package/plugins/contextMenu/predefinedItems/clearColumn.js +3 -5
  22. package/plugins/contextMenu/predefinedItems/clearColumn.mjs +3 -5
  23. package/plugins/contextMenu/predefinedItems/columnLeft.js +3 -5
  24. package/plugins/contextMenu/predefinedItems/columnLeft.mjs +3 -5
  25. package/plugins/contextMenu/predefinedItems/columnRight.js +3 -5
  26. package/plugins/contextMenu/predefinedItems/columnRight.mjs +3 -5
  27. package/plugins/contextMenu/predefinedItems/readOnly.js +0 -7
  28. package/plugins/contextMenu/predefinedItems/readOnly.mjs +0 -7
  29. package/plugins/contextMenu/predefinedItems/removeColumn.js +5 -7
  30. package/plugins/contextMenu/predefinedItems/removeColumn.mjs +3 -5
  31. package/plugins/contextMenu/predefinedItems/removeRow.js +5 -7
  32. package/plugins/contextMenu/predefinedItems/removeRow.mjs +3 -5
  33. package/plugins/contextMenu/predefinedItems/rowAbove.js +3 -5
  34. package/plugins/contextMenu/predefinedItems/rowAbove.mjs +3 -5
  35. package/plugins/contextMenu/predefinedItems/rowBelow.js +3 -5
  36. package/plugins/contextMenu/predefinedItems/rowBelow.mjs +3 -5
  37. package/plugins/contextMenu/utils.js +16 -25
  38. package/plugins/contextMenu/utils.mjs +15 -24
  39. package/plugins/copyPaste/contextMenuItem/copy.js +0 -7
  40. package/plugins/copyPaste/contextMenuItem/copy.mjs +0 -7
  41. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +1 -9
  42. package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +1 -9
  43. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +1 -9
  44. package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +1 -9
  45. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +1 -9
  46. package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +1 -9
  47. package/plugins/copyPaste/contextMenuItem/cut.js +0 -7
  48. package/plugins/copyPaste/contextMenuItem/cut.mjs +0 -7
  49. package/plugins/customBorders/customBorders.js +0 -7
  50. package/plugins/customBorders/customBorders.mjs +0 -7
  51. package/plugins/dropdownMenu/dropdownMenu.d.ts +1 -1
  52. package/plugins/dropdownMenu/dropdownMenu.js +30 -94
  53. package/plugins/dropdownMenu/dropdownMenu.mjs +30 -94
  54. package/shortcuts/recorder.js +2 -2
  55. package/shortcuts/recorder.mjs +2 -2
  56. package/shortcuts/utils.js +5 -21
  57. package/shortcuts/utils.mjs +4 -20
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-6d7bdba-20230620";
155
+ var hotVersion = "0.0.0-next-af5139c-20230620";
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-6d7bdba-20230620";
145
+ var hotVersion = "0.0.0-next-af5139c-20230620";
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-6d7bdba-20230620",
13
+ "version": "0.0.0-next-af5139c-20230620",
14
14
  "main": "index",
15
15
  "module": "index.mjs",
16
16
  "jsnext:main": "index.mjs",
@@ -835,14 +835,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
835
835
  key: "addToContextMenu",
836
836
  value: function addToContextMenu(defaultOptions) {
837
837
  var _this6 = this;
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
- }
838
+ var isThereAnyCellRendered = function isThereAnyCellRendered() {
846
839
  return _this6.hot.rowIndexMapper.getRenderableIndexesLength() > 0 && _this6.hot.columnIndexMapper.getRenderableIndexesLength() > 0;
847
840
  };
848
841
  defaultOptions.items.push({
@@ -859,7 +852,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
859
852
  return _this6.onContextMenuAddComment();
860
853
  },
861
854
  disabled: function disabled() {
862
- if (!isThereAnySelectedCellToProcess()) {
855
+ if (!isThereAnyCellRendered()) {
863
856
  return true;
864
857
  }
865
858
  return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
@@ -873,7 +866,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
873
866
  return _this6.onContextMenuRemoveComment();
874
867
  },
875
868
  disabled: function disabled() {
876
- if (!isThereAnySelectedCellToProcess()) {
869
+ if (!isThereAnyCellRendered()) {
877
870
  return true;
878
871
  }
879
872
  return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
@@ -901,7 +894,7 @@ var Comments = /*#__PURE__*/function (_BasePlugin) {
901
894
  return _this6.onContextMenuMakeReadOnly();
902
895
  },
903
896
  disabled: function disabled() {
904
- if (!isThereAnySelectedCellToProcess()) {
897
+ if (!isThereAnyCellRendered()) {
905
898
  return true;
906
899
  }
907
900
  return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner()) || !_this6.checkSelectionCommentsConsistency();
@@ -826,14 +826,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
826
826
  key: "addToContextMenu",
827
827
  value: function addToContextMenu(defaultOptions) {
828
828
  var _this6 = this;
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
- }
829
+ var isThereAnyCellRendered = function isThereAnyCellRendered() {
837
830
  return _this6.hot.rowIndexMapper.getRenderableIndexesLength() > 0 && _this6.hot.columnIndexMapper.getRenderableIndexesLength() > 0;
838
831
  };
839
832
  defaultOptions.items.push({
@@ -850,7 +843,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
850
843
  return _this6.onContextMenuAddComment();
851
844
  },
852
845
  disabled: function disabled() {
853
- if (!isThereAnySelectedCellToProcess()) {
846
+ if (!isThereAnyCellRendered()) {
854
847
  return true;
855
848
  }
856
849
  return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
@@ -864,7 +857,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
864
857
  return _this6.onContextMenuRemoveComment();
865
858
  },
866
859
  disabled: function disabled() {
867
- if (!isThereAnySelectedCellToProcess()) {
860
+ if (!isThereAnyCellRendered()) {
868
861
  return true;
869
862
  }
870
863
  return !(_this6.hot.getSelectedLast() && !_this6.hot.selection.isSelectedByCorner());
@@ -892,7 +885,7 @@ export var Comments = /*#__PURE__*/function (_BasePlugin) {
892
885
  return _this6.onContextMenuMakeReadOnly();
893
886
  },
894
887
  disabled: function disabled() {
895
- if (!isThereAnySelectedCellToProcess()) {
888
+ if (!isThereAnyCellRendered()) {
896
889
  return true;
897
890
  }
898
891
  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(position: { left: number, top: number } | Event, offset?: { above?: number, below?: number, left?: number, right?: number }): void;
63
+ open(event: Event): void;
64
64
  close(): void;
65
65
  executeCommand(commandName: string, ...params: any): void;
66
66
  }
@@ -22,12 +22,10 @@ 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");
26
25
  var _commandExecutor = _interopRequireDefault(require("./commandExecutor"));
27
26
  var _eventManager = _interopRequireDefault(require("../../eventManager"));
28
27
  var _itemsFactory = _interopRequireDefault(require("./itemsFactory"));
29
28
  var _menu = _interopRequireDefault(require("./menu"));
30
- var _utils = require("./utils");
31
29
  var _element = require("../../helpers/dom/element");
32
30
  var _predefinedItems = require("./predefinedItems");
33
31
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -49,7 +47,6 @@ var PLUGIN_KEY = 'contextMenu';
49
47
  exports.PLUGIN_KEY = PLUGIN_KEY;
50
48
  var PLUGIN_PRIORITY = 70;
51
49
  exports.PLUGIN_PRIORITY = PLUGIN_PRIORITY;
52
- var SHORTCUTS_GROUP = PLUGIN_KEY;
53
50
  _pluginHooks.default.getSingleton().register('afterContextMenuDefaultOptions');
54
51
  _pluginHooks.default.getSingleton().register('beforeContextMenuShow');
55
52
  _pluginHooks.default.getSingleton().register('afterContextMenuShow');
@@ -171,7 +168,6 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
171
168
  this.addHook('afterOnCellContextMenu', function (event) {
172
169
  return _this2.onAfterOnCellContextMenu(event);
173
170
  });
174
- this.registerShortcuts();
175
171
  _get(_getPrototypeOf(ContextMenu.prototype), "enablePlugin", this).call(this);
176
172
  }
177
173
 
@@ -186,7 +182,6 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
186
182
  value: function updatePlugin() {
187
183
  this.disablePlugin();
188
184
  this.enablePlugin();
189
- this.unregisterShortcuts();
190
185
  _get(_getPrototypeOf(ContextMenu.prototype), "updatePlugin", this).call(this);
191
186
  }
192
187
 
@@ -204,83 +199,39 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
204
199
  _get(_getPrototypeOf(ContextMenu.prototype), "disablePlugin", this).call(this);
205
200
  }
206
201
 
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
-
252
202
  /**
253
203
  * Opens menu and re-position it based on the passed coordinates.
254
204
  *
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
205
+ * @param {Event} event The mouse event object.
263
206
  */
264
207
  }, {
265
208
  key: "open",
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()) {
209
+ value: function open(event) {
210
+ if (!this.menu) {
276
211
  return;
277
212
  }
278
213
  this.prepareMenuItems();
279
214
  this.menu.open();
280
- (0, _object.objectEach)(offset, function (value, key) {
281
- _this4.menu.setOffset(key, value);
215
+ if (!this.menu.isOpened()) {
216
+ return;
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
282
234
  });
283
- this.menu.setPosition(position);
284
235
  }
285
236
 
286
237
  /**
@@ -289,8 +240,10 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
289
240
  }, {
290
241
  key: "close",
291
242
  value: function close() {
292
- var _this$menu2;
293
- (_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
243
+ if (!this.menu) {
244
+ return;
245
+ }
246
+ this.menu.close();
294
247
  this.itemsFactory = null;
295
248
  }
296
249
 
@@ -347,7 +300,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
347
300
  }, {
348
301
  key: "prepareMenuItems",
349
302
  value: function prepareMenuItems() {
350
- var _this5 = this;
303
+ var _this3 = this;
351
304
  this.itemsFactory = new _itemsFactory.default(this.hot, ContextMenu.DEFAULT_ITEMS);
352
305
  var settings = this.hot.getSettings()[PLUGIN_KEY];
353
306
  var predefinedItems = {
@@ -361,7 +314,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
361
314
 
362
315
  // Register all commands. Predefined and added by user or by plugins
363
316
  (0, _array.arrayEach)(menuItems, function (command) {
364
- return _this5.commandExecutor.registerCommand(command.key, command);
317
+ return _this3.commandExecutor.registerCommand(command.key, command);
365
318
  });
366
319
  }
367
320
 
@@ -398,11 +351,7 @@ var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
398
351
  return;
399
352
  }
400
353
  }
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
- });
354
+ this.open(event);
406
355
  }
407
356
 
408
357
  /**
@@ -32,17 +32,14 @@ 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";
36
35
  import CommandExecutor from "./commandExecutor.mjs";
37
36
  import EventManager from "../../eventManager.mjs";
38
37
  import ItemsFactory from "./itemsFactory.mjs";
39
38
  import Menu from "./menu.mjs";
40
- import { getDocumentOffsetByElement } from "./utils.mjs";
41
- import { hasClass } from "../../helpers/dom/element.mjs";
39
+ import { getWindowScrollLeft, getWindowScrollTop, hasClass } from "../../helpers/dom/element.mjs";
42
40
  import { ROW_ABOVE, ROW_BELOW, COLUMN_LEFT, COLUMN_RIGHT, REMOVE_ROW, REMOVE_COLUMN, UNDO, REDO, READ_ONLY, ALIGNMENT, SEPARATOR } from "./predefinedItems.mjs";
43
41
  export var PLUGIN_KEY = 'contextMenu';
44
42
  export var PLUGIN_PRIORITY = 70;
45
- var SHORTCUTS_GROUP = PLUGIN_KEY;
46
43
  Hooks.getSingleton().register('afterContextMenuDefaultOptions');
47
44
  Hooks.getSingleton().register('beforeContextMenuShow');
48
45
  Hooks.getSingleton().register('afterContextMenuShow');
@@ -164,7 +161,6 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
164
161
  this.addHook('afterOnCellContextMenu', function (event) {
165
162
  return _this2.onAfterOnCellContextMenu(event);
166
163
  });
167
- this.registerShortcuts();
168
164
  _get(_getPrototypeOf(ContextMenu.prototype), "enablePlugin", this).call(this);
169
165
  }
170
166
 
@@ -179,7 +175,6 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
179
175
  value: function updatePlugin() {
180
176
  this.disablePlugin();
181
177
  this.enablePlugin();
182
- this.unregisterShortcuts();
183
178
  _get(_getPrototypeOf(ContextMenu.prototype), "updatePlugin", this).call(this);
184
179
  }
185
180
 
@@ -197,83 +192,39 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
197
192
  _get(_getPrototypeOf(ContextMenu.prototype), "disablePlugin", this).call(this);
198
193
  }
199
194
 
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
-
245
195
  /**
246
196
  * Opens menu and re-position it based on the passed coordinates.
247
197
  *
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
198
+ * @param {Event} event The mouse event object.
256
199
  */
257
200
  }, {
258
201
  key: "open",
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()) {
202
+ value: function open(event) {
203
+ if (!this.menu) {
269
204
  return;
270
205
  }
271
206
  this.prepareMenuItems();
272
207
  this.menu.open();
273
- objectEach(offset, function (value, key) {
274
- _this4.menu.setOffset(key, value);
208
+ if (!this.menu.isOpened()) {
209
+ return;
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
275
227
  });
276
- this.menu.setPosition(position);
277
228
  }
278
229
 
279
230
  /**
@@ -282,8 +233,10 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
282
233
  }, {
283
234
  key: "close",
284
235
  value: function close() {
285
- var _this$menu2;
286
- (_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
236
+ if (!this.menu) {
237
+ return;
238
+ }
239
+ this.menu.close();
287
240
  this.itemsFactory = null;
288
241
  }
289
242
 
@@ -340,7 +293,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
340
293
  }, {
341
294
  key: "prepareMenuItems",
342
295
  value: function prepareMenuItems() {
343
- var _this5 = this;
296
+ var _this3 = this;
344
297
  this.itemsFactory = new ItemsFactory(this.hot, ContextMenu.DEFAULT_ITEMS);
345
298
  var settings = this.hot.getSettings()[PLUGIN_KEY];
346
299
  var predefinedItems = {
@@ -354,7 +307,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
354
307
 
355
308
  // Register all commands. Predefined and added by user or by plugins
356
309
  arrayEach(menuItems, function (command) {
357
- return _this5.commandExecutor.registerCommand(command.key, command);
310
+ return _this3.commandExecutor.registerCommand(command.key, command);
358
311
  });
359
312
  }
360
313
 
@@ -391,11 +344,7 @@ export var ContextMenu = /*#__PURE__*/function (_BasePlugin) {
391
344
  return;
392
345
  }
393
346
  }
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
- });
347
+ this.open(event);
399
348
  }
400
349
 
401
350
  /**
@@ -35,13 +35,6 @@ 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
- }
45
38
  return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
46
39
  },
47
40
  submenu: {
@@ -17,13 +17,6 @@ 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
- }
27
20
  return !(this.getSelectedRange() && !this.selection.isSelectedByCorner());
28
21
  },
29
22
  submenu: {
@@ -13,6 +13,7 @@ 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");
16
17
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
17
18
  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); }
18
19
  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; }
@@ -36,11 +37,8 @@ function clearColumnItem() {
36
37
  }
37
38
  },
38
39
  disabled: function disabled() {
39
- var range = this.getSelectedRangeLast();
40
- if (!range) {
41
- return true;
42
- }
43
- if (range.isSingleHeader() && range.highlight.col < 0) {
40
+ var selected = (0, _utils.getValidSelection)(this);
41
+ if (!selected) {
44
42
  return true;
45
43
  }
46
44
  return !this.selection.isSelectedByColumnHeader();
@@ -1,3 +1,4 @@
1
+ import { getValidSelection } from "../utils.mjs";
1
2
  import * as C from "../../../i18n/constants.mjs";
2
3
  export var KEY = 'clear_column';
3
4
 
@@ -18,11 +19,8 @@ export default function clearColumnItem() {
18
19
  }
19
20
  },
20
21
  disabled: function disabled() {
21
- var range = this.getSelectedRangeLast();
22
- if (!range) {
23
- return true;
24
- }
25
- if (range.isSingleHeader() && range.highlight.col < 0) {
22
+ var selected = getValidSelection(this);
23
+ if (!selected) {
26
24
  return true;
27
25
  }
28
26
  return !this.selection.isSelectedByColumnHeader();
@@ -13,6 +13,7 @@ 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");
16
17
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
17
18
  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); }
18
19
  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,11 +38,8 @@ function columnLeftItem() {
37
38
  if (!this.isColumnModificationAllowed()) {
38
39
  return true;
39
40
  }
40
- var range = this.getSelectedRangeLast();
41
- if (!range) {
42
- return true;
43
- }
44
- if (range.isSingleHeader() && range.highlight.col < 0) {
41
+ var selected = (0, _utils.getValidSelection)(this);
42
+ if (!selected) {
45
43
  return true;
46
44
  }
47
45
  if (this.selection.isSelectedByCorner()) {
@@ -1,3 +1,4 @@
1
+ import { getValidSelection } from "../utils.mjs";
1
2
  import * as C from "../../../i18n/constants.mjs";
2
3
  export var KEY = 'col_left';
3
4
 
@@ -19,11 +20,8 @@ export default function columnLeftItem() {
19
20
  if (!this.isColumnModificationAllowed()) {
20
21
  return true;
21
22
  }
22
- var range = this.getSelectedRangeLast();
23
- if (!range) {
24
- return true;
25
- }
26
- if (range.isSingleHeader() && range.highlight.col < 0) {
23
+ var selected = getValidSelection(this);
24
+ if (!selected) {
27
25
  return true;
28
26
  }
29
27
  if (this.selection.isSelectedByCorner()) {
@@ -13,6 +13,7 @@ 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");
16
17
  var C = _interopRequireWildcard(require("../../../i18n/constants"));
17
18
  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); }
18
19
  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,11 +38,8 @@ function columnRightItem() {
37
38
  if (!this.isColumnModificationAllowed()) {
38
39
  return true;
39
40
  }
40
- var range = this.getSelectedRangeLast();
41
- if (!range) {
42
- return true;
43
- }
44
- if (range.isSingleHeader() && range.highlight.col < 0) {
41
+ var selected = (0, _utils.getValidSelection)(this);
42
+ if (!selected) {
45
43
  return true;
46
44
  }
47
45
  if (this.selection.isSelectedByCorner()) {
@@ -1,3 +1,4 @@
1
+ import { getValidSelection } from "../utils.mjs";
1
2
  import * as C from "../../../i18n/constants.mjs";
2
3
  export var KEY = 'col_right';
3
4
 
@@ -19,11 +20,8 @@ export default function columnRightItem() {
19
20
  if (!this.isColumnModificationAllowed()) {
20
21
  return true;
21
22
  }
22
- var range = this.getSelectedRangeLast();
23
- if (!range) {
24
- return true;
25
- }
26
- if (range.isSingleHeader() && range.highlight.col < 0) {
23
+ var selected = getValidSelection(this);
24
+ if (!selected) {
27
25
  return true;
28
26
  }
29
27
  if (this.selection.isSelectedByCorner()) {
@@ -54,13 +54,6 @@ 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
- }
64
57
  if (this.selection.isSelectedByCorner()) {
65
58
  return true;
66
59
  }