File tree Expand file tree Collapse file tree 4 files changed +49
-2
lines changed
Expand file tree Collapse file tree 4 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 174174 "rimraf" : " ^2.6.3" ,
175175 "rmdir-recursive" : " ^0.0.1" ,
176176 "sequelize" : " ^5.21.2" ,
177+ "spellchecker" : " ^3.7.0" ,
177178 "sqlite3" : " ^4.1.0" ,
178179 "umzug" : " ^2.2.0" ,
179180 "unused-filename" : " ^2.1.0" ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ const { EVENTS, callEvent } = require('./events');
77const fileUtils = require ( '../utils/FileUtils' ) ;
88const { API_TRACKING_EVENT } = require ( '../utils/const' ) ;
99const { filterInvalidEmailAddresses } = require ( './../utils/EmailUtils' ) ;
10+ const spellChecker = require ( 'spellchecker' ) ;
1011
1112const lang = require ( './../lang' ) ;
1213const { windowTitle } = lang . strings . windows . composer ;
@@ -87,7 +88,28 @@ const createComposerWindow = () => {
8788 window,
8889 showSaveImageAs : false ,
8990 showInspectElement : false ,
90- showCopyImageAddress : false
91+ showCopyImageAddress : false ,
92+ prepend : ( defaultActions , browserWindow ) => {
93+ const checker = new spellChecker . Spellchecker ( ) ;
94+
95+ let options = [ ] ;
96+ if ( defaultActions . misspelledWord ) {
97+ options = options . concat (
98+ checker
99+ . getCorrectionsForMisspelling ( defaultActions . misspelledWord )
100+ . map ( word => {
101+ return {
102+ label : word ,
103+ click : ( ) => {
104+ browserWindow . webContents . insertText ( word ) ;
105+ }
106+ } ;
107+ } )
108+ . slice ( 0 , 5 )
109+ ) ;
110+ }
111+ return options ;
112+ }
91113 } ) ;
92114 return window ;
93115} ;
Original file line number Diff line number Diff line change 39843984 version "2.14.0"
39853985 resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
39863986
3987+ nan@^2.14.0 :
3988+ version "2.14.1"
3989+ resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01"
3990+ integrity sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==
3991+
39873992nanomatch@^1.2.9 :
39883993 version "1.2.13"
39893994 resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
@@ -5408,6 +5413,14 @@ speedometer@~0.1.2:
54085413 resolved "https://registry.yarnpkg.com/speedometer/-/speedometer-0.1.4.tgz#9876dbd2a169d3115402d48e6ea6329c8816a50d"
54095414 integrity sha1-mHbb0qFp0xFUAtSObqYynIgWpQ0=
54105415
5416+ spellchecker@^3.7.0 :
5417+ version "3.7.0"
5418+ resolved "https://registry.yarnpkg.com/spellchecker/-/spellchecker-3.7.0.tgz#d63e6fd612352b0108e7bbf942f271665ff63c8b"
5419+ integrity sha512-saQT4BR9nivbK70s0YjyIlSbZzO6bfWRULcGL2JU7fi7wotOnWl70P0QoUwwLywNQJQ47osgCo6GmOlqzRTxbQ==
5420+ dependencies :
5421+ any-promise "^1.3.0"
5422+ nan "^2.14.0"
5423+
54115424split-string@^3.0.1, split-string@^3.0.2 :
54125425 version "3.1.0"
54135426 resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
Original file line number Diff line number Diff line change 11import { labels } from './systemLabels' ;
22const electron = window . require ( 'electron' ) ;
3- const { remote, ipcRenderer } = electron ;
3+ const spellChecker = window . require ( 'spellchecker' ) ;
4+ const { remote, ipcRenderer, webFrame } = electron ;
45const composerId = remote . getCurrentWindow ( ) . id ;
56const globalManager = remote . require ( './src/globalManager' ) ;
67export const getAlicePort = remote . require ( './src/aliceManager' ) . getPort ;
@@ -33,3 +34,13 @@ export const LabelType = labels;
3334export const sendEventToMailbox = ( name , params ) => {
3435 ipcRenderer . send ( name , params ) ;
3536} ;
37+
38+ webFrame . setSpellCheckProvider ( mySettings . language , {
39+ spellCheck ( words , callback ) {
40+ const checker = new spellChecker . Spellchecker ( ) ;
41+ const misspelled = words . filter ( x => {
42+ return checker . isMisspelled ( x ) ;
43+ } ) ;
44+ callback ( misspelled ) ;
45+ }
46+ } ) ;
You can’t perform that action at this time.
0 commit comments