From ebaba4ff4a67db8f109aec282d9ff7c9a6d7b3eb Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 2 Feb 2025 16:14:29 +0200 Subject: [PATCH] feat(in-app-help): render images --- src/public/app/widgets/type_widgets/doc.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/public/app/widgets/type_widgets/doc.ts b/src/public/app/widgets/type_widgets/doc.ts index 431af3d3b..86bd7adde 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")); + }); + } + }