mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
keyboard shortcut for hoisting, hoisted note is always expanded and has arrow icon
This commit is contained in:
parent
17d030e800
commit
86fcbb0354
@ -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') {
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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"},
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user