From 62cb9c87c25bfb44b91869b76b7aab7fed7d7cf8 Mon Sep 17 00:00:00 2001 From: Phoenix <64720302+Concur-max@users.noreply.github.com> Date: Tue, 1 Jul 2025 15:04:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=E7=A7=BB=E9=99=A4=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=97=A5=E5=BF=97=E5=B9=B6=E4=BF=AE=E5=A4=8D=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E8=A1=A8=E6=83=85=E8=A7=A3=E6=9E=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除无用的console.log调试语句 修复parseEditorContent中图片表情解析逻辑,正确处理表情文本占位符 优化insertImageEmoji方法,移除多余的空格节点插入 --- src/components/editor/CustomEditor.vue | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/editor/CustomEditor.vue b/src/components/editor/CustomEditor.vue index 6f83bba..035256b 100644 --- a/src/components/editor/CustomEditor.vue +++ b/src/components/editor/CustomEditor.vue @@ -33,7 +33,6 @@ const props = defineProps({ const emit = defineEmits(['editor-event']) const userStore = useUserStore() const dialogueStore = useDialogueStore() -console.log('dialogueStore', dialogueStore.talk.talk_type) const editorDraftStore = useEditorDraftStore() const editorRef = ref(null) const content = ref('') @@ -172,7 +171,6 @@ const updateMentionPosition = (range) => { } } const insertMention = (member, clonedRange) => { - console.log('插入mention', member); const selection = window.getSelection(); if (!clonedRange || !selection || !editorRef.value) return; const range = clonedRange; @@ -565,20 +563,20 @@ const parseEditorContent = () => { currentTextBuffer += '\n'; break; case 'IMG': - flushTextBufferIfNeeded(); const src = node.getAttribute('src'); const alt = node.getAttribute('alt'); const isEmojiPic = node.classList.contains('editor-emoji'); const isTextEmojiPlaceholder = node.classList.contains('emoji'); - if (isTextEmojiPlaceholder && alt) { + if ((isEmojiPic || isTextEmojiPlaceholder) && alt) { currentTextBuffer += alt; } else if (src) { + flushTextBufferIfNeeded(); items.push({ type: 3, content: src, - isEmoji: isEmojiPic, - width: node.getAttribute('data-original-width') || node.width || null, - height: node.getAttribute('data-original-height') || node.height || null, + isEmoji: false, + width: node.getAttribute('data-original-width') || node.width, + height: node.getAttribute('data-original-height') || node.height }); } break; @@ -887,12 +885,8 @@ const insertImageEmoji = (imgSrc, altText) => { img.className = 'editor-emoji'; img.setAttribute('data-role', 'emoji'); range.insertNode(img); - const spaceNode = document.createTextNode('\u00A0'); range.setStartAfter(img); range.collapse(true); - range.insertNode(spaceNode); - range.setStartAfter(spaceNode); - range.collapse(true); if (selection) { selection.removeAllRanges(); selection.addRange(range);