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
keyboard shortcut for hoisting, hoisted note is always expanded and has arrow icon
azivner86fcbb035460
diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.jsindex 39d64b652f..1bfe15f4fa 100644--- a/src/public/javascripts/services/tree.js+++ b/src/public/javascripts/services/tree.js@@ -548,7 +548,7 @@ async function createNote(node, parentNoteId, target, isProtected, saveSelectionbranchId: branchEntity.branchId,isProtected: isProtected,extraClasses: await treeBuilder.getExtraClasses(noteEntity),- icon: treeBuilder.getIcon(noteEntity)+ icon: await treeBuilder.getIcon(noteEntity)};if (target === 'after') {diff --git a/src/public/javascripts/services/tree_builder.js b/src/public/javascripts/services/tree_builder.jsindex 63ff8fec71..2fc6a2c2ef 100644--- a/src/public/javascripts/services/tree_builder.js+++ b/src/public/javascripts/services/tree_builder.js@@ -35,10 +35,15 @@ async function prepareBranch(note) {}}-function getIcon(note) {+async function getIcon(note) {+ const hoistedNoteId = await hoistedNoteService.getHoistedNoteId();+if (note.noteId === 'root') {return "jam jam-chevrons-right";}+ else if (note.noteId === hoistedNoteId) {+ return "jam jam-arrow-up";+ }else if (note.type === 'text') {if (note.hasChildren()) {return "jam jam-folder";@@ -70,6 +75,7 @@ function getIcon(note) {async function prepareNode(branch) {const note = await branch.getNote();const title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title;+ const hoistedNoteId = await hoistedNoteService.getHoistedNoteId();const node = {noteId: note.noteId,@@ -78,9 +84,9 @@ async function prepareNode(branch) {isProtected: note.isProtected,title: utils.escapeHtml(title),extraClasses: await getExtraClasses(note),- icon: getIcon(note),+ icon: await getIcon(note),refKey: note.noteId,- expanded: note.type !== 'search' && branch.isExpanded+ expanded: (note.type !== 'search' && branch.isExpanded) || hoistedNoteId === note.noteId};if (note.hasChildren() || note.type === 'search') {@@ -148,10 +154,6 @@ async function getExtraClasses(note) {const extraClasses = [];- if (note.noteId === 'root') {- extraClasses.push("tree-root");- }-if (note.isProtected) {extraClasses.push("protected");}diff --git a/src/public/javascripts/services/tree_context_menu.js b/src/public/javascripts/services/tree_context_menu.jsindex fa44e2f46a..d8d1f05fcb 100644--- a/src/public/javascripts/services/tree_context_menu.js+++ b/src/public/javascripts/services/tree_context_menu.js@@ -83,8 +83,8 @@ const contextMenuItems = [{title: "Insert child note <kbd>Ctrl+P</kbd>", cmd: "insertChildNote", uiIcon: "plus"},{title: "Delete", cmd: "delete", uiIcon: "trash"},{title: "----"},- {title: "Hoist note", cmd: "hoist", uiIcon: "arrow-up"},- {title: "Unhoist note", cmd: "unhoist", uiIcon: "arrow-up"},+ {title: "Hoist note <kbd>CTRL-H</kbd>", cmd: "hoist", uiIcon: "arrow-up"},+ {title: "Unhoist note <kbd>CTRL-H</kbd>", cmd: "unhoist", uiIcon: "arrow-up"},{title: "Edit branch prefix <kbd>F2</kbd>", cmd: "editBranchPrefix", uiIcon: "pencil"},{title: "----"},{title: "Protect subtree", cmd: "protectSubtree", uiIcon: "shield-check"},diff --git a/src/public/javascripts/services/tree_keybindings.js b/src/public/javascripts/services/tree_keybindings.jsindex 03d0138d43..b3c8fca263 100644--- a/src/public/javascripts/services/tree_keybindings.js+++ b/src/public/javascripts/services/tree_keybindings.js@@ -4,6 +4,7 @@ import treeChangesService from "./branches.js";import contextMenuService from "./tree_context_menu.js";import treeService from "./tree.js";import editBranchPrefixDialog from "../dialogs/branch_prefix.js";+import hoistedNoteService from "./hoisted_note.js";const keyBindings = {"del": node => {@@ -113,6 +114,18 @@ const keyBindings = {node.getParent().setActive().then(treeService.clearSelectedNodes);}},+ "ctrl+h": node => {+ hoistedNoteService.getHoistedNoteId().then(hoistedNoteId => {+ if (node.data.noteId === hoistedNoteId) {+ hoistedNoteService.setHoistedNoteId('root');+ }+ else {+ hoistedNoteService.setHoistedNoteId(node.data.noteId);+ }+ });++ return false;+ },// code below shouldn't be necessary normally, however there's some problem with interaction with context menu plugin// after opening context menu, standard shortcuts don't work, but they are detected here// so we essentially takeover the standard handling with our implementation.