mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4272] TaskListCloud - improvements on CopyClipboardDirective (#4547)
* [ADF-4272] DocumentList - add Copy content tooltip directive * [ADF-4272] - fix build issue * [ADF-4272] - change directive name and add requested changes * [ADF-4272] - reset task-list-cloud html content * [ADF-4272] - fix build * [AFG-4272] - change name to CopyClipboard * [ADF-4272] - PR changes * [ADF-4272] - fix tests * [ADF-4272[] - lint * [ADF-4272] - merge clipboard directive with copy-content directive * [ADF-4272] - PR changes * [ADF-4272] - change docs
This commit is contained in:
committed by
Eugenio Romano
parent
dee63e3f3b
commit
a87d1ef002
@@ -32,8 +32,6 @@ export class ClipboardService {
|
||||
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) {
|
||||
return !target.hasAttribute('disabled');
|
||||
}
|
||||
|
||||
this.logService.error(`${target} should be input or textarea`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -50,6 +48,20 @@ export class ClipboardService {
|
||||
}
|
||||
}
|
||||
|
||||
copyContentToClipboard(content: string, message: string) {
|
||||
try {
|
||||
document.addEventListener('copy', (e: ClipboardEvent) => {
|
||||
e.clipboardData.setData('text/plain', (content));
|
||||
e.preventDefault();
|
||||
document.removeEventListener('copy', null);
|
||||
});
|
||||
document.execCommand('copy');
|
||||
this.notify(message);
|
||||
} catch (error) {
|
||||
this.logService.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
private notify(message) {
|
||||
if (message) {
|
||||
this.notificationService.openSnackMessage(message);
|
||||
|
Reference in New Issue
Block a user