Skip to content

Commit

Permalink
feat(in-app-help): render documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
eliandoran committed Feb 2, 2025
1 parent 61ee15c commit 7c34a61
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/public/app/widgets/type_widgets/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down
25 changes: 20 additions & 5 deletions src/services/in_app_help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7c34a61

Please sign in to comment.