Skip to content

Commit

Permalink
fix: iframe rendering (#3916)
Browse files Browse the repository at this point in the history
* fix iframe rendering

* fix eslint check
  • Loading branch information
ti777777 authored Sep 12, 2024
1 parent 42bc769 commit 6f3d576
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion web/src/components/MemoContent/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} />;
}
Expand Down

0 comments on commit 6f3d576

Please sign in to comment.