镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Mermaid diagrams are unreadable in dark mode #4814

Closed

Description

@christianlupus

Describe the bug
The background of the mermaid diagrams is transparent and the drawing color is a rather darkish gray. On the dark mode, the diagrams are almost impossible to read/see.

To Reproduce
Steps to reproduce the behavior:

  1. Enable dark mode
  2. Open a text document
  3. Insert a mermaid text block

Example:

sequenceDiagram
 actor A
 actor B
 A -> B : Somesthing
 activate B
 B --> A : Answer
 deactivate B
Loading

Expected behavior
More contrast would be essential. Either make the drawing color of mermaid light or put a white background to it.

Screenshots
If applicable, add screenshots to help explain your problem.
image

Server details:
Current instance on cloud.nextcloud.com

Client details:

  • OS: Archlinux
  • Browser: Firefox
  • Browser version: 110.0
  • Device: Desktop/Laptop

Activity

  1. moved this to 🧭 Planning evaluation (don't pick) in 📝 Productivity teamon Oct 10, 2023
  2. burrima commented on Oct 5, 2024

    @burrima

    Same issue here. Will this be planned anytime in reasonable future?
    Any work-around with custom CSS?
    My wish would be that support for plantuml would be added (with config option to specify own network-internal plantuml server).

    Edit: found a temporary work-around. Add the following in front of each diagram:
    %%{init: {'theme': 'dark' } }%%

  3. juliusknorr commented on Nov 6, 2024

    @juliusknorr
    Member

    I did a few experiments on how we can improve the theme handling of mermaid in text.

    While ideally we could try to inject css variables we have into the theme, i think the easiest quick win is to just set the dark theme if we detect dark mode.

    According to https://mermaid.js.org/config/theming.html#available-themes there is a darkMode theme variable, but I didn't see any noticable impact of setting this, so for now something like this should work:

    diff --git a/src/nodes/CodeBlockView.vue b/src/nodes/CodeBlockView.vue
    index 5e5fd7f70..7fcb58c48 100644
    --- a/src/nodes/CodeBlockView.vue
    +++ b/src/nodes/CodeBlockView.vue
    @@ -204,7 +204,8 @@ export default {
                                    // lazy load mermaid on first real usage
                                    if (this.mermaid === null) {
                                            this.mermaid = (await import('mermaid')).default
    -                                       this.mermaid.initialize({ startOnLoad: false })
    +                                       const isDarkMode = window?.matchMedia('(prefers-color-scheme: dark)').matches && !document.querySelector('body[data-theme-light]')
    +                                       this.mermaid.initialize({ startOnLoad: false, theme: isDarkMode ? 'dark' : 'default' })
                                    }
                                    await this.mermaid.parse(textContent)

    Just trying to figure out the most reliable way to detect Nextcloud dark/light mode before opening a pr.

  4. juliusknorr commented on Nov 6, 2024

    @juliusknorr
    Member
  5. added 2 commits that reference this issue on Jul 26, 2025
    5d726df
    82aec91
  6. moved this from 🧭 Planning evaluation (don't pick) to ☑️ Done in 📝 Productivity teamon Jul 26, 2025
  7. added 2 commits that reference this issue on Jul 26, 2025
    6f35e25
    4cec7ff
  8. added 2 commits that reference this issue on Jul 26, 2025
    ed49f86
    b74e0ea
  9. self-assigned this
    on Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions