From 6f7edd0b408586a971a49e273660ba83fd9682fc Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 8 Apr 2025 08:49:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E7=84=A6=E7=82=B9=E6=8A=96=E5=8A=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/components/ChatInput/index.vue | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue index c03418734..d89d604d8 100755 --- a/resources/assets/js/pages/manage/components/ChatInput/index.vue +++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue @@ -988,7 +988,7 @@ export default { // Mark model as touched if editor lost focus this.quill.on('selection-change', range => { - if (!inputLoadIsLast(this._uid)) { + if (!this.inputActivated()) { return; } if (range) { @@ -1247,6 +1247,10 @@ export default { }, 100) }, + inputActivated() { + return !this.fullInput && inputLoadIsLast(this._uid) + }, + getEditor() { return this.fullInput ? this.fullQuill : this.quill }, @@ -1294,6 +1298,7 @@ export default { onClickEditor() { this.clearSearchKey() this.updateEmojiQuick(this.value) + inputLoadAdd(this._uid) }, clearSearchKey() { @@ -1731,7 +1736,15 @@ export default { } }, this.options)) this.fullQuill.on('selection-change', range => { - this.fullSelection = range || {index: 0, length: 0}; + if (range) { + this.fullSelection = range + } else if (this.fullSelection && document.activeElement && /(ql-editor|ql-clipboard)/.test(document.activeElement.className)) { + // 修复iOS光标会超出的问题 + this.selectTimer && clearTimeout(this.selectTimer) + this.selectTimer = setTimeout(_ => { + this.fullQuill.setSelection(this.fullSelection.index, this.fullSelection.length) + }, 100) + } }) this.fullQuill.on('text-change', _ => { this.fullSelection = this.fullQuill.getSelection() @@ -1900,7 +1913,7 @@ export default { if (!this.quill) { return; } - if (!inputLoadIsLast(this._uid)) { + if (!this.inputActivated()) { return; } const {index} = this.quill.getSelection(true);