handsontable 0.0.0-next-0bd37c1-20240513 → 0.0.0-next-c2f1254-20240515
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/base.js +2 -2
- package/base.mjs +2 -2
- package/core.js +76 -179
- package/core.mjs +76 -179
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +1969 -1977
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +6 -6
- package/dist/handsontable.js +2441 -2449
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +9 -9
- package/editorManager.js +0 -67
- package/editorManager.mjs +0 -67
- package/editors/baseEditor/baseEditor.js +1 -36
- package/editors/baseEditor/baseEditor.mjs +2 -37
- package/editors/dateEditor/dateEditor.js +4 -1
- package/editors/dateEditor/dateEditor.mjs +4 -1
- package/editors/handsontableEditor/handsontableEditor.js +2 -2
- package/editors/handsontableEditor/handsontableEditor.mjs +2 -2
- package/editors/selectEditor/selectEditor.js +1 -9
- package/editors/selectEditor/selectEditor.mjs +1 -9
- package/editors/textEditor/textEditor.js +2 -11
- package/editors/textEditor/textEditor.mjs +2 -11
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/autofill/autofill.js +1 -1
- package/plugins/autofill/autofill.mjs +1 -1
- package/selection/selection.js +156 -4
- package/selection/selection.mjs +156 -4
- package/shortcutContexts/commands/editor/closeAndSave.js +2 -3
- package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -3
- package/shortcutContexts/commands/editor/closeAndSaveByArrowKeys.js +27 -0
- package/shortcutContexts/commands/editor/closeAndSaveByArrowKeys.mjs +24 -0
- package/shortcutContexts/commands/editor/closeAndSaveByEnter.js +11 -0
- package/shortcutContexts/commands/editor/closeAndSaveByEnter.mjs +8 -0
- package/shortcutContexts/commands/editor/index.js +3 -1
- package/shortcutContexts/commands/editor/index.mjs +3 -1
- package/shortcutContexts/editor.js +9 -1
- package/shortcutContexts/editor.mjs +9 -1
- package/shortcutContexts/index.js +1 -1
- package/shortcutContexts/index.mjs +1 -1
package/selection/selection.js
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
require("core-js/modules/es.error.cause.js");
|
5
|
+
require("core-js/modules/es.array.push.js");
|
5
6
|
require("core-js/modules/esnext.set.difference.v2.js");
|
6
7
|
require("core-js/modules/esnext.set.intersection.v2.js");
|
7
8
|
require("core-js/modules/esnext.set.is-disjoint-from.v2.js");
|
@@ -427,7 +428,23 @@ class Selection {
|
|
427
428
|
}
|
428
429
|
this.runLocalHooks('beforeHighlightSet');
|
429
430
|
this.setRangeFocus(this.selectedRange.current().highlight);
|
430
|
-
|
431
|
+
this.applyAndCommit();
|
432
|
+
const isLastLayer = _classPrivateFieldGet(_expectedLayersCount, this) === -1 || this.selectedRange.size() === _classPrivateFieldGet(_expectedLayersCount, this);
|
433
|
+
this.runLocalHooks('afterSetRangeEnd', coords, isLastLayer);
|
434
|
+
}
|
435
|
+
|
436
|
+
/**
|
437
|
+
* Applies and commits the selection to all layers (using the Walkontable Selection API) based on the selection (CellRanges)
|
438
|
+
* collected in the `selectedRange` module.
|
439
|
+
*
|
440
|
+
* @param {CellRange} [cellRange] The cell range to apply. If not provided, the current selection is used.
|
441
|
+
* @param {number} [layerLevel] The layer level to apply. If not provided, the current layer level is used.
|
442
|
+
*/
|
443
|
+
applyAndCommit() {
|
444
|
+
let cellRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.selectedRange.current();
|
445
|
+
let layerLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLayerLevel();
|
446
|
+
const countRows = this.tableProps.countRows();
|
447
|
+
const countCols = this.tableProps.countCols();
|
431
448
|
|
432
449
|
// If the next layer level is lower than previous then clear all area and header highlights. This is the
|
433
450
|
// indication that the new selection is performing.
|
@@ -509,8 +526,6 @@ class Selection {
|
|
509
526
|
activeCornerHeaderHighlight.add(this.tableProps.createCellCoords(-this.tableProps.countColHeaders(), -this.tableProps.countRowHeaders())).add(this.tableProps.createCellCoords(-1, -1)).commit();
|
510
527
|
}
|
511
528
|
}
|
512
|
-
const isLastLayer = _classPrivateFieldGet(_expectedLayersCount, this) === -1 || this.selectedRange.size() === _classPrivateFieldGet(_expectedLayersCount, this);
|
513
|
-
this.runLocalHooks('afterSetRangeEnd', coords, isLastLayer);
|
514
529
|
}
|
515
530
|
|
516
531
|
/**
|
@@ -607,6 +622,104 @@ class Selection {
|
|
607
622
|
this.setRangeFocus(focusCoords.normalize());
|
608
623
|
}
|
609
624
|
|
625
|
+
/**
|
626
|
+
* Transforms the last selection layer down or up by the index count.
|
627
|
+
*
|
628
|
+
* @param {number} visualRowIndex Visual row index from which the selection will be shifted.
|
629
|
+
* @param {number} amount The number of rows to shift the selection.
|
630
|
+
*/
|
631
|
+
shiftRows(visualRowIndex, amount) {
|
632
|
+
if (!this.isSelected()) {
|
633
|
+
return;
|
634
|
+
}
|
635
|
+
const range = this.selectedRange.current();
|
636
|
+
if (this.isSelectedByCorner()) {
|
637
|
+
this.selectAll(true, true, {
|
638
|
+
disableHeadersHighlight: true
|
639
|
+
});
|
640
|
+
} else if (this.isSelectedByColumnHeader() || range.getOuterTopStartCorner().row >= visualRowIndex) {
|
641
|
+
const {
|
642
|
+
from,
|
643
|
+
to,
|
644
|
+
highlight
|
645
|
+
} = range;
|
646
|
+
const countRows = this.tableProps.countRows();
|
647
|
+
const isSelectedByRowHeader = this.isSelectedByRowHeader();
|
648
|
+
const isSelectedByColumnHeader = this.isSelectedByColumnHeader();
|
649
|
+
const minRow = isSelectedByColumnHeader ? -1 : 0;
|
650
|
+
const coordsStartAmount = isSelectedByColumnHeader ? 0 : amount;
|
651
|
+
|
652
|
+
// Remove from the stack the last added selection as that selection below will be
|
653
|
+
// replaced by new transformed selection.
|
654
|
+
this.getSelectedRange().pop();
|
655
|
+
const coordsStart = this.tableProps.createCellCoords((0, _number.clamp)(from.row + coordsStartAmount, minRow, countRows - 1), from.col);
|
656
|
+
const coordsEnd = this.tableProps.createCellCoords((0, _number.clamp)(to.row + amount, minRow, countRows - 1), to.col);
|
657
|
+
this.markSource('shift');
|
658
|
+
if (highlight.row >= visualRowIndex) {
|
659
|
+
this.setRangeStartOnly(coordsStart, true, this.tableProps.createCellCoords((0, _number.clamp)(highlight.row + amount, 0, countRows - 1), highlight.col));
|
660
|
+
} else {
|
661
|
+
this.setRangeStartOnly(coordsStart, true);
|
662
|
+
}
|
663
|
+
if (isSelectedByRowHeader) {
|
664
|
+
this.selectedByRowHeader.add(this.getLayerLevel());
|
665
|
+
}
|
666
|
+
if (isSelectedByColumnHeader) {
|
667
|
+
this.selectedByColumnHeader.add(this.getLayerLevel());
|
668
|
+
}
|
669
|
+
this.setRangeEnd(coordsEnd);
|
670
|
+
this.markEndSource();
|
671
|
+
}
|
672
|
+
}
|
673
|
+
|
674
|
+
/**
|
675
|
+
* Transforms the last selection layer left or right by the index count.
|
676
|
+
*
|
677
|
+
* @param {number} visualColumnIndex Visual column index from which the selection will be shifted.
|
678
|
+
* @param {number} amount The number of columns to shift the selection.
|
679
|
+
*/
|
680
|
+
shiftColumns(visualColumnIndex, amount) {
|
681
|
+
if (!this.isSelected()) {
|
682
|
+
return;
|
683
|
+
}
|
684
|
+
const range = this.selectedRange.current();
|
685
|
+
if (this.isSelectedByCorner()) {
|
686
|
+
this.selectAll(true, true, {
|
687
|
+
disableHeadersHighlight: true
|
688
|
+
});
|
689
|
+
} else if (this.isSelectedByRowHeader() || range.getOuterTopStartCorner().col >= visualColumnIndex) {
|
690
|
+
const {
|
691
|
+
from,
|
692
|
+
to,
|
693
|
+
highlight
|
694
|
+
} = range;
|
695
|
+
const countCols = this.tableProps.countCols();
|
696
|
+
const isSelectedByRowHeader = this.isSelectedByRowHeader();
|
697
|
+
const isSelectedByColumnHeader = this.isSelectedByColumnHeader();
|
698
|
+
const minColumn = isSelectedByRowHeader ? -1 : 0;
|
699
|
+
const coordsStartAmount = isSelectedByRowHeader ? 0 : amount;
|
700
|
+
|
701
|
+
// Remove from the stack the last added selection as that selection below will be
|
702
|
+
// replaced by new transformed selection.
|
703
|
+
this.getSelectedRange().pop();
|
704
|
+
const coordsStart = this.tableProps.createCellCoords(from.row, (0, _number.clamp)(from.col + coordsStartAmount, minColumn, countCols - 1));
|
705
|
+
const coordsEnd = this.tableProps.createCellCoords(to.row, (0, _number.clamp)(to.col + amount, minColumn, countCols - 1));
|
706
|
+
this.markSource('shift');
|
707
|
+
if (highlight.col >= visualColumnIndex) {
|
708
|
+
this.setRangeStartOnly(coordsStart, true, this.tableProps.createCellCoords(highlight.row, (0, _number.clamp)(highlight.col + amount, 0, countCols - 1)));
|
709
|
+
} else {
|
710
|
+
this.setRangeStartOnly(coordsStart, true);
|
711
|
+
}
|
712
|
+
if (isSelectedByRowHeader) {
|
713
|
+
this.selectedByRowHeader.add(this.getLayerLevel());
|
714
|
+
}
|
715
|
+
if (isSelectedByColumnHeader) {
|
716
|
+
this.selectedByColumnHeader.add(this.getLayerLevel());
|
717
|
+
}
|
718
|
+
this.setRangeEnd(coordsEnd);
|
719
|
+
this.markEndSource();
|
720
|
+
}
|
721
|
+
}
|
722
|
+
|
610
723
|
/**
|
611
724
|
* Returns currently used layer level.
|
612
725
|
*
|
@@ -1039,9 +1152,48 @@ class Selection {
|
|
1039
1152
|
}
|
1040
1153
|
|
1041
1154
|
/**
|
1042
|
-
*
|
1155
|
+
* Refreshes the whole selection by clearing, reapplying and committing the renderable selection (Walkontable Selection API)
|
1156
|
+
* by using already added visual ranges.
|
1043
1157
|
*/
|
1044
1158
|
refresh() {
|
1159
|
+
if (!this.isSelected()) {
|
1160
|
+
return;
|
1161
|
+
}
|
1162
|
+
const countRows = this.tableProps.countRows();
|
1163
|
+
const countColumns = this.tableProps.countCols();
|
1164
|
+
if (countRows === 0 || countColumns === 0) {
|
1165
|
+
this.deselect();
|
1166
|
+
return;
|
1167
|
+
}
|
1168
|
+
const range = this.selectedRange.peekByIndex(this.selectedRange.size() - 1);
|
1169
|
+
const {
|
1170
|
+
from,
|
1171
|
+
to,
|
1172
|
+
highlight
|
1173
|
+
} = range;
|
1174
|
+
this.clear();
|
1175
|
+
highlight.assign({
|
1176
|
+
row: (0, _number.clamp)(highlight.row, -Infinity, countRows - 1),
|
1177
|
+
col: (0, _number.clamp)(highlight.col, -Infinity, countColumns - 1)
|
1178
|
+
});
|
1179
|
+
from.assign({
|
1180
|
+
row: (0, _number.clamp)(from.row, -Infinity, countRows - 1),
|
1181
|
+
col: (0, _number.clamp)(from.col, -Infinity, countColumns - 1)
|
1182
|
+
});
|
1183
|
+
to.assign({
|
1184
|
+
row: (0, _number.clamp)(to.row, 0, countRows - 1),
|
1185
|
+
col: (0, _number.clamp)(to.col, 0, countColumns - 1)
|
1186
|
+
});
|
1187
|
+
this.selectedRange.ranges.push(range);
|
1188
|
+
this.highlight.getFocus().add(highlight).commit().syncWith(range);
|
1189
|
+
this.applyAndCommit(range);
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
/**
|
1193
|
+
* Refreshes the whole selection by recommitting (recalculating visual indexes to renderable ones) the renderable selection
|
1194
|
+
* that was already added.
|
1195
|
+
*/
|
1196
|
+
commit() {
|
1045
1197
|
const customSelections = this.highlight.getCustomSelections();
|
1046
1198
|
customSelections.forEach(customSelection => {
|
1047
1199
|
customSelection.commit();
|
package/selection/selection.mjs
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
2
|
+
import "core-js/modules/es.array.push.js";
|
2
3
|
import "core-js/modules/esnext.set.difference.v2.js";
|
3
4
|
import "core-js/modules/esnext.set.intersection.v2.js";
|
4
5
|
import "core-js/modules/esnext.set.is-disjoint-from.v2.js";
|
@@ -421,7 +422,23 @@ class Selection {
|
|
421
422
|
}
|
422
423
|
this.runLocalHooks('beforeHighlightSet');
|
423
424
|
this.setRangeFocus(this.selectedRange.current().highlight);
|
424
|
-
|
425
|
+
this.applyAndCommit();
|
426
|
+
const isLastLayer = _classPrivateFieldGet(_expectedLayersCount, this) === -1 || this.selectedRange.size() === _classPrivateFieldGet(_expectedLayersCount, this);
|
427
|
+
this.runLocalHooks('afterSetRangeEnd', coords, isLastLayer);
|
428
|
+
}
|
429
|
+
|
430
|
+
/**
|
431
|
+
* Applies and commits the selection to all layers (using the Walkontable Selection API) based on the selection (CellRanges)
|
432
|
+
* collected in the `selectedRange` module.
|
433
|
+
*
|
434
|
+
* @param {CellRange} [cellRange] The cell range to apply. If not provided, the current selection is used.
|
435
|
+
* @param {number} [layerLevel] The layer level to apply. If not provided, the current layer level is used.
|
436
|
+
*/
|
437
|
+
applyAndCommit() {
|
438
|
+
let cellRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.selectedRange.current();
|
439
|
+
let layerLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getLayerLevel();
|
440
|
+
const countRows = this.tableProps.countRows();
|
441
|
+
const countCols = this.tableProps.countCols();
|
425
442
|
|
426
443
|
// If the next layer level is lower than previous then clear all area and header highlights. This is the
|
427
444
|
// indication that the new selection is performing.
|
@@ -503,8 +520,6 @@ class Selection {
|
|
503
520
|
activeCornerHeaderHighlight.add(this.tableProps.createCellCoords(-this.tableProps.countColHeaders(), -this.tableProps.countRowHeaders())).add(this.tableProps.createCellCoords(-1, -1)).commit();
|
504
521
|
}
|
505
522
|
}
|
506
|
-
const isLastLayer = _classPrivateFieldGet(_expectedLayersCount, this) === -1 || this.selectedRange.size() === _classPrivateFieldGet(_expectedLayersCount, this);
|
507
|
-
this.runLocalHooks('afterSetRangeEnd', coords, isLastLayer);
|
508
523
|
}
|
509
524
|
|
510
525
|
/**
|
@@ -601,6 +616,104 @@ class Selection {
|
|
601
616
|
this.setRangeFocus(focusCoords.normalize());
|
602
617
|
}
|
603
618
|
|
619
|
+
/**
|
620
|
+
* Transforms the last selection layer down or up by the index count.
|
621
|
+
*
|
622
|
+
* @param {number} visualRowIndex Visual row index from which the selection will be shifted.
|
623
|
+
* @param {number} amount The number of rows to shift the selection.
|
624
|
+
*/
|
625
|
+
shiftRows(visualRowIndex, amount) {
|
626
|
+
if (!this.isSelected()) {
|
627
|
+
return;
|
628
|
+
}
|
629
|
+
const range = this.selectedRange.current();
|
630
|
+
if (this.isSelectedByCorner()) {
|
631
|
+
this.selectAll(true, true, {
|
632
|
+
disableHeadersHighlight: true
|
633
|
+
});
|
634
|
+
} else if (this.isSelectedByColumnHeader() || range.getOuterTopStartCorner().row >= visualRowIndex) {
|
635
|
+
const {
|
636
|
+
from,
|
637
|
+
to,
|
638
|
+
highlight
|
639
|
+
} = range;
|
640
|
+
const countRows = this.tableProps.countRows();
|
641
|
+
const isSelectedByRowHeader = this.isSelectedByRowHeader();
|
642
|
+
const isSelectedByColumnHeader = this.isSelectedByColumnHeader();
|
643
|
+
const minRow = isSelectedByColumnHeader ? -1 : 0;
|
644
|
+
const coordsStartAmount = isSelectedByColumnHeader ? 0 : amount;
|
645
|
+
|
646
|
+
// Remove from the stack the last added selection as that selection below will be
|
647
|
+
// replaced by new transformed selection.
|
648
|
+
this.getSelectedRange().pop();
|
649
|
+
const coordsStart = this.tableProps.createCellCoords(clamp(from.row + coordsStartAmount, minRow, countRows - 1), from.col);
|
650
|
+
const coordsEnd = this.tableProps.createCellCoords(clamp(to.row + amount, minRow, countRows - 1), to.col);
|
651
|
+
this.markSource('shift');
|
652
|
+
if (highlight.row >= visualRowIndex) {
|
653
|
+
this.setRangeStartOnly(coordsStart, true, this.tableProps.createCellCoords(clamp(highlight.row + amount, 0, countRows - 1), highlight.col));
|
654
|
+
} else {
|
655
|
+
this.setRangeStartOnly(coordsStart, true);
|
656
|
+
}
|
657
|
+
if (isSelectedByRowHeader) {
|
658
|
+
this.selectedByRowHeader.add(this.getLayerLevel());
|
659
|
+
}
|
660
|
+
if (isSelectedByColumnHeader) {
|
661
|
+
this.selectedByColumnHeader.add(this.getLayerLevel());
|
662
|
+
}
|
663
|
+
this.setRangeEnd(coordsEnd);
|
664
|
+
this.markEndSource();
|
665
|
+
}
|
666
|
+
}
|
667
|
+
|
668
|
+
/**
|
669
|
+
* Transforms the last selection layer left or right by the index count.
|
670
|
+
*
|
671
|
+
* @param {number} visualColumnIndex Visual column index from which the selection will be shifted.
|
672
|
+
* @param {number} amount The number of columns to shift the selection.
|
673
|
+
*/
|
674
|
+
shiftColumns(visualColumnIndex, amount) {
|
675
|
+
if (!this.isSelected()) {
|
676
|
+
return;
|
677
|
+
}
|
678
|
+
const range = this.selectedRange.current();
|
679
|
+
if (this.isSelectedByCorner()) {
|
680
|
+
this.selectAll(true, true, {
|
681
|
+
disableHeadersHighlight: true
|
682
|
+
});
|
683
|
+
} else if (this.isSelectedByRowHeader() || range.getOuterTopStartCorner().col >= visualColumnIndex) {
|
684
|
+
const {
|
685
|
+
from,
|
686
|
+
to,
|
687
|
+
highlight
|
688
|
+
} = range;
|
689
|
+
const countCols = this.tableProps.countCols();
|
690
|
+
const isSelectedByRowHeader = this.isSelectedByRowHeader();
|
691
|
+
const isSelectedByColumnHeader = this.isSelectedByColumnHeader();
|
692
|
+
const minColumn = isSelectedByRowHeader ? -1 : 0;
|
693
|
+
const coordsStartAmount = isSelectedByRowHeader ? 0 : amount;
|
694
|
+
|
695
|
+
// Remove from the stack the last added selection as that selection below will be
|
696
|
+
// replaced by new transformed selection.
|
697
|
+
this.getSelectedRange().pop();
|
698
|
+
const coordsStart = this.tableProps.createCellCoords(from.row, clamp(from.col + coordsStartAmount, minColumn, countCols - 1));
|
699
|
+
const coordsEnd = this.tableProps.createCellCoords(to.row, clamp(to.col + amount, minColumn, countCols - 1));
|
700
|
+
this.markSource('shift');
|
701
|
+
if (highlight.col >= visualColumnIndex) {
|
702
|
+
this.setRangeStartOnly(coordsStart, true, this.tableProps.createCellCoords(highlight.row, clamp(highlight.col + amount, 0, countCols - 1)));
|
703
|
+
} else {
|
704
|
+
this.setRangeStartOnly(coordsStart, true);
|
705
|
+
}
|
706
|
+
if (isSelectedByRowHeader) {
|
707
|
+
this.selectedByRowHeader.add(this.getLayerLevel());
|
708
|
+
}
|
709
|
+
if (isSelectedByColumnHeader) {
|
710
|
+
this.selectedByColumnHeader.add(this.getLayerLevel());
|
711
|
+
}
|
712
|
+
this.setRangeEnd(coordsEnd);
|
713
|
+
this.markEndSource();
|
714
|
+
}
|
715
|
+
}
|
716
|
+
|
604
717
|
/**
|
605
718
|
* Returns currently used layer level.
|
606
719
|
*
|
@@ -1033,9 +1146,48 @@ class Selection {
|
|
1033
1146
|
}
|
1034
1147
|
|
1035
1148
|
/**
|
1036
|
-
*
|
1149
|
+
* Refreshes the whole selection by clearing, reapplying and committing the renderable selection (Walkontable Selection API)
|
1150
|
+
* by using already added visual ranges.
|
1037
1151
|
*/
|
1038
1152
|
refresh() {
|
1153
|
+
if (!this.isSelected()) {
|
1154
|
+
return;
|
1155
|
+
}
|
1156
|
+
const countRows = this.tableProps.countRows();
|
1157
|
+
const countColumns = this.tableProps.countCols();
|
1158
|
+
if (countRows === 0 || countColumns === 0) {
|
1159
|
+
this.deselect();
|
1160
|
+
return;
|
1161
|
+
}
|
1162
|
+
const range = this.selectedRange.peekByIndex(this.selectedRange.size() - 1);
|
1163
|
+
const {
|
1164
|
+
from,
|
1165
|
+
to,
|
1166
|
+
highlight
|
1167
|
+
} = range;
|
1168
|
+
this.clear();
|
1169
|
+
highlight.assign({
|
1170
|
+
row: clamp(highlight.row, -Infinity, countRows - 1),
|
1171
|
+
col: clamp(highlight.col, -Infinity, countColumns - 1)
|
1172
|
+
});
|
1173
|
+
from.assign({
|
1174
|
+
row: clamp(from.row, -Infinity, countRows - 1),
|
1175
|
+
col: clamp(from.col, -Infinity, countColumns - 1)
|
1176
|
+
});
|
1177
|
+
to.assign({
|
1178
|
+
row: clamp(to.row, 0, countRows - 1),
|
1179
|
+
col: clamp(to.col, 0, countColumns - 1)
|
1180
|
+
});
|
1181
|
+
this.selectedRange.ranges.push(range);
|
1182
|
+
this.highlight.getFocus().add(highlight).commit().syncWith(range);
|
1183
|
+
this.applyAndCommit(range);
|
1184
|
+
}
|
1185
|
+
|
1186
|
+
/**
|
1187
|
+
* Refreshes the whole selection by recommitting (recalculating visual indexes to renderable ones) the renderable selection
|
1188
|
+
* that was already added.
|
1189
|
+
*/
|
1190
|
+
commit() {
|
1039
1191
|
const customSelections = this.highlight.getCustomSelections();
|
1040
1192
|
customSelections.forEach(customSelection => {
|
1041
1193
|
customSelection.commit();
|
@@ -3,9 +3,8 @@
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
const command = exports.command = {
|
5
5
|
name: 'editorCloseAndSave',
|
6
|
-
callback(hot
|
6
|
+
callback(hot) {
|
7
7
|
const editorManager = hot._getEditorManager();
|
8
|
-
editorManager.closeEditorAndSaveChanges(
|
9
|
-
editorManager.moveSelectionAfterEnter(event);
|
8
|
+
editorManager.closeEditorAndSaveChanges();
|
10
9
|
}
|
11
10
|
};
|
@@ -1,8 +1,7 @@
|
|
1
1
|
export const command = {
|
2
2
|
name: 'editorCloseAndSave',
|
3
|
-
callback(hot
|
3
|
+
callback(hot) {
|
4
4
|
const editorManager = hot._getEditorManager();
|
5
|
-
editorManager.closeEditorAndSaveChanges(
|
6
|
-
editorManager.moveSelectionAfterEnter(event);
|
5
|
+
editorManager.closeEditorAndSaveChanges();
|
7
6
|
}
|
8
7
|
};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
var _baseEditor = require("../../../editors/baseEditor");
|
5
|
+
const command = exports.command = {
|
6
|
+
name: 'editorCloseAndSaveByArrowKeys',
|
7
|
+
callback(hot, event, keys) {
|
8
|
+
const editorManager = hot._getEditorManager();
|
9
|
+
const activeEditor = editorManager.getActiveEditor();
|
10
|
+
if (activeEditor.isInFullEditMode() && activeEditor.state === _baseEditor.EDITOR_STATE.EDITING) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
editorManager.closeEditorAndSaveChanges();
|
14
|
+
if (hot.getSelected()) {
|
15
|
+
if (keys.includes('arrowdown')) {
|
16
|
+
hot.selection.transformStart(1, 0);
|
17
|
+
} else if (keys.includes('arrowup')) {
|
18
|
+
hot.selection.transformStart(-1, 0);
|
19
|
+
} else if (keys.includes('arrowleft')) {
|
20
|
+
hot.selection.transformStart(0, -1 * hot.getDirectionFactor());
|
21
|
+
} else if (keys.includes('arrowright')) {
|
22
|
+
hot.selection.transformStart(0, hot.getDirectionFactor());
|
23
|
+
}
|
24
|
+
}
|
25
|
+
event.preventDefault();
|
26
|
+
}
|
27
|
+
};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { EDITOR_STATE } from "../../../editors/baseEditor/index.mjs";
|
2
|
+
export const command = {
|
3
|
+
name: 'editorCloseAndSaveByArrowKeys',
|
4
|
+
callback(hot, event, keys) {
|
5
|
+
const editorManager = hot._getEditorManager();
|
6
|
+
const activeEditor = editorManager.getActiveEditor();
|
7
|
+
if (activeEditor.isInFullEditMode() && activeEditor.state === EDITOR_STATE.EDITING) {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
editorManager.closeEditorAndSaveChanges();
|
11
|
+
if (hot.getSelected()) {
|
12
|
+
if (keys.includes('arrowdown')) {
|
13
|
+
hot.selection.transformStart(1, 0);
|
14
|
+
} else if (keys.includes('arrowup')) {
|
15
|
+
hot.selection.transformStart(-1, 0);
|
16
|
+
} else if (keys.includes('arrowleft')) {
|
17
|
+
hot.selection.transformStart(0, -1 * hot.getDirectionFactor());
|
18
|
+
} else if (keys.includes('arrowright')) {
|
19
|
+
hot.selection.transformStart(0, hot.getDirectionFactor());
|
20
|
+
}
|
21
|
+
}
|
22
|
+
event.preventDefault();
|
23
|
+
}
|
24
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
const command = exports.command = {
|
5
|
+
name: 'editorCloseAndSaveByEnter',
|
6
|
+
callback(hot, event) {
|
7
|
+
const editorManager = hot._getEditorManager();
|
8
|
+
editorManager.closeEditorAndSaveChanges(event.ctrlKey || event.metaKey);
|
9
|
+
editorManager.moveSelectionAfterEnter(event);
|
10
|
+
}
|
11
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export const command = {
|
2
|
+
name: 'editorCloseAndSaveByEnter',
|
3
|
+
callback(hot, event) {
|
4
|
+
const editorManager = hot._getEditorManager();
|
5
|
+
editorManager.closeEditorAndSaveChanges(event.ctrlKey || event.metaKey);
|
6
|
+
editorManager.moveSelectionAfterEnter(event);
|
7
|
+
}
|
8
|
+
};
|
@@ -3,6 +3,8 @@
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
exports.getAllCommands = getAllCommands;
|
5
5
|
var _closeAndSave = require("./closeAndSave");
|
6
|
+
var _closeAndSaveByArrowKeys = require("./closeAndSaveByArrowKeys");
|
7
|
+
var _closeAndSaveByEnter = require("./closeAndSaveByEnter");
|
6
8
|
var _closeWithoutSaving = require("./closeWithoutSaving");
|
7
9
|
var _fastOpen = require("./fastOpen");
|
8
10
|
var _open = require("./open");
|
@@ -12,5 +14,5 @@ var _open = require("./open");
|
|
12
14
|
* @returns {Function[]}
|
13
15
|
*/
|
14
16
|
function getAllCommands() {
|
15
|
-
return [_closeAndSave.command, _closeWithoutSaving.command, _fastOpen.command, _open.command];
|
17
|
+
return [_closeAndSave.command, _closeAndSaveByArrowKeys.command, _closeAndSaveByEnter.command, _closeWithoutSaving.command, _fastOpen.command, _open.command];
|
16
18
|
}
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import { command as closeAndSave } from "./closeAndSave.mjs";
|
2
|
+
import { command as closeAndSaveByArrowKeys } from "./closeAndSaveByArrowKeys.mjs";
|
3
|
+
import { command as closeAndSaveByEnter } from "./closeAndSaveByEnter.mjs";
|
2
4
|
import { command as closeWithoutSaving } from "./closeWithoutSaving.mjs";
|
3
5
|
import { command as fastOpen } from "./fastOpen.mjs";
|
4
6
|
import { command as open } from "./open.mjs";
|
@@ -8,5 +10,5 @@ import { command as open } from "./open.mjs";
|
|
8
10
|
* @returns {Function[]}
|
9
11
|
*/
|
10
12
|
export function getAllCommands() {
|
11
|
-
return [closeAndSave, closeWithoutSaving, fastOpen, open];
|
13
|
+
return [closeAndSave, closeAndSaveByArrowKeys, closeAndSaveByEnter, closeWithoutSaving, fastOpen, open];
|
12
14
|
}
|
@@ -17,11 +17,19 @@ function shortcutsEditorContext(hot) {
|
|
17
17
|
};
|
18
18
|
context.addShortcuts([{
|
19
19
|
keys: [['Enter'], ['Enter', 'Shift']],
|
20
|
-
callback: (event, keys) => commandsPool.
|
20
|
+
callback: (event, keys) => commandsPool.editorCloseAndSaveByEnter(event, keys)
|
21
21
|
}, {
|
22
22
|
keys: [['Enter', 'Control/Meta'], ['Enter', 'Control/Meta', 'Shift']],
|
23
23
|
captureCtrl: true,
|
24
|
+
callback: (event, keys) => commandsPool.editorCloseAndSaveByEnter(event, keys)
|
25
|
+
}, {
|
26
|
+
keys: [['Tab'], ['Tab', 'Shift'], ['PageDown'], ['PageUp']],
|
27
|
+
forwardToContext: hot.getShortcutManager().getContext('grid'),
|
24
28
|
callback: (event, keys) => commandsPool.editorCloseAndSave(event, keys)
|
29
|
+
}, {
|
30
|
+
keys: [['ArrowDown'], ['ArrowUp'], ['ArrowLeft'], ['ArrowRight']],
|
31
|
+
preventDefault: false,
|
32
|
+
callback: (event, keys) => commandsPool.editorCloseAndSaveByArrowKeys(event, keys)
|
25
33
|
}, {
|
26
34
|
keys: [['Escape'], ['Escape', 'Control/Meta']],
|
27
35
|
callback: () => commandsPool.editorCloseWithoutSaving()
|
@@ -13,11 +13,19 @@ export function shortcutsEditorContext(hot) {
|
|
13
13
|
};
|
14
14
|
context.addShortcuts([{
|
15
15
|
keys: [['Enter'], ['Enter', 'Shift']],
|
16
|
-
callback: (event, keys) => commandsPool.
|
16
|
+
callback: (event, keys) => commandsPool.editorCloseAndSaveByEnter(event, keys)
|
17
17
|
}, {
|
18
18
|
keys: [['Enter', 'Control/Meta'], ['Enter', 'Control/Meta', 'Shift']],
|
19
19
|
captureCtrl: true,
|
20
|
+
callback: (event, keys) => commandsPool.editorCloseAndSaveByEnter(event, keys)
|
21
|
+
}, {
|
22
|
+
keys: [['Tab'], ['Tab', 'Shift'], ['PageDown'], ['PageUp']],
|
23
|
+
forwardToContext: hot.getShortcutManager().getContext('grid'),
|
20
24
|
callback: (event, keys) => commandsPool.editorCloseAndSave(event, keys)
|
25
|
+
}, {
|
26
|
+
keys: [['ArrowDown'], ['ArrowUp'], ['ArrowLeft'], ['ArrowRight']],
|
27
|
+
preventDefault: false,
|
28
|
+
callback: (event, keys) => commandsPool.editorCloseAndSaveByArrowKeys(event, keys)
|
21
29
|
}, {
|
22
30
|
keys: [['Escape'], ['Escape', 'Control/Meta']],
|
23
31
|
callback: () => commandsPool.editorCloseWithoutSaving()
|
@@ -20,5 +20,5 @@ Object.keys(_constants).forEach(function (key) {
|
|
20
20
|
* @param {Handsontable} hotInstance The Handsontable instance.
|
21
21
|
*/
|
22
22
|
function registerAllShortcutContexts(hotInstance) {
|
23
|
-
[
|
23
|
+
[_grid.shortcutsGridContext, _editor.shortcutsEditorContext].forEach(context => context(hotInstance));
|
24
24
|
}
|
@@ -7,5 +7,5 @@ export * from "./constants.mjs";
|
|
7
7
|
* @param {Handsontable} hotInstance The Handsontable instance.
|
8
8
|
*/
|
9
9
|
export function registerAllShortcutContexts(hotInstance) {
|
10
|
-
[
|
10
|
+
[shortcutsGridContext, shortcutsEditorContext].forEach(context => context(hotInstance));
|
11
11
|
}
|