mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	added jump to note functionality
This commit is contained in:
		| @@ -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> | ||||
|  | ||||
|   | ||||
| @@ -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]; | ||||
|  | ||||
|   | ||||
| @@ -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); | ||||
| @@ -201,3 +205,30 @@ $(document).bind('keydown', 'alt+t', function() { | ||||
|  | ||||
|     $('#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; | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user