Files
ThothII/frontend/src/viewers/mermaid.ts
T
marcopanandClaude Sonnet 4.6 2a23de6825 feat(frontend): schema-linking viewer (mermaid+table) + markdown view
TDD: SchemaLinkingViewer with mocked renderMermaid, toggle flowchart↔table,
≤45 element cap with Italian notice. MarkdownView renders mermaid fences.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-28 12:43:11 +02:00

13 lines
394 B
TypeScript

let _initialized = false;
export async function renderMermaid(def: string): Promise<string> {
const mermaid = (await import("mermaid")).default;
if (!_initialized) {
mermaid.initialize({ startOnLoad: false, theme: "default" });
_initialized = true;
}
const id = `mermaid-${Math.random().toString(36).slice(2)}`;
const { svg } = await mermaid.render(id, def);
return svg;
}