This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 973
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #9880 Auditors: @bridiver, @bbondy, @bsclifton Test plan: a. Suggestions 1. Go to `about:styles` 2. Type `braave` in textbox 3. There should be redline under `braave` 4. Open context menu on `braave` 5. You can see `bravo`, `brave`, `Brava` 6. Click on `brave` 7. The text should be replaced with `brave` with no redline b. Learn Spelling 1. Go to `about:styles` 2. Type `braave` in textbox 3. There should be redline under `braave` 4. Open context menu on `braave` 5. Click `Learn Spelling` 6. `braave` will no longer be redlined 7. Next time you type `braave`, you will not see redline c. Forget Learned Spelling 1. Go to `about:styles` 2. Type `braave` in textbox 3. There should be redline under `braave` 4. Open context menu on `braave` 5. Click `Learn Spelling` 6. `braave` will no longer be redlined 7. Open context menu on `braave` 8. Click `Forget Learned Spelling` 9. Next time you type `braave`, you will see redline under it d. Legacy data migration 1. Use older Brave to `Learn Spelling` for `braave` and `Ignore Spelling` for `braaave` 2. Update to the version with chromium spellchecker 3. There will be no `dictionary` structure in session store 4. You can see those two words will be added to `Custom Dictionary.txt` under user folder 5. And try to type `braave` and `braaave` in `about:styles` 6. They should be valid words
- Loading branch information
Showing
19 changed files
with
129 additions
and
239 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
'use strict' | ||
|
||
const appConstants = require('../../../js/constants/appConstants') | ||
const {makeImmutable} = require('../../common/state/immutableUtil') | ||
const {getWebContents} = require('../webContentsCache') | ||
const spellChecker = require('../../spellChecker') | ||
|
||
const migrate = (state) => { | ||
if (state.get('dictionary')) { | ||
const addedWords = state.getIn(['dictionary', 'addedWords']) | ||
const ignoredWords = state.getIn(['dictionary', 'ignoredWords']) | ||
if (addedWords.size) { | ||
addedWords.forEach((word) => { | ||
spellChecker.addWord(word) | ||
}) | ||
} | ||
if (ignoredWords.size) { | ||
ignoredWords.forEach((word) => { | ||
spellChecker.addWord(word) | ||
}) | ||
} | ||
state = state.delete('dictionary') | ||
} | ||
return state | ||
} | ||
|
||
const spellCheckerReducer = (state, action, immutableAction) => { | ||
action = immutableAction || makeImmutable(action) | ||
switch (action.get('actionType')) { | ||
case appConstants.APP_SET_STATE: | ||
state = migrate(state) | ||
break | ||
case appConstants.APP_SPELLING_SUGGESTED: | ||
if (typeof action.suggestion === 'string') { | ||
const webContents = getWebContents(action.tabId) | ||
if (webContents && !webContents.isDestroyed()) { | ||
webContents.replaceMisspelling(action.suggestion) | ||
} | ||
} | ||
break | ||
case appConstants.APP_LEARN_SPELLING: | ||
if (typeof action.word === 'string') { | ||
spellChecker.addWord(action.word) | ||
const webContents = getWebContents(action.tabId) | ||
if (webContents && !webContents.isDestroyed()) { | ||
webContents.replaceMisspelling(action.word) | ||
} | ||
} | ||
break | ||
case appConstants.APP_FORGET_LEARNED_SPELLING: | ||
if (typeof action.word === 'string') { | ||
spellChecker.removeWord(action.word) | ||
const webContents = getWebContents(action.tabId) | ||
if (webContents && !webContents.isDestroyed()) { | ||
webContents.replace(action.word) | ||
} | ||
} | ||
} | ||
return state | ||
} | ||
|
||
module.exports = spellCheckerReducer |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const electron = require('electron') | ||
const session = electron.session | ||
|
||
module.exports.addWord = (word) => { | ||
session.defaultSession.spellChecker.addWord(word) | ||
} | ||
|
||
module.exports.removeWord = (word) => { | ||
session.defaultSession.spellChecker.removeWord(word) | ||
} |
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
Oops, something went wrong.