diff --git a/packages/mermaid/src/diagram-api/types.ts b/packages/mermaid/src/diagram-api/types.ts index 265af6587..ab82e7e74 100644 --- a/packages/mermaid/src/diagram-api/types.ts +++ b/packages/mermaid/src/diagram-api/types.ts @@ -82,3 +82,5 @@ export type ParseDirectiveDefinition = (statement: string, context: string, type export type HTML = d3.Selection; export type SVG = d3.Selection; + +export type getDiagramStyles = (options?: unknown) => string; diff --git a/packages/mermaid/src/styles.ts b/packages/mermaid/src/styles.ts index 2f1988419..001bd1794 100644 --- a/packages/mermaid/src/styles.ts +++ b/packages/mermaid/src/styles.ts @@ -1,7 +1,8 @@ import type { FlowChartStyleOptions } from './diagrams/flowchart/styles.js'; import { log } from './logger.js'; +import { getDiagramStyles } from './diagram-api/types.js'; -const themes: Record string> = {}; +const themes: Record = {}; const getStyles = ( type: string, @@ -73,12 +74,9 @@ const getStyles = ( `; }; -export const addStylesForDiagram = ( - type: string, - diagramTheme?: (options?: any) => string -): void => { - if (diagramTheme !== undefined) { - themes[type] = diagramTheme; +export const addStylesForDiagram = (type: string, getDiagramStyles?: getDiagramStyles): void => { + if (getDiagramStyles !== undefined) { + themes[type] = getDiagramStyles; } };