← All packages

@searsuite/sear-render-input

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

Keyboard input

classHeadlessKeyboardRouter
class HeadlessKeyboardRouter extends KeyboardRouter

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

constructorHeadlessKeyboardRouter(): HeadlessKeyboardRouter
propertyreadonly symbol: symbolstatic

DI token for resolving HeadlessKeyboardRouter.

methodstartListener(): void

Starts listening to the host input source.

methodstopListener(): void

Stops listening to the host input source.

methodsubscribe(_handlers: KeyboardRouterHandlers): void

Subscribes to state changes and returns an idempotent disposer.

Inherited members 4

Inherited from KeyboardRouter.

classInput
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.

constructorInput(): Input
methodstartListener(): void

Starts listening to the host input source.

methodstopListener(): void

Stops listening to the host input source.

Inherited members 4

Inherited from EventListener.

classInputManager

Registry for input adapters owned by one editor instance.

constructorInputManager(textInput: Input): InputManager

Constructs the manager with the configured text input adapter.

textInput

Text input adapter resolved from the host.

propertyreadonly textInput: Input

Text input adapter resolved from the host.

propertyreadonly symbol: symbolstatic

DI token for resolving the input manager.

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

Retrieves an input adapter by symbol.

ReturnsRegistered adapter, or void 0 when absent.

symbol

Adapter symbol.

methodgetTextInput(): TextInput | undefined

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

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

Registers an input adapter.

symbol

Adapter symbol.

input

Adapter instance.

classKeyboardRouter
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.

constructorKeyboardRouter(): KeyboardRouter
propertyreadonly symbol: symbolstatic

DI token for resolving KeyboardRouter.

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

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

Inherited members 6

Inherited from Input.

classWebKeyboardRouter
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().

constructorWebKeyboardRouter(eventTarget: EventTarget): WebKeyboardRouter
propertyreadonly eventTargetSymbol: symbolstatic

DI token for the keyboard event source, normally document.

methodstartListener(): void

Starts listening to the host input source.

methodstopListener(): void

Stops listening to the host input source.

methodsubscribe(handlers: KeyboardRouterHandlers): (): void

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

Inherited members 5

Inherited from KeyboardRouter.

interfaceKeyboardRouterHandlers

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?: (shiftKey: boolean, metaKey: boolean): void
propertyonArrowLeft?: (shiftKey: boolean, metaKey: boolean): void
propertyonArrowRight?: (shiftKey: boolean, metaKey: boolean): void
propertyonArrowUp?: (shiftKey: boolean, metaKey: boolean): void
propertyonCopy?: (): void

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

propertyonCut?: (): void

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

propertyonDelete?: (): void

Backspace / Delete key.

propertyonEdit?: (): void

Enters editing while retaining the selected cell's content.

propertyonEnd?: (shiftKey: boolean): void

Moves to the last occupied cell of the sheet.

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

Enter key – commit the current edit.

propertyonEscape?: (): void

Escape key – cancel the current edit.

propertyonFillDown?: (): void

Ctrl/Cmd + D/R - fill the selection from its top row/left column.

propertyonFillRight?: (): void
propertyonHome?: (primaryModifier: boolean, shiftKey: boolean): void

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

propertyonPage?: (direction: -1 | 1, shiftKey: boolean): void

Moves the active selection by roughly one viewport.

propertyonPaste?: (): void

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

propertyonRedo?: (): void

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

propertyonSelectAll?: (): void

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

propertyonSelectColumn?: (): void

Selects the entire active column.

propertyonSelectRow?: (): void

Selects the entire active row.

propertyonSoftEnter?: (): void

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

propertyonTab?: (shiftKey: boolean): void

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

propertyonToggleBold?: (): void

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

propertyonToggleItalic?: (): void

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

propertyonToggleReference?: (): void

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

propertyonToggleStrikethrough?: (): void

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

propertyonToggleUnderline?: (): void

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

propertyonUndo?: (): void

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

