mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
Add full text search in autocomplete results
This commit is contained in:
parent
5370e1e27c
commit
1d1c7eb2ca
@ -94,21 +94,21 @@ function showRecentNotes($el) {
|
||||
|
||||
$el.setSelectedNotePath("");
|
||||
$el.autocomplete("val", "");
|
||||
$el.autocomplete('open');
|
||||
$el.trigger('focus');
|
||||
|
||||
// simulate pressing down arrow to trigger autocomplete
|
||||
const e = $.Event('keydown');
|
||||
e.which = 40; // arrow down
|
||||
$el.trigger(e);
|
||||
}
|
||||
|
||||
function fullTextSearch($el,options){
|
||||
const searchString = $el.autocomplete("val")
|
||||
const searchString = $el.autocomplete('val');
|
||||
if (searchString.trim().length >= 1) {
|
||||
const originalFastSearch = options.fastSearch;
|
||||
clearText($el);
|
||||
options.fastSearch = false;
|
||||
$el.autocomplete("val", searchString);
|
||||
$el.autocomplete('val', searchString);
|
||||
$el.autocomplete('open');
|
||||
options.fastSearch = true;
|
||||
$el.trigger('focus');
|
||||
options.fastSearch = originalFastSearch;
|
||||
}
|
||||
}
|
||||
|
||||
function initNoteAutocomplete($el, options) {
|
||||
@ -120,6 +120,7 @@ function initNoteAutocomplete($el, options) {
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
options.fastSearch = true; // Perform fast search by default
|
||||
|
||||
$el.addClass("note-autocomplete-input");
|
||||
|
||||
@ -133,7 +134,7 @@ function initNoteAutocomplete($el, options) {
|
||||
|
||||
const $fullTextSearchButton = $("<button>")
|
||||
.addClass("input-group-text full-text-search-button bx bx-search")
|
||||
.prop("title", "Full text search. (Shift+Enter)");
|
||||
.prop("title", "Full text search (Shift+Enter)");
|
||||
|
||||
const $goToSelectedNoteButton = $("<button>")
|
||||
.addClass("input-group-text go-to-selected-note-button bx bx-arrow-to-right");
|
||||
@ -183,7 +184,6 @@ function initNoteAutocomplete($el, options) {
|
||||
}
|
||||
});
|
||||
|
||||
options.fastSearch = true; // Perform fast search by default
|
||||
$el.autocomplete({
|
||||
...autocompleteOptions,
|
||||
appendTo: document.querySelector('body'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user