mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: iframe rendering (#3916)
* fix iframe rendering * fix eslint check
This commit is contained in:
@@ -25,7 +25,17 @@ const CodeBlock: React.FC<Props> = ({ language, content }: Props) => {
|
||||
// Users can set Markdown code blocks as `__html` to render HTML directly.
|
||||
if (formatedLanguage === SpecialLanguage.HTML) {
|
||||
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) {
|
||||
return <MermaidBlock content={content} />;
|
||||
}
|
||||
|
Reference in New Issue
Block a user