diff --git a/components/uni-im-editor/uni-im-editor.vue b/components/uni-im-editor/uni-im-editor.vue index aa90e3422f50e1c91c08094be139ea3ec32ecac3..cf66a195b43b3612342460372302c307b780537f 100644 --- a/components/uni-im-editor/uni-im-editor.vue +++ b/components/uni-im-editor/uni-im-editor.vue @@ -1,9 +1,18 @@ @@ -13,7 +22,11 @@ emits: ["input", "confirm"], data() { return { - callRmdParam: [] + callRmdParam: [], + // #ifdef MP + "textareaValue":this.modelValue, + lastCursor:this.modelValue.length + // #endif } }, props: { @@ -32,7 +45,24 @@ }, mounted() { // 与rmd通讯专用 - this.callRmd = async (funcName, ...params) => { + this.callRmd = async (funcName, ...params) => { + // #ifdef MP + switch (funcName){ + case '$setContent': + this.textareaValue = params[0] + break; + case '$addHtmlToCursor': + // 在第lastCursor位置添加内容 + setTimeout(()=>{ + this.textareaValue = this.textareaValue.slice(0,this.lastCursor) + params[0] + this.textareaValue.slice(this.lastCursor) + },300) + break; + default: + console.error('小程序暂不支持与rmd通讯',funcName,params) + break; + } + return + // #endif this.callRmdParam = [] this.$nextTick(() => { return new Promise((resolve, reject) => { @@ -213,13 +243,26 @@ // #endif }, methods: { - oninput(e) { + oninput(e) { + // #ifdef MP + let oldValue = this.oninput.oldValue || ''; + // 当前输入框的值 + const value = e.detail.value + // 本次输入的数据 + const data = value.replace(oldValue, '') + this.oninput.oldValue = value + e = { + data, + value + } + // #endif + // console.error('input',e) this.$emit('input', e) } } } - + + + -