Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Guidance for building UIs with Nuxt UI, the official Tailwind-based component library for Nuxt.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/layouts/editor.md
1# Editor Layout23Build a rich text editor with toolbars, slash commands, mentions, and drag-and-drop.45## When to use67- Note-taking apps, CMS editors8- Collaborative editing interfaces9- Any rich text editing need (supports JSON, HTML, and Markdown)1011## Component tree1213```14UEditor15├── UEditorToolbar (fixed / bubble / floating)16├── UEditorDragHandle17├── UEditorSuggestionMenu18├── UEditorMentionMenu19└── UEditorEmojiMenu20```2122## Basic editor2324```vue25<script setup lang="ts">26const content = ref({27type: 'doc',28content: [29{30type: 'heading',31attrs: { level: 1 },32content: [{ type: 'text', text: 'Hello World' }]33},34{35type: 'paragraph',36content: [{ type: 'text', text: 'Start writing...' }]37}38]39})40</script>4142<template>43<UEditor v-slot="{ editor }" v-model="content">44<UEditorToolbar :editor="editor" />45<UEditorSuggestionMenu :editor="editor" />46<UEditorMentionMenu47:editor="editor"48:items="[49{ label: 'Benjamin', avatar: { src: 'https://github.com/benjamincanac.png' } },50{ label: 'Sébastien', avatar: { src: 'https://github.com/atinux.png' } }51]"52/>53<UEditorEmojiMenu :editor="editor" />54<UEditorDragHandle :editor="editor" />55</UEditor>56</template>57```5859> If you encounter prosemirror-related errors, add prosemirror packages to `vite.optimizeDeps.include` in `nuxt.config.ts`.6061## Key components6263- `UEditor` — rich text editor. `v-model` accepts JSON (default), HTML, or Markdown via `content-type` prop. Default slot provides `{ editor, handlers }` — `editor` is the Tiptap instance, `handlers` contains action functions for toolbar/menus.64- `UEditorToolbar` — toolbar with `layout`: `'fixed'` (default), `'bubble'` (on selection), `'floating'` (on empty lines).65- `UEditorDragHandle` — block drag-and-drop handle.66- `UEditorSuggestionMenu` — slash command menu (type `/` to open).67- `UEditorMentionMenu` — `@` mention menu.68- `UEditorEmojiMenu` — emoji picker (type `:` to open).6970## Toolbar modes7172```vue73<!-- Fixed (default) — always visible at top -->74<UEditorToolbar :editor="editor" />7576<!-- Bubble — appears on text selection -->77<UEditorToolbar :editor="editor" layout="bubble" />7879<!-- Floating — appears on empty lines -->80<UEditorToolbar :editor="editor" layout="floating" />81```8283## Content types8485```vue86<!-- JSON (default) -->87<UEditor v-model="jsonContent" />8889<!-- HTML -->90<UEditor v-model="htmlContent" content-type="html" />9192<!-- Markdown -->93<UEditor v-model="markdownContent" content-type="markdown" />94```9596## With document sidebar9798Combine with Dashboard layout for a multi-document editor:99100```vue [layouts/editor.vue]101<template>102<UDashboardGroup>103<UDashboardSidebar collapsible resizable>104<template #header>105<UButton icon="i-lucide-plus" label="New document" block />106</template>107108<template #default="{ collapsed }">109<UNavigationMenu110:collapsed="collapsed"111:items="documents.map(doc => ({112label: doc.title,113to: `/editor/${doc.id}`,114icon: 'i-lucide-file-text'115}))"116orientation="vertical"117/>118</template>119</UDashboardSidebar>120121<slot />122</UDashboardGroup>123</template>124```125126```vue [pages/editor/[id].vue]127<script setup lang="ts">128definePageMeta({ layout: 'editor' })129130const content = ref({ type: 'doc', content: [] })131</script>132133<template>134<UDashboardPanel>135<template #header>136<UDashboardNavbar title="Editor">137<template #right>138<UButton label="Save" icon="i-lucide-save" />139</template>140</UDashboardNavbar>141</template>142143<UContainer class="py-8">144<UEditor v-slot="{ editor }" v-model="content">145<UEditorToolbar :editor="editor" />146<UEditorSuggestionMenu :editor="editor" />147<UEditorEmojiMenu :editor="editor" />148<UEditorDragHandle :editor="editor" />149</UEditor>150</UContainer>151</UDashboardPanel>152</template>153```154