import type { Editor } from '@tiptap/core'; import type { Transaction } from '@tiptap/pm/state'; export interface ControlledCompositionRange { from: number; to: number; } export interface ControlledCompositionSnapshot { id: number; range: ControlledCompositionRange | null; text: string | null; } type CompositionSettledHandler = (editor: Editor, snapshot: ControlledCompositionSnapshot) => void; /** * Tracks the browser-owned part of a controlled TipTap composition. * * WebKit can expose the provisional Latin spelling to ProseMirror, dispatch * `compositionend`, and only then deliver the committed CJK text. Merely * delaying `onChange` leaves both strings in the document. This controller * keeps the original composition range mapped through every transaction and * gives the owning editor one bounded opportunity to replace that range with * the committed text after the browser has finished its DOM flush. */ export declare class ControlledEditorComposition { private active; private committedInputSeen; private committedText; private compositionData; private deadline; private generation; private awaitingCommittedTransaction; private range; private rangeFrozen; private settling; private settleAt; private settleHandler; private settleEditor; private sessionId; private timer; /** Start tracking the selection that the browser is about to compose over. */ start(editor?: Editor | null): void; /** * Keep the composition range aligned with ProseMirror's current document. * This includes the transaction generated when a browser first exposes the * provisional pinyin and the transaction generated by a late committed * input event. */ recordTransaction(transaction: Transaction): void; /** Observe beforeinput/input without taking ownership of the browser event. */ noteInput(event: Event): void; /** * End a composition. The two-argument form is retained for the Markdown and * presentation editors; document editing passes compositionend.data as the * middle argument so late WebKit input can be distinguished from typing. */ end(editor: Editor, dataOrHandler: string | null | undefined | CompositionSettledHandler, maybeHandler?: CompositionSettledHandler): void; isBlocking(editor?: Editor | null): boolean; destroy(): void; private selectionRange; private currentRangeText; private snapshot; private scheduleQuietSettlement; private scheduleSettlement; private clearSettlement; private cancelTimer; } export {};