diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 39d64b652..1bfe15f4f 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, saveSelection branchId: 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.js index 63ff8fec7..2fc6a2c2e 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.js index fa44e2f46..d8d1f05fc 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 Ctrl+P", 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 CTRL-H", cmd: "hoist", uiIcon: "arrow-up"}, + {title: "Unhoist note CTRL-H", cmd: "unhoist", uiIcon: "arrow-up"}, {title: "Edit branch prefix F2", 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.js index 03d0138d4..b3c8fca26 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.