mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	launchbar WIP
This commit is contained in:
		
							
								
								
									
										2
									
								
								.idea/misc.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.idea/misc.xml
									
									
									
										generated
									
									
									
								
							| @@ -3,7 +3,7 @@ | |||||||
|   <component name="JavaScriptSettings"> |   <component name="JavaScriptSettings"> | ||||||
|     <option name="languageLevel" value="ES6" /> |     <option name="languageLevel" value="ES6" /> | ||||||
|   </component> |   </component> | ||||||
|   <component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="openjdk-18" project-jdk-type="JavaSDK"> |   <component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="openjdk-16" project-jdk-type="JavaSDK"> | ||||||
|     <output url="file://$PROJECT_DIR$/out" /> |     <output url="file://$PROJECT_DIR$/out" /> | ||||||
|   </component> |   </component> | ||||||
| </project> | </project> | ||||||
| @@ -78,6 +78,7 @@ import OptionsDialog from "../widgets/dialogs/options.js"; | |||||||
| import FloatingButtons from "../widgets/floating_buttons/floating_buttons.js"; | import FloatingButtons from "../widgets/floating_buttons/floating_buttons.js"; | ||||||
| import RelationMapButtons from "../widgets/floating_buttons/relation_map_buttons.js"; | import RelationMapButtons from "../widgets/floating_buttons/relation_map_buttons.js"; | ||||||
| import MermaidExportButton from "../widgets/floating_buttons/mermaid_export_button.js"; | import MermaidExportButton from "../widgets/floating_buttons/mermaid_export_button.js"; | ||||||
|  | import ShortcutContainer from "../widgets/containers/shortcut_container.js"; | ||||||
|  |  | ||||||
| export default class DesktopLayout { | export default class DesktopLayout { | ||||||
|     constructor(customWidgets) { |     constructor(customWidgets) { | ||||||
| @@ -93,33 +94,34 @@ export default class DesktopLayout { | |||||||
|                 .id("launcher-pane") |                 .id("launcher-pane") | ||||||
|                 .css("width", "53px") |                 .css("width", "53px") | ||||||
|                 .child(new GlobalMenuWidget()) |                 .child(new GlobalMenuWidget()) | ||||||
|                 .child(new ButtonWidget() |                 .child(new ShortcutContainer()) | ||||||
|                     .icon("bx-file-blank") |                 // .child(new ButtonWidget() | ||||||
|                     .title("New note") |                 //     .icon("bx-file-blank") | ||||||
|                     .command("createNoteIntoInbox")) |                 //     .title("New note") | ||||||
|                 .child(new ButtonWidget() |                 //     .command("createNoteIntoInbox")) | ||||||
|                     .icon("bx-search") |                 // .child(new ButtonWidget() | ||||||
|                     .title("Search") |                 //     .icon("bx-search") | ||||||
|                     .command("searchNotes")) |                 //     .title("Search") | ||||||
|                 .child(new ButtonWidget() |                 //     .command("searchNotes")) | ||||||
|                     .icon("bx-send") |                 // .child(new ButtonWidget() | ||||||
|                     .title("Jump to note") |                 //     .icon("bx-send") | ||||||
|                     .command("jumpToNote")) |                 //     .title("Jump to note") | ||||||
|                 .child(new OpenNoteButtonWidget() |                 //     .command("jumpToNote")) | ||||||
|                     .targetNote('globalnotemap')) |                 // .child(new OpenNoteButtonWidget() | ||||||
|                 .child(new ButtonWidget() |                 //     .targetNote('globalnotemap')) | ||||||
|                     .icon("bx-history") |                 // .child(new ButtonWidget() | ||||||
|                     .title("Show recent changes") |                 //     .icon("bx-history") | ||||||
|                     .command("showRecentChanges")) |                 //     .title("Show recent changes") | ||||||
|                 .child(new CalendarWidget()) |                 //     .command("showRecentChanges")) | ||||||
|                 .child(new SpacerWidget(40, 0)) |                 // .child(new CalendarWidget()) | ||||||
|                 .child(new FlexContainer("column") |                 // .child(new SpacerWidget(40, 0)) | ||||||
|                     .id("plugin-buttons") |                 // .child(new FlexContainer("column") | ||||||
|                     .contentSized()) |                 //     .id("plugin-buttons") | ||||||
|                 .child(new BookmarkButtons()) |                 //     .contentSized()) | ||||||
|                 .child(new SpacerWidget(0, 1000)) |                 // .child(new BookmarkButtons()) | ||||||
|                 .child(new ProtectedSessionStatusWidget()) |                 // .child(new SpacerWidget(0, 1000)) | ||||||
|                 .child(new SyncStatusWidget()) |                 // .child(new ProtectedSessionStatusWidget()) | ||||||
|  |                 // .child(new SyncStatusWidget()) | ||||||
|                 .child(new LeftPaneToggleWidget()) |                 .child(new LeftPaneToggleWidget()) | ||||||
|             ) |             ) | ||||||
|             .child(new LeftPaneContainer() |             .child(new LeftPaneContainer() | ||||||
|   | |||||||
| @@ -70,4 +70,8 @@ export default class RootCommandExecutor extends Component { | |||||||
|     toggleLeftPaneCommand() { |     toggleLeftPaneCommand() { | ||||||
|         options.toggle('leftPaneVisible'); |         options.toggle('leftPaneVisible'); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     showLaunchBarShortcutsCommand() { | ||||||
|  |         appContext.tabManager.openContextWithNote('lb_root', true, null, 'lb_root'); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -47,6 +47,11 @@ const TPL = ` | |||||||
|     </button> |     </button> | ||||||
|  |  | ||||||
|     <div class="dropdown-menu dropdown-menu-right"> |     <div class="dropdown-menu dropdown-menu-right"> | ||||||
|  |         <a class="dropdown-item options-button" data-trigger-command="showLaunchBarShortcuts"> | ||||||
|  |             <span class="bx bx-slider"></span> | ||||||
|  |             Show launchbar shortcuts | ||||||
|  |         </a> | ||||||
|  |      | ||||||
|         <a class="dropdown-item options-button" data-trigger-command="showOptions"> |         <a class="dropdown-item options-button" data-trigger-command="showOptions"> | ||||||
|             <span class="bx bx-slider"></span> |             <span class="bx bx-slider"></span> | ||||||
|             Options |             Options | ||||||
|   | |||||||
| @@ -30,7 +30,10 @@ export default class Container extends BasicWidget { | |||||||
|  |  | ||||||
|     doRender() { |     doRender() { | ||||||
|         this.$widget = $(`<div>`); |         this.$widget = $(`<div>`); | ||||||
|  |         this.renderChildren(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     renderChildren() { | ||||||
|         for (const widget of this.children) { |         for (const widget of this.children) { | ||||||
|             this.$widget.append(widget.render()); |             this.$widget.append(widget.render()); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ export default class LeftPaneContainer extends FlexContainer { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|         return super.isEnabled() && options.is( 'leftPaneVisible'); |         return super.isEnabled() && options.is('leftPaneVisible'); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     entitiesReloadedEvent({loadResults}) { |     entitiesReloadedEvent({loadResults}) { | ||||||
|   | |||||||
							
								
								
									
										42
									
								
								src/public/app/widgets/containers/shortcut_container.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/public/app/widgets/containers/shortcut_container.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | |||||||
|  | import FlexContainer from "./flex_container.js"; | ||||||
|  | import froca from "../../services/froca.js"; | ||||||
|  | import ButtonWidget from "../buttons/button_widget.js"; | ||||||
|  |  | ||||||
|  | export default class ShortcutContainer extends FlexContainer { | ||||||
|  |     constructor() { | ||||||
|  |         super('column'); | ||||||
|  |  | ||||||
|  |         this.id('shortcut-container'); | ||||||
|  |         this.css('height', '100%'); | ||||||
|  |         this.filling(); | ||||||
|  |  | ||||||
|  |         this.load(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async load() { | ||||||
|  |         this.children = []; | ||||||
|  |  | ||||||
|  |         const visibleShortcutsRoot = await froca.getNote('lb_visibleshortcuts'); | ||||||
|  |  | ||||||
|  |         console.log(await visibleShortcutsRoot.getChildNotes()); | ||||||
|  |  | ||||||
|  |         for (const shortcut of await visibleShortcutsRoot.getChildNotes()) { | ||||||
|  |             this.child(new ButtonWidget() | ||||||
|  |                 .icon(shortcut.getLabelValue("iconClass")) | ||||||
|  |                 .title(shortcut.title) | ||||||
|  |                 .command(shortcut.getLabelValue("command"))); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         this.$widget.empty(); | ||||||
|  |         this.renderChildren(); | ||||||
|  |  | ||||||
|  |         this.handleEventInChildren('initialRenderComplete'); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     entitiesReloadedEvent({loadResults}) { | ||||||
|  |         if (loadResults.getNotes().find(note => note.noteId.startsWith("lb_")) | ||||||
|  |             || loadResults.getBranches().find(branch => branch.branchId.startsWith("lb_"))) { | ||||||
|  |             this.load(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -601,10 +601,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         for (const branch of childBranches) { |         for (const branch of childBranches) { | ||||||
|             if (branch.noteId === 'hidden') { |  | ||||||
|                 continue; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if (hideArchivedNotes) { |             if (hideArchivedNotes) { | ||||||
|                 const note = branch.getNoteFromCache(); |                 const note = branch.getNoteFromCache(); | ||||||
|  |  | ||||||
| @@ -936,7 +932,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|         if (this.noteContext |         if (this.noteContext | ||||||
|             && this.noteContext.notePath |             && this.noteContext.notePath | ||||||
|             && !this.noteContext.note.isDeleted |             && !this.noteContext.note.isDeleted | ||||||
|             && !this.noteContext.notePath.includes("root/hidden") |  | ||||||
|         ) { |         ) { | ||||||
|             const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath); |             const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath); | ||||||
|  |  | ||||||
| @@ -1083,7 +1078,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (!ecBranch.isDeleted && ecBranch.noteId !== 'hidden') { |             if (!ecBranch.isDeleted) { | ||||||
|                 for (const parentNode of this.getNodesByNoteId(ecBranch.parentNoteId)) { |                 for (const parentNode of this.getNodesByNoteId(ecBranch.parentNoteId)) { | ||||||
|                     if (parentNode.isFolder() && !parentNode.isLoaded()) { |                     if (parentNode.isFolder() && !parentNode.isLoaded()) { | ||||||
|                         continue; |                         continue; | ||||||
|   | |||||||
| @@ -237,12 +237,12 @@ function getBulkActionNote() { | |||||||
| } | } | ||||||
|  |  | ||||||
| function getLaunchBarRoot() { | function getLaunchBarRoot() { | ||||||
|     let note = becca.getNote('launchbar'); |     let note = becca.getNote('lb_root'); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         note = noteService.createNewNote({ |         note = noteService.createNewNote({ | ||||||
|             branchId: 'launchbar', |             branchId: 'lb_root', | ||||||
|             noteId: 'launchbar', |             noteId: 'lb_root', | ||||||
|             title: 'Launch bar', |             title: 'Launch bar', | ||||||
|             type: 'text', |             type: 'text', | ||||||
|             content: '', |             content: '', | ||||||
| @@ -288,13 +288,11 @@ function getLaunchBarVisibleShortcutsRoot() { | |||||||
| } | } | ||||||
|  |  | ||||||
| const shortcuts = [ | const shortcuts = [ | ||||||
|     { id: 'lb_newnote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank' }, |     { id: 'lb_newnote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank', isVisible: true }, | ||||||
|     { id: 'lb_searcj', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search' }, |     { id: 'lb_search', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search', isVisible: true }, | ||||||
|     { id: 'lb_jumpto', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send' }, |     { id: 'lb_jumpto', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send', isVisible: true }, | ||||||
|     { id: 'lb_notemap', targetNote: 'globalnotemap', title: 'Note map', icon: 'bx bx-map' }, |     { id: 'lb_notemap', targetNote: 'globalnotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true }, | ||||||
|     { id: 'lb_recentchanges', command: 'showRecentChanges', title: 'Show recent changes', icon: 'bx bx-history' }, |     { id: 'lb_recentchanges', command: 'showRecentChanges', title: 'Show recent changes', icon: 'bx bx-history', isVisible: false } | ||||||
|     { id: 'lb_recentchanges', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send' }, |  | ||||||
|  |  | ||||||
| ]; | ]; | ||||||
|  |  | ||||||
| function createMissingSpecialNotes() { | function createMissingSpecialNotes() { | ||||||
| @@ -304,7 +302,27 @@ function createMissingSpecialNotes() { | |||||||
|     getBulkActionNote(); |     getBulkActionNote(); | ||||||
|     getLaunchBarRoot(); |     getLaunchBarRoot(); | ||||||
|     getLaunchBarAvailableShortcutsRoot(); |     getLaunchBarAvailableShortcutsRoot(); | ||||||
|     getLaunchBarVisibleShortcutsRoot(); |     getLaunchBarVisibleShortcutsRoot() | ||||||
|  |  | ||||||
|  |     for (const shortcut of shortcuts) { | ||||||
|  |         let note = becca.getNote(shortcut.id); | ||||||
|  |         const parentNoteId = shortcut.isVisible ? getLaunchBarVisibleShortcutsRoot().noteId : getLaunchBarAvailableShortcutsRoot().noteId; | ||||||
|  |  | ||||||
|  |         if (!note) { | ||||||
|  |             note = noteService.createNewNote({ | ||||||
|  |                 branchId: shortcut.id, | ||||||
|  |                 noteId: shortcut.id, | ||||||
|  |                 title: shortcut.title, | ||||||
|  |                 type: 'text', | ||||||
|  |                 content: '', | ||||||
|  |                 parentNoteId: parentNoteId | ||||||
|  |             }).note; | ||||||
|  |  | ||||||
|  |             note.addLabel('builtinShortcut'); | ||||||
|  |             note.addLabel('iconClass', shortcut.icon); | ||||||
|  |             note.addLabel('command', shortcut.command); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     // share root is not automatically created since it's visible in the tree and many won't need it/use it |     // share root is not automatically created since it's visible in the tree and many won't need it/use it | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user