Add initThrowsErrors() (#2379)

* Add initThrowsErrors()

* Update mermaid.js

* Update mermaid.js
This commit is contained in:
Mindaugas Laganeckas 2022-04-19 17:21:10 +02:00 committed by GitHub
parent fb82a5be46
commit 473aced449
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 20 deletions

View File

@ -30,6 +30,18 @@ import utils from './utils';
* Renders the mermaid diagrams
*/
const init = function () {
try {
initThrowsErrors();
} catch (e) {
log.warn('Syntax Error rendering');
log.warn(e);
if (this.parseError) {
this.parseError(e);
}
}
};
const initThrowsErrors = function () {
const conf = mermaidAPI.getConfig();
// console.log('Starting rendering diagrams (init) - mermaid.init', conf);
let nodes;
@ -109,26 +121,18 @@ const init = function () {
log.debug('Detected early reinit: ', init);
}
try {
mermaidAPI.render(
id,
txt,
(svgCode, bindFunctions) => {
element.innerHTML = svgCode;
if (typeof callback !== 'undefined') {
callback(id);
}
if (bindFunctions) bindFunctions(element);
},
element
);
} catch (e) {
log.warn('Syntax Error rendering');
log.warn(e);
if (this.parseError) {
this.parseError(e);
}
}
mermaidAPI.render(
id,
txt,
(svgCode, bindFunctions) => {
element.innerHTML = svgCode;
if (typeof callback !== 'undefined') {
callback(id);
}
if (bindFunctions) bindFunctions(element);
},
element
);
}
};