mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 15:30:03 +02:00
Added href support and improved callback argument handling
This commit is contained in:
@@ -294,8 +294,8 @@ export const addTask = function (descr, data) {
|
|||||||
data: data
|
data: data
|
||||||
},
|
},
|
||||||
task: descr,
|
task: descr,
|
||||||
link: undefined,
|
|
||||||
/* The link the rectangle will href to */
|
/* The link the rectangle will href to */
|
||||||
|
link: undefined,
|
||||||
classes: []
|
classes: []
|
||||||
}
|
}
|
||||||
const taskInfo = parseData(lastTaskID, data)
|
const taskInfo = parseData(lastTaskID, data)
|
||||||
@@ -325,8 +325,8 @@ export const addTaskOrg = function (descr, data) {
|
|||||||
type: currentSection,
|
type: currentSection,
|
||||||
description: descr,
|
description: descr,
|
||||||
task: descr,
|
task: descr,
|
||||||
link: undefined,
|
|
||||||
/* The link the rectangle will href to */
|
/* The link the rectangle will href to */
|
||||||
|
link: undefined,
|
||||||
classes: []
|
classes: []
|
||||||
}
|
}
|
||||||
const taskInfo = compileData(lastTask, data)
|
const taskInfo = compileData(lastTask, data)
|
||||||
|
@@ -13,8 +13,9 @@
|
|||||||
/* a valid callback looks like this: callback(example_callback_arg) */
|
/* a valid callback looks like this: callback(example_callback_arg) */
|
||||||
/* callback prefix: callback( */
|
/* callback prefix: callback( */
|
||||||
/* callback suffix: ) */
|
/* callback suffix: ) */
|
||||||
%x callback
|
%x href
|
||||||
%x callbackname
|
%x callbackname
|
||||||
|
%x callbackargs
|
||||||
%%
|
%%
|
||||||
|
|
||||||
[\n]+ return 'NL';
|
[\n]+ return 'NL';
|
||||||
@@ -25,11 +26,16 @@
|
|||||||
["] this.begin("string");
|
["] this.begin("string");
|
||||||
<string>["] this.popState();
|
<string>["] this.popState();
|
||||||
<string>[^"]* return 'STR';
|
<string>[^"]* return 'STR';
|
||||||
"call"\s this.begin("callbackname");
|
|
||||||
<callbackname>\( this.popState(); this.begin("callback");
|
"href"\s+ this.begin("href");
|
||||||
<callbackname>[^(]+ return 'callbackname';
|
<href>[\s\n] this.popState();
|
||||||
<callback>[)] this.popState();
|
<href>[^\s\n]* return 'href';
|
||||||
<callback>[^)]* return 'callbackarguments';
|
|
||||||
|
"call"\s+ this.begin("callbackname");
|
||||||
|
<callbackname>\( this.popState(); this.begin("callbackargs");
|
||||||
|
<callbackname>[^(]* return 'callbackname';
|
||||||
|
<callbackargs>\) this.popState();
|
||||||
|
<callbackargs>[^)]* return 'callbackargs';
|
||||||
|
|
||||||
"click" return 'click';
|
"click" return 'click';
|
||||||
"gantt" return 'gantt';
|
"gantt" return 'gantt';
|
||||||
@@ -78,8 +84,17 @@ statement
|
|||||||
;
|
;
|
||||||
|
|
||||||
clickStatement
|
clickStatement
|
||||||
: click STR callbackname callbackarguments {$$ = $1;yy.setClickEvent($2, $3, $4);}
|
: click STR callbackname callbackargs {$$ = $1;yy.setClickEvent($2, $3, $4);}
|
||||||
| click STR STR callbackname callbackarguments {$$ = $1;yy.setLink($2, $3);yy.setClickEvent($2, $4, $5);}
|
| click STR callbackname callbackargs href {$$ = $1;yy.setClickEvent($2, $3, $4);yy.setLink($2,$5);}
|
||||||
| click STR STR {$$ = $1;yy.setLink($2, $3);}
|
| click STR href callbackname callbackargs {$$ = $1;yy.setClickEvent($2, $4, $5);yy.setLink($2,$3);}
|
||||||
|
| click STR href {$$ = $1;yy.setLink($2, $3);}
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
clickStatementDebug
|
||||||
|
: click STR callbackname callbackargs {$$=$1+' ' + $2 + ' ' + $3 + ' ' + $4;}
|
||||||
|
| click STR callbackname callbackargs href {$$=$1+' ' + $2 + ' ' + $3 + ' ' + $4 + ' ' + $5;}
|
||||||
|
| click STR href callbackname callbackargs {$$=$1+' ' + $2 + ' ' + $3 + ' ' + $4 + ' ' + $5;}
|
||||||
|
| click STR href {$$=$1+' ' + $2 + ' ' + $3;}
|
||||||
;
|
;
|
||||||
%%
|
%%
|
||||||
|
Reference in New Issue
Block a user