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

オープン
#714 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
56/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript
領域
frontend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
5.7k
フォーク
319
平均マージ
2日 14時間
マージ済み PR(30日)
24

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel/streamdown のほかの issue

vercel/streamdown の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。