fix tree keyboard shortcuts propagating outside of tree

This commit is contained in:
zadam 2020-02-02 10:10:37 +01:00
parent 0054a32dc7
commit 96e2b9bc18
4 changed files with 42 additions and 24 deletions

View File

@ -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 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); const eventName = action.actionName.charAt(0).toLowerCase() + action.actionName.slice(1);
// empty object param so that destructuring with optional params work if (action.scope !== 'note-tree') {
utils.bindGlobalShortcut(shortcut, () => appContext.trigger(eventName, {})); // empty object param so that destructuring with optional params work
utils.bindGlobalShortcut(shortcut, () => appContext.trigger(eventName, {}));
}
} }
} }
} }

View File

@ -7,7 +7,7 @@ export default class SpacedUpdate {
} }
scheduleUpdate() { scheduleUpdate() {
if (!this.changeForbidden) {console.trace(); if (!this.changeForbidden) {
this.changed = true; this.changed = true;
setTimeout(() => this.triggerUpdate()); setTimeout(() => this.triggerUpdate());
} }

View File

@ -3,7 +3,7 @@ import toastService from "../services/toast.js";
import server from "../services/server.js"; import server from "../services/server.js";
const TPL = ` const TPL = `
<div> <div class="search-results">
<style> <style>
.search-results { .search-results {
padding: 0 5px 5px 15px; padding: 0 5px 5px 15px;
@ -16,14 +16,14 @@ const TPL = `
border-bottom: 2px solid var(--main-border-color); border-bottom: 2px solid var(--main-border-color);
} }
.search-results ul { .search-results-list {
padding: 5px 5px 5px 15px; padding: 5px 5px 5px 15px;
} }
</style> </style>
<strong>Search results:</strong> <strong>Search results:</strong>
<ul class="search-results-inner"></ul> <ul class="search-results-list"></ul>
</div> </div>
`; `;
@ -32,7 +32,7 @@ export default class SearchResultsWidget extends BasicWidget {
this.$widget = $(TPL); this.$widget = $(TPL);
this.$searchResults = this.$widget; this.$searchResults = this.$widget;
this.$searchResultsInner = this.$widget.find(".search-results-inner"); this.$searchResultsInner = this.$widget.find(".search-results-list");
this.toggle(false); this.toggle(false);

View File

@ -37,26 +37,30 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{ {
actionName: "SearchInSubtree", actionName: "SearchInSubtree",
defaultShortcuts: ["CommandOrControl+Shift+S"], 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", actionName: "CollapseTree",
defaultShortcuts: ["Alt+C"] defaultShortcuts: ["Alt+C"],
}, },
{ {
actionName: "CollapseSubtree", actionName: "CollapseSubtree",
defaultShortcuts: ["Alt+-"], defaultShortcuts: ["Alt+-"],
description: "Collapses subtree of current note" description: "Collapses subtree of current note",
scope: "note-tree"
}, },
{ {
actionName: "ActivateParentNote", actionName: "ActivateParentNote",
defaultShortcuts: ["Backspace"], 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", actionName: "SortChildNotes",
defaultShortcuts: ["Alt+S"], defaultShortcuts: ["Alt+S"],
description: "Sort child notes" description: "Sort child notes",
scope: "note-tree"
}, },
@ -79,32 +83,38 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{ {
actionName: "DeleteNotes", actionName: "DeleteNotes",
defaultShortcuts: ["Delete"], defaultShortcuts: ["Delete"],
description: "Delete note" description: "Delete note",
scope: "note-tree"
}, },
{ {
actionName: "MoveNoteUp", actionName: "MoveNoteUp",
defaultShortcuts: ["CommandOrControl+Up"], defaultShortcuts: ["CommandOrControl+Up"],
description: "Move note up" description: "Move note up",
scope: "note-tree"
}, },
{ {
actionName: "MoveNoteDown", actionName: "MoveNoteDown",
defaultShortcuts: ["CommandOrControl+Down"], defaultShortcuts: ["CommandOrControl+Down"],
description: "Move note down" description: "Move note down",
scope: "note-tree"
}, },
{ {
actionName: "MoveNoteUpInHierarchy", actionName: "MoveNoteUpInHierarchy",
defaultShortcuts: ["CommandOrControl+Left"], defaultShortcuts: ["CommandOrControl+Left"],
description: "Move note up in hierarchy" description: "Move note up in hierarchy",
scope: "note-tree"
}, },
{ {
actionName: "MoveNoteDownInHierarchy", actionName: "MoveNoteDownInHierarchy",
defaultShortcuts: ["CommandOrControl+Right"], defaultShortcuts: ["CommandOrControl+Right"],
description: "Move note down in hierarchy" description: "Move note down in hierarchy",
scope: "note-tree"
}, },
{ {
actionName: "EditNoteTitle", actionName: "EditNoteTitle",
defaultShortcuts: ["Enter"], 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", actionName: "EditBranchPrefix",
@ -128,32 +138,38 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{ {
actionName: "CopyNotesToClipboard", actionName: "CopyNotesToClipboard",
defaultShortcuts: ["CommandOrControl+C"], defaultShortcuts: ["CommandOrControl+C"],
description: "Copy selected notes to the clipboard" description: "Copy selected notes to the clipboard",
scope: "note-tree"
}, },
{ {
actionName: "PasteNotesFromClipboard", actionName: "PasteNotesFromClipboard",
defaultShortcuts: ["CommandOrControl+V"], 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", actionName: "CutNotesToClipboard",
defaultShortcuts: ["CommandOrControl+X"], defaultShortcuts: ["CommandOrControl+X"],
description: "Cut selected notes to the clipboard" description: "Cut selected notes to the clipboard",
scope: "note-tree"
}, },
{ {
actionName: "SelectAllNotesInParent", actionName: "SelectAllNotesInParent",
defaultShortcuts: ["CommandOrControl+A"], 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", actionName: "AddNoteAboveToSelection",
defaultShortcuts: ["Shift+Up"], defaultShortcuts: ["Shift+Up"],
description: "Add note above to the selection" description: "Add note above to the selection",
scope: "note-tree"
}, },
{ {
actionName: "AddNoteBelowToSelection", actionName: "AddNoteBelowToSelection",
defaultShortcuts: ["Shift+Down"], defaultShortcuts: ["Shift+Down"],
description: "Add note above to the selection" description: "Add note above to the selection",
scope: "note-tree"
}, },