diff --git a/apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.ts index 20e8e34a5..7dff9d817 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.ts @@ -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(); @Output() readonly manualAnnotationRequested = new EventEmitter(); @Output() readonly pageChanged = new EventEmitter(); @@ -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)); } diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index 02722dbb5..e941e0603 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -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) { + async cancelResize($event: MouseEvent, annotationWrapper: AnnotationWrapper, annotationsChanged: EventEmitter) { $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); }