Creating & using a dynamic view component. Component is set depending on laravel config

parent 4c4fc7d0
export default {
methods: {
getCurrentEditor() {
const configuredEditor = window.AsgardCMS.editor;
if (configuredEditor === 'simplemde') {
return 'markdown-editor';
}
if (configuredEditor === 'ckeditor') {
return 'ckeditor';
}
return 'ckeditor'
},
}
}
...@@ -45,8 +45,9 @@ ...@@ -45,8 +45,9 @@
<el-form-item :label="trans('page.body')" <el-form-item :label="trans('page.body')"
:class="{'el-form-item is-error': form.errors.has(locale + '.body') }"> :class="{'el-form-item is-error': form.errors.has(locale + '.body') }">
<ckeditor v-model="page[locale].body" :value="page[locale].body"> <component :is="getCurrentEditor()" v-model="page[locale].body" :value="page[locale].body">
</ckeditor> </component>
<div class="el-form-item__error" v-if="form.errors.has(locale + '.body')" <div class="el-form-item__error" v-if="form.errors.has(locale + '.body')"
v-text="form.errors.first(locale + '.body')"></div> v-text="form.errors.first(locale + '.body')"></div>
</el-form-item> </el-form-item>
...@@ -154,10 +155,11 @@ ...@@ -154,10 +155,11 @@
import axios from 'axios' import axios from 'axios'
import Slugify from '../../../../Core/Assets/js/mixins/Slugify' import Slugify from '../../../../Core/Assets/js/mixins/Slugify'
import ShortcutHelper from '../../../../Core/Assets/js/mixins/ShortcutHelper' import ShortcutHelper from '../../../../Core/Assets/js/mixins/ShortcutHelper'
import ActiveEditor from '../../../../Core/Assets/js/mixins/ActiveEditor'
import Form from 'form-backend-validation' import Form from 'form-backend-validation'
export default { export default {
mixins: [Slugify, ShortcutHelper], mixins: [Slugify, ShortcutHelper, ActiveEditor],
props: { props: {
locales: {default: null}, locales: {default: null},
pageTitle: {default: null, String}, pageTitle: {default: null, String},
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment