mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-24 01:39:53 +02:00
Merge branch 'develop' into feature/117_er_diagram
This commit is contained in:
@@ -20,7 +20,7 @@ For more information and help in getting started, please view our [documentation
|
|||||||
|
|
||||||
With version 8.4 class diagrams have got some new features, bug fixes and documentation. Another new feature in 8.4 is the new diagram type, state diagrams.
|
With version 8.4 class diagrams have got some new features, bug fixes and documentation. Another new feature in 8.4 is the new diagram type, state diagrams.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Special note regarding version 8.2
|
## Special note regarding version 8.2
|
||||||
|
|
||||||
|
@@ -20,15 +20,10 @@
|
|||||||
<h1>info below</h1>
|
<h1>info below</h1>
|
||||||
<div style="display: flex;width: 100%; height: 100%">
|
<div style="display: flex;width: 100%; height: 100%">
|
||||||
<div class="mermaid" style="width: 100%; height: 100%">
|
<div class="mermaid" style="width: 100%; height: 100%">
|
||||||
sequenceDiagram
|
stateDiagram
|
||||||
Alice->>John: Hello John, how are you?
|
O --> A : ong line using<br/>should work<br/>should work<br/>should work
|
||||||
loop Healthcheck
|
A --> B : ong line using<br/>should work
|
||||||
John->>John: Fight against hypochondria
|
B --> C : Sing line
|
||||||
end
|
|
||||||
Note right of John: Rational thoughts!
|
|
||||||
John-->>Alice: Great!
|
|
||||||
John->>Bob: How about you?
|
|
||||||
Bob-->>John: Jolly good!
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -9,8 +9,7 @@
|
|||||||
%x string generic struct
|
%x string generic struct
|
||||||
|
|
||||||
%%
|
%%
|
||||||
\%\%[^\n]*\n* /* skip comments */
|
\%\%[^\n]*\n* /* do nothing */
|
||||||
\%\%\*((.|\n)*)\*\%\% /* multiline skip comments */
|
|
||||||
\n+ return 'NEWLINE';
|
\n+ return 'NEWLINE';
|
||||||
\s+ /* skip whitespace */
|
\s+ /* skip whitespace */
|
||||||
"classDiagram" return 'CLASS_DIAGRAM';
|
"classDiagram" return 'CLASS_DIAGRAM';
|
||||||
|
@@ -10,8 +10,7 @@
|
|||||||
%x dir
|
%x dir
|
||||||
%x vertex
|
%x vertex
|
||||||
%%
|
%%
|
||||||
\%\%[^\n]*\n* /* skip comments */
|
\%\%[^\n]*\n* /* do nothing */
|
||||||
\%\%\*((.|\n)*)\*\%\% /* multiline skip comments */
|
|
||||||
["] this.begin("string");
|
["] this.begin("string");
|
||||||
<string>["] this.popState();
|
<string>["] this.popState();
|
||||||
<string>[^"]* return "STR";
|
<string>[^"]* return "STR";
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
\s+ /* skip whitespace */
|
\s+ /* skip whitespace */
|
||||||
\#[^\n]* /* skip comments */
|
\#[^\n]* /* skip comments */
|
||||||
\%%[^\n]* /* skip comments */
|
\%%[^\n]* /* skip comments */
|
||||||
\%\%\*((.|\n)*)\*\%\% /* multiline skip comments */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
---interactivity command---
|
---interactivity command---
|
||||||
|
@@ -18,7 +18,6 @@
|
|||||||
\s+ /* skip all whitespace */
|
\s+ /* skip all whitespace */
|
||||||
\#[^\n]* /* skip comments */
|
\#[^\n]* /* skip comments */
|
||||||
\%%[^\n]* /* skip comments */
|
\%%[^\n]* /* skip comments */
|
||||||
\%\%\*((.|\n)*)\*\%\% /* multiline skip comments */
|
|
||||||
"gitGraph" return 'GG';
|
"gitGraph" return 'GG';
|
||||||
"commit" return 'COMMIT';
|
"commit" return 'COMMIT';
|
||||||
"branch" return 'BRANCH';
|
"branch" return 'BRANCH';
|
||||||
|
@@ -12,8 +12,7 @@
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
\%\%[^\n]* /* skip comments */
|
\%\%[^\n]* /* do nothing */
|
||||||
\%\%\*((.|\n)*)\*\%\% /* multiline skip comments */
|
|
||||||
\s+ /* skip whitespace */
|
\s+ /* skip whitespace */
|
||||||
"pie" return 'pie' ;
|
"pie" return 'pie' ;
|
||||||
[\s\n\r]+ return 'NL' ;
|
[\s\n\r]+ return 'NL' ;
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
<ID,ALIAS,LINE>((?!\n)\s)+ /* skip same-line whitespace */
|
<ID,ALIAS,LINE>((?!\n)\s)+ /* skip same-line whitespace */
|
||||||
<INITIAL,ID,ALIAS,LINE>\#[^\n]* /* skip comments */
|
<INITIAL,ID,ALIAS,LINE>\#[^\n]* /* skip comments */
|
||||||
\%%[^\n]* /* skip comments */
|
\%%[^\n]* /* skip comments */
|
||||||
\%\%\*((.|\n)*)\*\%\% /* multiline skip comments */
|
|
||||||
"participant" { this.begin('ID'); return 'participant'; }
|
"participant" { this.begin('ID'); return 'participant'; }
|
||||||
<ID>[^\->:\n,;]+?(?=((?!\n)\s)+"as"(?!\n)\s|[#\n;]|$) { yytext = yytext.trim(); this.begin('ALIAS'); return 'ACTOR'; }
|
<ID>[^\->:\n,;]+?(?=((?!\n)\s)+"as"(?!\n)\s|[#\n;]|$) { yytext = yytext.trim(); this.begin('ALIAS'); return 'ACTOR'; }
|
||||||
<ALIAS>"as" { this.popState(); this.popState(); this.begin('LINE'); return 'AS'; }
|
<ALIAS>"as" { this.popState(); this.popState(); this.begin('LINE'); return 'AS'; }
|
||||||
|
@@ -37,7 +37,6 @@
|
|||||||
<ID,STATE,struct,LINE>((?!\n)\s)+ /* skip same-line whitespace */
|
<ID,STATE,struct,LINE>((?!\n)\s)+ /* skip same-line whitespace */
|
||||||
<INITIAL,ID,STATE,struct,LINE>\#[^\n]* /* skip comments */
|
<INITIAL,ID,STATE,struct,LINE>\#[^\n]* /* skip comments */
|
||||||
\%%[^\n]* /* skip comments */
|
\%%[^\n]* /* skip comments */
|
||||||
\%\%\*((.|\n)*)\*\%\% /* multiline skip comments */
|
|
||||||
|
|
||||||
"scale"\s+ { this.pushState('SCALE'); /* console.log('Got scale', yytext);*/ return 'scale'; }
|
"scale"\s+ { this.pushState('SCALE'); /* console.log('Got scale', yytext);*/ return 'scale'; }
|
||||||
<SCALE>\d+ return 'WIDTH';
|
<SCALE>\d+ return 'WIDTH';
|
||||||
|
@@ -4,6 +4,7 @@ import stateDb from './stateDb';
|
|||||||
import utils from '../../utils';
|
import utils from '../../utils';
|
||||||
import common from '../common/common';
|
import common from '../common/common';
|
||||||
import { getConfig } from '../../config';
|
import { getConfig } from '../../config';
|
||||||
|
import { logger } from '../../logger';
|
||||||
|
|
||||||
// let conf;
|
// let conf;
|
||||||
|
|
||||||
@@ -456,6 +457,9 @@ export const drawEdge = function(elem, path, relation) {
|
|||||||
|
|
||||||
let titleHeight = 0;
|
let titleHeight = 0;
|
||||||
const titleRows = [];
|
const titleRows = [];
|
||||||
|
let maxWidth = 0;
|
||||||
|
let minX = 0;
|
||||||
|
|
||||||
for (let i = 0; i <= rows.length; i++) {
|
for (let i = 0; i <= rows.length; i++) {
|
||||||
const title = label
|
const title = label
|
||||||
.append('text')
|
.append('text')
|
||||||
@@ -464,27 +468,39 @@ export const drawEdge = function(elem, path, relation) {
|
|||||||
.attr('x', x)
|
.attr('x', x)
|
||||||
.attr('y', y + titleHeight);
|
.attr('y', y + titleHeight);
|
||||||
|
|
||||||
|
const boundstmp = title.node().getBBox();
|
||||||
|
maxWidth = Math.max(maxWidth, boundstmp.width);
|
||||||
|
minX = Math.min(minX, boundstmp.x);
|
||||||
|
|
||||||
|
logger.info(boundstmp.x, x, y + titleHeight);
|
||||||
|
|
||||||
if (titleHeight === 0) {
|
if (titleHeight === 0) {
|
||||||
const titleBox = title.node().getBBox();
|
const titleBox = title.node().getBBox();
|
||||||
titleHeight = titleBox.height;
|
titleHeight = titleBox.height;
|
||||||
|
logger.info('Title height', titleHeight, y);
|
||||||
}
|
}
|
||||||
titleRows.push(title);
|
titleRows.push(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let boxHeight = titleHeight * rows.length;
|
||||||
if (rows.length > 1) {
|
if (rows.length > 1) {
|
||||||
const heightAdj = rows.length * titleHeight * 0.25;
|
const heightAdj = (rows.length - 1) * titleHeight * 0.5;
|
||||||
|
|
||||||
titleRows.forEach((title, i) => title.attr('y', y + i * titleHeight - heightAdj));
|
titleRows.forEach((title, i) => title.attr('y', y + i * titleHeight - heightAdj));
|
||||||
|
boxHeight = titleHeight * rows.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bounds = label.node().getBBox();
|
const bounds = label.node().getBBox();
|
||||||
|
|
||||||
label
|
label
|
||||||
.insert('rect', ':first-child')
|
.insert('rect', ':first-child')
|
||||||
.attr('class', 'box')
|
.attr('class', 'box')
|
||||||
.attr('x', bounds.x - getConfig().state.padding / 2)
|
.attr('x', x - maxWidth / 2 - getConfig().state.padding / 2)
|
||||||
.attr('y', bounds.y - getConfig().state.padding / 2)
|
.attr('y', y - boxHeight / 2 - getConfig().state.padding / 2 - 3.5)
|
||||||
.attr('width', bounds.width + getConfig().state.padding)
|
.attr('width', maxWidth + getConfig().state.padding)
|
||||||
.attr('height', bounds.height + getConfig().state.padding);
|
.attr('height', boxHeight + getConfig().state.padding);
|
||||||
|
|
||||||
|
logger.info(bounds);
|
||||||
|
|
||||||
//label.attr('transform', '0 -' + (bounds.y / 2));
|
//label.attr('transform', '0 -' + (bounds.y / 2));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user