Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function setupLinux(locale) {
if (process.env.HUNSPELL_DICTIONARIES || locale !== 'en_US') {
// apt-get install hunspell- can be run for easy access to other dictionaries
var location = process.env.HUNSPELL_DICTIONARIES || '/usr/share/hunspell';
spellchecker.setDictionary(locale, location);
}
}
setEnabled(dictionaries) {
dictionaries = [].concat(dictionaries);
let result = false;
for (let i = 0; i < dictionaries.length; i++) {
if (this.availableDictionaries.includes(dictionaries[i])) {
result = true;
this.enabledDictionaries.push(dictionaries[i]);
// If using Hunspell or Windows then only allow 1 language for performance reasons
if (!this.multiLanguage) {
this.enabledDictionaries = [dictionaries[i]];
checker.setDictionary(dictionaries[i], this.dictionariesPath);
return true;
}
}
}
return result;
}
"we'll", "we're", "we've", "weren't", "what'll", "what're", "what's", "what've", "when's", "where'd",
"where's", "where've", "who'd", "who'll", "who're", "who's", "who've", "why'll", "why're", "why's", "won't",
"would've", "wouldn't", "wouldn't've", "y'all", "y'all'd've", "you'd", "you'd've", "you'll", "you're", "you've"
]
contractions.forEach((word) => contractionSet.add(word.replace(/'.*/, '')))
const availableDictionaries = spellchecker.getAvailableDictionaries()
let dict = (getSetting(settings.LANGUAGE) || app.getLocale()).replace('-', '_')
if (availableDictionaries.includes(dict)) {
dictionaryLocale = dict
spellchecker.setDictionary(dict)
} else {
dict = dict.split('_')[0]
if (availableDictionaries.includes(dict)) {
dictionaryLocale = dict
spellchecker.setDictionary(dict)
}
}
if (dictionaryLocale) {
appActions.setDictionary(dictionaryLocale)
}
}
"hadn't've", "hasn't", "haven't", "he'd", "he'd've", "he'll", "he's", "how'd", "how'll", "how's", "I'd",
"I'd've", "I'll", "I'm", "I've", "isn't", "it'd", "it'd've", "it'll", "it's", "let's", "ma'am", "mightn't",
"mightn't've", "might've", "mustn't", "must've", "needn't", "not've", "o'clock", "shan't", "she'd", "she'd've",
"she'll", "she's", "should've", "shouldn't", "shouldn't've", "that'll", "that's", "there'd", "there'd've",
"there're", "there's", "they'd", "they'd've", "they'll", "they're", "they've", "wasn't", "we'd", "we'd've",
"we'll", "we're", "we've", "weren't", "what'll", "what're", "what's", "what've", "when's", "where'd",
"where's", "where've", "who'd", "who'll", "who're", "who's", "who've", "why'll", "why're", "why's", "won't",
"would've", "wouldn't", "wouldn't've", "y'all", "y'all'd've", "you'd", "you'd've", "you'll", "you're", "you've"
]
contractions.forEach((word) => contractionSet.add(word.replace(/'.*/, '')))
const availableDictionaries = spellchecker.getAvailableDictionaries()
let dict = (getSetting(settings.LANGUAGE) || app.getLocale()).replace('-', '_')
if (availableDictionaries.includes(dict)) {
dictionaryLocale = dict
spellchecker.setDictionary(dict)
} else {
dict = dict.split('_')[0]
if (availableDictionaries.includes(dict)) {
dictionaryLocale = dict
spellchecker.setDictionary(dict)
}
}
if (dictionaryLocale) {
appActions.setDictionary(dictionaryLocale)
}
}
enabledDictionaries.flatMap((dictionary) => {
spellchecker.setDictionary(dictionary, dictionaryInstallationDirectory);
return spellchecker.getCorrectionsForMisspelling(word);
})
))));
ipcRenderer.on('spell-checker', function (event, enabled, autoCorrect, langCode) {
const chromiumLangCode = langCode.replace('_', '-');
autoCorrect = !!autoCorrect;
log('spell checker enabled:', enabled, 'auto correct:', autoCorrect, 'lang code:', langCode);
if (enabled) {
const dictionaryPath = getDictionaryPath(langCode);
log('using', langCode, 'from', dictionaryPath || 'system', 'for spell checking');
SpellChecker.setDictionary(langCode, dictionaryPath);
webFrame.setSpellCheckProvider(chromiumLangCode, autoCorrect, {
spellCheck: (text) => {
return !SpellChecker.isMisspelled(text);
}
});
} else {
webFrame.setSpellCheckProvider(chromiumLangCode, autoCorrect, {
spellCheck: () => {
return true;
}
});
}
});
function setupWin7AndEarlier(locale) {
if (process.env.HUNSPELL_DICTIONARIES || locale !== 'en_US') {
const location = process.env.HUNSPELL_DICTIONARIES;
window.log.info(
'Detected Windows 7 or below. Setting up spell-check with locale',
locale,
'and dictionary location',
location
);
spellchecker.setDictionary(locale, location);
} else {
window.log.info(
'Detected Windows 7 or below. Using default en_US spell check dictionary'
);
}
}
const allCorrections = this.enabledDictionaries.map((dictionary) => {
checker.setDictionary(dictionary);
return checker.getCorrectionsForMisspelling(text);
}).filter((c) => c.length > 0);