mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-10-31 02:44:17 +01:00 
			
		
		
		
	Compare commits
	
		
			5 Commits
		
	
	
		
			@mermaid-j
			...
			gh-readonl
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| ![github-merge-queue[bot]](/assets/img/avatar_default.png)  | 51de9de639 | ||
|   | 0dfedce52a | ||
|   | da150e8767 | ||
|   | 1f64452716 | ||
|   | 9986b023d7 | 
| @@ -251,6 +251,7 @@ Communication tools and platforms | |||||||
| - [Jekyll](https://jekyllrb.com/) | - [Jekyll](https://jekyllrb.com/) | ||||||
|   - [jekyll-mermaid](https://rubygems.org/gems/jekyll-mermaid) |   - [jekyll-mermaid](https://rubygems.org/gems/jekyll-mermaid) | ||||||
|   - [jekyll-mermaid-diagrams](https://github.com/fuzhibo/jekyll-mermaid-diagrams) |   - [jekyll-mermaid-diagrams](https://github.com/fuzhibo/jekyll-mermaid-diagrams) | ||||||
|  | - [MarkChart: Preview Mermaid diagrams on macOS](https://markchart.app/) | ||||||
| - [mermaid-isomorphic](https://github.com/remcohaszing/mermaid-isomorphic) | - [mermaid-isomorphic](https://github.com/remcohaszing/mermaid-isomorphic) | ||||||
| - [mermaid-server: Generate diagrams using a HTTP request](https://github.com/TomWright/mermaid-server) | - [mermaid-server: Generate diagrams using a HTTP request](https://github.com/TomWright/mermaid-server) | ||||||
| - [NiceGUI: Let any browser be the frontend of your Python code](https://nicegui.io) ✅ | - [NiceGUI: Let any browser be the frontend of your Python code](https://nicegui.io) ✅ | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ import * as graphlib from 'dagre-d3-es/src/graphlib/index.js'; | |||||||
| import { log } from '../../logger.js'; | import { log } from '../../logger.js'; | ||||||
| import { getConfig } from '../../diagram-api/diagramAPI.js'; | import { getConfig } from '../../diagram-api/diagramAPI.js'; | ||||||
| import { render } from '../../dagre-wrapper/index.js'; | import { render } from '../../dagre-wrapper/index.js'; | ||||||
| import utils from '../../utils.js'; | import utils, { getEdgeId } from '../../utils.js'; | ||||||
| import { interpolateToCurve, getStylesFromArray } from '../../utils.js'; | import { interpolateToCurve, getStylesFromArray } from '../../utils.js'; | ||||||
| import { setupGraphViewbox } from '../../setupGraphViewbox.js'; | import { setupGraphViewbox } from '../../setupGraphViewbox.js'; | ||||||
| import common from '../common/common.js'; | import common from '../common/common.js'; | ||||||
| @@ -231,7 +231,10 @@ export const addRelations = function (relations: ClassRelation[], g: graphlib.Gr | |||||||
|       //Set relationship style and line type |       //Set relationship style and line type | ||||||
|       classes: 'relation', |       classes: 'relation', | ||||||
|       pattern: edge.relation.lineType == 1 ? 'dashed' : 'solid', |       pattern: edge.relation.lineType == 1 ? 'dashed' : 'solid', | ||||||
|       id: `id_${edge.id1}_${edge.id2}_${cnt}`, |       id: getEdgeId(edge.id1, edge.id2, { | ||||||
|  |         prefix: 'id', | ||||||
|  |         counter: cnt, | ||||||
|  |       }), | ||||||
|       // Set link type for rendering |       // Set link type for rendering | ||||||
|       arrowhead: edge.type === 'arrow_open' ? 'none' : 'normal', |       arrowhead: edge.type === 'arrow_open' ? 'none' : 'normal', | ||||||
|       //Set edge extra labels |       //Set edge extra labels | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| import * as graphlib from 'dagre-d3-es/src/graphlib/index.js'; | import * as graphlib from 'dagre-d3-es/src/graphlib/index.js'; | ||||||
| import { select, curveLinear, selectAll } from 'd3'; | import { select, curveLinear, selectAll } from 'd3'; | ||||||
| import { getConfig } from '../../diagram-api/diagramAPI.js'; | import { getConfig } from '../../diagram-api/diagramAPI.js'; | ||||||
| import utils from '../../utils.js'; | import utils, { getEdgeId } from '../../utils.js'; | ||||||
| import { render } from '../../dagre-wrapper/index.js'; | import { render } from '../../dagre-wrapper/index.js'; | ||||||
| import { addHtmlLabel } from 'dagre-d3-es/src/dagre-js/label/add-html-label.js'; | import { addHtmlLabel } from 'dagre-d3-es/src/dagre-js/label/add-html-label.js'; | ||||||
| import { log } from '../../logger.js'; | import { log } from '../../logger.js'; | ||||||
| @@ -210,7 +210,11 @@ export const addEdges = async function (edges, g, diagObj) { | |||||||
|     cnt++; |     cnt++; | ||||||
|  |  | ||||||
|     // Identify Link |     // Identify Link | ||||||
|     const linkIdBase = 'L-' + edge.start + '-' + edge.end; |     const linkIdBase = getEdgeId(edge.start, edge.end, { | ||||||
|  |       counter: cnt, | ||||||
|  |       prefix: 'L', | ||||||
|  |     }); | ||||||
|  |  | ||||||
|     // count the links from+to the same node to give unique id |     // count the links from+to the same node to give unique id | ||||||
|     if (linkIdCnt[linkIdBase] === undefined) { |     if (linkIdCnt[linkIdBase] === undefined) { | ||||||
|       linkIdCnt[linkIdBase] = 0; |       linkIdCnt[linkIdBase] = 0; | ||||||
| @@ -219,7 +223,8 @@ export const addEdges = async function (edges, g, diagObj) { | |||||||
|       linkIdCnt[linkIdBase]++; |       linkIdCnt[linkIdBase]++; | ||||||
|       log.info('abc78 new entry', linkIdBase, linkIdCnt[linkIdBase]); |       log.info('abc78 new entry', linkIdBase, linkIdCnt[linkIdBase]); | ||||||
|     } |     } | ||||||
|     let linkId = linkIdBase + '-' + linkIdCnt[linkIdBase]; |     let linkId = `${linkIdBase}_${linkIdCnt[linkIdBase]}`; | ||||||
|  |  | ||||||
|     log.info('abc78 new link id to be used is', linkIdBase, linkId, linkIdCnt[linkIdBase]); |     log.info('abc78 new link id to be used is', linkIdBase, linkId, linkIdCnt[linkIdBase]); | ||||||
|     const linkNameStart = 'LS-' + edge.start; |     const linkNameStart = 'LS-' + edge.start; | ||||||
|     const linkNameEnd = 'LE-' + edge.end; |     const linkNameEnd = 'LE-' + edge.end; | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ import { applyStyle } from 'dagre-d3-es/src/dagre-js/util.js'; | |||||||
| import { addHtmlLabel } from 'dagre-d3-es/src/dagre-js/label/add-html-label.js'; | import { addHtmlLabel } from 'dagre-d3-es/src/dagre-js/label/add-html-label.js'; | ||||||
| import { log } from '../../logger.js'; | import { log } from '../../logger.js'; | ||||||
| import common, { evaluate, renderKatex } from '../common/common.js'; | import common, { evaluate, renderKatex } from '../common/common.js'; | ||||||
| import { interpolateToCurve, getStylesFromArray } from '../../utils.js'; | import { interpolateToCurve, getStylesFromArray, getEdgeId } from '../../utils.js'; | ||||||
| import { setupGraphViewbox } from '../../setupGraphViewbox.js'; | import { setupGraphViewbox } from '../../setupGraphViewbox.js'; | ||||||
| import flowChartShapes from './flowChartShapes.js'; | import flowChartShapes from './flowChartShapes.js'; | ||||||
| import { replaceIconSubstring } from '../../rendering-util/createText.js'; | import { replaceIconSubstring } from '../../rendering-util/createText.js'; | ||||||
| @@ -175,7 +175,10 @@ export const addEdges = async function (edges, g, diagObj) { | |||||||
|     cnt++; |     cnt++; | ||||||
|  |  | ||||||
|     // Identify Link |     // Identify Link | ||||||
|     const linkId = 'L-' + edge.start + '-' + edge.end; |     const linkId = getEdgeId(edge.start, edge.end, { | ||||||
|  |       counter: cnt, | ||||||
|  |       prefix: 'L', | ||||||
|  |     }); | ||||||
|     const linkNameStart = 'LS-' + edge.start; |     const linkNameStart = 'LS-' + edge.start; | ||||||
|     const linkNameEnd = 'LE-' + edge.end; |     const linkNameEnd = 'LE-' + edge.end; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ import { render } from '../../dagre-wrapper/index.js'; | |||||||
| import { log } from '../../logger.js'; | import { log } from '../../logger.js'; | ||||||
| import { configureSvgSize } from '../../setupGraphViewbox.js'; | import { configureSvgSize } from '../../setupGraphViewbox.js'; | ||||||
| import common from '../common/common.js'; | import common from '../common/common.js'; | ||||||
| import utils from '../../utils.js'; | import utils, { getEdgeId } from '../../utils.js'; | ||||||
|  |  | ||||||
| import { | import { | ||||||
|   DEFAULT_DIAGRAM_DIRECTION, |   DEFAULT_DIAGRAM_DIRECTION, | ||||||
| @@ -252,7 +252,6 @@ const setupNode = (g, parent, parsedItem, diagramStates, diagramDb, altFlag) => | |||||||
|         type: 'group', |         type: 'group', | ||||||
|         padding: 0, //getConfig().flowchart.padding |         padding: 0, //getConfig().flowchart.padding | ||||||
|       }; |       }; | ||||||
|       graphItemCount++; |  | ||||||
|  |  | ||||||
|       const parentNodeId = itemId + PARENT_ID; |       const parentNodeId = itemId + PARENT_ID; | ||||||
|       g.setNode(parentNodeId, groupData); |       g.setNode(parentNodeId, groupData); | ||||||
| @@ -270,17 +269,23 @@ const setupNode = (g, parent, parsedItem, diagramStates, diagramDb, altFlag) => | |||||||
|         from = noteData.id; |         from = noteData.id; | ||||||
|         to = itemId; |         to = itemId; | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       g.setEdge(from, to, { |       g.setEdge(from, to, { | ||||||
|         arrowhead: 'none', |         arrowhead: 'none', | ||||||
|         arrowType: '', |         arrowType: '', | ||||||
|         style: G_EDGE_STYLE, |         style: G_EDGE_STYLE, | ||||||
|         labelStyle: '', |         labelStyle: '', | ||||||
|  |         id: getEdgeId(from, to, { | ||||||
|  |           counter: graphItemCount, | ||||||
|  |         }), | ||||||
|         classes: CSS_EDGE_NOTE_EDGE, |         classes: CSS_EDGE_NOTE_EDGE, | ||||||
|         arrowheadStyle: G_EDGE_ARROWHEADSTYLE, |         arrowheadStyle: G_EDGE_ARROWHEADSTYLE, | ||||||
|         labelpos: G_EDGE_LABELPOS, |         labelpos: G_EDGE_LABELPOS, | ||||||
|         labelType: G_EDGE_LABELTYPE, |         labelType: G_EDGE_LABELTYPE, | ||||||
|         thickness: G_EDGE_THICKNESS, |         thickness: G_EDGE_THICKNESS, | ||||||
|       }); |       }); | ||||||
|  |  | ||||||
|  |       graphItemCount++; | ||||||
|     } else { |     } else { | ||||||
|       g.setNode(itemId, nodeData); |       g.setNode(itemId, nodeData); | ||||||
|     } |     } | ||||||
| @@ -324,7 +329,9 @@ const setupDoc = (g, parentParsedItem, doc, diagramStates, diagramDb, altFlag) = | |||||||
|           setupNode(g, parentParsedItem, item.state1, diagramStates, diagramDb, altFlag); |           setupNode(g, parentParsedItem, item.state1, diagramStates, diagramDb, altFlag); | ||||||
|           setupNode(g, parentParsedItem, item.state2, diagramStates, diagramDb, altFlag); |           setupNode(g, parentParsedItem, item.state2, diagramStates, diagramDb, altFlag); | ||||||
|           const edgeData = { |           const edgeData = { | ||||||
|             id: 'edge' + graphItemCount, |             id: getEdgeId(item.state1.id, item.state2.id, { | ||||||
|  |               counter: graphItemCount, | ||||||
|  |             }), | ||||||
|             arrowhead: 'normal', |             arrowhead: 'normal', | ||||||
|             arrowTypeEnd: 'arrow_barb', |             arrowTypeEnd: 'arrow_barb', | ||||||
|             style: G_EDGE_STYLE, |             style: G_EDGE_STYLE, | ||||||
|   | |||||||
| @@ -929,3 +929,19 @@ export const decodeEntities = function (text: string): string { | |||||||
| export const isString = (value: unknown): value is string => { | export const isString = (value: unknown): value is string => { | ||||||
|   return typeof value === 'string'; |   return typeof value === 'string'; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | export const getEdgeId = ( | ||||||
|  |   from: string, | ||||||
|  |   to: string, | ||||||
|  |   { | ||||||
|  |     counter = 0, | ||||||
|  |     prefix, | ||||||
|  |     suffix, | ||||||
|  |   }: { | ||||||
|  |     counter?: number; | ||||||
|  |     prefix?: string; | ||||||
|  |     suffix?: string; | ||||||
|  |   } | ||||||
|  | ) => { | ||||||
|  |   return `${prefix ? `${prefix}_` : ''}${from}_${to}_${counter}${suffix ? `_${suffix}` : ''}`; | ||||||
|  | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user