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
changed note selection in tree using keyboard - now only sibling nodes are selected
zadam1e979d71c761
diff --git a/src/public/javascripts/services/tree_keybindings.js b/src/public/javascripts/services/tree_keybindings.jsindex 63c35c1b6f..43e8e6d12f 100644--- a/src/public/javascripts/services/tree_keybindings.js+++ b/src/public/javascripts/services/tree_keybindings.js@@ -3,8 +3,7 @@ import treeChangesService from "./branches.js";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";+import utils from "./utils.js";import keyboardActionService from "./keyboard_actions.js";const fixedKeyBindings = {@@ -79,15 +78,17 @@ const templates = {node.setSelected(true);}- node.navigate($.ui.keyCode.UP, false).then(() => {- const currentNode = treeService.getFocusedNode();+ const prevSibling = node.getPrevSibling();- if (currentNode.isSelected()) {+ if (prevSibling) {+ prevSibling.setActive(true, {noEvents: true});++ if (prevSibling.isSelected()) {node.setSelected(false);}- currentNode.setSelected(true);- });+ prevSibling.setSelected(true);+ }return false;},@@ -102,15 +103,17 @@ const templates = {node.setSelected(true);}- node.navigate($.ui.keyCode.DOWN, false).then(() => {- const currentNode = treeService.getFocusedNode();+ const nextSibling = node.getNextSibling();++ if (nextSibling) {+ nextSibling.setActive(true, {noEvents: true});- if (currentNode.isSelected()) {+ if (nextSibling.isSelected()) {node.setSelected(false);}- currentNode.setSelected(true);- });+ nextSibling.setSelected(true);+ }return false;},@@ -163,7 +166,9 @@ async function getKeyboardBindings() {const action = await keyboardActionService.getAction(actionName);for (const shortcut of action.effectiveShortcuts || []) {- bindings[shortcut] = templates[actionName];+ const normalizedShortcut = utils.normalizeShortcut(shortcut);++ bindings[normalizedShortcut] = templates[actionName];}}diff --git a/src/public/javascripts/services/utils.js b/src/public/javascripts/services/utils.jsindex e52e27918f..4436232dfd 100644--- a/src/public/javascripts/services/utils.js+++ b/src/public/javascripts/services/utils.js@@ -137,11 +137,7 @@ function bindGlobalShortcut(keyboardShortcut, handler) {function bindElShortcut($el, keyboardShortcut, handler) {if (isDesktop()) {- keyboardShortcut = keyboardShortcut- .toLowerCase()- .replace("enter", "return")- .replace("ctrl+alt", "alt+ctrl")- .replace("meta+alt", "alt+meta"); // alt needs to be first+ keyboardShortcut = normalizeShortcut(keyboardShortcut);$el.bind('keydown', keyboardShortcut, e => {handler(e);@@ -152,6 +148,18 @@ function bindElShortcut($el, keyboardShortcut, handler) {}}+/**+ * Normalize to the form expected by the jquery.hotkeys.js+ */+function normalizeShortcut(shortcut) {+ return shortcut+ .toLowerCase()+ .replace("enter", "return")+ .replace("delete", "del")+ .replace("ctrl+alt", "alt+ctrl")+ .replace("meta+alt", "alt+meta"); // alt needs to be first;+}+function isMobile() {return window.device === "mobile"// window.device is not available in setup@@ -260,5 +268,6 @@ export default {closeActiveDialog,isHtmlEmpty,clearBrowserCache,- getUrlForDownload+ getUrlForDownload,+ normalizeShortcut};\ No newline at end of filediff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.jsindex e66c161ae1..4d9909d546 100644--- a/src/services/keyboard_actions.js+++ b/src/services/keyboard_actions.js@@ -104,7 +104,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [{actionName: "EditNoteTitle",defaultShortcuts: ["Enter"],- description: "Edit active note title"+ description: "Jump from tree to the note detail and edit title"},{actionName: "EditBranchPrefix",@@ -117,7 +117,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [},{actionName: "MoveNotesTo",- defaultShortcuts: ["CommandOrControl+Shift+C"]+ defaultShortcuts: ["CommandOrControl+Shift+X"]},{diff --git a/src/services/notes.js b/src/services/notes.jsindex 7f8fe74ee2..85e51bdea7 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -264,7 +264,6 @@ async function saveLinks(note, content) {if (note.type === 'text') {content = findImageLinks(content, foundLinks);content = findInternalLinks(content, foundLinks);- content = findExternalLinks(content, foundLinks);}else if (note.type === 'relation-map') {findRelationMapLinks(content, foundLinks);