From fc28c1da63d68b4989e7f8bc5d81a2f27842e732 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Wed, 25 Oct 2023 11:06:37 +0200 Subject: [PATCH 1/2] Limiting the number of edges that are allowed in the flowchart --- cypress/platform/knsv2.html | 18 ++++++++++++++---- .../mermaid/src/diagrams/flowchart/flowDb.js | 11 ++++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/cypress/platform/knsv2.html b/cypress/platform/knsv2.html index 13094644bd..020ea8b482 100644 --- a/cypress/platform/knsv2.html +++ b/cypress/platform/knsv2.html @@ -58,10 +58,19 @@
-flowchart-elk LR
-   subgraph example
-     node
-   end
+flowchart TB
+    C & D & E & F & G & H & I & J & K & L & M & N & O & P & Q & R & S & T & U & V & W & X & Y & Z & A1 & A2 & A3 & A4 & A5 & A6 & A7 & A8
+      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
+    C & D & E & F & G & H & I & J & K & L & M & N & O & P & Q & R & S & T & U & V & W & X & Y & Z & A1 & A2 & A3 & A4 & A5 & A6 & A7 & A8
+
+    
+
+    flowchart TB
+      A & A & A & A & A & A & A & A --->  C & D & E & F & G & H & I & J & K & L & M & N & O & P & Q & R & S & T & U & V & W & X & Y & Z
+    
+
+    flowchart TB
+      A1 & A2 & A3 & A4 & A5 & A6 & A7 & A8 -->  C & D & E & F & G & H & I & J & K & L & M & N & O & P & Q & R & S & T & U & V & W & X & Y & Z
     
 flowchart
@@ -441,6 +450,7 @@
           messageFontFamily: 'courier',
         },
         fontSize: 16,
+        logLevel: 0,
       });
       function callback() {
         alert('It worked');
diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.js b/packages/mermaid/src/diagrams/flowchart/flowDb.js
index 510c40ce84..9a9394e543 100644
--- a/packages/mermaid/src/diagrams/flowchart/flowDb.js
+++ b/packages/mermaid/src/diagrams/flowchart/flowDb.js
@@ -12,6 +12,7 @@ import {
   setDiagramTitle,
   getDiagramTitle,
 } from '../common/commonDb.js';
+import errorDiagram from '../error/errorDiagram.js';
 
 const MERMAID_DOM_ID_PREFIX = 'flowchart-';
 let vertexCounter = 0;
@@ -156,7 +157,15 @@ export const addSingleLink = function (_start, _end, type) {
     edge.stroke = type.stroke;
     edge.length = type.length;
   }
-  edges.push(edge);
+  if (edge?.length > 10) {
+    edge.length = 10;
+  }
+  if (edges.length < 280) {
+    log.info('abc78 pushing edge...');
+    edges.push(edge);
+  } else {
+    throw new Error('Too many edges');
+  }
 };
 export const addLink = function (_start, _end, type) {
   log.info('addLink (abc78)', _start, _end, type);

From 29942c04dc92a64f8c618d6d55f9b57800341cf5 Mon Sep 17 00:00:00 2001
From: Knut Sveidqvist 
Date: Wed, 25 Oct 2023 11:07:12 +0200
Subject: [PATCH 2/2] Updated mermaid version

---
 package.json                  | 2 +-
 packages/mermaid/package.json | 2 +-
 pnpm-lock.yaml                | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/package.json b/package.json
index ee0c01413c..76ffc7c5a9 100644
--- a/package.json
+++ b/package.json
@@ -88,7 +88,7 @@
     "cypress": "^12.10.0",
     "cypress-image-snapshot": "^4.0.1",
     "esbuild": "^0.19.0",
-    "eslint": "^8.39.0",
+    "eslint": "^8.47.0",
     "eslint-config-prettier": "^8.8.0",
     "eslint-plugin-cypress": "^2.13.2",
     "eslint-plugin-html": "^7.1.0",
diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json
index cf2bacf3a3..7d218d4aa6 100644
--- a/packages/mermaid/package.json
+++ b/packages/mermaid/package.json
@@ -1,6 +1,6 @@
 {
   "name": "mermaid",
-  "version": "10.5.1",
+  "version": "10.6.0",
   "description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
   "type": "module",
   "module": "./dist/mermaid.core.mjs",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2fab1d4a01..a43411342d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -90,7 +90,7 @@ importers:
         specifier: ^0.19.0
         version: 0.19.0
       eslint:
-        specifier: ^8.39.0
+        specifier: ^8.47.0
         version: 8.47.0
       eslint-config-prettier:
         specifier: ^8.8.0