|
@@ -104,16 +104,25 @@
|
|
|
formats: {}
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ richValue: {
|
|
|
+ handler(newVal) {
|
|
|
+ this.setEditorContent(newVal || '')
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ deep: true
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
- isExceedValidate(alert = false, title = '字数超出限制') {
|
|
|
+ isExceedValidate(alert = false, isReturn = false, title = '字数超出限制') {
|
|
|
const bool = Boolean(this.max-0 && (this.currentWordCount-0 > this.max-0))
|
|
|
if (alert && bool) uni.showToast({ title, icon: 'none', duration: 2000 })
|
|
|
- return bool
|
|
|
+ if (isReturn && bool) return true
|
|
|
},
|
|
|
handleBlur() {
|
|
|
this.editorCtx.getContents({
|
|
|
success: (res) => {
|
|
|
- this.$emit('blur',res.html)
|
|
|
+ this.$emit('blur', res.html === '<p><br></p>' ? '' : res.html)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -127,15 +136,20 @@
|
|
|
if (this.max-0 && (text.length >= this.max-0)) {
|
|
|
uni.showToast({ icon: 'none', title: `最多可输入${this.max}个字符` })
|
|
|
}
|
|
|
+ // this.$emit('change', html)
|
|
|
}, 500)
|
|
|
},
|
|
|
setEditorContent(content) {
|
|
|
this.editorCtx.setContents({
|
|
|
html: content
|
|
|
});
|
|
|
+ this.editorCtx.getContents({
|
|
|
+ success: (res) => {
|
|
|
+ this.currentWordCount = res?.text?.length || 0
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
onEditorReady() {
|
|
|
-
|
|
|
// #ifdef APP-PLUS || MP-WEIXIN || H5
|
|
|
this.createSelectorQuery().select('#editor').context((res) => {
|
|
|
this.editorCtx = res.context
|