UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

47 lines (46 loc) 1.8 kB
import { ValueSyncStore } from '../../../util/events/sync-store'; import type { Printable } from 'tree-dump'; import type { KeyController } from './KeyController'; import type { PeritextEventTarget } from '../../events/PeritextEventTarget'; import type { UiLifeCycles } from '../types'; import type { Peritext } from '../../../json-crdt-extensions/peritext'; export interface CursorControllerOpts { /** * Element to attach the controller to, this element will be used to listen to * "beforeinput" events and will be put into "contenteditable" mode. */ source: HTMLElement; txt: Peritext; et: PeritextEventTarget; keys: KeyController; } /** * Controller for handling text selection and cursor movements. Listens to * naive browser events and translates them into Peritext events. */ export declare class CursorController implements UiLifeCycles, Printable { readonly opts: CursorControllerOpts; readonly caretId: string; private readonly _cursor; constructor(opts: CursorControllerOpts); /** The position where user started to scrub the text. */ protected selAnchor: number; /** * String position at coordinate, or -1, if unknown. */ protected posAtPoint(x: number, y: number): number; /** -------------------------------------------------- {@link UiLifeCycles} */ start(): () => void; readonly focus: ValueSyncStore<boolean>; private readonly onFocus; private readonly onBlur; private x; private y; readonly mouseDown: ValueSyncStore<boolean>; private readonly onMouseDown; private readonly onMouseMove; private readonly onMouseUp; private onKeyDown; /** ----------------------------------------------------- {@link Printable} */ toString(tab?: string): string; }