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
@@ -67,6 +67,7 @@ import { CONDITION_NONE, CONDITION_BY_VALUE, OPERATION_AND, OPERATION_OR, OPERAT
|
|
67
67
|
import { TrimmingMap } from "../../translations/index.mjs";
|
68
68
|
export var PLUGIN_KEY = 'filters';
|
69
69
|
export var PLUGIN_PRIORITY = 250;
|
70
|
+
var SHORTCUTS_GROUP = PLUGIN_KEY;
|
70
71
|
|
71
72
|
/**
|
72
73
|
* @plugin Filters
|
@@ -282,6 +283,7 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
282
283
|
this.dropdownMenuPlugin.disablePlugin();
|
283
284
|
this.dropdownMenuPlugin.enablePlugin();
|
284
285
|
}
|
286
|
+
this.registerShortcuts();
|
285
287
|
_get(_getPrototypeOf(Filters.prototype), "enablePlugin", this).call(this);
|
286
288
|
}
|
287
289
|
|
@@ -305,9 +307,41 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
305
307
|
this.conditionCollection = null;
|
306
308
|
this.hot.rowIndexMapper.unregisterMap(this.pluginName);
|
307
309
|
}
|
310
|
+
this.unregisterShortcuts();
|
308
311
|
_get(_getPrototypeOf(Filters.prototype), "disablePlugin", this).call(this);
|
309
312
|
}
|
310
313
|
|
314
|
+
/**
|
315
|
+
* Register shortcuts responsible for clearing the filters.
|
316
|
+
*
|
317
|
+
* @private
|
318
|
+
*/
|
319
|
+
}, {
|
320
|
+
key: "registerShortcuts",
|
321
|
+
value: function registerShortcuts() {
|
322
|
+
var _this4 = this;
|
323
|
+
this.hot.getShortcutManager().getContext('grid').addShortcut({
|
324
|
+
keys: [['Alt', 'A']],
|
325
|
+
stopPropagation: true,
|
326
|
+
callback: function callback() {
|
327
|
+
_this4.clearConditions();
|
328
|
+
_this4.filter();
|
329
|
+
},
|
330
|
+
group: SHORTCUTS_GROUP
|
331
|
+
});
|
332
|
+
}
|
333
|
+
|
334
|
+
/**
|
335
|
+
* Unregister shortcuts responsible for clearing the filters.
|
336
|
+
*
|
337
|
+
* @private
|
338
|
+
*/
|
339
|
+
}, {
|
340
|
+
key: "unregisterShortcuts",
|
341
|
+
value: function unregisterShortcuts() {
|
342
|
+
this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
|
343
|
+
}
|
344
|
+
|
311
345
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
312
346
|
/**
|
313
347
|
* @memberof Filters#
|
@@ -474,7 +508,7 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
474
508
|
}, {
|
475
509
|
key: "filter",
|
476
510
|
value: function filter() {
|
477
|
-
var
|
511
|
+
var _this5 = this;
|
478
512
|
var dataFilter = this._createDataFilter();
|
479
513
|
var needToFilter = !this.conditionCollection.isEmpty();
|
480
514
|
var visibleVisualRows = [];
|
@@ -484,18 +518,18 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
484
518
|
if (needToFilter) {
|
485
519
|
var trimmedRows = [];
|
486
520
|
this.hot.batchExecution(function () {
|
487
|
-
|
521
|
+
_this5.filtersRowsMap.clear();
|
488
522
|
visibleVisualRows = arrayMap(dataFilter.filter(), function (rowData) {
|
489
523
|
return rowData.meta.visualRow;
|
490
524
|
});
|
491
525
|
var visibleVisualRowsAssertion = createArrayAssertion(visibleVisualRows);
|
492
|
-
rangeEach(
|
526
|
+
rangeEach(_this5.hot.countSourceRows() - 1, function (row) {
|
493
527
|
if (!visibleVisualRowsAssertion(row)) {
|
494
528
|
trimmedRows.push(row);
|
495
529
|
}
|
496
530
|
});
|
497
531
|
arrayEach(trimmedRows, function (physicalRow) {
|
498
|
-
|
532
|
+
_this5.filtersRowsMap.setValueAtIndex(physicalRow, true);
|
499
533
|
});
|
500
534
|
}, true);
|
501
535
|
if (!visibleVisualRows.length) {
|
@@ -508,7 +542,6 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
508
542
|
this.hot.runHooks('afterFilter', conditions);
|
509
543
|
this.hot.view.adjustElementsSize(true);
|
510
544
|
this.hot.render();
|
511
|
-
this.clearColumnSelection();
|
512
545
|
}
|
513
546
|
|
514
547
|
/**
|
@@ -532,20 +565,6 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
532
565
|
};
|
533
566
|
}
|
534
567
|
|
535
|
-
/**
|
536
|
-
* Clears column selection.
|
537
|
-
*
|
538
|
-
* @private
|
539
|
-
*/
|
540
|
-
}, {
|
541
|
-
key: "clearColumnSelection",
|
542
|
-
value: function clearColumnSelection() {
|
543
|
-
var selectedColumn = this.getSelectedColumn();
|
544
|
-
if (selectedColumn !== null) {
|
545
|
-
this.hot.selectCell(0, selectedColumn.visualIndex);
|
546
|
-
}
|
547
|
-
}
|
548
|
-
|
549
568
|
/**
|
550
569
|
* Returns handsontable source data with cell meta based on current selection.
|
551
570
|
*
|
@@ -555,21 +574,21 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
555
574
|
}, {
|
556
575
|
key: "getDataMapAtColumn",
|
557
576
|
value: function getDataMapAtColumn(column) {
|
558
|
-
var
|
577
|
+
var _this6 = this;
|
559
578
|
var visualColumn = this.hot.toVisualColumn(column);
|
560
579
|
var data = [];
|
561
580
|
arrayEach(this.hot.getSourceDataAtCol(visualColumn), function (value, rowIndex) {
|
562
|
-
var
|
563
|
-
var
|
564
|
-
row =
|
565
|
-
col =
|
566
|
-
visualCol =
|
567
|
-
visualRow =
|
568
|
-
type =
|
569
|
-
instance =
|
570
|
-
dateFormat =
|
571
|
-
locale =
|
572
|
-
var dataValue = (
|
581
|
+
var _this6$hot$getDataAtC;
|
582
|
+
var _this6$hot$getCellMet = _this6.hot.getCellMeta(rowIndex, visualColumn),
|
583
|
+
row = _this6$hot$getCellMet.row,
|
584
|
+
col = _this6$hot$getCellMet.col,
|
585
|
+
visualCol = _this6$hot$getCellMet.visualCol,
|
586
|
+
visualRow = _this6$hot$getCellMet.visualRow,
|
587
|
+
type = _this6$hot$getCellMet.type,
|
588
|
+
instance = _this6$hot$getCellMet.instance,
|
589
|
+
dateFormat = _this6$hot$getCellMet.dateFormat,
|
590
|
+
locale = _this6$hot$getCellMet.locale;
|
591
|
+
var dataValue = (_this6$hot$getDataAtC = _this6.hot.getDataAtCell(_this6.hot.toVisualRow(rowIndex), visualColumn)) !== null && _this6$hot$getDataAtC !== void 0 ? _this6$hot$getDataAtC : value;
|
573
592
|
data.push({
|
574
593
|
meta: {
|
575
594
|
row: row,
|
@@ -596,14 +615,14 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
596
615
|
}, {
|
597
616
|
key: "onAfterChange",
|
598
617
|
value: function onAfterChange(changes) {
|
599
|
-
var
|
618
|
+
var _this7 = this;
|
600
619
|
if (changes) {
|
601
620
|
arrayEach(changes, function (change) {
|
602
621
|
var _change = _slicedToArray(change, 2),
|
603
622
|
prop = _change[1];
|
604
|
-
var columnIndex =
|
605
|
-
if (
|
606
|
-
|
623
|
+
var columnIndex = _this7.hot.propToCol(prop);
|
624
|
+
if (_this7.conditionCollection.hasConditions(columnIndex)) {
|
625
|
+
_this7.updateValueComponentCondition(columnIndex);
|
607
626
|
}
|
608
627
|
});
|
609
628
|
}
|
@@ -674,10 +693,10 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
674
693
|
}, {
|
675
694
|
key: "onBeforeDropdownMenuSetItems",
|
676
695
|
value: function onBeforeDropdownMenuSetItems() {
|
677
|
-
var
|
696
|
+
var _this8 = this;
|
678
697
|
if (this.dropdownMenuPlugin) {
|
679
698
|
this.dropdownMenuPlugin.menu.addLocalHook('afterOpen', function () {
|
680
|
-
|
699
|
+
_this8.dropdownMenuPlugin.menu.hotMenu.updateSettings({
|
681
700
|
hiddenRows: true
|
682
701
|
});
|
683
702
|
});
|
@@ -768,6 +787,7 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
768
787
|
});
|
769
788
|
this.filtersRowsMap.clear();
|
770
789
|
this.filter();
|
790
|
+
this.hot.selectCell(0, selectedColumn.visualIndex);
|
771
791
|
}
|
772
792
|
(_this$dropdownMenuPlu3 = this.dropdownMenuPlugin) === null || _this$dropdownMenuPlu3 === void 0 ? void 0 : _this$dropdownMenuPlu3.close();
|
773
793
|
}
|
@@ -860,10 +880,10 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
860
880
|
}, {
|
861
881
|
key: "_createDataFilter",
|
862
882
|
value: function _createDataFilter() {
|
863
|
-
var
|
883
|
+
var _this9 = this;
|
864
884
|
var conditionCollection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.conditionCollection;
|
865
885
|
return new DataFilter(conditionCollection, function (physicalColumn) {
|
866
|
-
return
|
886
|
+
return _this9.getDataMapAtColumn(physicalColumn);
|
867
887
|
});
|
868
888
|
}
|
869
889
|
|
@@ -995,12 +1015,12 @@ export var Filters = /*#__PURE__*/function (_BasePlugin) {
|
|
995
1015
|
}, {
|
996
1016
|
key: "destroy",
|
997
1017
|
value: function destroy() {
|
998
|
-
var
|
1018
|
+
var _this10 = this;
|
999
1019
|
if (this.enabled) {
|
1000
1020
|
this.components.forEach(function (component, key) {
|
1001
1021
|
if (component !== null) {
|
1002
1022
|
component.destroy();
|
1003
|
-
|
1023
|
+
_this10.components.set(key, null);
|
1004
1024
|
}
|
1005
1025
|
});
|
1006
1026
|
this.conditionCollection.destroy();
|
@@ -20,7 +20,6 @@ var _editor = require("./editor");
|
|
20
20
|
var _extendCellsSelection = require("./extendCellsSelection");
|
21
21
|
var _moveCellSelection = require("./moveCellSelection");
|
22
22
|
var _emptySelectedCells = require("./emptySelectedCells");
|
23
|
-
var _scrollToFocusedCell = require("./scrollToFocusedCell");
|
24
23
|
var _selectAll = require("./selectAll");
|
25
24
|
var _populateSelectedCellsData = require("./populateSelectedCellsData");
|
26
25
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
@@ -29,7 +28,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
29
28
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
30
29
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
31
30
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
32
|
-
var allCommands = [].concat(_toConsumableArray((0, _editor.getAllCommands)()), _toConsumableArray((0, _extendCellsSelection.getAllCommands)()), _toConsumableArray((0, _moveCellSelection.getAllCommands)()), [_emptySelectedCells.command,
|
31
|
+
var allCommands = [].concat(_toConsumableArray((0, _editor.getAllCommands)()), _toConsumableArray((0, _extendCellsSelection.getAllCommands)()), _toConsumableArray((0, _moveCellSelection.getAllCommands)()), [_emptySelectedCells.command, _selectAll.command, _populateSelectedCellsData.command]);
|
33
32
|
|
34
33
|
/**
|
35
34
|
* Prepares and creates an object with all available commands to trigger.
|
@@ -22,10 +22,9 @@ import { getAllCommands as getAllEditorCommands } from "./editor/index.mjs";
|
|
22
22
|
import { getAllCommands as getAllSelectionExtendCommands } from "./extendCellsSelection/index.mjs";
|
23
23
|
import { getAllCommands as getAllSelectionMoveCommands } from "./moveCellSelection/index.mjs";
|
24
24
|
import { command as emptySelectedCells } from "./emptySelectedCells.mjs";
|
25
|
-
import { command as scrollToFocusedCell } from "./scrollToFocusedCell.mjs";
|
26
25
|
import { command as selectAll } from "./selectAll.mjs";
|
27
26
|
import { command as populateSelectedCellsData } from "./populateSelectedCellsData.mjs";
|
28
|
-
var allCommands = [].concat(_toConsumableArray(getAllEditorCommands()), _toConsumableArray(getAllSelectionExtendCommands()), _toConsumableArray(getAllSelectionMoveCommands()), [emptySelectedCells,
|
27
|
+
var allCommands = [].concat(_toConsumableArray(getAllEditorCommands()), _toConsumableArray(getAllSelectionExtendCommands()), _toConsumableArray(getAllSelectionMoveCommands()), [emptySelectedCells, selectAll, populateSelectedCellsData]);
|
29
28
|
|
30
29
|
/**
|
31
30
|
* Prepares and creates an object with all available commands to trigger.
|
package/shortcutContexts/grid.js
CHANGED
@@ -243,10 +243,5 @@ function shortcutsGridContext(hot) {
|
|
243
243
|
callback: function callback() {
|
244
244
|
return commandsPool.moveCellSelectionInlineEnd();
|
245
245
|
}
|
246
|
-
}, {
|
247
|
-
keys: [['Control/Meta', 'Backspace']],
|
248
|
-
callback: function callback() {
|
249
|
-
return commandsPool.scrollToFocusedCell();
|
250
|
-
}
|
251
246
|
}], config);
|
252
247
|
}
|
@@ -239,10 +239,5 @@ export function shortcutsGridContext(hot) {
|
|
239
239
|
callback: function callback() {
|
240
240
|
return commandsPool.moveCellSelectionInlineEnd();
|
241
241
|
}
|
242
|
-
}, {
|
243
|
-
keys: [['Control/Meta', 'Backspace']],
|
244
|
-
callback: function callback() {
|
245
|
-
return commandsPool.scrollToFocusedCell();
|
246
|
-
}
|
247
242
|
}], config);
|
248
243
|
}
|
package/shortcuts/recorder.js
CHANGED
@@ -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);
|
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);
|
118
118
|
if (isModifierKey(pressedKey) === false) {
|
119
119
|
return;
|
120
120
|
}
|
package/shortcuts/recorder.mjs
CHANGED
@@ -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);
|
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);
|
114
114
|
if (isModifierKey(pressedKey) === false) {
|
115
115
|
return;
|
116
116
|
}
|
package/shortcuts/utils.js
CHANGED
@@ -10,6 +10,10 @@ 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");
|
13
17
|
// This file handles key-name discrepancies between browsers.
|
14
18
|
// For the list of discrepancies, go to: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values.
|
15
19
|
var mappings = new Map([[' ', 'space'],
|
@@ -46,13 +50,25 @@ var getKeysList = function getKeysList(normalizedKeys) {
|
|
46
50
|
};
|
47
51
|
|
48
52
|
/**
|
49
|
-
*
|
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.
|
50
65
|
*
|
51
|
-
* @param {
|
66
|
+
* @param {Event} event The KeyboardEvent object.
|
52
67
|
* @returns {string}
|
53
68
|
*/
|
54
|
-
|
55
|
-
var
|
56
|
-
|
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();
|
57
73
|
};
|
58
74
|
exports.normalizeEventKey = normalizeEventKey;
|
package/shortcuts/utils.mjs
CHANGED
@@ -6,6 +6,10 @@ 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";
|
9
13
|
// This file handles key-name discrepancies between browsers.
|
10
14
|
// For the list of discrepancies, go to: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values.
|
11
15
|
var mappings = new Map([[' ', 'space'],
|
@@ -41,11 +45,23 @@ export var getKeysList = function getKeysList(normalizedKeys) {
|
|
41
45
|
};
|
42
46
|
|
43
47
|
/**
|
44
|
-
*
|
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.
|
45
59
|
*
|
46
|
-
* @param {
|
60
|
+
* @param {Event} event The KeyboardEvent object.
|
47
61
|
* @returns {string}
|
48
62
|
*/
|
49
|
-
export var normalizeEventKey = function normalizeEventKey(
|
50
|
-
|
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();
|
51
67
|
};
|
@@ -1,38 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
exports.command = void 0;
|
5
|
-
require("core-js/modules/es.array.includes.js");
|
6
|
-
require("core-js/modules/es.string.includes.js");
|
7
|
-
var command = {
|
8
|
-
name: 'scrollToFocusedCell',
|
9
|
-
callback: function callback(hot) {
|
10
|
-
var _hot$getSelectedRange = hot.getSelectedRangeLast(),
|
11
|
-
highlight = _hot$getSelectedRange.highlight;
|
12
|
-
var firstVisibleRow = hot.view.getFirstFullyVisibleRow() - 1;
|
13
|
-
var firstVisibleColumn = hot.view.getFirstFullyVisibleColumn() - 1;
|
14
|
-
var lastVisibleRow = hot.view.getLastFullyVisibleRow() + 1;
|
15
|
-
var lastVisibleColumn = hot.view.getLastFullyVisibleColumn() + 1;
|
16
|
-
var visibleCoordsFrom = hot._createCellCoords(firstVisibleRow, firstVisibleColumn);
|
17
|
-
var visibleCoordsTo = hot._createCellCoords(lastVisibleRow, lastVisibleColumn);
|
18
|
-
var visibleRange = hot._createCellRange(visibleCoordsFrom, visibleCoordsFrom, visibleCoordsTo);
|
19
|
-
if (!visibleRange.includes(highlight) && (highlight.row >= 0 || highlight.col >= 0)) {
|
20
|
-
var offsetRows = Math.floor(hot.countVisibleRows() / 2);
|
21
|
-
var offsetColumns = Math.floor(hot.countVisibleCols() / 2);
|
22
|
-
var scrollX = Math.max(highlight.row - offsetRows, 0);
|
23
|
-
var scrollY = Math.max(highlight.col - offsetColumns, 0);
|
24
|
-
var scrollCoords = [scrollX, scrollY];
|
25
|
-
|
26
|
-
// for row header focus do not change the scroll Y position, leave as it is
|
27
|
-
if (highlight.col < 0) {
|
28
|
-
scrollCoords[1] = null;
|
29
|
-
|
30
|
-
// for column header focus do not change the scroll X position, leave as it is
|
31
|
-
} else if (highlight.row < 0) {
|
32
|
-
scrollCoords[0] = null;
|
33
|
-
}
|
34
|
-
hot.scrollViewportTo.apply(hot, scrollCoords);
|
35
|
-
}
|
36
|
-
}
|
37
|
-
};
|
38
|
-
exports.command = command;
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import "core-js/modules/es.array.includes.js";
|
2
|
-
import "core-js/modules/es.string.includes.js";
|
3
|
-
export var command = {
|
4
|
-
name: 'scrollToFocusedCell',
|
5
|
-
callback: function callback(hot) {
|
6
|
-
var _hot$getSelectedRange = hot.getSelectedRangeLast(),
|
7
|
-
highlight = _hot$getSelectedRange.highlight;
|
8
|
-
var firstVisibleRow = hot.view.getFirstFullyVisibleRow() - 1;
|
9
|
-
var firstVisibleColumn = hot.view.getFirstFullyVisibleColumn() - 1;
|
10
|
-
var lastVisibleRow = hot.view.getLastFullyVisibleRow() + 1;
|
11
|
-
var lastVisibleColumn = hot.view.getLastFullyVisibleColumn() + 1;
|
12
|
-
var visibleCoordsFrom = hot._createCellCoords(firstVisibleRow, firstVisibleColumn);
|
13
|
-
var visibleCoordsTo = hot._createCellCoords(lastVisibleRow, lastVisibleColumn);
|
14
|
-
var visibleRange = hot._createCellRange(visibleCoordsFrom, visibleCoordsFrom, visibleCoordsTo);
|
15
|
-
if (!visibleRange.includes(highlight) && (highlight.row >= 0 || highlight.col >= 0)) {
|
16
|
-
var offsetRows = Math.floor(hot.countVisibleRows() / 2);
|
17
|
-
var offsetColumns = Math.floor(hot.countVisibleCols() / 2);
|
18
|
-
var scrollX = Math.max(highlight.row - offsetRows, 0);
|
19
|
-
var scrollY = Math.max(highlight.col - offsetColumns, 0);
|
20
|
-
var scrollCoords = [scrollX, scrollY];
|
21
|
-
|
22
|
-
// for row header focus do not change the scroll Y position, leave as it is
|
23
|
-
if (highlight.col < 0) {
|
24
|
-
scrollCoords[1] = null;
|
25
|
-
|
26
|
-
// for column header focus do not change the scroll X position, leave as it is
|
27
|
-
} else if (highlight.row < 0) {
|
28
|
-
scrollCoords[0] = null;
|
29
|
-
}
|
30
|
-
hot.scrollViewportTo.apply(hot, scrollCoords);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
};
|