From ca7edbcc6b201df7b5070cde205e66f576948475 Mon Sep 17 00:00:00 2001 From: Josh Kingsley Date: Sun, 26 Oct 2025 21:04:24 +0200 Subject: feat(web): add subdivideSelection method --- web/src/selection.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'web/src/selection.ts') 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]; + } } -- cgit v1.2.3