CKEditor5 与 vue.js 和 laravel 的集成
CKEditor5 integration with vue.js and laravel
我正在尝试将 ckeditor 上传到我的项目,但我尝试了 7 个小时,但它并没有消失。我搜索了 google,从 30 个包(npm)安装,我做了教程并慢慢放弃了。请帮忙,我需要为所有包含 id = "description".
的视图全局配置所见即所得编辑器
我有这样的东西:
组件 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>
查看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'
});
}
这些作品来自 https://github.com/igorxut/vue-ckeditor5
的教程
请帮助我运行 这个所见即所得的编辑器。非常感谢...:*
我会从头到尾告诉你如何 运行 ckeditor 5 与 laravel 和 vuejs 只需按照这些步骤
-1 使用 npm
在 laravel 中安装 CKEditor
npm install --save @ckeditor/ckeditor5-vue @ckeditor/ckeditor5-build-classic
-2 在 app.js 文件中添加此代码
import CKEditor from '@ckeditor/ckeditor5-vue';
Vue.use( CKEditor );
-3 在app.js
中为ckeditor创建一个组件
Vue.component('ck-editor', require('./components/ckeditor.vue').default);
-4 将此代码添加到您的 ckeditor.vue 文件
<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 创建一个blade 文件并添加此代码
<!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>
最后 运行 代码,它将显示 CKEditor 5
希望我的回答能帮到您
我正在尝试将 ckeditor 上传到我的项目,但我尝试了 7 个小时,但它并没有消失。我搜索了 google,从 30 个包(npm)安装,我做了教程并慢慢放弃了。请帮忙,我需要为所有包含 id = "description".
的视图全局配置所见即所得编辑器我有这样的东西: 组件 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>
查看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'
});
}
这些作品来自 https://github.com/igorxut/vue-ckeditor5
的教程请帮助我运行 这个所见即所得的编辑器。非常感谢...:*
我会从头到尾告诉你如何 运行 ckeditor 5 与 laravel 和 vuejs 只需按照这些步骤
-1 使用 npm
在 laravel 中安装 CKEditornpm install --save @ckeditor/ckeditor5-vue @ckeditor/ckeditor5-build-classic
-2 在 app.js 文件中添加此代码
import CKEditor from '@ckeditor/ckeditor5-vue';
Vue.use( CKEditor );
-3 在app.js
中为ckeditor创建一个组件Vue.component('ck-editor', require('./components/ckeditor.vue').default);
-4 将此代码添加到您的 ckeditor.vue 文件
<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 创建一个blade 文件并添加此代码
<!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>
最后 运行 代码,它将显示 CKEditor 5
希望我的回答能帮到您