You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Desktop: Fix "Open" option for attachments shown in context menu for web links (#12215)
This commit is contained in:
@@ -17,6 +17,7 @@ import { EditDialogControl } from './useEditDialog';
|
||||
import { Dispatch } from 'redux';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import type { MenuItem as MenuItemType } from 'electron';
|
||||
import isItemId from '@joplin/lib/models/utils/isItemId';
|
||||
|
||||
const Menu = bridge().Menu;
|
||||
const MenuItem = bridge().MenuItem;
|
||||
@@ -40,11 +41,16 @@ export default function(editor: Editor, plugins: PluginStates, dispatch: Dispatc
|
||||
let resourceId = '';
|
||||
let linkToCopy = null;
|
||||
|
||||
const pathToId = (path: string) => {
|
||||
const id = Resource.pathToId(path);
|
||||
return isItemId(id) ? id : '';
|
||||
};
|
||||
|
||||
if (element.nodeName === 'IMG') {
|
||||
itemType = ContextMenuItemType.Image;
|
||||
resourceId = Resource.pathToId((element as HTMLImageElement).src);
|
||||
resourceId = pathToId((element as HTMLImageElement).src);
|
||||
} else if (element.nodeName === 'A') {
|
||||
resourceId = Resource.pathToId((element as HTMLAnchorElement).href);
|
||||
resourceId = pathToId((element as HTMLAnchorElement).href);
|
||||
itemType = resourceId ? ContextMenuItemType.Resource : ContextMenuItemType.Link;
|
||||
linkToCopy = element.getAttribute('href') || '';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user