Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Context menu #403

Open
palmtreefrb opened this issue Jul 12, 2020 · 2 comments
Open

Added Context menu #403

palmtreefrb opened this issue Jul 12, 2020 · 2 comments

Comments

@palmtreefrb
Copy link

palmtreefrb commented Jul 12, 2020

Ubuntu 18.04
Don't know if your are interested, but I wanted the ability to copy/paste from context menu. It was very trivial to add using "electron-context-menu": "^2.2.0" npm package and adding the below code to electron.ts

import * as contextMenu from 'electron-context-menu'

contextMenu({
  prepend: (defaultActions, params, browserWindow) => [
    {
      label: 'Rainbow',
      // Only show it when right-clicking images
      visible: params.mediaType === 'image',
    },
    {
      label: 'Search Google for “{selection}”',
      // Only show it when right-clicking text
      visible: params.selectionText.trim().length > 0,
      click: () => {
        shell.openExternal(`https://google.com/search?q=${encodeURIComponent(params.selectionText)}`)
      },
    },
  ],
})

Screenshot from 2020-07-12 12-24-31

@thomasnordquist
Copy link
Owner

Seems to make a nice addition!
The google search is maybe a bit over the top 😅

@palmtreefrb
Copy link
Author

Hah, yes, that was just POC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants