fix: edge cases empty codeblock (#4061)

This commit is contained in:
Faisal Amir 2024-11-21 13:08:42 +07:00 committed by GitHub
parent e2a45095b2
commit 0039c5234e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 9 deletions

View File

@ -104,7 +104,9 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
'' ''
) )
if (!language) return node if (extractCodeLines(node) === '') {
return node
}
return { return {
type: 'element', type: 'element',
@ -145,7 +147,7 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
type: 'text', type: 'text',
value: language value: language
? `${getLanguageFromExtension(language)}` ? `${getLanguageFromExtension(language)}`
: 'No file name', : '',
}, },
], ],
}, },

View File

@ -55,7 +55,6 @@
.hljs { .hljs {
overflow: auto; overflow: auto;
display: block; display: block;
padding: 16px;
font-size: 14px; font-size: 14px;
border-bottom-left-radius: 0.4rem; border-bottom-left-radius: 0.4rem;
border-bottom-right-radius: 0.4rem; border-bottom-right-radius: 0.4rem;
@ -65,15 +64,16 @@
pre { pre {
background: hsla(var(--app-code-block)); background: hsla(var(--app-code-block));
overflow: auto; overflow: auto;
padding: 8px 16px;
border-radius: 0.4rem; border-radius: 0.4rem;
} }
pre > code { pre > code {
text-indent: 0;
white-space: pre; white-space: pre;
font-size: 14px; font-size: 14px;
overflow: auto; overflow: auto;
color: #f8f8f2; color: #f8f8f2;
display: block;
padding: 16px;
} }
.hljs-emphasis { .hljs-emphasis {
@ -155,12 +155,11 @@ span.code-line {
.numbered-code-line::before { .numbered-code-line::before {
content: attr(data-line-number); content: attr(data-line-number);
margin-left: -4px;
margin-left: -8px;
margin-right: 16px; margin-right: 16px;
width: 1rem; width: 1.2rem;
font-size: 12px; font-size: 12px;
color: var(--color-text-weak); color: hsla(var(--text-tertiary));
text-align: right; text-align: right;
display: inline-block; display: inline-block;