Skip to Content
Forms & Inputs@hacline/ui/rich-text-editor

Rich Text Editor

Edit structured documents with formatting, tables, block commands, and media previews.

Install

pnpm dlx shadcn@latest add https://hacline.huanan-caoo.workers.dev/r/rich-text-editor.json

With @hacline/ui, use the @hacline/ui/rich-text-editor entry and load @hacline/ui/tokens.css.

Editing and saving media

Select text to format it, type / at the start of a paragraph to insert a block, or drag a block by its handle. Insert an image or video, save the document, and reopen it to see the stored media. This demo saves in your browser.

Pass image or video with accept, optional maxBytes, and preview(file). Keep the returned preview URLs and their files for the editing session. On save, upload the files referenced in the current document, replace their src attributes with stored URLs, and persist the JSON. Release the preview URLs when the session ends. Keep them when saving fails so the draft can be retried.

Controlled and read-only

Replace the value from the parent, then turn off read-only to edit. Use RichTextEditorRoot with its parts to customize the layout.

PropUsage
value, onChangeRead and update a Tiptap JSONContent document.
readOnlyShow the document with editing controls hidden. Defaults to false.
label, placeholder, classNameSet the accessible name, empty hint, and container class.
localeUI language. Use en, zh, or ja. Defaults to en.
image, videoEnable the corresponding file picker. The image configuration also enables pasting and dropping image files.