mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 00:35:50 +01:00
Implement mermaid diagrams (#2187)
* Start implementing mermaid diagrams * Implement theming for mermaid diagrams * Add edit tab to mermaid diagrams * Remove comment * Render mermaid diagrams in included notes * Prevent mermaid notes from being removed to consistency checks
This commit is contained in:
@@ -82,6 +82,24 @@ async function getRenderedContent(note, options = {}) {
|
||||
|
||||
$renderedContent.append($content);
|
||||
}
|
||||
else if (type === 'mermaid') {
|
||||
await libraryLoader.requireLibrary(libraryLoader.MERMAID);
|
||||
|
||||
const noteComplement = await froca.getNoteComplement(note.noteId);
|
||||
const graph = noteComplement.content || "";
|
||||
|
||||
const updateWithContent = (content) => {
|
||||
$renderedContent.append($(content))
|
||||
}
|
||||
|
||||
try {
|
||||
mermaid.mermaidAPI.render('graphDiv', graph, updateWithContent);
|
||||
} catch (e) {
|
||||
const $error = $("<p>The diagram could not displayed.</p>");
|
||||
|
||||
$renderedContent.append($error);
|
||||
}
|
||||
}
|
||||
else if (type === 'render') {
|
||||
const $content = $('<div>');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user