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
moving edit branch prefix, search in subtree and toggle note hoisting to global entrypoints instead of being tree specific
zadam01ff34b5d428
diff --git a/src/public/javascripts/dialogs/branch_prefix.js b/src/public/javascripts/dialogs/branch_prefix.jsindex 443ae7c305..e9aa1cd649 100644--- a/src/public/javascripts/dialogs/branch_prefix.js+++ b/src/public/javascripts/dialogs/branch_prefix.js@@ -17,11 +17,21 @@ export async function showDialog(node) {glob.activeDialog = $dialog;- $dialog.modal();-branchId = node.data.branchId;const branch = treeCache.getBranch(branchId);+ if (branch.noteId === 'root') {+ return;+ }++ const parentNote = await treeCache.getNote(branch.parentNoteId);++ if (parentNote.type === 'search') {+ return;+ }++ $dialog.modal();+$treePrefixInput.val(branch.prefix);const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);diff --git a/src/public/javascripts/services/entrypoints.js b/src/public/javascripts/services/entrypoints.jsindex 67dd540544..a05a4aaa9b 100644--- a/src/public/javascripts/services/entrypoints.js+++ b/src/public/javascripts/services/entrypoints.js@@ -7,6 +7,8 @@ import treeService from "./tree.js";import dateNoteService from "./date_notes.js";import noteDetailService from "./note_detail.js";import keyboardActionService from "./keyboard_actions.js";+import hoistedNoteService from "./hoisted_note.js";+import treeCache from "./tree_cache.js";const NOTE_REVISIONS = "../dialogs/note_revisions.js";const OPTIONS = "../dialogs/options.js";@@ -113,7 +115,7 @@ function registerEntrypoints() {$("#toggle-zen-mode-button").on('click', toggleZenMode);keyboardActionService.setActionHandler("ToggleZenMode", toggleZenMode);- keyboardActionService.setActionHandler("InsertDateTime", () => {+ keyboardActionService.setActionHandler("InsertDateTimeToText", () => {const date = new Date();const dateString = utils.formatDateTime(date);@@ -230,6 +232,36 @@ function registerEntrypoints() {isProtected: node.data.isProtected});});++ keyboardActionService.setActionHandler("EditBranchPrefix", async () => {+ const node = treeService.getActiveNode();++ const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js");+ editBranchPrefixDialog.showDialog(node);+ });++ keyboardActionService.setActionHandler("ToggleNoteHoisting", async () => {+ const node = treeService.getActiveNode();++ hoistedNoteService.getHoistedNoteId().then(async hoistedNoteId => {+ if (node.data.noteId === hoistedNoteId) {+ hoistedNoteService.unhoist();+ }+ else {+ const note = await treeCache.getNote(node.data.noteId);++ if (note.type !== 'search') {+ hoistedNoteService.setHoistedNoteId(node.data.noteId);+ }+ }+ });+ });++ keyboardActionService.setActionHandler("SearchInSubtree", () => {+ const node = treeService.getActiveNode();++ searchNotesService.searchInSubtree(node.data.noteId);+ });}export default {diff --git a/src/public/javascripts/services/tree_keybindings.js b/src/public/javascripts/services/tree_keybindings.jsindex 27efd93d28..63c35c1b6f 100644--- a/src/public/javascripts/services/tree_keybindings.js+++ b/src/public/javascripts/services/tree_keybindings.js@@ -114,11 +114,6 @@ const templates = {return false;},- // TODO: this shouldn't be tree specific shortcut- "EditBranchPrefix": async node => {- const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js");- editBranchPrefixDialog.showDialog(node);- },"CollapseSubtree": node => {treeService.collapseTree(node);},@@ -158,28 +153,6 @@ const templates = {if (!await hoistedNoteService.isRootNode(node)) {node.getParent().setActive().then(treeService.clearSelectedNodes);}- },- // TODO: this should probably be app-global shortcut- "ToggleNoteHoisting": node => {- hoistedNoteService.getHoistedNoteId().then(async hoistedNoteId => {- if (node.data.noteId === hoistedNoteId) {- hoistedNoteService.unhoist();- }- else {- const note = await treeCache.getNote(node.data.noteId);-- if (note.type !== 'search') {- hoistedNoteService.setHoistedNoteId(node.data.noteId);- }- }- });-- return false;- },- "SearchInSubtree": node => {- searchNoteService.searchInSubtree(node.data.noteId);-- return false;}};