Skip to content

Commit

Permalink
Add copy event handling in AccountDetailComponent to capture ctrl+c (…
Browse files Browse the repository at this point in the history
…cmd+c on mac) (#36)

* add copy event handling in AccountDetailComponent

* bump version to 2.2.3 in package.json
  • Loading branch information
jlcvp authored Nov 28, 2024
1 parent 0e225b1 commit c661054
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "authleu",
"version": "2.2.1",
"version": "2.2.3",
"author": "Leonardo 'Leu' Pereira <jlcvp@users.noreply.github.com>",
"homepage": "https://github.com/jlcvp/AuthLeu",
"description": "Open source authenticator and 2fa code generator to use across multiple devices and platforms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export class AccountDetailComponent {
this.updateTokenCountdown()
}

@HostListener('copy', ['$event'])
onCopy(event: Event): void {
console.log('copy event captured', { event })
this.copyCode(undefined)
event?.preventDefault()
}
get account(): Account2FA | undefined {
return this._account
}
Expand Down Expand Up @@ -88,8 +94,8 @@ export class AccountDetailComponent {
const message = await firstValueFrom(this.translateService.get('ACCOUNT_DETAIL.CODE_COPIED'))
const toast = await this.toastController.create({
message,
positionAnchor: evt.target,
//position: 'middle'
positionAnchor: evt?.target,
position: evt ? undefined : 'middle',
mode: 'md',
cssClass: 'width-auto',
duration: 2000
Expand Down

0 comments on commit c661054

Please sign in to comment.