diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index 5bddaaa94..b888380e6 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -243,8 +243,8 @@ export class FilePreviewScreenComponent const nonRedactionEntries = annotations.filter( a => !bool(a.getCustomData('redaction')) || bool(a.getCustomData('changeLogRemoved')), ); - this._readableRedactionsService.setPreviewAnnotationsOpacity(redactions); - this._readableRedactionsService.setPreviewAnnotationsColor(redactions); + this._readableRedactionsService.setAnnotationsColor(redactions, 'redactionColor'); + this._readableRedactionsService.setAnnotationsOpacity(redactions); this._annotationManager.show(redactions); this._annotationManager.hide(nonRedactionEntries); this._suggestionsService.hideSuggestionsInPreview(redactions); @@ -694,9 +694,14 @@ export class FilePreviewScreenComponent this.addActiveScreenSubscription = combineLatest([this._viewModeService.viewMode$, this.state.file$, this._documentViewer.loaded$]) .pipe( - map( - ([viewMode, file]) => ['STANDARD', 'TEXT_HIGHLIGHTS'].includes(viewMode) && this.permissionsService.canRotatePage(file), - ), + map(([viewMode, file]) => { + if (viewMode === 'REDACTED' && !this._readableRedactionsService.active) { + this._readableRedactionsService.setCustomDrawHandler(); + } else { + this._readableRedactionsService.restoreDraw(); + } + return ['STANDARD', 'TEXT_HIGHLIGHTS'].includes(viewMode) && this.permissionsService.canRotatePage(file); + }), tap(canRotate => canRotate ? this._viewerHeaderService.enableRotationButtons() : this._viewerHeaderService.disableRotationButtons(), ), diff --git a/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts index 31deca85d..9d81f0a65 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts @@ -42,8 +42,8 @@ export class SuggestionsService { #convertSuggestionsToRedactions(suggestions: Annotation[]): void { suggestions = this.#filterSuggestions(suggestions); suggestions.forEach(s => s.setCustomData('suggestion', 'false')); - this._readableRedactionsService.setPreviewAnnotationsOpacity(suggestions); - this._readableRedactionsService.setPreviewAnnotationsColor(suggestions); + this._readableRedactionsService.setAnnotationsColor(suggestions, 'redactionColor'); + this._readableRedactionsService.setAnnotationsOpacity(suggestions); this._annotationManager.show(suggestions); } diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts index 7f6f45016..5dd4d3d76 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts @@ -19,7 +19,6 @@ import Quad = Core.Math.Quad; const DEFAULT_TEXT_ANNOTATION_OPACITY = 1; const DEFAULT_REMOVED_ANNOTATION_OPACITY = 0.2; -const FINAL_REDACTION_COLOR = '#000000'; @Injectable() export class AnnotationDrawService { @@ -167,8 +166,7 @@ export class AnnotationDrawService { annotationWrapper.isSuggestion && this._userPreferenceService.getDisplaySuggestionsInPreview() ? this._defaultColorsService.getColor(dossierTemplateId, 'requestAddColor') : this._defaultColorsService.getColor(dossierTemplateId, 'previewColor'); - annotation.setCustomData('redactionColor', String(redactionColor)); - annotation.setCustomData('finalRedactionColor', FINAL_REDACTION_COLOR); + annotation.setCustomData('redactionColor', '#0000BB'); annotation.setCustomData('annotationColor', String(annotationWrapper.color)); return annotation; diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/readable-redactions.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/readable-redactions.service.ts index 96e2fd278..f4f7dec66 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/readable-redactions.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/readable-redactions.service.ts @@ -48,6 +48,33 @@ export class ReadableRedactionsService { title: this.toggleReadableRedactionsBtnTitle, img: this.toggleReadableRedactionsBtnIcon, }); + + if (!this.active) { + this.setCustomDrawHandler(); + } else { + this.restoreDraw(); + } + } + + setCustomDrawHandler(): void { + const annotationClass: any = this._pdf.instance.Core.Annotations.TextHighlightAnnotation; + this._pdf.instance.Core.Annotations.setCustomDrawHandler( + annotationClass, + (ctx: CanvasRenderingContext2D, pageMatrix, rotation, options) => { + const annotation = options.annotation; + ctx.globalCompositeOperation = 'source-over'; + ctx.fillStyle = annotation.getCustomData('redactionColor'); + ctx.fillRect(annotation.getX(), annotation.getY(), annotation.getWidth(), annotation.getHeight()); + }, + { + generateAppearance: false, + }, + ); + } + + restoreDraw(): void { + const annotationClass: any = this._pdf.instance.Core.Annotations.TextHighlightAnnotation; + this._pdf.instance.Core.Annotations.restoreDraw(annotationClass); } setAnnotationsOpacity(annotations: Annotation[], restoreToOriginal = false) { @@ -63,20 +90,4 @@ export class ReadableRedactionsService { annotation['FillColor'] = color; }); } - - setPreviewAnnotationsOpacity(annotations: Annotation[]) { - annotations.forEach(annotation => { - const isSuggestion = bool(annotation.getCustomData('suggestion')); - const restoreToOriginal = !this.active && !isSuggestion; - this.setAnnotationsOpacity([annotation], restoreToOriginal); - }); - } - - setPreviewAnnotationsColor(annotations: Annotation[]) { - annotations.forEach(annotation => { - const isSuggestion = bool(annotation.getCustomData('suggestion')); - const color = this.active || isSuggestion ? 'redactionColor' : 'finalRedactionColor'; - this.setAnnotationsColor([annotation], color); - }); - } }