value |
string (two-way) |
"" |
The document, in format. Bind it to state; the editor writes every change back, and writing it from outside replaces the document. Empty is "". |
format |
"html" | "json" | "text" |
"html" |
What value holds: HTML, the document as JSON in a string (editor.getJSON()), or plain text (paragraphs separated by a blank line). |
placeholder |
string |
"" |
Shown in the empty editor, and set as aria-placeholder. |
label |
string |
"" |
Accessible name of the text box (aria-label). Or pass aria-labelledby in attrs. |
tools |
RichTextTool[] |
DEFAULT_TOOLS |
The toolbar's controls in order: undo, redo, block, bold, italic, underline, strike, code, highlight, link, bulletList, orderedList, taskList, list (the three lists in one menu), blockquote, codeBlock, horizontalRule, align, clear, image (shown with upload), find, and | for a separator. |
toolbar |
boolean |
true |
Shows the toolbar. Shortcuts and markdown input work without it. |
stickyToolbar |
boolean |
false |
The toolbar sticks to the top of the scrolling page while the editor is in view. |
headingLevels |
(1 | 2 | 3 | 4 | 5 | 6)[] |
[1, 2, 3, 4] |
Heading levels the document allows, the text style menu offers and the slash menu lists. Changing it rebuilds the editor around the same document. |
slashMenu |
boolean |
true |
Typing / opens a menu of blocks at the caret. |
slashOptions |
RichTextSlashOptions |
{} |
Suggestion options for the menu: the trigger (char, allowSpaces, allowToIncludeChar, allowedPrefixes, startOfLine, minQueryLength, allow, shouldShow, shouldResetDismissed, findSuggestionMatch, pluginKey), its decoration (decorationTag, decorationClass, decorationContent, decorationEmptyClass), the items (items, initialItems, debounce, command, render with mount) and placement (placement, offset, flip, container, floating, dismissOnOutsideClick). |
parseOptions |
ParseOptions |
{} |
Parse options for HTML content, such as { preserveWhitespace: "full" }. |
coreExtensionOptions |
CoreExtensionOptions |
{} |
Options for the built-ins: clipboardTextSerializer.blockSeparator joins copied blocks. |
rows |
number |
6 |
Minimum height of the content, in lines. |
maxRows |
number |
0 |
Height where the content stops growing and scrolls. 0 grows without limit. |
limit |
number |
0 |
Maximum characters. Typing and pasting stop at the limit; the count line shows n / limit. A new limit applies at once. |
count |
boolean |
false |
Shows the character and word count. On by itself when limit is set. |
name |
string |
"" |
Submits value with a form under this name. |
required |
boolean |
false |
With name: an empty editor blocks the form's submit and takes focus. |
disabled |
boolean |
false |
Not editable, not focusable, dimmed; the toolbar is off and the form control is not submitted. |
readonly |
boolean |
false |
Not editable, still selectable and submitted; the toolbar is off. |
invalid |
boolean |
false |
Danger border and aria-invalid="true". |
autofocus |
boolean | "start" | "end" | "all" |
false |
Focuses the editor when it mounts, with the caret at the start, the end (true) or everything selected. |
dir |
"" | "ltr" | "rtl" | "auto" |
"" |
Text direction of the content and the toolbar's arrow keys. Changes apply live. |
extensions |
Extension[] |
[] |
Your own extensions (Extension.create): key bindings, input rules, editor plugins, commands, and nodes and marks for the schema. Their keys run after the built-in formatting keys. |
exclude |
RichTextBuiltin[] |
[] |
Built-ins to leave out, as turning off a StarterKit extension does: marks (bold, italic, underline, strike, code, highlight, link, superscript, subscript), blocks (heading, blockquote, bulletList, orderedList, taskList, codeBlock, horizontalRule, hardBreak, image) and helpers (undoRedo, dropcursor, gapcursor, trailingNode). Their tools, slash items, shortcuts and markdown rules go, and pasted content drops them. An extension may define its own node or mark under a left-out name. Changing it rebuilds the editor. |
inputRules |
boolean |
true |
Markdown shortcuts as you type (# heading, - list, **bold**). false types them literally. |
pasteRules |
boolean |
true |
Markdown and links in pasted text become formatting. |
enableContentCheck |
boolean |
false |
Checks content against the schema: content with a node or mark the editor does not know fires onContentError and is refused instead of being dropped. |
emitContentError |
boolean |
false |
Keeps invalid content parsing as usual but still fires onContentError. |
highlights |
RichTextHighlight[] |
HIGHLIGHTS |
The highlight popover's swatches: { name, color } with any CSS color. The swatch's data-rich-text-swatch is the name in lower case. |
autoOpenLink |
boolean |
true |
Opens the link popover when the caret enters a link, with focus left in the text; moving out closes it. false keeps it to Mod + K and the link tool. |
find |
boolean |
true |
Find and replace on Mod + F and the find tool. false leaves Mod + F to the browser. |
findOpen |
boolean |
false |
Two-way: the find panel is open. Set it to open or close the panel; Mod + F and Escape write it back. |
linkOpen |
boolean |
false |
Two-way: the link popover is open. Set it to open the popover with its field focused. |
upload |
((file: File, onProgress: (percent: number) => void, signal: AbortSignal) => Promise<string>) | null |
null |
Uploads an image and resolves to its URL. Turns on the image tool, Mod + Shift + I, and image drop and paste. Cancel aborts the signal. |
imageAccept |
string |
"image/*" |
File types the image chooser, drop and paste accept, as in an input's accept. |
imageMaxSize |
number |
0 |
Largest image in bytes. 0 is no limit. |
imageLimit |
number |
1 |
Images per upload. Above 1 the chooser takes several files. |
class |
string |
"" |
Extra classes on the frame. |
attrs |
Record<string, string | number | boolean | undefined> |
{} |
Attributes for the text box: id, aria-labelledby, aria-describedby, data-testid. |
onValueChange |
(value: string) => void |
() => {} |
Called when the editor changes the document. Not called for writes to value from outside. |
onCreate |
(editor: Editor) => void |
() => {} |
Called once the Editor is ready, for commands (editor.chain().focus().toggleBold().run()) and events (editor.on) the attributes do not cover. |
onSelectionUpdate |
(editor: Editor) => void |
() => {} |
The selection moved; read editor.state.selection or editor.isActive(). |
onFocus |
(e: FocusEvent) => void |
() => {} |
The text box gained focus. |
onBlur |
(e: FocusEvent) => void |
() => {} |
The text box lost focus. |
onUploadError |
(error: Error) => void |
() => {} |
A file was refused (type, size or count) or its upload failed. |
onUploadSuccess |
(url: string) => void |
() => {} |
An upload finished and its image is in the text. |
onContentError |
(error: Error) => void |
() => {} |
Content the schema cannot hold, with enableContentCheck or emitContentError. |
onFindOpenChange |
(open: boolean) => void |
() => {} |
The find panel opened or closed on its own: Mod + F, the find tool, Escape or close. |
onLinkOpenChange |
(open: boolean) => void |
() => {} |
The link popover opened or closed on its own. |
onSetLink |
(href: string) => void |
() => {} |
After the link popover applies a link, with the href written. |
onHighlightApplied |
(highlight: RichTextHighlight) => void |
() => {} |
After the highlight popover applies a swatch, with its name and color. |