Quick start
Render an editor, add a plugin, and use the document in your page.
Three steps, assuming you have installed edytor.
1. Render an editor
<script lang="ts">
import { Edytor } from 'edytor';
import 'edytor/themes/notion.css';
</script>
<div class="edytor-notion">
<Edytor />
</div>
That is a rich text editor: headings, lists, to-dos, quotes, callouts, toggles, marks and links, with their shortcuts (Mod+B, Mod+Alt+1…). It renders on the server and hydrates in the browser. The theme is optional: without it the blocks work, unstyled.
The bare editor stays small on purpose. It has no menus, block handles, images or code blocks, and Tab does not nest blocks: each is one line away, below.
2. Add what you need
Every block kind beyond rich text is a plugin, imported from edytor and passed in plugins. Nesting is one prop:
<script lang="ts">
import { Edytor, createCodePlugin, createTablePlugin } from 'edytor';
import 'edytor/themes/notion.css';
</script>
<div class="edytor-notion">
<Edytor allowNesting plugins={[createCodePlugin(), createTablePlugin()]} />
</div>
Plugins lists them all: images and media, columns, mentions, comments, equations… Menus, toolbars and handles draw your own markup (Menus and handles); to start from Notion-style ones, add the ready-made menus (the edytor-chrome registry item) and list them.
3. Use the document
Give the editor a first document as value, and keep each new one from onChange in a $state:
<script lang="ts">
import { Edytor, type JSONDoc } from 'edytor';
let value = $state<JSONDoc>({
children: [{ type: 'heading', data: { level: 'h1' }, content: [{ text: 'Notes' }] }]
});
</script>
<Edytor {value} onChange={(next) => (value = next)} />
<p>{value.children?.length ?? 0} blocks</p>
<pre>{JSON.stringify(value, null, 2)}</pre>
onChange fires after every change, local, remote or undo, with the whole document as a JSONDoc (Document model): store it, and open it again as value. The editor reads value once, when it mounts. To change the content from code, use commands.