refactor: Move maxEdges out of flowchart config.

This commit is contained in:
Sidharth Vinod
2023-12-07 10:49:20 +05:30
parent 3b7cabee4b
commit 9b34adf2c9
2 changed files with 14 additions and 8 deletions

View File

@@ -158,11 +158,17 @@ export const addSingleLink = function (_start, _end, type) {
if (edge?.length > 10) { if (edge?.length > 10) {
edge.length = 10; edge.length = 10;
} }
if (edges.length < (config.flowchart.maxEdges ?? 500)) { if (edges.length < (config.maxEdges ?? 500)) {
log.info('abc78 pushing edge...'); log.info('abc78 pushing edge...');
edges.push(edge); edges.push(edge);
} else { } else {
throw new Error(`Edge limit exceeded. Increase config.flowchart.maxEdges to allow more edges.`); throw new Error(
`Edge limit exceeded. ${edges.length} edges found, but the limit is ${config.maxEdges}.
Initialize mermaid with maxEdges set to a higher number to allow more edges.
You cannot set this config via configuration inside the diagram as it is a secure config.
You have to call mermaid.initialize.`
);
} }
}; };
export const addLink = function (_start, _end, type) { export const addLink = function (_start, _end, type) {

View File

@@ -74,6 +74,12 @@ properties:
description: The maximum allowed size of the users text diagram description: The maximum allowed size of the users text diagram
type: number type: number
default: 50000 default: 50000
maxEdges:
description: |
Defines the maximum number of edges that can be drawn in a graph.
type: integer
default: 500
minimum: 0
darkMode: darkMode:
type: boolean type: boolean
default: false default: false
@@ -1900,12 +1906,6 @@ $defs: # JSON Schema definition (maybe we should move these to a separate file)
Flag for setting whether or not a html tag should be used for rendering labels on the edges. Flag for setting whether or not a html tag should be used for rendering labels on the edges.
type: boolean type: boolean
default: true default: true
maxEdges:
description: |
Defines the maximum number of edges that can be drawn in a graph.
type: integer
default: 500
minimum: 0
nodeSpacing: nodeSpacing:
description: | description: |
Defines the spacing between nodes on the same level Defines the spacing between nodes on the same level