xyhp915 / logseq-fenced-code-plus

A Logseq plugin for missing types of fenced code 🚀
MIT License
107 stars 17 forks source link

Theming for mermaid #7

Closed jkrude closed 1 year ago

jkrude commented 2 years ago

First of all thank you for this very useful plugin! As I mostly use dark-mode-themes with logseq it would be extremely useful if the mermaid-theming could be adjusted. Unfortunately, I'm not a web developer, but I guess you could change the theme to the system default here by adding:

host.mermaid.initialize({
  theme: (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) ?
    "dark" :
    "default"
})

Further, I am not sure if the internal logseq setting for dark mode could be directly queried. Otherwise, an option could be added for the plugin where the user can choose between the themes available by default and the %%{init: {'theme': 'theme-name' }}%% line is automatically injected.

Mermaid theming docs.

AhmedThahir commented 2 years ago

Will the above code work? Any updates on this?

DerAnderDo commented 2 years ago

Will the above code work? Any updates on this?

Yes, if you add %%{init: {'theme': 'dark' } }%% at the start of your mermaid code, it will be in dark mode.

Example:

image

Of course this is just a workaround and having mermaid dynamically configured by reading the logseq system theme would be much handier.