Revert "fix:修复单行CodeBlock中显示sub"

This reverts commit d808b6dffc.
This commit is contained in:
kangfenmao
2025-01-08 10:46:08 +08:00
parent cd5c1b4797
commit 7fb9a34f7d
3 changed files with 1 additions and 32 deletions
@@ -3,7 +3,6 @@ import CopyIcon from '@renderer/components/Icons/CopyIcon'
import { useSyntaxHighlighter } from '@renderer/context/SyntaxHighlighterProvider'
import { useSettings } from '@renderer/hooks/useSettings'
import React, { memo, useEffect, useRef, useState } from 'react'
import DOMPurify from 'dompurify'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'
@@ -38,7 +37,6 @@ const ExpandButton: React.FC<{
</ExpandButtonWrapper>
)
}
const ALLOWED_TAGS = ['sub'] // 允许的HTML标签
const CodeBlock: React.FC<CodeBlockProps> = ({ children, className }) => {
const match = /language-(\w+)/.exec(className || '')
@@ -135,15 +133,7 @@ const CodeBlock: React.FC<CodeBlockProps> = ({ children, className }) => {
{language === 'html' && children?.includes('</html>') && <Artifacts html={children} />}
</CodeBlockWrapper>
) : (
<code
className={className}
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(children, {
ALLOWED_TAGS,
ALLOWED_ATTR: [] // 不允许任何属性
})
}}
/>
<code className={className}>{children}</code>
)
}