2022-09-21 11:03:33 +02:00
|
|
|
// @ts-ignore: TODO Fix ts errors
|
|
|
|
import { mindmapDetector } from './mindmapDetector';
|
2022-09-21 12:35:25 +02:00
|
|
|
|
2022-09-26 14:22:21 +02:00
|
|
|
const scriptElement = document.currentScript as HTMLScriptElement;
|
|
|
|
const path = scriptElement.src;
|
|
|
|
const lastSlash = path.lastIndexOf('/');
|
|
|
|
const baseFolder = lastSlash < 0 ? path : path.substring(0, lastSlash + 1);
|
|
|
|
|
2022-09-26 08:01:23 +02:00
|
|
|
if (typeof document !== 'undefined') {
|
|
|
|
if (window.mermaid && typeof window.mermaid.detectors === 'object') {
|
|
|
|
window.mermaid.detectors.push({ id: 'mindmap', detector: mindmapDetector });
|
|
|
|
} else {
|
|
|
|
window.mermaid = {};
|
|
|
|
window.mermaid.detectors = [{ id: 'mindmap', detector: mindmapDetector }];
|
|
|
|
}
|
2022-09-21 12:35:25 +02:00
|
|
|
|
2022-09-26 08:01:23 +02:00
|
|
|
/*!
|
|
|
|
* Wait for document loaded before starting the execution.
|
|
|
|
*/
|
|
|
|
window.addEventListener(
|
|
|
|
'load',
|
|
|
|
() => {
|
|
|
|
if (window.mermaid && typeof window.mermaid.detectors === 'object') {
|
2022-09-26 14:22:21 +02:00
|
|
|
window.mermaid.detectors.push({
|
|
|
|
id: 'mindmap',
|
|
|
|
detector: mindmapDetector,
|
|
|
|
path: baseFolder,
|
|
|
|
});
|
2022-10-03 07:01:56 +02:00
|
|
|
console.error(window.mermaid.detectors); // eslint-disable-line no-console
|
2022-09-26 08:01:23 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
false
|
|
|
|
);
|
|
|
|
}
|