@editkit/svelte
v2.0.4
Published
Svelte 3/4/5 & SvelteKit rich text (WYSIWYG) editor action and bindings for EditKit with stable selection handling — tables, slash commands, bubble menu, and light/dark themes.
Maintainers
Keywords
Readme
Svelte Text Editor — EditKit Rich Text Editor for Svelte & SvelteKit (@editkit/svelte)
@editkit/svelte is the official Svelte and SvelteKit integration for EditKit Text Editor, with native tables, a color picker, and configurable toolbars.
⚡ Why @editkit/svelte?
- 🚀 No Third-Party Editor Engine: Built in TypeScript without ProseMirror, Lexical, Slate, or Quill.
- 🟠 Universal Svelte Support: Works seamlessly across Svelte 3, Svelte 4, Svelte 5 (Runes), and SvelteKit.
- 📊 First-Class Interactive Tables: 6×6 visual hover grid, row/column management, and cell coloring.
- 🎨 2D HSV Custom Color Picker: 21 palette swatches + 2D spectrum canvas and hue slider.
- 🫧 Contextual Floating Menus: Smart text selection bubble toolbar, floating table actions, and image resize bar.
- 🎛️ Granular Feature Props: Turn any toolbar button on or off with boolean options.
📦 Installation
# Using npm
npm install @editkit/svelte @editkit/ui
# Using pnpm
pnpm add @editkit/svelte @editkit/ui
# Using yarn
yarn add @editkit/svelte @editkit/uiAll-in-one alternative: npm install editkit-text-editor svelte, then import from editkit-text-editor/svelte and editkit-text-editor/styles.
🚀 Quick Start (use:editkit)
<script lang="ts">
import { editkit } from '@editkit/svelte';
import '@editkit/ui/styles';
let content = '<p>Hello from Svelte!</p>';
</script>
<div
use:editkit={{
content,
theme: 'dark',
placeholder: 'Write with EditKit in Svelte...',
features: {
chart: false,
math: false,
},
onChange: (html) => {
content = html;
}
}}
/>🎛️ Complete Options Reference
| Option | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| content | string | '' | Initial / reactive HTML content |
| theme | 'light' \| 'dark' \| 'system' | 'dark' | Theme appearance |
| placeholder | string | 'Write something...' | Empty editor placeholder text |
| editable | boolean | true | Read-only mode toggle |
| showToolbar | boolean | true | Show or hide the top formatting toolbar |
| bubbleMenu | boolean | true | Enable floating selection bubble toolbar |
| tableMenu | boolean | true | Enable contextual table action floating menu |
| imageMenu | boolean | true | Enable floating image resizer menu |
| features | ToolbarFeaturesConfig | {} | Granular toolbar button toggles |
| onChange | (html: string) => void | - | Callback on content change |
Content is sanitized by default with EditKit's DOMPurify-based policy. Use the sanitize action option to adjust allowlists, pass your own sanitizer function, or false for trusted HTML. Sanitize again on your server before storing or rendering saved HTML. See Content safety.
❓ FAQ
How do I use this Svelte text editor in SvelteKit?
Apply use:editkit to an element. Actions run only in the browser, so the editor is created after hydration without extra SSR configuration.
Which Svelte versions are supported?
Svelte 3, 4 and 5.
How do I read the editor content?
Pass onChange: (html) => ... in the action options, or call getEditor().getHTML() on the action's return value.
Does it clean up when the element is removed?
Yes. Svelte calls the action's destroy(), which removes the editor and all of its UI.
📄 License
MIT © Ashikur Rahman
