diff --git a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts index 4ccafa40d..190363b2b 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts @@ -14,7 +14,7 @@ import { toPosition } from '../utils/pdf-calculation.utils'; import { MultiSelectService } from './multi-select.service'; import { FilePreviewStateService } from './file-preview-state.service'; import { map, tap } from 'rxjs/operators'; -import { HeaderElements, TextPopups } from '../utils/constants'; +import { HeaderElements, HeaderElementType, TextPopups } from '../utils/constants'; import { FileDataService } from './file-data.service'; import { ViewerHeaderService } from '../../pdf-viewer/services/viewer-header.service'; import { ManualRedactionService } from './manual-redaction.service'; @@ -291,36 +291,41 @@ export class PdfProxyService { this._viewerHeaderService.disable([HeaderElements.TOGGLE_READABLE_REDACTIONS]); } - if (this.canPerformActions && !isCurrentPageExcluded) { - try { - this._pdf.instance.UI.enableTools(['AnnotationCreateRectangle']); - } catch (e) { - // happens + if (!isCurrentPageExcluded) { + if (this.canPerformActions) { + try { + this._pdf.instance.UI.enableTools(['AnnotationCreateRectangle']); + } catch (e) { + // happens + } + this._pdf.enable(TEXT_POPUPS_TO_TOGGLE); + this._viewerHeaderService.enable(HEADER_ITEMS_TO_TOGGLE); + + if (this._documentViewer.selectedText.length > 2) { + this._pdf.enable([TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE]); + } + } else { + this._pdf.instance.UI.disableTools(['AnnotationCreateRectangle']); + this._pdf.disable(TEXT_POPUPS_TO_TOGGLE); + this._viewerHeaderService.disable(HEADER_ITEMS_TO_TOGGLE); } - this._pdf.enable(TEXT_POPUPS_TO_TOGGLE); - this._viewerHeaderService.enable(HEADER_ITEMS_TO_TOGGLE); - - if (this._documentViewer.selectedText.length > 2) { - this._pdf.enable([TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE]); - } - - return; - } - - let textPopupElementsToDisable = [...TEXT_POPUPS_TO_TOGGLE]; - let headerElementsToDisable = [...HEADER_ITEMS_TO_TOGGLE]; - - if (isCurrentPageExcluded) { - textPopupElementsToDisable = textPopupElementsToDisable.filter( - element => !ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED.includes(element), - ); - headerElementsToDisable = headerElementsToDisable.filter(element => !ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED.includes(element)); } else { - this._pdf.instance.UI.disableTools(['AnnotationCreateRectangle']); - } + let textPopupElementsToDisable = [...TEXT_POPUPS_TO_TOGGLE]; + let headerElementsToDisable = [...HEADER_ITEMS_TO_TOGGLE]; - this._pdf.disable(textPopupElementsToDisable); - this._viewerHeaderService.disable(headerElementsToDisable); + if (this.canPerformActions) { + this._pdf.enable(ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED); + this._viewerHeaderService.enable(ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED as HeaderElementType[]); + + textPopupElementsToDisable = textPopupElementsToDisable.filter( + element => !ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED.includes(element), + ); + headerElementsToDisable = headerElementsToDisable.filter(element => !ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED.includes(element)); + } + + this._pdf.disable(textPopupElementsToDisable); + this._viewerHeaderService.disable(headerElementsToDisable); + } } private _getManualRedaction(quads: Record, text?: string, convertQuads = false): IManualRedactionEntry {