1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 02:03:39 +00:00

[PM-2043] Fix additional space and characters copied to clipboard (#5312)

* Change appSelectCopy to accept a dynamic input on what to copy

* Renamed select-copy directive to copy-text directive to be more accurate with the new behaviour

Signed-off-by: Andre Rosado <arosado@bitwarden.com>

* Moved CopyTextDirective on jslib module to be in alphabetic ordering

---------

Signed-off-by: Andre Rosado <arosado@bitwarden.com>
Co-authored-by: Andre Rosado <arosado@bitwarden.com>
This commit is contained in:
Sammy Chang
2023-07-17 12:00:50 -04:00
committed by GitHub
parent c3adf96da7
commit 906c11acb1
11 changed files with 49 additions and 50 deletions

View File

@@ -0,0 +1,20 @@
import { Directive, ElementRef, HostListener, Input } from "@angular/core";
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;
}
this.platformUtilsService.copyToClipboard(this.copyText, { window: window });
}
}