Skip to content

Commit

Permalink
Merge pull request #4113 from mermaid-js/3192_invisible_edges
Browse files Browse the repository at this point in the history
Adding the ability to use invisible edges
  • Loading branch information
pbrolin47 authored Feb 20, 2023
2 parents 786023f + eb04d80 commit 22b18a4
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cypress/integration/rendering/flowchart-v2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,17 @@ title: Simple flowchart
---
flowchart TD
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 }
);
Expand Down
14 changes: 14 additions & 0 deletions docs/syntax/flowchart.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,20 @@ flowchart LR
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

It is possible declare many links in the same line as per below:
Expand Down
3 changes: 3 additions & 0 deletions packages/mermaid/src/dagre-wrapper/edges.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph
case 'thick':
strokeClasses = 'edge-thickness-thick';
break;
case 'invisible':
strokeClasses = 'edge-thickness-thick';
break;
default:
strokeClasses = '';
}
Expand Down
4 changes: 4 additions & 0 deletions packages/mermaid/src/diagrams/flowchart/flowDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ const destructEndLink = (_str) => {
stroke = 'thick';
}

if (line[0] === '~') {
stroke = 'invisible';
}

let dots = countChar('.', line);

if (dots) {
Expand Down
5 changes: 5 additions & 0 deletions packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ export const addEdges = function (edges, g, diagObj) {
edgeData.pattern = 'solid';
edgeData.style = 'stroke-width: 3.5px;fill:none;';
break;
case 'invisible':
edgeData.thickness = 'invisible';
edgeData.pattern = 'solid';
edgeData.style = 'stroke-width: 0;fill:none;';
break;
}
if (edge.style !== undefined) {
const styles = getStylesFromArray(edge.style);
Expand Down
1 change: 1 addition & 0 deletions packages/mermaid/src/diagrams/flowchart/parser/flow.jison
Original file line number Diff line number Diff line change
Expand Up @@ -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*\~\~[\~]+\s* return 'LINK';
\s*[xo<]?\-\-\s* return 'START_LINK';
\s*[xo<]?\=\=\s* return 'START_LINK';
\s*[xo<]?\-\.\s* return 'START_LINK';
Expand Down
9 changes: 9 additions & 0 deletions packages/mermaid/src/docs/syntax/flowchart.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ flowchart LR
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

It is possible declare many links in the same line as per below:
Expand Down

0 comments on commit 22b18a4

Please sign in to comment.