standardize detector function definition with DiagramDetector type

This commit is contained in:
Yokozuna59
2023-06-12 15:19:54 +03:00
parent e688138167
commit 6ced1673b0
4 changed files with 7 additions and 8 deletions

View File

@@ -1,8 +1,8 @@
import type { ExternalDiagramDefinition } from '../../diagram-api/types.js'; import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-api/types.js';
const id = 'c4'; const id = 'c4';
const detector = (txt: string) => { const detector: DiagramDetector = (txt) => {
return /^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(txt); return /^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(txt);
}; };

View File

@@ -1,9 +1,8 @@
import type { MermaidConfig } from '../../../config.type.js';
import type { ExternalDiagramDefinition, DiagramDetector } from '../../../diagram-api/types.js'; import type { ExternalDiagramDefinition, DiagramDetector } from '../../../diagram-api/types.js';
const id = 'flowchart-elk'; const id = 'flowchart-elk';
const detector: DiagramDetector = (txt: string, config?: MermaidConfig): boolean => { const detector: DiagramDetector = (txt, config): boolean => {
if ( if (
// If diagram explicitly states flowchart-elk // If diagram explicitly states flowchart-elk
/^\s*flowchart-elk/.test(txt) || /^\s*flowchart-elk/.test(txt) ||

View File

@@ -1,7 +1,7 @@
import type { ExternalDiagramDefinition } from '../../diagram-api/types.js'; import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-api/types.js';
const id = 'mindmap'; const id = 'mindmap';
const detector = (txt: string) => { const detector: DiagramDetector = (txt) => {
return /^\s*mindmap/.test(txt); return /^\s*mindmap/.test(txt);
}; };

View File

@@ -1,8 +1,8 @@
import type { ExternalDiagramDefinition } from '../../diagram-api/types.js'; import type { DiagramDetector, ExternalDiagramDefinition } from '../../diagram-api/types.js';
const id = 'timeline'; const id = 'timeline';
const detector = (txt: string) => { const detector: DiagramDetector = (txt) => {
return /^\s*timeline/.test(txt); return /^\s*timeline/.test(txt);
}; };