mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	feat(in-app-help): render documentation
This commit is contained in:
		
							parent
							
								
									61ee15cc01
								
							
						
					
					
						commit
						7c34a6178a
					
				@ -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`);
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user