mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Fix for issue #311, mermaid will clear div used for rendering initially in the redner function.
This commit is contained in:
parent
a179212c60
commit
046b4fdae4
@ -67,7 +67,7 @@ exports.addVertex = function (id, text, type, style) {
|
|||||||
* @param linktext
|
* @param linktext
|
||||||
*/
|
*/
|
||||||
exports.addLink = function (start, end, type, linktext) {
|
exports.addLink = function (start, end, type, linktext) {
|
||||||
log.debug('Got edge', start, end);
|
log.info('Got edge...', start, end);
|
||||||
var edge = {start: start, end: end, type: undefined, text: ''};
|
var edge = {start: start, end: end, type: undefined, text: ''};
|
||||||
linktext = type.text;
|
linktext = type.text;
|
||||||
|
|
||||||
|
@ -53,6 +53,10 @@ function formatTime(timestamp) {
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function format(level) {
|
||||||
|
const time = formatTime(new Date());
|
||||||
|
return '%c ' + time +' :%c' + level + ': ';
|
||||||
|
}
|
||||||
|
|
||||||
function Log(level) {
|
function Log(level) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
@ -81,35 +85,12 @@ function Log(level) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.trace = function(str) {
|
this.trace = window.console.debug.bind(window.console, format('TRACE', name), 'color:grey;', 'color: grey;');
|
||||||
var args = Array.prototype.slice.call(arguments);
|
this.debug = window.console.debug.bind(window.console, format('DEBUG', name), 'color:grey;', 'color: green;');
|
||||||
args.unshift(LEVELS.trace);
|
this.info = window.console.debug.bind(window.console, format('INFO', name), 'color:grey;', 'color: blue;');
|
||||||
this.log.apply(this, args);
|
this.warn = window.console.debug.bind(window.console, format('WARN', name), 'color:grey;', 'color: orange;');
|
||||||
};
|
this.error = window.console.debug.bind(window.console, format('ERROR', name), 'color:grey;', 'color: red;');
|
||||||
|
|
||||||
this.debug = function(str) {
|
|
||||||
var args = Array.prototype.slice.call(arguments);
|
|
||||||
args.unshift(LEVELS.debug);
|
|
||||||
this.log.apply(this, args);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.info = function(str) {
|
|
||||||
var args = Array.prototype.slice.call(arguments);
|
|
||||||
args.unshift(LEVELS.info);
|
|
||||||
this.log.apply(this, args);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.warn = function(str) {
|
|
||||||
var args = Array.prototype.slice.call(arguments);
|
|
||||||
args.unshift(LEVELS.warn);
|
|
||||||
this.log.apply(this, args);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.error = function(str) {
|
|
||||||
var args = Array.prototype.slice.call(arguments);
|
|
||||||
args.unshift(LEVELS.error);
|
|
||||||
this.log.apply(this, args);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Log = Log;
|
exports.Log = Log;
|
||||||
|
@ -346,8 +346,6 @@ exports.decodeEntities = function(text){
|
|||||||
return ';';
|
return ';';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -376,6 +374,8 @@ exports.decodeEntities = function(text){
|
|||||||
var render = function(id, txt, cb, container){
|
var render = function(id, txt, cb, container){
|
||||||
|
|
||||||
if(typeof container !== 'undefined'){
|
if(typeof container !== 'undefined'){
|
||||||
|
container.innerHTML = '';
|
||||||
|
|
||||||
d3.select(container).append('div')
|
d3.select(container).append('div')
|
||||||
.attr('id', 'd'+id)
|
.attr('id', 'd'+id)
|
||||||
.append('svg')
|
.append('svg')
|
||||||
@ -385,6 +385,11 @@ var render = function(id, txt, cb, container){
|
|||||||
.append('g');
|
.append('g');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
var element = document.querySelector('#' + 'd'+id);
|
||||||
|
if(element){
|
||||||
|
element.innerHTML = '';
|
||||||
|
}
|
||||||
|
|
||||||
d3.select('body').append('div')
|
d3.select('body').append('div')
|
||||||
.attr('id', 'd'+id)
|
.attr('id', 'd'+id)
|
||||||
.append('svg')
|
.append('svg')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user