Disable add to dict button on length < 3

This commit is contained in:
Adina Țeudan 2020-12-07 12:15:37 +02:00
parent 3d90345c11
commit eb5770af0f

View File

@ -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']);
}