mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-15 18:24:33 +01:00
add getDiagramStyles type and use it in style.ts
This commit is contained in:
@@ -82,3 +82,5 @@ export type ParseDirectiveDefinition = (statement: string, context: string, type
|
|||||||
export type HTML = d3.Selection<HTMLIFrameElement, unknown, Element, unknown>;
|
export type HTML = d3.Selection<HTMLIFrameElement, unknown, Element, unknown>;
|
||||||
|
|
||||||
export type SVG = d3.Selection<SVGSVGElement, unknown, Element, unknown>;
|
export type SVG = d3.Selection<SVGSVGElement, unknown, Element, unknown>;
|
||||||
|
|
||||||
|
export type getDiagramStyles = (options?: unknown) => string;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import type { FlowChartStyleOptions } from './diagrams/flowchart/styles.js';
|
import type { FlowChartStyleOptions } from './diagrams/flowchart/styles.js';
|
||||||
import { log } from './logger.js';
|
import { log } from './logger.js';
|
||||||
|
import { getDiagramStyles } from './diagram-api/types.js';
|
||||||
|
|
||||||
const themes: Record<string, (options?: any) => string> = {};
|
const themes: Record<string, getDiagramStyles> = {};
|
||||||
|
|
||||||
const getStyles = (
|
const getStyles = (
|
||||||
type: string,
|
type: string,
|
||||||
@@ -73,12 +74,9 @@ const getStyles = (
|
|||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addStylesForDiagram = (
|
export const addStylesForDiagram = (type: string, getDiagramStyles?: getDiagramStyles): void => {
|
||||||
type: string,
|
if (getDiagramStyles !== undefined) {
|
||||||
diagramTheme?: (options?: any) => string
|
themes[type] = getDiagramStyles;
|
||||||
): void => {
|
|
||||||
if (diagramTheme !== undefined) {
|
|
||||||
themes[type] = diagramTheme;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user