Rich Editor
MessagingMITTiptap-based WYSIWYG editor with full toolbar, bubble menu, slash commands, tables, and markdown shortcuts.
bun add @otfdashkit/ui
Preview
Rich EditorMessaging
Code
@otfdashkit/uiimport { useState } from 'react'
import { RichEditor } from '@otfdashkit/ui'
export function Example() {
const [html, setHtml] = useState('')
return (
<div className="mx-auto w-full max-w-2xl space-y-3">
<RichEditor onChange={setHtml} />
<details className="text-xs text-[hsl(var(--muted-foreground))]">
<summary className="cursor-pointer select-none">View HTML output</summary>
<pre className="mt-2 overflow-x-auto rounded-md bg-[hsl(var(--muted))] p-3 font-mono text-[11px]">
{html || '<empty>'}
</pre>
</details>
</div>
)
}
Free with the SDK. This block ships in @otfdashkit/ui under the MIT license.
Props
Props declared in the RichEditor source. Inherited HTML attributes are not listed.
| Prop | Type | Default | Description |
|---|---|---|---|
| defaultValue | string | (readonly string[] & string) | Initial uncontrolled HTML content. | |
| editable | boolean | true | Default true. When false the content is read-only and no toolbar is shown. |
| maxLength | number | Optional character cap. Shows a counter and clamps content via onUpdate. | |
| onChange | (html: string) => void | Fired (debounced 100ms) when the editor's HTML changes. | |
| placeholder | string | 'Write something...' | Placeholder shown when the document is empty. |
| toolbar | 'full' | 'minimal' | 'bubble' | 'full' | Toolbar layout. Default 'full'. |
| value | string | Controlled HTML content. |