I am trying to upload ckeditor to my project, but for 7 hours I try and it does not go away. I searched google, installed from 30 packages (npm), I did with tutorials and slowly give up. Please help, I need to configure wysiwyg editor globally for all views that contain id = "description".
I have something like that: component CKeditor.vue
<template>
</template>
<script>
import ClassicEditor from '@ckeditor/ckeditor5-build-classic'
import VueCkeditor from 'vue-ckeditor5'
export default {
components: {
'vue-ckeditor': VueCkeditor.component
},
data(){
return {
value1: 'hello',
value2: 'world',
editors: {
classic: ClassicEditor
}
}
},
template:
`<vue-ckeditor type="classic" v-model="value1" :editors="editors"></vue-ckeditor>`
}
</script>
View create.blade.php:
<ckeditor type="classic" v-model="value1" class="form-control" rows="5" name="description" id="description" placeholder="Description" maxlength="3000"></ckeditor>
app.js:
import Vue from 'vue'
import axios from 'axios'
Vue.prototype.$http = axios
require('./bootstrap');
Vue.component('ckeditor', require('./components/CKeditor.vue').default);
window.Vue = require('vue');
window.onload = function () {
const app = new Vue({
el: '#app'
});
}
the works were on the tutorial from https://github.com/igorxut/vue-ckeditor5
please help me run this wysiwyg editor. So much thanks... :*
I'll give you from the begining to the end how you can run ckeditor 5 with laravel and vuejs just follow this steps
-1 install CKEditor in laravel with npm
npm install --save @ckeditor/ckeditor5-vue @ckeditor/ckeditor5-build-classic
-2 add this code in app.js file
import CKEditor from '@ckeditor/ckeditor5-vue';
Vue.use( CKEditor );
-3 create a component for ckeditor in app.js
Vue.component('ck-editor', require('./components/ckeditor.vue').default);
-4 add this code to your ckeditor.vue file
<template>
<div>
<ckeditor :editor="editor" v-model="editorData" :config="editorConfig"></ckeditor>
<button v-on:click="emptyEditor()">Empty the editor</button>
<br><br>
<h2>Editor display html code </h2>
<br>
<div>{{editorData}}</div>
<h2>Editor display html Result </h2>
<br>
<button v-on:click="displayEditorResult()">display result </button>
<br><br>
<div id="resultingText"></div>
</div>
</template>
<script>
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
export default {
data() {
return {
editor: ClassicEditor,
editorData: 'ckeditor 5 for laravel and vuejs',
editorConfig: {
// The configuration of the editor.
},
};
},
mounted(){
console.log('Component mounted.')
},
methods: {
emptyEditor() {
this.editorData = '';
},
displayEditorResult(){
document.getElementById('resultingText').innerHTML = this.editorData;
}
}
}
</script>
-5 create a blade file and add this code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ckeditor 5 wyswyg</title>
<link rel="stylesheet" href="/css/app.css">
</head>
<body>
<div id="app">
<ck-editor></ck-editor>
</div>
<script src="/js/app.js"></script>
<script>
</script>
</body>
</html>
finally run the code and it will display CKEditor 5
hope my answer can help you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.