Comments (20)
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:
See: https://www.electronjs.org/blog/electron-8-0#highlight-features
from electron-context-menu.
@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.
from electron-context-menu.
@djalmaaraujo That's not a proper solution though. I plan on having spell-checking integrated into this context menu.
from electron-context-menu.
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.
@IssueHunt has funded $100.00 to this issue.
- Submit pull request via IssueHunt to receive this reward.
- Want to contribute? Chip in to this issue via IssueHunt.
- Checkout the IssueHunt Issue Explorer to see more funded issues.
- Need help from developers? Add your repository on IssueHunt to raise funds.
from electron-context-menu.
π 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.
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.
I fetched up ripping out what I needed and removing this dependency in the end.
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.
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.
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.
There's no easy way to integrate https://github.com/electron-userland/electron-spellchecker with this module.
from electron-context-menu.
@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.
@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.
@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.
@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.
@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.
So the original plan stands, detect if spell checker is loaded, and then show one or other?
from electron-context-menu.
from electron-context-menu.
Watching this issue
from electron-context-menu.
@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)
- using the spell checker to replace a misspelled word crashes electronjs. HOT 2
- properties not defined HOT 1
- Not Working on Production HOT 10
- Unclear documentation: please add sample code for enabling hidden built-in options HOT 2
- Not working in Electron 14.0.0 HOT 1
- Electron 15: Module '"electron"' has no exported member 'WebviewTag' HOT 3
- Interaction with menubar HOT 1
- Enable accelerators for edit options HOT 1
- Ability to hide "Copy Link" and "Save Link As" for `file://` protocol HOT 2
- Incorrect Typescript types for defaultActions
- Default action `saveLinkAs` does not exist in Typescript type definitions
- Add other search engines HOT 4
- Picture in picture HOT 1
- [HELP] get link when right click HOT 2
- Allows to translate "No Guesses Found" when no suggestion are available
- The default options like 'cut' 'copy' 'paste', etc. don't show accelerators next to them HOT 5
- How to add all βPasteβ and βPaste as plain textβ ?
- Can I paste an image? HOT 1
- Shortcuts not working HOT 1
- Not working with Electron version >=27
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-context-menu.