Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getDiagram(title, input, callback) {
try {
mermaidAPI.initialize({
startOnLoad: true
});
mermaidAPI.parseError = function(err, hash) {
// console.log("parseError");
// console.log(err.messsage);
};
// console.log("Rendering");
// console.log(input);
// mermaidAPI.render(title, "graph TB;Loading;", diagram => {
// console.log("Rendered");
// setTimeout(
// () =>
// mermaidAPI.render(title, input, diagram => {
// console.log("Rendered");
// console.log(diagram);
componentDidMount () {
const { children, config, height, width } = this.props
const defaultConfig = {
// If this is true, mermaid tries to re-render
// using window.addEventListener('loaded', ...)
// which screws it all up.
startOnLoad: false,
gantt: {
useWidth: width,
useHeight: height || null,
},
}
const mermaidConfig = merge(defaultConfig, config)
mermaidAPI.initialize(mermaidConfig)
const doc = children.toString().trim()
const diagram = mermaidAPI.render(doc)
this.setState({
diagram,
})
}
activate() {
mermaidAPI.initialize({
startOnLoad: false,
theme: inkdrop.config.get('mermaid.theme')
})
if (markdownRenderer) {
markdownRenderer.remarkCodeComponents.mermaid = Mermaid
}
},
constructor(props) {
super(props);
mermaidAPI.initialize({
startOnLoad:false
});
}