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
@@ -22,9 +22,7 @@ require("core-js/modules/es.object.set-prototype-of.js");
22
22
  require("core-js/modules/es.object.get-prototype-of.js");
23
23
  var _base = require("../base");
24
24
  var _array = require("../../helpers/array");
25
- var _object = require("../../helpers/object");
26
25
  var _commandExecutor = _interopRequireDefault(require("../contextMenu/commandExecutor"));
27
- var _utils = require("../contextMenu/utils");
28
26
  var _eventManager = _interopRequireDefault(require("../../eventManager"));
29
27
  var _element = require("../../helpers/dom/element");
30
28
  var _itemsFactory = _interopRequireDefault(require("../contextMenu/itemsFactory"));
@@ -56,7 +54,6 @@ exports.PLUGIN_KEY = PLUGIN_KEY;
56
54
  var PLUGIN_PRIORITY = 230;
57
55
  exports.PLUGIN_PRIORITY = PLUGIN_PRIORITY;
58
56
  var BUTTON_CLASS_NAME = 'changeType';
59
- var SHORTCUTS_GROUP = PLUGIN_KEY;
60
57
 
61
58
  /* eslint-disable jsdoc/require-description-complete-sentence */
62
59
  /**
@@ -185,7 +182,6 @@ var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
185
182
  if (typeof settings.callback === 'function') {
186
183
  this.commandExecutor.setCommonCallback(settings.callback);
187
184
  }
188
- this.registerShortcuts();
189
185
  _get(_getPrototypeOf(DropdownMenu.prototype), "enablePlugin", this).call(this);
190
186
  this.callOnPluginsReady(function () {
191
187
  _this2.hot.runHooks('afterDropdownMenuDefaultOptions', predefinedItems);
@@ -249,71 +245,9 @@ var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
249
245
  if (this.menu) {
250
246
  this.menu.destroy();
251
247
  }
252
- this.unregisterShortcuts();
253
248
  _get(_getPrototypeOf(DropdownMenu.prototype), "disablePlugin", this).call(this);
254
249
  }
255
250
 
256
- /**
257
- * Register shortcuts responsible for toggling dropdown menu.
258
- *
259
- * @private
260
- */
261
- }, {
262
- key: "registerShortcuts",
263
- value: function registerShortcuts() {
264
- var _this3 = this;
265
- var context = this.hot.getShortcutManager().getContext('grid');
266
- var callback = function callback() {
267
- var _this3$hot$getSelecte = _this3.hot.getSelectedRangeLast(),
268
- highlight = _this3$hot$getSelecte.highlight;
269
- if ((highlight.isHeader() && highlight.row === -1 || highlight.isCell()) && highlight.col >= 0) {
270
- _this3.hot.selectColumns(highlight.col, highlight.col, -1);
271
- var _this3$hot$getSelecte2 = _this3.hot.getSelectedRangeLast(),
272
- from = _this3$hot$getSelecte2.from;
273
- var offset = (0, _utils.getDocumentOffsetByElement)(_this3.menu.container, _this3.hot.rootDocument);
274
- var target = _this3.hot.getCell(-1, from.col, true);
275
- var rect = target.getBoundingClientRect();
276
- _this3.open({
277
- left: rect.left + offset.left,
278
- top: rect.top + target.offsetHeight + offset.top
279
- }, {
280
- left: rect.width
281
- });
282
- _this3.hot._registerTimeout(function () {
283
- _this3.menu.selectFirstCell();
284
- });
285
- }
286
- };
287
- context.addShortcuts([{
288
- keys: [['Shift', 'Alt', 'ArrowDown'], ['Shift', 'Enter']],
289
- callback: callback,
290
- runOnlyIf: function runOnlyIf() {
291
- var _this3$hot$getSelecte3;
292
- return ((_this3$hot$getSelecte3 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte3 === void 0 ? void 0 : _this3$hot$getSelecte3.highlight.isHeader()) && !_this3.menu.isOpened();
293
- },
294
- group: SHORTCUTS_GROUP
295
- }, {
296
- keys: [['Shift', 'Alt', 'ArrowDown']],
297
- callback: callback,
298
- runOnlyIf: function runOnlyIf() {
299
- var _this3$hot$getSelecte4;
300
- return ((_this3$hot$getSelecte4 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte4 === void 0 ? void 0 : _this3$hot$getSelecte4.highlight.isCell()) && !_this3.menu.isOpened();
301
- },
302
- group: SHORTCUTS_GROUP
303
- }]);
304
- }
305
-
306
- /**
307
- * Unregister shortcuts responsible for toggling dropdown menu.
308
- *
309
- * @private
310
- */
311
- }, {
312
- key: "unregisterShortcuts",
313
- value: function unregisterShortcuts() {
314
- this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
315
- }
316
-
317
251
  /**
318
252
  * Registers the DOM listeners.
319
253
  *
@@ -322,42 +256,33 @@ var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
322
256
  }, {
323
257
  key: "registerEvents",
324
258
  value: function registerEvents() {
325
- var _this4 = this;
259
+ var _this3 = this;
326
260
  this.eventManager.addEventListener(this.hot.rootElement, 'click', function (event) {
327
- return _this4.onTableClick(event);
261
+ return _this3.onTableClick(event);
328
262
  });
329
263
  }
330
264
 
331
265
  /**
332
266
  * Opens menu and re-position it based on the passed coordinates.
333
267
  *
334
- * @param {{ top: number, left: number }|Event} position An object with `top` and `left` properties
335
- * which contains coordinates relative to the browsers viewport (without included scroll offsets).
336
- * Or if the native event is passed the menu will be positioned based on the `pageX` and `pageY`
337
- * coordinates.
338
- * @param {{ above?: number, below?: number, left?: number, right?: number }} offset An object allows applying
339
- * the offset to the menu position.
268
+ * @param {object|Event} position An object with `pageX` and `pageY` properties which contains values relative to
269
+ * the top left of the fully rendered content area in the browser or with `clientX`
270
+ * and `clientY` properties which contains values relative to the upper left edge
271
+ * of the content area (the viewport) of the browser window. This object is structurally
272
+ * compatible with native mouse event so it can be used either.
340
273
  * @fires Hooks#beforeDropdownMenuShow
341
274
  * @fires Hooks#afterDropdownMenuShow
342
275
  */
343
276
  }, {
344
277
  key: "open",
345
278
  value: function open(position) {
346
- var _this$menu,
347
- _this5 = this;
348
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
349
- above: 0,
350
- below: 0,
351
- left: 0,
352
- right: 0
353
- };
354
- if ((_this$menu = this.menu) !== null && _this$menu !== void 0 && _this$menu.isOpened()) {
279
+ if (!this.menu) {
355
280
  return;
356
281
  }
357
282
  this.menu.open();
358
- (0, _object.objectEach)(offset, function (value, key) {
359
- _this5.menu.setOffset(key, value);
360
- });
283
+ if (position.width) {
284
+ this.menu.setOffset('left', position.width);
285
+ }
361
286
  this.menu.setPosition(position);
362
287
  }
363
288
 
@@ -367,8 +292,10 @@ var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
367
292
  }, {
368
293
  key: "close",
369
294
  value: function close() {
370
- var _this$menu2;
371
- (_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
295
+ if (!this.menu) {
296
+ return;
297
+ }
298
+ this.menu.close();
372
299
  }
373
300
 
374
301
  /**
@@ -440,14 +367,23 @@ var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
440
367
  key: "onTableClick",
441
368
  value: function onTableClick(event) {
442
369
  event.stopPropagation();
443
- if ((0, _element.hasClass)(event.target, BUTTON_CLASS_NAME)) {
444
- var offset = (0, _utils.getDocumentOffsetByElement)(this.menu.container, this.hot.rootDocument);
370
+ if ((0, _element.hasClass)(event.target, BUTTON_CLASS_NAME) && !this.menu.isOpened()) {
371
+ var offsetTop = 0;
372
+ var offsetLeft = 0;
373
+ if (this.hot.rootDocument !== this.menu.container.ownerDocument) {
374
+ var frameElement = this.hot.rootWindow.frameElement;
375
+ var _frameElement$getBoun = frameElement.getBoundingClientRect(),
376
+ top = _frameElement$getBoun.top,
377
+ left = _frameElement$getBoun.left;
378
+ offsetTop = top;
379
+ offsetLeft = left;
380
+ }
445
381
  var rect = event.target.getBoundingClientRect();
446
382
  this.open({
447
- left: rect.left + offset.left,
448
- top: rect.top + event.target.offsetHeight + 3 + offset.top
449
- }, {
450
- left: rect.width
383
+ left: rect.left + offsetLeft,
384
+ top: rect.top + event.target.offsetHeight + 3 + offsetTop,
385
+ width: rect.width,
386
+ height: rect.height
451
387
  });
452
388
  }
453
389
  }
@@ -32,9 +32,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
32
32
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
33
33
  import { BasePlugin } from "../base/index.mjs";
34
34
  import { arrayEach } from "../../helpers/array.mjs";
35
- import { objectEach } from "../../helpers/object.mjs";
36
35
  import CommandExecutor from "../contextMenu/commandExecutor.mjs";
37
- import { getDocumentOffsetByElement } from "../contextMenu/utils.mjs";
38
36
  import EventManager from "../../eventManager.mjs";
39
37
  import { hasClass } from "../../helpers/dom/element.mjs";
40
38
  import ItemsFactory from "../contextMenu/itemsFactory.mjs";
@@ -49,7 +47,6 @@ Hooks.getSingleton().register('afterDropdownMenuExecute');
49
47
  export var PLUGIN_KEY = 'dropdownMenu';
50
48
  export var PLUGIN_PRIORITY = 230;
51
49
  var BUTTON_CLASS_NAME = 'changeType';
52
- var SHORTCUTS_GROUP = PLUGIN_KEY;
53
50
 
54
51
  /* eslint-disable jsdoc/require-description-complete-sentence */
55
52
  /**
@@ -179,7 +176,6 @@ export var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
179
176
  if (typeof settings.callback === 'function') {
180
177
  this.commandExecutor.setCommonCallback(settings.callback);
181
178
  }
182
- this.registerShortcuts();
183
179
  _get(_getPrototypeOf(DropdownMenu.prototype), "enablePlugin", this).call(this);
184
180
  this.callOnPluginsReady(function () {
185
181
  _this2.hot.runHooks('afterDropdownMenuDefaultOptions', predefinedItems);
@@ -243,71 +239,9 @@ export var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
243
239
  if (this.menu) {
244
240
  this.menu.destroy();
245
241
  }
246
- this.unregisterShortcuts();
247
242
  _get(_getPrototypeOf(DropdownMenu.prototype), "disablePlugin", this).call(this);
248
243
  }
249
244
 
250
- /**
251
- * Register shortcuts responsible for toggling dropdown menu.
252
- *
253
- * @private
254
- */
255
- }, {
256
- key: "registerShortcuts",
257
- value: function registerShortcuts() {
258
- var _this3 = this;
259
- var context = this.hot.getShortcutManager().getContext('grid');
260
- var callback = function callback() {
261
- var _this3$hot$getSelecte = _this3.hot.getSelectedRangeLast(),
262
- highlight = _this3$hot$getSelecte.highlight;
263
- if ((highlight.isHeader() && highlight.row === -1 || highlight.isCell()) && highlight.col >= 0) {
264
- _this3.hot.selectColumns(highlight.col, highlight.col, -1);
265
- var _this3$hot$getSelecte2 = _this3.hot.getSelectedRangeLast(),
266
- from = _this3$hot$getSelecte2.from;
267
- var offset = getDocumentOffsetByElement(_this3.menu.container, _this3.hot.rootDocument);
268
- var target = _this3.hot.getCell(-1, from.col, true);
269
- var rect = target.getBoundingClientRect();
270
- _this3.open({
271
- left: rect.left + offset.left,
272
- top: rect.top + target.offsetHeight + offset.top
273
- }, {
274
- left: rect.width
275
- });
276
- _this3.hot._registerTimeout(function () {
277
- _this3.menu.selectFirstCell();
278
- });
279
- }
280
- };
281
- context.addShortcuts([{
282
- keys: [['Shift', 'Alt', 'ArrowDown'], ['Shift', 'Enter']],
283
- callback: callback,
284
- runOnlyIf: function runOnlyIf() {
285
- var _this3$hot$getSelecte3;
286
- return ((_this3$hot$getSelecte3 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte3 === void 0 ? void 0 : _this3$hot$getSelecte3.highlight.isHeader()) && !_this3.menu.isOpened();
287
- },
288
- group: SHORTCUTS_GROUP
289
- }, {
290
- keys: [['Shift', 'Alt', 'ArrowDown']],
291
- callback: callback,
292
- runOnlyIf: function runOnlyIf() {
293
- var _this3$hot$getSelecte4;
294
- return ((_this3$hot$getSelecte4 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte4 === void 0 ? void 0 : _this3$hot$getSelecte4.highlight.isCell()) && !_this3.menu.isOpened();
295
- },
296
- group: SHORTCUTS_GROUP
297
- }]);
298
- }
299
-
300
- /**
301
- * Unregister shortcuts responsible for toggling dropdown menu.
302
- *
303
- * @private
304
- */
305
- }, {
306
- key: "unregisterShortcuts",
307
- value: function unregisterShortcuts() {
308
- this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
309
- }
310
-
311
245
  /**
312
246
  * Registers the DOM listeners.
313
247
  *
@@ -316,42 +250,33 @@ export var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
316
250
  }, {
317
251
  key: "registerEvents",
318
252
  value: function registerEvents() {
319
- var _this4 = this;
253
+ var _this3 = this;
320
254
  this.eventManager.addEventListener(this.hot.rootElement, 'click', function (event) {
321
- return _this4.onTableClick(event);
255
+ return _this3.onTableClick(event);
322
256
  });
323
257
  }
324
258
 
325
259
  /**
326
260
  * Opens menu and re-position it based on the passed coordinates.
327
261
  *
328
- * @param {{ top: number, left: number }|Event} position An object with `top` and `left` properties
329
- * which contains coordinates relative to the browsers viewport (without included scroll offsets).
330
- * Or if the native event is passed the menu will be positioned based on the `pageX` and `pageY`
331
- * coordinates.
332
- * @param {{ above?: number, below?: number, left?: number, right?: number }} offset An object allows applying
333
- * the offset to the menu position.
262
+ * @param {object|Event} position An object with `pageX` and `pageY` properties which contains values relative to
263
+ * the top left of the fully rendered content area in the browser or with `clientX`
264
+ * and `clientY` properties which contains values relative to the upper left edge
265
+ * of the content area (the viewport) of the browser window. This object is structurally
266
+ * compatible with native mouse event so it can be used either.
334
267
  * @fires Hooks#beforeDropdownMenuShow
335
268
  * @fires Hooks#afterDropdownMenuShow
336
269
  */
337
270
  }, {
338
271
  key: "open",
339
272
  value: function open(position) {
340
- var _this$menu,
341
- _this5 = this;
342
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
343
- above: 0,
344
- below: 0,
345
- left: 0,
346
- right: 0
347
- };
348
- if ((_this$menu = this.menu) !== null && _this$menu !== void 0 && _this$menu.isOpened()) {
273
+ if (!this.menu) {
349
274
  return;
350
275
  }
351
276
  this.menu.open();
352
- objectEach(offset, function (value, key) {
353
- _this5.menu.setOffset(key, value);
354
- });
277
+ if (position.width) {
278
+ this.menu.setOffset('left', position.width);
279
+ }
355
280
  this.menu.setPosition(position);
356
281
  }
357
282
 
@@ -361,8 +286,10 @@ export var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
361
286
  }, {
362
287
  key: "close",
363
288
  value: function close() {
364
- var _this$menu2;
365
- (_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
289
+ if (!this.menu) {
290
+ return;
291
+ }
292
+ this.menu.close();
366
293
  }
367
294
 
368
295
  /**
@@ -434,14 +361,23 @@ export var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
434
361
  key: "onTableClick",
435
362
  value: function onTableClick(event) {
436
363
  event.stopPropagation();
437
- if (hasClass(event.target, BUTTON_CLASS_NAME)) {
438
- var offset = getDocumentOffsetByElement(this.menu.container, this.hot.rootDocument);
364
+ if (hasClass(event.target, BUTTON_CLASS_NAME) && !this.menu.isOpened()) {
365
+ var offsetTop = 0;
366
+ var offsetLeft = 0;
367
+ if (this.hot.rootDocument !== this.menu.container.ownerDocument) {
368
+ var frameElement = this.hot.rootWindow.frameElement;
369
+ var _frameElement$getBoun = frameElement.getBoundingClientRect(),
370
+ top = _frameElement$getBoun.top,
371
+ left = _frameElement$getBoun.left;
372
+ offsetTop = top;
373
+ offsetLeft = left;
374
+ }
439
375
  var rect = event.target.getBoundingClientRect();
440
376
  this.open({
441
- left: rect.left + offset.left,
442
- top: rect.top + event.target.offsetHeight + 3 + offset.top
443
- }, {
444
- left: rect.width
377
+ left: rect.left + offsetLeft,
378
+ top: rect.top + event.target.offsetHeight + 3 + offsetTop,
379
+ width: rect.width,
380
+ height: rect.height
445
381
  });
446
382
  }
447
383
  }
@@ -88,7 +88,7 @@ function useRecorder(ownerWindow, handleEvent, beforeKeyDown, afterKeyDown, call
88
88
  if (event.keyCode === 229 || result === false || (0, _event.isImmediatePropagationStopped)(event)) {
89
89
  return;
90
90
  }
91
- var pressedKey = (0, _utils.normalizeEventKey)(event);
91
+ var pressedKey = (0, _utils.normalizeEventKey)(event.key);
92
92
  var extraModifierKeys = [];
93
93
  if (isModifierKey(pressedKey)) {
94
94
  modifierKeysObserver.press(pressedKey);
@@ -114,7 +114,7 @@ function useRecorder(ownerWindow, handleEvent, beforeKeyDown, afterKeyDown, call
114
114
  if (handleEvent(event) === false) {
115
115
  return;
116
116
  }
117
- var pressedKey = (0, _utils.normalizeEventKey)(event);
117
+ var pressedKey = (0, _utils.normalizeEventKey)(event.key);
118
118
  if (isModifierKey(pressedKey) === false) {
119
119
  return;
120
120
  }
@@ -84,7 +84,7 @@ export function useRecorder(ownerWindow, handleEvent, beforeKeyDown, afterKeyDow
84
84
  if (event.keyCode === 229 || result === false || isImmediatePropagationStopped(event)) {
85
85
  return;
86
86
  }
87
- var pressedKey = normalizeEventKey(event);
87
+ var pressedKey = normalizeEventKey(event.key);
88
88
  var extraModifierKeys = [];
89
89
  if (isModifierKey(pressedKey)) {
90
90
  modifierKeysObserver.press(pressedKey);
@@ -110,7 +110,7 @@ export function useRecorder(ownerWindow, handleEvent, beforeKeyDown, afterKeyDow
110
110
  if (handleEvent(event) === false) {
111
111
  return;
112
112
  }
113
- var pressedKey = normalizeEventKey(event);
113
+ var pressedKey = normalizeEventKey(event.key);
114
114
  if (isModifierKey(pressedKey) === false) {
115
115
  return;
116
116
  }
@@ -10,10 +10,6 @@ require("core-js/modules/web.dom-collections.iterator.js");
10
10
  require("core-js/modules/es.array.join.js");
11
11
  require("core-js/modules/es.array.sort.js");
12
12
  require("core-js/modules/es.array.map.js");
13
- require("core-js/modules/es.regexp.constructor.js");
14
- require("core-js/modules/es.regexp.exec.js");
15
- require("core-js/modules/es.regexp.to-string.js");
16
- require("core-js/modules/es.string.replace.js");
17
13
  // This file handles key-name discrepancies between browsers.
18
14
  // For the list of discrepancies, go to: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values.
19
15
  var mappings = new Map([[' ', 'space'],
@@ -50,25 +46,13 @@ var getKeysList = function getKeysList(normalizedKeys) {
50
46
  };
51
47
 
52
48
  /**
53
- * The regex tests if the event.code matches to the pattern and it's used to extract letters and digits from
54
- * the string.
55
- */
56
- exports.getKeysList = getKeysList;
57
- var codeToKeyRegExp = new RegExp('^(?:Key|Digit)([A-Z0-9])$');
58
-
59
- /**
60
- * Normalizes a keyboard event key value to a key before its modification. When the keyboard event
61
- * is triggered with Alt, Control or Shift keys the `key` property contains modified key e.g. for Alt+L
62
- * it will be `ł`. But that value is only valid for polish keyboard layout. To fix that limitations, for
63
- * letters and digits the value is taken from the `code` property which holds original value before
64
- * transformation.
49
+ * Normalize a `KeyboardEvent.key` property, to use it for keyboard shortcuts.
65
50
  *
66
- * @param {Event} event The KeyboardEvent object.
51
+ * @param {string} key KeyboardEvent's key property.
67
52
  * @returns {string}
68
53
  */
69
- var normalizeEventKey = function normalizeEventKey(_ref) {
70
- var key = _ref.key,
71
- code = _ref.code;
72
- return (codeToKeyRegExp.test(code) ? code.replace(codeToKeyRegExp, '$1') : key).toLowerCase();
54
+ exports.getKeysList = getKeysList;
55
+ var normalizeEventKey = function normalizeEventKey(key) {
56
+ return key.toLowerCase();
73
57
  };
74
58
  exports.normalizeEventKey = normalizeEventKey;
@@ -6,10 +6,6 @@ import "core-js/modules/web.dom-collections.iterator.js";
6
6
  import "core-js/modules/es.array.join.js";
7
7
  import "core-js/modules/es.array.sort.js";
8
8
  import "core-js/modules/es.array.map.js";
9
- import "core-js/modules/es.regexp.constructor.js";
10
- import "core-js/modules/es.regexp.exec.js";
11
- import "core-js/modules/es.regexp.to-string.js";
12
- import "core-js/modules/es.string.replace.js";
13
9
  // This file handles key-name discrepancies between browsers.
14
10
  // For the list of discrepancies, go to: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values.
15
11
  var mappings = new Map([[' ', 'space'],
@@ -45,23 +41,11 @@ export var getKeysList = function getKeysList(normalizedKeys) {
45
41
  };
46
42
 
47
43
  /**
48
- * The regex tests if the event.code matches to the pattern and it's used to extract letters and digits from
49
- * the string.
50
- */
51
- var codeToKeyRegExp = new RegExp('^(?:Key|Digit)([A-Z0-9])$');
52
-
53
- /**
54
- * Normalizes a keyboard event key value to a key before its modification. When the keyboard event
55
- * is triggered with Alt, Control or Shift keys the `key` property contains modified key e.g. for Alt+L
56
- * it will be `ł`. But that value is only valid for polish keyboard layout. To fix that limitations, for
57
- * letters and digits the value is taken from the `code` property which holds original value before
58
- * transformation.
44
+ * Normalize a `KeyboardEvent.key` property, to use it for keyboard shortcuts.
59
45
  *
60
- * @param {Event} event The KeyboardEvent object.
46
+ * @param {string} key KeyboardEvent's key property.
61
47
  * @returns {string}
62
48
  */
63
- export var normalizeEventKey = function normalizeEventKey(_ref) {
64
- var key = _ref.key,
65
- code = _ref.code;
66
- return (codeToKeyRegExp.test(code) ? code.replace(codeToKeyRegExp, '$1') : key).toLowerCase();
49
+ export var normalizeEventKey = function normalizeEventKey(key) {
50
+ return key.toLowerCase();
67
51
  };