Fix for defect #180, SVG foreignObject rendering

This commit is contained in:
knsv
2015-10-04 21:18:05 +02:00
parent 122274bf52
commit 8258fb059c
9 changed files with 870 additions and 852 deletions

41
dist/mermaidAPI.js vendored
View File

@@ -37101,7 +37101,7 @@ var ganttParser = require('./diagrams/gantt/parser/gantt');
var ganttDb = require('./diagrams/gantt/ganttDb');
var d3 = require('./d3');
var nextId = 0;
var log = require('./logger').create();
/**
* ## Configuration
@@ -37115,6 +37115,15 @@ var log = require('./logger').create();
* ```
*/
var config = {
/**
* logLevel , decides the amount of logging to be used.
* * debug: 1
* * info: 2
* * warn: 3
* * error: 4
* * fatal: 5
*/
logLevel: 3,
/**
* **cloneCssStyles** - This options controls whether or not the css rules should be copied into the generated svg
*/
@@ -37289,6 +37298,8 @@ var config = {
}
};
var log = require('./logger').create({level:config.logLevel});
/**
* ## parse
* Function that parses a mermaid diagram definition. If parsing fails the parseError callback is called and an error is
@@ -37344,7 +37355,7 @@ exports.version = function(){
exports.encodeEntities = function(text){
var txt = text;
txt = txt.replace(/#\w*;?/g,function(s,t,u){
txt = txt.replace(/#\w+\;/g,function(s,t,u){
var innerTxt = s.substring(1,s.length-1);
var isInt = /^\+?\d+$/.test(innerTxt);
@@ -37471,6 +37482,10 @@ var render = function(id, txt, cb, container){
break;
}
d3.select('#d'+id).selectAll('foreignobject div').attr('xmlns','http://www.w3.org/1999/xhtml');
// Fix for when the base tag is used
var svgCode = d3.select('#d'+id).node().innerHTML.replace(/url\(#arrowhead/g,'url('+ window.location.protocol+'//'+location.host+location.pathname +'#arrowhead','g');
@@ -37513,7 +37528,7 @@ var setConf = function(cnf){
var j;
for(j=0;j<lvl2Keys.length;j++) {
//log.debug('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
log.debug('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
if(typeof config[lvl1Keys[i]] === 'undefined'){
config[lvl1Keys[i]] = {};
@@ -37527,6 +37542,7 @@ var setConf = function(cnf){
}
};
exports.initialize = function(options){
log.debug('Initializing mermaidAPI');
// Update default config with options supplied at initialization
if(typeof options === 'object'){
setConf(options);
@@ -37645,10 +37661,12 @@ Logger.levels = {
warn: 3,
error: 4,
fatal: 5,
default:1
default:5
};
exports.create = function(type, options) {
exports.setLogLevel = function(level){
Logger.levels.default = level;
}
exports.create = function(options) {
return new Logger(options);
};
}).call(this,require("1YiZ5S"))
@@ -37676,20 +37694,11 @@ var log = require('./logger').create();
* @returns {string} A graph definition key
*/
module.exports.detectType = function(text,a){
text = text.replace(/^\s*%%.*\n/g,'\n');
if(text.match(/^\s*sequenceDiagram/)){
return "sequenceDiagram";
}
if(text.match(/^\s*sequence/)){
/* ```mermaid
graph TB
a-->b
b-->c
```
*/
return "sequence";
}
if(text.match(/^\s*digraph/)) {
//log.debug('Detected dot syntax');
return "dotGraph";