trilium/src/public/javascripts/services/note_detail_search.js

46 lines
1 KiB
JavaScript
Raw Normal View History

import noteDetailService from "./note_detail.js";
import searchNotesService from "./search_notes.js";
const $searchString = $("#search-string");
2018-11-08 17:30:35 +08:00
const $component = $('#note-detail-search');
const $refreshButton = $('#note-detail-search-refresh-results-button');
2019-04-01 03:19:10 +08:00
const $help = $("#note-detail-search-help");
2018-03-28 09:46:38 +08:00
function show() {
2019-04-01 03:19:10 +08:00
$help.html(searchNotesService.getHelpText());
2018-11-08 17:30:35 +08:00
$component.show();
try {
const json = JSON.parse(noteDetailService.getActiveNote().content);
$searchString.val(json.searchString);
}
catch (e) {
console.log(e);
$searchString.val('');
}
$searchString.on('input', noteDetailService.noteChanged);
}
2019-02-16 04:21:26 +08:00
function getContent() {
return JSON.stringify({
searchString: $searchString.val()
});
}
$refreshButton.click(async () => {
await noteDetailService.saveNoteIfChanged();
await searchNotesService.refreshSearch();
});
export default {
getContent,
2018-03-28 09:46:38 +08:00
show,
focus: () => null,
onNoteChange: () => null,
cleanup: () => null,
scrollToTop: () => null
}