#5237 Updated configuration schema for elk layout

This commit is contained in:
Knut Sveidqvist
2024-07-19 11:53:15 +02:00
parent 5b47950f9f
commit d96dcd2529
4 changed files with 36 additions and 27 deletions

View File

@@ -465,8 +465,8 @@ export const render = async (data4Layout: LayoutData, svg, element, algorithm) =
layoutOptions: { layoutOptions: {
'elk.hierarchyHandling': 'INCLUDE_CHILDREN', 'elk.hierarchyHandling': 'INCLUDE_CHILDREN',
'elk.algorithm': algorithm, 'elk.algorithm': algorithm,
'nodePlacement.strategy': data4Layout.config['elk.nodePlacement.strategy'], 'nodePlacement.strategy': data4Layout.config.elk.nodePlacementStrategy,
'elk.layered.mergeEdges': data4Layout.config['elk.mergeEdges'], 'elk.layered.mergeEdges': data4Layout.config.elk.mergeEdges,
'elk.direction': 'DOWN', 'elk.direction': 'DOWN',
'spacing.baseValue': 30, 'spacing.baseValue': 30,
// 'spacing.nodeNode': 40, // 'spacing.nodeNode': 40,

View File

@@ -88,16 +88,18 @@ export interface MermaidConfig {
* *
*/ */
maxEdges?: number; maxEdges?: number;
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. * 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; mergeEdges?: boolean;
/** /**
* Elk specific option affecting how nodes are placed. * Elk specific option affecting how nodes are placed.
* *
*/ */
'elk.nodePlacement.strategy'?: 'SIMPLE' | 'NETWORK_SIMPLEX' | 'LINEAR_SEGMENTS' | 'BRANDES_KOEPF'; nodePlacementStrategy?: 'SIMPLE' | 'NETWORK_SIMPLEX' | 'LINEAR_SEGMENTS' | 'BRANDES_KOEPF';
};
darkMode?: boolean; darkMode?: boolean;
htmlLabels?: boolean; htmlLabels?: boolean;
/** /**

View File

@@ -20,6 +20,10 @@ const config: RequiredDeep<MermaidConfig> = {
// Set, even though they're `undefined` so that `configKeys` finds these keys // 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? // TODO: Should we replace these with `null` so that they can go in the JSON Schema?
deterministicIDSeed: undefined, deterministicIDSeed: undefined,
elk: {
mergeEdges: false,
nodePlacementStrategy: 'SIMPLE',
},
themeCSS: undefined, themeCSS: undefined,
// add non-JSON default config values // add non-JSON default config values

View File

@@ -100,12 +100,15 @@ properties:
type: integer type: integer
default: 500 default: 500
minimum: 0 minimum: 0
elk.mergeEdges: elk:
type: object
properties:
mergeEdges:
description: | 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. 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 type: boolean
default: false default: false
elk.nodePlacement.strategy: nodePlacementStrategy:
description: | description: |
Elk specific option affecting how nodes are placed. Elk specific option affecting how nodes are placed.
type: string type: string