diff --git a/src/components/chat/contextMenu.ts b/src/components/chat/contextMenu.ts index a9dc9ec5..6adf8b8f 100644 --- a/src/components/chat/contextMenu.ts +++ b/src/components/chat/contextMenu.ts @@ -36,6 +36,7 @@ export default class ChatContextMenu { private isTargetAGroupedItem: boolean; private isTextSelected: boolean; private isAnchorTarget: boolean; + private isUsernameTarget: boolean; private peerId: number; private mid: number; private message: any; @@ -89,7 +90,11 @@ export default class ChatContextMenu { //this.msgID = msgID; this.target = e.target as HTMLElement; this.isTextSelected = !isSelectionEmpty(); - this.isAnchorTarget = this.target.tagName === 'A' && (this.target as HTMLAnchorElement).target === '_blank'; + this.isAnchorTarget = this.target.tagName === 'A' && ( + (this.target as HTMLAnchorElement).target === '_blank' || + this.target.classList.contains('anchor-url') + ); + this.isUsernameTarget = this.target.tagName === 'A' && this.target.classList.contains('mention'); const groupedItem = findUpClassName(this.target, 'grouped-item'); this.isTargetAGroupedItem = !!groupedItem; @@ -231,6 +236,22 @@ export default class ChatContextMenu { onClick: this.onCopyAnchorLinkClick, verify: () => this.isAnchorTarget, withSelection: true + }, { + icon: 'copy', + text: 'Text.Context.Copy.Username', + onClick: () => { + copyTextToClipboard(this.target.innerHTML); + }, + verify: () => this.isUsernameTarget, + withSelection: true + }, { + icon: 'copy', + text: 'Text.Context.Copy.Hashtag', + onClick: () => { + copyTextToClipboard(this.target.innerHTML); + }, + verify: () => this.target.classList.contains('anchor-hashtag'), + withSelection: true }, { icon: 'link', text: 'MessageContext.CopyMessageLink1', diff --git a/src/lang.ts b/src/lang.ts index 9d112ba9..c1c2af97 100644 --- a/src/lang.ts +++ b/src/lang.ts @@ -793,6 +793,8 @@ const lang = { //"Schedule.SendWhenOnline": "Send When Online", "Stickers.Recent": "Recent", //"Stickers.Favorite": "Favorite", + "Text.Context.Copy.Username": "Copy Username", + "Text.Context.Copy.Hashtag": "Copy Hashtag", "Time.TomorrowAt": "tomorrow at %@", "TwoStepAuth.SetPasswordHelp": "You can set a password that will be required when you log in on a new device in addition to the code you get in the SMS.", "TwoStepAuth.GenericHelp": "You have enabled Two-Step verification.\nYou'll need the password you set up here to log in to your Telegram account.",