mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	launchbar WIP
This commit is contained in:
		
							parent
							
								
									df7c089344
								
							
						
					
					
						commit
						2694bcff67
					
				
							
								
								
									
										3
									
								
								src/public/app/doc_notes/launchbar_note_shortcut.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/public/app/doc_notes/launchbar_note_shortcut.html
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| <p>Please define the target note in the promoted attributes.</p> | ||||
| 
 | ||||
| <p>Launchbar displays the title / icon from the shortcut which does not necessarily mirrors those of the target note.</p> | ||||
							
								
								
									
										3
									
								
								src/public/app/doc_notes/launchbar_script_shortcut.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/public/app/doc_notes/launchbar_script_shortcut.html
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| <p>Please define the target script note in the promoted attributes. This script will be executed immediately upon clicking the launchbar icon.</p> | ||||
| 
 | ||||
| <p>Launchbar displays the title / icon from the shortcut which does not necessarily mirrors those of the target script note.</p> | ||||
							
								
								
									
										6
									
								
								src/public/app/doc_notes/launchbar_spacer.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/public/app/doc_notes/launchbar_spacer.html
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| <p>Spacer allows you to visually group shortcuts. You can configure it in the promoted attributes:</p> | ||||
| 
 | ||||
| <ul> | ||||
|     <li><code>baseSize</code> - defines size in pixels (if there's enough space)</li> | ||||
|     <li><code>growthFactor</code> - set to 0 if you want the spacer to be of constant <code>baseSize</code>, with positive value it will grow.</li> | ||||
| </ul> | ||||
							
								
								
									
										1
									
								
								src/public/app/doc_notes/launchbar_widget_shortcut.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/public/app/doc_notes/launchbar_widget_shortcut.html
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| <p>Please define the target widget note in the promoted attributes. The widget will be used to render the launchbar icon.</p> | ||||
| @ -1,8 +1,6 @@ | ||||
| import treeService from '../services/tree.js'; | ||||
| import froca from "../services/froca.js"; | ||||
| import noteCreateService from "../services/note_create.js"; | ||||
| import contextMenu from "./context_menu.js"; | ||||
| import appContext from "../services/app_context.js"; | ||||
| 
 | ||||
| export default class ShortcutContextMenu { | ||||
|     /** | ||||
| @ -36,6 +34,7 @@ export default class ShortcutContextMenu { | ||||
| 
 | ||||
|         return [ | ||||
|             (isVisibleRoot || isAvailableRoot) ? { title: 'Add note shortcut', command: 'addNoteShortcut', uiIcon: "bx bx-plus" } : null, | ||||
|             (isVisibleRoot || isAvailableRoot) ? { title: 'Add script shortcut', command: 'addScriptShortcut', uiIcon: "bx bx-plus" } : null, | ||||
|             (isVisibleRoot || isAvailableRoot) ? { title: 'Add widget shortcut', command: 'addWidgetShortcut', uiIcon: "bx bx-plus" } : null, | ||||
|             (isVisibleRoot || isAvailableRoot) ? { title: 'Add spacer', command: 'addSpacerShortcut', uiIcon: "bx bx-plus" } : null, | ||||
|             (isVisibleRoot || isAvailableRoot) ? { title: "----" } : null, | ||||
|  | ||||
| @ -54,10 +54,10 @@ async function pasteInto(parentBranchId) { | ||||
|             await branchService.cloneNoteToBranch(clipboardNote.noteId, parentBranchId); | ||||
|         } | ||||
| 
 | ||||
|         // copy will keep clipboardBranchIds and clipboardMode so it's possible to paste into multiple places
 | ||||
|         // copy will keep clipboardBranchIds and clipboardMode, so it's possible to paste into multiple places
 | ||||
|     } | ||||
|     else { | ||||
|         toastService.throwError("Unrecognized clipboard mode=" + mode); | ||||
|         toastService.throwError("Unrecognized clipboard mode=" + clipboardMode); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -1521,6 +1521,10 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | ||||
|         this.createShortcutNote(node, 'note'); | ||||
|     } | ||||
| 
 | ||||
|     addScriptShortcutCommand({node}) { | ||||
|         this.createShortcutNote(node, 'script'); | ||||
|     } | ||||
| 
 | ||||
|     addWidgetShortcutCommand({node}) { | ||||
|         this.createShortcutNote(node, 'widget'); | ||||
|     } | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| const treeService = require("./tree.js"); | ||||
| const sql = require("./sql.js"); | ||||
| const treeService = require("./tree"); | ||||
| const sql = require("./sql"); | ||||
| 
 | ||||
| function moveBranchToNote(sourceBranch, targetParentNoteId) { | ||||
|     if (sourceBranch.parentNoteId === targetParentNoteId) { | ||||
|  | ||||
| @ -394,6 +394,17 @@ function createShortcut(parentNoteId, type) { | ||||
|         }).note; | ||||
| 
 | ||||
|         note.addLabel('relation:targetNote', 'promoted'); | ||||
|         note.addLabel('docName', 'launchbar_note_shortcut'); | ||||
|     } else if (type === 'script') { | ||||
|         note = noteService.createNewNote({ | ||||
|             title: "Script shortcut", | ||||
|             type: 'shortcut', | ||||
|             content: '', | ||||
|             parentNoteId: parentNoteId | ||||
|         }).note; | ||||
| 
 | ||||
|         note.addLabel('relation:script', 'promoted'); | ||||
|         note.addLabel('docName', 'launchbar_script_shortcut'); | ||||
|     } else if (type === 'widget') { | ||||
|         note = noteService.createNewNote({ | ||||
|             title: "Widget shortcut", | ||||
| @ -403,6 +414,7 @@ function createShortcut(parentNoteId, type) { | ||||
|         }).note; | ||||
| 
 | ||||
|         note.addLabel('relation:widget', 'promoted'); | ||||
|         note.addLabel('docName', 'launchbar_widget_shortcut'); | ||||
|     } else if (type === 'spacer') { | ||||
|         note = noteService.createNewNote({ | ||||
|             title: "Spacer", | ||||
| @ -417,6 +429,7 @@ function createShortcut(parentNoteId, type) { | ||||
|         note.addLabel('baseSize', '40'); | ||||
|         note.addLabel('label:growthFactor', 'promoted,number'); | ||||
|         note.addLabel('growthFactor', '0'); | ||||
|         note.addLabel('docName', 'launchbar_spacer'); | ||||
|     } else { | ||||
|         throw new Error(`Unrecognized shortcut type ${type}`); | ||||
|     } | ||||
|  | ||||
| @ -58,6 +58,16 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) { | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     const parentNoteIsShortcut = becca.getNote(parentNoteId).type === 'shortcut'; | ||||
|     const childNoteIsShortcut = becca.getNote(childNoteId).type === 'shortcut'; | ||||
| 
 | ||||
|     if (parentNoteIsShortcut !== childNoteIsShortcut) { | ||||
|         return { | ||||
|             success: false, | ||||
|             message: 'Moving/cloning is not possible between shortcuts / normal notes.' | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     return { success: true }; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam