mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
28 lines
771 B
TypeScript
28 lines
771 B
TypeScript
import { Directive, ElementRef, HostListener, Input } from "@angular/core";
|
|
|
|
import { ClientType } from "@bitwarden/common/enums";
|
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
|
|
@Directive({
|
|
selector: "[appCopyText]",
|
|
})
|
|
export class CopyTextDirective {
|
|
constructor(
|
|
private el: ElementRef,
|
|
private platformUtilsService: PlatformUtilsService,
|
|
) {}
|
|
|
|
@Input("appCopyText") copyText: string;
|
|
|
|
@HostListener("copy") onCopy() {
|
|
if (window == null) {
|
|
return;
|
|
}
|
|
|
|
const timeout = this.platformUtilsService.getClientType() === ClientType.Desktop ? 100 : 0;
|
|
setTimeout(() => {
|
|
this.platformUtilsService.copyToClipboard(this.copyText, { window: window });
|
|
}, timeout);
|
|
}
|
|
}
|