RED-6145: fix resizing for images & rectangles
This commit is contained in:
parent
5ab35e53ab
commit
41a794a246
@ -192,7 +192,6 @@ export class AnnotationActionsService {
|
||||
this._annotationManager.delete(annotationWrapper);
|
||||
const rectangleAnnotation = this.#generateRectangle(annotationWrapper);
|
||||
await this._annotationManager.add(rectangleAnnotation);
|
||||
this._annotationManager.select(rectangleAnnotation);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,12 @@ import { ViewerHeaderService } from '../../pdf-viewer/services/viewer-header.ser
|
||||
import { ManualRedactionService } from './manual-redaction.service';
|
||||
import { PdfViewer } from '../../pdf-viewer/services/pdf-viewer.service';
|
||||
import { REDAnnotationManager } from '../../pdf-viewer/services/annotation-manager.service';
|
||||
import { ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED, HEADER_ITEMS_TO_TOGGLE, TEXT_POPUPS_TO_TOGGLE } from '../../pdf-viewer/utils/constants';
|
||||
import {
|
||||
ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED,
|
||||
AnnotationToolNames,
|
||||
HEADER_ITEMS_TO_TOGGLE,
|
||||
TEXT_POPUPS_TO_TOGGLE,
|
||||
} from '../../pdf-viewer/utils/constants';
|
||||
import { REDDocumentViewer } from '../../pdf-viewer/services/document-viewer.service';
|
||||
import { combineLatest, Observable, Subject } from 'rxjs';
|
||||
import { ViewModeService } from './view-mode.service';
|
||||
@ -160,10 +165,19 @@ export class PdfProxyService {
|
||||
return;
|
||||
}
|
||||
|
||||
const annotation = this._fileDataService.find(annotations[0].Id);
|
||||
if (annotation?.resizing) {
|
||||
this._annotationsActionsService.cancelResize(null, annotation).then();
|
||||
const annotation = annotations[0];
|
||||
const wrapper = this._fileDataService.find(annotation.Id);
|
||||
if (!wrapper?.resizing) {
|
||||
return;
|
||||
}
|
||||
|
||||
// When resizing a rectangle, the original annotation is removed and triggers a deselect event and a new one is created
|
||||
// So we want to skip the first deselect event.
|
||||
if ((wrapper.isImage || wrapper.rectangle) && annotation.ToolName !== AnnotationToolNames.AnnotationCreateRectangle) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._annotationsActionsService.cancelResize(null, wrapper).then();
|
||||
}
|
||||
|
||||
private _configureElements() {
|
||||
@ -307,7 +321,7 @@ export class PdfProxyService {
|
||||
if (!isCurrentPageExcluded) {
|
||||
if (this.canPerformActions) {
|
||||
try {
|
||||
this._pdf.instance.UI.enableTools(['AnnotationCreateRectangle']);
|
||||
this._pdf.instance.UI.enableTools([AnnotationToolNames.AnnotationCreateRectangle]);
|
||||
} catch (e) {
|
||||
// happens
|
||||
}
|
||||
@ -318,7 +332,7 @@ export class PdfProxyService {
|
||||
this._pdf.enable([TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE]);
|
||||
}
|
||||
} else {
|
||||
this._pdf.instance.UI.disableTools(['AnnotationCreateRectangle']);
|
||||
this._pdf.instance.UI.disableTools([AnnotationToolNames.AnnotationCreateRectangle]);
|
||||
this._pdf.disable(TEXT_POPUPS_TO_TOGGLE);
|
||||
this._viewerHeaderService.disable(HEADER_ITEMS_TO_TOGGLE);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import { fromEvent, Observable } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { asList, getId, isStringOrWrapper } from '../utils/functions';
|
||||
import { getLast } from '@utils/functions';
|
||||
import { AnnotationToolNames } from '../utils/constants';
|
||||
import AnnotationManager = Core.AnnotationManager;
|
||||
import Annotation = Core.Annotations.Annotation;
|
||||
|
||||
@ -120,7 +121,7 @@ export class REDAnnotationManager {
|
||||
// when a rectangle is drawn,
|
||||
// it returns one annotation with tool name 'AnnotationCreateRectangle;
|
||||
// this will auto select rectangle after drawing
|
||||
if (annotations.length === 1 && annotations[0].ToolName === 'AnnotationCreateRectangle') {
|
||||
if (annotations.length === 1 && annotations[0].ToolName === AnnotationToolNames.AnnotationCreateRectangle) {
|
||||
this.#manager.selectAnnotations(annotations);
|
||||
annotations[0].disableRotationControl();
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import { UserPreferenceService } from '@users/user-preference.service';
|
||||
import { log, shareLast } from '@iqser/common-ui';
|
||||
import { stopAndPrevent, stopAndPreventIfNotAllowed } from '../utils/functions';
|
||||
import { RotationType, RotationTypes } from '@red/domain';
|
||||
import { AnnotationToolNames } from '../utils/constants';
|
||||
import DocumentViewer = Core.DocumentViewer;
|
||||
import Color = Core.Annotations.Color;
|
||||
import Quad = Core.Math.Quad;
|
||||
@ -135,7 +136,7 @@ export class REDDocumentViewer {
|
||||
}
|
||||
|
||||
setRectangleToolStyles(color: Color) {
|
||||
this.#document.getTool('AnnotationCreateRectangle').setStyles({
|
||||
this.#document.getTool(AnnotationToolNames.AnnotationCreateRectangle).setStyles({
|
||||
StrokeThickness: 2,
|
||||
StrokeColor: color,
|
||||
FillColor: color,
|
||||
|
||||
@ -87,3 +87,7 @@ export const DISABLED_HOTKEYS = [
|
||||
'K',
|
||||
'U',
|
||||
] as const;
|
||||
|
||||
export const AnnotationToolNames = {
|
||||
AnnotationCreateRectangle: 'AnnotationCreateRectangle',
|
||||
} as const;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user