Add support for changing the length of edges #1613
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📑 Summary
There is currently no way of influencing the length of (i.e. the number of ranks spanned by) a particular link in a flowchart. A workaround that uses invisible nodes has been proposed in #637. This PR provides an extension of the edge syntax that enables users to request a minimum length for any edge. The length of an edge can be extended by adding extra characters in its definition, as follows:
---
----
-----
-->
--->
---->
===
====
=====
==>
===>
====>
-.-
-..-
-...-
-.->
-..->
-...->
Note that this is change backwards compatible, because the syntax for length-1 edges coincides with the existing syntax which already generated length-1 edges. This feature leverages the
minlen
option exposed by Dagre which was not previously available when using Mermaid.Resolves #637, resolves #1495.
📏 Design Decisions
The Jison grammar for edges was refactored to avoid handling each combination of edge and arrow types separately. This makes the implementation of the new feature simpler and facilitates the addition of new edge and arrow types. The
destructLink
anddestructStartLink
parsing functions were modified accordingly.A
length
attribute, containing the length of each parsed edge, is added their internal representation. This attribute’s value is passed down to Dagre in the renderer via theminlen
option.📋 Tasks
Make sure you
develop
branch