-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Better integrate Electron>=8.1.1's spell checking #283
Comments
Would love to make this happen. @jiahaog Can you point me in the right direction for completing this? 👍 |
Ping @globau @eladnava: @thatkookooguy tried implemented spell checking, maybe see #222 if you feel like collaborate on something. |
I would also like to voice my support for this. And was wondering if @ronjouch you tried using something like: https://github.com/electron-userland/electron-spellchecker It seems that this library will work on any regular inputs as it listens to the document input event. The only situation where this will cause problems would be for applications that modify the input event / block it's event propagation. And there isn't anything that can be done about that really. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
You can enable spellchecking on your own now that this pr is merged into Electron. You'll need to pass a parameter to upgrade the version of Electron from the default, and another to enable the feature.
|
@e1ven Legend! Thanks for that 💯 |
FYI you will need to upgrade the version of
Then, run |
Thanks @e1ven @eladnava 🙂. Regarding the need to upgrade To those of you willing to give this branch a try, go ahead: it's ready to ship, currently being reviewed by Jia, will ship soon, so testing is extremely welcome. See the build instructions at #898 (comment) , and please report any issues with a Then, once #898 ships, help welcome to make this feature actually usable: a new flag to enable it more easily than passing |
This comment has been minimized.
This comment has been minimized.
I just rebuilt an app with the Edited later: Actually it does underline misspelled words now. Right click on them does not suggest any corrections though but knowing which ones got screwed up by my sausage fingers is helpful anyways. |
Everybody interested, see https://github.com/sindresorhus/electron-context-menu/releases/tag/v1.0.0 , Worth a look for those of you interested in contributing! |
Spellcheck is enabled on v9.0.0. But, how to change the language? |
Are there any news / someone figured out how to change the spellcheck language? |
Okay I found how to define that: But how can we call |
@pqnhan you just need to run nativefier with this option: |
@ronjouch I have a couple ideas on this. Both involve injected JS:
For 2 I have a working proof of concept. I have added the following to the mainWindow.ts: ipcMain.on('session-interaction', (event, request) => {
let result = null;
try {
if (request.func) {
if (request.funcArgs === undefined || request.funcArgs === null) {
request.funcArgs = [];
}
if (typeof request.funcArgs[Symbol.iterator] !== 'function') {
request.funcArgs = [request.funcArgs];
}
result = mainWindow.webContents.session[request.func](
...request.funcArgs,
);
} else if (request.property) {
result = mainWindow.webContents.session[request.property];
}
} catch (error) {
console.log('ERROR: session-interaction')
console.log(request);
console.log(error);
result = error;
}
event.reply('session-interaction-reply', result);
}); which now allows me to inject the following JS that will set the dictionary succesfully: const electron = require('electron');
electron.ipcRenderer.on('session-interaction-reply', (event, result) => {
console.log('session-interaction-reply', event, result)
});
electron.ipcRenderer.send('session-interaction', { property: 'availableSpellCheckerLanguages', });
electron.ipcRenderer.send('session-interaction', { func: 'setSpellCheckerLanguages', funcArgs: [['fr']], }); |
Also @llabusch93 even if we can get Nativefier to support this, Electron's spellchecker comes with a pretty big caveat that I hit personally:
So for MacOS, the |
@TheCleric your new plumbing looks good. Then,
|
Yeah that seems the simplest path.
I believe Electron does that automatically. From their docs:
So like on right click?
Honestly, don't hate this option at all. |
…th apps Electron `session` object (PR #1132) As discussed in #283 this PR will allow injected JS to do SOME interaction with the Electron session. There is a full explanation of what this feature can, and cannot do, with examples in the api.md documentation. This will provide a path for resolving many of our issues where users may "self-service" the solution by injecting JS that performs the task needed to meet their objectives. Co-authored-by: Ronan Jouchet <[email protected]>
Hey @ronjouch and @TheCleric , saw that your modifications are merged, cool! So is there now a way to set spellchecking languages with nativefier? Thanks for you work! |
If you are building a non-mac app, yes. (Electron on Mac just uses whatever the current selected OS language is and can't change it due to limitations on Mac). To set the spellcheck language on Windows and Linux, see the example on the new session-interaction api here: https://github.com/nativefier/nativefier/blob/master/docs/api.md#example This will guide you on how to create a JS file that will set the spellcheck language that can be injected via |
@TheCleric :: I've just tested that new session-interaction api on [email protected] and I'm not getting any response from the emitted event; I'm trying the sample code provided:
... my handler is never called; BTW, a recursive grep for "session-interaction" on the whole nativefier code tree got me nothing. Do I need to upgrade to an experimental release on another channel ? |
My apologies. It doesn't appear to have made it into the npm release yet. If you pull this repo it would be in the master branch. Sorry for my confusion. |
Hi there; I just released Nativefier 43.0.1 with @TheCleric's patch in, it will be on npm in a few minutes for you to try without having to use a dev build. |
now example is here https://github.com/nativefier/nativefier/blob/master/API.md#example and works for me |
…th apps Electron `session` object (PR nativefier#1132) As discussed in nativefier#283 this PR will allow injected JS to do SOME interaction with the Electron session. There is a full explanation of what this feature can, and cannot do, with examples in the api.md documentation. This will provide a path for resolving many of our issues where users may "self-service" the solution by injecting JS that performs the task needed to meet their objectives. Co-authored-by: Ronan Jouchet <[email protected]>
applications built with nativefier don't perform spell checking, which is unexpected, and out of alignment with how sites work in-browser.
it would be nice if something like the
electron-spell-check-provider
package was used to enable spell checking on fields.EDIT from @ronjouch on 2019/03/11: see #283 (comment) , Electron ≥ 8.1.1 supports spellchecking natively, and it's (crudely) usable by simply asking for it through BrowserOptions. However, it lacks basic features (an easy-to-use flag, a context menu letting users accept suggestions and switch languages, and maybe enabling spellcheck by default), so this is what this issue is about now.
EDIT from @ronjouch on 2020/04/22: see https://github.com/sindresorhus/electron-context-menu/releases/tag/v1.0.0 ,
[email protected]
(which I bumped Nativefier 8.0.7 to) includes "built-in support for spellchecking (sindresorhus/electron-context-menu#94), see sindresorhus/electron-context-menu@71c5d2e" . Maybe worth a look if you're interested in contributing!The text was updated successfully, but these errors were encountered: