处理聊天框无法复制复杂富文本
Some checks are pending
Check / lint (push) Waiting to run
Check / typecheck (push) Waiting to run
Check / build (build, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build, 18.x, windows-latest) (push) Waiting to run
Check / build (build:app, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:app, 18.x, windows-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Waiting to run

This commit is contained in:
wangyifeng 2025-04-09 15:08:54 +08:00
parent 9536ce98a6
commit 041692afe8

View File

@ -219,10 +219,19 @@
</div> </div>
<div class="load-toolbar pointer" style="transform: scaleY(-1);"> <div class="load-toolbar pointer" style="transform: scaleY(-1);">
<span v-if="loadConfig.status == 0">正在加载数据中 ...</span> <span v-if="loadConfig.status == 0">正在加载数据中 ...</span>
<span v-if="loadConfig.status == 1 || (loadConfig.status == 2 && !state.localPageLoadDone)" @click="onScrollToLower"> <span
v-if="
loadConfig.status == 1 ||
(loadConfig.status == 2 && !state.localPageLoadDone)
"
@click="onScrollToLower"
>
查看更多消息 ... 查看更多消息 ...
</span> </span>
<span v-if="loadConfig.status == 2 && state.localPageLoadDone" class="no-more"> <span
v-if="loadConfig.status == 2 && state.localPageLoadDone"
class="no-more"
>
没有更多消息了 没有更多消息了
</span> </span>
</div> </div>
@ -616,7 +625,8 @@ const state = ref({
lastMentionText: '', // @ lastMentionText: '', // @
lastMentionTriggered: false, // @ lastMentionTriggered: false, // @
lastMentionPosition: -1, // @ lastMentionPosition: -1, // @
isLoading: false,//loading isLoading: false, //loading
lastSelection: 0,
}) })
uniOnload(async (options) => { uniOnload(async (options) => {
@ -676,7 +686,8 @@ const handleHidePanel = () => {
// //
const onEditorClick = () => { const onEditorClick = () => {
handleHidePanel() handleHidePanel()
const quill = getQuill() // const quill = getQuill();
// if (quill.getText().endsWith('@\n')) { // if (quill.getText().endsWith('@\n')) {
// showMentionSelectDebounced(quill) // showMentionSelectDebounced(quill)
// } // }
@ -1429,10 +1440,6 @@ const getMentionSelectLists = (mentionSelectList) => {
) )
}) })
//
const length = quill.getLength()
quill.setSelection(length, 0)
// //
state.value.lastCursorIndex = undefined state.value.lastCursorIndex = undefined
@ -1707,18 +1714,33 @@ onUnmounted(() => {
// //
const showMentionSelectDebounced = (quill) => { const showMentionSelectDebounced = (quill) => {
const text = quill.getText() const text = quill.getText()
//
// @
const selection = quill.getSelection()
if (selection) {
state.lastSelection = selection.index
if (
text[selection.index - 1].charCodeAt(0) !== 64 &&
text[selection.index - 1].charCodeAt(0) !== 32 &&
text[selection.index - 1].charCodeAt(0) !== 10
) {
uni.showToast({
title: text[selection.index - 1],
icon: 'none',
})
state.value.lastMentionTriggered = false
return
}
}
// @@
if (text !== state.value.lastMentionText) { if (text !== state.value.lastMentionText) {
state.value.lastMentionTriggered = false state.value.lastMentionTriggered = false
} }
// //
if (state.value.lastMentionTriggered) { if (state.value.lastMentionTriggered) {
console.log('return') console.log('return')
return return
} }
// //
state.value.lastMentionText = text state.value.lastMentionText = text
state.value.lastMentionTriggered = true state.value.lastMentionTriggered = true
@ -1997,11 +2019,6 @@ const showMentionSelectDebounced = (quill) => {
} }
.quillBox { .quillBox {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
:deep(.ql-clipboard) { :deep(.ql-clipboard) {
position: relative; position: relative;
opacity: 0; opacity: 0;
@ -2020,19 +2037,10 @@ const showMentionSelectDebounced = (quill) => {
line-height: 44rpx; line-height: 44rpx;
font-size: 32rpx; font-size: 32rpx;
p { .ed-emoji {
display: inline-flex; width: 44rpx;
align-items: center; height: 44rpx;
justify-content: flex-start; display: inline-block;
flex-wrap: wrap;
white-space: normal;
word-break: break-all;
.ed-emoji {
width: 44rpx;
height: 44rpx;
display: inline-block;
}
} }
} }
} }