API reference: @salmonui/rich-text
RichTextExtensioninterface
import type { RichTextExtension } from '@salmonui/rich-text';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.
| Name | Signature | Description |
|---|---|---|
name | readonly name: string; | |
nodesoptional | readonly nodes?: Readonly<Record<string, NodeSpec>>; | |
marksoptional | readonly marks?: Readonly<Record<string, MarkSpec>>; | |
pluginsoptional | readonly plugins?: (context: RichTextExtensionContext) => readonly Plugin[] | Promise<readonly Plugin[]>; | |
keyBindingsoptional | readonly keyBindings?: Readonly<Record<string, string | Command>>; | Key -> command id or ProseMirror command, before the built-in table (ProseMirror key names, |
inputRulesoptional | readonly inputRules?: (schema: Schema) => readonly InputRule[]; | |
commandsoptional | readonly commands?: Readonly<Record<string, (...args: never[]) => Command>>; | Command id -> factory of a ProseMirror command; run with |
toolbarItemsoptional | readonly toolbarItems?: readonly RichTextExtensionToolbarItem[]; | |
htmloptional | readonly html?: {
readonly tags?: readonly string[];
readonly attributes?: Readonly<Record<string, readonly string[]>>;
}; | 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), |
replacesHistoryoptional | readonly replacesHistory?: boolean; | Turns off history in the engine (the Yjs undo manager replaces it). |
historyoptional | readonly history?: {
readonly undo: Command;
readonly redo: Command;
}; | The undo and redo that replace the engine's (with |