From 21d1cc6507ac218f9a79b54b3375d5e6c91762c6 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 3 Apr 2023 15:58:20 +0300 Subject: [PATCH] RED-6240 - Use Applied Redaction Color in Preview mode --- .../file-preview/file-preview-screen.component.ts | 6 ++---- .../services/readable-redactions.service.ts | 13 +++++-------- 2 files changed, 7 insertions(+), 12 deletions(-) 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 9d77ff5f4..e8db1ca54 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 @@ -247,10 +247,8 @@ export class FilePreviewScreenComponent const nonRedactionEntries = annotations.filter( a => !bool(a.getCustomData('redaction')) || bool(a.getCustomData('changeLogRemoved')), ); - if (this._readableRedactionsService.active) { - this._readableRedactionsService.setAnnotationsColor(redactions, 'redactionColor'); - this._readableRedactionsService.setAnnotationsOpacity(redactions); - } + this._readableRedactionsService.setAnnotationsColor(redactions, 'redactionColor'); + this._readableRedactionsService.setAnnotationsOpacity(redactions); this._annotationManager.show(redactions); this._annotationManager.hide(nonRedactionEntries); this._suggestionsService.hideSuggestionsInPreview(redactions); 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 50e09f693..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 @@ -63,14 +63,11 @@ export class ReadableRedactionsService { (ctx: CanvasRenderingContext2D, pageMatrix, rotation, options) => { const annotation = options.annotation; ctx.globalCompositeOperation = 'source-over'; - - (options.annotation as any).Quads.forEach(q => { - const yMin = Math.min(q.y1, q.y2, q.y3, q.y4); - const height = Math.sqrt(Math.pow(q.x1 - q.x4, 2) + Math.pow(q.y1 - q.y4, 2)); - const width = Math.sqrt(Math.pow(q.x1 - q.x2, 2) + Math.pow(q.y1 - q.y2, 2)); - ctx.fillStyle = annotation.getCustomData('redactionColor'); - ctx.fillRect(q.x1, yMin, width, height); - }); + ctx.fillStyle = annotation.getCustomData('redactionColor'); + ctx.fillRect(annotation.getX(), annotation.getY(), annotation.getWidth(), annotation.getHeight()); + }, + { + generateAppearance: false, }, ); }