Skip to content

API reference / Common / Engine types / TableSelection

Type Alias: TableSelection ​

ts
type TableSelection = 
  | {
  cells: {
     table: TableId;
     anchor: TableCellRef;
     focus: TableCellRef;
  };
}
  | {
  rows: {
     table: TableId;
     anchor: TableRowId;
     focus: TableRowId;
  };
}
  | {
  columns: {
     table: TableId;
     anchor: TableColumnId;
     focus: TableColumnId;
  };
}
  | {
  all: {
     table: TableId;
  };
}
  | {
  cellText: {
     table: TableId;
     cell: TableCellRef;
     text: TextSelection;
  };
};

What is selected inside one table — a block of cells, whole rows or columns, the whole table, or a caret / range in one cell's text.

Every variant names its own [TableId], as SpreadsheetSelection names its sheet on all four of its. A table selection is meaningless apart from its table — every consumer already takes the &Table beside it, and no selection can be routed to a different one.

Entities are named by id (a cell by its [TableCellRef] pair), not by index: ids are minted once and shared by every replica, so a selection survives a concurrent row or column insert untouched, and a concurrently deleted row simply stops resolving. There is no empty variant — emptiness is the embedding selection's own None.

The blocks are kept directed — an anchor and a focus rather than a normalized range — so a Shift-extend holds the anchor and moves only the focus. That is the shape a spreadsheet's SpreadsheetSelection takes for the same reason; the difference here is that the axes carry ids rather than indices, so the two corners name rows and columns rather than positions.