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.
Move learnSpelling and forgetLearnedSpelling to appActions
Auditors: @bridiver
- Loading branch information
Showing
7 changed files
with
52 additions
and
98 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,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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -560,19 +560,17 @@ function getMisspelledSuggestions (selection, isMisspelled, suggestions) { | |
if (isMisspelled) { | ||
template.push({ | ||
label: locale.translation('learnSpelling'), | ||
click: (item, focusedWindow) => { | ||
if (focusedWindow) { | ||
focusedWindow.webContents.addWord(selection) | ||
} | ||
click: () => { | ||
appActions.learnSpelling(selection) | ||
webviewActions.replace(selection) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bridiver
Collaborator
|
||
} | ||
}, CommonMenu.separatorMenuItem) | ||
} else { | ||
template.push({ | ||
label: locale.translation('forgetLearnedSpelling'), | ||
click: (item, focusedWindow) => { | ||
if (focusedWindow) { | ||
focusedWindow.webContents.removeWord(selection) | ||
} | ||
click: () => { | ||
appActions.forgetLearnedSpelling(selection) | ||
webviewActions.replace(selection) | ||
} | ||
}, CommonMenu.separatorMenuItem) | ||
} | ||
|
@@ -972,11 +970,10 @@ function mainTemplateInit (nodeProps, frame, tab) { | |
if (isInputField) { | ||
let misspelledSuggestions = [] | ||
if (nodeProps.misspelledWord) { | ||
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) | ||
} | ||
misspelledSuggestions = getMisspelledSuggestions(nodeProps.selectionText, true, nodeProps.dictionarySuggestions) | ||
} else if (nodeProps.properties.hasOwnProperty('learnedSpelling') && | ||
nodeProps.properties['learnedSpelling'] === nodeProps.selectionText) { | ||
misspelledSuggestions = getMisspelledSuggestions(nodeProps.selectionText, false, nodeProps.dictionarySuggestions) | ||
} | ||
|
||
const editableItems = getEditableItems(nodeProps.selectionText, nodeProps.editFlags, true) | ||
|
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ const diff = require('immutablediff') | |
const debounce = require('../lib/debounce') | ||
const path = require('path') | ||
const autofill = require('../../app/autofill') | ||
const spellChecker = require('../../app/spellChecker') | ||
const nativeImage = require('../../app/nativeImage') | ||
const filtering = require('../../app/filtering') | ||
const basicAuth = require('../../app/browser/basicAuth') | ||
|
@@ -904,6 +905,16 @@ const handleAppAction = (action) => { | |
case appConstants.APP_SWIPE_RIGHT: | ||
appState = appState.set('swipeRightPercent', action.percent) | ||
break | ||
case appConstants.APP_LEARN_SPELLING: | ||
This comment has been minimized.
Sorry, something went wrong.
bridiver
Collaborator
|
||
if (typeof action.word === 'string') { | ||
spellChecker.addWord(action.word) | ||
} | ||
break | ||
case appConstants.APP_FORGET_LEARNED_SPELLING: | ||
if (typeof action.word === 'string') { | ||
spellChecker.removeWord(action.word) | ||
} | ||
break | ||
default: | ||
} | ||
|
||
|
replaceMisspelling
should be called by the handler forlearnSpelling