mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import treeService from '../services/tree.js';
 | |
| import searchNotesService from '../services/search_notes.js';
 | |
| import noteAutocompleteService from '../services/note_autocomplete.js';
 | |
| 
 | |
| const $dialog = $("#jump-to-note-dialog");
 | |
| const $autoComplete = $("#jump-to-note-autocomplete");
 | |
| const $showInFullTextButton = $("#show-in-full-text-button");
 | |
| 
 | |
| $dialog.on("shown.bs.modal", e => $autoComplete.focus());
 | |
| 
 | |
| async function showDialog() {
 | |
|     glob.activeDialog = $dialog;
 | |
| 
 | |
|     $autoComplete.val('');
 | |
| 
 | |
|     $dialog.modal();
 | |
| 
 | |
|     noteAutocompleteService.initNoteAutocomplete($autoComplete)
 | |
|         .on('autocomplete:selected', function(event, suggestion, dataset) {
 | |
|             if (!suggestion.path) {
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             treeService.activateNote(suggestion.path);
 | |
| 
 | |
|             $dialog.modal('hide');
 | |
|         });
 | |
| 
 | |
|     noteAutocompleteService.showRecentNotes($autoComplete);
 | |
| }
 | |
| 
 | |
| function showInFullText(e) {
 | |
|     // stop from propagating upwards (dangerous especially with ctrl+enter executable javascript notes)
 | |
|     e.preventDefault();
 | |
|     e.stopPropagation();
 | |
| 
 | |
|     const searchText = $autoComplete.val();
 | |
| 
 | |
|     searchNotesService.resetSearch();
 | |
|     searchNotesService.showSearch();
 | |
|     searchNotesService.doSearch(searchText);
 | |
| 
 | |
|     $dialog.modal('hide');
 | |
| }
 | |
| 
 | |
| 
 | |
| $showInFullTextButton.click(showInFullText);
 | |
| 
 | |
| $dialog.bind('keydown', 'ctrl+return', showInFullText);
 | |
| 
 | |
| export default {
 | |
|     showDialog
 | |
| }; |