refactor: mardown展示优化
This commit is contained in:
parent
2a37568338
commit
4c8ca9678c
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<el-form-item v-loading="result.loading" :disable="true" :label="title" :prop="prop" :label-width="labelWidth">
|
<el-form-item v-loading="result.loading" :disable="true" :label="title" :prop="prop" :label-width="labelWidth">
|
||||||
<mavon-editor v-if="active" :editable="!disabled" @imgAdd="imgAdd" :default-open="disabled ? 'preview' : null" class="mavon-editor"
|
<mavon-editor :id="id" v-if="active" :editable="!disabled" @imgAdd="imgAdd" :default-open="defaultOpen" class="mavon-editor"
|
||||||
:subfield="disabled ? false : true" :toolbars="toolbars" :language="language" :toolbarsFlag="disabled ? false : true" @imgDel="imgDel" v-model="data[prop]" ref="md"/>
|
:subfield="false" :toolbars="toolbars" :language="language" :toolbarsFlag="disabled ? false : true" @imgDel="imgDel" v-model="data[prop]" ref="md"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
result: {loading: false},
|
result: {loading: false},
|
||||||
|
id: getUUID(),
|
||||||
|
defaultOpen: 'preview',
|
||||||
toolbars: {
|
toolbars: {
|
||||||
bold: true, // 粗体
|
bold: true, // 粗体
|
||||||
italic: true, // 斜体
|
italic: true, // 斜体
|
||||||
|
@ -73,6 +75,17 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
// 点击编辑,失去焦点展示
|
||||||
|
let el = document.getElementById(this.id);
|
||||||
|
el.addEventListener('click', () => {
|
||||||
|
this.defaultOpen = null;
|
||||||
|
});
|
||||||
|
let input = el.getElementsByClassName('auto-textarea-input');
|
||||||
|
input[0].addEventListener('blur', () => {
|
||||||
|
this.defaultOpen = 'preview';
|
||||||
|
});
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
imgAdd(pos, file){
|
imgAdd(pos, file){
|
||||||
let param = {
|
let param = {
|
||||||
|
|
Loading…
Reference in New Issue