propertyonUnhandledEscape?: (): void

Escape not handled by a focused host control.

propertyonZoomIn?: (): void
propertyonZoomOut?: (): void
propertyonZoomReset?: (): void

Pointer capture

classHeadlessPointerCapture
class HeadlessPointerCapture extends PointerCapture

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

constructorHeadlessPointerCapture(): HeadlessPointerCapture
methodstart(_handlers: PointerCaptureHandlers): (): void

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

methodstop(): void

Stops the active session without invoking its release callback.

Inherited members 1

Inherited from PointerCapture.

classPointerCapture

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

constructorPointerCapture(): PointerCapture
propertyreadonly symbol: symbolstatic

DI token for resolving the pointer capture adapter.

methodstart(handlers: PointerCaptureHandlers): (): void

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

methodstop(): void

Stops the active session without invoking its release callback.

classWebPointerCapture
class WebPointerCapture extends PointerCapture

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

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

Creates one editor-local browser pointer capture adapter.

propertyreadonly eventTargetSymbol: symbolstatic

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

methodstart(handlers: PointerCaptureHandlers): (): void

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

methodstop(): void

Stops the active session without invoking its release callback.

Inherited members 1

Inherited from PointerCapture.

interfacePointerCaptureHandlers

Callbacks active for one host-wide pointer capture session.

propertyreadonly onMove?: (event: PointerCapturePoint): void

Receives pointer movement while capture is active.

propertyreadonly onRelease: (event: PointerCapturePoint): void

Receives the release that ends the capture session.

interfacePointerCapturePoint

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

Text input

classHeadlessTextInput
class HeadlessTextInput extends TextInput

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

constructorHeadlessTextInput(): HeadlessTextInput
propertyreadonly symbol: symbolstatic

DI token for resolving HeadlessTextInput.

methodstartListener(): void

Starts forwarding host text and composition events.

methodstopListener(): void

Stops forwarding host text and composition events.

methodsubscribe(_handlers: TextInputHandlers): void

Subscribes to state changes and returns an idempotent disposer.

Inherited members 7

Inherited from TextInput.

classTextInput
class TextInput extends Input

Routes host text and composition input through portable subscriptions.

constructorTextInput(): TextInput
propertyreadonly symbol: symbolstatic

DI token for resolving TextInput.

methodrefocus(): void

Restores focus to the hidden host text-input surface.

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

Updates the position.

methodstartListener(): void

Starts forwarding host text and composition events.

methodstopListener(): void

Stops forwarding host text and composition events.

methodsubscribe(_handlers: TextInputHandlers): void

Subscribes to state changes and returns an idempotent disposer.

methodisTextInput<T>(event: T): eventstatic

Classifies text events within a typed input-action union.

Inherited members 4

Inherited from Input.

classWebTextInput
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.

constructorWebTextInput(): WebTextInput
propertyonDelete?: (): void

Handles the delete lifecycle event.

propertyonPaste?: (text: string): boolean
propertyonTextInput?: (event: TextInputEvent): void

Handles the input lifecycle event.

methodrefocus(): void

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

methodsetPosition(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.

methodstartListener(): void

Starts forwarding host text and composition events.

methodstopListener(): void

Stops forwarding host text and composition events.

methodsubscribe(handlers: TextInputHandlers): void

Subscribes to state changes and returns an idempotent disposer.

Inherited members 6

Inherited from TextInput.

interfaceTextInputHandlers

Portable text and selection-deletion subscriptions.

propertyonDelete?: (): void

Receives a clipboard cut as deletion of the current selection.

propertyonPaste?: (text: string): boolean

Returns true when a host handles a native paste as a committed grid operation.

propertyonTextInput?: (event: TextInputEvent): void

Receives committed text and composition updates through one ordered stream.

typeTextInputEvent
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.

variableTextInputKind
TextInputKind: { CompositionUpdate: "compositionUpdate"; Text: "text" }

Canonical kinds of portable text-input events.