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>
13 lines
394 B
TypeScript
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;
|
|
}
|