← All packages

API reference

@searsuite/sear-render-input

Keyboard, pointer, text-input, and composition routing contracts.

17 exportsderived from source

classHeadlessKeyboardRoutersource ↗
class HeadlessKeyboardRouter extends KeyboardRouter

Keyboard router for hosts that do not expose a keyboard event source.

constructorconstructor
HeadlessKeyboardRouter(): HeadlessKeyboardRouter
propertysymbolstatic
readonly symbol: symbol

DI token for resolving HeadlessKeyboardRouter.

methodstartListener
startListener(): void

Starts listening to the host input source.

methodstopListener
stopListener(): void

Stops listening to the host input source.

methodsubscribe
subscribe(_handlers: KeyboardRouterHandlers): void

Subscribes to state changes and returns an idempotent disposer.

_handlers: KeyboardRouterHandlers
Inherited members 4

Inherited from KeyboardRouter.

classHeadlessPointerCapturesource ↗
class HeadlessPointerCapture extends PointerCapture

No-op pointer capture adapter for hosts without a pointer event source.

constructorconstructor
HeadlessPointerCapture(): HeadlessPointerCapture
methodstart
start(_handlers: PointerCaptureHandlers): (): void

Starts one capture session and returns a disposer for that session.

_handlers: PointerCaptureHandlers
methodstop
stop(): void

Stops the active session without invoking its release callback.

Inherited members 1

Inherited from PointerCapture.

classHeadlessTextInputsource ↗
class HeadlessTextInput extends TextInput

Text-input adapter that intentionally owns no platform input element.

constructorconstructor
HeadlessTextInput(): HeadlessTextInput

Creates a TextInput instance.

propertysymbolstatic
readonly symbol: symbol

DI token for resolving HeadlessTextInput.

methodstartListener
startListener(): void

Starts forwarding host text and composition events.

methodstopListener
stopListener(): void

Stops forwarding host text and composition events.

methodsubscribe
subscribe(_handlers: TextInputHandlers): void

Subscribes to state changes and returns an idempotent disposer.

_handlers: TextInputHandlers
Inherited members 7

Inherited from TextInput.

classInputsource ↗
class Input extends EventListener

Base class for host input adapters.

Input adapters bridge platform events into the shared EventListener contract and expose explicit listener lifecycle methods for assembly teardown.

constructorconstructor
Input(): Input
methodstartListener
startListener(): void

Starts listening to the host input source.

methodstopListener
stopListener(): void

Stops listening to the host input source.

Inherited members 4

Inherited from EventListener.

classInputManagersource ↗
class InputManager

Registry for input adapters owned by one editor instance.

constructorconstructor
InputManager(textInput: Input): InputManager

Constructs the manager with the configured text input adapter.

textInput: Input

Text input adapter resolved from the host.

propertytextInput
readonly textInput: Input

Text input adapter resolved from the host.

propertysymbolstatic
readonly symbol: symbol

DI token for resolving the input manager.

methodget
get<T>(symbol: symbol): T | undefined

Retrieves an input adapter by symbol.

ReturnsRegistered adapter, or void 0 when absent.

symbol: symbol

Adapter symbol.

methodgetTextInput
getTextInput(): TextInput | undefined

Returns the text-input adapter when it has been registered.

methodregister
register(symbol: symbol, input: Input): void

Registers an input adapter.

symbol: symbol

Adapter symbol.

input: Input

Adapter instance.

classKeyboardRoutersource ↗
class KeyboardRouter extends Input

Abstract keyboard-shortcut router.

Implementations intercept action keys (arrows, Enter, Escape, Backspace, Ctrl+A/B/C/V/X and Tab) and dispatch them to the registered handlers. Unlike TextInput, implementations MUST work regardless of which DOM element currently holds focus – this is the key contract that fixes the "Ctrl+A lost after clicking canvas" problem.

Lifecycle: startListener() – attach the listener for the editor instance. stopListener() – detach it when the editor is destroyed.

constructorconstructor
KeyboardRouter(): KeyboardRouter
propertysymbolstatic
readonly symbol: symbol

DI token for resolving KeyboardRouter.

methodsubscribe
subscribe(handlers: KeyboardRouterHandlers): void | (): void

Installs handlers; implementations may return a disposer that restores the previous handlers.

handlers: KeyboardRouterHandlers
Inherited members 6

Inherited from Input.

classPointerCapturesource ↗
class PointerCapture

Platform-neutral, editor-local host-wide pointer capture contract.

constructorconstructor
PointerCapture(): PointerCapture
propertysymbolstatic
readonly symbol: symbol

DI token for resolving the pointer capture adapter.

methodstart
start(handlers: PointerCaptureHandlers): (): void

Starts one capture session and returns a disposer for that session.

