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,
|
branchId: branchEntity.branchId,
|
||||||
isProtected: isProtected,
|
isProtected: isProtected,
|
||||||
extraClasses: await treeBuilder.getExtraClasses(noteEntity),
|
extraClasses: await treeBuilder.getExtraClasses(noteEntity),
|
||||||
icon: treeBuilder.getIcon(noteEntity)
|
icon: await treeBuilder.getIcon(noteEntity)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (target === 'after') {
|
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') {
|
if (note.noteId === 'root') {
|
||||||
return "jam jam-chevrons-right";
|
return "jam jam-chevrons-right";
|
||||||
}
|
}
|
||||||
|
else if (note.noteId === hoistedNoteId) {
|
||||||
|
return "jam jam-arrow-up";
|
||||||
|
}
|
||||||
else if (note.type === 'text') {
|
else if (note.type === 'text') {
|
||||||
if (note.hasChildren()) {
|
if (note.hasChildren()) {
|
||||||
return "jam jam-folder";
|
return "jam jam-folder";
|
||||||
@ -70,6 +75,7 @@ function getIcon(note) {
|
|||||||
async function prepareNode(branch) {
|
async function prepareNode(branch) {
|
||||||
const note = await branch.getNote();
|
const note = await branch.getNote();
|
||||||
const title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title;
|
const title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title;
|
||||||
|
const hoistedNoteId = await hoistedNoteService.getHoistedNoteId();
|
||||||
|
|
||||||
const node = {
|
const node = {
|
||||||
noteId: note.noteId,
|
noteId: note.noteId,
|
||||||
@ -78,9 +84,9 @@ async function prepareNode(branch) {
|
|||||||
isProtected: note.isProtected,
|
isProtected: note.isProtected,
|
||||||
title: utils.escapeHtml(title),
|
title: utils.escapeHtml(title),
|
||||||
extraClasses: await getExtraClasses(note),
|
extraClasses: await getExtraClasses(note),
|
||||||
icon: getIcon(note),
|
icon: await getIcon(note),
|
||||||
refKey: note.noteId,
|
refKey: note.noteId,
|
||||||
expanded: note.type !== 'search' && branch.isExpanded
|
expanded: (note.type !== 'search' && branch.isExpanded) || hoistedNoteId === note.noteId
|
||||||
};
|
};
|
||||||
|
|
||||||
if (note.hasChildren() || note.type === 'search') {
|
if (note.hasChildren() || note.type === 'search') {
|
||||||
@ -148,10 +154,6 @@ async function getExtraClasses(note) {
|
|||||||
|
|
||||||
const extraClasses = [];
|
const extraClasses = [];
|
||||||
|
|
||||||
if (note.noteId === 'root') {
|
|
||||||
extraClasses.push("tree-root");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (note.isProtected) {
|
if (note.isProtected) {
|
||||||
extraClasses.push("protected");
|
extraClasses.push("protected");
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,8 @@ const contextMenuItems = [
|
|||||||
{title: "Insert child note <kbd>Ctrl+P</kbd>", cmd: "insertChildNote", uiIcon: "plus"},
|
{title: "Insert child note <kbd>Ctrl+P</kbd>", cmd: "insertChildNote", uiIcon: "plus"},
|
||||||
{title: "Delete", cmd: "delete", uiIcon: "trash"},
|
{title: "Delete", cmd: "delete", uiIcon: "trash"},
|
||||||
{title: "----"},
|
{title: "----"},
|
||||||
{title: "Hoist note", cmd: "hoist", uiIcon: "arrow-up"},
|
{title: "Hoist note <kbd>CTRL-H</kbd>", cmd: "hoist", uiIcon: "arrow-up"},
|
||||||
{title: "Unhoist note", cmd: "unhoist", 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: "Edit branch prefix <kbd>F2</kbd>", cmd: "editBranchPrefix", uiIcon: "pencil"},
|
||||||
{title: "----"},
|
{title: "----"},
|
||||||
{title: "Protect subtree", cmd: "protectSubtree", uiIcon: "shield-check"},
|
{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 contextMenuService from "./tree_context_menu.js";
|
||||||
import treeService from "./tree.js";
|
import treeService from "./tree.js";
|
||||||
import editBranchPrefixDialog from "../dialogs/branch_prefix.js";
|
import editBranchPrefixDialog from "../dialogs/branch_prefix.js";
|
||||||
|
import hoistedNoteService from "./hoisted_note.js";
|
||||||
|
|
||||||
const keyBindings = {
|
const keyBindings = {
|
||||||
"del": node => {
|
"del": node => {
|
||||||
@ -113,6 +114,18 @@ const keyBindings = {
|
|||||||
node.getParent().setActive().then(treeService.clearSelectedNodes);
|
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
|
// 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
|
// after opening context menu, standard shortcuts don't work, but they are detected here
|
||||||
// so we essentially takeover the standard handling with our implementation.
|
// so we essentially takeover the standard handling with our implementation.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user