Skip to content

Instantly share code, notes, and snippets.

@marufhasan1
Created November 29, 2021 07:09
Show Gist options
  • Save marufhasan1/6db6184195a5e0cfdce41f039fd99235 to your computer and use it in GitHub Desktop.
Save marufhasan1/6db6184195a5e0cfdce41f039fd99235 to your computer and use it in GitHub Desktop.
CKEditor5 With NuxtJs

Usage Guideline

1 - Install dependencies

npm install --save @ckeditor/ckeditor5-vue2 @ckeditor/ckeditor5-build-classic  

2 - initialize plugin

// nuxt.config.js
plugins: [
      ....,
      '~/plugins/ckeditor.client.js',
  ],

3 - Add the following component & module 4 - Usage

<MyCkEditor v-model="description"/>
//Nuxt Plugin
import Vue from 'vue';
import CKEditor from '@ckeditor/ckeditor5-vue2';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
Vue.use( CKEditor );
export default ({ app }, inject) => {
inject('ClassicEditor', ClassicEditor)
}
<template>
<ckeditor :editor="editor" :value="value" @input="handleInput" :config="editorConfig"/>
</template>
<script>
export default {
props : ['value'],
data(){
return{
editor: this.$ClassicEditor,
editorConfig: {
// The configuration of the editor.
}
}
},
methods:{
handleInput (e){
this.$emit('input', e)
}
}
}
</script>
<style >
.ck-editor__editable {
min-height: 200px;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment