import { type Person } from "./mentions"; import type { Mention } from "../model/types"; export interface ComposerOptions { /** Something quiet at the start of the button row, left of Cancel: the draft's "stays in this browser" glyph. */ lead?: Node; /** The send button's word ("Comment", "Reply", "Save"), and the line's name for screen readers unless `name`. */ label: string; /** The line's name for screen readers, when it isn't the button's word ("Edit comment"). */ name?: string; /** What the empty line says ("Comment or add others with @"). */ placeholder?: string; /** Words already in the line (editing a comment). */ value?: string; /** A new comment, or a reply in `thread()`. */ kind?: "comment" | "reply"; thread?: () => string; /** `mentions`: the people named in the words, found after trimming. */ onSend(text: string, mentions: Mention[]): Promise | void; /** Cancel or Esc: `words` are what was thrown away ("" when the line was empty). */ onCancel?(words: string): void; /** Who can be mentioned with `@`; without it, `@` is just a character. */ people?(): Person[]; } export interface Composer { element: HTMLElement; input: HTMLTextAreaElement; focus(): void; } /** One live insertion at the caret: words in progress, then final words. */ export interface Dictation { /** Replace the words in progress. */ update(text: string): void; /** Make them final; the next update starts after them. */ commit(text: string): void; /** Remove the words in progress. */ cancel(): void; } export interface ComposerHandle { readonly kind: "comment" | "reply"; readonly thread: string | null; text(): string; focus(): void; /** The box is still on screen. */ connected(): boolean; /** aria-pressed and the button's look. */ setPressed(on: boolean): void; dictate(): Dictation; /** Send, cancel, clear. Poll `connected()` for a box that is removed. */ onEnd(fn: () => void): () => void; } export interface ComposerTool { id: string; /** 24-unit SVG path data. */ icon: readonly string[]; /** Tooltip and aria-label. */ label: string; /** false: no button at all. */ available?(): boolean; press(handle: ComposerHandle): void; } /** What add-ons put in writing lines; set by the app while add-ons are mounted. */ export interface ComposerSource { tools(): ComposerTool[]; note(): string | null; /** Some add-on reports in the menu's top line (comments may be going elsewhere). */ reporting(): boolean; } export declare const setComposerSource: (s: ComposerSource | null) => void; /** The one quiet line add-ons may show above the new-comment box. */ export declare const composerNote: () => string | null; /** Whether an add-on reports in the menu's top line, where Pipeup's own "stays in this browser" would otherwise be. */ export declare const composerReporting: () => boolean; /** Sent to a writing line or a new-comment box when what add-ons put in it changes. */ export declare const SOURCE_CHANGED = "pu-source"; /** * A writing box: what it is for when empty, then Cancel and Send (named for what it does) while it is in use. * Enter sends, Shift+Enter breaks, Esc cancels. Send stays grey, and out of Tab's reach, until there are words. */ export declare function composer(o: ComposerOptions): Composer;