fix(editor): 移除调试日志并修复图片表情解析逻辑
移除无用的console.log调试语句 修复parseEditorContent中图片表情解析逻辑,正确处理表情文本占位符 优化insertImageEmoji方法,移除多余的空格节点插入
This commit is contained in:
parent
62d0ca6076
commit
62cb9c87c2
@ -33,7 +33,6 @@ const props = defineProps({
|
|||||||
const emit = defineEmits(['editor-event'])
|
const emit = defineEmits(['editor-event'])
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const dialogueStore = useDialogueStore()
|
const dialogueStore = useDialogueStore()
|
||||||
console.log('dialogueStore', dialogueStore.talk.talk_type)
|
|
||||||
const editorDraftStore = useEditorDraftStore()
|
const editorDraftStore = useEditorDraftStore()
|
||||||
const editorRef = ref(null)
|
const editorRef = ref(null)
|
||||||
const content = ref('')
|
const content = ref('')
|
||||||
@ -172,7 +171,6 @@ const updateMentionPosition = (range) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const insertMention = (member, clonedRange) => {
|
const insertMention = (member, clonedRange) => {
|
||||||
console.log('插入mention', member);
|
|
||||||
const selection = window.getSelection();
|
const selection = window.getSelection();
|
||||||
if (!clonedRange || !selection || !editorRef.value) return;
|
if (!clonedRange || !selection || !editorRef.value) return;
|
||||||
const range = clonedRange;
|
const range = clonedRange;
|
||||||
@ -565,20 +563,20 @@ const parseEditorContent = () => {
|
|||||||
currentTextBuffer += '\n';
|
currentTextBuffer += '\n';
|
||||||
break;
|
break;
|
||||||
case 'IMG':
|
case 'IMG':
|
||||||
flushTextBufferIfNeeded();
|
|
||||||
const src = node.getAttribute('src');
|
const src = node.getAttribute('src');
|
||||||
const alt = node.getAttribute('alt');
|
const alt = node.getAttribute('alt');
|
||||||
const isEmojiPic = node.classList.contains('editor-emoji');
|
const isEmojiPic = node.classList.contains('editor-emoji');
|
||||||
const isTextEmojiPlaceholder = node.classList.contains('emoji');
|
const isTextEmojiPlaceholder = node.classList.contains('emoji');
|
||||||
if (isTextEmojiPlaceholder && alt) {
|
if ((isEmojiPic || isTextEmojiPlaceholder) && alt) {
|
||||||
currentTextBuffer += alt;
|
currentTextBuffer += alt;
|
||||||
} else if (src) {
|
} else if (src) {
|
||||||
|
flushTextBufferIfNeeded();
|
||||||
items.push({
|
items.push({
|
||||||
type: 3,
|
type: 3,
|
||||||
content: src,
|
content: src,
|
||||||
isEmoji: isEmojiPic,
|
isEmoji: false,
|
||||||
width: node.getAttribute('data-original-width') || node.width || null,
|
width: node.getAttribute('data-original-width') || node.width,
|
||||||
height: node.getAttribute('data-original-height') || node.height || null,
|
height: node.getAttribute('data-original-height') || node.height
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -887,12 +885,8 @@ const insertImageEmoji = (imgSrc, altText) => {
|
|||||||
img.className = 'editor-emoji';
|
img.className = 'editor-emoji';
|
||||||
img.setAttribute('data-role', 'emoji');
|
img.setAttribute('data-role', 'emoji');
|
||||||
range.insertNode(img);
|
range.insertNode(img);
|
||||||
const spaceNode = document.createTextNode('\u00A0');
|
|
||||||
range.setStartAfter(img);
|
range.setStartAfter(img);
|
||||||
range.collapse(true);
|
range.collapse(true);
|
||||||
range.insertNode(spaceNode);
|
|
||||||
range.setStartAfter(spaceNode);
|
|
||||||
range.collapse(true);
|
|
||||||
if (selection) {
|
if (selection) {
|
||||||
selection.removeAllRanges();
|
selection.removeAllRanges();
|
||||||
selection.addRange(range);
|
selection.addRange(range);
|
||||||
|
Loading…
Reference in New Issue
Block a user