Skip to content

Build your personal knowledge base with Trilium Notes

feat(in-app-help): render images

Elian Doranebaba4ff4a67
diff --git a/src/public/app/widgets/type_widgets/doc.ts b/src/public/app/widgets/type_widgets/doc.ts
index 431af3d3be..86bd7addee 100644
--- a/src/public/app/widgets/type_widgets/doc.ts
+++ b/src/public/app/widgets/type_widgets/doc.ts
@@ -43,11 +43,26 @@ export default class DocTypeWidget extends TypeWidget {
this.$content.load(url, (response, status) => {
// fallback to english doc if no translation available
if (status === "error") {
- this.$content.load(`${window.glob.appPath}/doc_notes/en/${docName}.html`);
+ const fallbackUrl = `${window.glob.appPath}/doc_notes/en/${docName}.html`;
+ this.$content.load(fallbackUrl, () => this.#processContent(fallbackUrl));
+ return;
}
+
+ this.#processContent(url);
});
} else {
this.$content.empty();
}
}
+
+ #processContent(url: string) {
+ const dir = url.substring(0, url.lastIndexOf("/"));
+
+ // Images are relative to the docnote but that will not work when rendered in the application since the path breaks.
+ this.$content.find("img").each((i, el) => {
+ const $img = $(el);
+ $img.attr("src", dir + "/" + $img.attr("src"));
+ });
+ }
+
}