Merge branch 'RED-6234' into 'master'

RED-6234: Escape key aborts resize.

See merge request redactmanager/red-ui!186
This commit is contained in:
Dan Percic 2023-11-15 13:38:51 +01:00
commit 5248005e7a
2 changed files with 11 additions and 1 deletions

View File

@ -78,6 +78,7 @@ import { TablesService } from './services/tables.service';
import { ViewModeService } from './services/view-mode.service';
import { ALL_HOTKEYS, TextPopups } from './utils/constants';
import { RedactTextData } from './utils/dialog-types';
import { AnnotationActionsService } from './services/annotation-actions.service';
const textActions = [TextPopups.REDACT_TEXT, TextPopups.ADD_HINT, TextPopups.ADD_FALSE_POSITIVE];
@ -176,6 +177,7 @@ export class FilePreviewScreenComponent
private readonly _dossierTemplatesService: DossierTemplatesService,
private readonly _dialog: MatDialog,
private readonly _tablesService: TablesService,
private readonly _annotationActionsService: AnnotationActionsService,
) {
super();
effect(() => {
@ -398,6 +400,12 @@ export class FilePreviewScreenComponent
if (['Escape'].includes($event.key)) {
$event.preventDefault();
if (this._annotationManager.resizingAnnotationId) {
const resizedAnnotation = this._fileDataService
.annotations()
.find(annotation => annotation.id === this._annotationManager.resizingAnnotationId);
this._annotationActionsService.cancelResize(resizedAnnotation).then();
}
this.fullScreen = false;
this.closeFullScreen();
this._changeRef.markForCheck();

View File

@ -21,6 +21,7 @@ import TextHighlightAnnotation = Core.Annotations.TextHighlightAnnotation;
import DocumentViewer = Core.DocumentViewer;
import Quad = Core.Math.Quad;
import TextTool = Core.Tools.TextTool;
import { REDAnnotationManager } from './annotation-manager.service';
@Injectable()
export class PdfViewer {
@ -69,6 +70,7 @@ export class PdfViewer {
private readonly _logger: NGXLogger,
private readonly _errorService: ErrorService,
private readonly _userPreferenceService: UserPreferenceService,
private readonly _annotationManager: REDAnnotationManager,
) {
this.totalPages = this.#totalPages.asReadonly();
this.isCompareMode = this.#isCompareMode.asReadonly();
@ -274,7 +276,7 @@ export class PdfViewer {
#listenForEsc() {
this.#instance.UI.hotkeys.on('esc', e => {
e.preventDefault();
if (this.#isElementActive('searchPanel')) {
if (this.#isElementActive('searchPanel') && !this._annotationManager.resizingAnnotationId) {
this.#focusViewer();
this.deactivateSearch();
}