Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
launchbar WIP
zadamfc920becaca4
diff --git a/src/public/app/menus/shortcut_context_menu.js b/src/public/app/menus/shortcut_context_menu.jsindex 7dc3c62de0..6750e57379 100644--- a/src/public/app/menus/shortcut_context_menu.js+++ b/src/public/app/menus/shortcut_context_menu.js@@ -25,11 +25,13 @@ export default class ShortcutContextMenu {async getMenuItems() {const note = await froca.getNote(this.node.data.noteId);+ const parentNoteId = this.node.getParent().data.noteId;+const isLbRoot = note.noteId === 'lb_root';const isVisibleRoot = note.noteId === 'lb_visibleshortcuts';const isAvailableRoot = note.noteId === 'lb_availableshortcuts';- const isVisibleItem = this.node.getParent().data.noteId === 'lb_visibleshortcuts';- const isAvailableItem = this.node.getParent().data.noteId === 'lb_availableshortcuts';+ const isVisibleItem = parentNoteId === 'lb_visibleshortcuts';+ const isAvailableItem = parentNoteId === 'lb_availableshortcuts';const isItem = isVisibleItem || isAvailableItem;return [diff --git a/src/public/app/services/branches.js b/src/public/app/services/branches.jsindex c96c46cd35..eefa5e28e9 100644--- a/src/public/app/services/branches.js+++ b/src/public/app/services/branches.js@@ -124,7 +124,10 @@ async function moveNodeUpInHierarchy(node) {return;}- const resp = await server.put('branches/' + node.data.branchId + '/move-after/' + node.getParent().data.branchId);+ const targetBranchId = node.getParent().data.branchId;+ const branchIdToMove = node.data.branchId;++ const resp = await server.put(`branches/${branchIdToMove}/move-after/${targetBranchId}`);if (!resp.success) {alert(resp.message);diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.jsindex 694709df54..6756e98a8a 100644--- a/src/public/app/widgets/note_tree.js+++ b/src/public/app/widgets/note_tree.js@@ -1508,4 +1508,32 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {noteCreateService.duplicateSubtree(nodeToDuplicate.data.noteId, branch.parentNoteId);}}++ moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) {+ branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_visibleshortcuts');+ }++ moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) {+ branchService.moveToParentNote(selectedOrActiveBranchIds, 'lb_availableshortcuts');+ }++ addNoteShortcutCommand({node}) {+ this.createShortcutNote(node, 'note');+ }++ addWidgetShortcutCommand({node}) {+ this.createShortcutNote(node, 'widget');+ }++ addSpacerShortcutCommand({node}) {+ this.createShortcutNote(node, 'spacer');+ }++ async createShortcutNote(node, type) {+ const resp = await server.post(`special-notes/shortcuts/${node.data.noteId}/${type}`);++ if (!resp.success) {+ alert(resp.message);+ }+ }}diff --git a/src/routes/api/special_notes.js b/src/routes/api/special_notes.jsindex 04ae3e55a8..6e6d50d830 100644--- a/src/routes/api/special_notes.js+++ b/src/routes/api/special_notes.js@@ -66,6 +66,10 @@ function getHoistedNote() {return becca.getNote(cls.getHoistedNoteId());}+function createShortcut(req) {+ return specialNotesService.createShortcut(req.params.parentNoteId, req.params.type);+}+module.exports = {getInboxNote,getDayNote,@@ -76,5 +80,6 @@ module.exports = {createSqlConsole,saveSqlConsole,createSearchNote,- saveSearchNote+ saveSearchNote,+ createShortcut};diff --git a/src/routes/routes.js b/src/routes/routes.jsindex 3e2ade7c08..71bea43bba 100644--- a/src/routes/routes.js+++ b/src/routes/routes.js@@ -293,6 +293,7 @@ function register(app) {apiRoute(POST, '/api/special-notes/save-sql-console', specialNotesRoute.saveSqlConsole);apiRoute(POST, '/api/special-notes/search-note', specialNotesRoute.createSearchNote);apiRoute(POST, '/api/special-notes/save-search-note', specialNotesRoute.saveSearchNote);+ apiRoute(POST, '/api/special-notes/shortcuts/:parentNoteId/:type', specialNotesRoute.createShortcut);// :filename is not used by trilium, but instead used for "save as" to assign a human readable filenameroute(GET, '/api/images/:noteId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage);diff --git a/src/services/special_notes.js b/src/services/special_notes.jsindex 0b7922d23f..85f1cf7f0b 100644--- a/src/services/special_notes.js+++ b/src/services/special_notes.js@@ -347,7 +347,6 @@ function createMissingSpecialNotes() {const parentNoteId = shortcut.isVisible ? getLaunchBarVisibleShortcutsRoot().noteId : getLaunchBarAvailableShortcutsRoot().noteId;note = noteService.createNewNote({- branchId: shortcut.id,noteId: shortcut.id,title: shortcut.title,type: 'shortcut',@@ -383,6 +382,12 @@ function createMissingSpecialNotes() {}}+function createShortcut(parentNoteId, type) {+ if (type === 'note') {++ }+}+module.exports = {getInboxNote,createSqlConsole,@@ -392,4 +397,5 @@ module.exports = {createMissingSpecialNotes,getShareRoot,getBulkActionNote,+ createShortcut};