mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-01 20:43:33 +00:00
context-menu: Copy the email address, not the link text.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
@@ -3,9 +3,10 @@ import * as t from '../utils/translation-util';
|
|||||||
const {clipboard, Menu} = remote;
|
const {clipboard, Menu} = remote;
|
||||||
|
|
||||||
export const contextMenu = (webContents: Electron.WebContents, event: Event, props: ContextMenuParams) => {
|
export const contextMenu = (webContents: Electron.WebContents, event: Event, props: ContextMenuParams) => {
|
||||||
const isText = Boolean(props.selectionText.length);
|
const isText = props.selectionText !== '';
|
||||||
const isLink = Boolean(props.linkURL);
|
const isLink = props.linkURL !== '';
|
||||||
const isEmailAddress = Boolean(props.linkURL.startsWith('mailto:'));
|
const linkURL = isLink ? new URL(props.linkURL) : undefined;
|
||||||
|
const isEmailAddress = isLink ? linkURL.protocol === 'mailto:' : undefined;
|
||||||
|
|
||||||
const makeSuggestion = (suggestion: string) => ({
|
const makeSuggestion = (suggestion: string) => ({
|
||||||
label: suggestion,
|
label: suggestion,
|
||||||
@@ -63,7 +64,7 @@ export const contextMenu = (webContents: Electron.WebContents, event: Event, pro
|
|||||||
click(_item) {
|
click(_item) {
|
||||||
clipboard.write({
|
clipboard.write({
|
||||||
bookmark: props.linkText,
|
bookmark: props.linkText,
|
||||||
text: isEmailAddress ? props.linkText : props.linkURL
|
text: isEmailAddress ? linkURL.pathname : props.linkURL
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
Reference in New Issue
Block a user