# Rich editor

A Tiptap editor with a slash menu, an image toolbar and a Markdown bridge.

Section: Blocks / Editor
Page: https://ui.heyramzi.com/components/rich-editor
Import path: `@heyramzi/ui/editor`

## Import

```ts
import { RichEditor } from "@heyramzi/ui/editor";
```

## Usage

```svelte
<RichEditor content={doc} onContentChange={(json) => (doc = json)} minHeight="14rem" />
```

## Demo

```svelte
<script lang="ts">
	import { RichEditor } from "@heyramzi/ui/editor";

	let doc = $state<Record<string, unknown> | null>({
		type: "doc",
		content: [
			{ type: "heading", attrs: { level: 2 }, content: [{ type: "text", text: "Write here" }] },
			{
				type: "paragraph",
				content: [{ type: "text", text: "Type a slash for headings, lists, tables and images." }],
			},
		],
	});
</script>

<div class="w-full max-w-2xl rounded-xl border border-border bg-card p-4">
	<RichEditor content={doc} onContentChange={(json) => (doc = json)} minHeight="14rem" />
</div>
```

## API

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `content` | `Record<string, unknown> \| null` | `null` |  |
| `onContentChange` | `(json: Record<string, unknown>) => void` |  |  |
| `placeholder` | `string` | `"Start writing..."` |  |
| `minHeight` | `string` | `"28rem"` |  |
| `preset` | `"full" \| "notes"` | `"full"` |  |
| `blockIds` | `boolean` | `false` |  |
| `variant` | `"box" \| "page"` | `"box"` | `box` is the framed editor with a toolbar. `page` is a document: no frame, no toolbar, type set by `.doc-surface` (see doc-page.css), heading anchors on. |
| `copyLinkLabel` | `string` | `"Copy link"` | The word on a heading's hover button, for `page`. |
| `onCopyLink` | `(url: string, id: string) => void` |  | A heading's link was copied. |
| `instance` | `Editor \| null` | `null` | bindable. The live editor, for a host that needs focus or the document. |
| `label` | `string` | `"Text editor"` | The editable region's accessible name. |
