From 96e2b9bc1832c4179e75f33b261c306e02df1e02 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 2 Feb 2020 10:10:37 +0100 Subject: [PATCH] fix tree keyboard shortcuts propagating outside of tree --- .../javascripts/services/keyboard_actions.js | 6 ++- .../javascripts/services/spaced_update.js | 2 +- .../javascripts/widgets/search_results.js | 8 +-- src/services/keyboard_actions.js | 50 ++++++++++++------- 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/public/javascripts/services/keyboard_actions.js b/src/public/javascripts/services/keyboard_actions.js index 16f802523..e021b8b10 100644 --- a/src/public/javascripts/services/keyboard_actions.js +++ b/src/public/javascripts/services/keyboard_actions.js @@ -12,8 +12,10 @@ const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => { if (shortcut && !shortcut.startsWith("global:")) { // global shortcuts should be handled in the electron code const eventName = action.actionName.charAt(0).toLowerCase() + action.actionName.slice(1); - // empty object param so that destructuring with optional params work - utils.bindGlobalShortcut(shortcut, () => appContext.trigger(eventName, {})); + if (action.scope !== 'note-tree') { + // empty object param so that destructuring with optional params work + utils.bindGlobalShortcut(shortcut, () => appContext.trigger(eventName, {})); + } } } } diff --git a/src/public/javascripts/services/spaced_update.js b/src/public/javascripts/services/spaced_update.js index 54029ce4f..ed67f8a2b 100644 --- a/src/public/javascripts/services/spaced_update.js +++ b/src/public/javascripts/services/spaced_update.js @@ -7,7 +7,7 @@ export default class SpacedUpdate { } scheduleUpdate() { - if (!this.changeForbidden) {console.trace(); + if (!this.changeForbidden) { this.changed = true; setTimeout(() => this.triggerUpdate()); } diff --git a/src/public/javascripts/widgets/search_results.js b/src/public/javascripts/widgets/search_results.js index fac675fed..c19ec0cbe 100644 --- a/src/public/javascripts/widgets/search_results.js +++ b/src/public/javascripts/widgets/search_results.js @@ -3,7 +3,7 @@ import toastService from "../services/toast.js"; import server from "../services/server.js"; const TPL = ` -
+
Search results: -
    +
      `; @@ -32,7 +32,7 @@ export default class SearchResultsWidget extends BasicWidget { this.$widget = $(TPL); this.$searchResults = this.$widget; - this.$searchResultsInner = this.$widget.find(".search-results-inner"); + this.$searchResultsInner = this.$widget.find(".search-results-list"); this.toggle(false); diff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.js index c8b1b7dd5..a07b16e0f 100644 --- a/src/services/keyboard_actions.js +++ b/src/services/keyboard_actions.js @@ -37,26 +37,30 @@ const DEFAULT_KEYBOARD_ACTIONS = [ { actionName: "SearchInSubtree", defaultShortcuts: ["CommandOrControl+Shift+S"], - description: "Search for notes in the active note's subtree" + description: "Search for notes in the active note's subtree", + scope: "note-tree" }, { actionName: "CollapseTree", - defaultShortcuts: ["Alt+C"] + defaultShortcuts: ["Alt+C"], }, { actionName: "CollapseSubtree", defaultShortcuts: ["Alt+-"], - description: "Collapses subtree of current note" + description: "Collapses subtree of current note", + scope: "note-tree" }, { actionName: "ActivateParentNote", defaultShortcuts: ["Backspace"], - description: "Activates the parent note of currently active note" + description: "Activates the parent note of currently active note", + scope: "note-tree" }, { actionName: "SortChildNotes", defaultShortcuts: ["Alt+S"], - description: "Sort child notes" + description: "Sort child notes", + scope: "note-tree" }, @@ -79,32 +83,38 @@ const DEFAULT_KEYBOARD_ACTIONS = [ { actionName: "DeleteNotes", defaultShortcuts: ["Delete"], - description: "Delete note" + description: "Delete note", + scope: "note-tree" }, { actionName: "MoveNoteUp", defaultShortcuts: ["CommandOrControl+Up"], - description: "Move note up" + description: "Move note up", + scope: "note-tree" }, { actionName: "MoveNoteDown", defaultShortcuts: ["CommandOrControl+Down"], - description: "Move note down" + description: "Move note down", + scope: "note-tree" }, { actionName: "MoveNoteUpInHierarchy", defaultShortcuts: ["CommandOrControl+Left"], - description: "Move note up in hierarchy" + description: "Move note up in hierarchy", + scope: "note-tree" }, { actionName: "MoveNoteDownInHierarchy", defaultShortcuts: ["CommandOrControl+Right"], - description: "Move note down in hierarchy" + description: "Move note down in hierarchy", + scope: "note-tree" }, { actionName: "EditNoteTitle", defaultShortcuts: ["Enter"], - description: "Jump from tree to the note detail and edit title" + description: "Jump from tree to the note detail and edit title", + scope: "note-tree" }, { actionName: "EditBranchPrefix", @@ -128,32 +138,38 @@ const DEFAULT_KEYBOARD_ACTIONS = [ { actionName: "CopyNotesToClipboard", defaultShortcuts: ["CommandOrControl+C"], - description: "Copy selected notes to the clipboard" + description: "Copy selected notes to the clipboard", + scope: "note-tree" }, { actionName: "PasteNotesFromClipboard", defaultShortcuts: ["CommandOrControl+V"], - description: "Paste notes from the clipboard into active note" + description: "Paste notes from the clipboard into active note", + scope: "note-tree" }, { actionName: "CutNotesToClipboard", defaultShortcuts: ["CommandOrControl+X"], - description: "Cut selected notes to the clipboard" + description: "Cut selected notes to the clipboard", + scope: "note-tree" }, { actionName: "SelectAllNotesInParent", defaultShortcuts: ["CommandOrControl+A"], - description: "Select all notes from the current note level" + description: "Select all notes from the current note level", + scope: "note-tree" }, { actionName: "AddNoteAboveToSelection", defaultShortcuts: ["Shift+Up"], - description: "Add note above to the selection" + description: "Add note above to the selection", + scope: "note-tree" }, { actionName: "AddNoteBelowToSelection", defaultShortcuts: ["Shift+Down"], - description: "Add note above to the selection" + description: "Add note above to the selection", + scope: "note-tree" },