From d79d3f13520a6a4c670ec64a0001de60f4ff4f35 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 19 Aug 2024 19:42:31 +0200 Subject: [PATCH] enh: mermaid dark theme --- .../components/chat/Messages/CodeBlock.svelte | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib/components/chat/Messages/CodeBlock.svelte b/src/lib/components/chat/Messages/CodeBlock.svelte index ac5b03a2a..35d967b6b 100644 --- a/src/lib/components/chat/Messages/CodeBlock.svelte +++ b/src/lib/components/chat/Messages/CodeBlock.svelte @@ -241,6 +241,22 @@ __builtins__.input = input`); debounceTimeout = setTimeout(highlightCode, 10); } } + + onMount(async () => { + if (document.documentElement.classList.contains('dark')) { + mermaid.initialize({ + startOnLoad: true, + theme: 'dark', + securityLevel: 'loose' + }); + } else { + mermaid.initialize({ + startOnLoad: true, + theme: 'default', + securityLevel: 'loose' + }); + } + });