mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	add link converted to module
This commit is contained in:
		
							parent
							
								
									979acc8b4a
								
							
						
					
					
						commit
						c723bfc3ac
					
				| @ -1,26 +1,32 @@ | |||||||
| $(document).bind('keydown', 'alt+l', () => { | const addLink = (function() { | ||||||
|     $("#note-autocomplete").val(''); |     const dialogEl = $("#insert-link-dialog"); | ||||||
|     $("#link-title").val(''); |     const formEl = $("#insert-link-form"); | ||||||
|  |     const autoCompleteEl = $("#note-autocomplete"); | ||||||
|  |     const noteDetailEl = $('#note-detail'); | ||||||
|  |     const linkTitleEl = $("#link-title"); | ||||||
| 
 | 
 | ||||||
|     const noteDetail = $('#note-detail'); |     function showDialog() { | ||||||
|     noteDetail.summernote('editor.saveRange'); |         noteDetailEl.summernote('editor.saveRange'); | ||||||
| 
 | 
 | ||||||
|     $("#insert-link-dialog").dialog({ |         dialogEl.dialog({ | ||||||
|             modal: true, |             modal: true, | ||||||
|             width: 500 |             width: 500 | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  |         autoCompleteEl.val('').focus(); | ||||||
|  |         linkTitleEl.val(''); | ||||||
|  | 
 | ||||||
|         function setDefaultLinkTitle(noteId) { |         function setDefaultLinkTitle(noteId) { | ||||||
|             const noteTitle = getNoteTitle(noteId); |             const noteTitle = getNoteTitle(noteId); | ||||||
| 
 | 
 | ||||||
|         $("#link-title").val(noteTitle); |             linkTitleEl.val(noteTitle); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|     $("#note-autocomplete").autocomplete({ |         autoCompleteEl.autocomplete({ | ||||||
|             source: getAutocompleteItems(glob.allNoteIds), |             source: getAutocompleteItems(glob.allNoteIds), | ||||||
|             minLength: 0, |             minLength: 0, | ||||||
|             change: () => { |             change: () => { | ||||||
|             const val = $("#note-autocomplete").val(); |                 const val = autoCompleteEl.val(); | ||||||
|                 const noteId = getNodeIdFromLabel(val); |                 const noteId = getNodeIdFromLabel(val); | ||||||
| 
 | 
 | ||||||
|                 if (noteId) { |                 if (noteId) { | ||||||
| @ -35,22 +41,21 @@ $(document).bind('keydown', 'alt+l', () => { | |||||||
|                 setDefaultLinkTitle(noteId); |                 setDefaultLinkTitle(noteId); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
| }); |     } | ||||||
| 
 | 
 | ||||||
| $("#insert-link-form").submit(() => { |     formEl.submit(() => { | ||||||
|     let val = $("#note-autocomplete").val(); |         let val = autoCompleteEl.val(); | ||||||
| 
 | 
 | ||||||
|         const noteId = getNodeIdFromLabel(val); |         const noteId = getNodeIdFromLabel(val); | ||||||
| 
 | 
 | ||||||
|         if (noteId) { |         if (noteId) { | ||||||
|         const linkTitle = $("#link-title").val(); |             const linkTitle = linkTitleEl.val(); | ||||||
|         const noteDetail = $('#note-detail'); |  | ||||||
| 
 | 
 | ||||||
|         $("#insert-link-dialog").dialog("close"); |             dialogEl.dialog("close"); | ||||||
| 
 | 
 | ||||||
|         noteDetail.summernote('editor.restoreRange'); |             noteDetailEl.summernote('editor.restoreRange'); | ||||||
| 
 | 
 | ||||||
|         noteDetail.summernote('createLink', { |             noteDetailEl.summernote('createLink', { | ||||||
|                 text: linkTitle, |                 text: linkTitle, | ||||||
|                 url: 'app#' + noteId, |                 url: 'app#' + noteId, | ||||||
|                 isNewWindow: true |                 isNewWindow: true | ||||||
| @ -104,3 +109,10 @@ function getNodeIdFromLabel(label) { | |||||||
| 
 | 
 | ||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     $(document).bind('keydown', 'alt+l', showDialog); | ||||||
|  | 
 | ||||||
|  |     return { | ||||||
|  |         showDialog | ||||||
|  |     }; | ||||||
|  | })(); | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner