generated from githubnext/blocks-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jake Donham
committed
Jun 24, 2022
1 parent
b8313b3
commit 2d10e0c
Showing
6 changed files
with
2,766 additions
and
2,714 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
import { | ||
FileBlockProps, | ||
} from "@githubnext/utils"; | ||
import React from "react"; | ||
|
||
import { FileBlockProps } from "@githubnext/utils"; | ||
import "./index.css"; | ||
|
||
import mermaid from 'mermaid'; | ||
import mermaid from "mermaid"; | ||
|
||
mermaid.mermaidAPI.initialize({ startOnLoad: false }); | ||
|
||
const Mermaid: React.FC = (props) => { | ||
const __html = mermaid.mermaidAPI.render( | ||
'id', | ||
String(props.children), | ||
); | ||
return <div dangerouslySetInnerHTML={{ __html }}/>; | ||
} | ||
|
||
export default function (props: FileBlockProps) { | ||
const { context, content, metadata, onUpdateMetadata } = props; | ||
return <Mermaid>{content}</Mermaid>; | ||
const { content } = props; | ||
const [rendered, setRendered] = React.useState(""); | ||
|
||
React.useEffect(() => { | ||
const rendered = mermaid.mermaidAPI.render("id", content); | ||
setRendered(rendered); | ||
}, [content]); | ||
|
||
return <div dangerouslySetInnerHTML={{ __html: rendered }} />; | ||
} |
Oops, something went wrong.