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
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, {}));
}
}
}
}

View File

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

View File

@ -3,7 +3,7 @@ import toastService from "../services/toast.js";
import server from "../services/server.js";
const TPL = `
<div>
<div class="search-results">
<style>
.search-results {
padding: 0 5px 5px 15px;
@ -16,14 +16,14 @@ const TPL = `
border-bottom: 2px solid var(--main-border-color);
}
.search-results ul {
.search-results-list {
padding: 5px 5px 5px 15px;
}
</style>
<strong>Search results:</strong>
<ul class="search-results-inner"></ul>
<ul class="search-results-list"></ul>
</div>
`;
@ -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);

View File

@ -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"
},