Skip to content

Build your personal knowledge base with Trilium Notes

added jump to note functionality

azivnera54207dc07f1
diff --git a/src/templates/app.html b/src/templates/app.html
index 9f3262775a..ec08d7725f 100644
--- a/src/templates/app.html
+++ b/src/templates/app.html
@@ -109,7 +109,18 @@
<input id="linkTitle" style="width: 100%;">
</div>
- <button id="addLinkButton" class="btn btn-sm">Add link</button>
+ <button class="btn btn-sm">Add link</button>
+ </form>
+ </div>
+
+ <div id="jumpToNoteDialog" title="Jumpt to note" style="display: none;">
+ <form id="jumpToNoteForm">
+ <div class="form-group">
+ <label for="jumpToNoteAutocomplete">Jump to note</label>
+ <input id="jumpToNoteAutocomplete" style="width: 100%;">
+ </div>
+
+ <button class="btn btn-sm">Jump</button>
</form>
</div>
diff --git a/static/js/html2notecase.js b/static/js/html2notecase.js
index e8e4c230ef..ada8f6aee5 100644
--- a/static/js/html2notecase.js
+++ b/static/js/html2notecase.js
@@ -84,8 +84,6 @@ function html2notecase(contents, note) {
const linkMatch = /^<a[^>]+?href="([^"]+?)"[^>]*?>([^<]+?)<\/a>/.exec(curContent);
if (linkMatch !== null) {
- console.log("matched link: ", linkMatch);
-
const targetUrl = linkMatch[1];
const linkText = linkMatch[2];
diff --git a/static/js/init.js b/static/js/init.js
index e5fde4b7c3..812c0d943f 100644
--- a/static/js/init.js
+++ b/static/js/init.js
@@ -107,6 +107,21 @@ function getNodeIdFromLabel(label) {
return null;
}
+function getAutocompleteItems() {
+ const autocompleteItems = [];
+
+ for (const noteId of globalAllNoteIds) {
+ const fullName = getFullName(noteId);
+
+ autocompleteItems.push({
+ value: fullName + " (" + noteId + ")",
+ label: fullName
+ });
+ }
+
+ return autocompleteItems;
+}
+
$(document).bind('keydown', 'alt+l', function() {
$("#noteAutocomplete").val('');
$("#linkTitle").val('');
@@ -119,17 +134,6 @@ $(document).bind('keydown', 'alt+l', function() {
width: 500
});
- let autocompleteItems = [];
-
- for (const noteId of globalAllNoteIds) {
- let fullName = getFullName(noteId);
-
- autocompleteItems.push({
- value: fullName + " (" + noteId + ")",
- label: fullName
- });
- }
-
function setDefaultLinkTitle(noteId) {
const note = getNodeByKey(noteId);
if (!note) {
@@ -146,7 +150,7 @@ $(document).bind('keydown', 'alt+l', function() {
}
$("#noteAutocomplete").autocomplete({
- source: autocompleteItems,
+ source: getAutocompleteItems(),
minLength: 0,
change: function () {
const val = $("#noteAutocomplete").val();
@@ -166,7 +170,7 @@ $(document).bind('keydown', 'alt+l', function() {
});
});
-$("#insertLinkForm").submit(function addLink() {
+$("#insertLinkForm").submit(function() {
let val = $("#noteAutocomplete").val();
const noteId = getNodeIdFromLabel(val);
@@ -200,4 +204,31 @@ $(document).bind('keydown', 'alt+t', function() {
date.getHours() + ":" + date.getMinutes();
$('#noteDetail').summernote('insertText', dateString);
+});
+
+$(document).bind('keydown', 'alt+j', function() {
+ $("#jumpToNoteAutocomplete").val('');
+
+ $("#jumpToNoteDialog").dialog({
+ modal: true,
+ width: 500
+ });
+
+ $("#jumpToNoteAutocomplete").autocomplete({
+ source: getAutocompleteItems(),
+ minLength: 0
+ });
+});
+
+$("#jumpToNoteForm").submit(function() {
+ const val = $("#jumpToNoteAutocomplete").val();
+ const noteId = getNodeIdFromLabel(val);
+
+ if (noteId) {
+ getNodeByKey(noteId).setActive();
+
+ $("#jumpToNoteDialog").dialog('close');
+ }
+
+ return false;
});
\ No newline at end of file