import type { Editor, EditorConfig, EditorState } from '@rtif-sdk/web'; /** * `createEditor` config minus `mount` (supplied by ``), plus an * optional change callback. * * **Create-time only:** the config is read exactly once, when the handle is * first created (like a `useRef` initial value). Changing `doc`, `features`, * etc. on a later render has NO effect — remount with a new handle (e.g. via a * React `key`) to apply a new config. The single exception is `onChange`, * which always sees the latest closure. */ export interface UseEditorConfig extends Omit { /** * Called after every editor state change (edits, selection, focus, * composition). Always the latest render's closure. Do not `exec`/dispatch * synchronously from it — the engine forbids re-entrant dispatch; use * `queueMicrotask` for follow-up edits. */ readonly onChange?: (state: EditorState) => void; } /** * The stable editor handle returned by {@link useEditor}. Its identity never * changes across renders, so it is safe in dependency arrays and contexts. * * The handle exists before the editor does: the web editor is only created * when `` mounts (in an effect — never during render or SSR). * Pre-mount, `editor`/`getState()` are null and `exec`/`focus` throw. */ export interface EditorHandle { /** The live web editor, or null until `` has mounted it. */ readonly editor: Editor | null; /** * Run a feature command by name (`exec('bold.toggle')`). * * @throws {Error} `[NOT_MOUNTED]` when called before `` mounted. */ exec(command: string, params?: unknown): void; /** * Focus the editor. * * @throws {Error} `[NOT_MOUNTED]` when called before `` mounted. */ focus(): void; /** The current editor state, or null while unmounted. */ getState(): EditorState | null; } /** * Create a stable {@link EditorHandle}. SSR-safe: nothing here touches the * DOM — the editor itself is created inside ``'s effect, which * never runs on the server, so server renders see `getState() === null` and * emit plain markup. * * @param config - Create-time editor config (see {@link UseEditorConfig}). * @returns The same handle on every render. * * @example * ```tsx * const editor = useEditor({ placeholder: 'Write…' }); * return ; * ``` */ export declare function useEditor(config: UseEditorConfig): EditorHandle; //# sourceMappingURL=use-editor.d.ts.map