# Rich Text Editor A composable rich text editor built on Tiptap, with a toolbar, bubble menu, character count and typeset content. ## Installation ```bash npx shadcn@latest add litingyes/blocove/rich-text-editor ``` > Typography requires [shadcn/typeset](https://ui.shadcn.com/docs/typeset). Copy `typeset.css` next to your main stylesheet, import it after Tailwind and add the `.typeset-docs` preset. This example also uses: `rich-text-editor-heading`, `rich-text-editor-code-block`, `rich-text-editor-bold`, `rich-text-editor-italic`, `rich-text-editor-underline`, `rich-text-editor-strike`, `rich-text-editor-code`, `rich-text-editor-link`. ```bash npx shadcn@latest add litingyes/blocove/rich-text-editor-heading litingyes/blocove/rich-text-editor-code-block litingyes/blocove/rich-text-editor-bold litingyes/blocove/rich-text-editor-italic litingyes/blocove/rich-text-editor-underline litingyes/blocove/rich-text-editor-strike litingyes/blocove/rich-text-editor-code litingyes/blocove/rich-text-editor-link ``` Typography is rendered inside a shadcn/typeset container. Nodes and marks are separate items: install the ones you compose into the rich text editor. ## Usage ### Install typeset ```bash curl -o src/typeset.css https://ui.shadcn.com/typeset.css ``` ### Typeset setup ```css /* src/styles.css */ @import "tailwindcss"; @import "./typeset.css"; @import "@fontsource-variable/inter"; @import "@fontsource-variable/jetbrains-mono"; .typeset-docs { --typeset-font-body: var(--font-inter); --typeset-font-heading: var(--font-inter); --typeset-font-mono: var(--font-jetbrains-mono); --typeset-size: 16px; --typeset-leading: 1.75; --typeset-flow: 1.25em; } ``` ## API Reference ### Editor Root component. Registers the declared extensions and provides the editor context. | Prop | Type | Default | | --- | --- | --- | | `value` | `string` | - | | `defaultValue` | `string` | - | | `onChange` | `(html: string) => void` | - | | `placeholder` | `string` | `"Start writing…"` | | `editable` | `boolean` | `true` | | `autoFocus` | `boolean` | `false` | | `characterLimit` | `number` | - | | `extensions` | `Extensions` | - | | `onReady` | `(editor: Editor) => void` | - | | `className` | `string` | - | | `editorProps` | `EditorProps` | - | | `children` | `ReactNode` | - | ### EditorContent Editable surface. Wraps the ProseMirror document in the typeset container. | Prop | Type | Default | | --- | --- | --- | | `className` | `string` | - | | `typeset` | `boolean` | `true` | | `...props` | `React.ComponentProps<'div'>` | - | ### EditorToolbar Toolbar with undo/redo, alignment and clear formatting. Children are extension controls. | Prop | Type | Default | | --- | --- | --- | | `className` | `string` | - | | `children` | `ReactNode` | - | ### EditorToolbarButton Toolbar control with a tooltip and an optional keyboard shortcut. Used by every extension item. | Prop | Type | Default | | --- | --- | --- | | `label` | `string` | - | | `shortcut` | `string` | - | | `pressed` | `boolean` | - | | `onPressedChange` | `(pressed: boolean) => void` | - | | `onClick` | `() => void` | - | | `disabled` | `boolean` | `false` | | `className` | `string` | - | | `children` | `ReactNode` | - | ### EditorBubbleMenu Floating menu shown above a text selection. Render mark controls as children. | Prop | Type | Default | | --- | --- | --- | | `className` | `string` | - | | `children` | `ReactNode` | - | ### EditorFloatingMenu Menu anchored to the block holding the caret. It only shows while that block is empty, which is where an insert affordance belongs. | Prop | Type | Default | | --- | --- | --- | | `className` | `string` | - | | `children` | `ReactNode` | - | ### EditorCharacterCount Live character and word count for the current document. | Prop | Type | Default | | --- | --- | --- | | `className` | `string` | - | | `format` | `"characters" | "words" | "both"` | `"characters"` | ### defineExtensionComponent Declares a Tiptap extension as a component that the Editor collects from its children. | Prop | Type | Default | | --- | --- | --- | | `name` | `string` | - | | `extension` | `(props) => Extensions` | - | | `returns` | `ExtensionComponent` | - | ## Registry dependencies - `litingyes/blocove/rich-text-editor-extension` - `litingyes/blocove/rich-text-editor-text` - `litingyes/blocove/rich-text-editor-paragraph` - `litingyes/blocove/rich-text-editor-hard-break` - `button` - `kbd` - `separator` - `toggle` - `tooltip` Namespace: `npx shadcn@latest add @blocove/rich-text-editor`