Contents

Editor options

Options are the second argument of VEditor.create() (and of the VEditor constructor). The first argument is a <textarea> element or a selector. VEditor.create() loads the interface language first, see Translations.

import { VEditor } from '/veditor/js/index.js';

const editor = await VEditor.create('#content', {
    language: 'en',
    height: '400px',
    placeholder: 'Write your article…',
    licenseKey: 'VED1.…', // your key; leave it out on local and test addresses
});

General

OptionDefaultDescription
toolbarDEFAULT_TOOLBARlist of toolbar items, `''` is a separator; the toolbar wraps onto more rows (see Toolbar)
pluginsDEFAULT_PLUGINSlist of plugins
languagethe document lang or eninterface language, one of 36 (see Translations)
height'300px'minimum height of the editing area (the editor grows with the content)
maxHeightnonemaximum height of the editing area, then it scrolls
placeholder''text shown in an empty editor
label“Rich text editor”accessible label of the editing area
readOnlyfalseread-only mode (editor.setReadOnly() changes it at runtime)
directionnone'ltr' or 'rtl' for the whole editor
licenseKey''licence key; not needed on local and test addresses
inlinefalseediting without a frame; the toolbar appears above the content only while the editor has focus
balloonToolbarnonelist of toolbar items shown above selected text, with or without inline

Content

OptionDefaultDescription
heading.optionsparagraph, H1–H6[{ tag, label }]
styles[][{ name, element, classes }]: the “Style” list, see HTML sanitizer
fontpredefined{ colors, backgrounds, sizes }: classes color-*, background-*, size-*
codeBlock.languagescommon languages[{ value, label }]
templates[][{ title, description, html }]
specialCharactersdefault groups[{ group, chars: [...] }]
emojidefault groups[{ group, chars: [...] }]
dateTime.formats4 formatsIntl.DateTimeFormat options for “Insert date and time”
headingIdsfalseevery heading in the output gets an id (an anchor from its text)
typographytruereplacements while typing: ... → …, -- → – , (c) → ©, quotes by language
link.externalNewTabfalsea new link to another domain opens in a new tab by default
image.lazyLoadingtrueloading="lazy" on inserted images

Files, uploads and AI

OptionDefaultDescription
filePickernonefunction (callback, meta): your file manager, see File manager and uploads
uploadnonefunction (file) → Promise<{ url, alt?, srcset?, sizes? }> for dropped and pasted images
ainone{ url, csrfToken, headers, autocomplete, autocompleteDelay, languages, language }, see AI

Working comfort

OptionDefaultDescription
autosaveofftrue or { key, delay }: a draft in localStorage with restore or discard
wordCount.onUpdatenonefunction (stats) after every change

Toolbar

The toolbar option is the list of toolbar items in the order they appear; '|' is a separator. Without it the editor shows the full default toolbar. Each editor on a page can have its own toolbar, for example a short one for comments and a full one for articles.

Basic: comments

await VEditor.create('#comment', {
    toolbar: ['bold', 'italic', 'link', '|', 'bulletedList', 'numberedList', '|', 'undo', 'redo'],
    height: '150px',
});
Editor with a basic toolbar: bold, italic, link, two lists, undo and redo

Standard: articles

await VEditor.create('#content', {
    toolbar: [
        'heading', 'style', '|',
        'bold', 'italic', 'underline', 'removeFormat', '|',
        'link', '|',
        'bulletedList', 'numberedList', 'outdent', 'indent', '|',
        'alignLeft', 'alignCenter', 'alignRight', '|',
        'blockQuote', 'image', 'mediaEmbed', 'insertTable', '|',
        'undo', 'redo', '|',
        'sourceEditing', 'fullscreen',
    ],
});
Editor with a standard toolbar for articles: headings, styles, basic formatting, link, lists, indents, alignment, quote, image, media, table, undo, source and full screen

Full: the default

Without the toolbar option the editor shows every item (DEFAULT_TOOLBAR):

[
  'heading', 'style', '|',
  'aiAssistant', 'aiChat',
  'bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', 'code', 'removeFormat', '|',
  'fontColor', 'fontBackgroundColor', 'fontSize', '|',
  'link', 'anchor', '|',
  'bulletedList', 'numberedList', 'taskList', 'listStyle', 'listStart', 'outdent', 'indent', '|',
  'alignLeft', 'alignCenter', 'alignRight', 'alignJustify', 'textDirection', '|',
  'blockQuote', 'codeBlock', 'accordion', 'horizontalLine', 'pageBreak', '|',
  'image', 'mediaEmbed', 'insertTable', 'insertToc', 'insertTemplate', 'specialCharacters', 'emoji', 'insertDateTime', '|',
  'findAndReplace', 'review', 'pasteAsText', '|',
  'undo', 'redo', '|',
  'sourceEditing', 'showBlocks', 'preview', 'print', 'fullscreen', 'help',
]
Editor with the full default toolbar wrapped into several rows

The AI buttons appear only when ai.url is set and the licence covers the AI edition. To start from the default list and remove a few items, import DEFAULT_TOOLBAR:

import { VEditor, DEFAULT_TOOLBAR } from '/veditor/js/index.js';

await VEditor.create('#content', {
    toolbar: DEFAULT_TOOLBAR.filter((name) => !['emoji', 'pageBreak', 'print'].includes(name)),
});

The balloonToolbar option (a toolbar above selected text) takes the same names.

Toolbar items

ItemButton
headingparagraph or heading H1–H6 (the list from heading.options)
stylethe “Style” list from the styles option
aiAssistantAI assistant: quick actions and your own prompt (AI edition)
aiChatAI chat in a side panel (AI edition)
bold, italic, underline, strikethroughbold (Ctrl+B), italic (Ctrl+I), underline (Ctrl+U), strikethrough (Ctrl+Shift+X)
subscript, superscriptsubscript, superscript
codeinline code
removeFormatremoves text formatting
fontColor, fontBackgroundColor, fontSizetext colour, background colour and size from the font option
linklink: address, new tab, relation (rel)
anchoranchor (id) that a link can point to
bulletedList, numberedList, taskListbulleted, numbered and task list
listStylelist marker style (disc, square, a, i…)
listStartlist properties: start number, reversed counting
outdent, indentdecrease and increase indent
alignLeft, alignCenter, alignRight, alignJustifytext alignment
textDirectionright-to-left text
blockQuote, codeBlockblock quote, code block with a language
accordioncollapsible section (<details>)
horizontalLine, pageBreakhorizontal line, page break for printing
imageimage: file manager, upload, alt text, alignment, size
mediaEmbedYouTube and Vimeo videos, video and audio files
insertTabletable
insertToctable of contents built from the headings
insertTemplatetemplates from the templates option
specialCharacters, emojispecial characters, emoji
insertDateTimedate and time in the formats from dateTime.formats
findAndReplacefind and replace (Ctrl+F)
reviewreview panel: accessibility checks, with AI also a text check
pasteAsTexttoggles pasting as plain text
undo, redoundo (Ctrl+Z), redo (Ctrl+Y)
sourceEditingHTML source
showBlocksshows the outlines of blocks
preview, printpreview, print
fullscreenfull screen
helpkeyboard shortcuts (Alt+0)

Outside the default list you can also use unlink (remove link) and indentList / outdentList (list indentation only, also Tab and Shift+Tab).

Styles for a sticky toolbar

The toolbar sticks to the top of the window while you scroll. If your page has a fixed header, move it down with a CSS variable:

.veditor { --ve-sticky-top: 64px; }

Next steps

Something unclear? Send feedback on the documentation.