8 / 25

InteractionsURL copied

Scripted Interaction & ResilienceURL copied

Theme-Aware Re-renderingURL copied

  • MutationObserver watches <html> class changes for dark mode toggle
  • reinitializeMermaid() function:
    • Detects theme via getCurrentTheme() (checks for .dark class)
    • Preserves wrapper height before clearing to prevent layout shifts
    • Deletes old state and re-creates fresh diagram
    • Decodes HTML entities from data-mermaid-code attribute
    • Re-runs mermaid.run() and initMermaidInteraction() after 100ms delay
    • Skips reinit on initial load (uses isInitialLoad flag)