fn

createSelectionBridge

Signature

ts
export function createSelectionBridge(
  getRoot: () => HTMLElement | null,
  blockElements: BlockElementRegistry,
): SelectionBridge{ ... }

Parameters

ParameterTypeDescription
getRoot() => HTMLElement | null
blockElementsBlockElementRegistry

Returns

SelectionBridge
PropertyTypeDescription
read() => Selection | nullRead the native selection as a model selection (null if outside writekit).
write(selection: Selection) => voidApply a model selection to the native selection (focusing the root).
save() => Selection | nullSnapshot the current model selection.
restore(selection: Selection | null) => voidRestore a previously saved selection.
domPointToOffset(host: HTMLElement, node: Node, offset: number) => number
offsetToDomPoint(host: HTMLElement, offset: number) => { node: Node; offset: number }