Fix for defect #158

This commit is contained in:
knsv 2015-04-20 21:21:17 +02:00
parent f310eb0574
commit 2204d46ce1
13 changed files with 181 additions and 266 deletions

88
dist/mermaid.full.js vendored
View File

@ -28315,6 +28315,7 @@ module.exports.draw = function (text, id) {
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding;
elem.style.height = h + 'px';
elem.setAttribute('height', h);
var svg = d3.select('#' + id);
// http://codepen.io/anon/pen/azLvWR
@ -30093,10 +30094,11 @@ if (typeof module !== 'undefined' && require.main === module) {
/**
* Created by knut on 14-11-19.
*/
var actors = {};
var actors = {};
var actorKeys = [];
var messages = [];
var notes = [];
var messages = [];
var notes = [];
exports.addActor = function(id,name,description){
//console.log('Adding actor: '+id);
actors[id] = {name:name, description:description};
@ -30108,6 +30110,9 @@ exports.addMessage = function(idFrom, idTo, message, answer){
messages.push({from:idFrom, to:idTo, message:message, answer:answer});
};
/**
*
*/
exports.addSignal = function(idFrom, idTo, message, messageType){
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
messages.push({from:idFrom, to:idTo, message:message, type:messageType});
@ -30128,37 +30133,36 @@ exports.getActorKeys = function(){
};
exports.clear = function(){
actors = {};
actors = {};
messages = [];
};
exports.LINETYPE = {
SOLID : 0,
DOTTED : 1,
NOTE : 2,
SOLID_CROSS : 3,
DOTTED_CROSS: 4,
SOLID_OPEN : 5,
DOTTED_OPEN : 6,
LOOP_START : 10,
LOOP_END : 11,
ALT_START : 12,
ALT_ELSE : 13,
ALT_END : 14,
OPT_START : 15,
OPT_END : 16
SOLID : 0 ,
DOTTED : 1 ,
NOTE : 2 ,
SOLID_CROSS : 3 ,
DOTTED_CROSS : 4 ,
SOLID_OPEN : 5 ,
DOTTED_OPEN : 6 ,
LOOP_START : 10 ,
LOOP_END : 11 ,
ALT_START : 12 ,
ALT_ELSE : 13 ,
ALT_END : 14 ,
OPT_START : 15 ,
OPT_END : 16
};
exports.ARROWTYPE = {
FILLED : 0,
OPEN : 1
FILLED : 0,
OPEN : 1
};
exports.PLACEMENT = {
LEFTOF : 0,
RIGHTOF : 1,
OVER : 2
LEFTOF : 0,
RIGHTOF : 1,
OVER : 2
};
exports.addNote = function (actor, placement, message){
@ -30809,15 +30813,15 @@ exports.getTextObj = function(){
exports.getNoteRect = function(){
var rect = {
x: 0,
y: 0,
fill: '#EDF2AE',
stroke: '#666',
width: 100,
anchor:'start',
height: 100,
rx: 0,
ry: 0
x : 0,
y : 0,
fill : '#EDF2AE',
stroke : '#666',
width : 100,
anchor : 'start',
height : 100,
rx : 0,
ry : 0
};
return rect;
};
@ -31012,21 +31016,22 @@ var equals = function (val, variable){
};
global.mermaid = {
startOnLoad:true,
htmlLabels:true,
init:function(sequenceConfig, nodes){
startOnLoad: true,
htmlLabels: true,
init: function(sequenceConfig, nodes) {
init.apply(null, arguments);
},
version:function(){
version: function() {
return exports.version();
},
getParser:function(){
getParser: function() {
return flow.parser;
},
parse:function(text){
parse: function(text) {
return parse(text);
},
parseError:function(err,hash){
parseError: function(err, hash) {
console.log('Mermaid Syntax error:');
console.log(err);
}
@ -31068,6 +31073,9 @@ if(typeof document !== 'undefined'){
}, false);
}
var apa = 1;
var bapselsin = 2;
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../package.json":84,"./diagrams/example/exampleDb":85,"./diagrams/example/exampleRenderer":86,"./diagrams/example/parser/example":87,"./diagrams/flowchart/flowRenderer":90,"./diagrams/flowchart/graphDb":91,"./diagrams/flowchart/parser/dot":92,"./diagrams/flowchart/parser/flow":93,"./diagrams/gantt/ganttDb":95,"./diagrams/gantt/ganttRenderer":96,"./diagrams/gantt/parser/gantt":97,"./diagrams/sequenceDiagram/parser/sequenceDiagram":99,"./diagrams/sequenceDiagram/sequenceDb":100,"./diagrams/sequenceDiagram/sequenceRenderer":101,"./utils":104,"he":81}],104:[function(require,module,exports){
/**

File diff suppressed because one or more lines are too long

88
dist/mermaid.slim.js vendored
View File

@ -28283,6 +28283,7 @@ module.exports.draw = function (text, id) {
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding;
elem.style.height = h + 'px';
elem.setAttribute('height', h);
var svg = d3.select('#' + id);
// http://codepen.io/anon/pen/azLvWR
@ -30061,10 +30062,11 @@ if (typeof module !== 'undefined' && require.main === module) {
/**
* Created by knut on 14-11-19.
*/
var actors = {};
var actors = {};
var actorKeys = [];
var messages = [];
var notes = [];
var messages = [];
var notes = [];
exports.addActor = function(id,name,description){
//console.log('Adding actor: '+id);
actors[id] = {name:name, description:description};
@ -30076,6 +30078,9 @@ exports.addMessage = function(idFrom, idTo, message, answer){
messages.push({from:idFrom, to:idTo, message:message, answer:answer});
};
/**
*
*/
exports.addSignal = function(idFrom, idTo, message, messageType){
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
messages.push({from:idFrom, to:idTo, message:message, type:messageType});
@ -30096,37 +30101,36 @@ exports.getActorKeys = function(){
};
exports.clear = function(){
actors = {};
actors = {};
messages = [];
};
exports.LINETYPE = {
SOLID : 0,
DOTTED : 1,
NOTE : 2,
SOLID_CROSS : 3,
DOTTED_CROSS: 4,
SOLID_OPEN : 5,
DOTTED_OPEN : 6,
LOOP_START : 10,
LOOP_END : 11,
ALT_START : 12,
ALT_ELSE : 13,
ALT_END : 14,
OPT_START : 15,
OPT_END : 16
SOLID : 0 ,
DOTTED : 1 ,
NOTE : 2 ,
SOLID_CROSS : 3 ,
DOTTED_CROSS : 4 ,
SOLID_OPEN : 5 ,
DOTTED_OPEN : 6 ,
LOOP_START : 10 ,
LOOP_END : 11 ,
ALT_START : 12 ,
ALT_ELSE : 13 ,
ALT_END : 14 ,
OPT_START : 15 ,
OPT_END : 16
};
exports.ARROWTYPE = {
FILLED : 0,
OPEN : 1
FILLED : 0,
OPEN : 1
};
exports.PLACEMENT = {
LEFTOF : 0,
RIGHTOF : 1,
OVER : 2
LEFTOF : 0,
RIGHTOF : 1,
OVER : 2
};
exports.addNote = function (actor, placement, message){
@ -30777,15 +30781,15 @@ exports.getTextObj = function(){
exports.getNoteRect = function(){
var rect = {
x: 0,
y: 0,
fill: '#EDF2AE',
stroke: '#666',
width: 100,
anchor:'start',
height: 100,
rx: 0,
ry: 0
x : 0,
y : 0,
fill : '#EDF2AE',
stroke : '#666',
width : 100,
anchor : 'start',
height : 100,
rx : 0,
ry : 0
};
return rect;
};
@ -30980,21 +30984,22 @@ var equals = function (val, variable){
};
global.mermaid = {
startOnLoad:true,
htmlLabels:true,
init:function(sequenceConfig, nodes){
startOnLoad: true,
htmlLabels: true,
init: function(sequenceConfig, nodes) {
init.apply(null, arguments);
},
version:function(){
version: function() {
return exports.version();
},
getParser:function(){
getParser: function() {
return flow.parser;
},
parse:function(text){
parse: function(text) {
return parse(text);
},
parseError:function(err,hash){
parseError: function(err, hash) {
console.log('Mermaid Syntax error:');
console.log(err);
}
@ -31036,6 +31041,9 @@ if(typeof document !== 'undefined'){
}, false);
}
var apa = 1;
var bapselsin = 2;
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../package.json":84,"./diagrams/example/exampleDb":85,"./diagrams/example/exampleRenderer":86,"./diagrams/example/parser/example":87,"./diagrams/flowchart/flowRenderer":90,"./diagrams/flowchart/graphDb":91,"./diagrams/flowchart/parser/dot":92,"./diagrams/flowchart/parser/flow":93,"./diagrams/gantt/ganttDb":95,"./diagrams/gantt/ganttRenderer":96,"./diagrams/gantt/parser/gantt":97,"./diagrams/sequenceDiagram/parser/sequenceDiagram":99,"./diagrams/sequenceDiagram/sequenceDb":100,"./diagrams/sequenceDiagram/sequenceRenderer":101,"./utils":104,"he":81}],104:[function(require,module,exports){
/**

File diff suppressed because one or more lines are too long

View File

@ -24,6 +24,7 @@ function cli(options) {
, verbose: 'v'
, phantomPath: 'e'
, sequenceConfig: 'c'
, ganttConfig: 'g'
, css: 't'
}
, 'boolean': ['help', 'png', 'svg']
@ -45,6 +46,7 @@ function cli(options) {
, " -e --phantomPath Specify the path to the phantomjs executable"
, " -t --css Specify the path to a CSS file to be included when processing output"
, " -c --sequenceConfig Specify the path to the file with the configuration to be applied in the sequence diagram"
, " -g --ganttConfig Specify the path to the file with the configuration to be applied in the gantt diagram"
, " -h --help Show this message"
, " -v --verbose Show logging"
, " --version Print version and quit"
@ -74,7 +76,7 @@ cli.prototype.parse = function(argv, next) {
}
// ensure that parameter-expecting options have parameters
;['outputDir', 'phantomPath', 'sequenceConfig', 'css'].forEach(function(i) {
;['outputDir', 'phantomPath', 'sequenceConfig', 'ganttConfig', 'css'].forEach(function(i) {
if(typeof options[i] !== 'undefined') {
if (typeof options[i] !== 'string' || options[i].length < 1) {
this.errors.push(new Error(i + " expects a value."))
@ -94,6 +96,12 @@ cli.prototype.parse = function(argv, next) {
options.sequenceConfig = checkConfig(options.sequenceConfig)
}
if (options.ganttConfig) {
options.ganttConfig = checkConfig(options.ganttConfig)
console.log('Got conf'+options.ganttConfig);
}
if (options.css) {
try {
options.css = fs.readFileSync(options.css, 'utf8')

View File

@ -20,6 +20,7 @@ function processMermaid(files, _options, _next) {
, options.svg
, options.css || ''
, options.sequenceConfig
, options.ganttConfig
, options.verbose
]

View File

@ -28,18 +28,24 @@ var system = require('system')
, fs = require('fs')
, webpage = require('webpage')
var page = webpage.create()
, files = phantom.args.slice(6, phantom.args.length)
, files = phantom.args.slice(7, phantom.args.length)
, options = {
outputDir: phantom.args[0]
, png: phantom.args[1] === 'true' ? true : false
, svg: phantom.args[2] === 'true' ? true : false
, css: phantom.args[3] !== '' ? phantom.args[3] : '* { margin: 0; padding: 0; }'
, sequenceConfig: phantom.args[4]
, verbose: phantom.args[5] === 'true' ? true : false
, ganttConfig: phantom.args[5]
, verbose: phantom.args[6] === 'true' ? true : false
}
, log = logger(options.verbose)
console.log('options');
console.log(options.ganttConfig);
page.content = [
'<html>'
, '<head>'
@ -68,8 +74,9 @@ files.forEach(function(file) {
// look like it. we need to serialize then unserialize the svgContent that's
// taken from the DOM
svgContent = page.evaluate(executeInPage, {
contents: contents,
sequenceConfig: options.sequenceConfig
contents : contents,
ganttConfig : options.ganttConfig,
sequenceConfig : options.sequenceConfig
})
oDOM = oParser.parseFromString(svgContent, "text/xml")
@ -193,6 +200,7 @@ function executeInPage(data) {
var xmlSerializer = new XMLSerializer()
, contents = data.contents
, sequenceConfig = data.sequenceConfig
, ganttConfig = data.ganttConfig
, toRemove
, el
, elContent
@ -221,6 +229,17 @@ function executeInPage(data) {
document.body.appendChild(sc)
}
if(typeof ganttConfig !== undefined && ganttConfig !== 'undefined'){
console.log('Got ganttConfig');
sc = document.createElement("script")
scContent = document.createTextNode('mermaid.ganttConfig = JSON.parse(' + JSON.stringify(ganttConfig) + ');')
sc.appendChild(scContent)
document.body.appendChild(sc)
}else{
console.log('No gantt config');
}
mermaid.init();
svg = document.querySelector('svg')

View File

@ -21,4 +21,3 @@ gantt
Add gantt diagram to demo page :after a1 , 2h
Add gantt to diagram to demo page :after a1 , 2h
```
testa

View File

@ -38,6 +38,7 @@ module.exports.draw = function (text, id) {
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding;
elem.style.height = h + 'px';
elem.setAttribute('height', h);
var svg = d3.select('#' + id);
// http://codepen.io/anon/pen/azLvWR

View File

@ -1,10 +1,11 @@
/**
* Created by knut on 14-11-19.
*/
var actors = {};
var actors = {};
var actorKeys = [];
var messages = [];
var notes = [];
var messages = [];
var notes = [];
exports.addActor = function(id,name,description){
//console.log('Adding actor: '+id);
actors[id] = {name:name, description:description};
@ -16,6 +17,9 @@ exports.addMessage = function(idFrom, idTo, message, answer){
messages.push({from:idFrom, to:idTo, message:message, answer:answer});
};
/**
*
*/
exports.addSignal = function(idFrom, idTo, message, messageType){
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
messages.push({from:idFrom, to:idTo, message:message, type:messageType});
@ -36,37 +40,36 @@ exports.getActorKeys = function(){
};
exports.clear = function(){
actors = {};
actors = {};
messages = [];
};
exports.LINETYPE = {
SOLID : 0,
DOTTED : 1,
NOTE : 2,
SOLID_CROSS : 3,
DOTTED_CROSS: 4,
SOLID_OPEN : 5,
DOTTED_OPEN : 6,
LOOP_START : 10,
LOOP_END : 11,
ALT_START : 12,
ALT_ELSE : 13,
ALT_END : 14,
OPT_START : 15,
OPT_END : 16
SOLID : 0 ,
DOTTED : 1 ,
NOTE : 2 ,
SOLID_CROSS : 3 ,
DOTTED_CROSS : 4 ,
SOLID_OPEN : 5 ,
DOTTED_OPEN : 6 ,
LOOP_START : 10 ,
LOOP_END : 11 ,
ALT_START : 12 ,
ALT_ELSE : 13 ,
ALT_END : 14 ,
OPT_START : 15 ,
OPT_END : 16
};
exports.ARROWTYPE = {
FILLED : 0,
OPEN : 1
FILLED : 0,
OPEN : 1
};
exports.PLACEMENT = {
LEFTOF : 0,
RIGHTOF : 1,
OVER : 2
LEFTOF : 0,
RIGHTOF : 1,
OVER : 2
};
exports.addNote = function (actor, placement, message){

View File

@ -217,15 +217,15 @@ exports.getTextObj = function(){
exports.getNoteRect = function(){
var rect = {
x: 0,
y: 0,
fill: '#EDF2AE',
stroke: '#666',
width: 100,
anchor:'start',
height: 100,
rx: 0,
ry: 0
x : 0,
y : 0,
fill : '#EDF2AE',
stroke : '#666',
width : 100,
anchor : 'start',
height : 100,
rx : 0,
ry : 0
};
return rect;
};

View File

@ -186,21 +186,22 @@ var equals = function (val, variable){
};
global.mermaid = {
startOnLoad:true,
htmlLabels:true,
init:function(sequenceConfig, nodes){
startOnLoad: true,
htmlLabels: true,
init: function(sequenceConfig, nodes) {
init.apply(null, arguments);
},
version:function(){
version: function() {
return exports.version();
},
getParser:function(){
getParser: function() {
return flow.parser;
},
parse:function(text){
parse: function(text) {
return parse(text);
},
parseError:function(err,hash){
parseError: function(err, hash) {
console.log('Mermaid Syntax error:');
console.log(err);
}
@ -241,3 +242,6 @@ if(typeof document !== 'undefined'){
exports.contentLoaded();
}, false);
}
var apa = 1;
var bapselsin = 2;

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<script src="../dist/mermaid.full.js"></script>
<link rel="stylesheet" href="seq.css"/>
<link rel="stylesheet" href="../dist/mermaid.forest.css"/>
<script>
var mermaid_config = {
startOnLoad:true
@ -44,143 +44,7 @@
]
};
</script>
<script>
function apa(){
console.log('CLICKED');
}
</script>
<style>
* {
margin: 0;
padding: 0;
}
body {
background: #fff;
font-family: 'Open-Sans',sans-serif;
}
.grid .tick {
stroke: lightgrey;
opacity: 0.3;
shape-rendering: crispEdges;
}
.grid path {
stroke-width: 0;
}
.taskText {
text-anchor:middle;
font-size:11px;
}
.taskText0, .taskText3 {
fill:black;
}
.taskText1, .taskText2 {
fill:white;
}
.taskTextOutsideRight {
fill:black;
text-anchor:start;
font-size:11px;
}
.taskTextOutsideLeft {
fill:black;
text-anchor:end;
font-size:11px;
}
.taskTextOutside0,.taskTextOutside2, {
fill:black;
}
.taskTextOutside1, .taskTextOutside3 {
fill:darkblue;
}
.titleText {
text-anchor:middle;
font-size:18px;
fill:#633;
}
.section {
stroke:none;
opacity:0.2;
}
.section0 {
fill:#6666FF;
}
.section1 {
fill:white;
opacity:0.2;
}
.section2 {
fill:orange;
opacity:0.2;
}
.task {
/*stroke:none;*/
}
.task0 {
fill: #ffffdd;
}
.task1 {
fill: #8a90dd;
}
.task2 {
fill: #8a90dd;
}
.sectionTitle {
text-anchor:start;
font-size:11px;
text-height:14px;
}
.sectionTitle0 { fill:#454545;}
.sectionTitle1 { fill:#454545;}
.sectionTitle2 { fill:#454545;}
.sectionTitle3 { fill:#b23473;}
.done0, .done1, .done2, .done3 {
stroke:grey;
fill: lightgrey;
stroke-width:2;
}
.crit0, .crit1, .crit2, .crit3 {
stroke:#ff8888;
fill: red;
stroke-width:2;
}
.activeCrit0, .activeCrit1, .activeCrit2, .activeCrit3 {
stroke:#ff8888;
fill: #ffffc0;
stroke-width:2;
}
.doneCrit0, .doneCrit1, .doneCrit2, .doneCrit3 {
stroke:#ff8888;
fill: lightgrey;
stroke-width:2;
cursor: pointer;
shape-rendering: crispEdges;
}
.active0 {
stroke:black;
fill: #ffffdd;
stroke-width:2;
}
.active1 {
stroke:black;
fill: #8a90dd;
stroke-width:2;
}
.active2 {
stroke:black;
fill: #8a90dd;
stroke-width:2;
}
.today {
fill:none;
stroke:red;
stroke-width:2px;
}
</style>
</head>
<body>
<h1>scale tests</h1>