I try to add button as plugin to ckeditor toolbar with this guide and created a simple plugin . but i have error on my code this is my code to try add button to ckeditor toolbar and return error
[Vue warn]: Failed to resolve async component: function HelperCkeditorNuxt() {
return Promise.all(/*! import() | components/helper-ckeditor-nuxt */[__webpack_require__.e("vendors/components/helper-ckeditor-nuxt/components/helper-my-custom-plugin"), __webpack_require__.e("vendors/components/helper-ckeditor-nuxt"), __webpack_require__.e("components/helper-ckeditor-nuxt")]).then(__webpack_require__.bind(null, /*! ../../components/helper/CkeditorNuxt.vue */ "./components/helper/CkeditorNuxt.vue")).then(function (c) {
return Object(_utils__WEBPACK_IMPORTED_MODULE_4__["wrapFunctional"])(c.default || c);
});
}
Reason: CKEditorError: ckeditor-duplicated-modules
<template>
<ckeditor
:editor="editor"
:value="value"
:config="config"
:tag-name="tagName"
:disabled="disabled"
@input="(event) => $emit('input', event)"
/>
</template>
<script>
let ClassicEditor
let CKEditor
let EssentialsPlugin
let BoldPlugin
let LinkPlugin
let MyCustomPlugin
if (process.client) {
ClassicEditor = require('@ckeditor/ckeditor5-build-classic')
CKEditor = require('@ckeditor/ckeditor5-vue2')
EssentialsPlugin = require('@ckeditor/ckeditor5-essentials/src/essentials')
BoldPlugin = require('@ckeditor/ckeditor5-basic-styles/src/bold')
LinkPlugin = require('@ckeditor/ckeditor5-link/src/link')
MyCustomPlugin = require('../helper/MyCustomPlugin')
} else {
CKEditor = { component: { template: '<div></div>' } }
}
export default {
components: {
ckeditor: CKEditor.component,
},
props: {
value: {
type: String,
required: false,
default: '',
},
tagName: {
type: String,
required: false,
default: 'div',
},
disabled: {
type: Boolean,
required: false,
},
uploadUrl: {
type: String,
required: false,
default: '',
},
// config: {
// type: Object,
// required: false,
// default: function () {},
// },
},
data() {
return {
editor: ClassicEditor,
config: {
plugins: [EssentialsPlugin, BoldPlugin, LinkPlugin],
extraPlugins: [MyCustomPlugin],
toolbar: {
items: ['bold', 'link', 'myCustomPlugin'],
},
},
}
},
}
</script>
my custom plugin
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import imageIcon from '@ckeditor/ckeditor5-core/theme/icons/image.svg';
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
class MyCustomPlugin extends Plugin {
init() {
const editor = this.editor;
editor.ui.componentFactory.add( 'myCustomPlugin', locale => {
const view = new ButtonView( locale );
view.set( {
label: 'Insert image',
icon: imageIcon,
tooltip: true
} );
view.on( 'execute', () => {
console.log('dispatch some event');
} );
return view;
} );
}
}
export default MyCustomPlugin;
I install this package for ckeditor package.json looks like this:
"@ckeditor/ckeditor5-build-classic": "^29.0.0",
"@ckeditor/ckeditor5-vue2": "^1.0.5",
and this is my error pic