-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(App): Add option to enable/disable spell checker
- Loading branch information
Showing
10 changed files
with
149 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
import { SpellCheckHandler, ContextMenuListener, ContextMenuBuilder } from 'electron-spellchecker'; | ||
|
||
window.spellCheckHandler = new SpellCheckHandler(); | ||
setTimeout(() => { | ||
window.spellCheckHandler.attachToInput(); | ||
}, 1000); | ||
|
||
// TODO: should we set the language to user settings? | ||
// window.spellCheckHandler.switchLanguage('en-US'); | ||
|
||
const contextMenuBuilder = new ContextMenuBuilder(window.spellCheckHandler); | ||
const contextMenuListener = new ContextMenuListener((info) => { // eslint-disable-line | ||
contextMenuBuilder.showPopupMenu(info); | ||
}); | ||
import { isMac } from '../environment'; | ||
|
||
export default class Spellchecker { | ||
isEnabled = false; | ||
spellchecker = null; | ||
|
||
enable() { | ||
this.spellchecker = new SpellCheckHandler(); | ||
if (!isMac) { | ||
this.spellchecker.attachToInput(); | ||
this.spellchecker.switchLanguage(navigator.language); | ||
} | ||
|
||
const contextMenuBuilder = new ContextMenuBuilder(this.spellchecker); | ||
|
||
new ContextMenuListener((info) => { // eslint-disable-line | ||
contextMenuBuilder.showPopupMenu(info); | ||
}); | ||
} | ||
|
||
// TODO: this does not work yet, needs more testing | ||
// switchLanguage(language) { | ||
// if (language !== 'auto') { | ||
// this.spellchecker.switchLanguage(language); | ||
// } | ||
// } | ||
} | ||
|