2020-12-09 21:42:46 +03:00
|
|
|
|
<!--
|
|
|
|
|
mermaid-js loader
|
|
|
|
|
-->
|
2021-01-23 10:07:18 +03:00
|
|
|
|
|
2022-06-02 15:55:34 +03:00
|
|
|
|
<script src="{{ site.data.assets[origin].mermaid.js | relative_url }}"></script>
|
2021-12-12 21:37:10 +03:00
|
|
|
|
|
2020-12-09 21:42:46 +03:00
|
|
|
|
<script>
|
2022-11-04 23:28:44 +03:00
|
|
|
|
(function () {
|
|
|
|
|
|
2021-12-12 21:37:10 +03:00
|
|
|
|
function updateMermaid(event) {
|
|
|
|
|
if (event.source === window && event.data &&
|
2022-11-04 23:28:44 +03:00
|
|
|
|
event.data.direction === ModeToggle.ID) {
|
2021-12-12 21:37:10 +03:00
|
|
|
|
|
|
|
|
|
const mode = event.data.message;
|
|
|
|
|
|
|
|
|
|
if (typeof mermaid === "undefined") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-04 23:28:44 +03:00
|
|
|
|
let expectedTheme = (mode === ModeToggle.DARK_MODE ? "dark" : "default");
|
|
|
|
|
let config = {theme: expectedTheme};
|
2021-12-12 21:37:10 +03:00
|
|
|
|
|
|
|
|
|
/* Re-render the SVG › <https://github.com/mermaid-js/mermaid/issues/311#issuecomment-332557344> */
|
2022-11-04 23:28:44 +03:00
|
|
|
|
$(".mermaid").each(function () {
|
2021-12-12 21:37:10 +03:00
|
|
|
|
let svgCode = $(this).prev().children().html();
|
|
|
|
|
$(this).removeAttr("data-processed");
|
|
|
|
|
$(this).html(svgCode);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
mermaid.initialize(config);
|
|
|
|
|
mermaid.init(undefined, ".mermaid");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-10 14:49:43 +03:00
|
|
|
|
let initTheme = "default";
|
2020-12-09 21:42:46 +03:00
|
|
|
|
|
2022-01-12 19:23:08 +03:00
|
|
|
|
if ($("html[data-mode=dark]").length > 0
|
|
|
|
|
|| ($("html[data-mode]").length == 0
|
2022-11-04 23:28:44 +03:00
|
|
|
|
&& window.matchMedia("(prefers-color-scheme: dark)").matches)) {
|
2020-12-10 14:49:43 +03:00
|
|
|
|
initTheme = "dark";
|
|
|
|
|
}
|
2020-12-09 21:42:46 +03:00
|
|
|
|
|
2020-12-10 14:49:43 +03:00
|
|
|
|
let mermaidConf = {
|
|
|
|
|
theme: initTheme /* <default|dark|forest|neutral> */
|
|
|
|
|
};
|
2020-12-09 21:42:46 +03:00
|
|
|
|
|
2022-11-04 23:28:44 +03:00
|
|
|
|
/* Create mermaid tag */
|
|
|
|
|
$("pre").has("code.language-mermaid").each(function () {
|
2020-12-10 14:49:43 +03:00
|
|
|
|
let svgCode = $(this).children().html();
|
|
|
|
|
$(this).addClass("unloaded");
|
2022-11-04 23:28:44 +03:00
|
|
|
|
$(this).after(`<pre class=\"mermaid\">${svgCode}</pre>`);
|
2020-12-10 14:49:43 +03:00
|
|
|
|
});
|
2020-12-09 21:42:46 +03:00
|
|
|
|
|
2020-12-10 14:49:43 +03:00
|
|
|
|
mermaid.initialize(mermaidConf);
|
2021-12-12 21:37:10 +03:00
|
|
|
|
|
|
|
|
|
window.addEventListener("message", updateMermaid);
|
2022-11-04 23:28:44 +03:00
|
|
|
|
})();
|
|
|
|
|
|
2020-12-09 21:42:46 +03:00
|
|
|
|
</script>
|