Editor
Rich text with its own engine and no dependency: headings, lists, tables, images, links and Markdown shortcuts, bound as sanitised HTML.
Import
import { Editor } from '@vitral/vue';Default
Release notes
This editor writes semantic HTML, keeps undo history and understands Markdown as you type. Try ## , - or **bold**.
Paste from Word or Google Docs
Select text and press Ctrl+K for a link
Nothing pasted can run a script: only what the schema knows survives.
Custom toolbar
`toolbar` takes groups of item names; the `toolbar` slot replaces the bar with parts of your own.
Only the basics here.
Bubble toolbar
`bubble-menu` shows a toolbar over selected text; with `:toolbar="false"` it is the only one.
Select some of this text: a floating toolbar appears over it, with bold, italic, a link and a colour.
Read only
With count and limit
`max-length` stops typing and pasting at the limit; the count describes the text.
Keep it short.
HTML and JSON output
Type here and watch both formats change.
<p>Type here and watch <strong>both</strong> formats change.</p>
null
Composed from parts
`Editor.Root`, `Editor.Toolbar`, `Editor.Button`, `Editor.Content`, `Editor.BubbleMenu`, `Editor.Footer` and `Editor.Count`, also exported as `EditorRoot`, `EditorToolbar`… share one editor; `useEditor()` reaches it from your own components.
This one is built from parts, with a toolbar of its own and a word count.
API
Read from packages/vue/src/components/Editor/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| placeholder | string | — |
| readonly | boolean | The text can be read, selected and copied, not changed. |
| disabled | boolean | — |
| invalid | boolean | — |
| variant | InputVariant | Defaults to the plugin's `inputVariant`. |
| maxLength | number | The most characters the text may hold; typing and pasting stop there. |
| autofocus | boolean | Focuses the text, with the caret at the end, once mounted. |
| colors | string[] | Palette colour names the colour and highlight pickers offer, in order. Defaults to the whole palette. |
| historyDelay | number | Milliseconds within which consecutive typing is one undo step. Defaults to 500. |
| slashMenu | boolean | SlashCommand[] | The menu a `/` opens where a word starts: `true` for the blocks the editor knows, the commands to offer, or `false` for none. Defaults to true. |
| blockMenu | boolean | BlockAction[] | The handle beside the block the caret is in: `true` for the usual actions, the actions to offer, or `false` for none. Defaults to true. |
| toolbar | boolean | EditorToolbarItem[][] | The toolbar: `false` for none, or groups of item names, as in `[['bold', 'italic'], ['link']]`. The `toolbar` slot replaces it entirely. |
| bubbleMenu | boolean | EditorToolbarItem[] | A floating toolbar over selected text; `true` for the default buttons, or the items to show. |
| showCount | boolean | Shows the word and character count under the text. On by default when there is a `maxLength`. |
| showWordCount | boolean | Shows the word count beside the character count. Defaults to true. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| update:modelValue | value: string | — |
| update:json | value: EditorJSON | — |
| text-change | event: EditorTextChangeEvent | The content changed. |
| selection-change | event: EditorSelectionChangeEvent | — |
| focus | event: FocusEvent | — |
| blur | event: FocusEvent | — |
| load | event: { instance: unknown } | The editor is ready; `instance` is the framework-free editor behind the component. |
Slots
| Name | Slot props | Description |
|---|---|---|
| toolbar | — | Replaces the toolbar. Build one from `EditorToolbar`, `EditorButton` and the other parts. |
| footer | — | Replaces the footer's content (the count). |