From 1f8d382b1fbf9a61fb61e235062b8a33adc1f444 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 19 Nov 2019 21:11:20 +0100 Subject: [PATCH 1/3] added "search in subtree" context menu, #534 --- src/public/javascripts/services/search_notes.js | 7 +++++++ src/public/javascripts/services/tree_context_menu.js | 6 ++++++ src/public/javascripts/services/tree_keybindings.js | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/src/public/javascripts/services/search_notes.js b/src/public/javascripts/services/search_notes.js index 2145ea02e..a11cb29b8 100644 --- a/src/public/javascripts/services/search_notes.js +++ b/src/public/javascripts/services/search_notes.js @@ -142,6 +142,12 @@ async function refreshSearch() { toastService.showMessage("Saved search note refreshed."); } +function searchInSubtree(noteId) { + showSearch(); + + $searchInput.val(`@in=${noteId} @text*=*`); +} + function init() { const hashValue = document.location.hash ? document.location.hash.substr(1) : ""; // strip initial # @@ -178,5 +184,6 @@ export default { refreshSearch, doSearch, init, + searchInSubtree, getHelpText: () => helpText }; \ No newline at end of file diff --git a/src/public/javascripts/services/tree_context_menu.js b/src/public/javascripts/services/tree_context_menu.js index 6cb5fc320..50cf6b3d1 100644 --- a/src/public/javascripts/services/tree_context_menu.js +++ b/src/public/javascripts/services/tree_context_menu.js @@ -9,6 +9,7 @@ import hoistedNoteService from './hoisted_note.js'; import noteDetailService from './note_detail.js'; import clipboard from './clipboard.js'; import protectedSessionHolder from "./protected_session_holder.js"; +import searchNotesService from "./search_notes.js"; class TreeContextMenu { constructor(node) { @@ -55,6 +56,8 @@ class TreeContextMenu { { title: "Delete Delete", cmd: "delete", uiIcon: "trash", enabled: isNotRoot && !isHoisted && parentNotSearch }, { title: "----" }, + { title: "Search in subtree Ctrl+Shift+F", cmd: "searchInSubtree", uiIcon: "search", + enabled: notSearch && noSelectedNotes }, isHoisted ? null : { title: "Hoist note Ctrl-H", cmd: "hoist", uiIcon: "empty", enabled: noSelectedNotes && notSearch }, !isHoisted || !isNotRoot ? null : { title: "Unhoist note Ctrl-H", cmd: "unhoist", uiIcon: "arrow-up" }, { title: "Edit branch prefix F2", cmd: "editBranchPrefix", uiIcon: "empty", @@ -177,6 +180,9 @@ class TreeContextMenu { treeService.duplicateNote(this.node.data.noteId, branch.parentNoteId); } + else if (cmd === "searchInSubtree") { + searchNotesService.searchInSubtree(this.node.data.noteId); + } else { ws.logError("Unknown command: " + cmd); } diff --git a/src/public/javascripts/services/tree_keybindings.js b/src/public/javascripts/services/tree_keybindings.js index eb5d4b4f7..e93279f2e 100644 --- a/src/public/javascripts/services/tree_keybindings.js +++ b/src/public/javascripts/services/tree_keybindings.js @@ -4,6 +4,7 @@ import treeService from "./tree.js"; import hoistedNoteService from "./hoisted_note.js"; import clipboard from "./clipboard.js"; import treeCache from "./tree_cache.js"; +import searchNoteService from "./search_notes.js"; const keyBindings = { "del": node => { @@ -167,6 +168,11 @@ const keyBindings = { "down": node => { node.navigate($.ui.keyCode.DOWN, true).then(treeService.clearSelectedNodes); + return false; + }, + "ctrl+shift+f": node => { + searchNoteService.searchInSubtree(node.data.noteId); + return false; } }; From 07043fb177afb9d754428a410b3019d53d7b6fa0 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 19 Nov 2019 23:04:43 +0100 Subject: [PATCH 2/3] switch search in subtree to ctrl+shift+s to stay consistent with ctrl+s --- src/public/javascripts/services/tree_context_menu.js | 2 +- src/public/javascripts/services/tree_keybindings.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/public/javascripts/services/tree_context_menu.js b/src/public/javascripts/services/tree_context_menu.js index 50cf6b3d1..43e8c6292 100644 --- a/src/public/javascripts/services/tree_context_menu.js +++ b/src/public/javascripts/services/tree_context_menu.js @@ -56,7 +56,7 @@ class TreeContextMenu { { title: "Delete Delete", cmd: "delete", uiIcon: "trash", enabled: isNotRoot && !isHoisted && parentNotSearch }, { title: "----" }, - { title: "Search in subtree Ctrl+Shift+F", cmd: "searchInSubtree", uiIcon: "search", + { title: "Search in subtree Ctrl+Shift+S", cmd: "searchInSubtree", uiIcon: "search", enabled: notSearch && noSelectedNotes }, isHoisted ? null : { title: "Hoist note Ctrl-H", cmd: "hoist", uiIcon: "empty", enabled: noSelectedNotes && notSearch }, !isHoisted || !isNotRoot ? null : { title: "Unhoist note Ctrl-H", cmd: "unhoist", uiIcon: "arrow-up" }, diff --git a/src/public/javascripts/services/tree_keybindings.js b/src/public/javascripts/services/tree_keybindings.js index e93279f2e..1ce0b43c9 100644 --- a/src/public/javascripts/services/tree_keybindings.js +++ b/src/public/javascripts/services/tree_keybindings.js @@ -170,7 +170,7 @@ const keyBindings = { return false; }, - "ctrl+shift+f": node => { + "ctrl+shift+s": node => { searchNoteService.searchInSubtree(node.data.noteId); return false; From d357943ebb4469db3728423a155cd38323597cbc Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 19 Nov 2019 23:05:54 +0100 Subject: [PATCH 3/3] release 0.37.3 --- package.json | 2 +- src/services/build.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 002203a60..4a95fdcc3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "Trilium Notes", "description": "Trilium Notes", - "version": "0.37.2", + "version": "0.37.3", "license": "AGPL-3.0-only", "main": "electron.js", "bin": { diff --git a/src/services/build.js b/src/services/build.js index 6f9ca3968..d137ff116 100644 --- a/src/services/build.js +++ b/src/services/build.js @@ -1 +1 @@ -module.exports = { buildDate:"2019-11-18T23:04:09+01:00", buildRevision: "834e1f7253186922d2b5df2f6a01c34f7c2d7fe4" }; +module.exports = { buildDate:"2019-11-19T23:05:54+01:00", buildRevision: "07043fb177afb9d754428a410b3019d53d7b6fa0" };