update quill editor

This commit is contained in:
lb
2023-02-08 11:03:26 +08:00
parent 64274e0743
commit 5f84d1da6f
7 changed files with 149 additions and 12 deletions

View File

@@ -10,7 +10,8 @@ export default {
ReadOnlyMode: false,
Placeholder: '在这里输入描述信息...',
ScrollingContainer: null,
editor: null
editor: null,
content: ''
}
},
watch: {
@@ -34,11 +35,15 @@ export default {
// 只在 mode 不为 create 的时候,才加载数据
if (val && this.mode !== 'create') {
// this.mode 会比 modelValue 先获得值
this.editor && this.editor.setContents(JSON.parse(val), "user")
this.content = JSON.parse(val)
this.editor && this.editor.setContents(this.content, "user")
} else if (val === null || val === undefined) {
// 当 modelValue 传入空时,清空内容
this.editor && this.editor.setContents('\n', "user")
}
},
content(val) {
this.$emit('update:modelValue', { subject: 'richInput', payload: { data: val } })
}
},
mounted() {
@@ -71,7 +76,8 @@ export default {
})
this.editor.on('text-change', (delta, oldDelta, source) => {
this.$emit('update:modelValue', { subject: 'richInput', payload: { data: this.editor.getContents() } })
this.content = this.editor.getContents()
// this.$emit('update:modelValue', { subject: 'richInput', payload: { data: this.editor.getContents() } })
})
},
methods: {