mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
Merge pull request #3947 from SiriusXT/master
FindInText: Automatically search the selected text
This commit is contained in:
commit
1089e84f56
@ -145,19 +145,27 @@ export default class FindWidget extends NoteContextAwareWidget {
|
|||||||
if (!['text', 'code', 'render'].includes(this.note.type)) {
|
if (!['text', 'code', 'render'].includes(this.note.type)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.handler = await this.getHandler();
|
||||||
|
var searchTerm = await this.handler.getInitialSearchTerm();
|
||||||
|
searchTerm = searchTerm=="" ? window.getSelection().toString():searchTerm;
|
||||||
|
|
||||||
this.$findBox.show();
|
this.$findBox.show();
|
||||||
this.$input.focus();
|
this.$input.focus();
|
||||||
this.handler = await this.getHandler();
|
|
||||||
|
|
||||||
const isAlreadyVisible = this.$findBox.is(":visible");
|
const isAlreadyVisible = this.$findBox.is(":visible");
|
||||||
|
|
||||||
if (isAlreadyVisible) {
|
if (isAlreadyVisible) {
|
||||||
|
this.$input.val(searchTerm || "");
|
||||||
|
if (searchTerm !== "") {
|
||||||
|
this.$input.select();
|
||||||
|
await this.performFind();
|
||||||
|
}
|
||||||
this.$input.select();
|
this.$input.select();
|
||||||
} else {
|
} else {
|
||||||
this.$totalFound.text(0);
|
this.$totalFound.text(0);
|
||||||
this.$currentFound.text(0);
|
this.$currentFound.text(0);
|
||||||
const searchTerm = await this.handler.getInitialSearchTerm();
|
searchTerm = await this.handler.getInitialSearchTerm();
|
||||||
this.$input.val(searchTerm || "");
|
this.$input.val(searchTerm || "");
|
||||||
if (searchTerm !== "") {
|
if (searchTerm !== "") {
|
||||||
this.$input.select();
|
this.$input.select();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user