diff --git a/packages/mermaid-layout-elk/src/render.ts b/packages/mermaid-layout-elk/src/render.ts index 80abea986a..4634877651 100644 --- a/packages/mermaid-layout-elk/src/render.ts +++ b/packages/mermaid-layout-elk/src/render.ts @@ -465,8 +465,8 @@ export const render = async (data4Layout: LayoutData, svg, element, algorithm) = layoutOptions: { 'elk.hierarchyHandling': 'INCLUDE_CHILDREN', 'elk.algorithm': algorithm, - 'nodePlacement.strategy': data4Layout.config['elk.nodePlacement.strategy'], - 'elk.layered.mergeEdges': data4Layout.config['elk.mergeEdges'], + 'nodePlacement.strategy': data4Layout.config.elk.nodePlacementStrategy, + 'elk.layered.mergeEdges': data4Layout.config.elk.mergeEdges, 'elk.direction': 'DOWN', 'spacing.baseValue': 30, // 'spacing.nodeNode': 40, diff --git a/packages/mermaid/src/config.type.ts b/packages/mermaid/src/config.type.ts index a010fb088d..2d25282f38 100644 --- a/packages/mermaid/src/config.type.ts +++ b/packages/mermaid/src/config.type.ts @@ -88,16 +88,18 @@ export interface MermaidConfig { * */ maxEdges?: number; - /** - * Elk specific option that allows edges to share path where it convenient. It can make for pretty diagrams but can also make it harder to read the diagram. - * - */ - 'elk.mergeEdges'?: boolean; - /** - * Elk specific option affecting how nodes are placed. - * - */ - 'elk.nodePlacement.strategy'?: 'SIMPLE' | 'NETWORK_SIMPLEX' | 'LINEAR_SEGMENTS' | 'BRANDES_KOEPF'; + elk?: { + /** + * Elk specific option that allows edges to share path where it convenient. It can make for pretty diagrams but can also make it harder to read the diagram. + * + */ + mergeEdges?: boolean; + /** + * Elk specific option affecting how nodes are placed. + * + */ + nodePlacementStrategy?: 'SIMPLE' | 'NETWORK_SIMPLEX' | 'LINEAR_SEGMENTS' | 'BRANDES_KOEPF'; + }; darkMode?: boolean; htmlLabels?: boolean; /** diff --git a/packages/mermaid/src/defaultConfig.ts b/packages/mermaid/src/defaultConfig.ts index 727842bba1..0fa897d118 100644 --- a/packages/mermaid/src/defaultConfig.ts +++ b/packages/mermaid/src/defaultConfig.ts @@ -20,6 +20,10 @@ const config: RequiredDeep = { // Set, even though they're `undefined` so that `configKeys` finds these keys // TODO: Should we replace these with `null` so that they can go in the JSON Schema? deterministicIDSeed: undefined, + elk: { + mergeEdges: false, + nodePlacementStrategy: 'SIMPLE', + }, themeCSS: undefined, // add non-JSON default config values diff --git a/packages/mermaid/src/schemas/config.schema.yaml b/packages/mermaid/src/schemas/config.schema.yaml index 501e03b849..3f3d8bbcca 100644 --- a/packages/mermaid/src/schemas/config.schema.yaml +++ b/packages/mermaid/src/schemas/config.schema.yaml @@ -100,21 +100,24 @@ properties: type: integer default: 500 minimum: 0 - elk.mergeEdges: - description: | - Elk specific option that allows edges to share path where it convenient. It can make for pretty diagrams but can also make it harder to read the diagram. - type: boolean - default: false - elk.nodePlacement.strategy: - description: | - Elk specific option affecting how nodes are placed. - type: string - enum: - - SIMPLE - - NETWORK_SIMPLEX - - LINEAR_SEGMENTS - - BRANDES_KOEPF - default: SIMPLE + elk: + type: object + properties: + mergeEdges: + description: | + Elk specific option that allows edges to share path where it convenient. It can make for pretty diagrams but can also make it harder to read the diagram. + type: boolean + default: false + nodePlacementStrategy: + description: | + Elk specific option affecting how nodes are placed. + type: string + enum: + - SIMPLE + - NETWORK_SIMPLEX + - LINEAR_SEGMENTS + - BRANDES_KOEPF + default: SIMPLE darkMode: type: boolean default: false