@streamdown/mermaid: plugin defaults override Mermaid's own theme and font

Aperta
#714 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
frontend

Direzione di ricerca

The issue points to createMermaidPlugin and its defaultConfig merge, but does not name a file or test. Start by locating that plugin and its configuration tests, then check how caller options reach Mermaid. Done when the plugin leaves Mermaid's theme and font defaults intact unless callers set them, with tests covering those defaults and explicit overrides.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

createMermaidPlugin puts the caller's config on top of its own defaults:

const defaultConfig: MermaidConfig = {
  startOnLoad: false,
  theme: "default",
  securityLevel: "strict",
  fontFamily: "monospace",
  suppressErrorRendering: true,
};
// ...
let currentConfig = { ...defaultConfig, ...options.config };

Because of that, there's no way to get Mermaid's own theme and font back. On Mermaid 12, whose default theme is now redux-color, every diagram still draws with the old default theme in a monospace font.

Passing theme: undefined gets around the theme. Passing fontFamily: undefined doesn't help: Mermaid only writes its --mermaid-font-family rule when fontFamily is set, so the diagram ends up with no font rule at all.

We ended up writing our own small plugin so chat diagrams match the ones we draw elsewhere with Mermaid's defaults.

Could the plugin keep only the settings it needs (startOnLoad: false, and probably securityLevel and suppressErrorRendering) and leave theme and fontFamily to Mermaid unless the caller sets them? That changes how diagrams look for anyone relying on today's defaults, so it might need a major version or an opt-in option.

Seen on @streamdown/mermaid 1.0.3 (also current main) with mermaid 12.3.0. Happy to send a PR.

Lingua principale
TypeScript
Stelle
5.7k
Fork
319
Merge medio
2g 14h
PR unite (30g)
24

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel/streamdown

Tutte le issue di vercel/streamdown

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.