mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	added "show results in full text"
This commit is contained in:
		| @@ -1,10 +1,13 @@ | ||||
| import treeService from '../services/tree.js'; | ||||
| import linkService from '../services/link.js'; | ||||
| import server from '../services/server.js'; | ||||
| import searchNotesService from '../services/search_notes.js'; | ||||
|  | ||||
| const $dialog = $("#jump-to-note-dialog"); | ||||
| const $autoComplete = $("#jump-to-note-autocomplete"); | ||||
| const $form = $("#jump-to-note-form"); | ||||
| const $jumpToNoteButton = $("#jump-to-note-button"); | ||||
| const $showInFullTextButton = $("#show-in-full-text-button"); | ||||
|  | ||||
| async function showDialog() { | ||||
|     glob.activeDialog = $dialog; | ||||
| @@ -24,12 +27,6 @@ async function showDialog() { | ||||
|         }, | ||||
|         minLength: 2 | ||||
|     }); | ||||
|  | ||||
|     $autoComplete.autocomplete("instance")._renderItem = function(ul, item) { | ||||
|         return $("<li>") | ||||
|             .append("<div>" + item.label + "</div>") | ||||
|             .appendTo(ul); | ||||
|     }; | ||||
| } | ||||
|  | ||||
| function getSelectedNotePath() { | ||||
| @@ -47,12 +44,32 @@ function goToNote() { | ||||
|     } | ||||
| } | ||||
|  | ||||
| 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.dialog('close'); | ||||
| } | ||||
|  | ||||
| $form.submit(() => { | ||||
|     goToNote(); | ||||
|  | ||||
|     return false; | ||||
| }); | ||||
|  | ||||
| $jumpToNoteButton.click(goToNote); | ||||
|  | ||||
| $showInFullTextButton.click(showInFullText); | ||||
|  | ||||
| $dialog.bind('keydown', 'ctrl+return', showInFullText); | ||||
|  | ||||
| export default { | ||||
|     showDialog | ||||
| }; | ||||
| @@ -23,7 +23,7 @@ function registerEntrypoints() { | ||||
|  | ||||
|     utils.bindShortcut('ctrl+l', addLinkDialog.showDialog); | ||||
|  | ||||
|     $("#jump-to-note-button").click(jumpToNoteDialog.showDialog); | ||||
|     $("#jump-to-note-dialog-button").click(jumpToNoteDialog.showDialog); | ||||
|     utils.bindShortcut('ctrl+j', jumpToNoteDialog.showDialog); | ||||
|  | ||||
|     $("#show-note-revisions-button").click(noteRevisionsDialog.showCurrentNoteRevisions); | ||||
|   | ||||
| @@ -11,10 +11,14 @@ const $searchBox = $("#search-box"); | ||||
| const $searchResults = $("#search-results"); | ||||
| const $searchResultsInner = $("#search-results-inner"); | ||||
|  | ||||
| function showSearch() { | ||||
|     $searchBox.show(); | ||||
|     $searchInput.focus(); | ||||
| } | ||||
|  | ||||
| function toggleSearch() { | ||||
|     if ($searchBox.is(":hidden")) { | ||||
|         $searchBox.show(); | ||||
|         $searchInput.focus(); | ||||
|         showSearch(); | ||||
|     } | ||||
|     else { | ||||
|         resetSearch(); | ||||
| @@ -32,8 +36,13 @@ function getTree() { | ||||
|     return $tree.fancytree('getTree'); | ||||
| } | ||||
|  | ||||
| async function doSearch() { | ||||
|     const searchText = $searchInput.val(); | ||||
| async function doSearch(searchText) { | ||||
|     if (searchText) { | ||||
|         $searchInput.val(searchText); | ||||
|     } | ||||
|     else { | ||||
|         searchText = $searchInput.val(); | ||||
|     } | ||||
|  | ||||
|     const results = await server.get('search/' + encodeURIComponent(searchText)); | ||||
|  | ||||
| @@ -81,5 +90,8 @@ $resetSearchButton.click(resetSearch); | ||||
| $saveSearchButton.click(saveSearch); | ||||
|  | ||||
| export default { | ||||
|     toggleSearch | ||||
|     toggleSearch, | ||||
|     resetSearch, | ||||
|     showSearch, | ||||
|     doSearch | ||||
| }; | ||||
| @@ -371,12 +371,12 @@ div.ui-tooltip { | ||||
|     display: flex; | ||||
| } | ||||
|  | ||||
| .btn { | ||||
| .btn:not(.btn-primary) { | ||||
|     border-color: #ddd; | ||||
|     background-color: #eee; | ||||
| } | ||||
|  | ||||
| .btn.active { | ||||
| .btn.active:not(.btn-primary) { | ||||
|     background-color: #ccc; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -24,7 +24,7 @@ | ||||
|         </div> | ||||
|  | ||||
|         <div style="flex-grow: 100; display: flex;"> | ||||
|           <button class="btn btn-xs" id="jump-to-note-button" title="CTRL+J">Jump to note</button> | ||||
|           <button class="btn btn-xs" id="jump-to-note-dialog-button" title="CTRL+J">Jump to note</button> | ||||
|           <button class="btn btn-xs" id="recent-notes-button" title="CTRL+E">Recent notes</button> | ||||
|           <button class="btn btn-xs" id="recent-changes-button">Recent changes</button> | ||||
|           <div> | ||||
| @@ -303,7 +303,11 @@ | ||||
|           <input id="jump-to-note-autocomplete" style="width: 100%;"> | ||||
|         </div> | ||||
|  | ||||
|         <button name="action" value="jump" class="btn btn-sm">Jump <kbd>enter</kbd></button> | ||||
|         <div style="display: flex; justify-content: space-between;"> | ||||
|           <button id="jump-to-note-button" class="btn btn-sm btn-primary">Jump <kbd>enter</kbd></button> | ||||
|  | ||||
|           <button id="show-in-full-text-button" class="btn btn-sm"><< Show results in full text <kbd>ctrl+enter</kbd></button> | ||||
|         </div> | ||||
|       </form> | ||||
|     </div> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user