mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	findInText: Automatically search the selected text
This commit is contained in:
		
							parent
							
								
									88a961180f
								
							
						
					
					
						commit
						57aa0a0fe1
					
				@ -146,18 +146,26 @@ export default class FindWidget extends NoteContextAwareWidget {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        this.handler = await this.getHandler();
 | 
			
		||||
        var searchTerm = await this.handler.getInitialSearchTerm();
 | 
			
		||||
        searchTerm = searchTerm=="" ? window.getSelection().toString():searchTerm;
 | 
			
		||||
 | 
			
		||||
        this.$findBox.show();
 | 
			
		||||
        this.$input.focus();
 | 
			
		||||
        this.handler = await this.getHandler();
 | 
			
		||||
 | 
			
		||||
        const isAlreadyVisible = this.$findBox.is(":visible");
 | 
			
		||||
 | 
			
		||||
        if (isAlreadyVisible) {
 | 
			
		||||
            this.$input.val(searchTerm || "");
 | 
			
		||||
            if (searchTerm !== "") {
 | 
			
		||||
                this.$input.select();
 | 
			
		||||
                await this.performFind();
 | 
			
		||||
            }
 | 
			
		||||
            this.$input.select();
 | 
			
		||||
        } else {
 | 
			
		||||
            this.$totalFound.text(0);
 | 
			
		||||
            this.$currentFound.text(0);
 | 
			
		||||
            const searchTerm = await this.handler.getInitialSearchTerm();
 | 
			
		||||
            searchTerm = await this.handler.getInitialSearchTerm();
 | 
			
		||||
            this.$input.val(searchTerm || "");
 | 
			
		||||
            if (searchTerm !== "") {
 | 
			
		||||
                this.$input.select();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user