mirror of
https://github.com/zadam/trilium.git
synced 2024-12-26 17:21:23 +08:00
fuzzy search
This commit is contained in:
parent
1f19c9cd0d
commit
19561191f6
3 changed files with 31 additions and 2 deletions
|
@ -93,7 +93,7 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="jumpToNoteDialog" title="Jumpt to note" style="display: none;">
|
<div id="jumpToNoteDialog" title="Jump to note" style="display: none;">
|
||||||
<form id="jumpToNoteForm">
|
<form id="jumpToNoteForm">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="jumpToNoteAutocomplete">Jump to note</label>
|
<label for="jumpToNoteAutocomplete">Jump to note</label>
|
||||||
|
@ -139,6 +139,8 @@
|
||||||
|
|
||||||
<script src="stat/lib/jquery.ui-contextmenu.min.js"></script>
|
<script src="stat/lib/jquery.ui-contextmenu.min.js"></script>
|
||||||
|
|
||||||
|
<script src="stat/lib/fuse.min.js"></script>
|
||||||
|
|
||||||
<!-- https://github.com/ricmoo/aes-js -->
|
<!-- https://github.com/ricmoo/aes-js -->
|
||||||
<script src="stat/lib/aes.js"></script>
|
<script src="stat/lib/aes.js"></script>
|
||||||
<!-- https://github.com/emn178/js-sha256 -->
|
<!-- https://github.com/emn178/js-sha256 -->
|
||||||
|
|
|
@ -47,4 +47,22 @@ $(window).on('beforeunload', function(){
|
||||||
// this makes sure that when user e.g. reloads the page or navigates away from the page, the note's content is saved
|
// this makes sure that when user e.g. reloads the page or navigates away from the page, the note's content is saved
|
||||||
// this sends the request asynchronously and doesn't wait for result
|
// this sends the request asynchronously and doesn't wait for result
|
||||||
saveNoteIfChanged();
|
saveNoteIfChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Overrides the default autocomplete filter function to search for matched on atleast 1 word in each of the input term's words
|
||||||
|
$.ui.autocomplete.filter = function (array, terms) {
|
||||||
|
const options = {
|
||||||
|
shouldSort: true,
|
||||||
|
threshold: 0.6,
|
||||||
|
location: 0,
|
||||||
|
distance: 100,
|
||||||
|
maxPatternLength: 32,
|
||||||
|
minMatchCharLength: 1,
|
||||||
|
keys: [
|
||||||
|
"value"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const fuse = new Fuse(array, options); // "list" is the item array
|
||||||
|
return fuse.search(terms);
|
||||||
|
};
|
9
static/lib/fuse.min.js
vendored
Normal file
9
static/lib/fuse.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue