mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-16 22:09:57 +02:00
Added documentation and implemented empty functionarguments
This commit is contained in:
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
%options case-insensitive
|
%options case-insensitive
|
||||||
|
|
||||||
/* string is used to detect blocks that are surrounded by double quotes. */
|
|
||||||
/* copied from /src/diagrams/flowchart/parser/flow.jison */
|
|
||||||
%x click
|
%x click
|
||||||
%x href
|
%x href
|
||||||
%x callbackname
|
%x callbackname
|
||||||
@@ -20,16 +18,37 @@
|
|||||||
\#[^\n]* /* skip comments */
|
\#[^\n]* /* skip comments */
|
||||||
\%%[^\n]* /* skip comments */
|
\%%[^\n]* /* skip comments */
|
||||||
|
|
||||||
"href"[\s]+["] this.begin("href"); /* return the next double quoted word after 'href' */
|
/*
|
||||||
<href>["] this.popState(); /* e.g. return https://example.com for 'href "https://example.com"' */
|
---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 task that was specified by 'click'.
|
||||||
|
*/
|
||||||
|
"href"[\s]+["] this.begin("href");
|
||||||
|
<href>["] this.popState();
|
||||||
<href>[^"]* return 'href';
|
<href>[^"]* return 'href';
|
||||||
|
|
||||||
|
/*
|
||||||
|
---interactivity command---
|
||||||
|
'call' adds a callback to the specified task. 'call' can only be specified when
|
||||||
|
the line was introdcued 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");
|
"call"[\s]+ this.begin("callbackname");
|
||||||
|
<callbackname>\([\s]*\) this.popState();
|
||||||
<callbackname>\( this.popState(); this.begin("callbackargs");
|
<callbackname>\( this.popState(); this.begin("callbackargs");
|
||||||
<callbackname>[^(]* return 'callbackname';
|
<callbackname>[^(]* return 'callbackname';
|
||||||
<callbackargs>\) this.popState();
|
<callbackargs>\) this.popState();
|
||||||
<callbackargs>[^)]* return 'callbackargs';
|
<callbackargs>[^)]* return 'callbackargs';
|
||||||
|
|
||||||
|
/*
|
||||||
|
'click' is the keyword to introduce a line that contains interactivity commands.
|
||||||
|
'click' must be followed by an existing task-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]+ this.begin("click");
|
||||||
<click>[\s\n] this.popState();
|
<click>[\s\n] this.popState();
|
||||||
<click>[^\s\n]* return 'click';
|
<click>[^\s\n]* return 'click';
|
||||||
@@ -79,17 +98,31 @@ statement
|
|||||||
| taskTxt taskData {yy.addTask($1,$2);$$='task';}
|
| taskTxt taskData {yy.addTask($1,$2);$$='task';}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
click allows any combination of href and call.
|
||||||
|
*/
|
||||||
clickStatement
|
clickStatement
|
||||||
: click callbackname callbackargs {$$ = $1;yy.setClickEvent($1, $2, $3);}
|
: click callbackname {$$ = $1;yy.setClickEvent($1, $2, null);}
|
||||||
|
| click callbackname callbackargs {$$ = $1;yy.setClickEvent($1, $2, $3);}
|
||||||
|
|
||||||
|
| click callbackname href {$$ = $1;yy.setClickEvent($1, $2, null);yy.setLink($1,$3);}
|
||||||
| click callbackname callbackargs href {$$ = $1;yy.setClickEvent($1, $2, $3);yy.setLink($1,$4);}
|
| click callbackname callbackargs href {$$ = $1;yy.setClickEvent($1, $2, $3);yy.setLink($1,$4);}
|
||||||
|
|
||||||
|
| click href callbackname {$$ = $1;yy.setClickEvent($1, $3, null);yy.setLink($1,$2);}
|
||||||
| click href callbackname callbackargs {$$ = $1;yy.setClickEvent($1, $3, $4);yy.setLink($1,$2);}
|
| click href callbackname callbackargs {$$ = $1;yy.setClickEvent($1, $3, $4);yy.setLink($1,$2);}
|
||||||
|
|
||||||
| click href {$$ = $1;yy.setLink($1, $2);}
|
| click href {$$ = $1;yy.setLink($1, $2);}
|
||||||
;
|
;
|
||||||
|
|
||||||
clickStatementDebug
|
clickStatementDebug
|
||||||
: click callbackname callbackargs {$$=$1+' ' + $2 + ' ' + $3;}
|
: click callbackname {$$=$1 + ' ' + $2;}
|
||||||
| click callbackname callbackargs href {$$=$1+' ' + $2 + ' ' + $3 + ' ' + $4;}
|
| click callbackname href {$$=$1 + ' ' + $2 + ' ' + $3;}
|
||||||
| click href callbackname callbackargs {$$=$1+' ' + $2 + ' ' + $3 + ' ' + $4;}
|
|
||||||
| click href {$$=$1+' ' + $2;}
|
| click callbackname callbackargs {$$=$1 + ' ' + $2 + ' ' + $3;}
|
||||||
;
|
| click callbackname callbackargs href {$$=$1 + ' ' + $2 + ' ' + $3 + ' ' + $4;}
|
||||||
%%
|
|
||||||
|
| click href callbackname {$$=$1 + ' ' + $2 + ' ' + $3;}
|
||||||
|
| click href callbackname callbackargs {$$=$1 + ' ' + $2 + ' ' + $3 + ' ' + $4;}
|
||||||
|
|
||||||
|
| click href {$$=$1 + ' ' + $2;}
|
||||||
|
;%%
|
||||||
|
Reference in New Issue
Block a user