mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	feat(in-app-help): use preprocessed subtree data
This commit is contained in:
		| @@ -13,6 +13,9 @@ | |||||||
| *   Markdown export: | *   Markdown export: | ||||||
|     *   Reduce extra whitespace between list items. |     *   Reduce extra whitespace between list items. | ||||||
|     *   Preserve include note. |     *   Preserve include note. | ||||||
|  | *   In-app help: | ||||||
|  |     *   Document structure is now precalculated, so start-up time should be slightly increased. | ||||||
|  |     *   Optimized the content in order to reduce the size on disk. | ||||||
|  |  | ||||||
| ## 🌍 Internationalization | ## 🌍 Internationalization | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,6 +12,7 @@ import cls from "./src/services/cls.js"; | |||||||
| import type { AdvancedExportOptions } from "./src/services/export/zip.js"; | import type { AdvancedExportOptions } from "./src/services/export/zip.js"; | ||||||
| import TaskContext from "./src/services/task_context.js"; | import TaskContext from "./src/services/task_context.js"; | ||||||
| import { deferred } from "./src/services/utils.js"; | import { deferred } from "./src/services/utils.js"; | ||||||
|  | import { parseNoteMetaFile } from "./src/services/in_app_help.js"; | ||||||
|  |  | ||||||
| const NOTE_ID_USER_GUIDE = "pOsGYCXsbNQG"; | const NOTE_ID_USER_GUIDE = "pOsGYCXsbNQG"; | ||||||
| const NOTE_ID_RELEASE_NOTES = "hD3V4hiu2VW4"; | const NOTE_ID_RELEASE_NOTES = "hD3V4hiu2VW4"; | ||||||
| @@ -172,8 +173,13 @@ async function cleanUpMeta(outputPath: string, minify: boolean) { | |||||||
|         el.isExpanded = false; |         el.isExpanded = false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const json = minify ? JSON.stringify(meta) : JSON.stringify(meta, null, 4); |     if (minify) { | ||||||
|     await fs.writeFile(metaPath, json); |         const subtree = parseNoteMetaFile(meta); | ||||||
|  |         await fs.writeFile(metaPath, JSON.stringify(subtree)); | ||||||
|  |     } else { | ||||||
|  |         await fs.writeFile(metaPath, JSON.stringify(meta, null, 4)); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| async function registerHandlers() { | async function registerHandlers() { | ||||||
|   | |||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -15,15 +15,14 @@ export function getHelpHiddenSubtreeData() { | |||||||
|     const metaFilePath = path.join(helpDir, "!!!meta.json"); |     const metaFilePath = path.join(helpDir, "!!!meta.json"); | ||||||
|  |  | ||||||
|     try { |     try { | ||||||
|         const metaFileContent = JSON.parse(fs.readFileSync(metaFilePath).toString("utf-8")); |         return JSON.parse(fs.readFileSync(metaFilePath).toString("utf-8")); | ||||||
|         return parseNoteMetaFile(metaFileContent as NoteMetaFile); |  | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|         console.warn(e); |         console.warn(e); | ||||||
|         return []; |         return []; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| function parseNoteMetaFile(noteMetaFile: NoteMetaFile): HiddenSubtreeItem[] { | export function parseNoteMetaFile(noteMetaFile: NoteMetaFile): HiddenSubtreeItem[] { | ||||||
|     if (!noteMetaFile.files) { |     if (!noteMetaFile.files) { | ||||||
|         console.log("No meta files"); |         console.log("No meta files"); | ||||||
|         return []; |         return []; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user