# RichTextExtension (@salmonui/rich-text)

> The RichTextExtension interface of @salmonui/rich-text: An editor extension: schema nodes and marks, ProseMirror plugins (a factory may be async, for example the /collab Yjs binding), key bindings, input rules, commands and toolbar items. Keep the array stable.

Canonical: https://salmonui.dev/docs/reference/rich-text/RichTextExtension

```ts
import type { RichTextExtension } from '@salmonui/rich-text';
```

Entry index: https://salmonui.dev/docs/reference/rich-text (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/rich-text.md).

## Reference

Kind: interface

```ts
interface RichTextExtension {
    readonly name: string;
    readonly nodes?: Readonly<Record<string, NodeSpec>>;
    readonly marks?: Readonly<Record<string, MarkSpec>>;
    readonly plugins?: (context: RichTextExtensionContext) => readonly Plugin[] | Promise<readonly Plugin[]>;
    readonly keyBindings?: Readonly<Record<string, string | Command>>;
    readonly inputRules?: (schema: Schema) => readonly InputRule[];
    readonly commands?: Readonly<Record<string, (...args: never[]) => Command>>;
    readonly toolbarItems?: readonly RichTextExtensionToolbarItem[];
    readonly html?: {
        readonly tags?: readonly string[];
        readonly attributes?: Readonly<Record<string, readonly string[]>>;
    };
    readonly replacesHistory?: boolean;
    readonly history?: {
        readonly undo: Command;
        readonly redo: Command;
    };
}
```

An editor extension: schema nodes and marks, ProseMirror plugins
(a factory may be async, for example the `/collab` Yjs binding), key
bindings, input rules, commands and toolbar items. Keep the array stable.

Members (11):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `name` | `readonly name: string;` |  |  |
| `nodes` | `readonly nodes?: Readonly<Record<string, NodeSpec>>;` | optional |  |
| `marks` | `readonly marks?: Readonly<Record<string, MarkSpec>>;` | optional |  |
| `plugins` | `readonly plugins?: (context: RichTextExtensionContext) => readonly Plugin[] \| Promise<readonly Plugin[]>;` | optional |  |
| `keyBindings` | `readonly keyBindings?: Readonly<Record<string, string \| Command>>;` | optional | Key -> command id or ProseMirror command, before the built-in table (ProseMirror key names, `Mod-` for Ctrl/Cmd). |
| `inputRules` | `readonly inputRules?: (schema: Schema) => readonly InputRule[];` | optional |  |
| `commands` | `readonly commands?: Readonly<Record<string, (...args: never[]) => Command>>;` | optional | Command id -> factory of a ProseMirror command; run with `actionsRef.current.run(id, ...args)`. |
| `toolbarItems` | `readonly toolbarItems?: readonly RichTextExtensionToolbarItem[];` | optional |  |
| `html` | `readonly html?: {     readonly tags?: readonly string[];     readonly attributes?: Readonly<Record<string, readonly string[]>>; };` | optional | Elements and attributes the extension's nodes and marks write, added to the always-on sanitizer for value in, paste and HTML out. Active content (script, style, iframe, object, embed, forms), `on*` handlers, `style` and URL attributes other than href / cite / src / poster are never allowed; those four are checked by the URL rules. |
| `replacesHistory` | `readonly replacesHistory?: boolean;` | optional | Turns off history in the engine (the Yjs undo manager replaces it). |
| `history` | `readonly history?: {     readonly undo: Command;     readonly redo: Command; };` | optional | The undo and redo that replace the engine's (with `replacesHistory`): `commands.undo` / `redo`, the toolbar and its enabled state use them. Called without `dispatch` they answer whether a step is available. |
