Genesis
@beta

RichTextEditor

RichTextEditor — formatted text input for lessons, notes and other long-form content. - **Value:** JSON is canonical (`RichTextDoc`). `onChange` hands you the sanitized document plus lazily derived `html`/`text`. Store the JSON; on the server re-run `sanitizeRichTextDoc` and derive HTML with `richTextToHtml` (both from `/rich-text`, no DOM needed). - **Security:** output goes through the same allow-list as `RichText`; links keep only http(s)/mailto/tel/relative URLs; embeds are rebuilt from a validated YouTube/Vimeo/Loom id. - **SSR:** the editor mounts on the client only (Tiptap `immediatelyRender: false`). Until then a JSON value renders read-only, so server HTML shows the content instead of an empty box. - **Keyboard:** standard shortcuts (⌘/Ctrl+B, I, U, K for link, ⌘/Ctrl+Alt+2/3 for headings, ⌘/Ctrl+Shift+7/8 for lists, ⌘/Ctrl+Shift+B for quote, ⌘/Ctrl+Z / Shift+Z), shown in each toolbar tooltip. The toolbar is one tab stop with arrow-key navigation (Radix Toolbar).

packages/ui/src/components/rich-text/rich-text-editor.tsx

Import
Subpath export: @marktiderman/genesis-ui/rich-text-editor
import { RichTextEditor } from "@marktiderman/genesis-ui/rich-text-editor";
Components
Auto-generated from TypeScript source via react-docgen-typescript.

Node

The Node class is used to create custom node extensions.

No declared props.

RichTextDoc

The root node of a rich text document.

No declared props.

RichTextHeadingLevel

Heading levels a document may contain. `h1` is left to the page title.

No declared props.

RichTextEditor

RichTextEditor — formatted text input for lessons, notes and other long-form content. - **Value:** JSON is canonical (`RichTextDoc`). `onChange` hands you the sanitized document plus lazily derived `html`/`text`. Store the JSON; on the server re-run `sanitizeRichTextDoc` and derive HTML with `richTextToHtml` (both from `/rich-text`, no DOM needed). - **Security:** output goes through the same allow-list as `RichText`; links keep only http(s)/mailto/tel/relative URLs; embeds are rebuilt from a validated YouTube/Vimeo/Loom id. - **SSR:** the editor mounts on the client only (Tiptap `immediatelyRender: false`). Until then a JSON value renders read-only, so server HTML shows the content instead of an empty box. - **Keyboard:** standard shortcuts (⌘/Ctrl+B, I, U, K for link, ⌘/Ctrl+Alt+2/3 for headings, ⌘/Ctrl+Shift+7/8 for lists, ⌘/Ctrl+Shift+B for quote, ⌘/Ctrl+Z / Shift+Z), shown in each toolbar tooltip. The toolbar is one tab stop with arrow-key navigation (Radix Toolbar).

PropTypeDefaultDescription
aria-describedbystring—
aria-labelstring—
aria-labelledbystring—
autoFocusboolean—
classNamestring—Classes for the outer frame.
contentClassNamestring—Classes for the editable area (for example a taller `min-h-*`).
defaultValueRichTextEditorValue—Initial value for an uncontrolled editor.
disabledboolean—Not editable, toolbar disabled, dimmed.
embedsboolean—Enable YouTube / Vimeo / Loom embeds (toolbar button and schema). Default `false`. Read at mount.
headingLevelsreadonly RichTextHeadingLevel[]—Heading levels offered in the toolbar and kept in the document. Default `[2, 3]`. Read at mount.
idstring—`id` of the editable element. A `<label htmlFor={id}>` names the editor (wired as `aria-labelledby`, since a contenteditable is not a labelable element) and clicking it focuses the editor.
invalidboolean—Marks the field invalid (`aria-invalid`, destructive border).
labelsPartial<RichTextEditorLabels>—Override any user-facing string (for translation).
maxLengthnumber—Maximum characters. Typing and pasting stop at the limit. Read at mount.
namestring—Form field name. When set, a hidden input carries the document as JSON so a native `<form>` submission includes it.
onBlur(() => void)—
onChange((doc: RichTextDoc, details: RichTextChangeDetails) => void)—Called on every edit with the sanitized document. `details` derives HTML and text lazily, so reading only `doc` costs no serialization.
onFocus(() => void)—
placeholderstring—Placeholder shown while the document is empty.
readOnlyboolean—Content is visible and selectable but not editable; the toolbar is hidden.
showCharacterCountboolean—Show the character count under the editor. On by default when `maxLength` is set.
testIDstring—Stable test/automation selector (emitted as `data-testid` on the frame).
toolbarfalse | readonly RichTextToolbarItem[]—Toolbar items, in groups as listed. `false` hides the toolbar (shortcuts still work).
valueRichTextEditorValue—Controlled value. Pass back the `doc` from `onChange` synchronously; any other document (including an older one from a debounced or deferred parent) replaces the content and resets the selection.
Storybook
Storybook hosts the canonical visual reference with controls for every variant.