CKEditor 4 Vue Component
ckeditor4-vue provides an official Vue.js 2 component for integrating the CKEditor 4 WYSIWYG editor into web applications. As of version 3.x (including the current 3.2.1), this package is part of the commercial CKEditor 4 LTS (Long Term Support) offering. The underlying CKEditor 4 editor reached its End of Life (EOL) for open-source users on June 30, 2023. Open-source versions of this Vue component (2.4.0 and below) no longer receive security updates or bug fixes, posing significant risks. The commercial LTS model extends security updates and critical bug fixes for CKEditor 4 until December 2028. This package simplifies the integration of CKEditor 4 into Vue 2 projects by providing a declarative component, differentiating it from manual integration methods.
Common errors
-
[Vue warn]: Unknown custom element: <ckeditor> - did you register the component correctly?
cause The CKEditor component was not registered as a global Vue component before the application attempted to render it.fixAdd `Vue.use(CKEditor);` to your application's main entry file (e.g., `main.js` or `app.js`) before creating your Vue instance. -
TypeError: Cannot read properties of undefined (reading 'config')
cause This error often indicates that the CKEditor core script (ckeditor.js) is not correctly loaded or accessible, or the component isn't properly initialized.fixVerify that `ckeditor.js` (the core CKEditor script) is available in your project. If using a bundler, ensure it's imported or configured correctly. If using the script tag, double-check the path and ensure it loads before the Vue component. -
Error: [CKEDITOR] Error code: editor-incorrect-api
cause Attempting to use a version of `ckeditor4-vue` (>=2.4.1) that is part of the commercial CKEditor 4 LTS model without a valid license, or with an improperly configured setup.fixObtain a commercial license for CKEditor 4 LTS from CKSource, or downgrade your `ckeditor4-vue` package to version 2.4.0 or below (accepting the associated security risks for an EOL product).
Warnings
- breaking CKEditor 4, the underlying editor for this component, reached its End of Life (EOL) for open-source users on June 30, 2023. Versions of ckeditor4-vue from 2.4.0 and below are open-source but receive no further security updates or critical bug fixes.
- breaking Versions of ckeditor4-vue above 2.4.0 (including 3.x) are distributed under commercial terms as part of the CKEditor 4 LTS (Long Term Support) model. Using these versions requires adherence to the Extended Support Model license.
- gotcha This package is designed for Vue 2.x. It is not compatible with Vue 3.x applications due to its peer dependency on Vue ^2.5.17 and internal Vue 2 specific API usage.
- gotcha Failing to properly install the component using `Vue.use(CKEditor)` before your Vue application mounts will result in the `<ckeditor>` tag not being recognized.
Install
-
npm install ckeditor4-vue -
yarn add ckeditor4-vue -
pnpm add ckeditor4-vue
Imports
- CKEditor
import { CKEditor } from 'ckeditor4-vue';import CKEditor from 'ckeditor4-vue';
- Vue.use
new Vue().use(CKEditor);
Vue.use(CKEditor);
- CKEditor global
<script src="../node_modules/ckeditor4-vue/dist/ckeditor.js"></script>
Quickstart
import Vue from 'vue';
import CKEditor from 'ckeditor4-vue';
Vue.use( CKEditor );
new Vue({
el: '#app',
template: `
<div id="app">
<ckeditor :value="editorContent" @input="updateEditorContent"></ckeditor>
</div>
`,
data: {
editorContent: 'Hello, World!'
},
methods: {
updateEditorContent(event) {
this.editorContent = event;
console.log('Editor content updated:', this.editorContent);
}
}
});