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
fixed jump to note
azivnerc8aaf6085d2a
diff --git a/public/javascripts/dialogs/add_link.js b/public/javascripts/dialogs/add_link.jsindex 02f3c43c21..aeed99bd62 100644--- a/public/javascripts/dialogs/add_link.js+++ b/public/javascripts/dialogs/add_link.js@@ -31,7 +31,7 @@ const addLink = (function() {minLength: 0,change: () => {const val = autoCompleteEl.val();- const noteId = link.getNodeIdFromLabel(val);+ const noteId = link.getNodePathFromLabel(val);if (noteId) {setDefaultLinkTitle(noteId);@@ -40,7 +40,7 @@ const addLink = (function() {// this is called when user goes through autocomplete list with keyboard// at this point the item isn't selected yet so we use supplied ui.item to see where the cursor isfocus: (event, ui) => {- const noteId = link.getNodeIdFromLabel(ui.item.value);+ const noteId = link.getNodePathFromLabel(ui.item.value);setDefaultLinkTitle(noteId);}@@ -50,7 +50,7 @@ const addLink = (function() {formEl.submit(() => {let val = autoCompleteEl.val();- const noteId = link.getNodeIdFromLabel(val);+ const noteId = link.getNodePathFromLabel(val);if (noteId) {const linkTitle = linkTitleEl.val();diff --git a/public/javascripts/dialogs/jump_to_note.js b/public/javascripts/dialogs/jump_to_note.jsindex 8051fd8d24..50c232c8ea 100644--- a/public/javascripts/dialogs/jump_to_note.js+++ b/public/javascripts/dialogs/jump_to_note.js@@ -5,7 +5,7 @@ const jumpToNote = (function() {const autoCompleteEl = $("#jump-to-note-autocomplete");const formEl = $("#jump-to-note-form");- function showDialog() {+ async function showDialog() {glob.activeDialog = dialogEl;autoCompleteEl.val('');@@ -15,23 +15,31 @@ const jumpToNote = (function() {width: 800});- autoCompleteEl.autocomplete({+ await autoCompleteEl.autocomplete({source: noteTree.getAutocompleteItems(),minLength: 0});}- $(document).bind('keydown', 'alt+j', showDialog);-- formEl.submit(() => {+ function goToNote() {const val = autoCompleteEl.val();- const noteId = link.getNodeIdFromLabel(val);+ const notePath = link.getNodePathFromLabel(val);- if (noteId) {- noteTree.activateNode(noteId);+ if (notePath) {+ noteTree.activateNode(notePath);dialogEl.dialog('close');}+ }++ $(document).bind('keydown', 'alt+j', showDialog);++ formEl.submit(() => {+ const action = dialogEl.find("button:focus").val();++ if (action === 'jump') {+ goToNote();+ }return false;});diff --git a/public/javascripts/init.js b/public/javascripts/init.jsindex c96fea726f..490c98b12a 100644--- a/public/javascripts/init.js+++ b/public/javascripts/init.js@@ -79,7 +79,7 @@ $.ui.autocomplete.filter = (array, terms) => {$(document).tooltip({items: ".note-editable a",content: function(callback) {- const noteId = link.getNoteIdFromLink($(this).attr("href"));+ const noteId = link.getNotePathFromLink($(this).attr("href"));if (noteId !== null) {noteEditor.loadNote(noteId).then(note => callback(note.detail.note_text));diff --git a/public/javascripts/link.js b/public/javascripts/link.jsindex 541f401d6d..580005b927 100644--- a/public/javascripts/link.js+++ b/public/javascripts/link.js@@ -1,22 +1,22 @@"use strict";const link = (function() {- function getNoteIdFromLink(url) {- const noteIdMatch = /app#([A-Za-z0-9]+)$/.exec(url);+ function getNotePathFromLink(url) {+ const notePathMatch = /app#([A-Za-z0-9/]+)$/.exec(url);- if (noteIdMatch === null) {+ if (notePathMatch === null) {return null;}else {- return noteIdMatch[1];+ return notePathMatch[1];}}- function getNodeIdFromLabel(label) {- const noteIdMatch = / \(([A-Za-z0-9]+)\)/.exec(label);+ function getNodePathFromLabel(label) {+ const notePathMatch = / \(([A-Za-z0-9/]+)\)/.exec(label);- if (noteIdMatch !== null) {- return noteIdMatch[1];+ if (notePathMatch !== null) {+ return notePathMatch[1];}return null;@@ -37,7 +37,7 @@ const link = (function() {let noteId = linkEl.attr("note-id");if (!noteId) {- noteId = getNoteIdFromLink(linkEl.attr('href'));+ noteId = getNotePathFromLink(linkEl.attr('href'));}if (noteId) {@@ -64,8 +64,8 @@ const link = (function() {$(document).on('dblclick', '.note-editable a, div.ui-tooltip-content', goToInternalNote);return {- getNodeIdFromLabel,- getNoteIdFromLink,+ getNodePathFromLabel,+ getNotePathFromLink,createNoteLink};})();\ No newline at end of filediff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.jsindex 05bf3b3253..574f2903b5 100644--- a/public/javascripts/note_tree.js+++ b/public/javascripts/note_tree.js@@ -468,7 +468,7 @@ const noteTree = (function() {const childTitlePath = (titlePath ? (titlePath + ' / ') : '') + getNoteTitle(childNoteId);autocompleteItems.push({- value: childNotePath,+ value: childTitlePath + ' (' + childNotePath + ')',label: childTitlePath});diff --git a/views/index.ejs b/views/index.ejsindex df64f280eb..c1337dbc1f 100644--- a/views/index.ejs+++ b/views/index.ejs@@ -137,7 +137,13 @@<input id="jump-to-note-autocomplete" style="width: 100%;"></div>- <button class="btn btn-sm">Jump</button>+ <button name="action" value="jump" class="btn btn-sm">Jump</button>++ <button name="action" value="add-link" class="btn btn-sm">Add link</button>++ <button name="action" value="add-current-as-child" class="btn btn-sm">Add current as child</button>++ <button name="action" value="add-selected-as-child" class="btn btn-sm">Add selected as child</button></form></div>