953 B30 lines
Blame
1<!doctype html>
2<html>
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6 <title>Mermaid Quick Test Page</title>
7 <link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" />
8 </head>
9 <body>
10 <div id="graph"></div>
11
12 <script type="module">
13 import mermaid from './mermaid.esm.mjs';
14 mermaid.initialize({ startOnLoad: false });
15 mermaid.mermaidAPI.initialize();
16
17 async function rerender(text) {
18 const graphText = `graph TD
19 A[${text}] -->|Get money| B(Go shopping)`;
20 const { svg } = await mermaid.mermaidAPI.render('id', graphText);
21 console.log('\x1b[35m%s\x1b[0m', '>> graph', svg);
22 document.getElementById('graph').innerHTML = svg;
23 }
24 window.rerender = rerender;
25 await rerender('XMas');
26 </script>
27 <button id="rerender" onclick="rerender('Saturday')">Rerender</button>
28 </body>
29</html>
30