Merge pull request #4113 from mermaid-js/3192_invisible_edges

Adding the ability to use invisible edges
This commit is contained in:
pbrolin47
2023-02-20 14:40:43 +01:00
committed by GitHub
7 changed files with 47 additions and 0 deletions

View File

@@ -670,6 +670,17 @@ title: Simple flowchart
--- ---
flowchart TD flowchart TD
A --> B A --> B
`,
{ titleTopMargin: 0 }
);
});
it('3192: It should be possieble to render flowcharts with invisisble edges', () => {
imgSnapshotTest(
`---
title: Simple flowchart with invisisble edges
---
flowchart TD
A ~~~ B
`, `,
{ titleTopMargin: 0 } { titleTopMargin: 0 }
); );

View File

@@ -391,6 +391,20 @@ flowchart LR
A == text ==> B A == text ==> B
``` ```
### An invisisble link
This can be a usefull tool in some instances where you want to alter the default positining of a node.
```mermaid-example
flowchart LR
A ~~~ B
```
```mermaid
flowchart LR
A ~~~ B
```
### Chaining of links ### Chaining of links
It is possible declare many links in the same line as per below: It is possible declare many links in the same line as per below:

View File

@@ -453,6 +453,9 @@ export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph
case 'thick': case 'thick':
strokeClasses = 'edge-thickness-thick'; strokeClasses = 'edge-thickness-thick';
break; break;
case 'invisible':
strokeClasses = 'edge-thickness-thick';
break;
default: default:
strokeClasses = ''; strokeClasses = '';
} }

View File

@@ -677,6 +677,10 @@ const destructEndLink = (_str) => {
stroke = 'thick'; stroke = 'thick';
} }
if (line[0] === '~') {
stroke = 'invisible';
}
let dots = countChar('.', line); let dots = countChar('.', line);
if (dots) { if (dots) {

View File

@@ -280,6 +280,11 @@ export const addEdges = function (edges, g, diagObj) {
edgeData.pattern = 'solid'; edgeData.pattern = 'solid';
edgeData.style = 'stroke-width: 3.5px;fill:none;'; edgeData.style = 'stroke-width: 3.5px;fill:none;';
break; break;
case 'invisible':
edgeData.thickness = 'invisible';
edgeData.pattern = 'solid';
edgeData.style = 'stroke-width: 0;fill:none;';
break;
} }
if (edge.style !== undefined) { if (edge.style !== undefined) {
const styles = getStylesFromArray(edge.style); const styles = getStylesFromArray(edge.style);

View File

@@ -121,6 +121,7 @@ that id.
\s*[xo<]?\-\-+[-xo>]\s* return 'LINK'; \s*[xo<]?\-\-+[-xo>]\s* return 'LINK';
\s*[xo<]?\=\=+[=xo>]\s* return 'LINK'; \s*[xo<]?\=\=+[=xo>]\s* return 'LINK';
\s*[xo<]?\-?\.+\-[xo>]?\s* return 'LINK'; \s*[xo<]?\-?\.+\-[xo>]?\s* return 'LINK';
\s*\~\~[\~]+\s* return 'LINK';
\s*[xo<]?\-\-\s* return 'START_LINK'; \s*[xo<]?\-\-\s* return 'START_LINK';
\s*[xo<]?\=\=\s* return 'START_LINK'; \s*[xo<]?\=\=\s* return 'START_LINK';
\s*[xo<]?\-\.\s* return 'START_LINK'; \s*[xo<]?\-\.\s* return 'START_LINK';

View File

@@ -245,6 +245,15 @@ flowchart LR
A == text ==> B A == text ==> B
``` ```
### An invisisble link
This can be a usefull tool in some instances where you want to alter the default positining of a node.
```mermaid-example
flowchart LR
A ~~~ B
```
### Chaining of links ### Chaining of links
It is possible declare many links in the same line as per below: It is possible declare many links in the same line as per below: