fix(flowchart-v2): fix arrowMarkerAbsolute=true

The if-check for arrowMarkerAbsolute in the flowchart-v2 code is in
dagre-wrapper. Unfortunately, I can't seem to find a way to find the
local conf (e.g. the one set via `flowRenderer.setConf()`, so instead
I'm using global mermaid config from `src/config`.

Flowchart v1 arrowMarkerAbsolute=true is still broken, but I'm not
really sure how to fix that.
This commit is contained in:
Alois Klink 2022-09-14 02:12:08 +01:00
parent 6e7037bafd
commit 595f7680e9
3 changed files with 9 additions and 4 deletions

View File

@ -95,7 +95,7 @@ describe('Configuration', () => {
});
it('should handle arrowMarkerAbsolute set to true', () => {
renderGraph(
`graph TD
`flowchart TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]

View File

@ -472,7 +472,8 @@ export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph
// });
let url = '';
if (getConfig().state.arrowMarkerAbsolute) {
// // TODO: Can we load this config only from the rendered graph type?
if (getConfig().flowchart.arrowMarkerAbsolute || getConfig().state.arrowMarkerAbsolute) {
url =
window.location.protocol +
'//' +

View File

@ -96,6 +96,7 @@ import { journeyDetector } from '../diagrams/user-journey/journeyDetector';
import journeyDb from '../diagrams/user-journey/journeyDb';
import journeyRenderer from '../diagrams/user-journey/journeyRenderer';
import journeyStyles from '../diagrams/user-journey/styles';
import { getConfig, setConfig } from '../config';
export const addDiagrams = () => {
registerDiagram(
@ -275,11 +276,12 @@ export const addDiagrams = () => {
renderer: flowRendererV2,
styles: flowStyles,
init: (cnf) => {
flowRenderer.setConf(cnf.flowchart);
if (!cnf.flowchart) {
cnf.flowchart = {};
}
// TODO, broken as of 2022-09-14 (13809b50251845475e6dca65cc395761be38fbd2)
cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
flowRenderer.setConf(cnf.flowchart);
flowDb.clear();
flowDb.setGen('gen-1');
},
@ -294,11 +296,13 @@ export const addDiagrams = () => {
renderer: flowRendererV2,
styles: flowStyles,
init: (cnf) => {
flowRendererV2.setConf(cnf.flowchart);
if (!cnf.flowchart) {
cnf.flowchart = {};
}
cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
// flowchart-v2 uses dagre-wrapper, which doesn't have access to flowchart cnf
setConfig({ flowchart: { arrowMarkerAbsolute: cnf.arrowMarkerAbsolute } });
flowRendererV2.setConf(cnf.flowchart);
flowDb.clear();
flowDb.setGen('gen-2');
},