Skip to content

Commit

Permalink
refactor: Move maxEdges out of flowchart config.
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Dec 7, 2023
1 parent 3b7cabe commit 9b34adf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions packages/mermaid/src/diagrams/flowchart/flowDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,17 @@ export const addSingleLink = function (_start, _end, type) {
if (edge?.length > 10) {
edge.length = 10;
}
if (edges.length < (config.flowchart.maxEdges ?? 500)) {
if (edges.length < (config.maxEdges ?? 500)) {
log.info('abc78 pushing edge...');
edges.push(edge);
} else {
throw new Error(`Edge limit exceeded. Increase config.flowchart.maxEdges to allow more edges.`);
throw new Error(

Check warning on line 165 in packages/mermaid/src/diagrams/flowchart/flowDb.js

View check run for this annotation

Codecov / codecov/patch

packages/mermaid/src/diagrams/flowchart/flowDb.js#L165

Added line #L165 was not covered by tests
`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) {
Expand Down
12 changes: 6 additions & 6 deletions packages/mermaid/src/schemas/config.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ properties:
description: The maximum allowed size of the users text diagram
type: number
default: 50000
maxEdges:
description: |
Defines the maximum number of edges that can be drawn in a graph.
type: integer
default: 500
minimum: 0
darkMode:
type: boolean
default: false
Expand Down Expand Up @@ -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.
type: boolean
default: true
maxEdges:
description: |
Defines the maximum number of edges that can be drawn in a graph.
type: integer
default: 500
minimum: 0
nodeSpacing:
description: |
Defines the spacing between nodes on the same level
Expand Down

0 comments on commit 9b34adf

Please sign in to comment.