alexwkleung / Iris

✨ A comfortable note-taking app powered by Markdown
https://irisnotes.vercel.app/
MIT License
15 stars 1 forks source link

Dynamic mermaid theme #96

Closed alexwkleung closed 6 months ago

alexwkleung commented 8 months ago

From limited testing, you can force mermaid to reinitialize via the following:

import mermaid from 'mermaid'

//reset current mermaid config
mermaid.mermaidAPI.reset();

//initialize mermaid again with new config
mermaid.initialize({
    //config...
});

This should be sufficient for changing the mermaid theme from light to dark and vice versa. Performance wise I don't know of a better way to reinitialize mermaid (old API is exported but it's commented out in source code from what I remember).

alexwkleung commented 8 months ago

Hmm, I don't think this works how I imagined it. Will need to further investigate once I work on it later on.

alexwkleung commented 8 months ago

Looking at the type definitions and the documentation briefly, it doesn't seem like mermaid exposes a "destroy initializer" function so I probably have to create a workaround I guess.