mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	Merge pull request #4202 from eliandoran/feature/jump_to_note_list
Use a list instead of dropdown for jump-to-note
This commit is contained in:
		| @@ -106,7 +106,7 @@ function initNoteAutocomplete($el, options) { | |||||||
|     $el.addClass("note-autocomplete-input"); |     $el.addClass("note-autocomplete-input"); | ||||||
|  |  | ||||||
|     const $clearTextButton = $("<a>") |     const $clearTextButton = $("<a>") | ||||||
|             .addClass("input-group-text input-clearer-button bx bx-x") |             .addClass("input-group-text input-clearer-button bx bxs-tag-x") | ||||||
|             .prop("title", "Clear text field"); |             .prop("title", "Clear text field"); | ||||||
|  |  | ||||||
|     const $showRecentNotesButton = $("<a>") |     const $showRecentNotesButton = $("<a>") | ||||||
| @@ -137,7 +137,14 @@ function initNoteAutocomplete($el, options) { | |||||||
|         return false; |         return false; | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     let autocompleteOptions = {}; | ||||||
|  |     if (options.container) { | ||||||
|  |         autocompleteOptions.dropdownMenuContainer = options.container; | ||||||
|  |         autocompleteOptions.debug = true;   // don't close on blur | ||||||
|  |     } | ||||||
|  |  | ||||||
|     $el.autocomplete({ |     $el.autocomplete({ | ||||||
|  |         ...autocompleteOptions, | ||||||
|         appendTo: document.querySelector('body'), |         appendTo: document.querySelector('body'), | ||||||
|         hint: false, |         hint: false, | ||||||
|         autoselect: true, |         autoselect: true, | ||||||
|   | |||||||
| @@ -8,18 +8,16 @@ const TPL = `<div class="jump-to-note-dialog modal mx-auto" tabindex="-1" role=" | |||||||
|     <div class="modal-dialog modal-lg" role="document"> |     <div class="modal-dialog modal-lg" role="document"> | ||||||
|         <div class="modal-content"> |         <div class="modal-content"> | ||||||
|             <div class="modal-header"> |             <div class="modal-header"> | ||||||
|                 <h5 class="modal-title">Jump to note</h5> |                 <div class="input-group"> | ||||||
|  |                     <input class="jump-to-note-autocomplete form-control" placeholder="search for note by its name"> | ||||||
|  |                 </div> | ||||||
|  |  | ||||||
|                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> |                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||||||
|                     <span aria-hidden="true">×</span> |                     <span aria-hidden="true">×</span> | ||||||
|                 </button> |                 </button> | ||||||
|             </div> |             </div> | ||||||
|             <div class="modal-body"> |             <div class="modal-body"> | ||||||
|                 <div class="form-group"> |                 <div class="algolia-autocomplete-container jump-to-note-results"></div> | ||||||
|                     <label for="jump-to-note-autocomplete">Note</label> |  | ||||||
|                     <div class="input-group"> |  | ||||||
|                         <input class="jump-to-note-autocomplete form-control" placeholder="search for note by its name"> |  | ||||||
|                     </div> |  | ||||||
|                 </div> |  | ||||||
|             </div> |             </div> | ||||||
|             <div class="modal-footer"> |             <div class="modal-footer"> | ||||||
|                 <button class="show-in-full-text-button btn btn-sm">Search in full text <kbd>Ctrl+Enter</kbd></button> |                 <button class="show-in-full-text-button btn btn-sm">Search in full text <kbd>Ctrl+Enter</kbd></button> | ||||||
| @@ -40,6 +38,7 @@ export default class JumpToNoteDialog extends BasicWidget { | |||||||
|     doRender() { |     doRender() { | ||||||
|         this.$widget = $(TPL); |         this.$widget = $(TPL); | ||||||
|         this.$autoComplete = this.$widget.find(".jump-to-note-autocomplete"); |         this.$autoComplete = this.$widget.find(".jump-to-note-autocomplete"); | ||||||
|  |         this.$results = this.$widget.find(".jump-to-note-results"); | ||||||
|         this.$showInFullTextButton = this.$widget.find(".show-in-full-text-button"); |         this.$showInFullTextButton = this.$widget.find(".show-in-full-text-button"); | ||||||
|         this.$showInFullTextButton.on('click', e => this.showInFullText(e)); |         this.$showInFullTextButton.on('click', e => this.showInFullText(e)); | ||||||
|  |  | ||||||
| @@ -56,7 +55,11 @@ export default class JumpToNoteDialog extends BasicWidget { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     async refresh() { |     async refresh() { | ||||||
|         noteAutocompleteService.initNoteAutocomplete(this.$autoComplete, {hideGoToSelectedNoteButton: true}) |         noteAutocompleteService.initNoteAutocomplete(this.$autoComplete, { | ||||||
|  |             allowCreatingNotes: true, | ||||||
|  |             hideGoToSelectedNoteButton: true, | ||||||
|  |             container: this.$results | ||||||
|  |         }) | ||||||
|             // clear any event listener added in previous invocation of this function |             // clear any event listener added in previous invocation of this function | ||||||
|             .off('autocomplete:noteselected') |             .off('autocomplete:noteselected') | ||||||
|             .on('autocomplete:noteselected', function (event, suggestion, dataset) { |             .on('autocomplete:noteselected', function (event, suggestion, dataset) { | ||||||
|   | |||||||
| @@ -504,6 +504,11 @@ table.promoted-attributes-in-tooltip td, table.promoted-attributes-in-tooltip th | |||||||
|     z-index: 2000 !important; |     z-index: 2000 !important; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .algolia-autocomplete-container .aa-dropdown-menu { | ||||||
|  |     position: inherit !important;     | ||||||
|  |     overflow: auto; | ||||||
|  | } | ||||||
|  |  | ||||||
| .algolia-autocomplete .aa-input, .algolia-autocomplete .aa-hint { | .algolia-autocomplete .aa-input, .algolia-autocomplete .aa-hint { | ||||||
|     width: 100%; |     width: 100%; | ||||||
| } | } | ||||||
| @@ -520,18 +525,18 @@ table.promoted-attributes-in-tooltip td, table.promoted-attributes-in-tooltip th | |||||||
|     margin: 0; |     margin: 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| .algolia-autocomplete .aa-dropdown-menu .aa-suggestion { | .aa-dropdown-menu .aa-suggestion { | ||||||
|     cursor: pointer; |     cursor: pointer; | ||||||
|     padding: 5px; |     padding: 5px; | ||||||
|     margin: 0; |     margin: 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| .algolia-autocomplete .aa-dropdown-menu .aa-suggestion p { | .aa-dropdown-menu .aa-suggestion p { | ||||||
|     padding: 0; |     padding: 0; | ||||||
|     margin: 0; |     margin: 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| .algolia-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor { | .aa-dropdown-menu .aa-suggestion.aa-cursor { | ||||||
|     color: var(--active-item-text-color); |     color: var(--active-item-text-color); | ||||||
|     background-color: var(--active-item-background-color); |     background-color: var(--active-item-background-color); | ||||||
| } | } | ||||||
| @@ -1069,3 +1074,20 @@ textarea { | |||||||
|     position: relative; |     position: relative; | ||||||
|     top: 8px; |     top: 8px; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .jump-to-note-dialog .modal-header { | ||||||
|  |     align-items: center; | ||||||
|  |     padding-bottom: 1rem !important; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .jump-to-note-dialog .modal-body { | ||||||
|  |     padding: 0; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .jump-to-note-results .aa-dropdown-menu { | ||||||
|  |     max-height: 40vh; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .jump-to-note-results .aa-suggestions { | ||||||
|  |     padding: 1rem; | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user