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

GH-1085 Replace simple-spellchecker with electron-spellchecker #1128

Closed
wants to merge 5 commits into from

Conversation

keithcruz
Copy link

@keithcruz keithcruz commented Dec 11, 2019

Before submitting, please confirm you've

Please provide the following information:

Summary

This is a WIP that replaces simple-spellchecker with electron-spellchecker.

Issue link

GH-1085
Test Cases

Additional Notes
Some initial findings:

  1. Language detection doesn’t seem to work on Mac. I have tried by setting and not setting the initial language and then proceeding to type in Spanish and it never seems to switch or catch on. I have found a few issues in the repo that indicate that this may be an ongoing issue. Some whacky macOS logic in need of ❤? electron-userland/electron-spellchecker#127 . In the current version of mattermost spellcheck you are able to switch language from the context menu. Electron-spellcheck does not have this behavior built in. Further investigation is required to determine if it would be possible to add this capability or if it would be better to just add to the settings an option to select a language if on mac.
  2. Electron-builder and electron-rebuild seem to have issues building native node modules with the two package.json structure. It may be worthwhile to see if a single package.json structure will be better long term. What's the difference between the --which-module and --only options? electron/rebuild#253 (comment)

@deanwhillier deanwhillier added the Work In Progress Not yet ready for review label Dec 11, 2019
@keithcruz
Copy link
Author

@deanwhillier Next step will be to see if adding language switching via context menu is possible or not too much of a hack 😁 . If not would like to get input on whether or not the team would like to add language selection as a setting or to keep the current implementation with simple-spellchecker. It seems being able to switch languages automatically is best, via context menu next best, and via a setting as the least desirable option but that is a personal opinion and would like feedback on whether the benefits of electron-spellcheck outweigh the slight regression.

@wget
Copy link
Collaborator

wget commented Dec 15, 2019

@keithcruz +1 for only one package.json data structure.

This has been discussed one year ago with yuya-oc who didn't have time to implement such a refactorisation. If you think this will help, please go for it =)

@mattermod
Copy link
Contributor

This issue has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

/cc @jasonblais @hanzei

@keithcruz
Copy link
Author

@deanwhillier @jasonblais apologies for the lack of activity, I will have an update on this soon. Thanks.

@deanwhillier
Copy link
Contributor

@keithcruz, I'm open to automatic language switching, but wonder if a backup setting would be good in case someone really wants a different language than their OS. I don't think language selection from the context menu is necessary at all! Open to others thoughts on this!

@devinbinnie, @Willyfrog, can you guys please take some time over the next bit to start reviewing this PR?

Copy link
Contributor

@Willyfrog Willyfrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the context menu has changed, I think it probably improved, but we might want to have a PM/UX review that.

Regarding language detection we should probably try and take advantage of provideHintText if we can

I suggested to have a setting for the default language of the user (or revert to the original option of having the context menu on it), but I'm open to alternatives. while I like to have autodetection, we should also have a way for the user to select by themselves in case it fails (and maybe users might want to turn autodetect off)

@@ -154,18 +152,6 @@ export default class MattermostView extends React.Component {
webview.blur();
webview.focus();
}
if (!this.state.isContextMenuAdded) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing this would remove any menu associated?

window.spellCheckHandler = new SpellCheckHandler();
window.spellCheckHandler.attachToInput();

window.spellCheckHandler.switchLanguage('en-US');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this is not final, right?

window.spellCheckHandler.switchLanguage('en-US');

const contextMenuBuilder = new ContextMenuBuilder(window.spellCheckHandler);
/* eslint-disable-next-line no-unused-vars */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason to create a listener and not attaching it somewhere?

"auto-launch": "^5.0.5",
"bootstrap": "^3.3.7",
"cld": "^2.5.1",
"electron-context-menu": "^0.15.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are not using this anymore, it should be removed too.

@@ -45,6 +46,17 @@ window.addEventListener('load', () => {
watchReactAppUntilInitialized(() => {
ipcRenderer.sendToHost('onGuestInitialized', window.basename);
});

window.spellCheckHandler = new SpellCheckHandler();
window.spellCheckHandler.attachToInput();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should consider if config.useSpellChecker is set


const contextMenuBuilder = new ContextMenuBuilder(window.spellCheckHandler);
/* eslint-disable-next-line no-unused-vars */
const contextMenuListener = new ContextMenuListener((info) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we going to use this? we shouldn't disable eslint warnings/errors unless we have a very good reason to do so.

window.spellCheckHandler = new SpellCheckHandler();
window.spellCheckHandler.attachToInput();

window.spellCheckHandler.switchLanguage('en-US');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add a configurable default on the settings page and use that as the base

@mattermod
Copy link
Contributor

This issue has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

/cc @jasonblais @hanzei

@Willyfrog
Copy link
Contributor

@keithcruz let me know if you need clarification or any help with this

@deanwhillier
Copy link
Contributor

@Willyfrog, given we are looking into the new Spellchecker that comes with Electron v8 (or v7, can't remember exactly off hand), should we wait to determine if it will work as we need before abandoning this approach?

@Willyfrog
Copy link
Contributor

definitely, my initial tests shows that it works as basic spellchecker, but I have yet to test the "add new spelling" feature, which requires using browserview, as it is difficult to add to a webview tag.

@deanwhillier
Copy link
Contributor

Closing as we are moving towards using the integrated spell checker in Electron 8.

@mattermod mattermod removed the Work In Progress Not yet ready for review label Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants