mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
fix: Import diagram
This commit is contained in:
parent
0f2e0c2ab4
commit
c919bef70e
@ -100,7 +100,7 @@ mindmap
|
||||
logLevel: 0,
|
||||
// basePath: './packages/',
|
||||
// themeVariables: { darkMode: true },
|
||||
extraDiagrams: ['./mermaid-mindmap-detector.js'],
|
||||
extraDiagrams: ['./mermaid-mindmap-detector.core.mjs'],
|
||||
// extraDiagrams: ['../../mermaid-mindmap/registry.ts'],
|
||||
});
|
||||
function callback() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
export const id = 'mindmap';
|
||||
|
||||
const detector = (txt: string) => {
|
||||
export const detector = (txt: string) => {
|
||||
return txt.match(/^\s*mindmap/) !== null;
|
||||
};
|
||||
|
||||
@ -8,9 +8,3 @@ export const loadDiagram = async () => {
|
||||
const { mindmap } = await import('./add-diagram');
|
||||
return { id, diagram: mindmap };
|
||||
};
|
||||
|
||||
export default {
|
||||
id,
|
||||
detector,
|
||||
loadDiagram,
|
||||
};
|
||||
|
@ -54,6 +54,9 @@ export const addDetector = (
|
||||
loader: DiagramLoader | null
|
||||
) => {
|
||||
detectors[key] = { detector, loader };
|
||||
// TODO: Remove
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(detectors);
|
||||
};
|
||||
|
||||
export const getDiagramLoader = (key: string) => detectors[key].loader;
|
||||
|
@ -57,15 +57,11 @@ const init = async function (
|
||||
const conf = mermaidAPI.getConfig();
|
||||
if (typeof conf.extraDiagrams !== 'undefined' && conf.extraDiagrams.length > 0) {
|
||||
// config.extraDiagrams.forEach(async (diagram: string) => {
|
||||
const apa = await import(conf.extraDiagrams[0]);
|
||||
// Todo figure out how to get the diagram properly
|
||||
//@ts-ignore temporary code
|
||||
const did = window['mermaid-mindmap-detector'].default.id; //eslint-disable-line
|
||||
//@ts-ignore temporary code
|
||||
const detector = window['mermaid-mindmap-detector'].default.detector; //eslint-disable-line
|
||||
//@ts-ignore temporary code
|
||||
const loader = window['mermaid-mindmap-detector'].default.loadDiagram; //eslint-disable-line
|
||||
addDetector(did, detector, loader);
|
||||
const { id, detector, loadDiagram } = await import(conf.extraDiagrams[0]);
|
||||
// TODO: Remove
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(id, detector, loadDiagram);
|
||||
addDetector(id, detector, loadDiagram);
|
||||
// });
|
||||
}
|
||||
mermaid.detectors.forEach(({ id, detector, path }) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user