mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Updated conf handling
Added initialize function Moved genric configuration as clonseCssStyles till conf root Added parse funtion to the mermaidAPI api
This commit is contained in:
parent
55fa62d9c0
commit
08fa19bc83
155
dist/mermaid-legacy.full.js
vendored
155
dist/mermaid-legacy.full.js
vendored
@ -15768,9 +15768,9 @@ process.chdir = function (dir) {
|
||||
},{}],85:[function(require,module,exports){
|
||||
module.exports={
|
||||
"name": "mermaid",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
|
||||
"main": "src/main.js",
|
||||
"main": "src/mermaid.js",
|
||||
"keywords": [
|
||||
"diagram",
|
||||
"markdown",
|
||||
@ -16604,7 +16604,6 @@ if (!dagreD3) {
|
||||
module.exports = dagreD3;
|
||||
|
||||
},{"dagre-d3":1}],91:[function(require,module,exports){
|
||||
(function (global){
|
||||
/**
|
||||
* Created by knut on 14-12-11.
|
||||
*/
|
||||
@ -16679,7 +16678,7 @@ exports.addVertices = function (vert, g) {
|
||||
}
|
||||
|
||||
var labelTypeStr = '';
|
||||
if(global.mermaid.htmlLabels) {
|
||||
if(conf.htmlLabels) {
|
||||
labelTypeStr = 'html';
|
||||
} else {
|
||||
verticeText = verticeText.replace(/<br>/g, "\n");
|
||||
@ -16783,7 +16782,7 @@ exports.addEdges = function (edges, g) {
|
||||
else {
|
||||
var edgeText = edge.text.replace(/<br>/g, "\n");
|
||||
if(typeof edge.style === 'undefined'){
|
||||
if (global.mermaid.htmlLabels){
|
||||
if (conf.htmlLabels){
|
||||
g.setEdge(edge.start, edge.end,{labelType: "html",style: style, labelpos:'c', label: '<span style="background:#e8e8e8">'+edge.text+'</span>', arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
}else{
|
||||
g.setEdge(edge.start, edge.end,{labelType: "text", style: "stroke: #333; stroke-width: 1.5px;fill:none", labelpos:'c', label: edgeText, arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
@ -17055,14 +17054,12 @@ exports.draw = function (text, id,isDot) {
|
||||
//te.text(subGraphs[subGraphs.length-i-1].title);
|
||||
te.text(subG.title);
|
||||
|
||||
console.log('Setting subg - '+i+' to title '+subGraphs[pos].title);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../../d3":86,"./dagre-d3":90,"./graphDb":92,"./parser/dot":93,"./parser/flow":94}],92:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-11-03.
|
||||
@ -21865,6 +21862,7 @@ var he = require('he');
|
||||
var mermaidAPI = require('./mermaidAPI');
|
||||
var nextId = 0;
|
||||
|
||||
module.exports.mermaidAPI = mermaidAPI;
|
||||
/**
|
||||
* Function that goes through the document to find the chart definitions in there and render them.
|
||||
*
|
||||
@ -21883,12 +21881,12 @@ var nextId = 0;
|
||||
* c-->|No |d(Transform);
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders the mermaid diagrams
|
||||
* @* param nodes- a css selector or an array of nodes
|
||||
*/
|
||||
var init = function () {
|
||||
console.log('In mermaid.init');
|
||||
var nodes;
|
||||
if(arguments.length === 2){
|
||||
// sequence config was passed as #1
|
||||
@ -21910,9 +21908,10 @@ var init = function () {
|
||||
|
||||
var i;
|
||||
|
||||
console.log('Found ',nodes.length,' nodes');
|
||||
console.log('Hooo hooo');
|
||||
mermaidAPI.initialize(mermaid_config);
|
||||
if(typeof mermaid_config !== 'undefined'){
|
||||
mermaidAPI.initialize(mermaid_config);
|
||||
}
|
||||
|
||||
var insertSvg = function(svgCode){
|
||||
element.innerHTML = svgCode;
|
||||
};
|
||||
@ -21942,14 +21941,20 @@ var init = function () {
|
||||
|
||||
exports.tester = function(){};
|
||||
|
||||
exports.init = init;
|
||||
|
||||
/**
|
||||
* Function returning version information
|
||||
* @returns {string} A string containing the version info
|
||||
*/
|
||||
exports.version = function(){
|
||||
return require('../package.json').version;
|
||||
return 'v'+require('../package.json').version;
|
||||
};
|
||||
|
||||
exports.initialize = function(config){
|
||||
mermaidAPI.initialize(config);
|
||||
}
|
||||
|
||||
var equals = function (val, variable){
|
||||
if(typeof variable === 'undefined'){
|
||||
return false;
|
||||
@ -21966,6 +21971,9 @@ global.mermaid = {
|
||||
init: function(sequenceConfig, nodes) {
|
||||
init.apply(null, arguments);
|
||||
},
|
||||
initialize: function(config) {
|
||||
mermaidAPI.initialize(config);
|
||||
},
|
||||
version: function() {
|
||||
return mermaidAPI.version();
|
||||
},
|
||||
@ -21982,10 +21990,8 @@ global.mermaid = {
|
||||
};
|
||||
|
||||
exports.contentLoaded = function(){
|
||||
console.log('Content loaded');
|
||||
// Check state of start config mermaid namespace
|
||||
console.log('Starting mermaid');
|
||||
console.log('global.mermaid.startOnLoad',global.mermaid.startOnLoad);
|
||||
console.log('mermaid_config',mermaid_config);
|
||||
if (typeof mermaid_config !== 'undefined') {
|
||||
if (equals(false, mermaid_config.htmlLabels)) {
|
||||
global.mermaid.htmlLabels = false;
|
||||
@ -22002,8 +22008,11 @@ exports.contentLoaded = function(){
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No config found, do autostart in this simple case
|
||||
global.mermaid.init();
|
||||
// No config found, do check API config
|
||||
var config = mermaidAPI.getConfig();
|
||||
if(config.startOnLoad){
|
||||
global.mermaid.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22043,12 +22052,11 @@ var nextId = 0;
|
||||
|
||||
// Default options, can be overridden at initialization time
|
||||
var config = {
|
||||
mermaid:{
|
||||
cloneCssStyles: true
|
||||
},
|
||||
cloneCssStyles: true,
|
||||
flowchart:{
|
||||
// Default is to not set width
|
||||
// width: 1200
|
||||
htmlLabels:true
|
||||
},
|
||||
sequenceDiagram:{
|
||||
diagramMarginX:50,
|
||||
@ -22104,7 +22112,7 @@ var config = {
|
||||
return d.getMonth();
|
||||
}]
|
||||
] }
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Function that parses a mermaid diagram defintion. If parsing fails the parseError callback is called and an error is
|
||||
@ -22146,6 +22154,7 @@ var parse = function(text){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
exports.parse = parse;
|
||||
|
||||
/**
|
||||
* Function returning version information
|
||||
@ -22175,7 +22184,7 @@ var render = function(id, txt,cb){
|
||||
case 'graph':
|
||||
flowRenderer.setConf(config.flowchart);
|
||||
flowRenderer.draw(txt, id, false);
|
||||
if(config.mermaid.cloneCssStyles){
|
||||
if(config.cloneCssStyles){
|
||||
classes = flowRenderer.getClasses(txt, false);
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
}
|
||||
@ -22184,7 +22193,7 @@ var render = function(id, txt,cb){
|
||||
case 'dotGraph':
|
||||
flowRenderer.setConf(config.flowchart);
|
||||
flowRenderer.draw(txt, id, true);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
classes = flowRenderer.getClasses(txt, true);
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
}
|
||||
@ -22194,20 +22203,20 @@ var render = function(id, txt,cb){
|
||||
seq.setConf(config.sequenceDiagram);
|
||||
//}
|
||||
seq.draw(txt,id);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
case 'gantt':
|
||||
gantt.setConf(config.gantt);
|
||||
gantt.draw(txt,id);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
case 'info':
|
||||
info.draw(txt,id,exports.version());
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
@ -22222,45 +22231,7 @@ var render = function(id, txt,cb){
|
||||
|
||||
exports.render = function(id, text,cb){
|
||||
if(typeof document === 'undefined'){
|
||||
//jsdom = require('jsdom').jsdom;
|
||||
//console.log(jsdom);
|
||||
|
||||
//htmlStub = '<html><head></head><body><div class="mermaid">'+text+'</div><script src="dist/mermaid.full.js"></script><script>var mermaid_config = {startOnLoad:true}</script></body></html>';
|
||||
htmlStub = '<html><head></head><body></body></html>';
|
||||
// // html file skull with a container div for the d3 dataviz
|
||||
//
|
||||
// pass the html stub to jsDom
|
||||
/* jsdom.env({
|
||||
features : { QuerySelectorAll : true },
|
||||
html : htmlStub,
|
||||
done : function(errors, win) {
|
||||
// process the html document, like if we were at client side
|
||||
// code to generate the dataviz and process the resulting html file to be added here
|
||||
//var d3 = require('d3');
|
||||
//console.log('Here we go: '+JSON.stringify(d3));
|
||||
|
||||
global.document = win.document;
|
||||
global.window = win;
|
||||
|
||||
var element = win.document.createElement('div');
|
||||
element.setAttribute('id','did');
|
||||
//document.
|
||||
console.log(document.body.innerHTML);
|
||||
//console.log('Element:',element);
|
||||
//console.log(win);
|
||||
//mermaid.init();
|
||||
//render(win.document, 'myId', text, callback);
|
||||
|
||||
}
|
||||
});*/
|
||||
//var jsdom = require('jsdom').jsdom;
|
||||
//global.document = jsdom(htmlStub);
|
||||
//global.window = document.parentWindow;
|
||||
//
|
||||
//render(id, text, cb);
|
||||
//var element = win.document.createElement('div');
|
||||
//element.setAttribute('id','did');
|
||||
//document.
|
||||
// Todo handle rendering serverside using phantomjs
|
||||
}
|
||||
else{
|
||||
// In browser
|
||||
@ -22274,55 +22245,41 @@ var setConf = function(cnf){
|
||||
var lvl1Keys = Object.keys(cnf);
|
||||
var i;
|
||||
for(i=0;i<lvl1Keys.length;i++){
|
||||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j])
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
if(typeof cnf[lvl1Keys[i]] === 'object' ){
|
||||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
//console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
|
||||
if(typeof config[lvl1Keys[i]] === 'undefined'){
|
||||
|
||||
config[lvl1Keys[i]] = {};
|
||||
}
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
}
|
||||
}else{
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.initialize = function(options){
|
||||
// Update default config with options supplied at initialization
|
||||
console.log('In init:'+typeof options,JSON.stringify(options))
|
||||
if(typeof options === 'object'){
|
||||
setConf(options);
|
||||
}
|
||||
console.log('Done init:'+typeof options,JSON.stringify(config))
|
||||
|
||||
};
|
||||
|
||||
exports.getConfig = function(){
|
||||
return config;
|
||||
};
|
||||
global.mermaidAPI = {
|
||||
render : exports.render,
|
||||
render : exports.render,
|
||||
parse : exports.parse,
|
||||
initialize : exports.initialize,
|
||||
detectType: utils.detectType
|
||||
detectType : utils.detectType
|
||||
};
|
||||
|
||||
//var getBBox = function(selector){
|
||||
// var xmin, xmax, ymin, ymax,p;
|
||||
// // clean up path
|
||||
// var t = d3.select(selector).attr("d"); // get svg line's code
|
||||
// console.log(t)
|
||||
// t = t.replace(/[a-z].*/g," ") // remove relative coords, could rather tag it for later processing to absolute!
|
||||
// .replace(/[\sA-Z]+/gi," ").trim().split(" "); // remove letters and simplify spaces.
|
||||
// console.log(t)
|
||||
//
|
||||
// for(var i in t){ // set valid initial values
|
||||
// if(t[i].length>1){
|
||||
// p = t[i].split(",");
|
||||
// xmin = xmax = p[0]; ymin = ymax = p[1]; }
|
||||
// }
|
||||
// for(var i in t){ // update xmin,xmax,ymin,ymax
|
||||
// p = t[i].split(",");
|
||||
// if(!p[1]){ p[0]=xmin; p[1] = ymin;} // ignore relative jumps such h20 v-10
|
||||
// xmin = Math.min(xmin, p[0]);
|
||||
// xmax = Math.max(xmax, p[0]);
|
||||
// ymin = Math.min(ymin, p[1]);
|
||||
// ymax = Math.max(ymax, p[1]);
|
||||
// } return [[xmin,ymax],[xmax,ymin]]; // [[left, bottom], [right, top]] as for https://github.com/mbostock/d3/wiki/Geo-Paths#bounds
|
||||
//}
|
||||
//var bb = getBBox("path");
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../package.json":85,"./d3":86,"./diagrams/example/exampleDb":87,"./diagrams/example/exampleRenderer":88,"./diagrams/example/parser/example":89,"./diagrams/flowchart/flowRenderer":91,"./diagrams/flowchart/graphDb":92,"./diagrams/flowchart/parser/dot":93,"./diagrams/flowchart/parser/flow":94,"./diagrams/gantt/ganttDb":95,"./diagrams/gantt/ganttRenderer":96,"./diagrams/gantt/parser/gantt":97,"./diagrams/sequenceDiagram/parser/sequenceDiagram":98,"./diagrams/sequenceDiagram/sequenceDb":99,"./diagrams/sequenceDiagram/sequenceRenderer":100,"./utils":104}],104:[function(require,module,exports){
|
||||
/**
|
||||
|
11
dist/mermaid-legacy.slim.js
vendored
11
dist/mermaid-legacy.slim.js
vendored
@ -24950,9 +24950,9 @@ process.chdir = function (dir) {
|
||||
},{}],86:[function(require,module,exports){
|
||||
module.exports={
|
||||
"name": "mermaid",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
|
||||
"main": "src/main.js",
|
||||
"main": "src/mermaid.js",
|
||||
"keywords": [
|
||||
"diagram",
|
||||
"markdown",
|
||||
@ -25786,7 +25786,6 @@ if (!dagreD3) {
|
||||
module.exports = dagreD3;
|
||||
|
||||
},{"dagre-d3":2}],92:[function(require,module,exports){
|
||||
(function (global){
|
||||
/**
|
||||
* Created by knut on 14-12-11.
|
||||
*/
|
||||
@ -25861,7 +25860,7 @@ exports.addVertices = function (vert, g) {
|
||||
}
|
||||
|
||||
var labelTypeStr = '';
|
||||
if(global.mermaid.htmlLabels) {
|
||||
if(conf.htmlLabels) {
|
||||
labelTypeStr = 'html';
|
||||
} else {
|
||||
verticeText = verticeText.replace(/<br>/g, "\n");
|
||||
@ -25965,7 +25964,7 @@ exports.addEdges = function (edges, g) {
|
||||
else {
|
||||
var edgeText = edge.text.replace(/<br>/g, "\n");
|
||||
if(typeof edge.style === 'undefined'){
|
||||
if (global.mermaid.htmlLabels){
|
||||
if (conf.htmlLabels){
|
||||
g.setEdge(edge.start, edge.end,{labelType: "html",style: style, labelpos:'c', label: '<span style="background:#e8e8e8">'+edge.text+'</span>', arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
}else{
|
||||
g.setEdge(edge.start, edge.end,{labelType: "text", style: "stroke: #333; stroke-width: 1.5px;fill:none", labelpos:'c', label: edgeText, arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
@ -26237,14 +26236,12 @@ exports.draw = function (text, id,isDot) {
|
||||
//te.text(subGraphs[subGraphs.length-i-1].title);
|
||||
te.text(subG.title);
|
||||
|
||||
console.log('Setting subg - '+i+' to title '+subGraphs[pos].title);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../../d3":87,"./dagre-d3":91,"./graphDb":93,"./parser/dot":94,"./parser/flow":95}],93:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-11-03.
|
||||
|
4
dist/mermaid-legacy.slim.min.js
vendored
4
dist/mermaid-legacy.slim.min.js
vendored
File diff suppressed because one or more lines are too long
154
dist/mermaid.js
vendored
154
dist/mermaid.js
vendored
@ -24950,9 +24950,9 @@ process.chdir = function (dir) {
|
||||
},{}],86:[function(require,module,exports){
|
||||
module.exports={
|
||||
"name": "mermaid",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
|
||||
"main": "src/main.js",
|
||||
"main": "src/mermaid.js",
|
||||
"keywords": [
|
||||
"diagram",
|
||||
"markdown",
|
||||
@ -25786,7 +25786,6 @@ if (!dagreD3) {
|
||||
module.exports = dagreD3;
|
||||
|
||||
},{"dagre-d3":2}],92:[function(require,module,exports){
|
||||
(function (global){
|
||||
/**
|
||||
* Created by knut on 14-12-11.
|
||||
*/
|
||||
@ -25861,7 +25860,7 @@ exports.addVertices = function (vert, g) {
|
||||
}
|
||||
|
||||
var labelTypeStr = '';
|
||||
if(global.mermaid.htmlLabels) {
|
||||
if(conf.htmlLabels) {
|
||||
labelTypeStr = 'html';
|
||||
} else {
|
||||
verticeText = verticeText.replace(/<br>/g, "\n");
|
||||
@ -25965,7 +25964,7 @@ exports.addEdges = function (edges, g) {
|
||||
else {
|
||||
var edgeText = edge.text.replace(/<br>/g, "\n");
|
||||
if(typeof edge.style === 'undefined'){
|
||||
if (global.mermaid.htmlLabels){
|
||||
if (conf.htmlLabels){
|
||||
g.setEdge(edge.start, edge.end,{labelType: "html",style: style, labelpos:'c', label: '<span style="background:#e8e8e8">'+edge.text+'</span>', arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
}else{
|
||||
g.setEdge(edge.start, edge.end,{labelType: "text", style: "stroke: #333; stroke-width: 1.5px;fill:none", labelpos:'c', label: edgeText, arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
@ -26237,14 +26236,12 @@ exports.draw = function (text, id,isDot) {
|
||||
//te.text(subGraphs[subGraphs.length-i-1].title);
|
||||
te.text(subG.title);
|
||||
|
||||
console.log('Setting subg - '+i+' to title '+subGraphs[pos].title);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../../d3":87,"./dagre-d3":91,"./graphDb":93,"./parser/dot":94,"./parser/flow":95}],93:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-11-03.
|
||||
@ -31047,6 +31044,7 @@ var he = require('he');
|
||||
var mermaidAPI = require('./mermaidAPI');
|
||||
var nextId = 0;
|
||||
|
||||
module.exports.mermaidAPI = mermaidAPI;
|
||||
/**
|
||||
* Function that goes through the document to find the chart definitions in there and render them.
|
||||
*
|
||||
@ -31065,12 +31063,12 @@ var nextId = 0;
|
||||
* c-->|No |d(Transform);
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders the mermaid diagrams
|
||||
* @* param nodes- a css selector or an array of nodes
|
||||
*/
|
||||
var init = function () {
|
||||
console.log('In mermaid.init');
|
||||
var nodes;
|
||||
if(arguments.length === 2){
|
||||
// sequence config was passed as #1
|
||||
@ -31092,8 +31090,6 @@ var init = function () {
|
||||
|
||||
var i;
|
||||
|
||||
console.log('Found ',nodes.length,' nodes');
|
||||
console.log('Hooo hooo');
|
||||
if(typeof mermaid_config !== 'undefined'){
|
||||
mermaidAPI.initialize(mermaid_config);
|
||||
}
|
||||
@ -31127,14 +31123,20 @@ var init = function () {
|
||||
|
||||
exports.tester = function(){};
|
||||
|
||||
exports.init = init;
|
||||
|
||||
/**
|
||||
* Function returning version information
|
||||
* @returns {string} A string containing the version info
|
||||
*/
|
||||
exports.version = function(){
|
||||
return require('../package.json').version;
|
||||
return 'v'+require('../package.json').version;
|
||||
};
|
||||
|
||||
exports.initialize = function(config){
|
||||
mermaidAPI.initialize(config);
|
||||
}
|
||||
|
||||
var equals = function (val, variable){
|
||||
if(typeof variable === 'undefined'){
|
||||
return false;
|
||||
@ -31151,6 +31153,9 @@ global.mermaid = {
|
||||
init: function(sequenceConfig, nodes) {
|
||||
init.apply(null, arguments);
|
||||
},
|
||||
initialize: function(config) {
|
||||
mermaidAPI.initialize(config);
|
||||
},
|
||||
version: function() {
|
||||
return mermaidAPI.version();
|
||||
},
|
||||
@ -31167,10 +31172,8 @@ global.mermaid = {
|
||||
};
|
||||
|
||||
exports.contentLoaded = function(){
|
||||
console.log('Content loaded');
|
||||
// Check state of start config mermaid namespace
|
||||
console.log('Starting mermaid');
|
||||
console.log('global.mermaid.startOnLoad',global.mermaid.startOnLoad);
|
||||
console.log('mermaid_config',mermaid_config);
|
||||
if (typeof mermaid_config !== 'undefined') {
|
||||
if (equals(false, mermaid_config.htmlLabels)) {
|
||||
global.mermaid.htmlLabels = false;
|
||||
@ -31187,9 +31190,18 @@ exports.contentLoaded = function(){
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No config found, do autostart in this simple case
|
||||
// No config found, do check API config
|
||||
var config = mermaidAPI.getConfig();
|
||||
if(config.startOnLoad){
|
||||
global.mermaid.init();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
var config = mermaidAPI.getConfig();
|
||||
if(config.startOnLoad){
|
||||
global.mermaid.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
@ -31228,12 +31240,11 @@ var nextId = 0;
|
||||
|
||||
// Default options, can be overridden at initialization time
|
||||
var config = {
|
||||
mermaid:{
|
||||
cloneCssStyles: true
|
||||
},
|
||||
cloneCssStyles: true,
|
||||
flowchart:{
|
||||
// Default is to not set width
|
||||
// width: 1200
|
||||
htmlLabels:true
|
||||
},
|
||||
sequenceDiagram:{
|
||||
diagramMarginX:50,
|
||||
@ -31289,7 +31300,7 @@ var config = {
|
||||
return d.getMonth();
|
||||
}]
|
||||
] }
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Function that parses a mermaid diagram defintion. If parsing fails the parseError callback is called and an error is
|
||||
@ -31331,6 +31342,7 @@ var parse = function(text){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
exports.parse = parse;
|
||||
|
||||
/**
|
||||
* Function returning version information
|
||||
@ -31360,7 +31372,7 @@ var render = function(id, txt,cb){
|
||||
case 'graph':
|
||||
flowRenderer.setConf(config.flowchart);
|
||||
flowRenderer.draw(txt, id, false);
|
||||
if(config.mermaid.cloneCssStyles){
|
||||
if(config.cloneCssStyles){
|
||||
classes = flowRenderer.getClasses(txt, false);
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
}
|
||||
@ -31369,7 +31381,7 @@ var render = function(id, txt,cb){
|
||||
case 'dotGraph':
|
||||
flowRenderer.setConf(config.flowchart);
|
||||
flowRenderer.draw(txt, id, true);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
classes = flowRenderer.getClasses(txt, true);
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
}
|
||||
@ -31379,20 +31391,20 @@ var render = function(id, txt,cb){
|
||||
seq.setConf(config.sequenceDiagram);
|
||||
//}
|
||||
seq.draw(txt,id);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
case 'gantt':
|
||||
gantt.setConf(config.gantt);
|
||||
gantt.draw(txt,id);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
case 'info':
|
||||
info.draw(txt,id,exports.version());
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
@ -31407,45 +31419,7 @@ var render = function(id, txt,cb){
|
||||
|
||||
exports.render = function(id, text,cb){
|
||||
if(typeof document === 'undefined'){
|
||||
//jsdom = require('jsdom').jsdom;
|
||||
//console.log(jsdom);
|
||||
|
||||
//htmlStub = '<html><head></head><body><div class="mermaid">'+text+'</div><script src="dist/mermaid.full.js"></script><script>var mermaid_config = {startOnLoad:true}</script></body></html>';
|
||||
htmlStub = '<html><head></head><body></body></html>';
|
||||
// // html file skull with a container div for the d3 dataviz
|
||||
//
|
||||
// pass the html stub to jsDom
|
||||
/* jsdom.env({
|
||||
features : { QuerySelectorAll : true },
|
||||
html : htmlStub,
|
||||
done : function(errors, win) {
|
||||
// process the html document, like if we were at client side
|
||||
// code to generate the dataviz and process the resulting html file to be added here
|
||||
//var d3 = require('d3');
|
||||
//console.log('Here we go: '+JSON.stringify(d3));
|
||||
|
||||
global.document = win.document;
|
||||
global.window = win;
|
||||
|
||||
var element = win.document.createElement('div');
|
||||
element.setAttribute('id','did');
|
||||
//document.
|
||||
console.log(document.body.innerHTML);
|
||||
//console.log('Element:',element);
|
||||
//console.log(win);
|
||||
//mermaid.init();
|
||||
//render(win.document, 'myId', text, callback);
|
||||
|
||||
}
|
||||
});*/
|
||||
//var jsdom = require('jsdom').jsdom;
|
||||
//global.document = jsdom(htmlStub);
|
||||
//global.window = document.parentWindow;
|
||||
//
|
||||
//render(id, text, cb);
|
||||
//var element = win.document.createElement('div');
|
||||
//element.setAttribute('id','did');
|
||||
//document.
|
||||
// Todo handle rendering serverside using phantomjs
|
||||
}
|
||||
else{
|
||||
// In browser
|
||||
@ -31459,55 +31433,41 @@ var setConf = function(cnf){
|
||||
var lvl1Keys = Object.keys(cnf);
|
||||
var i;
|
||||
for(i=0;i<lvl1Keys.length;i++){
|
||||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j])
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
if(typeof cnf[lvl1Keys[i]] === 'object' ){
|
||||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
//console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
|
||||
if(typeof config[lvl1Keys[i]] === 'undefined'){
|
||||
|
||||
config[lvl1Keys[i]] = {};
|
||||
}
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
}
|
||||
}else{
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.initialize = function(options){
|
||||
// Update default config with options supplied at initialization
|
||||
console.log('In init:'+typeof options,JSON.stringify(options))
|
||||
if(typeof options === 'object'){
|
||||
setConf(options);
|
||||
}
|
||||
console.log('Done init:'+typeof options,JSON.stringify(config))
|
||||
|
||||
};
|
||||
|
||||
exports.getConfig = function(){
|
||||
return config;
|
||||
};
|
||||
global.mermaidAPI = {
|
||||
render : exports.render,
|
||||
render : exports.render,
|
||||
parse : exports.parse,
|
||||
initialize : exports.initialize,
|
||||
detectType: utils.detectType
|
||||
detectType : utils.detectType
|
||||
};
|
||||
|
||||
//var getBBox = function(selector){
|
||||
// var xmin, xmax, ymin, ymax,p;
|
||||
// // clean up path
|
||||
// var t = d3.select(selector).attr("d"); // get svg line's code
|
||||
// console.log(t)
|
||||
// t = t.replace(/[a-z].*/g," ") // remove relative coords, could rather tag it for later processing to absolute!
|
||||
// .replace(/[\sA-Z]+/gi," ").trim().split(" "); // remove letters and simplify spaces.
|
||||
// console.log(t)
|
||||
//
|
||||
// for(var i in t){ // set valid initial values
|
||||
// if(t[i].length>1){
|
||||
// p = t[i].split(",");
|
||||
// xmin = xmax = p[0]; ymin = ymax = p[1]; }
|
||||
// }
|
||||
// for(var i in t){ // update xmin,xmax,ymin,ymax
|
||||
// p = t[i].split(",");
|
||||
// if(!p[1]){ p[0]=xmin; p[1] = ymin;} // ignore relative jumps such h20 v-10
|
||||
// xmin = Math.min(xmin, p[0]);
|
||||
// xmax = Math.max(xmax, p[0]);
|
||||
// ymin = Math.min(ymin, p[1]);
|
||||
// ymax = Math.max(ymax, p[1]);
|
||||
// } return [[xmin,ymax],[xmax,ymin]]; // [[left, bottom], [right, top]] as for https://github.com/mbostock/d3/wiki/Geo-Paths#bounds
|
||||
//}
|
||||
//var bb = getBBox("path");
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../package.json":86,"./d3":87,"./diagrams/example/exampleDb":88,"./diagrams/example/exampleRenderer":89,"./diagrams/example/parser/example":90,"./diagrams/flowchart/flowRenderer":92,"./diagrams/flowchart/graphDb":93,"./diagrams/flowchart/parser/dot":94,"./diagrams/flowchart/parser/flow":95,"./diagrams/gantt/ganttDb":96,"./diagrams/gantt/ganttRenderer":97,"./diagrams/gantt/parser/gantt":98,"./diagrams/sequenceDiagram/parser/sequenceDiagram":99,"./diagrams/sequenceDiagram/sequenceDb":100,"./diagrams/sequenceDiagram/sequenceRenderer":101,"./utils":105}],105:[function(require,module,exports){
|
||||
/**
|
||||
|
24
dist/mermaid.min.js
vendored
24
dist/mermaid.min.js
vendored
File diff suppressed because one or more lines are too long
154
dist/mermaid.slim.js
vendored
154
dist/mermaid.slim.js
vendored
@ -15734,9 +15734,9 @@ process.chdir = function (dir) {
|
||||
},{}],85:[function(require,module,exports){
|
||||
module.exports={
|
||||
"name": "mermaid",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
|
||||
"main": "src/main.js",
|
||||
"main": "src/mermaid.js",
|
||||
"keywords": [
|
||||
"diagram",
|
||||
"markdown",
|
||||
@ -16570,7 +16570,6 @@ if (!dagreD3) {
|
||||
module.exports = dagreD3;
|
||||
|
||||
},{"dagre-d3":1}],91:[function(require,module,exports){
|
||||
(function (global){
|
||||
/**
|
||||
* Created by knut on 14-12-11.
|
||||
*/
|
||||
@ -16645,7 +16644,7 @@ exports.addVertices = function (vert, g) {
|
||||
}
|
||||
|
||||
var labelTypeStr = '';
|
||||
if(global.mermaid.htmlLabels) {
|
||||
if(conf.htmlLabels) {
|
||||
labelTypeStr = 'html';
|
||||
} else {
|
||||
verticeText = verticeText.replace(/<br>/g, "\n");
|
||||
@ -16749,7 +16748,7 @@ exports.addEdges = function (edges, g) {
|
||||
else {
|
||||
var edgeText = edge.text.replace(/<br>/g, "\n");
|
||||
if(typeof edge.style === 'undefined'){
|
||||
if (global.mermaid.htmlLabels){
|
||||
if (conf.htmlLabels){
|
||||
g.setEdge(edge.start, edge.end,{labelType: "html",style: style, labelpos:'c', label: '<span style="background:#e8e8e8">'+edge.text+'</span>', arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
}else{
|
||||
g.setEdge(edge.start, edge.end,{labelType: "text", style: "stroke: #333; stroke-width: 1.5px;fill:none", labelpos:'c', label: edgeText, arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
@ -17021,14 +17020,12 @@ exports.draw = function (text, id,isDot) {
|
||||
//te.text(subGraphs[subGraphs.length-i-1].title);
|
||||
te.text(subG.title);
|
||||
|
||||
console.log('Setting subg - '+i+' to title '+subGraphs[pos].title);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../../d3":86,"./dagre-d3":90,"./graphDb":92,"./parser/dot":93,"./parser/flow":94}],92:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-11-03.
|
||||
@ -21831,6 +21828,7 @@ var he = require('he');
|
||||
var mermaidAPI = require('./mermaidAPI');
|
||||
var nextId = 0;
|
||||
|
||||
module.exports.mermaidAPI = mermaidAPI;
|
||||
/**
|
||||
* Function that goes through the document to find the chart definitions in there and render them.
|
||||
*
|
||||
@ -21849,12 +21847,12 @@ var nextId = 0;
|
||||
* c-->|No |d(Transform);
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders the mermaid diagrams
|
||||
* @* param nodes- a css selector or an array of nodes
|
||||
*/
|
||||
var init = function () {
|
||||
console.log('In mermaid.init');
|
||||
var nodes;
|
||||
if(arguments.length === 2){
|
||||
// sequence config was passed as #1
|
||||
@ -21876,8 +21874,6 @@ var init = function () {
|
||||
|
||||
var i;
|
||||
|
||||
console.log('Found ',nodes.length,' nodes');
|
||||
console.log('Hooo hooo');
|
||||
if(typeof mermaid_config !== 'undefined'){
|
||||
mermaidAPI.initialize(mermaid_config);
|
||||
}
|
||||
@ -21911,14 +21907,20 @@ var init = function () {
|
||||
|
||||
exports.tester = function(){};
|
||||
|
||||
exports.init = init;
|
||||
|
||||
/**
|
||||
* Function returning version information
|
||||
* @returns {string} A string containing the version info
|
||||
*/
|
||||
exports.version = function(){
|
||||
return require('../package.json').version;
|
||||
return 'v'+require('../package.json').version;
|
||||
};
|
||||
|
||||
exports.initialize = function(config){
|
||||
mermaidAPI.initialize(config);
|
||||
}
|
||||
|
||||
var equals = function (val, variable){
|
||||
if(typeof variable === 'undefined'){
|
||||
return false;
|
||||
@ -21935,6 +21937,9 @@ global.mermaid = {
|
||||
init: function(sequenceConfig, nodes) {
|
||||
init.apply(null, arguments);
|
||||
},
|
||||
initialize: function(config) {
|
||||
mermaidAPI.initialize(config);
|
||||
},
|
||||
version: function() {
|
||||
return mermaidAPI.version();
|
||||
},
|
||||
@ -21951,10 +21956,8 @@ global.mermaid = {
|
||||
};
|
||||
|
||||
exports.contentLoaded = function(){
|
||||
console.log('Content loaded');
|
||||
// Check state of start config mermaid namespace
|
||||
console.log('Starting mermaid');
|
||||
console.log('global.mermaid.startOnLoad',global.mermaid.startOnLoad);
|
||||
console.log('mermaid_config',mermaid_config);
|
||||
if (typeof mermaid_config !== 'undefined') {
|
||||
if (equals(false, mermaid_config.htmlLabels)) {
|
||||
global.mermaid.htmlLabels = false;
|
||||
@ -21971,9 +21974,18 @@ exports.contentLoaded = function(){
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No config found, do autostart in this simple case
|
||||
// No config found, do check API config
|
||||
var config = mermaidAPI.getConfig();
|
||||
if(config.startOnLoad){
|
||||
global.mermaid.init();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
var config = mermaidAPI.getConfig();
|
||||
if(config.startOnLoad){
|
||||
global.mermaid.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
@ -22012,12 +22024,11 @@ var nextId = 0;
|
||||
|
||||
// Default options, can be overridden at initialization time
|
||||
var config = {
|
||||
mermaid:{
|
||||
cloneCssStyles: true
|
||||
},
|
||||
cloneCssStyles: true,
|
||||
flowchart:{
|
||||
// Default is to not set width
|
||||
// width: 1200
|
||||
htmlLabels:true
|
||||
},
|
||||
sequenceDiagram:{
|
||||
diagramMarginX:50,
|
||||
@ -22073,7 +22084,7 @@ var config = {
|
||||
return d.getMonth();
|
||||
}]
|
||||
] }
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Function that parses a mermaid diagram defintion. If parsing fails the parseError callback is called and an error is
|
||||
@ -22115,6 +22126,7 @@ var parse = function(text){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
exports.parse = parse;
|
||||
|
||||
/**
|
||||
* Function returning version information
|
||||
@ -22144,7 +22156,7 @@ var render = function(id, txt,cb){
|
||||
case 'graph':
|
||||
flowRenderer.setConf(config.flowchart);
|
||||
flowRenderer.draw(txt, id, false);
|
||||
if(config.mermaid.cloneCssStyles){
|
||||
if(config.cloneCssStyles){
|
||||
classes = flowRenderer.getClasses(txt, false);
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
}
|
||||
@ -22153,7 +22165,7 @@ var render = function(id, txt,cb){
|
||||
case 'dotGraph':
|
||||
flowRenderer.setConf(config.flowchart);
|
||||
flowRenderer.draw(txt, id, true);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
classes = flowRenderer.getClasses(txt, true);
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
}
|
||||
@ -22163,20 +22175,20 @@ var render = function(id, txt,cb){
|
||||
seq.setConf(config.sequenceDiagram);
|
||||
//}
|
||||
seq.draw(txt,id);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
case 'gantt':
|
||||
gantt.setConf(config.gantt);
|
||||
gantt.draw(txt,id);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
case 'info':
|
||||
info.draw(txt,id,exports.version());
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
@ -22191,45 +22203,7 @@ var render = function(id, txt,cb){
|
||||
|
||||
exports.render = function(id, text,cb){
|
||||
if(typeof document === 'undefined'){
|
||||
//jsdom = require('jsdom').jsdom;
|
||||
//console.log(jsdom);
|
||||
|
||||
//htmlStub = '<html><head></head><body><div class="mermaid">'+text+'</div><script src="dist/mermaid.full.js"></script><script>var mermaid_config = {startOnLoad:true}</script></body></html>';
|
||||
htmlStub = '<html><head></head><body></body></html>';
|
||||
// // html file skull with a container div for the d3 dataviz
|
||||
//
|
||||
// pass the html stub to jsDom
|
||||
/* jsdom.env({
|
||||
features : { QuerySelectorAll : true },
|
||||
html : htmlStub,
|
||||
done : function(errors, win) {
|
||||
// process the html document, like if we were at client side
|
||||
// code to generate the dataviz and process the resulting html file to be added here
|
||||
//var d3 = require('d3');
|
||||
//console.log('Here we go: '+JSON.stringify(d3));
|
||||
|
||||
global.document = win.document;
|
||||
global.window = win;
|
||||
|
||||
var element = win.document.createElement('div');
|
||||
element.setAttribute('id','did');
|
||||
//document.
|
||||
console.log(document.body.innerHTML);
|
||||
//console.log('Element:',element);
|
||||
//console.log(win);
|
||||
//mermaid.init();
|
||||
//render(win.document, 'myId', text, callback);
|
||||
|
||||
}
|
||||
});*/
|
||||
//var jsdom = require('jsdom').jsdom;
|
||||
//global.document = jsdom(htmlStub);
|
||||
//global.window = document.parentWindow;
|
||||
//
|
||||
//render(id, text, cb);
|
||||
//var element = win.document.createElement('div');
|
||||
//element.setAttribute('id','did');
|
||||
//document.
|
||||
// Todo handle rendering serverside using phantomjs
|
||||
}
|
||||
else{
|
||||
// In browser
|
||||
@ -22243,55 +22217,41 @@ var setConf = function(cnf){
|
||||
var lvl1Keys = Object.keys(cnf);
|
||||
var i;
|
||||
for(i=0;i<lvl1Keys.length;i++){
|
||||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j])
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
if(typeof cnf[lvl1Keys[i]] === 'object' ){
|
||||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
//console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
|
||||
if(typeof config[lvl1Keys[i]] === 'undefined'){
|
||||
|
||||
config[lvl1Keys[i]] = {};
|
||||
}
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
}
|
||||
}else{
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.initialize = function(options){
|
||||
// Update default config with options supplied at initialization
|
||||
console.log('In init:'+typeof options,JSON.stringify(options))
|
||||
if(typeof options === 'object'){
|
||||
setConf(options);
|
||||
}
|
||||
console.log('Done init:'+typeof options,JSON.stringify(config))
|
||||
|
||||
};
|
||||
|
||||
exports.getConfig = function(){
|
||||
return config;
|
||||
};
|
||||
global.mermaidAPI = {
|
||||
render : exports.render,
|
||||
render : exports.render,
|
||||
parse : exports.parse,
|
||||
initialize : exports.initialize,
|
||||
detectType: utils.detectType
|
||||
detectType : utils.detectType
|
||||
};
|
||||
|
||||
//var getBBox = function(selector){
|
||||
// var xmin, xmax, ymin, ymax,p;
|
||||
// // clean up path
|
||||
// var t = d3.select(selector).attr("d"); // get svg line's code
|
||||
// console.log(t)
|
||||
// t = t.replace(/[a-z].*/g," ") // remove relative coords, could rather tag it for later processing to absolute!
|
||||
// .replace(/[\sA-Z]+/gi," ").trim().split(" "); // remove letters and simplify spaces.
|
||||
// console.log(t)
|
||||
//
|
||||
// for(var i in t){ // set valid initial values
|
||||
// if(t[i].length>1){
|
||||
// p = t[i].split(",");
|
||||
// xmin = xmax = p[0]; ymin = ymax = p[1]; }
|
||||
// }
|
||||
// for(var i in t){ // update xmin,xmax,ymin,ymax
|
||||
// p = t[i].split(",");
|
||||
// if(!p[1]){ p[0]=xmin; p[1] = ymin;} // ignore relative jumps such h20 v-10
|
||||
// xmin = Math.min(xmin, p[0]);
|
||||
// xmax = Math.max(xmax, p[0]);
|
||||
// ymin = Math.min(ymin, p[1]);
|
||||
// ymax = Math.max(ymax, p[1]);
|
||||
// } return [[xmin,ymax],[xmax,ymin]]; // [[left, bottom], [right, top]] as for https://github.com/mbostock/d3/wiki/Geo-Paths#bounds
|
||||
//}
|
||||
//var bb = getBBox("path");
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../package.json":85,"./d3":86,"./diagrams/example/exampleDb":87,"./diagrams/example/exampleRenderer":88,"./diagrams/example/parser/example":89,"./diagrams/flowchart/flowRenderer":91,"./diagrams/flowchart/graphDb":92,"./diagrams/flowchart/parser/dot":93,"./diagrams/flowchart/parser/flow":94,"./diagrams/gantt/ganttDb":95,"./diagrams/gantt/ganttRenderer":96,"./diagrams/gantt/parser/gantt":97,"./diagrams/sequenceDiagram/parser/sequenceDiagram":98,"./diagrams/sequenceDiagram/sequenceDb":99,"./diagrams/sequenceDiagram/sequenceRenderer":100,"./utils":104}],104:[function(require,module,exports){
|
||||
/**
|
||||
|
10
dist/mermaid.slim.min.js
vendored
10
dist/mermaid.slim.min.js
vendored
File diff suppressed because one or more lines are too long
123
dist/mermaidAPI.js
vendored
123
dist/mermaidAPI.js
vendored
@ -24617,9 +24617,9 @@ process.chdir = function (dir) {
|
||||
},{}],85:[function(require,module,exports){
|
||||
module.exports={
|
||||
"name": "mermaid",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
|
||||
"main": "src/main.js",
|
||||
"main": "src/mermaid.js",
|
||||
"keywords": [
|
||||
"diagram",
|
||||
"markdown",
|
||||
@ -25453,7 +25453,6 @@ if (!dagreD3) {
|
||||
module.exports = dagreD3;
|
||||
|
||||
},{"dagre-d3":2}],91:[function(require,module,exports){
|
||||
(function (global){
|
||||
/**
|
||||
* Created by knut on 14-12-11.
|
||||
*/
|
||||
@ -25528,7 +25527,7 @@ exports.addVertices = function (vert, g) {
|
||||
}
|
||||
|
||||
var labelTypeStr = '';
|
||||
if(global.mermaid.htmlLabels) {
|
||||
if(conf.htmlLabels) {
|
||||
labelTypeStr = 'html';
|
||||
} else {
|
||||
verticeText = verticeText.replace(/<br>/g, "\n");
|
||||
@ -25632,7 +25631,7 @@ exports.addEdges = function (edges, g) {
|
||||
else {
|
||||
var edgeText = edge.text.replace(/<br>/g, "\n");
|
||||
if(typeof edge.style === 'undefined'){
|
||||
if (global.mermaid.htmlLabels){
|
||||
if (conf.htmlLabels){
|
||||
g.setEdge(edge.start, edge.end,{labelType: "html",style: style, labelpos:'c', label: '<span style="background:#e8e8e8">'+edge.text+'</span>', arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
}else{
|
||||
g.setEdge(edge.start, edge.end,{labelType: "text", style: "stroke: #333; stroke-width: 1.5px;fill:none", labelpos:'c', label: edgeText, arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
@ -25904,14 +25903,12 @@ exports.draw = function (text, id,isDot) {
|
||||
//te.text(subGraphs[subGraphs.length-i-1].title);
|
||||
te.text(subG.title);
|
||||
|
||||
console.log('Setting subg - '+i+' to title '+subGraphs[pos].title);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../../d3":86,"./dagre-d3":90,"./graphDb":92,"./parser/dot":93,"./parser/flow":94}],92:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-11-03.
|
||||
@ -30730,12 +30727,11 @@ var nextId = 0;
|
||||
|
||||
// Default options, can be overridden at initialization time
|
||||
var config = {
|
||||
mermaid:{
|
||||
cloneCssStyles: true
|
||||
},
|
||||
cloneCssStyles: true,
|
||||
flowchart:{
|
||||
// Default is to not set width
|
||||
// width: 1200
|
||||
htmlLabels:true
|
||||
},
|
||||
sequenceDiagram:{
|
||||
diagramMarginX:50,
|
||||
@ -30791,7 +30787,7 @@ var config = {
|
||||
return d.getMonth();
|
||||
}]
|
||||
] }
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Function that parses a mermaid diagram defintion. If parsing fails the parseError callback is called and an error is
|
||||
@ -30833,6 +30829,7 @@ var parse = function(text){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
exports.parse = parse;
|
||||
|
||||
/**
|
||||
* Function returning version information
|
||||
@ -30862,7 +30859,7 @@ var render = function(id, txt,cb){
|
||||
case 'graph':
|
||||
flowRenderer.setConf(config.flowchart);
|
||||
flowRenderer.draw(txt, id, false);
|
||||
if(config.mermaid.cloneCssStyles){
|
||||
if(config.cloneCssStyles){
|
||||
classes = flowRenderer.getClasses(txt, false);
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
}
|
||||
@ -30871,7 +30868,7 @@ var render = function(id, txt,cb){
|
||||
case 'dotGraph':
|
||||
flowRenderer.setConf(config.flowchart);
|
||||
flowRenderer.draw(txt, id, true);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
classes = flowRenderer.getClasses(txt, true);
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
}
|
||||
@ -30881,20 +30878,20 @@ var render = function(id, txt,cb){
|
||||
seq.setConf(config.sequenceDiagram);
|
||||
//}
|
||||
seq.draw(txt,id);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
case 'gantt':
|
||||
gantt.setConf(config.gantt);
|
||||
gantt.draw(txt,id);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
case 'info':
|
||||
info.draw(txt,id,exports.version());
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
@ -30909,45 +30906,7 @@ var render = function(id, txt,cb){
|
||||
|
||||
exports.render = function(id, text,cb){
|
||||
if(typeof document === 'undefined'){
|
||||
//jsdom = require('jsdom').jsdom;
|
||||
//console.log(jsdom);
|
||||
|
||||
//htmlStub = '<html><head></head><body><div class="mermaid">'+text+'</div><script src="dist/mermaid.full.js"></script><script>var mermaid_config = {startOnLoad:true}</script></body></html>';
|
||||
htmlStub = '<html><head></head><body></body></html>';
|
||||
// // html file skull with a container div for the d3 dataviz
|
||||
//
|
||||
// pass the html stub to jsDom
|
||||
/* jsdom.env({
|
||||
features : { QuerySelectorAll : true },
|
||||
html : htmlStub,
|
||||
done : function(errors, win) {
|
||||
// process the html document, like if we were at client side
|
||||
// code to generate the dataviz and process the resulting html file to be added here
|
||||
//var d3 = require('d3');
|
||||
//console.log('Here we go: '+JSON.stringify(d3));
|
||||
|
||||
global.document = win.document;
|
||||
global.window = win;
|
||||
|
||||
var element = win.document.createElement('div');
|
||||
element.setAttribute('id','did');
|
||||
//document.
|
||||
console.log(document.body.innerHTML);
|
||||
//console.log('Element:',element);
|
||||
//console.log(win);
|
||||
//mermaid.init();
|
||||
//render(win.document, 'myId', text, callback);
|
||||
|
||||
}
|
||||
});*/
|
||||
//var jsdom = require('jsdom').jsdom;
|
||||
//global.document = jsdom(htmlStub);
|
||||
//global.window = document.parentWindow;
|
||||
//
|
||||
//render(id, text, cb);
|
||||
//var element = win.document.createElement('div');
|
||||
//element.setAttribute('id','did');
|
||||
//document.
|
||||
// Todo handle rendering serverside using phantomjs
|
||||
}
|
||||
else{
|
||||
// In browser
|
||||
@ -30961,55 +30920,41 @@ var setConf = function(cnf){
|
||||
var lvl1Keys = Object.keys(cnf);
|
||||
var i;
|
||||
for(i=0;i<lvl1Keys.length;i++){
|
||||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j])
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
if(typeof cnf[lvl1Keys[i]] === 'object' ){
|
||||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
//console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
|
||||
if(typeof config[lvl1Keys[i]] === 'undefined'){
|
||||
|
||||
config[lvl1Keys[i]] = {};
|
||||
}
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
}
|
||||
}else{
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.initialize = function(options){
|
||||
// Update default config with options supplied at initialization
|
||||
console.log('In init:'+typeof options,JSON.stringify(options))
|
||||
if(typeof options === 'object'){
|
||||
setConf(options);
|
||||
}
|
||||
console.log('Done init:'+typeof options,JSON.stringify(config))
|
||||
|
||||
};
|
||||
|
||||
exports.getConfig = function(){
|
||||
return config;
|
||||
};
|
||||
global.mermaidAPI = {
|
||||
render : exports.render,
|
||||
render : exports.render,
|
||||
parse : exports.parse,
|
||||
initialize : exports.initialize,
|
||||
detectType: utils.detectType
|
||||
detectType : utils.detectType
|
||||
};
|
||||
|
||||
//var getBBox = function(selector){
|
||||
// var xmin, xmax, ymin, ymax,p;
|
||||
// // clean up path
|
||||
// var t = d3.select(selector).attr("d"); // get svg line's code
|
||||
// console.log(t)
|
||||
// t = t.replace(/[a-z].*/g," ") // remove relative coords, could rather tag it for later processing to absolute!
|
||||
// .replace(/[\sA-Z]+/gi," ").trim().split(" "); // remove letters and simplify spaces.
|
||||
// console.log(t)
|
||||
//
|
||||
// for(var i in t){ // set valid initial values
|
||||
// if(t[i].length>1){
|
||||
// p = t[i].split(",");
|
||||
// xmin = xmax = p[0]; ymin = ymax = p[1]; }
|
||||
// }
|
||||
// for(var i in t){ // update xmin,xmax,ymin,ymax
|
||||
// p = t[i].split(",");
|
||||
// if(!p[1]){ p[0]=xmin; p[1] = ymin;} // ignore relative jumps such h20 v-10
|
||||
// xmin = Math.min(xmin, p[0]);
|
||||
// xmax = Math.max(xmax, p[0]);
|
||||
// ymin = Math.min(ymin, p[1]);
|
||||
// ymax = Math.max(ymax, p[1]);
|
||||
// } return [[xmin,ymax],[xmax,ymin]]; // [[left, bottom], [right, top]] as for https://github.com/mbostock/d3/wiki/Geo-Paths#bounds
|
||||
//}
|
||||
//var bb = getBBox("path");
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../package.json":85,"./d3":86,"./diagrams/example/exampleDb":87,"./diagrams/example/exampleRenderer":88,"./diagrams/example/parser/example":89,"./diagrams/flowchart/flowRenderer":91,"./diagrams/flowchart/graphDb":92,"./diagrams/flowchart/parser/dot":93,"./diagrams/flowchart/parser/flow":94,"./diagrams/gantt/ganttDb":95,"./diagrams/gantt/ganttRenderer":96,"./diagrams/gantt/parser/gantt":97,"./diagrams/sequenceDiagram/parser/sequenceDiagram":98,"./diagrams/sequenceDiagram/sequenceDb":99,"./diagrams/sequenceDiagram/sequenceRenderer":100,"./utils":103}],103:[function(require,module,exports){
|
||||
/**
|
||||
|
125
dist/mermaidAPI.slim.js
vendored
125
dist/mermaidAPI.slim.js
vendored
File diff suppressed because one or more lines are too long
8
dist/mermaidAPI.slim.min.js
vendored
8
dist/mermaidAPI.slim.min.js
vendored
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
||||
"name": "mermaid",
|
||||
"version": "0.4.0",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
|
||||
"main": "src/main.js",
|
||||
"main": "src/mermaid.js",
|
||||
"keywords": [
|
||||
"diagram",
|
||||
"markdown",
|
||||
|
@ -72,7 +72,7 @@ exports.addVertices = function (vert, g) {
|
||||
}
|
||||
|
||||
var labelTypeStr = '';
|
||||
if(global.mermaid.htmlLabels) {
|
||||
if(conf.htmlLabels) {
|
||||
labelTypeStr = 'html';
|
||||
} else {
|
||||
verticeText = verticeText.replace(/<br>/g, "\n");
|
||||
@ -176,7 +176,7 @@ exports.addEdges = function (edges, g) {
|
||||
else {
|
||||
var edgeText = edge.text.replace(/<br>/g, "\n");
|
||||
if(typeof edge.style === 'undefined'){
|
||||
if (global.mermaid.htmlLabels){
|
||||
if (conf.htmlLabels){
|
||||
g.setEdge(edge.start, edge.end,{labelType: "html",style: style, labelpos:'c', label: '<span style="background:#e8e8e8">'+edge.text+'</span>', arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
}else{
|
||||
g.setEdge(edge.start, edge.end,{labelType: "text", style: "stroke: #333; stroke-width: 1.5px;fill:none", labelpos:'c', label: edgeText, arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
||||
@ -448,7 +448,6 @@ exports.draw = function (text, id,isDot) {
|
||||
//te.text(subGraphs[subGraphs.length-i-1].title);
|
||||
te.text(subG.title);
|
||||
|
||||
console.log('Setting subg - '+i+' to title '+subGraphs[pos].title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
src/index.js
Normal file
5
src/index.js
Normal file
@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Created by knut on 2015-06-06.
|
||||
*/
|
||||
module.exports.mermaid = require('./mermaid.js');
|
||||
module.exports.mermaidAPI = require('./mermaidAPI.js');
|
@ -2,6 +2,7 @@ var he = require('he');
|
||||
var mermaidAPI = require('./mermaidAPI');
|
||||
var nextId = 0;
|
||||
|
||||
module.exports.mermaidAPI = mermaidAPI;
|
||||
/**
|
||||
* Function that goes through the document to find the chart definitions in there and render them.
|
||||
*
|
||||
@ -20,12 +21,12 @@ var nextId = 0;
|
||||
* c-->|No |d(Transform);
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders the mermaid diagrams
|
||||
* @* param nodes- a css selector or an array of nodes
|
||||
*/
|
||||
var init = function () {
|
||||
console.log('In mermaid.init');
|
||||
var nodes;
|
||||
if(arguments.length === 2){
|
||||
// sequence config was passed as #1
|
||||
@ -47,8 +48,6 @@ var init = function () {
|
||||
|
||||
var i;
|
||||
|
||||
console.log('Found ',nodes.length,' nodes');
|
||||
console.log('Hooo hooo');
|
||||
if(typeof mermaid_config !== 'undefined'){
|
||||
mermaidAPI.initialize(mermaid_config);
|
||||
}
|
||||
@ -82,14 +81,20 @@ var init = function () {
|
||||
|
||||
exports.tester = function(){};
|
||||
|
||||
exports.init = init;
|
||||
|
||||
/**
|
||||
* Function returning version information
|
||||
* @returns {string} A string containing the version info
|
||||
*/
|
||||
exports.version = function(){
|
||||
return require('../package.json').version;
|
||||
return 'v'+require('../package.json').version;
|
||||
};
|
||||
|
||||
exports.initialize = function(config){
|
||||
mermaidAPI.initialize(config);
|
||||
}
|
||||
|
||||
var equals = function (val, variable){
|
||||
if(typeof variable === 'undefined'){
|
||||
return false;
|
||||
@ -106,6 +111,9 @@ global.mermaid = {
|
||||
init: function(sequenceConfig, nodes) {
|
||||
init.apply(null, arguments);
|
||||
},
|
||||
initialize: function(config) {
|
||||
mermaidAPI.initialize(config);
|
||||
},
|
||||
version: function() {
|
||||
return mermaidAPI.version();
|
||||
},
|
||||
@ -122,10 +130,8 @@ global.mermaid = {
|
||||
};
|
||||
|
||||
exports.contentLoaded = function(){
|
||||
console.log('Content loaded');
|
||||
// Check state of start config mermaid namespace
|
||||
console.log('Starting mermaid');
|
||||
console.log('global.mermaid.startOnLoad',global.mermaid.startOnLoad);
|
||||
console.log('mermaid_config',mermaid_config);
|
||||
if (typeof mermaid_config !== 'undefined') {
|
||||
if (equals(false, mermaid_config.htmlLabels)) {
|
||||
global.mermaid.htmlLabels = false;
|
||||
@ -142,9 +148,18 @@ exports.contentLoaded = function(){
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No config found, do autostart in this simple case
|
||||
// No config found, do check API config
|
||||
var config = mermaidAPI.getConfig();
|
||||
if(config.startOnLoad){
|
||||
global.mermaid.init();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
var config = mermaidAPI.getConfig();
|
||||
if(config.startOnLoad){
|
||||
global.mermaid.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -18,12 +18,11 @@ var nextId = 0;
|
||||
|
||||
// Default options, can be overridden at initialization time
|
||||
var config = {
|
||||
mermaid:{
|
||||
cloneCssStyles: true
|
||||
},
|
||||
cloneCssStyles: true,
|
||||
flowchart:{
|
||||
// Default is to not set width
|
||||
// width: 1200
|
||||
htmlLabels:true
|
||||
},
|
||||
sequenceDiagram:{
|
||||
diagramMarginX:50,
|
||||
@ -79,7 +78,7 @@ var config = {
|
||||
return d.getMonth();
|
||||
}]
|
||||
] }
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Function that parses a mermaid diagram defintion. If parsing fails the parseError callback is called and an error is
|
||||
@ -121,6 +120,7 @@ var parse = function(text){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
exports.parse = parse;
|
||||
|
||||
/**
|
||||
* Function returning version information
|
||||
@ -150,7 +150,7 @@ var render = function(id, txt,cb){
|
||||
case 'graph':
|
||||
flowRenderer.setConf(config.flowchart);
|
||||
flowRenderer.draw(txt, id, false);
|
||||
if(config.mermaid.cloneCssStyles){
|
||||
if(config.cloneCssStyles){
|
||||
classes = flowRenderer.getClasses(txt, false);
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
}
|
||||
@ -159,7 +159,7 @@ var render = function(id, txt,cb){
|
||||
case 'dotGraph':
|
||||
flowRenderer.setConf(config.flowchart);
|
||||
flowRenderer.draw(txt, id, true);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
classes = flowRenderer.getClasses(txt, true);
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
}
|
||||
@ -169,20 +169,20 @@ var render = function(id, txt,cb){
|
||||
seq.setConf(config.sequenceDiagram);
|
||||
//}
|
||||
seq.draw(txt,id);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
case 'gantt':
|
||||
gantt.setConf(config.gantt);
|
||||
gantt.draw(txt,id);
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
case 'info':
|
||||
info.draw(txt,id,exports.version());
|
||||
if(config.mermaid.cloneCssStyles) {
|
||||
if(config.cloneCssStyles) {
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
}
|
||||
break;
|
||||
@ -197,45 +197,7 @@ var render = function(id, txt,cb){
|
||||
|
||||
exports.render = function(id, text,cb){
|
||||
if(typeof document === 'undefined'){
|
||||
//jsdom = require('jsdom').jsdom;
|
||||
//console.log(jsdom);
|
||||
|
||||
//htmlStub = '<html><head></head><body><div class="mermaid">'+text+'</div><script src="dist/mermaid.full.js"></script><script>var mermaid_config = {startOnLoad:true}</script></body></html>';
|
||||
htmlStub = '<html><head></head><body></body></html>';
|
||||
// // html file skull with a container div for the d3 dataviz
|
||||
//
|
||||
// pass the html stub to jsDom
|
||||
/* jsdom.env({
|
||||
features : { QuerySelectorAll : true },
|
||||
html : htmlStub,
|
||||
done : function(errors, win) {
|
||||
// process the html document, like if we were at client side
|
||||
// code to generate the dataviz and process the resulting html file to be added here
|
||||
//var d3 = require('d3');
|
||||
//console.log('Here we go: '+JSON.stringify(d3));
|
||||
|
||||
global.document = win.document;
|
||||
global.window = win;
|
||||
|
||||
var element = win.document.createElement('div');
|
||||
element.setAttribute('id','did');
|
||||
//document.
|
||||
console.log(document.body.innerHTML);
|
||||
//console.log('Element:',element);
|
||||
//console.log(win);
|
||||
//mermaid.init();
|
||||
//render(win.document, 'myId', text, callback);
|
||||
|
||||
}
|
||||
});*/
|
||||
//var jsdom = require('jsdom').jsdom;
|
||||
//global.document = jsdom(htmlStub);
|
||||
//global.window = document.parentWindow;
|
||||
//
|
||||
//render(id, text, cb);
|
||||
//var element = win.document.createElement('div');
|
||||
//element.setAttribute('id','did');
|
||||
//document.
|
||||
// Todo handle rendering serverside using phantomjs
|
||||
}
|
||||
else{
|
||||
// In browser
|
||||
@ -249,52 +211,37 @@ var setConf = function(cnf){
|
||||
var lvl1Keys = Object.keys(cnf);
|
||||
var i;
|
||||
for(i=0;i<lvl1Keys.length;i++){
|
||||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j])
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
if(typeof cnf[lvl1Keys[i]] === 'object' ){
|
||||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
//console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
|
||||
if(typeof config[lvl1Keys[i]] === 'undefined'){
|
||||
|
||||
config[lvl1Keys[i]] = {};
|
||||
}
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
}
|
||||
}else{
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.initialize = function(options){
|
||||
// Update default config with options supplied at initialization
|
||||
console.log('In init:'+typeof options,JSON.stringify(options))
|
||||
if(typeof options === 'object'){
|
||||
setConf(options);
|
||||
}
|
||||
console.log('Done init:'+typeof options,JSON.stringify(config))
|
||||
|
||||
};
|
||||
|
||||
exports.getConfig = function(){
|
||||
return config;
|
||||
};
|
||||
global.mermaidAPI = {
|
||||
render : exports.render,
|
||||
render : exports.render,
|
||||
parse : exports.parse,
|
||||
initialize : exports.initialize,
|
||||
detectType: utils.detectType
|
||||
detectType : utils.detectType
|
||||
};
|
||||
|
||||
//var getBBox = function(selector){
|
||||
// var xmin, xmax, ymin, ymax,p;
|
||||
// // clean up path
|
||||
// var t = d3.select(selector).attr("d"); // get svg line's code
|
||||
// console.log(t)
|
||||
// t = t.replace(/[a-z].*/g," ") // remove relative coords, could rather tag it for later processing to absolute!
|
||||
// .replace(/[\sA-Z]+/gi," ").trim().split(" "); // remove letters and simplify spaces.
|
||||
// console.log(t)
|
||||
//
|
||||
// for(var i in t){ // set valid initial values
|
||||
// if(t[i].length>1){
|
||||
// p = t[i].split(",");
|
||||
// xmin = xmax = p[0]; ymin = ymax = p[1]; }
|
||||
// }
|
||||
// for(var i in t){ // update xmin,xmax,ymin,ymax
|
||||
// p = t[i].split(",");
|
||||
// if(!p[1]){ p[0]=xmin; p[1] = ymin;} // ignore relative jumps such h20 v-10
|
||||
// xmin = Math.min(xmin, p[0]);
|
||||
// xmax = Math.max(xmax, p[0]);
|
||||
// ymin = Math.min(ymin, p[1]);
|
||||
// ymax = Math.max(ymax, p[1]);
|
||||
// } return [[xmin,ymax],[xmax,ymin]]; // [[left, bottom], [right, top]] as for https://github.com/mbostock/d3/wiki/Geo-Paths#bounds
|
||||
//}
|
||||
//var bb = getBBox("path");
|
55
src/mermaidAPI.spec.js
Normal file
55
src/mermaidAPI.spec.js
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Created by knut on 14-11-26.
|
||||
*/
|
||||
/**
|
||||
* Created by knut on 14-11-23.
|
||||
*/
|
||||
var api = require('./mermaidAPI.js');
|
||||
|
||||
describe('when using mermaidAPI and ',function() {
|
||||
describe('doing initialize ',function() {
|
||||
//var main;
|
||||
//var document;
|
||||
//var window;
|
||||
beforeEach(function () {
|
||||
var MockBrowser = require('mock-browser').mocks.MockBrowser;
|
||||
var mock = new MockBrowser();
|
||||
|
||||
delete global.mermaid_config;
|
||||
|
||||
// and in the run-code inside some object
|
||||
document = mock.getDocument();
|
||||
window = mock.getWindow();
|
||||
});
|
||||
|
||||
it('should copy a literal into the configuration', function () {
|
||||
var orgConfig = api.getConfig();
|
||||
expect(orgConfig.testLiteral).toBe(undefined);
|
||||
|
||||
api.initialize({'testLiteral':true});
|
||||
var config = api.getConfig();
|
||||
|
||||
expect(config.testLiteral).toBe(true);
|
||||
});
|
||||
it('should copy a an object into the configuration', function () {
|
||||
var orgConfig = api.getConfig();
|
||||
expect(orgConfig.testObject).toBe(undefined);
|
||||
|
||||
|
||||
var object = {
|
||||
test1:1,
|
||||
test2:false
|
||||
};
|
||||
|
||||
api.initialize({'testObject':object});
|
||||
api.initialize({'testObject':{'test3':true}});
|
||||
var config = api.getConfig();
|
||||
|
||||
expect(config.testObject.test1).toBe(1);
|
||||
expect(config.testObject.test2).toBe(false);
|
||||
expect(config.testObject.test3).toBe(true);
|
||||
expect(config.cloneCssStyles).toBe(orgConfig.cloneCssStyles);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
@ -5,8 +5,8 @@
|
||||
|
||||
<link rel="stylesheet" href="../dist/mermaid.forest.css"/>
|
||||
|
||||
<script src="../node_modules/d3/d3.js"></script>
|
||||
<script src="../dist/mermaid.slim.js"></script>
|
||||
<scrpt src="../node_modules/d3/d3.js"></scrpt>
|
||||
<script src="../dist/mermaid.js"></script>
|
||||
<scrpt src="../dist/mermaid.full.js"></scrpt>
|
||||
<style type="text/css">
|
||||
html {
|
||||
@ -72,6 +72,17 @@ html {
|
||||
end
|
||||
end
|
||||
</div>
|
||||
<div class="mermaid">graph TB
|
||||
c1-->a2
|
||||
subgraph one
|
||||
a1-->a2
|
||||
end
|
||||
subgraph two
|
||||
b1-->b2
|
||||
end
|
||||
subgraph three
|
||||
c1-->c2
|
||||
end</div>
|
||||
<div class="mermaid">
|
||||
graph TB
|
||||
subgraph A
|
||||
|
23
upgrading.md
Normal file
23
upgrading.md
Normal file
@ -0,0 +1,23 @@
|
||||
#Upgrading to from version -0.4.0
|
||||
|
||||
Some of the interfaces has been upgraded.
|
||||
|
||||
#Initialization
|
||||
|
||||
mermaid_config is no longer used. Instead a call to mermaid initialize is done as in the example below:
|
||||
|
||||
## version 0.4.0
|
||||
|
||||
```
|
||||
mermaid_config = {
|
||||
startOnLoad:true
|
||||
};
|
||||
```
|
||||
|
||||
## will look like below in version 0.5.0
|
||||
|
||||
```
|
||||
mermaid.initialize({
|
||||
startOnLoad:true
|
||||
});
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user