mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-10-31 10:54:15 +01:00 
			
		
		
		
	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:
		| @@ -95,7 +95,7 @@ describe('Configuration', () => { | |||||||
|     }); |     }); | ||||||
|     it('should handle arrowMarkerAbsolute set to true', () => { |     it('should handle arrowMarkerAbsolute set to true', () => { | ||||||
|       renderGraph( |       renderGraph( | ||||||
|         `graph TD |         `flowchart TD | ||||||
|         A[Christmas] -->|Get money| B(Go shopping) |         A[Christmas] -->|Get money| B(Go shopping) | ||||||
|         B --> C{Let me think} |         B --> C{Let me think} | ||||||
|         C -->|One| D[Laptop] |         C -->|One| D[Laptop] | ||||||
|   | |||||||
| @@ -472,7 +472,8 @@ export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph | |||||||
|   // }); |   // }); | ||||||
|  |  | ||||||
|   let url = ''; |   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 = |     url = | ||||||
|       window.location.protocol + |       window.location.protocol + | ||||||
|       '//' + |       '//' + | ||||||
|   | |||||||
| @@ -96,6 +96,7 @@ import { journeyDetector } from '../diagrams/user-journey/journeyDetector'; | |||||||
| import journeyDb from '../diagrams/user-journey/journeyDb'; | import journeyDb from '../diagrams/user-journey/journeyDb'; | ||||||
| import journeyRenderer from '../diagrams/user-journey/journeyRenderer'; | import journeyRenderer from '../diagrams/user-journey/journeyRenderer'; | ||||||
| import journeyStyles from '../diagrams/user-journey/styles'; | import journeyStyles from '../diagrams/user-journey/styles'; | ||||||
|  | import { getConfig, setConfig } from '../config'; | ||||||
|  |  | ||||||
| export const addDiagrams = () => { | export const addDiagrams = () => { | ||||||
|   registerDiagram( |   registerDiagram( | ||||||
| @@ -275,11 +276,12 @@ export const addDiagrams = () => { | |||||||
|       renderer: flowRendererV2, |       renderer: flowRendererV2, | ||||||
|       styles: flowStyles, |       styles: flowStyles, | ||||||
|       init: (cnf) => { |       init: (cnf) => { | ||||||
|         flowRenderer.setConf(cnf.flowchart); |  | ||||||
|         if (!cnf.flowchart) { |         if (!cnf.flowchart) { | ||||||
|           cnf.flowchart = {}; |           cnf.flowchart = {}; | ||||||
|         } |         } | ||||||
|  |         // TODO, broken as of 2022-09-14 (13809b50251845475e6dca65cc395761be38fbd2) | ||||||
|         cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; |         cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; | ||||||
|  |         flowRenderer.setConf(cnf.flowchart); | ||||||
|         flowDb.clear(); |         flowDb.clear(); | ||||||
|         flowDb.setGen('gen-1'); |         flowDb.setGen('gen-1'); | ||||||
|       }, |       }, | ||||||
| @@ -294,11 +296,13 @@ export const addDiagrams = () => { | |||||||
|       renderer: flowRendererV2, |       renderer: flowRendererV2, | ||||||
|       styles: flowStyles, |       styles: flowStyles, | ||||||
|       init: (cnf) => { |       init: (cnf) => { | ||||||
|         flowRendererV2.setConf(cnf.flowchart); |  | ||||||
|         if (!cnf.flowchart) { |         if (!cnf.flowchart) { | ||||||
|           cnf.flowchart = {}; |           cnf.flowchart = {}; | ||||||
|         } |         } | ||||||
|         cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; |         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.clear(); | ||||||
|         flowDb.setGen('gen-2'); |         flowDb.setGen('gen-2'); | ||||||
|       }, |       }, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Alois Klink
					Alois Klink