@friendlyinternet/nuxt-crouton-editor
v2.0.1
Published
Rich text editor layer extending nuxt-crouton (now wraps Nuxt UI Editor)
Maintainers
Readme
Nuxt Crouton Editor
Rich text editor addon layer for Nuxt Crouton, now powered by Nuxt UI Editor.
v2.0 Breaking Change: This package now wraps Nuxt UI's
UEditorcomponent instead of bundling TipTap directly. This provides a more feature-rich, maintained editor with better Nuxt UI integration.
Features
- Nuxt UI Editor - Full-featured rich text editing via Nuxt UI
- Backwards Compatible -
CroutonEditorSimplestill works as before - New Capabilities - Access to slash commands, mentions, emoji picker, drag & drop
- Type-safe - Full TypeScript support
- Dark Mode - Automatic dark mode support via Nuxt UI theming
Installation
1. Install the package
pnpm add @friendlyinternet/nuxt-crouton-editor2. Ensure Nuxt UI is configured
This package requires @nuxt/ui v4+ to be installed and configured in your project:
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@nuxt/ui'],
extends: [
'@friendlyinternet/nuxt-crouton',
'@friendlyinternet/nuxt-crouton-editor'
]
})Usage
CroutonEditorSimple (Backwards Compatible)
The simplest way to add a rich text editor:
<template>
<CroutonEditorSimple v-model="content" />
</template>
<script setup lang="ts">
const content = ref('<p>Hello world!</p>')
</script>Props:
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| modelValue | string | '' | HTML/Markdown content (v-model) |
| placeholder | string | 'Start writing...' | Placeholder text |
| contentType | 'html' \| 'markdown' \| 'json' | 'html' | Content format |
Using Nuxt UI Editor Directly (Recommended)
For full control, use Nuxt UI's editor components directly:
<template>
<UEditor
v-slot="{ editor }"
v-model="content"
content-type="html"
placeholder="Write something..."
>
<!-- Bubble toolbar on text selection -->
<UEditorToolbar :editor="editor" :items="toolbarItems" layout="bubble" />
<!-- Slash commands (type /) -->
<UEditorSuggestionMenu :editor="editor" :items="slashItems" />
<!-- Drag handle for block reordering -->
<UEditorDragHandle :editor="editor" />
</UEditor>
</template>
<script setup lang="ts">
import type { EditorToolbarItem, EditorSuggestionMenuItem } from '@nuxt/ui'
const content = ref('<p>Hello world!</p>')
const toolbarItems: EditorToolbarItem[][] = [
[
{ kind: 'mark', mark: 'bold', icon: 'i-lucide-bold' },
{ kind: 'mark', mark: 'italic', icon: 'i-lucide-italic' },
{ kind: 'mark', mark: 'strike', icon: 'i-lucide-strikethrough' }
],
[
{ kind: 'bulletList', icon: 'i-lucide-list' },
{ kind: 'orderedList', icon: 'i-lucide-list-ordered' }
]
]
const slashItems: EditorSuggestionMenuItem[][] = [
[
{ kind: 'heading', level: 1, label: 'Heading 1', icon: 'i-lucide-heading-1' },
{ kind: 'heading', level: 2, label: 'Heading 2', icon: 'i-lucide-heading-2' },
{ kind: 'bulletList', label: 'Bullet List', icon: 'i-lucide-list' }
]
]
</script>Migration from v1.x
Breaking Changes
- Peer dependency: Requires
@nuxt/uiv4+ instead ofnuxt-tiptap - Removed:
CroutonEditorToolbar- useUEditorToolbardirectly - Removed: Direct TipTap dependencies - handled by Nuxt UI
Migration Steps
Update dependencies:
pnpm remove nuxt-tiptap @tiptap/vue-3 @tiptap/starter-kit pnpm add @nuxt/ui@^4.0.0Update nuxt.config.ts:
export default defineNuxtConfig({ modules: ['@nuxt/ui'], // Required extends: [ '@friendlyinternet/nuxt-crouton', '@friendlyinternet/nuxt-crouton-editor' ] })Component changes:
<!-- Before (still works) --> <CroutonEditorSimple v-model="content" /> <!-- After (recommended for full features) --> <UEditor v-model="content" content-type="html" />Custom toolbar (if you were using
CroutonEditorToolbar):<!-- Before --> <CroutonEditorToolbar :editor="editor" /> <!-- After --> <UEditorToolbar :editor="editor" :items="toolbarItems" layout="bubble" />
New Features in v2.0
With Nuxt UI Editor, you now have access to:
- Slash Commands - Type
/for quick formatting - Mentions - Type
@to mention users - Emoji Picker - Type
:for emojis - Drag & Drop - Reorder blocks with drag handle
- Multiple Toolbars - Fixed, bubble, or floating layouts
- Markdown Support - Native markdown content type
- Custom Extensions - Easy TipTap extension integration
Nuxt UI Editor Documentation
For full documentation on all editor features, see:
Support
For issues, questions, or contributions:
License
MIT
Part of the Nuxt Crouton ecosystem
