// Type definitions for richtexteditor/headless export interface HeadlessEditorOptions { /** Initial HTML content. */ value?: string; /** Partial RichTextEditor config, merged over the default config. */ config?: Record; /** Keep the word/character status counter (off by default in headless mode). */ showStatistics?: boolean; /** Base path used to load rte.js + assets. Defaults to "/richtexteditor". */ assetBasePath?: string; /** Skip asset auto-loading (assets already present on the page). */ autoload?: boolean; } export type HeadlessFormat = | "bold" | "italic" | "underline" | "strike" | "strikethrough" | "subscript" | "superscript" | "ul" | "ol" | "justifyleft" | "justifycenter" | "justifyright" | "justifyfull" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "paragraph" | "blockquote" | "pre"; export interface HeadlessState { [key: string]: boolean; canUndo: boolean; canRedo: boolean; } export type HeadlessEventName = "update" | "change" | "selectionchange" | "focus" | "blur"; export interface HeadlessController { /** The underlying RichTextEditor instance (escape hatch). */ readonly editor: any; /** Dispatch a command. Block types use run("formatblock", "h1"). Chainable. */ run(command: string, value?: string): this; cmd(command: string, value?: string): this; /** Is a format active at the current selection? */ isActive(name: HeadlessFormat | string): boolean; /** Is a command currently enabled (e.g. "undo")? */ can(command: string): boolean; /** Snapshot of active formatting (+ canUndo/canRedo) for binding a toolbar. */ state(keys?: string[]): HeadlessState; on(event: HeadlessEventName, cb: (...args: any[]) => void): this; off(event: HeadlessEventName, cb?: (...args: any[]) => void): this; getHTML(): string; setHTML(html: string): this; getText(): string; setText(text: string): this; getMarkdown(): string; setMarkdown(markdown: string): this; getJSON(): any; getStatistics(): { words: number; characters: number } | null; isEmpty(): boolean; focus(): this; destroy(): this; } /** Load assets, mount a chrome-less editor, and resolve to a controller. */ export function createHeadlessEditor( element: string | HTMLElement, options?: HeadlessEditorOptions ): Promise; export const STATE_MAP: Record; export const DEFAULT_STATE_KEYS: string[];