Skip to content

Commit

Permalink
Update mermaid.html
Browse files Browse the repository at this point in the history
  • Loading branch information
nicobako authored May 12, 2024
1 parent 3e50dc8 commit 700904a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions mermaid.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
I'm<!DOCTYPE html>
<html lang="en">

<head>
Expand All @@ -10,27 +10,26 @@
</head>

<body>
<div id="mermaid">
<pre class="mermaid">
<pre id="mermaid" class="mermaid">
graph LR
A --- B
B-->C[fa:fa-ban forbidden]
B-->D(fa:fa-spinner);
</pre>
</div>
<script>
grist.ready({ requiredAccess: 'read table', columns: ["mermaid"] });
grist.onRecord(function (record) {
console.log("record", record);
const mapped = grist.mapColumnNames(record);
console.log("mapped", mapped);
const mermaid_el_id = 'mermaid';
document.getElementById(mermaid_el_id).innerHTML = `<pre class='mermaid'>${mapped.mermaid}</pre>`;
mermaid.initialize();
});
const el = document.getElementById(mermaid_el_id);
const graph = mapped.mermaid;
mermaid.render("graphDiv", graph).then( res => el.innerHTML = res.svg );
</script>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaidAPI.initialize({ startOnLoad: false });
</script>

</body>
Expand Down

0 comments on commit 700904a

Please sign in to comment.