mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fixes
This commit is contained in:
parent
8a8bdaf80e
commit
a68fd5ab83
@ -6,6 +6,8 @@ import libraryLoader from "./library_loader.js";
|
|||||||
import openService from "./open.js";
|
import openService from "./open.js";
|
||||||
import froca from "./froca.js";
|
import froca from "./froca.js";
|
||||||
|
|
||||||
|
let idCounter = 1;
|
||||||
|
|
||||||
async function getRenderedContent(note, options = {}) {
|
async function getRenderedContent(note, options = {}) {
|
||||||
options = Object.assign({
|
options = Object.assign({
|
||||||
trim: false,
|
trim: false,
|
||||||
@ -93,7 +95,7 @@ async function getRenderedContent(note, options = {}) {
|
|||||||
.css("justify-content", "space-around");
|
.css("justify-content", "space-around");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mermaid.mermaidAPI.render("mermaid-graph", content,
|
mermaid.mermaidAPI.render("in-mermaid-graph-" + idCounter++, content,
|
||||||
content => $renderedContent.append($(content)));
|
content => $renderedContent.append($(content)));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const $error = $("<p>The diagram could not displayed.</p>");
|
const $error = $("<p>The diagram could not displayed.</p>");
|
||||||
|
@ -35,6 +35,10 @@ const TPL = `
|
|||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
export default class NoteActionsWidget extends NoteContextAwareWidget {
|
export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||||
|
isEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
|
|
||||||
|
@ -18,20 +18,16 @@ const TPL = `<div class="mermaid-widget">
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="mermaid-error alert alert-warning">
|
<div class="mermaid-error alert alert-warning">
|
||||||
<p><strong>The diagram could not displayed.</strong></p>
|
<p><strong>The diagram could not displayed. See <a href="https://mermaid-js.github.io/mermaid/#/flowchart?id=graph">help and examples</a>.</strong></p>
|
||||||
<p class="error-content">Rendering diagram...</p>
|
<p class="error-content"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mermaid-render"></div>
|
<div class="mermaid-render"></div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
|
let idCounter = 1;
|
||||||
|
|
||||||
export default class MermaidWidget extends NoteContextAwareWidget {
|
export default class MermaidWidget extends NoteContextAwareWidget {
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.idCounter = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return super.isEnabled() && this.note && this.note.type === 'mermaid';
|
return super.isEnabled() && this.note && this.note.type === 'mermaid';
|
||||||
}
|
}
|
||||||
@ -45,6 +41,8 @@ export default class MermaidWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refreshWithNote(note) {
|
async refreshWithNote(note) {
|
||||||
|
this.$errorContainer.hide();
|
||||||
|
|
||||||
await libraryLoader.requireLibrary(libraryLoader.MERMAID);
|
await libraryLoader.requireLibrary(libraryLoader.MERMAID);
|
||||||
|
|
||||||
const documentStyle = window.getComputedStyle(document.documentElement);
|
const documentStyle = window.getComputedStyle(document.documentElement);
|
||||||
@ -57,14 +55,12 @@ export default class MermaidWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
this.$display.empty();
|
this.$display.empty();
|
||||||
|
|
||||||
this.$errorMessage.text('Rendering diagram...');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mermaid.mermaidAPI.render('graphDiv-' + this.idCounter++, content, content => this.$display.html(content));
|
mermaid.mermaidAPI.render('mermaid-graph-' + idCounter++, content, content => this.$display.html(content));
|
||||||
|
|
||||||
this.$errorContainer.hide();
|
this.$errorContainer.hide();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.$errorMessage.text(e.message).append(`<br/><br/><p>See <a href="https://mermaid-js.github.io/mermaid/#/flowchart?id=graph">help and examples</a>.</p>`);
|
this.$errorMessage.text(e.message);
|
||||||
this.$errorContainer.show();
|
this.$errorContainer.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,8 @@ class ConsistencyChecks {
|
|||||||
|
|
||||||
ws.sendMessageToAllClients({type: 'consistency-checks-failed'});
|
ws.sendMessageToAllClients({type: 'consistency-checks-failed'});
|
||||||
} else {
|
} else {
|
||||||
log.info(`All consistency checks passed (took ${elapsedTimeMs}ms)`);
|
log.info(`All consistency checks passed (took ${elapsedTimeMs}ms)` +
|
||||||
|
(this.fixedIssues ? " after some fixes" : "with no errors detected"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user