Vue Quill Editor
Vue Quill Editor (specifically `surmon-china/vue-quill-editor`) is a rich text editor component designed for Vue 2 applications, acting as a wrapper around the Quill.js editor. The package, currently at version 3.0.6, supports integration in both Single Page Applications (SPA) and Server-Side Rendering (SSR) environments. However, the library is officially deprecated by its maintainer due to the stalled maintenance of the upstream Quill.js project, and critically, it does not support Vue 3. While suitable for existing Vue 2 projects requiring a rich text editor, new development, especially with Vue 3, should consider alternative, actively maintained solutions like 'VueQuill' (a separate Vue 3 specific wrapper in beta) or 'Tiptap'.
Common errors
-
TypeError: Cannot read properties of undefined (reading 'emit') OR TypeError: Cannot read property 'content' of undefined
cause This error typically occurs when attempting to interact with the Quill editor instance or its properties before the `quillEditor` component has fully initialized, or if `v-model` is misconfigured or accessing a non-existent data property.fixEnsure the editor component is properly mounted and visible. If accessing the Quill instance directly, use the `@ready` event to guarantee the instance is available. For `v-model`, confirm the bound data property is defined and initialized correctly in your Vue component's `data` option. -
Quill:toolbar Container required for toolbar
cause The Quill editor's toolbar module expects a specific HTML container element to exist in the DOM where it can render the toolbar buttons. This error indicates that the required container is either missing, has an incorrect ID/class, or the configuration pointing to it is wrong.fixVerify that your `quill-editor` component's options include a `toolbar` configuration. If using a custom toolbar, ensure the HTML structure for the toolbar is present in your template and correctly linked via `container` in Quill's toolbar options. The default `snow` and `bubble` themes usually provide this automatically, so ensure theme CSS is also imported. -
Uncaught SyntaxError: Unexpected token import (or similar module loading errors)
cause This error frequently arises in environments with mixed CommonJS and ES Module usage, or when a build tool (like Webpack) is not correctly configured to transpile or handle module syntax, especially in older Node.js versions, Electron applications, or specific SSR setups.fixReview your project's build configuration (e.g., `webpack.config.js`, Babel presets). If in an SSR context, strictly adhere to the conditional `require('vue-quill-editor/dist/ssr')` pattern. For Electron or similar desktop applications, ensure your Webpack setup transpiles `node_modules` if necessary, and that your Node.js environment supports the module syntax being used.
Warnings
- breaking The `vue-quill-editor` library is officially deprecated by its maintainer and explicitly does not support Vue 3. Using this package in a Vue 3 project will lead to compatibility issues, errors, and an unmaintained codebase. The underlying Quill.js project itself has also seen stalled maintenance since version 1.3.x.
- gotcha When implementing `vue-quill-editor` in Server-Side Rendering (SSR) environments (e.g., Nuxt.js), the component must be dynamically `require`d and conditionally initialized only in the browser context. Direct ESM `import` statements for `vue-quill-editor` will cause build failures during server-side compilation.
- gotcha Directly updating the `v-model` bound data property for the editor's content might not always reflect visually in the Quill editor, especially when the update is programmatic rather than user-initiated. This can be particularly noticeable with older Quill versions or specific scenarios.
- deprecated Older versions of Quill.js, upon which `vue-quill-editor` is built, may trigger browser console warnings regarding the deprecation of synchronous 'DOMNodeInserted' DOM Mutation Events. These warnings indicate potential performance issues and a risk of future incompatibility with browser changes.
Install
-
npm install vue-quill-editor -
yarn add vue-quill-editor -
pnpm add vue-quill-editor
Imports
- VueQuillEditor (global plugin)
const VueQuillEditor = require('vue-quill-editor'); Vue.use(VueQuillEditor);import Vue from 'vue'; import VueQuillEditor from 'vue-quill-editor'; Vue.use(VueQuillEditor);
- quillEditor (component)
import quillEditor from 'vue-quill-editor';
import { quillEditor } from 'vue-quill-editor'; - Quill styles
import 'quill/dist/quill.core.css'; import 'quill/dist/quill.snow.css'; // Or 'quill/dist/quill.bubble.css' for bubble theme
- VueQuillEditor (SSR-specific)
import VueQuillEditor from 'vue-quill-editor';
if (process.browser) { const VueQuillEditor = require('vue-quill-editor/dist/ssr'); Vue.use(VueQuillEditor); }
Quickstart
import Vue from 'vue';
import { quillEditor } from 'vue-quill-editor';
// Require Quill styles
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css'; // Using the 'snow' theme
new Vue({
el: '#app',
components: {
quillEditor
},
data() {
return {
content: '<h2>Hello Vue Quill!</h2><p>Start editing here.</p>',
editorOption: {
placeholder: 'Compose your rich text...',
theme: 'snow', // Available themes: 'snow', 'bubble'
modules: {
toolbar: [
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
[{ 'script': 'sub'}, { 'script': 'super' }],
[{ 'indent': '-1'}, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }],
[{ 'align': [] }],
['clean']
]
}
}
};
},
methods: {
onEditorBlur(quill) {
console.log('Editor blur!', quill);
},
onEditorFocus(quill) {
console.log('Editor focus!', quill);
},
onEditorReady(quill) {
console.log('Editor ready!', quill);
},
onEditorChange({ quill, html, text }) {
console.log('Editor content changed!', html, text);
this.content = html;
}
},
template: `
<div id="app" style="font-family: Arial, sans-serif; max-width: 800px; margin: 20px auto;">
<h1>Vue Quill Editor Example (Vue 2)</h1>
<quill-editor
v-model="content"
:options="editorOption"
@blur="onEditorBlur($event)"
@focus="onEditorFocus($event)"
@ready="onEditorReady($event)"
@change="onEditorChange($event)"
/>
<div style="margin-top: 30px; padding: 15px; border: 1px solid #eee; background: #f9f9f9;">
<h3>Current Editor Content (HTML)</h3>
<pre style="white-space: pre-wrap; word-break: break-all; background: #fff; padding: 10px; border: 1px solid #ddd;">{{ content }}</pre>
</div>
</div>
`
});