Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Using Chromium's spellchecker
Browse files Browse the repository at this point in the history
fixes #9880

Auditors: @bridiver, @bbondy, @bsclifton
  • Loading branch information
darkdh committed Jul 11, 2017
1 parent 03ae74b commit e394659
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 121 deletions.
21 changes: 0 additions & 21 deletions app/browser/reducers/spellCheckReducer.js

This file was deleted.

1 change: 0 additions & 1 deletion app/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ let generateBraveManifest = () => {
getBraveExtUrl('about-blank.html') + '#*'
],
js: [
'content/scripts/spellCheck.js',
'content/scripts/themeColor.js'
]
},
Expand Down
22 changes: 0 additions & 22 deletions app/extensions/brave/content/scripts/spellCheck.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/extensions/brave/locales/en-US/menu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ extensionsManager=Extensions…
zoom=Zoom
new=New
learnSpelling=Learn Spelling
ignoreSpelling=Ignore Spelling
forgetLearnedSpelling=Forget Learned Spelling
autoHideMenuBar=Menu Bar
updateChannel=Update Channel
licenseText=This software uses libraries from the FFmpeg project under the LGPLv2.1
Expand Down
2 changes: 0 additions & 2 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const SiteHacks = require('./siteHacks')
const CmdLine = require('./cmdLine')
const UpdateStatus = require('../js/constants/updateStatus')
const urlParse = require('./common/urlParse')
const spellCheck = require('./spellCheck')
const locale = require('./locale')
const contentSettings = require('../js/state/contentSettings')
const privacy = require('../js/state/privacy')
Expand Down Expand Up @@ -346,7 +345,6 @@ app.on('ready', () => {
Autofill.init()
Extensions.init()
SiteHacks.init()
spellCheck.init()
HttpsEverywhere.init()
TrackingProtection.init()
AdBlock.init()
Expand Down
2 changes: 1 addition & 1 deletion app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ var rendererIdentifiers = function () {
'braveryStartUsingPayments',
'blockPopups',
'learnSpelling',
'ignoreSpelling',
'forgetLearnedSpelling',
'lookupSelection',
// Other identifiers
'aboutBlankTitle',
Expand Down
7 changes: 0 additions & 7 deletions app/spellCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ module.exports.init = () => {
}
e.returnValue = misspelled
})
ipcMain.on(messages.GET_MISSPELLING_INFO, (e, word) => {
const misspelled = isMisspelled(word)
e.returnValue = {
isMisspelled: misspelled,
suggestions: !misspelled ? [] : spellchecker.getCorrectionsForMisspelling(word)
}
})

appStore.addChangeListener(() => {
let addedWords = appStore.getState().getIn(['dictionary', 'addedWords'])
Expand Down
22 changes: 0 additions & 22 deletions docs/appActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,28 +455,6 @@ Hides a message in the notification bar



### addWord(word, learn)

Adds a word to the dictionary

**Parameters**

**word**: `string`, The word to add

**learn**: `boolean`, true if the word should be learned, false if ignored



### setDictionary(locale)

Adds a word to the dictionary

**Parameters**

**locale**: `string`, The locale to set for the dictionary



### setLoginRequiredDetail(tabId, detail)

Adds information about pending basic auth login requests
Expand Down
24 changes: 0 additions & 24 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,30 +553,6 @@ const appActions = {
})
},

/**
* Adds a word to the dictionary
* @param {string} word - The word to add
* @param {boolean} learn - true if the word should be learned, false if ignored
*/
addWord: function (word, learn) {
dispatch({
actionType: appConstants.APP_ADD_WORD,
word,
learn
})
},

/**
* Adds a word to the dictionary
* @param {string} locale - The locale to set for the dictionary
*/
setDictionary: function (locale) {
dispatch({
actionType: appConstants.APP_SET_DICTIONARY,
locale
})
},

/**
* Adds information about pending basic auth login requests
* @param {number} tabId - The tabId that generated the request
Expand Down
1 change: 0 additions & 1 deletion js/constants/appConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const appConstants = {
APP_UPDATE_PUBLISHER_INFO: _,
APP_SHOW_NOTIFICATION: _, /** @param {Object} detail */
APP_HIDE_NOTIFICATION: _, /** @param {string} message */
APP_ADD_WORD: _, /** @param {string} word, @param {boolean} learn */
APP_SET_DICTIONARY: _, /** @param {string} locale */
APP_BACKUP_KEYS: _,
APP_RECOVER_WALLET: _,
Expand Down
1 change: 0 additions & 1 deletion js/constants/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const messages = {
RELOAD: _,
DETACH: _,
IS_MISSPELLED: _, /** @arg {string} word, the word to check */
GET_MISSPELLING_INFO: _, /** @arg {string} word, the word to lookup */
PASSWORD_DETAILS_UPDATED: _, /** @arg {Object} passwords app state */
PASSWORD_SITE_DETAILS_UPDATED: _, /** @arg {Object} passwords app state */
// Init
Expand Down
29 changes: 16 additions & 13 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,17 +543,19 @@ function getMisspelledSuggestions (selection, isMisspelled, suggestions) {
if (isMisspelled) {
template.push({
label: locale.translation('learnSpelling'),
click: () => {
appActions.addWord(selection, true)
// This is needed so the underline goes away
webviewActions.replace(selection)
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.addWord(selection)
}
}
}, {
label: locale.translation('ignoreSpelling'),
click: () => {
appActions.addWord(selection, false)
// This is needed so the underline goes away
webviewActions.replace(selection)
}, CommonMenu.separatorMenuItem)
} else {
template.push({
label: locale.translation('forgetLearnedSpelling'),
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.removeWord(selection)
}
}
}, CommonMenu.separatorMenuItem)
}
Expand Down Expand Up @@ -953,9 +955,10 @@ function mainTemplateInit (nodeProps, frame, tab) {
if (isInputField) {
let misspelledSuggestions = []
if (nodeProps.misspelledWord) {
const info = ipc.sendSync(messages.GET_MISSPELLING_INFO, nodeProps.selectionText)
if (info) {
misspelledSuggestions = getMisspelledSuggestions(nodeProps.selectionText, info.isMisspelled, info.suggestions)
if (nodeProps.misspelledWord === 'match-brave-custom-dictionary' && !nodeProps.dictionarySuggestions.length) {
misspelledSuggestions = getMisspelledSuggestions(nodeProps.selectionText, false, nodeProps.dictionarySuggestions)
} else {
misspelledSuggestions = getMisspelledSuggestions(nodeProps.selectionText, true, nodeProps.dictionarySuggestions)
}
}

Expand Down
4 changes: 0 additions & 4 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ const handleAppAction = (action) => {
require('../../app/browser/reducers/sitesReducer'),
require('../../app/browser/reducers/windowsReducer'),
require('../../app/browser/reducers/syncReducer'),
require('../../app/browser/reducers/spellCheckReducer'),
require('../../app/browser/reducers/clipboardReducer'),
require('../../app/browser/reducers/urlBarSuggestionsReducer'),
require('../../app/browser/reducers/passwordManagerReducer'),
Expand Down Expand Up @@ -654,9 +653,6 @@ const handleAppAction = (action) => {
appState = appState.setIn(path, wordList.push(action.word))
}
break
case appConstants.APP_SET_DICTIONARY:
appState = appState.setIn(['dictionary', 'locale'], action.locale)
break
case appConstants.APP_LEDGER_RECOVERY_STATUS_CHANGED:
{
const date = new Date().getTime()
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
"react-dnd": "^2.1.4",
"react-dnd-html5-backend": "^2.1.2",
"react-dom": "^15.5.4",
"spellchecker": "brave/node-spellchecker",
"string.prototype.endswith": "^0.2.0",
"string.prototype.startswith": "^0.2.0",
"tablesort": "5.0.0",
Expand Down

0 comments on commit e394659

Please sign in to comment.