mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 15:59:51 +02:00
Arguments handling for flow chart functions
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
%x string
|
||||
%x dir
|
||||
%x vertex
|
||||
%x click
|
||||
%x href
|
||||
%x callbackname
|
||||
%x callbackargs
|
||||
%x open_directive
|
||||
%x type_directive
|
||||
%x arg_directive
|
||||
@@ -31,7 +35,42 @@
|
||||
"interpolate" return 'INTERPOLATE';
|
||||
"classDef" return 'CLASSDEF';
|
||||
"class" return 'CLASS';
|
||||
"click" return 'CLICK';
|
||||
|
||||
/*
|
||||
---interactivity command---
|
||||
'href' adds a link to the specified task. 'href' can only be specified when the
|
||||
line was introduced with 'click'.
|
||||
'href "<link>"' attaches the specified link to the node that was specified by 'click'.
|
||||
*/
|
||||
"href"[\s]+["] this.begin("href");
|
||||
<href>["] this.popState();
|
||||
<href>[^"]* return 'HREF';
|
||||
|
||||
/*
|
||||
---interactivity command---
|
||||
'call' adds a callback to the specified task. 'call' can only be specified when
|
||||
the line was introduced with 'click'.
|
||||
'call <callbackname>(<args>)' attaches the function 'callbackname' with the specified
|
||||
arguments to the task that was specified by 'click'.
|
||||
Function arguments are optional: 'call <callbackname>()' simply executes 'callbackname' without any arguments.
|
||||
*/
|
||||
"call"[\s]+ this.begin("callbackname");
|
||||
<callbackname>\([\s]*\) this.popState();
|
||||
<callbackname>\( this.popState(); this.begin("callbackargs");
|
||||
<callbackname>[^(]* return 'CALLBACKNAME';
|
||||
<callbackargs>\) this.popState();
|
||||
<callbackargs>[^)]* return 'CALLBACKARGS';
|
||||
|
||||
/*
|
||||
'click' is the keyword to introduce a line that contains interactivity commands.
|
||||
'click' must be followed by an existing node-id. All commands are attached to
|
||||
that id.
|
||||
'click <id>' can be followed by href or call commands in any desired order
|
||||
*/
|
||||
"click"[\s]+ this.begin("click");
|
||||
<click>[\s\n] this.popState();
|
||||
<click>[^\s\n]* return 'CLICK';
|
||||
|
||||
"graph" {if(yy.lex.firstGraph()){this.begin("dir");} return 'GRAPH';}
|
||||
"flowchart" {if(yy.lex.firstGraph()){this.begin("dir");} return 'GRAPH';}
|
||||
"subgraph" return 'subgraph';
|
||||
@@ -411,12 +450,26 @@ classStatement:CLASS SPACE alphaNum SPACE alphaNum
|
||||
;
|
||||
|
||||
clickStatement
|
||||
: CLICK SPACE alphaNum SPACE alphaNum {$$ = $1;yy.setClickEvent($3, $5, undefined);}
|
||||
| CLICK SPACE alphaNum SPACE alphaNum SPACE STR {$$ = $1;yy.setClickEvent($3, $5, $7) ;}
|
||||
| CLICK SPACE alphaNum SPACE STR {$$ = $1;yy.setLink($3, $5, undefined, undefined);}
|
||||
| CLICK SPACE alphaNum SPACE STR SPACE STR {$$ = $1;yy.setLink($3, $5, $7, undefined );}
|
||||
| CLICK SPACE alphaNum SPACE STR SPACE LINK_TARGET {$$ = $1;yy.setLink($3, $5, undefined, $7 );}
|
||||
| CLICK SPACE alphaNum SPACE STR SPACE STR SPACE LINK_TARGET {$$ = $1;yy.setLink($3, $5, $7, $9 );}
|
||||
: CLICK CALLBACKNAME {$$ = $1;yy.setClickEvent($1, $2);
|
||||
| CLICK CALLBACKNAME CALLBACKARGS {$$ = $1;yy.setClickEvent($1, $2, $3);}
|
||||
| CLICK CALLBACKNAME CALLBACKARGS HREF {$$ = $1;yy.setClickEvent($1, $2, $3);yy.setLink($1,$4);}
|
||||
| CLICK CALLBACKNAME CALLBACKARGS SPACE STR {$$ = $1;yy.setClickEvent($1, $2, $3);yy.setTooltip($1, $4)}
|
||||
| CLICK CALLBACKNAME CALLBACKARGS HREF SPACE STR {$$ = $1;yy.setClickEvent($1, $2, $3);yy.setLink($1,$4);yy.setTooltip($1, $6)}
|
||||
| CLICK CALLBACKNAME CALLBACKARGS HREF SPACE LINK_TARGET {$$ = $1;yy.setClickEvent($1, $2, $3);yy.setLink($1,$4, $6)}
|
||||
| CLICK CALLBACKNAME CALLBACKARGS HREF SPACE STR SPACE LINK_TARGET {$$ = $1;yy.setClickEvent($1, $2, $3);yy.setLink($1,$4, $8);yy.setTooltip($1, $6)}
|
||||
|
||||
| CLICK CALLBACKNAME HREF {$$ = $1;yy.setClickEvent($1, $2);yy.setLink($1,$3);}
|
||||
| CLICK CALLBACKNAME SPACE STR {$$ = $1;yy.setClickEvent($1, $2);yy.setTooltip($1, $4)}
|
||||
| CLICK CALLBACKNAME HREF SPACE STR {$$ = $1;yy.setClickEvent($1, $2);yy.setLink($1,$3);yy.setTooltip($1, $5)}
|
||||
| CLICK CALLBACKNAME HREF SPACE LINK_TARGET {$$ = $1;yy.setClickEvent($1, $2, $3);yy.setLink($1,$4, $5)}
|
||||
| CLICK CALLBACKNAME HREF SPACE STR SPACE LINK_TARGET {$$ = $1;yy.setClickEvent($1, $2, $3);yy.setLink($1,$4, $7);yy.setTooltip($1, $5)}
|
||||
|
||||
| CLICK HREF {$$ = $1;yy.setLink($1, $2);}
|
||||
| CLICK HREF CALLBACKNAME {$$ = $1;yy.setClickEvent($1, $3);yy.setLink($1,$2);}
|
||||
| CLICK HREF CALLBACKNAME CALLBACKARGS {$$ = $1;yy.setClickEvent($1, $3, $4);yy.setLink($1,$2);}
|
||||
| CLICK HREF SPACE STR {$$ = $1;yy.setLink($1, $2);yy.setTooltip($1, $4)}
|
||||
| CLICK HREF SPACE LINK_TARGET {$$ = $1;yy.setLink($1, $2, $4);}
|
||||
| CLICK HREF SPACE STR SPACE LINK_TARGET {$$ = $1;yy.setLink($1, $2, $7);yy.setTooltip($1, $4)}
|
||||
;
|
||||
|
||||
styleStatement:STYLE SPACE alphaNum SPACE stylesOpt
|
||||
|
Reference in New Issue
Block a user