handlers: PointerCaptureHandlers
methodstop
stop(): void

Stops the active session without invoking its release callback.

classTextInputsource ↗
class TextInput extends Input

Routes host text and composition input through portable subscriptions.

constructorconstructor
TextInput(): TextInput

Creates a TextInput instance.

propertysymbolstatic
readonly symbol: symbol

DI token for resolving TextInput.

methodrefocus
refocus(): void

Restores focus to the hidden host text-input surface.

methodsetPosition
setPosition(_x: number, _y: number): void

Updates the position.

_x: number
_y: number
methodstartListener
startListener(): void

Starts forwarding host text and composition events.

methodstopListener
stopListener(): void

Stops forwarding host text and composition events.

methodsubscribe
subscribe(_handlers: TextInputHandlers): void

Subscribes to state changes and returns an idempotent disposer.

_handlers: TextInputHandlers
methodisTextInputstatic
isTextInput<T>(event: T): event

Classifies text events within a typed input-action union.

event: T
Inherited members 4

Inherited from Input.

classWebKeyboardRoutersource ↗
class WebKeyboardRouter extends KeyboardRouter

Browser implementation of KeyboardRouter.

Attaches a keydown listener to the injected EventTarget in the capture phase so that keyboard shortcuts are intercepted before any bubbling-phase handler can act on them, and – critically – regardless of which DOM element holds editor focus at the time. Native host form controls retain their own keys. This means shortcuts like Ctrl+A remain functional even after a canvas click has shifted browser focus away from the hidden &lt;input&gt; used for IME composition.

The EventTarget (typically document) is injected via DI using WebKeyboardRouter.eventTargetSymbol, keeping this class free of hard-coded browser globals and making it straightforward to test with a stub.

The listener is active only between startListener() / stopListener().

constructorconstructor
WebKeyboardRouter(eventTarget: EventTarget): WebKeyboardRouter

Creates a WebKeyboardRouter instance.

eventTarget: EventTarget
propertyeventTargetSymbolstatic
readonly eventTargetSymbol: symbol

DI token for the keyboard event source, normally document.

methodstartListener
startListener(): void

Starts listening to the host input source.

methodstopListener
stopListener(): void

Stops listening to the host input source.

methodsubscribe
subscribe(handlers: KeyboardRouterHandlers): (): void

Installs handlers; implementations may return a disposer that restores the previous handlers.

handlers: KeyboardRouterHandlers
Inherited members 5

Inherited from KeyboardRouter.

classWebPointerCapturesource ↗
class WebPointerCapture extends PointerCapture

Browser pointer capture adapter that emits render-root view coordinates.

constructorconstructor
WebPointerCapture(renderContext: RenderContext, platform: Platform, eventTarget: unknown): WebPointerCapture

Creates one editor-local browser pointer capture adapter.

renderContext: RenderContext
platform: Platform
eventTarget: unknown
propertyeventTargetSymbolstatic
readonly eventTargetSymbol: symbol

DI token for the host-wide event source, normally document.

methodstart
start(handlers: PointerCaptureHandlers): (): void

Starts one capture session and returns a disposer for that session.

handlers: PointerCaptureHandlers
methodstop
stop(): void

Stops the active session without invoking its release callback.

Inherited members 1

Inherited from PointerCapture.

classWebTextInputsource ↗
class WebTextInput extends TextInput

Browser implementation of TextInput.

Manages a hidden &lt;input&gt; element that receives IME composition events and regular printable-character input. All keyboard-shortcut / action-key handling (arrows, Enter, Escape, Backspace, Ctrl+A) has been moved to WebKeyboardRouter so that those shortcuts remain functional even when browser focus shifts away from this element (e.g. after a canvas click).

The hidden input must still hold focus during active editing so that the OS IME candidate window is anchored to it. Call refocus() whenever a pointer event inside the editor area moves focus elsewhere.

constructorconstructor
WebTextInput(): WebTextInput

Creates a WebTextInput instance.

propertyonDelete
onDelete?: (): void

Handles the delete lifecycle event.

propertyonTextInput
onTextInput?: (event: TextInputEvent): void

Handles the input lifecycle event.

methodrefocus
refocus(): void

Restore focus to the hidden input (e.g. after a canvas click moves focus away).

methodsetPosition
setPosition(x: number, y: number): void

Move the hidden input to the cursor's screen position so that the OS IME candidate window is anchored near the cell being edited.

x: number
y: number
methodstartListener
startListener(): void

Starts forwarding host text and composition events.

methodstopListener
stopListener(): void

Stops forwarding host text and composition events.

methodsubscribe
subscribe(handlers: TextInputHandlers): void

Subscribes to state changes and returns an idempotent disposer.

handlers: TextInputHandlers
Inherited members 6

Inherited from TextInput.

