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

1558
dist/mermaid.js vendored

File diff suppressed because it is too large Load Diff

4
dist/mermaid.min.js vendored

File diff suppressed because one or more lines are too long

43
dist/mermaid.slim.js vendored
View File

@ -28235,6 +28235,7 @@ module.exports.mermaidAPI = mermaidAPI;
* @param nodes a css selector or an array of nodes
*/
var init = function () {
var conf= mermaidAPI.getConfig();
log.debug('Starting rendering diagrams');
var nodes;
if(arguments.length >= 2){
@ -28255,7 +28256,6 @@ var init = function () {
callback = arguments[arguments.length-1];
log.debug('Callback function found');
}else{
var conf= mermaidAPI.getConfig();
if(typeof conf.mermaid !== 'undefined'){
if(typeof conf.mermaid.callback === 'function'){
callback = conf.mermaid.callback;
@ -28559,10 +28559,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,_dereq_("1YiZ5S"))
@ -28598,7 +28600,7 @@ var ganttParser = _dereq_('./diagrams/gantt/parser/gantt');
var ganttDb = _dereq_('./diagrams/gantt/ganttDb');
var d3 = _dereq_('./d3');
var nextId = 0;
var log = _dereq_('./logger').create();
/**
* ## Configuration
@ -28612,6 +28614,15 @@ var log = _dereq_('./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
*/
@ -28786,6 +28797,8 @@ var config = {
}
};
var log = _dereq_('./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
@ -28841,7 +28854,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);
@ -28968,6 +28981,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');
@ -29010,7 +29027,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]] = {};
@ -29024,6 +29041,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);
@ -29076,20 +29094,11 @@ var log = _dereq_('./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";

File diff suppressed because one or more lines are too long

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";

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -282,7 +282,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);
@ -409,6 +409,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');

View File

@ -27,5 +27,14 @@
Ali#45;ce->>John: Hello John, how are you? #60;
John-->>Alice: Great!#quot;
</div>
<div class="mermaid" id="i211">
graph LR;
A[Hard edge]-->|Link text|B(Round edge);
B-->C{Decision};
C-->|One|D[Result one];
C-->|Two|E[Result two];
classDef pink fill:#f9f,stroke:#333,stroke-width:4px;
class C pink;
</div>
</body>
</html>