RED-3617: treat rectangles as text highlights
This commit is contained in:
parent
e676eaf59a
commit
43e5e80275
@ -128,7 +128,7 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
cancelResize($event: MouseEvent) {
|
||||
this.annotationActionsService.cancelResize($event, this.annotations[0], this.annotationsChanged);
|
||||
return this.annotationActionsService.cancelResize($event, this.annotations[0], this.annotationsChanged);
|
||||
}
|
||||
|
||||
private async _setPermissions() {
|
||||
|
||||
@ -153,7 +153,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
this._setAnnotationsColor(redactions, 'annotationColor');
|
||||
const wrappers = await this._fileDataService.annotations;
|
||||
const ocrAnnotationIds = wrappers.filter(a => a.isOCR).map(a => a.id);
|
||||
|
||||
const standardEntries = annotations
|
||||
.filter(a => a.getCustomData('changeLogRemoved') === 'false')
|
||||
.filter(a => !ocrAnnotationIds.includes(a.Id));
|
||||
@ -437,8 +436,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
this._logger.info('[ANNOTATIONS] To draw: ', annotationsToDraw);
|
||||
const annotationsToDrawIds = annotationsToDraw.map(a => a.annotationId);
|
||||
this.pdf.deleteAnnotations(annotationsToDrawIds);
|
||||
this.pdf.deleteAnnotations(annotationsToDraw.map(a => a.annotationId));
|
||||
return this._cleanupAndRedrawAnnotations(annotationsToDraw);
|
||||
}
|
||||
|
||||
@ -601,9 +599,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
this.addActiveScreenSubscription = combineLatest([this._viewModeService.viewMode$, this.state.file$])
|
||||
.pipe(
|
||||
tap(([viewMode, file]) => {
|
||||
console.log(viewMode, file.hasHighlights);
|
||||
if (viewMode === ViewModes.TEXT_HIGHLIGHTS && !file.hasHighlights) {
|
||||
console.log('switch');
|
||||
this._viewModeService.switchToStandard();
|
||||
}
|
||||
}),
|
||||
|
||||
@ -426,19 +426,26 @@ export class AnnotationActionsService {
|
||||
return availableActions;
|
||||
}
|
||||
|
||||
resize($event: MouseEvent, annotationWrapper: AnnotationWrapper) {
|
||||
async resize($event: MouseEvent, annotationWrapper: AnnotationWrapper) {
|
||||
$event?.stopPropagation();
|
||||
|
||||
annotationWrapper.resizing = true;
|
||||
|
||||
const viewerAnnotation = this._pdf.annotationManager.getAnnotationById(annotationWrapper.id);
|
||||
if (annotationWrapper.rectangle) {
|
||||
this._pdf.deleteAnnotations([annotationWrapper.id]);
|
||||
const rectangleAnnotation = this.#generateRectangle(annotationWrapper);
|
||||
this._pdf.annotationManager.addAnnotation(rectangleAnnotation, { imported: true });
|
||||
await this._pdf.annotationManager.drawAnnotationsFromList([rectangleAnnotation]);
|
||||
this._pdf.annotationManager.selectAnnotation(rectangleAnnotation);
|
||||
return;
|
||||
}
|
||||
|
||||
viewerAnnotation.ReadOnly = false;
|
||||
viewerAnnotation.Hidden = false;
|
||||
viewerAnnotation.disableRotationControl();
|
||||
this._pdf.annotationManager.redrawAnnotation(viewerAnnotation);
|
||||
this._pdf.annotationManager.selectAnnotation(viewerAnnotation);
|
||||
|
||||
this._annotationDrawService.annotationToQuads(viewerAnnotation);
|
||||
}
|
||||
|
||||
acceptResize($event: MouseEvent, annotationWrapper: AnnotationWrapper, annotationsChanged?: EventEmitter<AnnotationWrapper[]>) {
|
||||
@ -469,9 +476,7 @@ export class AnnotationActionsService {
|
||||
|
||||
annotationWrapper.resizing = false;
|
||||
|
||||
const viewerAnnotation = this._pdf.annotationManager.getAnnotationById(annotationWrapper.id);
|
||||
viewerAnnotation.ReadOnly = false;
|
||||
this._pdf.deleteAnnotations([viewerAnnotation.Id]);
|
||||
this._pdf.deleteAnnotations([annotationWrapper.id]);
|
||||
await this._annotationDrawService.drawAnnotations([annotationWrapper]);
|
||||
this._pdf.annotationManager.deselectAllAnnotations();
|
||||
annotationsChanged.emit([annotationWrapper]);
|
||||
@ -496,6 +501,26 @@ export class AnnotationActionsService {
|
||||
this._processObsAndEmit(this._manualRedactionService.addAnnotation(requests, dossierId, fileId), annotations, annotationsChanged);
|
||||
}
|
||||
|
||||
#generateRectangle(annotationWrapper: AnnotationWrapper) {
|
||||
const annotation = new this._pdf.Annotations.RectangleAnnotation();
|
||||
const pageHeight = this._pdf.documentViewer.getPageHeight(annotationWrapper.pageNumber);
|
||||
const rectangle: IRectangle = annotationWrapper.positions[0];
|
||||
annotation.PageNumber = annotationWrapper.pageNumber;
|
||||
annotation.X = rectangle.topLeft.x;
|
||||
annotation.Y = pageHeight - (rectangle.topLeft.y + rectangle.height);
|
||||
annotation.Width = rectangle.width;
|
||||
annotation.Height = rectangle.height;
|
||||
annotation.ReadOnly = false;
|
||||
annotation.Hidden = false;
|
||||
annotation.disableRotationControl();
|
||||
annotation.FillColor = this._annotationDrawService.getAndConvertColor(annotationWrapper.superType, annotationWrapper.type);
|
||||
annotation.StrokeColor = annotation.FillColor;
|
||||
annotation.Opacity = 0.6;
|
||||
annotation.StrokeThickness = 1;
|
||||
annotation.Id = annotationWrapper.id;
|
||||
return annotation;
|
||||
}
|
||||
|
||||
private _getHighlightOperationData(
|
||||
operation: TextHighlightOperation,
|
||||
highlights: AnnotationWrapper[],
|
||||
|
||||
@ -18,12 +18,11 @@ import { FileDataService } from './file-data.service';
|
||||
import { SuperTypes } from '@models/file/super-types';
|
||||
import Annotation = Core.Annotations.Annotation;
|
||||
|
||||
const DEFAULT_TEXT_ANNOTATION_OPACITY = 1;
|
||||
const DEFAULT_REMOVED_ANNOTATION_OPACITY = 0.2;
|
||||
|
||||
@Injectable()
|
||||
export class AnnotationDrawService {
|
||||
static readonly DEFAULT_RECTANGLE_ANNOTATION_OPACITY = 0.6;
|
||||
static readonly DEFAULT_TEXT_ANNOTATION_OPACITY = 1;
|
||||
static readonly DEFAULT_REMOVED_ANNOTATION_OPACITY = 0.2;
|
||||
|
||||
constructor(
|
||||
private readonly _dictionariesMapService: DictionariesMapService,
|
||||
private readonly _dossiersService: DossiersService,
|
||||
@ -160,35 +159,14 @@ export class AnnotationDrawService {
|
||||
return rectangleAnnot;
|
||||
}
|
||||
|
||||
let annotation: Core.Annotations.RectangleAnnotation | Core.Annotations.TextHighlightAnnotation;
|
||||
if (annotationWrapper.rectangle || annotationWrapper.isImage) {
|
||||
annotation = new this._pdf.Annotations.RectangleAnnotation();
|
||||
const pageHeight = this._pdf.documentViewer.getPageHeight(pageNumber);
|
||||
const firstPosition = annotationWrapper.positions[0];
|
||||
annotation.X = firstPosition.topLeft.x;
|
||||
annotation.Y = pageHeight - (firstPosition.topLeft.y + firstPosition.height);
|
||||
annotation.Width = firstPosition.width;
|
||||
annotation.FillColor = this.getAndConvertColor(annotationWrapper.superType, annotationWrapper.type);
|
||||
annotation.Opacity = annotationWrapper.isChangeLogRemoved
|
||||
? AnnotationDrawService.DEFAULT_REMOVED_ANNOTATION_OPACITY
|
||||
: AnnotationDrawService.DEFAULT_RECTANGLE_ANNOTATION_OPACITY;
|
||||
annotation.Height = firstPosition.height;
|
||||
annotation.Intensity = 100;
|
||||
} else {
|
||||
annotation = new this._pdf.Annotations.TextHighlightAnnotation();
|
||||
annotation.Quads = this._rectanglesToQuads(annotationWrapper.positions, pageNumber);
|
||||
annotation.Opacity = annotationWrapper.isChangeLogRemoved
|
||||
? AnnotationDrawService.DEFAULT_REMOVED_ANNOTATION_OPACITY
|
||||
: AnnotationDrawService.DEFAULT_TEXT_ANNOTATION_OPACITY;
|
||||
}
|
||||
|
||||
const annotation = new this._pdf.Annotations.TextHighlightAnnotation();
|
||||
annotation.Quads = this._rectanglesToQuads(annotationWrapper.positions, pageNumber);
|
||||
annotation.Opacity = annotationWrapper.isChangeLogRemoved ? DEFAULT_REMOVED_ANNOTATION_OPACITY : DEFAULT_TEXT_ANNOTATION_OPACITY;
|
||||
annotation.setContents(annotationWrapper.content);
|
||||
|
||||
annotation.PageNumber = pageNumber;
|
||||
annotation.StrokeColor = this.getAndConvertColor(annotationWrapper.superType, annotationWrapper.type);
|
||||
annotation.Id = annotationWrapper.id;
|
||||
annotation.ReadOnly = true;
|
||||
// change log entries are drawn lighter
|
||||
|
||||
annotation.Hidden =
|
||||
annotationWrapper.isChangeLogRemoved ||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user