-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathMarkdownHtml.tsx
More file actions
36 lines (32 loc) · 794 Bytes
/
MarkdownHtml.tsx
File metadata and controls
36 lines (32 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { memo, useMemo } from "react";
import {
type MarkdownPreviewTheme,
renderMarkdownHtml,
MARKDOWN_PREVIEW_CONTAINER_STYLE,
} from "~/lib/markdownHtml";
export function MarkdownHtml({
markdown,
theme,
className,
bodyClassName,
testId,
}: {
markdown: string;
theme: MarkdownPreviewTheme;
className?: string;
bodyClassName?: string;
testId?: string;
}) {
const rendered = useMemo(() => renderMarkdownHtml(markdown, theme), [markdown, theme]);
return (
<div className={className} style={MARKDOWN_PREVIEW_CONTAINER_STYLE}>
<style>{rendered.css}</style>
<div
className={bodyClassName}
data-testid={testId}
dangerouslySetInnerHTML={{ __html: rendered.html }}
/>
</div>
);
}
export default memo(MarkdownHtml);