mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-15 09:04:04 +02:00
1d14c8a706
commit ae8a0641ab3681a3b25f6dc4ac40f20d52aaeb4d Author: Laurent Cozic <laurent@cozic.net> Date: Tue Feb 11 17:58:08 2020 +0000 Fixed plugin asset commit 03adf7fc7c878f82f6a43515d37fd5e3dd59390f Author: Laurent Cozic <laurent@cozic.net> Date: Mon Feb 10 22:09:18 2020 +0000 Desktop: Adding Mermaid support
25 lines
572 B
JavaScript
25 lines
572 B
JavaScript
/* 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);
|