Revert "fix:修复单行CodeBlock中显示sub"
This reverts commit 09e6756efefa1026a67d28df09db7e5e5e50274d.
This commit is contained in:
parent
3f4fa9b0ec
commit
7d61af7170
@ -65,7 +65,6 @@
|
|||||||
"adm-zip": "^0.5.16",
|
"adm-zip": "^0.5.16",
|
||||||
"apache-arrow": "^18.1.0",
|
"apache-arrow": "^18.1.0",
|
||||||
"docx": "^9.0.2",
|
"docx": "^9.0.2",
|
||||||
"dompurify": "^3.2.3",
|
|
||||||
"electron-log": "^5.1.5",
|
"electron-log": "^5.1.5",
|
||||||
"electron-store": "^8.2.0",
|
"electron-store": "^8.2.0",
|
||||||
"electron-updater": "^6.3.9",
|
"electron-updater": "^6.3.9",
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import CopyIcon from '@renderer/components/Icons/CopyIcon'
|
|||||||
import { useSyntaxHighlighter } from '@renderer/context/SyntaxHighlighterProvider'
|
import { useSyntaxHighlighter } from '@renderer/context/SyntaxHighlighterProvider'
|
||||||
import { useSettings } from '@renderer/hooks/useSettings'
|
import { useSettings } from '@renderer/hooks/useSettings'
|
||||||
import React, { memo, useEffect, useRef, useState } from 'react'
|
import React, { memo, useEffect, useRef, useState } from 'react'
|
||||||
import DOMPurify from 'dompurify'
|
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
|
||||||
@ -38,7 +37,6 @@ const ExpandButton: React.FC<{
|
|||||||
</ExpandButtonWrapper>
|
</ExpandButtonWrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const ALLOWED_TAGS = ['sub'] // 允许的HTML标签
|
|
||||||
|
|
||||||
const CodeBlock: React.FC<CodeBlockProps> = ({ children, className }) => {
|
const CodeBlock: React.FC<CodeBlockProps> = ({ children, className }) => {
|
||||||
const match = /language-(\w+)/.exec(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} />}
|
{language === 'html' && children?.includes('</html>') && <Artifacts html={children} />}
|
||||||
</CodeBlockWrapper>
|
</CodeBlockWrapper>
|
||||||
) : (
|
) : (
|
||||||
<code
|
<code className={className}>{children}</code>
|
||||||
className={className}
|
|
||||||
dangerouslySetInnerHTML={{
|
|
||||||
__html: DOMPurify.sanitize(children, {
|
|
||||||
ALLOWED_TAGS,
|
|
||||||
ALLOWED_ATTR: [] // 不允许任何属性
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
20
yarn.lock
20
yarn.lock
@ -2761,13 +2761,6 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@types/trusted-types@npm:^2.0.7":
|
|
||||||
version: 2.0.7
|
|
||||||
resolution: "@types/trusted-types@npm:2.0.7"
|
|
||||||
checksum: 10c0/4c4855f10de7c6c135e0d32ce462419d8abbbc33713b31d294596c0cc34ae1fa6112a2f9da729c8f7a20707782b0d69da3b1f8df6645b0366d08825ca1522e0c
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"@types/unist@npm:*, @types/unist@npm:^3.0.0":
|
"@types/unist@npm:*, @types/unist@npm:^3.0.0":
|
||||||
version: 3.0.3
|
version: 3.0.3
|
||||||
resolution: "@types/unist@npm:3.0.3"
|
resolution: "@types/unist@npm:3.0.3"
|
||||||
@ -3024,7 +3017,6 @@ __metadata:
|
|||||||
dexie: "npm:^4.0.8"
|
dexie: "npm:^4.0.8"
|
||||||
dexie-react-hooks: "npm:^1.1.7"
|
dexie-react-hooks: "npm:^1.1.7"
|
||||||
docx: "npm:^9.0.2"
|
docx: "npm:^9.0.2"
|
||||||
dompurify: "npm:^3.2.3"
|
|
||||||
dotenv-cli: "npm:^7.4.2"
|
dotenv-cli: "npm:^7.4.2"
|
||||||
electron: "npm:31.7.6"
|
electron: "npm:31.7.6"
|
||||||
electron-builder: "npm:^24.13.3"
|
electron-builder: "npm:^24.13.3"
|
||||||
@ -5110,18 +5102,6 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"dompurify@npm:^3.2.3":
|
|
||||||
version: 3.2.3
|
|
||||||
resolution: "dompurify@npm:3.2.3"
|
|
||||||
dependencies:
|
|
||||||
"@types/trusted-types": "npm:^2.0.7"
|
|
||||||
dependenciesMeta:
|
|
||||||
"@types/trusted-types":
|
|
||||||
optional: true
|
|
||||||
checksum: 10c0/0ce5cb89b76f396d800751bcb48e0d137792891d350ccc049f1bc9a5eca7332cc69030c25007ff4962e0824a5696904d4d74264df9277b5ad955642dfb6f313f
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"domutils@npm:^3.0.1":
|
"domutils@npm:^3.0.1":
|
||||||
version: 3.2.2
|
version: 3.2.2
|
||||||
resolution: "domutils@npm:3.2.2"
|
resolution: "domutils@npm:3.2.2"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user