1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

macOS: Fixes #3404: Show context menu option to copy a link

This commit is contained in:
Laurent Cozic 2020-10-22 16:32:13 +01:00
parent 8543849ea1
commit 68e4b4eaad
3 changed files with 5 additions and 2 deletions

View File

@ -117,7 +117,7 @@ export function menuItems():ContextMenuItems {
onAction: async (options:ContextMenuOptions) => {
clipboard.writeText(options.linkToCopy !== null ? options.linkToCopy : options.textToCopy);
},
isActive: (itemType:ContextMenuItemType) => itemType === ContextMenuItemType.Link,
isActive: (itemType:ContextMenuItemType, options:ContextMenuOptions) => itemType === ContextMenuItemType.Link || !!options.linkToCopy,
},
};
}

View File

@ -41,7 +41,7 @@ export default function useMessageHandler(scrollWhenReady:any, setScrollWhenRead
itemType: arg0 && arg0.type,
resourceId: arg0.resourceId,
textToCopy: arg0.textToCopy,
linkToCopy: null,
linkToCopy: arg0.linkToCopy || null,
htmlToCopy: '',
insertContent: () => { console.warn('insertContent() not implemented'); },
});

View File

@ -368,9 +368,12 @@
const selectedText = window.getSelection().toString();
if (selectedText) {
const linkToCopy = event.target && event.target.getAttribute('href') ? event.target.getAttribute('href') : null;
ipcProxySendToHost('contextMenu', {
type: 'text',
textToCopy: selectedText,
linkToCopy: linkToCopy,
});
} else if (event.target.getAttribute('href')) {
ipcProxySendToHost('contextMenu', {