mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 03:32:26 +08:00
feat(in-app-help): render images
This commit is contained in:
parent
7c34a6178a
commit
ebaba4ff4a
@ -43,11 +43,26 @@ export default class DocTypeWidget extends TypeWidget {
|
|||||||
this.$content.load(url, (response, status) => {
|
this.$content.load(url, (response, status) => {
|
||||||
// fallback to english doc if no translation available
|
// fallback to english doc if no translation available
|
||||||
if (status === "error") {
|
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 {
|
} else {
|
||||||
this.$content.empty();
|
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"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user