feat: enable more HTML restrictions in comments
This commit is contained in:
parent
3a8b501bbd
commit
347e10e215
|
|
@ -95,6 +95,7 @@ export const CommentItem: React.FC<{
|
|||
</div>
|
||||
<PageContent
|
||||
content={comment.metadata?.content?.content}
|
||||
isComment={true}
|
||||
></PageContent>
|
||||
<div className="mt-1 flex items-center">
|
||||
<Reactions
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export const PageContent: React.FC<{
|
|||
onScroll?: (scrollTop: number) => void
|
||||
onMouseEnter?: () => void
|
||||
parsedContent?: ReturnType<typeof renderPageContent>
|
||||
isComment?: boolean
|
||||
}> = ({
|
||||
className,
|
||||
content,
|
||||
|
|
@ -22,6 +23,7 @@ export const PageContent: React.FC<{
|
|||
onScroll,
|
||||
onMouseEnter,
|
||||
parsedContent,
|
||||
isComment,
|
||||
}) => {
|
||||
useCodeCopy()
|
||||
|
||||
|
|
@ -29,12 +31,12 @@ export const PageContent: React.FC<{
|
|||
if (parsedContent) {
|
||||
return parsedContent
|
||||
} else if (content) {
|
||||
const result = renderPageContent(content)
|
||||
const result = renderPageContent(content, false, isComment)
|
||||
return result
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}, [content, parsedContent])
|
||||
}, [content, isComment, parsedContent])
|
||||
|
||||
useEffect(() => {
|
||||
const hashChangeHandler = () => {
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ const rehypePrism = rehypePrismGenerator(refractor)
|
|||
export const renderPageContent = (
|
||||
content: string,
|
||||
html?: boolean,
|
||||
simple?: boolean,
|
||||
): Rendered => {
|
||||
const env: MarkdownEnv = {
|
||||
excerpt: "",
|
||||
|
|
@ -162,7 +163,7 @@ export const renderPageContent = (
|
|||
]
|
||||
},
|
||||
})
|
||||
.use(rehypeSanitize, sanitizeScheme)
|
||||
.use(rehypeSanitize, simple ? undefined : sanitizeScheme)
|
||||
.use(rehypeTable)
|
||||
.use(rehypeExternalLink)
|
||||
.use(rehypeWrapCode)
|
||||
|
|
|
|||
Loading…
Reference in New Issue