diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-09-03 14:09:04 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-09-03 14:09:04 +0200 |
| commit | 91a03428957545c2601340b06de7baf7d6889f62 (patch) | |
| tree | 74e84ff19685cea0fe6c3b12f591e4c1df93f78a /internal/mdedit/res/app.js | |
| parent | 688a652304275d2e4fe4a4be4c0c3d8d640f1138 (diff) | |
| download | gofu-91a03428957545c2601340b06de7baf7d6889f62.tar.gz | |
mdedit: add optional mermaid support
Diffstat (limited to 'internal/mdedit/res/app.js')
| -rw-r--r-- | internal/mdedit/res/app.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/mdedit/res/app.js b/internal/mdedit/res/app.js index c934697..f022bae 100644 --- a/internal/mdedit/res/app.js +++ b/internal/mdedit/res/app.js @@ -29,9 +29,13 @@ const receiveHTML = body => { $("div#preview").innerHTML = body; $("span#status").innerText = "Saved"; + + if (window.mermaid) { + mermaid.run({ querySelector: "div#preview code.language-mermaid" }); + } }; - // whenever the <textedit> changes, wait 3 seconds and then save all changes + // whenever the <textedit> changes, wait 1 second and then save all changes let timeoutID = null; const onTextChange = event => { if (timeoutID !== null) { @@ -52,6 +56,11 @@ handleResponse(fetch("/data.md", opts), receiveHTML); }; + // initialize Mermaid on startup + if (window.mermaid) { + window.mermaid.initialize({ startOnLoad: false }); + } + // load Markdown and rendered HTML on startup handleResponse(fetch("/data.md"), body => { const editor = $("textarea#editor"); |
