mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
show mermaid errors, fixes #3610
This commit is contained in:
parent
e9a2cacb5b
commit
896a4fe981
@ -73,36 +73,37 @@ export default class MermaidWidget extends NoteContextAwareWidget {
|
||||
const wheelZoomLoaded = libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM);
|
||||
|
||||
try {
|
||||
const renderedSvg = await this.renderSvg();
|
||||
this.$display.html(renderedSvg);
|
||||
await this.renderSvg(async renderedSvg => {
|
||||
this.$display.html(renderedSvg);
|
||||
|
||||
await wheelZoomLoaded;
|
||||
await wheelZoomLoaded;
|
||||
|
||||
this.$display.attr("id", `mermaid-render-${idCounter}`);
|
||||
this.$display.attr("id", `mermaid-render-${idCounter}`);
|
||||
|
||||
WZoom.create(`#mermaid-render-${idCounter}`, {
|
||||
type: 'html',
|
||||
maxScale: 10,
|
||||
speed: 20,
|
||||
zoomOnClick: false
|
||||
WZoom.create(`#mermaid-render-${idCounter}`, {
|
||||
type: 'html',
|
||||
maxScale: 10,
|
||||
speed: 20,
|
||||
zoomOnClick: false
|
||||
});
|
||||
|
||||
this.$errorContainer.hide();
|
||||
});
|
||||
|
||||
this.$errorContainer.hide();
|
||||
} catch (e) {
|
||||
this.$errorMessage.text(e.message);
|
||||
this.$errorContainer.show();
|
||||
}
|
||||
}
|
||||
|
||||
renderSvg() {
|
||||
return new Promise(async res => {
|
||||
idCounter++;
|
||||
async renderSvg(cb) {
|
||||
idCounter++;
|
||||
|
||||
const noteComplement = await froca.getNoteComplement(this.noteId);
|
||||
const content = noteComplement.content || "";
|
||||
const noteComplement = await froca.getNoteComplement(this.noteId);
|
||||
const content = noteComplement.content || "";
|
||||
|
||||
mermaid.mermaidAPI.render(`mermaid-graph-${idCounter}`, content, res);
|
||||
});
|
||||
// this can't be promisified since in case of error this both calls callback with error SVG and throws exception
|
||||
// with error details
|
||||
mermaid.mermaidAPI.render(`mermaid-graph-${idCounter}`, content, cb);
|
||||
}
|
||||
|
||||
async entitiesReloadedEvent({loadResults}) {
|
||||
@ -116,9 +117,9 @@ export default class MermaidWidget extends NoteContextAwareWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
const renderedSvg = await this.renderSvg();
|
||||
|
||||
this.download(`${this.note.title}.svg`, renderedSvg);
|
||||
await this.renderSvg(renderedSvg => {
|
||||
this.download(`${this.note.title}.svg`, renderedSvg);
|
||||
});
|
||||
}
|
||||
|
||||
download(filename, text) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user