lifanagju_citu hai 1 mes
pai
achega
0bba82e2de
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      components/RichEditor/index.vue

+ 8 - 1
components/RichEditor/index.vue

@@ -46,7 +46,7 @@
 			</view>
 		</view>
 		<view v-if="max && max-0" class="word-count" :class="currentWordCount > max-0 ? 'warn' : 'normal'">
-			<text>{{ currentWordCount }}</text>
+			<text>{{ currentWordCount ? currentWordCount - 1 : currentWordCount }}</text>
 			<text> / </text>
 			<text>{{ max }}</text>
 		</view>
@@ -103,6 +103,7 @@
           shanchu: true,
           direction: false
         },
+				inputText: null,
 				inputTimer: null,
 				currentWordCount: 0,
 				readOnly: false,
@@ -136,6 +137,7 @@
 					const text = e?.detail?.text ? e.detail.text : null
 					const html = e?.detail?.html ? e.detail.html : null
 					if (!text || !html) return
+					this.inputText = text
 					this.currentWordCount = text.length || 0
 					if (this.max-0 && (text.length >= this.max-0)) {
 						uni.showToast({ icon: 'none', title: `最多可输入${this.max}个字符` })
@@ -144,6 +146,10 @@
 				}, 500)
 			},
 			setEditorContent(content) {
+				console.log('setEditorContent-content1:', content)
+				if (!content && !this.inputText) return
+				if (typeof content !== 'string') content = ''
+				console.log('setEditorContent-content2:', content)
 				this.editorCtx.setContents({
 					html: content
 				});
@@ -152,6 +158,7 @@
 						this.currentWordCount = res?.text?.length || 0
 					}
 				})
+				this.editorCtx.blur()
 			},
 			onEditorReady() {
 				// #ifdef APP-PLUS || MP-WEIXIN || H5