RED-10592: fixed listener to esc key in pdf viewer.
This commit is contained in:
parent
1d2f450ba4
commit
5359f5aca9
@ -4,7 +4,6 @@ import {
|
||||
Component,
|
||||
computed,
|
||||
ElementRef,
|
||||
HostListener,
|
||||
Input,
|
||||
NgZone,
|
||||
OnDestroy,
|
||||
@ -179,6 +178,7 @@ export class FileHeaderComponent implements OnInit, AfterViewInit, OnDetach, OnD
|
||||
this.fullScreen = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Bind()
|
||||
handleKeyEvent($event: KeyboardEvent) {
|
||||
if (this._router.url.indexOf('/file/') < 0) {
|
||||
|
||||
@ -295,7 +295,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
super.ngOnDestroy();
|
||||
}
|
||||
|
||||
@Bind()
|
||||
handleEscInsideViewer($event: KeyboardEvent) {
|
||||
$event.preventDefault();
|
||||
if (!!this._annotationManager.selected[0]) {
|
||||
@ -369,7 +368,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,
|
||||
@ -170,7 +185,6 @@ export class PdfViewer {
|
||||
this.#disableHotkeys();
|
||||
this.#getSelectedText();
|
||||
this.#listenForCommandF();
|
||||
this.#listenForEsc();
|
||||
this.#listenForShift();
|
||||
this.#clearSearchResultsWhenVisibilityChanged();
|
||||
});
|
||||
@ -278,23 +292,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