fix: iframe rendering (#3916)

* fix iframe rendering

* fix eslint check
pull/3845/head
ti777777 7 months ago committed by GitHub
parent 42bc769d5d
commit 6f3d5762ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -25,7 +25,17 @@ const CodeBlock: React.FC<Props> = ({ language, content }: Props) => {
// Users can set Markdown code blocks as `__html` to render HTML directly. // Users can set Markdown code blocks as `__html` to render HTML directly.
if (formatedLanguage === SpecialLanguage.HTML) { if (formatedLanguage === SpecialLanguage.HTML) {
const purify = DOMPurify(window); const purify = DOMPurify(window);
return <div className="w-full overflow-auto !my-2" dangerouslySetInnerHTML={{ __html: purify.sanitize(content) }} />; return (
<div
className="w-full overflow-auto !my-2"
dangerouslySetInnerHTML={{
__html: purify.sanitize(content, {
ALLOWED_TAGS: ["iframe"],
ADD_ATTR: ["allow", "allowfullscreen", "frameborder", "scrolling"],
}),
}}
/>
);
} else if (formatedLanguage === SpecialLanguage.MERMAID) { } else if (formatedLanguage === SpecialLanguage.MERMAID) {
return <MermaidBlock content={content} />; return <MermaidBlock content={content} />;
} }

Loading…
Cancel
Save