handsontable 0.0.0-next-221e46b-20240307 → 0.0.0-next-200799f-20240311
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/walkontable/src/cell/range.d.ts +1 -0
- package/3rdparty/walkontable/src/cell/range.js +22 -5
- package/3rdparty/walkontable/src/cell/range.mjs +22 -5
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core/viewportScroll/index.js +4 -1
- package/core/viewportScroll/index.mjs +4 -1
- package/core/viewportScroll/scrollStrategies/focusScroll.js +15 -0
- package/core/viewportScroll/scrollStrategies/focusScroll.mjs +11 -0
- package/core.d.ts +4 -3
- package/core.js +78 -21
- package/core.mjs +78 -21
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +2645 -1363
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +152 -152
- package/dist/handsontable.js +2645 -1363
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +32 -32
- package/editorManager.js +12 -8
- package/editorManager.mjs +12 -8
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/pluginHooks.d.ts +1 -0
- package/pluginHooks.js +43 -1
- package/pluginHooks.mjs +43 -1
- package/plugins/collapsibleColumns/collapsibleColumns.js +7 -1
- package/plugins/collapsibleColumns/collapsibleColumns.mjs +7 -1
- package/plugins/columnSorting/columnSorting.js +6 -0
- package/plugins/columnSorting/columnSorting.mjs +6 -0
- package/plugins/contextMenu/menu/defaultShortcutsList.js +26 -10
- package/plugins/contextMenu/menu/defaultShortcutsList.mjs +26 -10
- package/plugins/mergeCells/calculations/selection.js +1 -70
- package/plugins/mergeCells/calculations/selection.mjs +1 -70
- package/plugins/mergeCells/cellsCollection.js +116 -0
- package/plugins/mergeCells/cellsCollection.mjs +116 -0
- package/plugins/mergeCells/contextMenuItem/toggleMerge.js +11 -1
- package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +11 -1
- package/plugins/mergeCells/focusOrder.js +258 -0
- package/plugins/mergeCells/focusOrder.mjs +253 -0
- package/plugins/mergeCells/mergeCells.js +394 -199
- package/plugins/mergeCells/mergeCells.mjs +394 -199
- package/plugins/multiColumnSorting/multiColumnSorting.js +6 -0
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +6 -0
- package/plugins/nestedHeaders/nestedHeaders.js +1 -0
- package/plugins/nestedHeaders/nestedHeaders.mjs +1 -0
- package/plugins/nestedRows/nestedRows.js +7 -1
- package/plugins/nestedRows/nestedRows.mjs +7 -1
- package/renderers/checkboxRenderer/checkboxRenderer.js +4 -4
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +4 -4
- package/selection/highlight/visualSelection.js +16 -2
- package/selection/highlight/visualSelection.mjs +16 -2
- package/selection/selection.js +225 -44
- package/selection/selection.mjs +224 -43
- package/selection/transformation.js +86 -32
- package/selection/transformation.mjs +86 -32
- package/shortcutContexts/commands/editor/closeAndSave.js +2 -2
- package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -2
- package/shortcutContexts/commands/editor/open.js +18 -3
- package/shortcutContexts/commands/editor/open.mjs +18 -3
- package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +3 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +3 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +9 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +9 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +10 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +10 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +3 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +3 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +3 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +3 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +3 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +3 -1
- package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +6 -1
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +6 -1
- package/shortcutContexts/commands/moveCellSelection/inlineStart.js +6 -1
- package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +6 -1
- package/shortcutContexts/grid.js +2 -2
- package/shortcutContexts/grid.mjs +2 -2
- package/shortcuts/context.js +2 -1
- package/shortcuts/context.mjs +2 -1
- package/tableView.js +20 -0
- package/tableView.mjs +20 -0
- package/utils/dataStructures/linkedList.js +6 -1
- package/utils/dataStructures/linkedList.mjs +6 -1
package/editorManager.js
CHANGED
@@ -318,18 +318,22 @@ class EditorManager {
|
|
318
318
|
}
|
319
319
|
|
320
320
|
/**
|
321
|
-
* Controls selection's
|
321
|
+
* Controls selection's behavior after clicking `Enter`.
|
322
322
|
*
|
323
323
|
* @private
|
324
|
-
* @param {
|
324
|
+
* @param {KeyboardEvent} event The keyboard event object.
|
325
325
|
*/
|
326
|
-
moveSelectionAfterEnter(
|
327
|
-
const enterMoves =
|
328
|
-
|
329
|
-
|
330
|
-
|
326
|
+
moveSelectionAfterEnter(event) {
|
327
|
+
const enterMoves = {
|
328
|
+
...(typeof this.tableMeta.enterMoves === 'function' ? this.tableMeta.enterMoves(event) : this.tableMeta.enterMoves)
|
329
|
+
};
|
330
|
+
if (event.shiftKey) {
|
331
|
+
enterMoves.row = -enterMoves.row;
|
332
|
+
enterMoves.col = -enterMoves.col;
|
333
|
+
}
|
334
|
+
if (this.hot.selection.isMultiple()) {
|
335
|
+
this.selection.transformFocus(enterMoves.row, enterMoves.col);
|
331
336
|
} else {
|
332
|
-
// move selection down (add a new row if needed)
|
333
337
|
this.selection.transformStart(enterMoves.row, enterMoves.col, true);
|
334
338
|
}
|
335
339
|
}
|
package/editorManager.mjs
CHANGED
@@ -314,18 +314,22 @@ class EditorManager {
|
|
314
314
|
}
|
315
315
|
|
316
316
|
/**
|
317
|
-
* Controls selection's
|
317
|
+
* Controls selection's behavior after clicking `Enter`.
|
318
318
|
*
|
319
319
|
* @private
|
320
|
-
* @param {
|
320
|
+
* @param {KeyboardEvent} event The keyboard event object.
|
321
321
|
*/
|
322
|
-
moveSelectionAfterEnter(
|
323
|
-
const enterMoves =
|
324
|
-
|
325
|
-
|
326
|
-
|
322
|
+
moveSelectionAfterEnter(event) {
|
323
|
+
const enterMoves = {
|
324
|
+
...(typeof this.tableMeta.enterMoves === 'function' ? this.tableMeta.enterMoves(event) : this.tableMeta.enterMoves)
|
325
|
+
};
|
326
|
+
if (event.shiftKey) {
|
327
|
+
enterMoves.row = -enterMoves.row;
|
328
|
+
enterMoves.col = -enterMoves.col;
|
329
|
+
}
|
330
|
+
if (this.hot.selection.isMultiple()) {
|
331
|
+
this.selection.transformFocus(enterMoves.row, enterMoves.col);
|
327
332
|
} else {
|
328
|
-
// move selection down (add a new row if needed)
|
329
333
|
this.selection.transformStart(enterMoves.row, enterMoves.col, true);
|
330
334
|
}
|
331
335
|
}
|
package/helpers/mixed.js
CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
|
|
134
134
|
function _injectProductInfo(key, element) {
|
135
135
|
const hasValidType = !isEmpty(key);
|
136
136
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
137
|
-
const hotVersion = "0.0.0-next-
|
137
|
+
const hotVersion = "0.0.0-next-200799f-20240311";
|
138
138
|
let keyValidityDate;
|
139
139
|
let consoleMessageState = 'invalid';
|
140
140
|
let domMessageState = 'invalid';
|
package/helpers/mixed.mjs
CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
|
|
124
124
|
export function _injectProductInfo(key, element) {
|
125
125
|
const hasValidType = !isEmpty(key);
|
126
126
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
127
|
-
const hotVersion = "0.0.0-next-
|
127
|
+
const hotVersion = "0.0.0-next-200799f-20240311";
|
128
128
|
let keyValidityDate;
|
129
129
|
let consoleMessageState = 'invalid';
|
130
130
|
let domMessageState = 'invalid';
|
package/package.json
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
"url": "https://github.com/handsontable/handsontable/issues"
|
11
11
|
},
|
12
12
|
"author": "Handsoncode <hello@handsontable.com>",
|
13
|
-
"version": "0.0.0-next-
|
13
|
+
"version": "0.0.0-next-200799f-20240311",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
package/pluginHooks.d.ts
CHANGED
@@ -133,6 +133,7 @@ export interface Events {
|
|
133
133
|
afterSelectionByProp?: (row: number, prop: string, row2: number, prop2: string, preventScrolling: { value: boolean }, selectionLayerLevel: number) => void;
|
134
134
|
afterSelectionEnd?: (row: number, column: number, row2: number, column2: number, selectionLayerLevel: number) => void;
|
135
135
|
afterSelectionEndByProp?: (row: number, prop: string, row2: number, prop2: string, selectionLayerLevel: number) => void;
|
136
|
+
afterSelectionFocusSet?: (row: number, column: number, preventScrolling: { value: boolean }) => void;
|
136
137
|
afterSelectRows?: (from: CellCoords, to: CellCoords, highlight: CellCoords) => void;
|
137
138
|
afterSetCellMeta?: (row: number, column: number, key: string, value: any) => void;
|
138
139
|
afterSetDataAtCell?: (changes: CellChange[], source?: ChangeSource) => void;
|
package/pluginHooks.js
CHANGED
@@ -650,7 +650,9 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
|
|
650
650
|
* @param {string} prop Selection start data source object property name.
|
651
651
|
* @param {number} row2 Selection end visual row index.
|
652
652
|
* @param {string} prop2 Selection end data source object property name.
|
653
|
-
* @param {object} preventScrolling
|
653
|
+
* @param {object} preventScrolling A reference to the observable object with the `value` property.
|
654
|
+
* Property `preventScrolling.value` expects a boolean value that
|
655
|
+
* Handsontable uses to control scroll behavior after selection.
|
654
656
|
* @param {number} selectionLayerLevel The number which indicates what selection layer is currently modified.
|
655
657
|
* @example
|
656
658
|
* ```js
|
@@ -700,6 +702,46 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
|
|
700
702
|
* @param {number} selectionLayerLevel The number which indicates what selection layer is currently modified.
|
701
703
|
*/
|
702
704
|
'afterSelectionEndByProp',
|
705
|
+
/**
|
706
|
+
* Fired after the focus position within a selected range is changed.
|
707
|
+
*
|
708
|
+
* @since 14.2.0
|
709
|
+
* @event Hooks#afterSelectionFocusSet
|
710
|
+
* @param {number} row The focus visual row index position.
|
711
|
+
* @param {number} column The focus visual column index position.
|
712
|
+
* @param {object} preventScrolling A reference to the observable object with the `value` property.
|
713
|
+
* Property `preventScrolling.value` expects a boolean value that
|
714
|
+
* Handsontable uses to control scroll behavior after selection.
|
715
|
+
* @example
|
716
|
+
* ```js
|
717
|
+
* ::: only-for javascript
|
718
|
+
* new Handsontable(element, {
|
719
|
+
* afterSelectionFocusSet: (row, column, preventScrolling) => {
|
720
|
+
* // If set to `false` (default): when focused cell selection is outside the viewport,
|
721
|
+
* // Handsontable scrolls the viewport to that cell.
|
722
|
+
* // If set to `true`: when focused cell selection is outside the viewport,
|
723
|
+
* // Handsontable doesn't scroll the viewport.
|
724
|
+
* preventScrolling.value = true;
|
725
|
+
* }
|
726
|
+
* })
|
727
|
+
* ```
|
728
|
+
* :::
|
729
|
+
*
|
730
|
+
* ::: only-for react
|
731
|
+
* ```jsx
|
732
|
+
* <HotTable
|
733
|
+
* afterSelectionFocusSet={(row, column, preventScrolling) => {
|
734
|
+
* // If set to `false` (default): when focused cell selection is outside the viewport,
|
735
|
+
* // Handsontable scrolls the viewport to that cell.
|
736
|
+
* // If set to `true`: when focused cell selection is outside the viewport,
|
737
|
+
* // Handsontable doesn't scroll the viewport.
|
738
|
+
* preventScrolling.value = true;
|
739
|
+
* }}
|
740
|
+
* />
|
741
|
+
* ```
|
742
|
+
* :::
|
743
|
+
*/
|
744
|
+
'afterSelectionFocusSet',
|
703
745
|
/**
|
704
746
|
* Fired before one or more columns are selected (e.g. During mouse header click or {@link Core#selectColumns} API call).
|
705
747
|
*
|
package/pluginHooks.mjs
CHANGED
@@ -646,7 +646,9 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
|
|
646
646
|
* @param {string} prop Selection start data source object property name.
|
647
647
|
* @param {number} row2 Selection end visual row index.
|
648
648
|
* @param {string} prop2 Selection end data source object property name.
|
649
|
-
* @param {object} preventScrolling
|
649
|
+
* @param {object} preventScrolling A reference to the observable object with the `value` property.
|
650
|
+
* Property `preventScrolling.value` expects a boolean value that
|
651
|
+
* Handsontable uses to control scroll behavior after selection.
|
650
652
|
* @param {number} selectionLayerLevel The number which indicates what selection layer is currently modified.
|
651
653
|
* @example
|
652
654
|
* ```js
|
@@ -696,6 +698,46 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
|
|
696
698
|
* @param {number} selectionLayerLevel The number which indicates what selection layer is currently modified.
|
697
699
|
*/
|
698
700
|
'afterSelectionEndByProp',
|
701
|
+
/**
|
702
|
+
* Fired after the focus position within a selected range is changed.
|
703
|
+
*
|
704
|
+
* @since 14.2.0
|
705
|
+
* @event Hooks#afterSelectionFocusSet
|
706
|
+
* @param {number} row The focus visual row index position.
|
707
|
+
* @param {number} column The focus visual column index position.
|
708
|
+
* @param {object} preventScrolling A reference to the observable object with the `value` property.
|
709
|
+
* Property `preventScrolling.value` expects a boolean value that
|
710
|
+
* Handsontable uses to control scroll behavior after selection.
|
711
|
+
* @example
|
712
|
+
* ```js
|
713
|
+
* ::: only-for javascript
|
714
|
+
* new Handsontable(element, {
|
715
|
+
* afterSelectionFocusSet: (row, column, preventScrolling) => {
|
716
|
+
* // If set to `false` (default): when focused cell selection is outside the viewport,
|
717
|
+
* // Handsontable scrolls the viewport to that cell.
|
718
|
+
* // If set to `true`: when focused cell selection is outside the viewport,
|
719
|
+
* // Handsontable doesn't scroll the viewport.
|
720
|
+
* preventScrolling.value = true;
|
721
|
+
* }
|
722
|
+
* })
|
723
|
+
* ```
|
724
|
+
* :::
|
725
|
+
*
|
726
|
+
* ::: only-for react
|
727
|
+
* ```jsx
|
728
|
+
* <HotTable
|
729
|
+
* afterSelectionFocusSet={(row, column, preventScrolling) => {
|
730
|
+
* // If set to `false` (default): when focused cell selection is outside the viewport,
|
731
|
+
* // Handsontable scrolls the viewport to that cell.
|
732
|
+
* // If set to `true`: when focused cell selection is outside the viewport,
|
733
|
+
* // Handsontable doesn't scroll the viewport.
|
734
|
+
* preventScrolling.value = true;
|
735
|
+
* }}
|
736
|
+
* />
|
737
|
+
* ```
|
738
|
+
* :::
|
739
|
+
*/
|
740
|
+
'afterSelectionFocusSet',
|
699
741
|
/**
|
700
742
|
* Fired before one or more columns are selected (e.g. During mouse header click or {@link Core#selectColumns} API call).
|
701
743
|
*
|
@@ -9,6 +9,7 @@ var _number = require("../../helpers/number");
|
|
9
9
|
var _console = require("../../helpers/console");
|
10
10
|
var _element = require("../../helpers/dom/element");
|
11
11
|
var _event = require("../../helpers/dom/event");
|
12
|
+
var _shortcutContexts = require("../../shortcutContexts");
|
12
13
|
var _a11y = require("../../helpers/a11y");
|
13
14
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
14
15
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
@@ -308,12 +309,17 @@ class CollapsibleColumns extends _base.BasePlugin {
|
|
308
309
|
col: columnIndex
|
309
310
|
});
|
310
311
|
}
|
312
|
+
|
313
|
+
// prevent default Enter behavior (move to the next row within a selection range)
|
314
|
+
return false;
|
311
315
|
},
|
312
316
|
runOnlyIf: () => {
|
313
317
|
var _this$hot$getSelected;
|
314
318
|
return (_this$hot$getSelected = this.hot.getSelectedRangeLast()) === null || _this$hot$getSelected === void 0 ? void 0 : _this$hot$getSelected.highlight.isHeader();
|
315
319
|
},
|
316
|
-
group: SHORTCUTS_GROUP
|
320
|
+
group: SHORTCUTS_GROUP,
|
321
|
+
relativeToGroup: _shortcutContexts.EDITOR_EDIT_GROUP,
|
322
|
+
position: 'before'
|
317
323
|
});
|
318
324
|
}
|
319
325
|
|
@@ -18,6 +18,7 @@ import { rangeEach } from "../../helpers/number.mjs";
|
|
18
18
|
import { warn } from "../../helpers/console.mjs";
|
19
19
|
import { addClass, hasClass, removeClass, fastInnerText, removeAttribute, setAttribute } from "../../helpers/dom/element.mjs";
|
20
20
|
import { stopImmediatePropagation } from "../../helpers/dom/event.mjs";
|
21
|
+
import { EDITOR_EDIT_GROUP as SHORTCUTS_GROUP_EDITOR } from "../../shortcutContexts/index.mjs";
|
21
22
|
import { A11Y_EXPANDED, A11Y_HIDDEN } from "../../helpers/a11y.mjs";
|
22
23
|
export const PLUGIN_KEY = 'collapsibleColumns';
|
23
24
|
export const PLUGIN_PRIORITY = 290;
|
@@ -305,12 +306,17 @@ export class CollapsibleColumns extends BasePlugin {
|
|
305
306
|
col: columnIndex
|
306
307
|
});
|
307
308
|
}
|
309
|
+
|
310
|
+
// prevent default Enter behavior (move to the next row within a selection range)
|
311
|
+
return false;
|
308
312
|
},
|
309
313
|
runOnlyIf: () => {
|
310
314
|
var _this$hot$getSelected;
|
311
315
|
return (_this$hot$getSelected = this.hot.getSelectedRangeLast()) === null || _this$hot$getSelected === void 0 ? void 0 : _this$hot$getSelected.highlight.isHeader();
|
312
316
|
},
|
313
|
-
group: SHORTCUTS_GROUP
|
317
|
+
group: SHORTCUTS_GROUP,
|
318
|
+
relativeToGroup: SHORTCUTS_GROUP_EDITOR,
|
319
|
+
position: 'before'
|
314
320
|
});
|
315
321
|
}
|
316
322
|
|
@@ -12,6 +12,7 @@ var _base = require("../base");
|
|
12
12
|
var _translations = require("../../translations");
|
13
13
|
var _pluginHooks = _interopRequireDefault(require("../../pluginHooks"));
|
14
14
|
var _columnStatesManager = require("./columnStatesManager");
|
15
|
+
var _shortcutContexts = require("../../shortcutContexts");
|
15
16
|
var _utils = require("./utils");
|
16
17
|
var _domHelpers = require("./domHelpers");
|
17
18
|
var _rootComparator = require("./rootComparator");
|
@@ -249,12 +250,17 @@ class ColumnSorting extends _base.BasePlugin {
|
|
249
250
|
if (highlight.row === -1 && highlight.col >= 0) {
|
250
251
|
this.sort(this.getColumnNextConfig(highlight.col));
|
251
252
|
}
|
253
|
+
|
254
|
+
// prevent default Enter behavior (move to the next row within a selection range)
|
255
|
+
return false;
|
252
256
|
},
|
253
257
|
runOnlyIf: () => {
|
254
258
|
var _this$hot$getSelected;
|
255
259
|
const highlight = (_this$hot$getSelected = this.hot.getSelectedRangeLast()) === null || _this$hot$getSelected === void 0 ? void 0 : _this$hot$getSelected.highlight;
|
256
260
|
return highlight && this.hot.selection.isCellVisible(highlight) && highlight.isHeader();
|
257
261
|
},
|
262
|
+
relativeToGroup: _shortcutContexts.EDITOR_EDIT_GROUP,
|
263
|
+
position: 'before',
|
258
264
|
group: SHORTCUTS_GROUP
|
259
265
|
});
|
260
266
|
}
|
@@ -15,6 +15,7 @@ import { BasePlugin } from "../base/index.mjs";
|
|
15
15
|
import { IndexesSequence, PhysicalIndexToValueMap as IndexToValueMap } from "../../translations/index.mjs";
|
16
16
|
import Hooks from "../../pluginHooks.mjs";
|
17
17
|
import { ColumnStatesManager } from "./columnStatesManager.mjs";
|
18
|
+
import { EDITOR_EDIT_GROUP as SHORTCUTS_GROUP_EDITOR } from "../../shortcutContexts/index.mjs";
|
18
19
|
import { HEADER_SPAN_CLASS, getNextSortOrder, areValidSortStates, getHeaderSpanElement, isFirstLevelColumnHeader, wasHeaderClickedProperly } from "./utils.mjs";
|
19
20
|
import { getClassesToRemove, getClassesToAdd } from "./domHelpers.mjs";
|
20
21
|
import { rootComparator } from "./rootComparator.mjs";
|
@@ -245,12 +246,17 @@ export class ColumnSorting extends BasePlugin {
|
|
245
246
|
if (highlight.row === -1 && highlight.col >= 0) {
|
246
247
|
this.sort(this.getColumnNextConfig(highlight.col));
|
247
248
|
}
|
249
|
+
|
250
|
+
// prevent default Enter behavior (move to the next row within a selection range)
|
251
|
+
return false;
|
248
252
|
},
|
249
253
|
runOnlyIf: () => {
|
250
254
|
var _this$hot$getSelected;
|
251
255
|
const highlight = (_this$hot$getSelected = this.hot.getSelectedRangeLast()) === null || _this$hot$getSelected === void 0 ? void 0 : _this$hot$getSelected.highlight;
|
252
256
|
return highlight && this.hot.selection.isCellVisible(highlight) && highlight.isHeader();
|
253
257
|
},
|
258
|
+
relativeToGroup: SHORTCUTS_GROUP_EDITOR,
|
259
|
+
position: 'before',
|
254
260
|
group: SHORTCUTS_GROUP
|
255
261
|
});
|
256
262
|
}
|
@@ -9,10 +9,26 @@ exports.createDefaultShortcutsList = createDefaultShortcutsList;
|
|
9
9
|
* @returns {KeyboardShortcut[]}
|
10
10
|
*/
|
11
11
|
function createDefaultShortcutsList(menu) {
|
12
|
+
const {
|
13
|
+
hot,
|
14
|
+
hotMenu
|
15
|
+
} = menu;
|
12
16
|
return [{
|
13
|
-
keys: [['
|
14
|
-
forwardToContext:
|
17
|
+
keys: [['Control/Meta', 'A']],
|
18
|
+
forwardToContext: hot.getShortcutManager().getContext('grid'),
|
15
19
|
callback: () => menu.close(true)
|
20
|
+
}, {
|
21
|
+
keys: [['Tab'], ['Shift', 'Tab']],
|
22
|
+
callback: (event, keys) => {
|
23
|
+
const settings = hot.getSettings();
|
24
|
+
const tabMoves = typeof settings.tabMoves === 'function' ? settings.tabMoves(event) : settings.tabMoves;
|
25
|
+
if (keys.includes('shift')) {
|
26
|
+
hot.selection.transformStart(-tabMoves.row, -tabMoves.col);
|
27
|
+
} else {
|
28
|
+
hot.selection.transformStart(tabMoves.row, tabMoves.col);
|
29
|
+
}
|
30
|
+
menu.close(true);
|
31
|
+
}
|
16
32
|
}, {
|
17
33
|
keys: [['Escape']],
|
18
34
|
callback: () => menu.close()
|
@@ -25,7 +41,7 @@ function createDefaultShortcutsList(menu) {
|
|
25
41
|
}, {
|
26
42
|
keys: [['ArrowRight']],
|
27
43
|
callback: () => {
|
28
|
-
const selection =
|
44
|
+
const selection = hotMenu.getSelectedLast();
|
29
45
|
if (selection) {
|
30
46
|
const subMenu = menu.openSubMenu(selection[0]);
|
31
47
|
if (subMenu) {
|
@@ -36,7 +52,7 @@ function createDefaultShortcutsList(menu) {
|
|
36
52
|
}, {
|
37
53
|
keys: [['ArrowLeft']],
|
38
54
|
callback: () => {
|
39
|
-
const selection =
|
55
|
+
const selection = hotMenu.getSelectedLast();
|
40
56
|
if (selection && menu.isSubMenu()) {
|
41
57
|
menu.close();
|
42
58
|
if (menu.isSubMenu()) {
|
@@ -53,11 +69,11 @@ function createDefaultShortcutsList(menu) {
|
|
53
69
|
}, {
|
54
70
|
keys: [['Enter'], ['Space']],
|
55
71
|
callback: event => {
|
56
|
-
const selection =
|
72
|
+
const selection = hotMenu.getSelectedLast();
|
57
73
|
if (!selection) {
|
58
74
|
return;
|
59
75
|
}
|
60
|
-
if (
|
76
|
+
if (hotMenu.getSourceDataAtRow(selection[0]).submenu) {
|
61
77
|
menu.openSubMenu(selection[0]).getNavigator().toFirstItem();
|
62
78
|
} else {
|
63
79
|
menu.executeCommand(event);
|
@@ -67,9 +83,9 @@ function createDefaultShortcutsList(menu) {
|
|
67
83
|
}, {
|
68
84
|
keys: [['PageUp']],
|
69
85
|
callback: () => {
|
70
|
-
const selection =
|
86
|
+
const selection = hotMenu.getSelectedLast();
|
71
87
|
if (selection) {
|
72
|
-
|
88
|
+
hotMenu.selection.transformStart(-hotMenu.countVisibleRows(), 0);
|
73
89
|
} else {
|
74
90
|
menu.getNavigator().toFirstItem();
|
75
91
|
}
|
@@ -77,9 +93,9 @@ function createDefaultShortcutsList(menu) {
|
|
77
93
|
}, {
|
78
94
|
keys: [['PageDown']],
|
79
95
|
callback: () => {
|
80
|
-
const selection =
|
96
|
+
const selection = hotMenu.getSelectedLast();
|
81
97
|
if (selection) {
|
82
|
-
|
98
|
+
hotMenu.selection.transformStart(hotMenu.countVisibleRows(), 0);
|
83
99
|
} else {
|
84
100
|
menu.getNavigator().toLastItem();
|
85
101
|
}
|
@@ -5,10 +5,26 @@
|
|
5
5
|
* @returns {KeyboardShortcut[]}
|
6
6
|
*/
|
7
7
|
export function createDefaultShortcutsList(menu) {
|
8
|
+
const {
|
9
|
+
hot,
|
10
|
+
hotMenu
|
11
|
+
} = menu;
|
8
12
|
return [{
|
9
|
-
keys: [['
|
10
|
-
forwardToContext:
|
13
|
+
keys: [['Control/Meta', 'A']],
|
14
|
+
forwardToContext: hot.getShortcutManager().getContext('grid'),
|
11
15
|
callback: () => menu.close(true)
|
16
|
+
}, {
|
17
|
+
keys: [['Tab'], ['Shift', 'Tab']],
|
18
|
+
callback: (event, keys) => {
|
19
|
+
const settings = hot.getSettings();
|
20
|
+
const tabMoves = typeof settings.tabMoves === 'function' ? settings.tabMoves(event) : settings.tabMoves;
|
21
|
+
if (keys.includes('shift')) {
|
22
|
+
hot.selection.transformStart(-tabMoves.row, -tabMoves.col);
|
23
|
+
} else {
|
24
|
+
hot.selection.transformStart(tabMoves.row, tabMoves.col);
|
25
|
+
}
|
26
|
+
menu.close(true);
|
27
|
+
}
|
12
28
|
}, {
|
13
29
|
keys: [['Escape']],
|
14
30
|
callback: () => menu.close()
|
@@ -21,7 +37,7 @@ export function createDefaultShortcutsList(menu) {
|
|
21
37
|
}, {
|
22
38
|
keys: [['ArrowRight']],
|
23
39
|
callback: () => {
|
24
|
-
const selection =
|
40
|
+
const selection = hotMenu.getSelectedLast();
|
25
41
|
if (selection) {
|
26
42
|
const subMenu = menu.openSubMenu(selection[0]);
|
27
43
|
if (subMenu) {
|
@@ -32,7 +48,7 @@ export function createDefaultShortcutsList(menu) {
|
|
32
48
|
}, {
|
33
49
|
keys: [['ArrowLeft']],
|
34
50
|
callback: () => {
|
35
|
-
const selection =
|
51
|
+
const selection = hotMenu.getSelectedLast();
|
36
52
|
if (selection && menu.isSubMenu()) {
|
37
53
|
menu.close();
|
38
54
|
if (menu.isSubMenu()) {
|
@@ -49,11 +65,11 @@ export function createDefaultShortcutsList(menu) {
|
|
49
65
|
}, {
|
50
66
|
keys: [['Enter'], ['Space']],
|
51
67
|
callback: event => {
|
52
|
-
const selection =
|
68
|
+
const selection = hotMenu.getSelectedLast();
|
53
69
|
if (!selection) {
|
54
70
|
return;
|
55
71
|
}
|
56
|
-
if (
|
72
|
+
if (hotMenu.getSourceDataAtRow(selection[0]).submenu) {
|
57
73
|
menu.openSubMenu(selection[0]).getNavigator().toFirstItem();
|
58
74
|
} else {
|
59
75
|
menu.executeCommand(event);
|
@@ -63,9 +79,9 @@ export function createDefaultShortcutsList(menu) {
|
|
63
79
|
}, {
|
64
80
|
keys: [['PageUp']],
|
65
81
|
callback: () => {
|
66
|
-
const selection =
|
82
|
+
const selection = hotMenu.getSelectedLast();
|
67
83
|
if (selection) {
|
68
|
-
|
84
|
+
hotMenu.selection.transformStart(-hotMenu.countVisibleRows(), 0);
|
69
85
|
} else {
|
70
86
|
menu.getNavigator().toFirstItem();
|
71
87
|
}
|
@@ -73,9 +89,9 @@ export function createDefaultShortcutsList(menu) {
|
|
73
89
|
}, {
|
74
90
|
keys: [['PageDown']],
|
75
91
|
callback: () => {
|
76
|
-
const selection =
|
92
|
+
const selection = hotMenu.getSelectedLast();
|
77
93
|
if (selection) {
|
78
|
-
|
94
|
+
hotMenu.selection.transformStart(hotMenu.countVisibleRows(), 0);
|
79
95
|
} else {
|
80
96
|
menu.getNavigator().toLastItem();
|
81
97
|
}
|
@@ -36,74 +36,6 @@ class SelectionCalculations {
|
|
36
36
|
this.hot = plugin.hot;
|
37
37
|
}
|
38
38
|
|
39
|
-
/**
|
40
|
-
* "Snap" the delta value according to defined merged cells. (In other words, compensate the rowspan -
|
41
|
-
* e.g. Going up with `delta.row = -1` over a merged cell with `rowspan = 3`, `delta.row` should change to `-3`.).
|
42
|
-
*
|
43
|
-
* @param {object} delta The delta object containing `row` and `col` properties.
|
44
|
-
* @param {CellRange} selectionRange The selection range.
|
45
|
-
* @param {object} mergedCell A merged cell object.
|
46
|
-
*/
|
47
|
-
snapDelta(delta, selectionRange, mergedCell) {
|
48
|
-
const cellCoords = selectionRange.to;
|
49
|
-
const newRow = cellCoords.row + delta.row;
|
50
|
-
const newColumn = cellCoords.col + delta.col;
|
51
|
-
if (delta.row) {
|
52
|
-
this.jumpOverMergedCell(delta, mergedCell, newRow);
|
53
|
-
} else if (delta.col) {
|
54
|
-
this.jumpOverMergedCell(delta, mergedCell, newColumn);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
/**
|
59
|
-
* "Jump" over the merged cell (compensate for the indexes within the merged cell to get past it).
|
60
|
-
*
|
61
|
-
* @private
|
62
|
-
* @param {object} delta The delta object.
|
63
|
-
* @param {MergedCellCoords} mergedCell The merge cell object.
|
64
|
-
* @param {number} newIndex New row/column index, created with the delta.
|
65
|
-
*/
|
66
|
-
jumpOverMergedCell(delta, mergedCell, newIndex) {
|
67
|
-
let flatDelta = delta.row || delta.col;
|
68
|
-
let includesIndex = null;
|
69
|
-
let firstIndex = null;
|
70
|
-
let lastIndex = null;
|
71
|
-
if (delta.row) {
|
72
|
-
includesIndex = mergedCell.includesVertically(newIndex);
|
73
|
-
firstIndex = mergedCell.row;
|
74
|
-
lastIndex = mergedCell.getLastRow();
|
75
|
-
} else if (delta.col) {
|
76
|
-
includesIndex = mergedCell.includesHorizontally(newIndex);
|
77
|
-
firstIndex = mergedCell.col;
|
78
|
-
lastIndex = mergedCell.getLastColumn();
|
79
|
-
}
|
80
|
-
if (flatDelta === 0) {
|
81
|
-
return;
|
82
|
-
} else if (flatDelta > 0) {
|
83
|
-
if (includesIndex && newIndex !== firstIndex) {
|
84
|
-
flatDelta += lastIndex - newIndex + 1;
|
85
|
-
}
|
86
|
-
} else if (includesIndex && newIndex !== lastIndex) {
|
87
|
-
flatDelta -= newIndex - firstIndex + 1;
|
88
|
-
}
|
89
|
-
if (delta.row) {
|
90
|
-
delta.row = flatDelta;
|
91
|
-
} else if (delta.col) {
|
92
|
-
delta.col = flatDelta;
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
/**
|
97
|
-
* Get a selection range with `to` property incremented by the provided delta.
|
98
|
-
*
|
99
|
-
* @param {CellRange} oldSelectionRange The base selection range.
|
100
|
-
* @param {object} delta The delta object with `row` and `col` properties.
|
101
|
-
* @returns {CellRange} A new `CellRange` object.
|
102
|
-
*/
|
103
|
-
getUpdatedSelectionRange(oldSelectionRange, delta) {
|
104
|
-
return this.hot._createCellRange(oldSelectionRange.highlight, oldSelectionRange.from, this.hot._createCellCoords(oldSelectionRange.to.row + delta.row, oldSelectionRange.to.col + delta.col));
|
105
|
-
}
|
106
|
-
|
107
39
|
/**
|
108
40
|
* Generate an additional class name for the entirely-selected merged cells.
|
109
41
|
*
|
@@ -136,8 +68,7 @@ class SelectionCalculations {
|
|
136
68
|
const fullMergeAreaWithinSelection = startRow <= mergedCell.row && startColumn <= mergedCell.col && endRow >= mergeRowEnd && endColumn >= mergeColumnEnd;
|
137
69
|
if (fullMergeAreaWithinSelection) {
|
138
70
|
return `${this.fullySelectedMergedCellClassName}-${layerLevel}`;
|
139
|
-
} else if (this.
|
140
|
-
// eslint-disable-line max-len
|
71
|
+
} else if (this.isMergeCellFullySelected(mergedCell, this.plugin.hot.getSelectedRange())) {
|
141
72
|
return `${this.fullySelectedMergedCellClassName}-multiple`;
|
142
73
|
}
|
143
74
|
}
|
@@ -33,74 +33,6 @@ class SelectionCalculations {
|
|
33
33
|
this.hot = plugin.hot;
|
34
34
|
}
|
35
35
|
|
36
|
-
/**
|
37
|
-
* "Snap" the delta value according to defined merged cells. (In other words, compensate the rowspan -
|
38
|
-
* e.g. Going up with `delta.row = -1` over a merged cell with `rowspan = 3`, `delta.row` should change to `-3`.).
|
39
|
-
*
|
40
|
-
* @param {object} delta The delta object containing `row` and `col` properties.
|
41
|
-
* @param {CellRange} selectionRange The selection range.
|
42
|
-
* @param {object} mergedCell A merged cell object.
|
43
|
-
*/
|
44
|
-
snapDelta(delta, selectionRange, mergedCell) {
|
45
|
-
const cellCoords = selectionRange.to;
|
46
|
-
const newRow = cellCoords.row + delta.row;
|
47
|
-
const newColumn = cellCoords.col + delta.col;
|
48
|
-
if (delta.row) {
|
49
|
-
this.jumpOverMergedCell(delta, mergedCell, newRow);
|
50
|
-
} else if (delta.col) {
|
51
|
-
this.jumpOverMergedCell(delta, mergedCell, newColumn);
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
/**
|
56
|
-
* "Jump" over the merged cell (compensate for the indexes within the merged cell to get past it).
|
57
|
-
*
|
58
|
-
* @private
|
59
|
-
* @param {object} delta The delta object.
|
60
|
-
* @param {MergedCellCoords} mergedCell The merge cell object.
|
61
|
-
* @param {number} newIndex New row/column index, created with the delta.
|
62
|
-
*/
|
63
|
-
jumpOverMergedCell(delta, mergedCell, newIndex) {
|
64
|
-
let flatDelta = delta.row || delta.col;
|
65
|
-
let includesIndex = null;
|
66
|
-
let firstIndex = null;
|
67
|
-
let lastIndex = null;
|
68
|
-
if (delta.row) {
|
69
|
-
includesIndex = mergedCell.includesVertically(newIndex);
|
70
|
-
firstIndex = mergedCell.row;
|
71
|
-
lastIndex = mergedCell.getLastRow();
|
72
|
-
} else if (delta.col) {
|
73
|
-
includesIndex = mergedCell.includesHorizontally(newIndex);
|
74
|
-
firstIndex = mergedCell.col;
|
75
|
-
lastIndex = mergedCell.getLastColumn();
|
76
|
-
}
|
77
|
-
if (flatDelta === 0) {
|
78
|
-
return;
|
79
|
-
} else if (flatDelta > 0) {
|
80
|
-
if (includesIndex && newIndex !== firstIndex) {
|
81
|
-
flatDelta += lastIndex - newIndex + 1;
|
82
|
-
}
|
83
|
-
} else if (includesIndex && newIndex !== lastIndex) {
|
84
|
-
flatDelta -= newIndex - firstIndex + 1;
|
85
|
-
}
|
86
|
-
if (delta.row) {
|
87
|
-
delta.row = flatDelta;
|
88
|
-
} else if (delta.col) {
|
89
|
-
delta.col = flatDelta;
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
/**
|
94
|
-
* Get a selection range with `to` property incremented by the provided delta.
|
95
|
-
*
|
96
|
-
* @param {CellRange} oldSelectionRange The base selection range.
|
97
|
-
* @param {object} delta The delta object with `row` and `col` properties.
|
98
|
-
* @returns {CellRange} A new `CellRange` object.
|
99
|
-
*/
|
100
|
-
getUpdatedSelectionRange(oldSelectionRange, delta) {
|
101
|
-
return this.hot._createCellRange(oldSelectionRange.highlight, oldSelectionRange.from, this.hot._createCellCoords(oldSelectionRange.to.row + delta.row, oldSelectionRange.to.col + delta.col));
|
102
|
-
}
|
103
|
-
|
104
36
|
/**
|
105
37
|
* Generate an additional class name for the entirely-selected merged cells.
|
106
38
|
*
|
@@ -133,8 +65,7 @@ class SelectionCalculations {
|
|
133
65
|
const fullMergeAreaWithinSelection = startRow <= mergedCell.row && startColumn <= mergedCell.col && endRow >= mergeRowEnd && endColumn >= mergeColumnEnd;
|
134
66
|
if (fullMergeAreaWithinSelection) {
|
135
67
|
return `${this.fullySelectedMergedCellClassName}-${layerLevel}`;
|
136
|
-
} else if (this.
|
137
|
-
// eslint-disable-line max-len
|
68
|
+
} else if (this.isMergeCellFullySelected(mergedCell, this.plugin.hot.getSelectedRange())) {
|
138
69
|
return `${this.fullySelectedMergedCellClassName}-multiple`;
|
139
70
|
}
|
140
71
|
}
|