summaryrefslogtreecommitdiff
path: root/web/src/selection.ts
diff options
context:
space:
mode:
authorJosh Kingsley <josh@joshkingsley.me>2025-10-26 21:04:24 +0200
committerJosh Kingsley <josh@joshkingsley.me>2025-10-26 21:04:24 +0200
commitca7edbcc6b201df7b5070cde205e66f576948475 (patch)
tree8700db8148efb224375424840bf9cf8fdee3dd4e /web/src/selection.ts
parentaf8cf348feb8e6bb4bda4a277b06a0f41ff890d9 (diff)
feat(web): add subdivideSelection method
Diffstat (limited to 'web/src/selection.ts')
-rw-r--r--web/src/selection.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/web/src/selection.ts b/web/src/selection.ts
index 294db52..abaf8b5 100644
--- a/web/src/selection.ts
+++ b/web/src/selection.ts
@@ -17,6 +17,9 @@ export abstract class Selection {
abstract extend(cellRef: CellRef): Selection;
abstract getSelectedCells(grid: RenderedGrid): RenderedCell[][];
+
+ abstract startCellRef(): CellRef;
+ abstract endCellRef(): CellRef;
}
export class ActiveCellSelection extends Selection {
@@ -34,6 +37,14 @@ export class ActiveCellSelection extends Selection {
getSelectedCells(grid: RenderedGrid): RenderedCell[][] {
return [[getRenderedCell(grid, this.activeCellRef)!]];
}
+
+ startCellRef(): CellRef {
+ return this.activeCellRef;
+ }
+
+ endCellRef(): CellRef {
+ return this.activeCellRef;
+ }
}
export type CellRange = [CellRef, CellRef];
@@ -101,4 +112,12 @@ export class RangeSelection extends Selection {
return row.renderedCells.slice(firstCellIndex, lastCellIndex + 1);
});
}
+
+ startCellRef(): CellRef {
+ return this.range[0];
+ }
+
+ endCellRef(): CellRef {
+ return this.range[1];
+ }
}