handsontable
Version:
Handsontable is a JavaScript Data Grid available for React, Angular and Vue.
32 lines (30 loc) • 1.08 kB
JavaScript
;
exports.__esModule = true;
const command = exports.command = {
name: 'extendCellsSelectionToMostLeft',
callback(hot) {
const {
selection,
columnIndexMapper
} = hot;
const {
highlight,
from,
to
} = hot.getSelectedRangeLast();
const isFocusHighlightedByHeader = highlight.isHeader() && selection.isSelectedByColumnHeader();
if (highlight.isCell() || isFocusHighlightedByHeader) {
const column = columnIndexMapper.getNearestNotHiddenIndex(...(hot.isRtl() ? [hot.countCols() - 1, -1] : [0, 1]));
const newFrom = from.clone();
newFrom.col = highlight.col;
selection.markSource('keyboard');
selection.setRangeStart(newFrom, undefined, false, highlight.clone());
// Restore the column highlight by header flag after setting up a new selection.
if (isFocusHighlightedByHeader) {
selection.selectedByColumnHeader.add(selection.getLayerLevel());
}
selection.setRangeEnd(hot._createCellCoords(to.row, column));
selection.markEndSource();
}
}
};