处理聊天框无法复制复杂富文本
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 class="load-toolbar pointer" style="transform: scaleY(-1);">
<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 v-if="loadConfig.status == 2 && state.localPageLoadDone" class="no-more">
<span
v-if="loadConfig.status == 2 && state.localPageLoadDone"
class="no-more"
>
没有更多消息了
</span>
</div>
@ -616,7 +625,8 @@ const state = ref({
lastMentionText: '', // @
lastMentionTriggered: false, // @
lastMentionPosition: -1, // @
isLoading: false,//loading
isLoading: false, //loading
lastSelection: 0,
})
uniOnload(async (options) => {
@ -676,7 +686,8 @@ const handleHidePanel = () => {
//
const onEditorClick = () => {
handleHidePanel()
const quill = getQuill()
// const quill = getQuill();
// if (quill.getText().endsWith('@\n')) {
// showMentionSelectDebounced(quill)
// }
@ -1429,10 +1440,6 @@ const getMentionSelectLists = (mentionSelectList) => {
)
})
//
const length = quill.getLength()
quill.setSelection(length, 0)
//
state.value.lastCursorIndex = undefined
@ -1707,18 +1714,33 @@ onUnmounted(() => {
//
const showMentionSelectDebounced = (quill) => {
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) {
state.value.lastMentionTriggered = false
}
//
if (state.value.lastMentionTriggered) {
console.log('return')
return
}
//
state.value.lastMentionText = text
state.value.lastMentionTriggered = true
@ -1997,11 +2019,6 @@ const showMentionSelectDebounced = (quill) => {
}
.quillBox {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
:deep(.ql-clipboard) {
position: relative;
opacity: 0;
@ -2020,19 +2037,10 @@ const showMentionSelectDebounced = (quill) => {
line-height: 44rpx;
font-size: 32rpx;
p {
display: inline-flex;
align-items: center;
justify-content: flex-start;
flex-wrap: wrap;
white-space: normal;
word-break: break-all;
.ed-emoji {
width: 44rpx;
height: 44rpx;
display: inline-block;
}
.ed-emoji {
width: 44rpx;
height: 44rpx;
display: inline-block;
}
}
}