1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/ReactNativeClient/lib/joplin-renderer/assets/mermaid/mermaid_render.js

25 lines
572 B
JavaScript
Raw Normal View History

/* global mermaid */
function mermaidReady() {
return typeof mermaid !== 'undefined';
}
function mermaidInit() {
// Mermaid's wonderful API has two init methods: init() and initialize().
// init() is deprectated but works, and initialize() is recommended but doesn't
// work, so let's use init() for now.
if (mermaidReady()) mermaid.init();
}
document.addEventListener('joplin-noteDidUpdate', () => {
mermaidInit();
});
const initIID_ = setInterval(() => {
const isReady = mermaidReady();
if (isReady) {
clearInterval(initIID_);
mermaidInit();
}
}, 100);