UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

28 lines (27 loc) 1.86 kB
import { SubscriptionEventTarget } from '../../../util/events/TypedEventTarget'; import type { PeritextEventDetailMap, CursorDetail, FormatDetail, DeleteDetail, MarkerDetail, BufferDetail, SelectionMoveInstruction } from './types'; export type PeritextEventMap = { [K in keyof PeritextEventDetailMap]: CustomEvent<PeritextEventDetailMap[K]>; }; export type PeritextEventHandlerMap = { [K in keyof PeritextEventDetailMap]: (event: CustomEvent<PeritextEventDetailMap[K]>) => void; }; export declare class PeritextEventTarget extends SubscriptionEventTarget<PeritextEventMap> { readonly id: number; defaults: Partial<PeritextEventHandlerMap>; dispatch<K extends keyof Omit<PeritextEventDetailMap, 'change'>>(type: K, detail: Omit<PeritextEventDetailMap, 'change'>[K]): void; change(ev?: CustomEvent<any>): void; insert(text: string): void; delete(len: number, unit?: SelectionMoveInstruction[1]): void; delete(edge: SelectionMoveInstruction[0], unit: SelectionMoveInstruction[1], len?: SelectionMoveInstruction[2], collapse?: SelectionMoveInstruction[3]): void; delete(detail?: DeleteDetail): void; cursor(detail: CursorDetail): void; move(edge: SelectionMoveInstruction[0], unit: SelectionMoveInstruction[1], len?: SelectionMoveInstruction[2], collapse?: SelectionMoveInstruction[3]): void; move(move?: CursorDetail['move'], at?: CursorDetail['at']): void; format(action: FormatDetail['action'], type: FormatDetail['type'], stack?: FormatDetail['stack'], data?: FormatDetail['data']): void; format(detail: FormatDetail): void; marker(action: MarkerDetail['action'], type: MarkerDetail['type'], data?: MarkerDetail['data']): void; marker(detail: MarkerDetail): void; buffer(action: BufferDetail['action'], format?: BufferDetail['format']): void; buffer(detail: BufferDetail): void; }