RED-7605: Fixed search.

This commit is contained in:
Nicoleta Panaghiu 2023-09-20 11:51:38 +03:00
parent f578c0facb
commit e318ca2b3d
2 changed files with 13 additions and 3 deletions

View File

@ -382,7 +382,7 @@ export class FilePreviewScreenComponent
}
}
@HostListener('window:keyup', ['$event'])
@HostListener('document:keyup', ['$event'])
handleKeyEvent($event: KeyboardEvent) {
if (this._router.url.indexOf('/file/') < 0) {
return;
@ -396,6 +396,7 @@ export class FilePreviewScreenComponent
this.fullScreen = false;
this.closeFullScreen();
this.pdf.deactivateSearch();
window.focus();
this._changeRef.markForCheck();
}

View File

@ -102,6 +102,10 @@ export class PdfViewer {
return page$.pipe(map(page => this.#adjustPage(page)));
}
get searchActive() {
return this.instance.UI.isElementOpen('searchPanel');
}
focusSearch() {
const iframeWindow = this.#instance.UI.iframeWindow;
const input = iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement;
@ -260,8 +264,13 @@ export class PdfViewer {
#listenForCommandF() {
this.#instance.UI.hotkeys.on('command+f, ctrl+f', e => {
e.preventDefault();
this.activateSearch();
this.focusSearch();
if (!this.searchActive) {
this.activateSearch();
this.focusSearch();
}
if (this.documentViewer.getSelectedText()) {
this.#searchForSelectedText();
}
});
}