Instead of leaving the config empty, the editor now manages the theme: after every validation and on site light/dark changes, syncManagedTheme sets it to the diagram type's own mermaid default (the config section's theme, e.g. redux-color for flowcharts, else the global default) or, in dark mode, the redux -dark variant (redux-dark-color) or dark.
Only editor-set themes are replaced: a missing theme, the global default, a section default or any of their dark variants (isManagedTheme). A theme the user chose, such as forest, is never touched.
Detector ids that do not match their config section (flowchart-v2, flowchart-elk, classDiagram, stateDiagram, xychart, railroadAbnf/Ebnf/Peg) are aliased in mermaid.ts; ids without a section (wardley, zenuml) use the global default.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Mermaid 12 picks its own theme, look and layout per diagram type, so the editor no longer needs to pin a theme. defaultState.mermaid is now `{}`.
- clearDefaultThemeConfig (migration v1): a persisted config whose only key is "theme": "default" is cleared to {} once; anything else is the user's and is left alone.
- toggleDarkTheme: light mode removes the site-managed theme instead of re-pinning "default"; dark mode still sets "dark". User-chosen themes are untouched.
- The migration registry is resolved lazily: the state module imports util.ts, which imports the migrations, so the registry cannot read state exports while the module graph is still initialising.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>