mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Fix subgraph issue
This commit is contained in:
parent
015b976c28
commit
52d0605066
6
dist/index.html
vendored
6
dist/index.html
vendored
@ -7,6 +7,12 @@
|
||||
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=">
|
||||
</head>
|
||||
<body>
|
||||
<div class="mermaid">
|
||||
graph TB
|
||||
subgraph One
|
||||
a1-->a2
|
||||
end
|
||||
</div>
|
||||
<div class="mermaid">
|
||||
graph LR
|
||||
456ac9b0d15a8b7f1e71073221059886[1051 AAA fa:fa-check]
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mermaid",
|
||||
"version": "8.0.0-beta.5",
|
||||
"version": "8.0.0-beta.6",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
||||
"main": "dist/mermaid.core.js",
|
||||
"keywords": [
|
||||
@ -38,7 +38,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"d3": "^4.13.0",
|
||||
"dagre-d3-renderer": "^0.5.1",
|
||||
"dagre-d3-renderer": "^0.5.3",
|
||||
"dagre-layout": "^0.8.6",
|
||||
"graphlibrary": "^2.2.0",
|
||||
"he": "^1.1.1",
|
||||
|
@ -318,7 +318,7 @@ export const addSubGraph = function (list, title) {
|
||||
|
||||
return a.filter(function (item) {
|
||||
const type = typeof item
|
||||
if (item === ' ') {
|
||||
if (item.trim() === '') {
|
||||
return false
|
||||
}
|
||||
if (type in prims) { return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true) } else { return objs.indexOf(item) >= 0 ? false : objs.push(item) }
|
||||
@ -329,7 +329,7 @@ export const addSubGraph = function (list, title) {
|
||||
|
||||
nodeList = uniq(nodeList.concat.apply(nodeList, list))
|
||||
|
||||
const subGraph = { id: 'subGraph' + subCount, nodes: nodeList, title: title }
|
||||
const subGraph = { id: 'subGraph' + subCount, nodes: nodeList, title: title.trim() }
|
||||
subGraphs.push(subGraph)
|
||||
subCount = subCount + 1
|
||||
return subGraph.id
|
||||
|
@ -225,7 +225,7 @@ statement
|
||||
{$$=[];}
|
||||
| clickStatement separator
|
||||
{$$=[];}
|
||||
| subgraph text separator document end
|
||||
| subgraph text separator document end
|
||||
{$$=yy.addSubGraph($4,$2);}
|
||||
| subgraph separator document end
|
||||
{$$=yy.addSubGraph($3,undefined);}
|
||||
|
@ -22,6 +22,17 @@ describe('when parsing ', function () {
|
||||
expect(edges[0].text).toBe('')
|
||||
})
|
||||
|
||||
it('should handle subgraph with tab indentation', function () {
|
||||
const res = flow.parser.parse('graph TB\nsubgraph One\n\ta1-->a2\nend')
|
||||
const subgraphs = flow.parser.yy.getSubGraphs()
|
||||
expect(subgraphs.length).toBe(1)
|
||||
const subgraph = subgraphs[0]
|
||||
expect(subgraph.nodes.length).toBe(2)
|
||||
expect(subgraph.nodes[0]).toBe('a1')
|
||||
expect(subgraph.nodes[1]).toBe('a2')
|
||||
expect(subgraph.title).toBe('One')
|
||||
})
|
||||
|
||||
it('should handle angle bracket ' > ' as direction LR', function () {
|
||||
const res = flow.parser.parse('graph >;A-->B;')
|
||||
|
||||
|
@ -2209,9 +2209,9 @@ d3@^4.13.0:
|
||||
d3-voronoi "1.1.2"
|
||||
d3-zoom "1.7.1"
|
||||
|
||||
dagre-d3-renderer@^0.5.1:
|
||||
version "0.5.1"
|
||||
resolved "https://registry.yarnpkg.com/dagre-d3-renderer/-/dagre-d3-renderer-0.5.1.tgz#a0996ed436f13ae9fdb8ac526c3a921e03fa8462"
|
||||
dagre-d3-renderer@^0.5.3:
|
||||
version "0.5.3"
|
||||
resolved "https://registry.yarnpkg.com/dagre-d3-renderer/-/dagre-d3-renderer-0.5.3.tgz#fef1a6c254a2c5945fbeb5257370ec32fe98d980"
|
||||
dependencies:
|
||||
dagre-layout "^0.8.6"
|
||||
lodash "^4.17.5"
|
||||
|
Loading…
x
Reference in New Issue
Block a user