feat(in-app-help): render documentation

This commit is contained in:
Elian Doran 2025-02-02 15:34:44 +02:00
parent 61ee15cc01
commit 7c34a6178a
No known key found for this signature in database
2 changed files with 22 additions and 6 deletions

View File

@ -39,7 +39,8 @@ export default class DocTypeWidget extends TypeWidget {
if (docName) {
// find doc based on language
const lng = i18next.language;
this.$content.load(`${window.glob.appPath}/doc_notes/${lng}/${docName}.html`, (response, status) => {
const url = `${window.glob.appPath}/doc_notes/${lng}/${docName}.html`.replaceAll(" ", "%20");
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`);

View File

@ -26,21 +26,36 @@ function parseNoteMetaFile(noteMetaFile: NoteMetaFile): HiddenSubtreeItem[] {
return [];
}
const metaRoot = parseNoteMeta(noteMetaFile.files[0]);
return metaRoot.children ?? [];
const metaRoot = noteMetaFile.files[0];
const parsedMetaRoot = parseNoteMeta(metaRoot, "/" + (metaRoot.dirFileName ?? ""));
console.log(JSON.stringify(parsedMetaRoot, null, 4));
return parsedMetaRoot.children ?? [];
}
function parseNoteMeta(noteMeta: NoteMeta): HiddenSubtreeItem {
function parseNoteMeta(noteMeta: NoteMeta, docNameRoot: string): HiddenSubtreeItem {
const item: HiddenSubtreeItem = {
id: `_help_${noteMeta.noteId}`,
title: noteMeta.title,
type: "doc"
type: "doc",
attributes: []
};
// Handle text notes
if (noteMeta.type === "text" && noteMeta.dataFileName) {
const docPath = `${docNameRoot}/${path.basename(noteMeta.dataFileName, ".html")}`
.substring(1);
item.attributes?.push({
type: "label",
name: "docName",
value: docPath
});
}
if (noteMeta.children) {
const children: HiddenSubtreeItem[] = [];
for (const childMeta of noteMeta.children) {
children.push(parseNoteMeta(childMeta));
let newDocNameRoot = (noteMeta.dirFileName ? `${docNameRoot}/${noteMeta.dirFileName}` : docNameRoot);
children.push(parseNoteMeta(childMeta, newDocNameRoot));
}
item.children = children;