DeepSHPlugins
dsh-mermaid-render 项目预览
GITHUB / COMMUNITY PROJECT

dsh-mermaid-render

工具与集成TypeScript

Web UI 对话 mermaid 渲染插件:将消息中的 mermaid 代码块渲染为可交互图表卡片(缩放 / 适应宽度 / 全屏查看 / 预览代码切换),复用官方组件原语,渲染失败时保留原代码块并内联展示错误。

1 Starsgenius-alray 更新时间 2026-08-16
访问 GitHub 仓库
dsh-mermaid-render 项目预览

项目介绍

中文

Web UI 对话 mermaid 渲染插件:将消息中的 mermaid 代码块渲染为可交互图表卡片(缩放 / 适应宽度 / 全屏查看 / 预览代码切换),复用官方组件原语,渲染失败时保留原代码块并内联展示错误。

English

Mermaid diagram renderer for the Web UI conversation: renders mermaid code blocks into interactive cards (zoom, fit-width, fullscreen viewer, preview/code toggle) with official UI primitives, and keeps the original code block with an inline error banner when rendering fails.

项目信息与收录信号

快照 2026-09-11
作者 / 组织
genius-alray
仓库
genius-alray/dsh-mermaid-render
GitHub Stars
1
Forks
0
开发语言
TypeScript
许可证
未记录
最近推送
2026-08-16
Manifest
数据中检测到声明

公开仓库不自动等于可商用;许可证与当前兼容性以原项目文档为准。Manifest 和数据评分不构成安装安全认证。

数据评分

51/ 100
维护活跃
82
文档与实用信息
100
生态关注度
9
安装便捷信号
75
项目声明信号
80

README 含完整安装与使用说明;关注度尚低(1)。

评分来自已有数据快照的五维模型,仅作浏览参考,不是实际使用评测或安全检测结论。

安装与使用

所有项目资料与许可均以对应 GitHub 仓库为准。

dsh plugin --profile web add github:genius-alray/dsh-mermaid-render

复制命令不会自动执行。请先阅读仓库文档,确认环境要求与许可证。

项目截图

仓库 README

GitHub 原文

已保存的仓库文档快照;文档抓取时间未记录,可能与上方目录介绍处于不同版本。安装前请核对当前仓库说明。

dsh-mermaid-render

Interactive Mermaid diagram rendering for agent messages in the DSH Web UI: mermaid code blocks in the conversation are rendered into interactive diagram cards — zoom, fit-width, fullscreen viewer, and a preview/code toggle — built entirely on official UI primitives and DSW design tokens. When rendering fails, the original code block is preserved and an inline error banner is shown right below it.

Features

  • Auto-render mermaid code blocks — fences with mermaid / mmd info strings in conversation messages become diagram cards automatically (both assistant and user messages).
  • Zoom / fit-width — viewport-only zoom: the card shell keeps its size, only the diagram inside scales and scrolls. Ctrl/⌘+wheel zooms, the fit button resets to width fit.
  • Fullscreen viewer — a fixed overlay (product-style mask layer, portal to body): zoom, fit, and close via Esc / mask click / button.
  • Preview / code toggle — a segmented selector in the card's top-right switches between the rendered diagram and the original mermaid source.
  • Graceful failure — on a render or loader error the original code block stays visible and a compact inline error banner appears under it; no stray elements are left in the page.
  • Theme-aware — diagrams re-render with the mermaid dark/default theme when the app theme changes.
  • Bilingual UI — zh / en labels follow the app locale.
  • Native look — primitives Pill / Tooltip components, composer-style icon buttons, lucide-style SVG icons, --dsw-* tokens only.

Install

Installed via the official dsh plugin command; it links the package into the profile and automatically appends the dsh.bundle package to dsh.profile.bundles (no manual profile edits).

dsh plugin --profile web add genius-alray/dsh-mermaid-render

Then restart dsh web — the bundle layer is composed at boot.

Git-source installs may hit pnpm's build-script approval on first run; follow the printed hint to add the key to the profile's pnpm-workspace.yaml allowBuilds and re-run. The repo commits prebuilt lib/, so no local build is required.

Usage

Send a message containing a mermaid code block:

```mermaid
flowchart TD
    A[Start] --> B{Has a mermaid block?}
    B -- yes --> C[Load mermaid renderer]
    B -- no --> D[Keep plain code block]
    C --> E[Render interactive diagram]
    E --> F[Toolbar: zoom / fit / fullscreen]
```

The block renders into a card with a bottom-right toolbar (zoom in / zoom out / fit width / fullscreen) and a top-right Preview / Code selector. On a syntax error the card is not rendered: the original code block remains and an inline "Mermaid render failed" banner with the parser message appears below it.

Technical notes

  • Bundle plugin (official form): package.json declares dsh.bundle.patch: ./cordis.patch.yml; the patch mounts the package itself. Pure client (dsh.client.platform: web); lib/client.js is served at /plugins/dsh-mermaid-render/client.js.
  • mermaid is not bundled — the ~3.3 MB library is loaded lazily at first use via a runtime dynamic import() of the pinned [email protected] +esm build from jsDelivr, so the plugin bundle stays ~34 kB and the page boot cost is zero.
  • Rendering pipeline — a MutationObserver watches the conversation scrollport for .md-code-block elements whose fence infostring is mermaid/mmd; each block is rendered into a private hidden container (mermaid's error path leaves a huge "Syntax error" SVG in the DOM otherwise — the private container keeps the page clean), then the resulting SVG is mounted into a React root as an interactive card.
  • Text fidelity — the SVG is scaled through its own width/height (native vector re-render) rather than CSS transforms, and the card isolates inherited typography (font: 13px/1.5 + CJK font stack) so Chinese node labels never overflow or clip inside foreignObject labels.
  • Stable layout — the stage height is fixed at fit-time and scrollbar-gutter: stable reserves the scrollbar slot, so clientWidth cannot oscillate and the page never jitters.
  • UI primitives — Pill (preview/code toggle), Tooltip, composer-style icon buttons, and hand-drawn lucide-style icons; only --dsw-* tokens, no hard-coded colors.

License

MIT

使用前核对

安装步骤、兼容版本与授权范围以原项目当前文档为准。Stars 和评分是快照中的导航信号。

安装与排错 · 项目问题反馈

同类项目