/** * The keys pressed between a click on a text and the caret going into it. * * Most clicks start the edit in the click itself, because the Studio has told * the page beforehand which of its elements are texts and what they hold * (`textFields` in the canvas protocol). This is for the rest: a text whose * value changed since the Studio last said, so the page cannot tell on its own * that the element shows it and asks (`clicked`, then `editInline`). That * round trip takes long enough -- a few hundred milliseconds in development -- * for the first letters of a word typed straight after the click to land on * the page's body, which drops them, and for an `End` to be lost so that what * follows goes in at the click. * * So they are held, and nothing else hears them: neither the page's own * shortcuts nor the browser, so nothing is scrolled or typed where the caret * is not. When the edit starts they are replayed into it * ({@link replayKeys}); when the Studio opens the field in its column instead, * they are dropped, which is what a key pressed on a page that is not being * typed in does anyway. * * Not held: Escape (Select's own way out, heard by the bridge), a modifier on * its own, and anything mid-composition, which belongs to an input method this * cannot replay. */ export type HeldKey = { key: string; shiftKey: boolean; ctrlKey: boolean; metaKey: boolean; altKey: boolean; }; export type HeldKeys = { /** Stop holding, and hand over what was held, in the order pressed. */ release(): HeldKey[]; }; /** * How long keys are held at most. The Studio answers every pick it asks the * page about, so this is only for an answer that never comes (a Studio that * went away mid-pick): the page's keyboard is not taken for longer. */ export declare const HOLD_KEYS_MS = 2000; /** Hold the keys pressed in `view` from now until {@link HeldKeys.release}. */ export declare function holdKeys(view: Window, options?: { timeoutMs?: number; }): HeldKeys; /** * Press `keys` again, in the text being typed in on the page: what the * keyboard would have done had the caret been there when they were pressed. * * A synthetic key event types nothing -- the browser does no default action * for an event a script made -- so each key goes through the same two events * a real one does, and its effect is done here only where nothing handled * them: * * 1. `keydown`, to the copy: what ends a single line (Enter) or the edit * (Escape) is heard there, as for a real key. * 2. `beforeinput`, for a key that edits: what joins two blocks of a richtext * (Backspace at the start of one) or splits one (Enter) is handled there, * as for a real key (`inlineEditing.ts`). * 3. Otherwise the browser's own editing, through `execCommand` -- which is * what `inlineEditing.ts` types with too -- or the selection's own `modify` * for a key that moves the caret. * * Tab and shortcuts other than select-all are dropped: they would act on the * page or the browser, not on the text. Replay stops when the edit does -- * an Enter that ended a single line -- and the keys after it are dropped, as * they would have gone to a page that is no longer being typed in. */ export declare function replayKeys(doc: Document, keys: readonly HeldKey[]): void;