Git Product home page Git Product logo

Comments (20)

sindresorhus avatar sindresorhus commented on July 24, 2024 4

This should be easier to implement in Electron 8. There's now a spellcheck option in BrowserWindow (which indicates misspelled words with a red squiggly line) and https://github.com/electron/electron/pull/20897/files#diff-9b078be8f43e00e3b99edb5be31fa353R573 to get the suggested replacements.

Here's how it should look:

Screenshot 2020-02-05 at 15 43 48

See: https://www.electronjs.org/blog/electron-8-0#highlight-features

from electron-context-menu.

djalmaaraujo avatar djalmaaraujo commented on July 24, 2024 2

@sindresorhus I figured out by using one context menu for all the things (this module) and the other just for spellcheck:

In the electron-context-menu config, you can use:

shouldShowMenu: (event, params) => !params.misspelledWord,

And on the electron-spellchecker you can use:

let contextMenuListener = new ContextMenuListener((info) => {
  if (!info.misspelledWord) return;

  contextMenuBuilder.showPopupMenu(info);
});

Doing this one can exclude the other in the correct context.

@jwheare

from electron-context-menu.

sindresorhus avatar sindresorhus commented on July 24, 2024 1

@djalmaaraujo That's not a proper solution though. I plan on having spell-checking integrated into this context menu.

from electron-context-menu.

snene avatar snene commented on July 24, 2024 1

Thanks @djalmaaraujo ! It worked for me too. It's a great workaround. I just needed to get the latest version of electron-context-menu. Thanks again!

from electron-context-menu.

IssueHuntBot avatar IssueHuntBot commented on July 24, 2024 1

@IssueHunt has funded $100.00 to this issue.


from electron-context-menu.

sindresorhus avatar sindresorhus commented on July 24, 2024

πŸ‘ Interested in doing a pull request?

Should try to require electron-spellchecker and if it's a dependency, use it. We don't want that module as a direct dependency, as it's heavy and not everyone needs it. So we instead let people add it as a dependency if they need and it will just work.

from electron-context-menu.

jwheare avatar jwheare commented on July 24, 2024

Yup, currently working on splicing it in with prepend. Will see about a more integrated PR once I've got that working. There's a bit of inter process fiddling required I think.

from electron-context-menu.

jwheare avatar jwheare commented on July 24, 2024

I fetched up ripping out what I needed and removing this dependency in the end.

https://github.com/irccloud/irccloud-desktop/blob/54174cc142db1bf236f0196e55acaaf986f976b0/app/context_menu.js

The spelling suggestions integration is done with an ipcRenderer.send from the renderer process (where the spellcheck provider has to be registered)
https://github.com/irccloud/irccloud-desktop/blob/54174cc142db1bf236f0196e55acaaf986f976b0/app/preload.js#L17


A few other things to note that I added, in case you fancy extending this package in future with any of them, or if others are interested (not all possible with the current append/prepend hooks)

  • Opening links in browser
  • Link downloading
  • Image URL copying
  • Save as from sindresorhus/electron-dl#4
  • Inspector changes mentioned in #10
  • Services menu on macOS
  • Added a short timeout before popping up the context menu, to allow for the selection change to register

from electron-context-menu.

sindresorhus avatar sindresorhus commented on July 24, 2024

Cool. Thanks for the ideas. Some of that does make sense.

To make this module more easily extendable I'm thinking of a system where you can mix custom items with the provided ones:

require('electron-context-menu')({
    menu: x => [
        x.COPY,
        {
            title: 'foo'
        },
        x.INSPECT
    ]
});

Where x.COPY is a Symbol.

Continued in #14

Regardless of you using it, what do you think about it?

from electron-context-menu.

jwheare avatar jwheare commented on July 24, 2024

Yeah that would be handy. If I could reuse your cut/copy/paste symbols and build the whole menu myself, while still using your separator filtering that'd be better. Just having more exports for the different stages would be a good start.

from electron-context-menu.

djalmaaraujo avatar djalmaaraujo commented on July 24, 2024

There's no easy way to integrate https://github.com/electron-userland/electron-spellchecker with this module.

from electron-context-menu.

sindresorhus avatar sindresorhus commented on July 24, 2024

@djalmaaraujo It is possible, it's just that electron-spellchecker is not very well documented. You could use: https://github.com/electron-userland/electron-spellchecker/blob/d457b6722b0748a6c2aa23f9a0fdac7d6d296fe0/src/spell-check-handler.js#L471

Relevant issue: electron-userland/electron-spellchecker#80

from electron-context-menu.

djalmaaraujo avatar djalmaaraujo commented on July 24, 2024

@sindresorhus The docs are very bad indeed. This method you mentioned would check if a word is misspelled, but return the suggestions to this the context-menu, is a different thing. It's not related to this issue anyway. tks

from electron-context-menu.

djalmaaraujo avatar djalmaaraujo commented on July 24, 2024

@sindresorhus With my answer above, I think you can call "built-in support" something that is true. :). I would close this issue.

from electron-context-menu.

snene avatar snene commented on July 24, 2024

@djalmaaraujo Were you actually able to use both electron-context-menu and electron-spellchecker together and display the correct context menu using the solution you mentioned? I tried that and I am not able to.

When I right click on the misspelled word then first I get the application context menu and then I have to click again to get the spell checker context menu. Any help or pointers?

from electron-context-menu.

djalmaaraujo avatar djalmaaraujo commented on July 24, 2024

@snene I used both, if I click on the text, I get the suggestions and IGNORE the next context-menu, so I don't end up having 2.

shouldShowMenu: (event, params) => !params.misspelledWord,

This will prevent electron-context-menu from opening the context-menu. Try to read again my previous comment and I think you will get the idea.

from electron-context-menu.

janat08 avatar janat08 commented on July 24, 2024

So the original plan stands, detect if spell checker is loaded, and then show one or other?

from electron-context-menu.

djalmaaraujo avatar djalmaaraujo commented on July 24, 2024

@buzinas @philfreo ☝️

from electron-context-menu.

SterlingChin avatar SterlingChin commented on July 24, 2024

Watching this issue

from electron-context-menu.

issuehunt-oss avatar issuehunt-oss commented on July 24, 2024

@sindresorhus has rewarded $90.00 to @nautatva. See it on IssueHunt

  • πŸ’° Total deposit: $100.00
  • πŸŽ‰ Repository reward(0%): $0.00
  • πŸ”§ Service fee(10%): $10.00

from electron-context-menu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.