fix: 避免不同的消息类型之间的换行符导致显示异常
This commit is contained in:
@@ -24,6 +24,15 @@ customElements.define('chat-text', class extends HTMLElement {
|
||||
update() {
|
||||
if (this.span == null) return
|
||||
|
||||
const isFirstElementInParent = this.parentElement?.firstElementChild == this
|
||||
const isLastElementInParent = this.parentElement?.lastElementChild == this
|
||||
|
||||
// 避免不同的消息类型之间的换行符导致显示异常
|
||||
if (isFirstElementInParent)
|
||||
this.span.textContent = this.textContent.trimStart()
|
||||
else if (isLastElementInParent)
|
||||
this.span.textContent = this.textContent.trimEnd()
|
||||
else
|
||||
this.span.textContent = this.textContent
|
||||
this.span.style.textDecoration = $(this).attr('underline') ? 'underline' : ''
|
||||
this.span.style.fontStyle = $(this).attr('em') ? 'italic' : ''
|
||||
|
||||
Reference in New Issue
Block a user