UNPKG

1.45 kBTypeScriptView Raw
1import { MermaidConfig } from '../config.type.js';
2export interface InjectUtils {
3 _log: any;
4 _setLogLevel: any;
5 _getConfig: any;
6 _sanitizeText: any;
7 _setupGraphViewbox: any;
8 _commonDb: any;
9 _parseDirective: any;
10}
11/**
12 * Generic Diagram DB that may apply to any diagram type.
13 */
14export interface DiagramDb {
15 clear?: () => void;
16 setDiagramTitle?: (title: string) => void;
17 setDisplayMode?: (title: string) => void;
18 getAccTitle?: () => string;
19 getAccDescription?: () => string;
20 bindFunctions?: (element: Element) => void;
21}
22export interface DiagramDefinition {
23 db: DiagramDb;
24 renderer: any;
25 parser: any;
26 styles: any;
27 init?: (config: MermaidConfig) => void;
28 injectUtils?: (_log: InjectUtils['_log'], _setLogLevel: InjectUtils['_setLogLevel'], _getConfig: InjectUtils['_getConfig'], _sanitizeText: InjectUtils['_sanitizeText'], _setupGraphViewbox: InjectUtils['_setupGraphViewbox'], _commonDb: InjectUtils['_commonDb'], _parseDirective: InjectUtils['_parseDirective']) => void;
29}
30export interface DetectorRecord {
31 detector: DiagramDetector;
32 loader?: DiagramLoader;
33}
34export interface ExternalDiagramDefinition {
35 id: string;
36 detector: DiagramDetector;
37 loader: DiagramLoader;
38}
39export type DiagramDetector = (text: string, config?: MermaidConfig) => boolean;
40export type DiagramLoader = () => Promise<{
41 id: string;
42 diagram: DiagramDefinition;
43}>;