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
					
				@ -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