Merge branch 'develop' into other/1143_utilze_browser_console_object_better

This commit is contained in:
Knut Sveidqvist 2019-12-18 18:41:14 +01:00 committed by GitHub
commit 5716d163ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 184 additions and 136 deletions

View File

@ -18,20 +18,23 @@
<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%">
graph LR graph TB
a[gorillan vaggar]|b[apan hoppar]--> c --> d A --> B
subgraph "One Two" A ==> C
a1-->a2-->a3 A .-> D
end A === E
A -.- F
D -- Hello --> a
D-- text including R TD space --xb
</div> </div>
</div> </div>
<script src="./mermaid.js"></script> <script src="./mermaid.js"></script>
<script> <script>
mermaid.initialize({ mermaid.initialize({
// theme: 'dark', theme: 'dark',
// arrowMarkerAbsolute: true, // arrowMarkerAbsolute: true,
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}', // themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
logLevel: 3, logLevel: 0,
flowchart: { curve: 'linear', "htmlLabels": false }, flowchart: { curve: 'linear', "htmlLabels": false },
// gantt: { axisFormat: '%m/%d/%Y' }, // gantt: { axisFormat: '%m/%d/%Y' },
sequence: { actorMargin: 50 }, sequence: { actorMargin: 50 },

View File

@ -509,6 +509,130 @@ export const firstGraph = () => {
return false; return false;
}; };
const destructStartLink = _str => {
const str = _str.trim();
switch (str) {
case '<--':
return { type: 'arrow', stroke: 'normal' };
case 'x--':
return { type: 'arrow_cross', stroke: 'normal' };
case 'o--':
return { type: 'arrow_circle', stroke: 'normal' };
case '<-.':
return { type: 'arrow', stroke: 'dotted' };
case 'x-.':
return { type: 'arrow_cross', stroke: 'dotted' };
case 'o-.':
return { type: 'arrow_circle', stroke: 'dotted' };
case '<==':
return { type: 'arrow', stroke: 'thick' };
case 'x==':
return { type: 'arrow_cross', stroke: 'thick' };
case 'o==':
return { type: 'arrow_circle', stroke: 'thick' };
case '--':
return { type: 'arrow_open', stroke: 'normal' };
case '==':
return { type: 'arrow_open', stroke: 'thick' };
case '-.':
return { type: 'arrow_open', stroke: 'dotted' };
}
};
const destructEndLink = _str => {
const str = _str.trim();
switch (str) {
case '--x':
return { type: 'arrow_cross', stroke: 'normal' };
case '-->':
return { type: 'arrow', stroke: 'normal' };
case '<-->':
return { type: 'double_arrow_point', stroke: 'normal' };
case 'x--x':
return { type: 'double_arrow_cross', stroke: 'normal' };
case 'o--o':
return { type: 'double_arrow_circle', stroke: 'normal' };
case 'o.-o':
return { type: 'double_arrow_circle', stroke: 'dotted' };
case '<==>':
return { type: 'double_arrow_point', stroke: 'thick' };
case 'o==o':
return { type: 'double_arrow_circle', stroke: 'thick' };
case 'x==x':
return { type: 'double_arrow_cross', stroke: 'thick' };
case 'x.-x':
return { type: 'double_arrow_cross', stroke: 'dotted' };
case 'x-.-x':
return { type: 'double_arrow_cross', stroke: 'dotted' };
case '<.->':
return { type: 'double_arrow_point', stroke: 'dotted' };
case '<-.->':
return { type: 'double_arrow_point', stroke: 'dotted' };
case 'o-.-o':
return { type: 'double_arrow_circle', stroke: 'dotted' };
case '--o':
return { type: 'arrow_circle', stroke: 'normal' };
case '---':
return { type: 'arrow_open', stroke: 'normal' };
case '-.-x':
return { type: 'arrow_cross', stroke: 'dotted' };
case '-.->':
return { type: 'arrow', stroke: 'dotted' };
case '-.-o':
return { type: 'arrow_circle', stroke: 'dotted' };
case '-.-':
return { type: 'arrow_open', stroke: 'dotted' };
case '.-x':
return { type: 'arrow_cross', stroke: 'dotted' };
case '.->':
return { type: 'arrow', stroke: 'dotted' };
case '.-o':
return { type: 'arrow_circle', stroke: 'dotted' };
case '.-':
return { type: 'arrow_open', stroke: 'dotted' };
case '==x':
return { type: 'arrow_cross', stroke: 'thick' };
case '==>':
return { type: 'arrow', stroke: 'thick' };
case '==o':
return { type: 'arrow_circle', stroke: 'thick' };
case '===':
return { type: 'arrow_open', stroke: 'thick' };
}
};
const destructLink = (_str, _startStr) => {
const info = destructEndLink(_str);
let startInfo;
if (_startStr) {
startInfo = destructStartLink(_startStr);
console.log(startInfo, info);
if (startInfo.stroke !== info.stroke) {
return { type: 'INVALID', stroke: 'INVALID' };
}
if (startInfo.type === 'arrow_open') {
// -- xyz --> - take arrow type form ending
startInfo.type = info.type;
} else {
// x-- xyz --> - not supported
if (startInfo.type !== info.type) return { type: 'INVALID', stroke: 'INVALID' };
startInfo.type = 'double_' + startInfo.type;
}
if (startInfo.type === 'double_arrow') {
startInfo.type = 'double_arrow_point';
}
return startInfo;
}
return info;
};
export default { export default {
addVertex, addVertex,
addLink, addLink,
@ -531,6 +655,7 @@ export default {
getDepthFirstPos, getDepthFirstPos,
indexNodes, indexNodes,
getSubGraphs, getSubGraphs,
destructLink,
lex: { lex: {
firstGraph firstGraph
} }

View File

@ -87,7 +87,7 @@ describe('[Edges] when parsing', () => {
expect(edges[0].text).toBe(''); expect(edges[0].text).toBe('');
}); });
it('should handle double edged nodes with text on thick arrows', function() { it('should handle double edged nodes with text on thick arrows XYZ1', function() {
const res = flow.parser.parse('graph TD;\nA x== text ==x B;'); const res = flow.parser.parse('graph TD;\nA x== text ==x B;');
const vert = flow.parser.yy.getVertices(); const vert = flow.parser.yy.getVertices();

View File

@ -182,7 +182,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].stroke).toBe('normal'); expect(edges[0].stroke).toBe('normal');
}); });
it('it should handle dotted text on lines', function() { it('it should handle dotted text on lines (TD3)', function() {
const res = flow.parser.parse('graph TD;A-. test text with == .->B;'); const res = flow.parser.parse('graph TD;A-. test text with == .->B;');
const vert = flow.parser.yy.getVertices(); const vert = flow.parser.yy.getVertices();
@ -265,7 +265,7 @@ describe('[Text] when parsing', () => {
expect(edges[0].text).toBe('text including URL space'); expect(edges[0].text).toBe('text including URL space');
}); });
it('should handle space and dir (TD)', function() { it('should handle space and dir (TD2)', function() {
const res = flow.parser.parse('graph TD;A-- text including R TD space --xB;'); const res = flow.parser.parse('graph TD;A-- text including R TD space --xB;');
const vert = flow.parser.yy.getVertices(); const vert = flow.parser.yy.getVertices();

View File

@ -41,46 +41,46 @@
";" return 'SEMI'; ";" return 'SEMI';
"," return 'COMMA'; "," return 'COMMA';
"*" return 'MULT'; "*" return 'MULT';
\s*\-\-[x]\s* return 'ARROW_CROSS'; \s*\-\-[x]\s* return 'LINK';
\s*\-\-\>\s* return 'ARROW_POINT'; \s*\-\-\>\s* return 'LINK';
\s*\<\-\-\>\s* return 'DOUBLE_ARROW_POINT'; \s*\<\-\-\>\s* return 'LINK';
\s*[x]\-\-[x]\s* return 'DOUBLE_ARROW_CROSS'; \s*[x]\-\-[x]\s* return 'LINK';
\s*[o]\-\-[o]\s* return 'DOUBLE_ARROW_CIRCLE'; \s*[o]\-\-[o]\s* return 'LINK';
\s*[o]\.\-[o]\s* return 'DOUBLE_DOTTED_ARROW_CIRCLE'; \s*[o]\.\-[o]\s* return 'LINK';
\s*\<\=\=\>\s* return 'DOUBLE_THICK_ARROW_POINT'; \s*\<\=\=\>\s* return 'LINK';
\s*[o]\=\=[o]\s* return 'DOUBLE_THICK_ARROW_CIRCLE'; \s*[o]\=\=[o]\s* return 'LINK';
\s*[x]\=\=[x]\s* return 'DOUBLE_THICK_ARROW_CROSS'; \s*[x]\=\=[x]\s* return 'LINK';
\s*[x].\-[x]\s* return 'DOUBLE_DOTTED_ARROW_CROSS'; \s*[x].\-[x]\s* return 'LINK';
\s*[x]\-\.\-[x]\s* return 'DOUBLE_DOTTED_ARROW_CROSS'; \s*[x]\-\.\-[x]\s* return 'LINK';
\s*\<\.\-\>\s* return 'DOUBLE_DOTTED_ARROW_POINT'; \s*\<\.\-\>\s* return 'LINK';
\s*\<\-\.\-\>\s* return 'DOUBLE_DOTTED_ARROW_POINT'; \s*\<\-\.\-\>\s* return 'LINK';
\s*[o]\-\.\-[o]\s* return 'DOUBLE_DOTTED_ARROW_CIRCLE'; \s*[o]\-\.\-[o]\s* return 'LINK';
\s*\-\-[o]\s* return 'ARROW_CIRCLE'; \s*\-\-[o]\s* return 'LINK';
\s*\-\-\-\s* return 'ARROW_OPEN'; \s*\-\-\-\s* return 'LINK';
\s*\-\.\-[x]\s* return 'DOTTED_ARROW_CROSS'; \s*\-\.\-[x]\s* return 'LINK';
\s*\-\.\-\>\s* return 'DOTTED_ARROW_POINT'; \s*\-\.\-\>\s* return 'LINK';
\s*\-\.\-[o]\s* return 'DOTTED_ARROW_CIRCLE'; \s*\-\.\-[o]\s* return 'LINK';
\s*\-\.\-\s* return 'DOTTED_ARROW_OPEN'; \s*\-\.\-\s* return 'LINK';
\s*.\-[x]\s* return 'DOTTED_ARROW_CROSS'; \s*.\-[x]\s* return 'LINK';
\s*\.\-\>\s* return 'DOTTED_ARROW_POINT'; \s*\.\-\>\s* return 'LINK';
\s*\.\-[o]\s* return 'DOTTED_ARROW_CIRCLE'; \s*\.\-[o]\s* return 'LINK';
\s*\.\-\s* return 'DOTTED_ARROW_OPEN'; \s*\.\-\s* return 'LINK';
\s*\=\=[x]\s* return 'THICK_ARROW_CROSS'; \s*\=\=[x]\s* return 'LINK';
\s*\=\=\>\s* return 'THICK_ARROW_POINT'; \s*\=\=\>\s* return 'LINK';
\s*\=\=[o]\s* return 'THICK_ARROW_CIRCLE'; \s*\=\=[o]\s* return 'LINK';
\s*\=\=[\=]\s* return 'THICK_ARROW_OPEN'; \s*\=\=[\=]\s* return 'LINK';
\s*\<\-\-\s* return 'START_DOUBLE_ARROW_POINT'; \s*\<\-\-\s* return 'START_LINK';
\s*[x]\-\-\s* return 'START_DOUBLE_ARROW_CROSS'; \s*[x]\-\-\s* return 'START_LINK';
\s*[o]\-\-\s* return 'START_DOUBLE_ARROW_CIRCLE'; \s*[o]\-\-\s* return 'START_LINK';
\s*\<\-\.\s* return 'START_DOUBLE_DOTTED_ARROW_POINT'; \s*\<\-\.\s* return 'START_LINK';
\s*[x]\-\.\s* return 'START_DOUBLE_DOTTED_ARROW_CROSS'; \s*[x]\-\.\s* return 'START_LINK';
\s*[o]\-\.\s* return 'START_DOUBLE_DOTTED_ARROW_CIRCLE'; \s*[o]\-\.\s* return 'START_LINK';
\s*\<\=\=\s* return 'START_DOUBLE_THICK_ARROW_POINT'; \s*\<\=\=\s* return 'START_LINK';
\s*[x]\=\=\s* return 'START_DOUBLE_THICK_ARROW_CROSS'; \s*[x]\=\=\s* return 'START_LINK';
\s*[o]\=\=\s* return 'START_DOUBLE_THICK_ARROW_CIRCLE'; \s*[o]\=\=\s* return 'START_LINK';
\s*\-\-\s* return '--'; \s*\-\-\s* return 'START_LINK';
\s*\-\.\s* return '-.'; \s*\-\.\s* return 'START_LINK';
\s*\=\=\s* return '=='; \s*\=\=\s* return 'START_LINK';
"(-" return '(-'; "(-" return '(-';
"-)" return '-)'; "-)" return '-)';
"([" return 'STADIUMSTART'; "([" return 'STADIUMSTART';
@ -342,92 +342,12 @@ link: linkStatement arrowText
{$1.text = $2;$$ = $1;} {$1.text = $2;$$ = $1;}
| linkStatement | linkStatement
{$$ = $1;} {$$ = $1;}
| '--' text ARROW_POINT | START_LINK text LINK
{$$ = {"type":"arrow","stroke":"normal","text":$2};} {var inf = yy.destructLink($3, $1); $$ = {"type":inf.type,"stroke":inf.stroke,"text":$2};}
| 'START_DOUBLE_ARROW_POINT' text ARROW_POINT
{$$ = {"type":"double_arrow_point","stroke":"normal","text":$2};}
| '--' text ARROW_CIRCLE
{$$ = {"type":"arrow_circle","stroke":"normal","text":$2};}
| 'START_DOUBLE_ARROW_CIRCLE' text ARROW_CIRCLE
{$$ = {"type":"double_arrow_circle","stroke":"normal","text":$2};}
| '--' text ARROW_CROSS
{$$ = {"type":"arrow_cross","stroke":"normal","text":$2};}
| 'START_DOUBLE_ARROW_CROSS' text ARROW_CROSS
{$$ = {"type":"double_arrow_cross","stroke":"normal","text":$2};}
| '--' text ARROW_OPEN
{$$ = {"type":"arrow_open","stroke":"normal","text":$2};}
| '-.' text DOTTED_ARROW_POINT
{$$ = {"type":"arrow","stroke":"dotted","text":$2};}
| 'START_DOUBLE_DOTTED_ARROW_POINT' text DOTTED_ARROW_POINT
{$$ = {"type":"double_arrow_point","stroke":"dotted","text":$2};}
| '-.' text DOTTED_ARROW_CIRCLE
{$$ = {"type":"arrow_circle","stroke":"dotted","text":$2};}
| 'START_DOUBLE_DOTTED_ARROW_CIRCLE' text DOTTED_ARROW_CIRCLE
{$$ = {"type":"double_arrow_circle","stroke":"dotted","text":$2};}
| '-.' text DOTTED_ARROW_CROSS
{$$ = {"type":"arrow_cross","stroke":"dotted","text":$2};}
| 'START_DOUBLE_DOTTED_ARROW_CROSS' text DOTTED_ARROW_CROSS
{$$ = {"type":"double_arrow_cross","stroke":"dotted","text":$2};}
| '-.' text DOTTED_ARROW_OPEN
{$$ = {"type":"arrow_open","stroke":"dotted","text":$2};}
| '==' text THICK_ARROW_POINT
{$$ = {"type":"arrow","stroke":"thick","text":$2};}
| 'START_DOUBLE_THICK_ARROW_POINT' text THICK_ARROW_POINT
{$$ = {"type":"double_arrow_point","stroke":"thick","text":$2};}
| '==' text THICK_ARROW_CIRCLE
{$$ = {"type":"arrow_circle","stroke":"thick","text":$2};}
| 'START_DOUBLE_THICK_ARROW_CIRCLE' text THICK_ARROW_CIRCLE
{$$ = {"type":"double_arrow_circle","stroke":"thick","text":$2};}
| '==' text THICK_ARROW_CROSS
{$$ = {"type":"arrow_cross","stroke":"thick","text":$2};}
| 'START_DOUBLE_THICK_ARROW_CROSS' text THICK_ARROW_CROSS
{$$ = {"type":"double_arrow_cross","stroke":"thick","text":$2};}
| '==' text THICK_ARROW_OPEN
{$$ = {"type":"arrow_open","stroke":"thick","text":$2};}
; ;
linkStatement: ARROW_POINT linkStatement: LINK
{$$ = {"type":"arrow","stroke":"normal"};} {var inf = yy.destructLink($1);$$ = {"type":inf.type,"stroke":inf.stroke};}
| DOUBLE_ARROW_POINT
{$$ = {"type":"double_arrow_point","stroke":"normal"};}
| ARROW_CIRCLE
{$$ = {"type":"arrow_circle","stroke":"normal"};}
| DOUBLE_ARROW_CIRCLE
{$$ = {"type":"double_arrow_circle","stroke":"normal"};}
| ARROW_CROSS
{$$ = {"type":"arrow_cross","stroke":"normal"};}
| DOUBLE_ARROW_CROSS
{$$ = {"type":"double_arrow_cross","stroke":"normal"};}
| ARROW_OPEN
{$$ = {"type":"arrow_open","stroke":"normal"};}
| DOTTED_ARROW_POINT
{$$ = {"type":"arrow","stroke":"dotted"};}
| DOUBLE_DOTTED_ARROW_POINT
{$$ = {"type":"double_arrow_point","stroke":"dotted"};}
| DOTTED_ARROW_CIRCLE
{$$ = {"type":"arrow_circle","stroke":"dotted"};}
| DOUBLE_DOTTED_ARROW_CIRCLE
{$$ = {"type":"double_arrow_circle","stroke":"dotted"};}
| DOTTED_ARROW_CROSS
{$$ = {"type":"arrow_cross","stroke":"dotted"};}
| DOUBLE_DOTTED_ARROW_CROSS
{$$ = {"type":"double_arrow_cross","stroke":"dotted"};}
| DOTTED_ARROW_OPEN
{$$ = {"type":"arrow_open","stroke":"dotted"};}
| THICK_ARROW_POINT
{$$ = {"type":"arrow","stroke":"thick"};}
| DOUBLE_THICK_ARROW_POINT
{$$ = {"type":"double_arrow_point","stroke":"thick"};}
| THICK_ARROW_CIRCLE
{$$ = {"type":"arrow_circle","stroke":"thick"};}
| DOUBLE_THICK_ARROW_CIRCLE
{$$ = {"type":"double_arrow_circle","stroke":"thick"};}
| THICK_ARROW_CROSS
{$$ = {"type":"arrow_cross","stroke":"thick"};}
| DOUBLE_THICK_ARROW_CROSS
{$$ = {"type":"double_arrow_cross","stroke":"thick"};}
| THICK_ARROW_OPEN
{$$ = {"type":"arrow_open","stroke":"thick"};}
; ;
arrowText: arrowText:
@ -515,7 +435,7 @@ styleComponent: ALPHA | COLON | MINUS | NUM | UNIT | SPACE | HEX | BRKT | DOT |
/* Token lists */ /* Token lists */
textToken : textNoTagsToken | TAGSTART | TAGEND | '==' | '--' | PCT | DEFAULT; textToken : textNoTagsToken | TAGSTART | TAGEND | START_LINK | PCT | DEFAULT;
textNoTagsToken: alphaNumToken | SPACE | MINUS | keywords ; textNoTagsToken: alphaNumToken | SPACE | MINUS | keywords ;

View File

@ -116,7 +116,6 @@ const init = function() {
}; };
const initialize = function(config) { const initialize = function(config) {
logger.debug('Initializing mermaid ');
if (typeof config.mermaid !== 'undefined') { if (typeof config.mermaid !== 'undefined') {
if (typeof config.mermaid.startOnLoad !== 'undefined') { if (typeof config.mermaid.startOnLoad !== 'undefined') {
mermaid.startOnLoad = config.mermaid.startOnLoad; mermaid.startOnLoad = config.mermaid.startOnLoad;
@ -126,6 +125,7 @@ const initialize = function(config) {
} }
} }
mermaidAPI.initialize(config); mermaidAPI.initialize(config);
logger.debug('Initializing mermaid ');
}; };
/** /**