|
|
|
@ -16,13 +16,13 @@ const TPL = `<div class="mermaid-widget">
|
|
|
|
margin-bottom: 10px;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
flex-basis: 0;
|
|
|
|
flex-basis: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mermaid-render {
|
|
|
|
.mermaid-render {
|
|
|
|
overflow: auto;
|
|
|
|
overflow: auto;
|
|
|
|
height: 100%;
|
|
|
|
height: 100%;
|
|
|
|
text-align: center;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mermaid-render svg {
|
|
|
|
.mermaid-render svg {
|
|
|
|
width: 95%; /* https://github.com/zadam/trilium/issues/4340 */
|
|
|
|
width: 95%; /* https://github.com/zadam/trilium/issues/4340 */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -58,22 +58,10 @@ export default class MermaidWidget extends NoteContextAwareWidget {
|
|
|
|
this.$errorContainer.hide();
|
|
|
|
this.$errorContainer.hide();
|
|
|
|
|
|
|
|
|
|
|
|
await libraryLoader.requireLibrary(libraryLoader.MERMAID);
|
|
|
|
await libraryLoader.requireLibrary(libraryLoader.MERMAID);
|
|
|
|
|
|
|
|
|
|
|
|
const documentStyle = window.getComputedStyle(document.documentElement);
|
|
|
|
|
|
|
|
const mermaidTheme = documentStyle.getPropertyValue('--mermaid-theme');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mermaid.mermaidAPI.initialize({
|
|
|
|
mermaid.mermaidAPI.initialize({
|
|
|
|
startOnLoad: false,
|
|
|
|
startOnLoad: false,
|
|
|
|
theme: mermaidTheme.trim(),
|
|
|
|
...getMermaidConfig()
|
|
|
|
securityLevel: 'antiscript',
|
|
|
|
|
|
|
|
flow: { useMaxWidth: false },
|
|
|
|
|
|
|
|
sequence: { useMaxWidth: false },
|
|
|
|
|
|
|
|
gantt: { useMaxWidth: false },
|
|
|
|
|
|
|
|
"class": { useMaxWidth: false },
|
|
|
|
|
|
|
|
state: { useMaxWidth: false },
|
|
|
|
|
|
|
|
pie: { useMaxWidth: true },
|
|
|
|
|
|
|
|
journey: { useMaxWidth: false },
|
|
|
|
|
|
|
|
git: { useMaxWidth: false },
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.$display.empty();
|
|
|
|
this.$display.empty();
|
|
|
|
@ -146,3 +134,21 @@ export default class MermaidWidget extends NoteContextAwareWidget {
|
|
|
|
utils.downloadSvg(this.note.title, svg);
|
|
|
|
utils.downloadSvg(this.note.title, svg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function getMermaidConfig() {
|
|
|
|
|
|
|
|
const documentStyle = window.getComputedStyle(document.documentElement);
|
|
|
|
|
|
|
|
const mermaidTheme = documentStyle.getPropertyValue('--mermaid-theme');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
theme: mermaidTheme.trim(),
|
|
|
|
|
|
|
|
securityLevel: 'antiscript',
|
|
|
|
|
|
|
|
flow: { useMaxWidth: false },
|
|
|
|
|
|
|
|
sequence: { useMaxWidth: false },
|
|
|
|
|
|
|
|
gantt: { useMaxWidth: false },
|
|
|
|
|
|
|
|
"class": { useMaxWidth: false },
|
|
|
|
|
|
|
|
state: { useMaxWidth: false },
|
|
|
|
|
|
|
|
pie: { useMaxWidth: true },
|
|
|
|
|
|
|
|
journey: { useMaxWidth: false },
|
|
|
|
|
|
|
|
git: { useMaxWidth: false },
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|