blob: a24bbf5dbffbcce99bb07a1558b92b3897909e24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import { CellRef, cellRefEquals } from "../../types";
export type CellRange = [start: CellRef, end: CellRef];
export interface GridSelection {
activeCellRef: CellRef;
range?: CellRange;
}
export function extendSelection(
selection: GridSelection | undefined,
cellRef: CellRef,
): GridSelection {
if (!selection || cellRefEquals(selection.activeCellRef, cellRef)) {
return { activeCellRef: cellRef };
}
if (selection.range) {
return { ...selection, range: [selection.range[0], cellRef] };
}
return { ...selection, range: [selection.activeCellRef, cellRef] };
}
|