From 9b34adf2c9b8ee02f54de876dee5e9cb9b3c9d0d Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 7 Dec 2023 10:49:20 +0530 Subject: [PATCH] refactor: Move maxEdges out of flowchart config. --- packages/mermaid/src/diagrams/flowchart/flowDb.js | 10 ++++++++-- packages/mermaid/src/schemas/config.schema.yaml | 12 ++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.js b/packages/mermaid/src/diagrams/flowchart/flowDb.js index aaaa6cd8cd..899345b6ed 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowDb.js +++ b/packages/mermaid/src/diagrams/flowchart/flowDb.js @@ -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( + `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) { diff --git a/packages/mermaid/src/schemas/config.schema.yaml b/packages/mermaid/src/schemas/config.schema.yaml index 027cf9ff79..f39dbe9189 100644 --- a/packages/mermaid/src/schemas/config.schema.yaml +++ b/packages/mermaid/src/schemas/config.schema.yaml @@ -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 @@ -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