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
@marktiderman/genesis-ui/rich-text-editorimport { RichTextEditor } from "@marktiderman/genesis-ui/rich-text-editor";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).
| Prop | Type | Default | Description |
|---|---|---|---|
| aria-describedby | string | — | |
| aria-label | string | — | |
| aria-labelledby | string | — | |
| autoFocus | boolean | — | |
| className | string | — | Classes for the outer frame. |
| contentClassName | string | — | Classes for the editable area (for example a taller `min-h-*`). |
| defaultValue | RichTextEditorValue | — | Initial value for an uncontrolled editor. |
| disabled | boolean | — | Not editable, toolbar disabled, dimmed. |
| embeds | boolean | — | Enable YouTube / Vimeo / Loom embeds (toolbar button and schema). Default `false`. Read at mount. |
| headingLevels | readonly RichTextHeadingLevel[] | — | Heading levels offered in the toolbar and kept in the document. Default `[2, 3]`. Read at mount. |
| id | string | — | `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. |
| invalid | boolean | — | Marks the field invalid (`aria-invalid`, destructive border). |
| labels | Partial<RichTextEditorLabels> | — | Override any user-facing string (for translation). |
| maxLength | number | — | Maximum characters. Typing and pasting stop at the limit. Read at mount. |
| name | string | — | 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) | — | |
| placeholder | string | — | Placeholder shown while the document is empty. |
| readOnly | boolean | — | Content is visible and selectable but not editable; the toolbar is hidden. |
| showCharacterCount | boolean | — | Show the character count under the editor. On by default when `maxLength` is set. |
| testID | string | — | Stable test/automation selector (emitted as `data-testid` on the frame). |
| toolbar | false | readonly RichTextToolbarItem[] | — | Toolbar items, in groups as listed. `false` hides the toolbar (shortcuts still work). |
| value | RichTextEditorValue | — | 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. |