From eb5770af0f4d5d4ead2f70a4c90f5c5dab4f062a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 7 Dec 2020 12:15:37 +0200 Subject: [PATCH] Disable add to dict button on length < 3 --- .../file/pdf-viewer/pdf-viewer.component.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts index 1675aa77b..202c82eb6 100644 --- a/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts @@ -30,6 +30,7 @@ export interface ViewerState { }) export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { private _viewerState: ViewerState = null; // no initial state + private _selectedText = ''; @Input() fileData: Blob; @Input() fileStatus: FileStatusWrapper; @@ -125,6 +126,15 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { } }); + instance.docViewer.on('textSelected', (quads, selectedText, pageNumber) => { + this._selectedText = selectedText; + if (selectedText.length > 2 && this.canPerformActions) { + this.instance.enableElements(['add-dictionary']); + } else { + this.instance.disableElements(['add-dictionary']); + } + }); + this._loadDocument(); }); } @@ -256,7 +266,10 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { private _handleCustomActions() { if (this.canPerformActions) { - this.instance.enableElements(['add-redaction', 'add-dictionary', 'add-rectangle', 'shapeToolGroupButton']); + this.instance.enableElements(['add-redaction', 'add-rectangle', 'shapeToolGroupButton']); + if (this._selectedText.length > 2) { + this.instance.enableElements(['add-dictionary']); + } } else { this.instance.disableElements(['add-redaction', 'add-dictionary', 'add-rectangle', 'shapeToolGroupButton']); }