RED-10592: fixed listener to esc key in pdf viewer.
This commit is contained in:
parent
036b921977
commit
df0e89589e
@ -4,7 +4,6 @@ import {
|
||||
Component,
|
||||
computed,
|
||||
ElementRef,
|
||||
HostListener,
|
||||
Input,
|
||||
NgZone,
|
||||
OnDestroy,
|
||||
|
||||
@ -300,7 +300,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
super.ngOnDestroy();
|
||||
}
|
||||
|
||||
@Bind()
|
||||
handleEscInsideViewer($event: KeyboardEvent) {
|
||||
$event.preventDefault();
|
||||
if (!!this._annotationManager.selected[0]) {
|
||||
@ -374,7 +373,13 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
|
||||
this.pdfProxyService.configureElements();
|
||||
this.#restoreOldFilters();
|
||||
this.pdf.instance.UI.hotkeys.on('esc', this.handleEscInsideViewer);
|
||||
this.pdf.instance.UI.hotkeys.on('esc', {
|
||||
keydown: (e: KeyboardEvent) => this.pdf.escKeyHandler.keydown(e),
|
||||
keyup: (e: KeyboardEvent) => {
|
||||
this.pdf.escKeyHandler.keyup(e);
|
||||
this.handleEscInsideViewer(e);
|
||||
},
|
||||
});
|
||||
this._viewerHeaderService.resetLayers();
|
||||
this.pdf.instance.UI.iframeWindow.document.removeEventListener('click', this.handleViewerClick);
|
||||
this.pdf.instance.UI.iframeWindow.document.addEventListener('click', this.handleViewerClick);
|
||||
|
||||
@ -65,6 +65,21 @@ export class PdfViewer {
|
||||
};
|
||||
selectedText = '';
|
||||
|
||||
readonly escKeyHandler = {
|
||||
keydown: (e: KeyboardEvent) => {
|
||||
e.preventDefault();
|
||||
this.#clickSelectToolButton();
|
||||
},
|
||||
keyup: (e: KeyboardEvent) => {
|
||||
e.preventDefault();
|
||||
if (this.#isElementActive('searchPanel') && !this._annotationManager.resizingAnnotationId) {
|
||||
this.#focusViewer();
|
||||
this.deactivateSearch();
|
||||
}
|
||||
this.#clickSelectToolButton();
|
||||
},
|
||||
};
|
||||
|
||||
constructor(
|
||||
private readonly _logger: NGXLogger,
|
||||
private readonly _errorService: ErrorService,
|
||||
@ -168,7 +183,6 @@ export class PdfViewer {
|
||||
this.#disableHotkeys();
|
||||
this.#getSelectedText();
|
||||
this.#listenForCommandF();
|
||||
this.#listenForEsc();
|
||||
this.#listenForShift();
|
||||
this.#clearSearchResultsWhenVisibilityChanged();
|
||||
});
|
||||
@ -276,23 +290,6 @@ export class PdfViewer {
|
||||
});
|
||||
}
|
||||
|
||||
#listenForEsc() {
|
||||
this.#instance.UI.hotkeys.on('esc', {
|
||||
keydown: (e: KeyboardEvent) => {
|
||||
e.preventDefault();
|
||||
this.#clickSelectToolButton();
|
||||
},
|
||||
keyup: (e: KeyboardEvent) => {
|
||||
e.preventDefault();
|
||||
if (this.#isElementActive('searchPanel') && !this._annotationManager.resizingAnnotationId) {
|
||||
this.#focusViewer();
|
||||
this.deactivateSearch();
|
||||
}
|
||||
this.#clickSelectToolButton();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
#listenForShift() {
|
||||
this.#instance.UI.iframeWindow.addEventListener('keydown', e => {
|
||||
if (e.target === this.#searchInput) return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user