sindresorhus/electron-context-menu

Ability to hide "Copy Link" and "Save Link As" for `file://` protocol

oleg-slapdash opened this issue · 2 comments

Currently, the package allows copying links that are not really links and just internal files.

It would be awesome if there was a way to disable file:// links from being treated as links.

Alternatively, maybe we can pass a function instead of a callback into showCopyLink so we can fine-tune the behaviour.

I think it would make sense to add a top-level option for this. I think it should hide them for file:// by default. You would rarely want to expose file:// URLs.

Same applies to copy image and video address too.

For anyone facing this issue and reading this.

It might not be the best solution since it targets the whole menu, but the api offers and option function parameter shouldShowMenu that decides wether or not the menu should be shown:

shouldShowMenu: (event, parameters) => {
  return !paremeters.linkURL.includes('file://')
}

In case I didn't want any context on links so it did the trick.

Hope it helps somebody out there