Input Bridge
Class reference for InputBridge.
The InputBridge creates an invisible proxy <textarea> that accurately hijacks all keystrokes, clipboard actions, and Input Method Editor (IME) flows to translate native actions to the Headless Editor math, bypassing contenteditable.
Constructor
new InputBridge(opts: InputBridgeOptions)InputBridgeOptions
getState / dispatch / getSchema / getCharMap / getViewportRect / getFloatPosition: Read-only lazy state pullers wrapping the complex Editor engine natively.keymap: The resolved keybindings dictating hotkey actions.inputHandlers: Interceptor functions specific to DOM keystrokes.navigator: The proxy Editor reference interface.pasteTransformer: ThePasteTransformerinstance handlingclipboardDataoperations.onFocus / onBlur: Bubble tracking for UX boundaries.
Properties
isFocused
get isFocused(): booleanReturns true when the invisible <textarea> natively holds the browser's DOM execution focus.
container
get container(): HTMLElement | nullThe parent physical node containing the hidden proxy.
Methods
Mounting & Lifecycle
mount(container: HTMLElement)
mount(container: HTMLElement): voidGenerates the invisible textarea, styles it specifically to 1x1 pixels invisibly, and attaches the 8 critical DOM event listeners (input, compositionend, cut, copy, paste, keydown).
unmount()
unmount(): voidRemoves the textarea and detaches all listeners globally.
focus()
focus(): voidProgrammatically instructs the browser to native-focus the <textarea> to intercept inputs organically.
Scrolling & Positioning
syncPosition()
syncPosition(): voidPhysically offsets the textarea.style.top/left/height directly to hover beneath the mathematical cursor coordinates. Doing this ensures Mobile Keyboard Magnifiers open near the actual text, preventing the OS from jumping erratically natively.
scrollCursorIntoView()
scrollCursorIntoView(): voidUses the CharacterMap output coordinates to execute internal scrollTop bounding box adjustments on the nearest parent overflow scroller, locking the cursor in the visible frame gracefully.
setPageElementLookup()
setPageElementLookup(fn: ((page: number) => HTMLElement | null) | null): voidAccepts an adapter resolver that translates a 1-based internal layout page into the physical Browser DOM <div data-page="1"> Wrapper, required for Scroll-Into-View math accurately.
lookupPage()
lookupPage(page: number): HTMLElement | nullRetrieves the DOM node representing the specified page.
Utility Functions
keyEventToString()
export function keyEventToString(e: KeyboardEvent): stringTranslates raw DOM Event variants into predictable ProseMirror mapping targets like "Mod-Shift-z".
findScrollParent()
export function findScrollParent(el: HTMLElement | null): HTMLElement | nullRecursively traverses up the DOM to locate the primary overflow host natively.