Skip to content
Edytor
Esc
↑↓navigate↵open⌘Jpreview
On this page

Ready-made menus

The Notion-style menus, toolbar, handles and panels, in shadcn-svelte, added to your app with one command, as plugins you list in your own editor.

The package draws no menu, toolbar, handle or panel: each is a snippet you pass its plugin (Menus and handles). The edytor-chrome registry item draws all of them the Notion way, in shadcn-svelte components on your theme’s tokens, and exports each bundled plugin given that markup, so your own <Edytor> lists them as they are. The starter editor is the same chrome with the page around the blocks, in one component.

npx shadcn-svelte@latest add https://edytor.dev/r/edytor-chrome.json

It needs Tailwind v4 and npx shadcn-svelte@latest init first (as the starter’s install), and writes $lib/components/edytor/chrome/ (the chrome, its words and tokens.css, the Notion theme on your tokens) and the shadcn components it uses (button, input, kbd, separator, avatar, textarea) into $lib/components/ui/, and adds edytor and @floating-ui/dom: each menu places itself by its controller’s anchor with one attachment, float (float.ts: Floating UI’s computePosition and autoUpdate, fixed, flipping, 8px inside the viewport and below what your sticky header hides: set it as the root’s scroll-padding-top, which also keeps a scrolled-to caret below the header).

What it exports

  • chrome: one snippet per surface (the slash menu, the toolbar and its link card, the block handles and the block menu, the code header and its language list, the table’s grips and menus, the image toolbar, the empty media panel, the callout icon picker, the comment cards, the find bar…), to pass a factory yourself.
  • Each package factory given those snippets: slashMenuPlugin is createSlashMenuPlugin with the starter’s menu, and slashMenu(options) takes the factory’s other options. The same for toolbar, blockMenu, blockHandles, code, table, equation, image, embed, bookmark, calloutIcons, find, marquee, mention, pageLink, comments, file, video and audio; imageToolbarPlugin, mediaEmptyPlugin and suggestionBarPlugin are ready as they are.
  • HistoryPanel: the version history panel.
  • words and setWords: the chrome’s words (Localization).

The files are yours: an app that never adds the item ships none of it, and <Edytor /> from edytor does not grow.

Pass its plugins

<script lang="ts">
	import { Edytor } from 'edytor';
	import 'edytor/themes/notion.css';
	// The blocks on your shadcn tokens, so they follow `.dark` with the menus.
	import '$lib/components/edytor/chrome/tokens.css';
	import {
		blockHandlesPlugin,
		blockMenuPlugin,
		calloutIconsPlugin,
		codePlugin,
		imageToolbarPlugin,
		mediaEmptyPlugin,
		slashMenuPlugin,
		toolbarPlugin
	} from '$lib/components/edytor/chrome/index.js';

	const plugins = [
		slashMenuPlugin,
		toolbarPlugin,
		blockHandlesPlugin,
		blockMenuPlugin,
		codePlugin,
		imageToolbarPlugin,
		mediaEmptyPlugin,
		calloutIconsPlugin
	];
</script>

<div class="edytor-notion">
	<Edytor {plugins} />
</div>

That is the editor above: a / menu, a toolbar over a selection, a + and a grip beside each block with its block menu, a code block with its language list, the image toolbar and the empty image’s panel, and the callout’s icon picker. The edytor-notion class applies the imported Notion theme, and tokens.css sets its variables on your shadcn tokens: the menus read the tokens already, so with it .dark turns the blocks and the menus dark together (Customizing). Take only the plugins you need: a plugin left out takes its chrome with it, and the editor still edits.

To change the words, call setWords (Localization). To draw one surface your own way, edit its file (SlashMenu.svelte, Toolbar.svelte…: keep the controller’s attachments, change the markup), or give its factory your own snippet (slashMenu({ menu })): see Menus and handles.

Was this page helpful?