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

55 lines
1.3 KiB
JavaScript
Raw Normal View History

import noteDetailService from "./note_detail.js";
import searchNotesService from "./search_notes.js";
2019-05-04 06:16:41 +08:00
class NoteDetailSearch {
/**
2019-05-09 01:55:24 +08:00
* @param {TabContext} ctx
2019-05-04 06:16:41 +08:00
*/
constructor(ctx) {
this.ctx = ctx;
2019-05-09 01:55:24 +08:00
this.$searchString = ctx.$tabContent.find(".search-string");
this.$component = ctx.$tabContent.find('.note-detail-search');
this.$help = ctx.$tabContent.find(".note-detail-search-help");
this.$refreshButton = ctx.$tabContent.find('.note-detail-search-refresh-results-button');
2019-05-04 06:16:41 +08:00
this.$refreshButton.click(async () => {
await noteDetailService.saveNotesIfChanged();
await searchNotesService.refreshSearch();
});
}
2019-05-12 18:58:55 +08:00
render() {
2019-05-04 06:16:41 +08:00
this.$help.html(searchNotesService.getHelpText());
2019-05-04 06:16:41 +08:00
this.$component.show();
2019-04-01 03:19:10 +08:00
2019-05-04 06:16:41 +08:00
try {
const json = JSON.parse(this.ctx.note.content);
2019-05-04 06:16:41 +08:00
this.$searchString.val(json.searchString);
}
catch (e) {
console.log(e);
this.$searchString.val('');
}
2019-06-13 01:59:52 +08:00
this.$searchString.on('input', () => this.ctx.noteChanged());
}
2019-05-04 06:16:41 +08:00
getContent() {
return JSON.stringify({
searchString: this.$searchString.val()
});
}
2019-05-04 06:16:41 +08:00
focus() {}
2019-05-04 06:16:41 +08:00
onNoteChange() {}
2019-02-16 04:21:26 +08:00
2019-05-04 06:16:41 +08:00
cleanup() {}
2019-05-04 06:16:41 +08:00
scrollToTop() {}
}
2019-05-04 06:16:41 +08:00
export default NoteDetailSearch;