Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix not rendered style when style is optional #4528

Merged
2 changes: 2 additions & 0 deletions packages/mermaid/src/diagram-api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ export type ParseDirectiveDefinition = (statement: string, context: string, type
export type HTML = d3.Selection<HTMLIFrameElement, unknown, Element, unknown>;

export type SVG = d3.Selection<SVGSVGElement, unknown, Element, unknown>;

export type getDiagramStyles = (options?: any) => string;
Yokozuna59 marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 5 additions & 7 deletions packages/mermaid/src/styles.ts
Original file line number Diff line number Diff line change
@@ -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, (options?: any) => string> = {};
const themes: Record<string, getDiagramStyles> = {};

const getStyles = (
type: string,
Expand Down Expand Up @@ -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 => {
Yokozuna59 marked this conversation as resolved.
Show resolved Hide resolved
if (getDiagramStyles !== undefined) {
themes[type] = getDiagramStyles;
}
};

Expand Down