mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-01 13:31:32 +08:00 
			
		
		
		
	feat(tray): show a list of bookmarks
This commit is contained in:
		
							parent
							
								
									84edf0348f
								
							
						
					
					
						commit
						cd0c79e3d2
					
				| @ -6,6 +6,7 @@ import { fileURLToPath } from "url"; | |||||||
| import type { KeyboardActionNames } from "./keyboard_actions_interface.js"; | import type { KeyboardActionNames } from "./keyboard_actions_interface.js"; | ||||||
| import date_notes from "./date_notes.js"; | import date_notes from "./date_notes.js"; | ||||||
| import type BNote from "../becca/entities/bnote.js"; | import type BNote from "../becca/entities/bnote.js"; | ||||||
|  | import becca from "../becca/becca.js"; | ||||||
| 
 | 
 | ||||||
| let tray: Tray; | let tray: Tray; | ||||||
| // `mainWindow.isVisible` doesn't work with `mainWindow.show` and `mainWindow.hide` - it returns `false` when the window
 | // `mainWindow.isVisible` doesn't work with `mainWindow.show` and `mainWindow.hide` - it returns `false` when the window
 | ||||||
| @ -64,6 +65,26 @@ function updateTrayMenu() { | |||||||
|         mainWindow?.webContents.send("openInSameTab", note.noteId); |         mainWindow?.webContents.send("openInSameTab", note.noteId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     function buildBookmarksMenu() { | ||||||
|  |         const parentNote = becca.getNoteOrThrow("_lbBookmarks"); | ||||||
|  |         const menuItems: Electron.MenuItemConstructorOptions[] = []; | ||||||
|  | 
 | ||||||
|  |         for (const bookmarkNote of parentNote?.children) { | ||||||
|  |             if (bookmarkNote.isLabelTruthy("bookmarkFolder")) { | ||||||
|  |                 // Ignore bookmark folders for now.
 | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             menuItems.push({ | ||||||
|  |                 label: bookmarkNote.title, | ||||||
|  |                 type: "normal", | ||||||
|  |                 click: () => openInSameTab(bookmarkNote) | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return menuItems; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     const contextMenu = Menu.buildFromTemplate([ |     const contextMenu = Menu.buildFromTemplate([ | ||||||
|         { |         { | ||||||
|             label: "New Note", |             label: "New Note", | ||||||
| @ -75,6 +96,11 @@ function updateTrayMenu() { | |||||||
|             type: "normal", |             type: "normal", | ||||||
|             click: () => openInSameTab(date_notes.getTodayNote()) |             click: () => openInSameTab(date_notes.getTodayNote()) | ||||||
|         }, |         }, | ||||||
|  |         { | ||||||
|  |             label: "Bookmarks", | ||||||
|  |             type: "submenu", | ||||||
|  |             submenu: buildBookmarksMenu() | ||||||
|  |         }, | ||||||
|         { type: "separator" }, |         { type: "separator" }, | ||||||
|         { |         { | ||||||
|             label: isVisible ? "Hide" : "Show", |             label: isVisible ? "Hide" : "Show", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran