fix: chat-mention 被消去

This commit is contained in:
CrescentLeaf
2025-11-16 22:06:39 +08:00
parent e1039703d1
commit 9e8c9bc508
2 changed files with 4 additions and 3 deletions

View File

@@ -85,9 +85,9 @@ const markedInstance = new marked.Marked({
} else
switch (type) {
case "UserMention":
return `<chat-mention user-id="${escapeHTML(/^tws:\/\/user\?id=(.*)/.exec(href)?.[1] || '')}" text="${escapeHTML(/^UserMention=(.*)/.exec(text)?.[1] || '')}"></chat-mention>`
return `<chat-mention user-id="${escapeHTML(/^tws:\/\/user\?id=(.*)/.exec(href)?.[1] || '')}" text="${escapeHTML(/^UserMention=(.*)/.exec(text)?.[1] || '')}">PH</chat-mention>`
case "ChatMention":
return `<chat-mention chat-id="${escapeHTML(/^tws:\/\/chat\?id=(.*)/.exec(href)?.[1] || '')}" text="${escapeHTML(/^ChatMention=(.*)/.exec(text)?.[1] || '')}"></chat-mention>`
return `<chat-mention chat-id="${escapeHTML(/^tws:\/\/chat\?id=(.*)/.exec(href)?.[1] || '')}" text="${escapeHTML(/^ChatMention=(.*)/.exec(text)?.[1] || '')}">PH</chat-mention>`
}
return `<chat-text em="true">(不支持的附件语法: ![${text}](${href}))</chat-text>`
},

View File

@@ -33,8 +33,9 @@ function prettyFlatParsedMessage(html: string) {
]
function checkContinuousElement(tagName: string) {
if (lastElementType != tagName) {
console.log(lastElementType, ls.map((v) => v.innerHTML))
if (textElementTags.indexOf(lastElementType) != -1) {
// 由于 chat-mention 不是用内部元素实现的, 因此在这个元素的生成中必须放置占位字符串
// 尽管显示上占位字符串不会显示, 但是在这里依然是会被处理的, 因为本身还是 innerHTML
if (ls.map((v) => v.innerHTML).join('').trim() != '')
ret += `<chat-text-container>${ls.map((v) => v.outerHTML).join('')}</chat-text-container>`
} else