interfaceKeyboardRouterHandlerssource ↗
interface KeyboardRouterHandlers

Callbacks for all keyboard-shortcut / action-key events that the editor needs to intercept. These are intentionally separate from text composition events (which remain the responsibility of TextInput).

propertyonArrowDown
onArrowDown?: (shiftKey: boolean, metaKey: boolean): void
propertyonArrowLeft
onArrowLeft?: (shiftKey: boolean, metaKey: boolean): void
propertyonArrowRight
onArrowRight?: (shiftKey: boolean, metaKey: boolean): void
propertyonArrowUp
onArrowUp?: (shiftKey: boolean, metaKey: boolean): void
propertyonCopy
onCopy?: (): void

Ctrl/Cmd + C - copy the active sheet selection.

propertyonCut
onCut?: (): void

Ctrl/Cmd + X - cut the active sheet selection.

propertyonDelete
onDelete?: (): void

Backspace / Delete key.

propertyonEdit
onEdit?: (): void

Enters editing while retaining the selected cell's content.

propertyonEnd
onEnd?: (): void

Moves to the last occupied cell of the sheet.

propertyonEnter
onEnter?: (shiftKey: boolean, primaryModifier?: boolean): void

Enter key – commit the current edit.

propertyonEscape
onEscape?: (): void

Escape key – cancel the current edit.

propertyonHome
onHome?: (primaryModifier: boolean): void

Moves to the start of the active row, or sheet with a primary modifier.

propertyonPage
onPage?: (direction: -1 | 1): void

Moves the active selection by roughly one viewport.

propertyonPaste
onPaste?: (): void

Ctrl/Cmd + V - paste from the host clipboard.

propertyonRedo
onRedo?: (): void

Ctrl/Cmd + Shift + Z or Ctrl/Cmd + Y - redo the latest undone mutation.

propertyonSelectAll
onSelectAll?: (): void

Ctrl/Cmd + A – select all content in the editor.

propertyonSelectColumn
onSelectColumn?: (): void

Selects the entire active column.

propertyonSelectRow
onSelectRow?: (): void

Selects the entire active row.

propertyonSoftEnter
onSoftEnter?: (): void

Alt/Option + Enter – insert a line break (soft enter) inside the cell.

propertyonTab
onTab?: (shiftKey: boolean): void

Tab / Shift+Tab - move the active sheet selection horizontally.

propertyonToggleBold
onToggleBold?: (): void

Ctrl/Cmd + B - toggle bold text in the active rich-text editor.

propertyonToggleItalic
onToggleItalic?: (): void

Ctrl/Cmd + I - toggle italic text in the active rich-text editor.

propertyonToggleReference
onToggleReference?: (): void

Cycles the reference at the formula caret through relative and absolute modes.

propertyonToggleStrikethrough
onToggleStrikethrough?: (): void

Ctrl/Cmd + Shift + X - toggle strikethrough text in the active rich-text editor.

propertyonToggleUnderline
onToggleUnderline?: (): void

Ctrl/Cmd + U - toggle underlined text in the active rich-text editor.

propertyonUndo
onUndo?: (): void

Ctrl/Cmd + Z - undo the latest sheet mutation.

propertyonUnhandledEscape
onUnhandledEscape?: (): void

Escape not handled by a focused host control.

propertyonZoomIn
onZoomIn?: (): void
propertyonZoomOut
onZoomOut?: (): void
propertyonZoomReset
onZoomReset?: (): void
interfacePointerCaptureHandlerssource ↗
interface PointerCaptureHandlers

Callbacks active for one host-wide pointer capture session.

propertyonMove
readonly onMove?: (event: PointerCapturePoint): void

Receives pointer movement while capture is active.

propertyonRelease
readonly onRelease: (event: PointerCapturePoint): void

Receives the release that ends the capture session.

interfacePointerCapturePointsource ↗
interface PointerCapturePoint

Pointer position normalized to the editor render root's view coordinates.

propertyview
readonly view: { x: number; y: number }
interfaceTextInputHandlerssource ↗
interface TextInputHandlers

Portable text and selection-deletion subscriptions.

propertyonDelete
onDelete?: (): void

Receives a clipboard cut as deletion of the current selection.

propertyonTextInput
onTextInput?: (event: TextInputEvent): void

Receives committed text and composition updates through one ordered stream.

typeTextInputEventsource ↗
type TextInputEvent = { kind: typeof TextInputKind.Text; text: string } | { caretOffset: number; kind: typeof TextInputKind.CompositionUpdate; text: string }

Committed text or an in-flight composition update, including composition clearing.

variableTextInputKindsource ↗
TextInputKind: { CompositionUpdate: "compositionUpdate"; Text: "text" }

Canonical kinds of portable text-input events.