mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 16:29:40 +02:00
Merge pull request #4528 from Yokozuna59/bug/4527_fix-optional-style-issue
fix not rendered style when style is optional
This commit is contained in:
@@ -7,7 +7,6 @@ import { addStylesForDiagram } from '../styles.js';
|
|||||||
import { DiagramDefinition, DiagramDetector } from './types.js';
|
import { DiagramDefinition, DiagramDetector } from './types.js';
|
||||||
import * as _commonDb from '../commonDb.js';
|
import * as _commonDb from '../commonDb.js';
|
||||||
import { parseDirective as _parseDirective } from '../directiveUtils.js';
|
import { parseDirective as _parseDirective } from '../directiveUtils.js';
|
||||||
import isEmpty from 'lodash-es/isEmpty.js';
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Packaging and exposing resources for external diagrams so that they can import
|
Packaging and exposing resources for external diagrams so that they can import
|
||||||
@@ -51,9 +50,7 @@ export const registerDiagram = (
|
|||||||
if (detector) {
|
if (detector) {
|
||||||
addDetector(id, detector);
|
addDetector(id, detector);
|
||||||
}
|
}
|
||||||
if (!isEmpty(diagram.styles)) {
|
|
||||||
addStylesForDiagram(id, diagram.styles);
|
addStylesForDiagram(id, diagram.styles);
|
||||||
}
|
|
||||||
|
|
||||||
if (diagram.injectUtils) {
|
if (diagram.injectUtils) {
|
||||||
diagram.injectUtils(
|
diagram.injectUtils(
|
||||||
|
@@ -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 DiagramStylesProvider = (options?: any) => 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 type { DiagramStylesProvider } from './diagram-api/types.js';
|
||||||
|
|
||||||
const themes: Record<string, any> = {};
|
const themes: Record<string, DiagramStylesProvider> = {};
|
||||||
|
|
||||||
const getStyles = (
|
const getStyles = (
|
||||||
type: string,
|
type: string,
|
||||||
@@ -73,8 +74,10 @@ const getStyles = (
|
|||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addStylesForDiagram = (type: string, diagramTheme: unknown): void => {
|
export const addStylesForDiagram = (type: string, diagramTheme?: DiagramStylesProvider): void => {
|
||||||
|
if (diagramTheme !== undefined) {
|
||||||
themes[type] = diagramTheme;
|
themes[type] = diagramTheme;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default getStyles;
|
export default getStyles;
|
||||||
|
Reference in New Issue
Block a user