Skip to content

Commit 4973ed8

Browse files
committed
feat(zbugs): support mermaid diagrams
1 parent 5132a4a commit 4973ed8

File tree

3 files changed

+3346
-14987
lines changed

3 files changed

+3346
-14987
lines changed

apps/zbugs/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"rehype-sanitize": "^6.0.0",
3838
"remark-gfm": "^4.0.0",
3939
"use-debounce": "^10.0.4",
40+
"remark-mermaidjs": "4.1.1",
4041
"wouter": "^3.3.5"
4142
},
4243
"devDependencies": {
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import MarkdownBase from 'react-markdown';
22
import remarkGfm from 'remark-gfm';
3+
import mermaid from 'remark-mermaidjs';
4+
5+
// We have to use an old version of remark-mermaidjs until they resolve this issue: remarkjs/react-markdown#680
6+
// Alternatively, just do this ourselves and remove `react-markdown`.
7+
// It isn't that hard: https://github.com/tantaman/strut/blob/main/src/components/editor/well/WellSlidePreview.tsx#L63-L79
8+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9+
type TODO_old_mermaid = any;
310

411
/**
512
* Do not import this component directly. Use `Markdown` instead.
613
*/
714
export default function Markdown({children}: {children: string}) {
8-
return <MarkdownBase rehypePlugins={[remarkGfm]}>{children}</MarkdownBase>;
15+
return (
16+
<MarkdownBase remarkPlugins={[remarkGfm, mermaid as TODO_old_mermaid]}>
17+
{children}
18+
</MarkdownBase>
19+
);
920
}

0 commit comments

Comments
 (0)