@searsuite/sear-plugin-selection
Selection
SheetSelectionPlugin owns Sheet selection state. SelectRangeCommand requests a new anchor and focus; the
plugin expands a range when it intersects a merged cell, stages selection operations, and publishes a selection
change after commit. GetSelection and GetSelections read the resulting state, while observations notify a host
that needs to update its interface.
import { GetSelection, SelectRangeCommand } from '@searsuite/sear-plugin-selection';
editor.commands.run(SelectRangeCommand, { anchor: [2, 3], focus: [2, 3] });
const selection = editor.queries.run(GetSelection, undefined);
Use when: responding to pointer, keyboard, or application navigation. Coordinates are zero-based. A host should run the command rather than writing the selection matrix or highlight state directly.
Selection has document-facing operations, local navigation state, and a render projection. SheetHighlightPlugin
draws the current range and can combine additional highlight providers; it does not become the owner of the
selected range. EnsureSelectionVisibleCommand asks the viewport to reveal the selection after navigation.
Workbook remounting captures the local selection session through SheetSelectionSessionStateDefinition. The
feature's command and query contracts remain the same when the active Sheet is recreated.
- enumSheetAdditionalSelectionMode
-
How a selection command updates disjoint local selections.
enum member AppendCurrent: "append-current"enum member Clear: "clear"enum member Preserve: "preserve" - enumSheetSelectionInteractionName
-
Enumerates SheetSelectionInteractionName values.
enum member Changed: "selection-changed" - enumSheetSelectionPipelineName
-
Observable pipeline and step names owned by the Selection module.
enum member SelectionChange: "selection-change" - enumSheetSelectionPipelineStepName
-
Enumerates SheetSelectionPipelineStepName values.
- enumSheetSelectionPointerAction
-
Pointer-session transitions owned by the Sheet selection plugin.
- enumSheetSelectionSource
-
Enumerates SheetSelectionSource values.
- classSheetSelectionPlugin
-
class SheetSelectionPlugin extends Plugin<SearCoreSheet, CellProperties, [RectRange, RectRange]>Owns Sheet selections, navigation, commands, and observations.
constructor SheetSelectionPlugin(sheetCellMergePlugin: SheetCellMergePlugin, keyboardRouter: KeyboardRouter, platform?: Platform, interactionReducers?: SheetInteractionReducerRegistry, commands?: SheetCommandBus, rangeMoves?: SheetRangeMoveRegistry, rangeDrag?: SheetRangeDrag, highlights?: SheetHighlightRegistry): SheetSelectionPluginproperty depth: numberDraw and event ordering hint; lower values run earlier.
property interestedIn: MatrixOTActionName[]Declares which Sheet OT action names this plugin is interested in. The engine will only call
applywhen a transaction contains at least one operation matching these action names, unless the transaction is owned by this plugin.['uc', 'rr', 'rc']— only called for UpdateCell, ResizeRow, ResizeCol['*']— called for any transaction (wildcard)[]— only called for this plugin's own transactions
property readonly pluginKey: PluginKeystaticStable plugin key for SheetSelectionPlugin.
property readonly symbol: symbolstaticDI token for resolving SheetSelectionPlugin.
method apply(pluginState: [Rect, Rect], transaction: Transaction): [Rect, Rect] | nullApplies a transaction to SheetSelectionPlugin state.
method bindCore(core: SearCoreSheet): voidBinds this plugin to the core owned by its editor-local container.
method extendForDownwardEntry(): voidAdds a destination row only when Enter would otherwise keep the active cell in place.
method extendForRightwardEntry(): voidAdds a destination column only when Tab would otherwise keep the active cell in place.
method getPluginConfig(searCore: SearCoreSheet): nullReturns the plugin config.
method isInMergedCell(rangeRect: Rect): Rect | nullReturns whether in merged cell.
method lockCommittedState(state: [Rect, Rect]): voidLocks committed selection rectangles while transaction clones remain writable.
method onDblClick(searCore: SearCoreSheet, event: EventWithOffsetAndTarget<CellProperties>): boolean | voidHandles the dbl click lifecycle event.
method onEditorDestroy(): voidCancels transient pointer work before this editor is released.
method onFillHandleDoubleClick(event: EventWithOffsetAndTarget<CellProperties>): booleanLets the editor distinguish the fill handle from a cell-body double click.
method onMouseDown(searCore: SearCoreSheet, event: EventWithOffsetAndTarget<CellProperties>): boolean | voidHandles the mouse down lifecycle event.
method onMouseMove(searCore: SearCoreSheet, event: EventWithOffsetAndTarget<CellProperties>): boolean | voidHandles the mouse move lifecycle event.
method onMouseUp(_searCore: SearCoreSheet, _event: EventWithOffsetAndTarget<CellProperties>): boolean | voidHandles the mouse up lifecycle event.
method onTransactionCommitted(transaction: Transaction): voidRebases local keyboard anchors only after structural transactions commit.
method registerCommands(commands: SheetCommandBus): voidRegisters the commands.
method registerConfig(): { config: ConfigUnit<{ defaultBorderColor: string }>; key: PluginKey }[]Registers default configuration values owned by this plugin.
method registerQueries(queries: SheetQueryRegistry): voidRegisters the active selection as a typed query rather than a DataEngine field.
method registerSessionState(registry: SessionStateRegistry): voidRegisters selection-owned local remount state.
method registerState(): { key: PluginKey; state: [Rect, Rect] }Registers one or more plugin-owned state records with the host manager.
method render(searCore: SearCoreSheet, offset?: { x: number; y: number }): Node<CellProperties>[]Renders SheetSelectionPlugin scene output.
Inherited members 20
Inherited from Plugin.
- documentState
- transactionHistory
- transactionOT
- warnOnDuplicateDepth
- key
- dirtyRect
- enforceRuntimeWriteBoundary
- enforceStateWriteBoundary
- getState
- hasStateWriteBoundary
- onClick
- onInitialDataCell
- onInitialDataComplete
- onResize
- onScroll
- projectTransaction
- sealRuntimeMetadata
- sealRuntimeMethods
- sealRuntimeWrites
- setState
- interfaceSelectionChangedInteractionSignal
-
interface SelectionChangedInteractionSignal extends SheetInteractionSignalproperty anchor: Pointproperty focus: Pointproperty source: SheetSelectionSourceproperty type: SheetSelectionInteractionName - interfaceSheetEnsureSelectionVisibleInput
-
interface SheetEnsureSelectionVisibleInput extends SheetSelectRangeInputInherited members 8
Inherited from SheetSelectRangeInput.
- interfaceSheetSelectionPointerInput
-
Detached input coordinates for a selection pointer transition.
property readonly action: SheetSelectionPointerActionproperty readonly ctrlKey?: booleanproperty readonly metaKey?: booleanproperty readonly shiftKey?: booleanproperty readonly target?: { endColIndex: number | undefined; endRowIndex: number | undefined; region: CellRegion | undefined; startColIndex: number | undefined; startRowIndex: number | undefined } | nullproperty readonly view?: { x: number; y: number } - interfaceSheetSelectRangeInput
-
Public programmatic input for selecting a rectangular sheet range.
property readonly activeAnchor?: PointOptional active anchor stored for in-progress pointer or keyboard interactions.
property readonly activeFocus?: PointOptional active focus stored for in-progress pointer or keyboard interactions.
property readonly additionalSelectionMode?: SheetAdditionalSelectionModeTransition applied to disjoint local selections at commit.
property readonly anchor: PointFinal selected range anchor.
property readonly ensureVisible?: booleanWhether the command should also scroll the selection into view.
property readonly focus: PointFinal selected range focus.
property readonly source?: SheetSelectionSourceOrigin of this selection change.
- typeSheetSelectionSessionState
-
type SheetSelectionSessionState = readonly [RectRange, RectRange]Local selection state retained while remounting one workbook sheet.
- variableEnsureSelectionVisibleCommand
-
EnsureSelectionVisibleCommand: SheetCommandDefinition<SheetEnsureSelectionVisibleInput, SheetCommandResult> - variableGetActiveCell
-
GetActiveCell: SheetQueryDefinition<void, readonly [number, number] | null>Reads the cell where the current selection began, including reversed ranges.
- variableGetSelection
-
GetSelection: SheetQueryDefinition<void, SheetRangeBounds | null>Typed query for the active rectangular selection, independent of selection storage.
- variableGetSelections
-
GetSelections: SheetQueryDefinition<void, readonly SheetRangeBounds[]>All disjoint selections, with the current active rectangle last.
- variableHandleSheetSelectionPointerCommand
-
HandleSheetSelectionPointerCommand: SheetCommandDefinition<SheetSelectionPointerInput, SheetCommandResult>Routes selection pointer-session changes through the editor command bus.
- variableSelectRangeCommand
-
SelectRangeCommand: SheetCommandDefinition<SheetSelectRangeInput, SheetCommandResult> - variableSheetSelectionRenderSemantics
-
SheetSelectionRenderSemantics: { outlineRole: "selection-outline"; owner: "sheet-selection" }Stable semantic attributes emitted by retained render targets for Selection.
- variableSheetSelectionSessionStateDefinition
-
SheetSelectionSessionStateDefinition: SessionStateDefinition<SheetSelectionSessionState>Stable session-state identity owned by SheetSelectionPlugin.
- functionregisterSelectionQueries
-
registerSelectionQueries(queries: SheetQueryRegistry, readSelection: (): SheetRangeBounds | null): voidRegisters the selection query against an editor-local query registry.
- functionregisterSheetSelectionInteractionReducers
-
registerSheetSelectionInteractionReducers(registry: SheetInteractionReducerRegistry): voidRegisters Selection's local interaction projection once per DI container.
Dragging and moving
Drag and move commands update the selected range or fill it, while conflict queries check proposed moves.
- classSheetRangeDrag
-
Owns one local range-border gesture; document changes enter through the move command.
constructor SheetRangeDrag(commands: SheetCommandBus, queries: SheetQueryRegistry, coordinates: CoordinateEngine, pointer: PointerCapture, keyboard: KeyboardRouter, cursorRules: CursorRegistry, cursor: CursorEngine, highlights: SheetHighlightRegistry, platform: Platform, interactions: SheetInteractionStore, inputValidation: SheetCellInputValidationRegistry): SheetRangeDragproperty readonly symbol: typeof symbolstaticmethod bind(core: SearCoreSheet, readSelection: (): Rect, ownerToken: object): voidInstalls editor-local cursor and preview contributions once Core is available.
method destroy(ownerToken?: object): voidIdempotently releases preview, cursor, pointer capture and animation resources.
method isActive(): booleanmethod onFillHandleDoubleClick(event: EventWithOffsetAndTarget<CellProperties>): booleanFills down to the end of a continuous adjacent column when the handle is double-clicked.
method onMouseDown(event: EventWithOffsetAndTarget<CellProperties>): booleanStarts on selection borders or already selected axis headers.
method registerCommands(commands: SheetCommandBus): voidRoutes local pointer and animation inputs through the editor command boundary.
method setUserInteraction(service: UserInteractionService | undefined): voidBinds the optional host-owned confirmation service during assembly.
- classSheetRangeMoveError
-
class SheetRangeMoveError extends SearErrorA range move rejected before any document state was staged.
Inherited members 10
Inherited from SearError.
- interfaceMoveSheetRangeInput
-
Moves a single rectangle to a new top-left coordinate on the same sheet.
property readonly overwrite?: booleanExplicit authorization to replace existing destination data.
property readonly source: SheetMoveRangeproperty readonly target: readonly [number, number] - interfaceSheetFillRangeInput
- typeSheetDragAxis
-
type SheetDragAxis = typeof SheetDragAxis[keyof typeof SheetDragAxis]SheetDragAxis: { Column: 1; Row: 0 }Canonical axes for complete row/column selection gestures.
- typeSheetRangeDragInput
-
type SheetRangeDragInput = { action: typeof SheetRangeDragAction.Begin | typeof SheetRangeDragAction.FillBegin | typeof SheetRangeDragAction.Update | typeof SheetRangeDragAction.Release; point: PointerCapturePoint } | { action: typeof SheetRangeDragAction.Cancel | typeof SheetRangeDragAction.Tick }Portable inputs for one local gesture, never persisted as document state.
- variableAnalyzeSheetRangeMove
-
AnalyzeSheetRangeMove: SheetQueryDefinition<MoveSheetRangeInput, SheetRangeMoveAnalysis>Reads the latest legal destination and owner constraints for a range move.
- variableClearSelectedContentsCommand
-
ClearSelectedContentsCommand: SheetCommandDefinition<void, SheetCommandResult>Clears every rectangle of a disjoint selection in one data transaction.
- variableFillSheetRangeCommand
-
FillSheetRangeCommand: SheetCommandDefinition<SheetFillRangeInput, SheetCommandResult>Fills cells from a selected source rectangle through the pointer destination.
- variableGetSheetRangeMoveConflict
-
GetSheetRangeMoveConflict: SheetQueryDefinition<MoveSheetRangeInput, boolean>Validates a move and reports whether replacement requires user authorization.
- variableHandleSheetRangeDragCommand
-
HandleSheetRangeDragCommand: SheetCommandDefinition<SheetRangeDragInput, SheetCommandResult> - variableMoveSheetRangeCommand
-
MoveSheetRangeCommand: SheetCommandDefinition<MoveSheetRangeInput, SheetCommandResult> - variableSheetRangeDragAction
-
SheetRangeDragAction: { Begin: "begin"; Cancel: "cancel"; FillBegin: "fill-begin"; Release: "release"; Tick: "tick"; Update: "update" }Canonical phases of a local range-border gesture.
- variableSheetRangeMoveErrorCode
-
SheetRangeMoveErrorCode: { DestinationOccupied: "SHEET_MOVE_DESTINATION_OCCUPIED"; InvalidRange: "SHEET_MOVE_INVALID_RANGE" }Stable range-move validation failures exposed to hosts.
Highlights
Highlight providers paint selection-related ranges without changing the committed selection.
- enumSheetHighlightPipelineStepName
-
Observable pipeline steps owned by the generic range-highlight host.
enum member Refresh: "sheet-highlight.refresh" - classSheetHighlightPlugin
-
class SheetHighlightPlugin extends Plugin<SearCoreSheet, CellProperties, Record<string, never>>Renders registered range-highlighter output as a single managed scene layer.
constructor SheetHighlightPlugin(registry: SheetHighlightRegistry): SheetHighlightPluginproperty readonly pluginKey: PluginKeystaticStable plugin key for SheetHighlightPlugin.
property readonly symbol: typeof symbolstaticDI token for resolving SheetHighlightPlugin.
method apply(_state: Record<string, never>, _transaction: Transaction): Record<string, never> | nullApplies a transaction to SheetHighlightPlugin state.
method getPluginConfig(): unknownReturns the plugin config.
method registerState(): { key: PluginKey; state: Record<string, never> }Registers the state.
method render(searCore: SearCoreSheet): Node<CellProperties>[]Renders SheetHighlightPlugin scene output.
Inherited members 29
Inherited from Plugin.
- depth
- documentState
- interestedIn
- transactionHistory
- transactionOT
- warnOnDuplicateDepth
- key
- dirtyRect
- enforceRuntimeWriteBoundary
- enforceStateWriteBoundary
- getState
- hasStateWriteBoundary
- lockCommittedState
- onClick
- onDblClick
- onInitialDataCell
- onInitialDataComplete
- onMouseDown
- onMouseMove
- onMouseUp
- onResize
- onScroll
- onTransactionCommitted
- projectTransaction
- registerConfig
- sealRuntimeMetadata
- sealRuntimeMethods
- sealRuntimeWrites
- setState
- classSheetHighlightRegistry
-
Registry for independently replaceable sheet-range highlighters.
The registry owns provider activation and change notification; the paired SheetHighlightPlugin owns scene-node creation and teardown.
constructor SheetHighlightRegistry(platform?: Platform): SheetHighlightRegistryproperty readonly symbol: typeof symbolstaticDI token for resolving SheetHighlightRegistry.
method getHighlights(context: SheetHighlightContext): SheetRangeHighlight[]Returns the highlights.
method invalidate(): voidRequests a new provider evaluation when state read by a provider (for example selection, search terms, or remote cursors) changes externally.
method register(provider: SheetHighlightProvider): (): voidRegisters the value.
method setEnabled(providerKey: string, enabled: boolean): voidUpdates the enabled.
method subscribe(listener: (): void): (): voidSubscribes to state changes and returns an idempotent disposer.
- interfaceSheetHighlightContext
-
Read-only sheet state made available to every range-highlight provider.
property searCore: SearCoreSheet - interfaceSheetHighlightProvider
-
Extension point for range decorations such as formula precedents, search results, validation errors, collaboration selections, and audit trails.
- interfaceSheetRangeHighlight
-
A visual-only cell range supplied by an independently registered provider.
property depth?: numberproperty edge?: SheetHighlightEdgeproperty end: Pointproperty fill?: stringproperty inset?: numberInsets the visual box from the resolved cell-range boundary.
property overlay?: booleanPaints a transient range above the grid in the final overlay pass.
property skipHit?: booleanproperty start: Pointproperty stroke?: stringproperty strokeWidth?: numberproperty type?: string - typeSheetHighlightEdge
-
type SheetHighlightEdge = typeof SheetHighlightEdge[keyof typeof SheetHighlightEdge]SheetHighlightEdge: { Bottom: "bottom"; Left: "left"; Right: "right"; Top: "top" }Viewport-spanning overlay guide anchored to a cell-range edge.
No matching API entries.