fix: 优化消息撤回逻辑和编辑器内容处理
- 调整消息菜单的撤回选项显示逻辑,区分单聊和群聊场景 - 修复编辑器内容处理,使用trimEnd替代trim避免尾部空格问题 - 移除重复的quote元素删除操作 - 优化编辑器空内容判断逻辑
This commit is contained in:
parent
5340461a7e
commit
b905db0cfa
@ -100,6 +100,7 @@ const handleInput = (event) => {
|
|||||||
const editorClone = target.cloneNode(true)
|
const editorClone = target.cloneNode(true)
|
||||||
const quoteElements = editorClone.querySelectorAll('.editor-quote')
|
const quoteElements = editorClone.querySelectorAll('.editor-quote')
|
||||||
quoteElements.forEach(quote => quote.remove())
|
quoteElements.forEach(quote => quote.remove())
|
||||||
|
quoteElements.forEach(quote => quote.remove())
|
||||||
|
|
||||||
// 处理表情图片,将其 alt 属性(表情文本)添加到文本内容中
|
// 处理表情图片,将其 alt 属性(表情文本)添加到文本内容中
|
||||||
const emojiImages = editorClone.querySelectorAll('img.editor-emoji')
|
const emojiImages = editorClone.querySelectorAll('img.editor-emoji')
|
||||||
@ -119,7 +120,8 @@ const handleInput = (event) => {
|
|||||||
editorContent.value = textContent
|
editorContent.value = textContent
|
||||||
|
|
||||||
// 检查是否需要清空编辑器以显示placeholder
|
// 检查是否需要清空编辑器以显示placeholder
|
||||||
const isEmpty = textContent.trim() === '' &&
|
// 只有当编辑器中没有任何内容(包括空格)且没有其他元素时才清空
|
||||||
|
const isEmpty = textContent === '' &&
|
||||||
!target.querySelector('img, .editor-file, .mention')
|
!target.querySelector('img, .editor-file, .mention')
|
||||||
|
|
||||||
if (isEmpty && target.innerHTML !== '') {
|
if (isEmpty && target.innerHTML !== '') {
|
||||||
@ -525,14 +527,14 @@ const sendMessage = () => {
|
|||||||
if (messageData.items.length === 0 ||
|
if (messageData.items.length === 0 ||
|
||||||
(messageData.items.length === 1 &&
|
(messageData.items.length === 1 &&
|
||||||
messageData.items[0].type === 1 &&
|
messageData.items[0].type === 1 &&
|
||||||
!messageData.items[0].content.trim())) {
|
!messageData.items[0].content.trimEnd())) {
|
||||||
return // 没有内容,不发送
|
return // 没有内容,不发送
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理不同类型的消息
|
// 处理不同类型的消息
|
||||||
messageData.items.forEach(item => {
|
messageData.items.forEach(item => {
|
||||||
// 处理文本内容
|
// 处理文本内容
|
||||||
if (item.type === 1 && item.content.trim()) {
|
if (item.type === 1 && item.content.trimEnd()) {
|
||||||
const data = {
|
const data = {
|
||||||
items: [{
|
items: [{
|
||||||
content: item.content,
|
content: item.content,
|
||||||
@ -634,7 +636,7 @@ const parseEditorContent = () => {
|
|||||||
if (textContent.trim()) {
|
if (textContent.trim()) {
|
||||||
items.push({
|
items.push({
|
||||||
type: 1,
|
type: 1,
|
||||||
content: textContent.trim()
|
content: textContent.trimEnd()
|
||||||
})
|
})
|
||||||
textContent = ''
|
textContent = ''
|
||||||
}
|
}
|
||||||
@ -674,7 +676,7 @@ const parseEditorContent = () => {
|
|||||||
if (textContent.trim()) {
|
if (textContent.trim()) {
|
||||||
items.push({
|
items.push({
|
||||||
type: 1,
|
type: 1,
|
||||||
content: textContent.trim()
|
content: textContent.trimEnd()
|
||||||
})
|
})
|
||||||
textContent = ''
|
textContent = ''
|
||||||
}
|
}
|
||||||
@ -696,7 +698,7 @@ const parseEditorContent = () => {
|
|||||||
if (textContent.trim()) {
|
if (textContent.trim()) {
|
||||||
items.push({
|
items.push({
|
||||||
type: 1,
|
type: 1,
|
||||||
content: textContent.trim()
|
content: textContent.trimEnd()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,20 @@ export function useMenu() {
|
|||||||
|
|
||||||
dropdown.options.push({ label: '多选', key: 'multiSelect' })
|
dropdown.options.push({ label: '多选', key: 'multiSelect' })
|
||||||
dropdown.options.push({ label: '引用', key: 'quote' })
|
dropdown.options.push({ label: '引用', key: 'quote' })
|
||||||
if (isRevoke(uid, item)|| (dialogueStore.groupInfo as any).is_manager) {
|
//如果是单聊
|
||||||
dropdown.options.push({ label: `撤回`, key: 'revoke' })
|
if(item.talk_type===1){
|
||||||
|
//撤回时间限制内,并且是自己发的
|
||||||
|
if(isRevoke(uid, item)&&item.float==='right'){
|
||||||
|
dropdown.options.push({ label: `撤回`, key: 'revoke' })
|
||||||
|
}
|
||||||
|
//群聊
|
||||||
|
}else if(item.talk_type===2){
|
||||||
|
//管理员可以强制撤回所有成员信息
|
||||||
|
if ((dialogueStore.groupInfo as any).is_manager) {
|
||||||
|
dropdown.options.push({ label: `撤回`, key: 'revoke' })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dropdown.options.push({ label: '删除', key: 'delete' })
|
dropdown.options.push({ label: '删除', key: 'delete' })
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user