-
Notifications
You must be signed in to change notification settings - Fork 0
/
mermaid.html
45 lines (34 loc) · 1.21 KB
/
mermaid.html
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
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://docs.getgrist.com/grist-plugin-api.js"></script>
</head>
<body>
<div id="mermaid-svg">Place Holder</div>
</pre>
<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 graphDefinition = mapped.mermaid;
runMermaid(graphDefinition).then((svg) => {
document.getElementById("mermaid-svg").innerHTML = svg;
})
});
</script>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: false });
async function runMermaid(graphDefinition) {
const { svg } = await mermaid.render('graphDiv', graphDefinition);
return svg;
};
globalThis.runMermaid = runMermaid;
</script>
</body>
</html>