diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts index 5be425c50..87ce5cff8 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts @@ -115,6 +115,11 @@ export class PdfViewer { return page$.pipe(map(page => this.#adjustPage(page))); } + get #searchInput() { + const iframeWindow = this.#instance.UI.iframeWindow; + return iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement; + } + activateSearch() { this.#instance.UI.searchTextFull('', this.searchOptions); } @@ -292,13 +297,13 @@ export class PdfViewer { #listenForShift() { this.#instance.UI.iframeWindow.addEventListener('keydown', e => { - e.preventDefault(); + if (e.target === this.#searchInput) return; if (e.key === 'Shift') { this.#setSelectionMode(SelectionModes.RECTANGULAR); } }); this.#instance.UI.iframeWindow.addEventListener('keyup', e => { - e.preventDefault(); + if (e.target === this.#searchInput) return; if (e.key === 'Shift') { this.#setSelectionMode(SelectionModes.STRUCTURAL); } @@ -395,13 +400,11 @@ export class PdfViewer { if (this.#isElementActive('textPopup')) { this.#instance.UI.closeElements(['textPopup']); } - const iframeWindow = this.#instance.UI.iframeWindow; - const input = iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement; - if (input) { - input.focus(); + if (this.#searchInput) { + this.#searchInput.focus(); } - if (input?.value?.length > 0) { - input.select(); + if (this.#searchInput?.value?.length > 0) { + this.#searchInput.select(); } }