All files / src/util mermaidConfig.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                        7x    
import type { MermaidConfig } from "mermaid";
 
/**
 * The one Mermaid configuration fe-core renders with.
 *
 * Diagrams come from model output, and model output can be steered by
 * anything the model read — a web page, a retrieved document. Mermaid's SVG
 * is inserted into the page as HTML, so the diagram source must not be able
 * to put script there. `securityLevel: "strict"` encodes HTML in labels and
 * disables `click` directives entirely. Under `"loose"`, verified in Chromium,
 * `click A href "javascript:…"` produced an SVG link that ran attacker script
 * on this origin when the node was clicked.
 *
 * Rendering is otherwise unchanged: `<br>` line breaks, subgraphs, classDef
 * styling and markdown strings render identically under both levels. Only
 * the (never wired up) node click actions are lost.
 *
 * The hygiene test fails any other `securityLevel` in the source.
 */
export function mermaidConfig(theme: "dark" | "default"): MermaidConfig {
  return { startOnLoad: false, theme, securityLevel: "strict" };
}