mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
fix(in-app-help): style error when loading a note
This commit is contained in:
parent
3796818a78
commit
d901a0f787
@ -41,16 +41,15 @@ export default class DocTypeWidget extends TypeWidget {
|
|||||||
|
|
||||||
#loadContent(note: FNote) {
|
#loadContent(note: FNote) {
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
const docName = note.getLabelValue("docName");
|
let docName = note.getLabelValue("docName");
|
||||||
|
|
||||||
if (docName) {
|
if (docName) {
|
||||||
// find doc based on language
|
// find doc based on language
|
||||||
const lng = i18next.language;
|
const url = this.#getUrl(docName, i18next.language);
|
||||||
const url = `${window.glob.appPath}/doc_notes/${lng}/${docName}.html`.replaceAll(" ", "%20");
|
|
||||||
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") {
|
||||||
const fallbackUrl = `${window.glob.appPath}/doc_notes/en/${docName}.html`;
|
const fallbackUrl = this.#getUrl(docName, "en");
|
||||||
this.$content.load(fallbackUrl, () => this.#processContent(fallbackUrl));
|
this.$content.load(fallbackUrl, () => this.#processContent(fallbackUrl));
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
@ -65,6 +64,19 @@ export default class DocTypeWidget extends TypeWidget {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#getUrl(docNameValue: string, language: string) {
|
||||||
|
// For help notes, we only get the content to avoid loading of styles and meta.
|
||||||
|
let suffix = "";
|
||||||
|
if (docNameValue?.startsWith("User Guide")) {
|
||||||
|
suffix = " .content";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cannot have spaces in the URL due to how JQuery.load works.
|
||||||
|
docNameValue = docNameValue.replaceAll(" ", "%20");
|
||||||
|
|
||||||
|
return `${window.glob.appPath}/doc_notes/${language}/${docNameValue}.html${suffix}`;
|
||||||
|
}
|
||||||
|
|
||||||
#processContent(url: string) {
|
#processContent(url: string) {
|
||||||
const dir = url.substring(0, url.lastIndexOf("/"));
|
const dir = url.substring(0, url.lastIndexOf("/"));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user