mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 18:05:55 +01:00 
			
		
		
		
	recent notes can now both jump and add link
This commit is contained in:
		
							
								
								
									
										2
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								TODO
									
									
									
									
									
								
							| @@ -28,7 +28,7 @@ Encryption: | |||||||
| Bugs: | Bugs: | ||||||
| - deleting cloned nodes ends with 500 (probably only on folders) | - deleting cloned nodes ends with 500 (probably only on folders) | ||||||
| - Uncaught Error: cannot call methods on fancytree prior to initialization; attempted to call method 'getTree' | - Uncaught Error: cannot call methods on fancytree prior to initialization; attempted to call method 'getTree' | ||||||
| - recent changes sorts 1st october to the end | - FIXED: recent changes sorts 1st october to the end | ||||||
|  |  | ||||||
| Others: | Others: | ||||||
| - dates should be stored in UTC to work correctly with time zones | - dates should be stored in UTC to work correctly with time zones | ||||||
|   | |||||||
| @@ -82,7 +82,15 @@ | |||||||
|  |  | ||||||
|     <div id="recentNotesDialog" title="Recent notes" style="display: none;"> |     <div id="recentNotesDialog" title="Recent notes" style="display: none;"> | ||||||
|       <select id="recentNotesSelectBox" size="15" style="width: 100%"> |       <select id="recentNotesSelectBox" size="15" style="width: 100%"> | ||||||
|         </select> |       </select> | ||||||
|  |  | ||||||
|  |       <br/><br/> | ||||||
|  |  | ||||||
|  |       <p> | ||||||
|  |         <button class="btn btn-sm" id="recentNotesJumpTo">Jump to</button> | ||||||
|  |           | ||||||
|  |         <button class="btn btn-sm" id="recentNotesAddLink">Add link</button> | ||||||
|  |       </p> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|     <div id="insertLinkDialog" title="Insert link" style="display: none;"> |     <div id="insertLinkDialog" title="Insert link" style="display: none;"> | ||||||
|   | |||||||
| @@ -11,16 +11,7 @@ $(document).bind('keydown', 'alt+l', function() { | |||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     function setDefaultLinkTitle(noteId) { |     function setDefaultLinkTitle(noteId) { | ||||||
|         const note = getNodeByKey(noteId); |         const noteTitle = getNoteTitle(noteId); | ||||||
|         if (!note) { |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         let noteTitle = note.title; |  | ||||||
|  |  | ||||||
|         if (noteTitle.endsWith(" (clone)")) { |  | ||||||
|             noteTitle = noteTitle.substr(0, noteTitle.length - 8); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         $("#linkTitle").val(noteTitle); |         $("#linkTitle").val(noteTitle); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -15,6 +15,8 @@ function addRecentNote(noteTreeId, noteContentId) { | |||||||
| } | } | ||||||
|  |  | ||||||
| $(document).bind('keydown', 'alt+q', function() { | $(document).bind('keydown', 'alt+q', function() { | ||||||
|  |     $('#noteDetail').summernote('editor.saveRange'); | ||||||
|  |  | ||||||
|     $("#recentNotesDialog").dialog({ |     $("#recentNotesDialog").dialog({ | ||||||
|         modal: true, |         modal: true, | ||||||
|         width: 500 |         width: 500 | ||||||
| @@ -47,23 +49,52 @@ $(document).bind('keydown', 'alt+q', function() { | |||||||
|     }); |     }); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | function getSelectedNoteIdFromRecentNotes() { | ||||||
|  |     return $("#recentNotesSelectBox option:selected").val(); | ||||||
|  | } | ||||||
|  |  | ||||||
| function setActiveNoteBasedOnRecentNotes() { | function setActiveNoteBasedOnRecentNotes() { | ||||||
|     let noteId = $("#recentNotesSelectBox option:selected").val(); |     const noteId = getSelectedNoteIdFromRecentNotes(); | ||||||
|  |  | ||||||
|     getNodeByKey(noteId).setActive(); |     getNodeByKey(noteId).setActive(); | ||||||
|  |  | ||||||
|     $("#recentNotesDialog").dialog('close'); |     $("#recentNotesDialog").dialog('close'); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function addLinkBasedOnRecentNotes() { | ||||||
|  |     const noteId = getSelectedNoteIdFromRecentNotes(); | ||||||
|  |  | ||||||
|  |     const linkTitle = getNoteTitle(noteId); | ||||||
|  |     const noteDetail = $('#noteDetail'); | ||||||
|  |  | ||||||
|  |     $("#recentNotesDialog").dialog("close"); | ||||||
|  |  | ||||||
|  |     noteDetail.summernote('editor.restoreRange'); | ||||||
|  |  | ||||||
|  |     noteDetail.summernote('createLink', { | ||||||
|  |         text: linkTitle, | ||||||
|  |         url: 'app#' + noteId, | ||||||
|  |         isNewWindow: true | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  |  | ||||||
| $('#recentNotesSelectBox').keydown(function(e) { | $('#recentNotesSelectBox').keydown(function(e) { | ||||||
|     let key = e.which; |     const key = e.which; | ||||||
|  |  | ||||||
|     if (key === 13)// the enter key code |     if (key === 13)// the enter key code | ||||||
|     { |     { | ||||||
|         setActiveNoteBasedOnRecentNotes(); |         setActiveNoteBasedOnRecentNotes(); | ||||||
|     } |     } | ||||||
|  |     else if (key === 76 /* l */) { | ||||||
|  |         addLinkBasedOnRecentNotes(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     e.preventDefault(); | ||||||
| }); | }); | ||||||
|  |  | ||||||
| $('#recentNotesSelectBox').dblclick(function(e) { | $('#recentNotesSelectBox').dblclick(function(e) { | ||||||
|     setActiveNoteBasedOnRecentNotes(); |     setActiveNoteBasedOnRecentNotes(); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | $('#recentNotesJumpTo').click(setActiveNoteBasedOnRecentNotes); | ||||||
|  | $('#recentNotesAddLink').click(addLinkBasedOnRecentNotes); | ||||||
| @@ -10,6 +10,21 @@ function getNodeByKey(noteId) { | |||||||
|     return globalTree.fancytree('getNodeByKey', noteId); |     return globalTree.fancytree('getNodeByKey', noteId); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function getNoteTitle(noteId) { | ||||||
|  |     const note = getNodeByKey(noteId); | ||||||
|  |     if (!note) { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     let noteTitle = note.title; | ||||||
|  |  | ||||||
|  |     if (noteTitle.endsWith(" (clone)")) { | ||||||
|  |         noteTitle = noteTitle.substr(0, noteTitle.length - 8); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return noteTitle; | ||||||
|  | } | ||||||
|  |  | ||||||
| function getFullName(noteId) { | function getFullName(noteId) { | ||||||
|     let note = getNodeByKey(noteId); |     let note = getNodeByKey(noteId); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user