fix add rectangle & resize

This commit is contained in:
Dan Percic 2022-03-18 15:24:12 +02:00
parent f899ffc6af
commit 6cd3450fdb
2 changed files with 8 additions and 7 deletions

View File

@ -42,6 +42,7 @@ import { ALLOWED_KEYBOARD_SHORTCUTS, HeaderElements, TextPopups } from '../../sh
import { FilePreviewDialogService } from '../../services/file-preview-dialog.service';
import { loadCompareDocumentWrapper } from '../../../dossier/utils/compare-mode.utils';
import { FileDataService } from '../../services/file-data.service';
import { fromEvent } from 'rxjs';
import Tools = Core.Tools;
import TextTool = Tools.TextTool;
import Annotation = Core.Annotations.Annotation;
@ -61,7 +62,6 @@ function getDivider(hiddenOn?: readonly ('desktop' | 'mobile' | 'tablet')[]) {
export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnChanges {
@Input() dossier: Dossier;
@Input() canPerformActions = false;
@Output() readonly fileReady = new EventEmitter();
@Output() readonly annotationSelected = new EventEmitter<string[]>();
@Output() readonly manualAnnotationRequested = new EventEmitter<ManualRedactionEntryWrapper>();
@Output() readonly pageChanged = new EventEmitter<number>();
@ -257,6 +257,8 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
return this._handleCustomActions();
});
fromEvent(this.documentViewer, 'pageNumberUpdated').subscribe(console.log);
this.documentViewer.addEventListener('documentLoaded', this._setReadyAndInitialState);
this.documentViewer.addEventListener('keyUp', ($event: KeyboardEvent) => {
@ -546,6 +548,7 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
const quads = [this._annotationDrawService.annotationToQuads(activeAnnotation)];
const manualRedaction = this._getManualRedaction({ [activePage]: quads });
this._cleanUpSelectionAndButtonState();
this.pdf.deleteAnnotations([activeAnnotation.Id]);
this.manualAnnotationRequested.emit(new ManualRedactionEntryWrapper(quads, manualRedaction, 'REDACTION', activeAnnotation.Id));
}

View File

@ -245,10 +245,7 @@ export class AnnotationActionsService {
type: 'actionButton',
img: this._convertPath('/assets/icons/general/close.svg'),
title: this._translateService.instant('annotation-actions.resize-cancel.label'),
onClick: () =>
this._ngZone.run(() => {
this.cancelResize(null, firstAnnotation, annotationsChanged);
}),
onClick: () => this._ngZone.run(() => this.cancelResize(null, firstAnnotation, annotationsChanged)),
});
return availableActions;
}
@ -451,14 +448,15 @@ export class AnnotationActionsService {
});
}
cancelResize($event: MouseEvent, annotationWrapper: AnnotationWrapper, annotationsChanged: EventEmitter<AnnotationWrapper>) {
async cancelResize($event: MouseEvent, annotationWrapper: AnnotationWrapper, annotationsChanged: EventEmitter<AnnotationWrapper>) {
$event?.stopPropagation();
annotationWrapper.resizing = false;
const viewerAnnotation = this._pdf.annotationManager.getAnnotationById(annotationWrapper.id);
viewerAnnotation.ReadOnly = false;
this._pdf.annotationManager.redrawAnnotation(viewerAnnotation);
this._pdf.deleteAnnotations([viewerAnnotation.Id]);
await this._annotationDrawService.drawAnnotations([annotationWrapper]);
this._pdf.annotationManager.deselectAllAnnotations();
annotationsChanged.emit(annotationWrapper);
}