Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// are incorrectly marked as spelling errors. This lets people get away with
// incorrectly spelled contracted words, but it's the best we can do for now.
const contractions = [
"ain't", "aren't", "can't", "could've", "couldn't", "couldn't've", "didn't", "doesn't", "don't", "hadn't",
"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)
}
}
loadAvailableDictionaries() {
this.availableDictionaries = checker.getAvailableDictionaries().sort();
if (this.availableDictionaries.length === 0) {
this.multiLanguage = false;
// Dictionaries path is correct for build
this.dictionariesPath = path.join(
app.getAppPath(),
app.getAppPath().endsWith('app.asar') ? '..' : '.',
'dictionaries'
);
this.getDictionariesFromInstallDirectory();
} else {
this.multiLanguage = process.platform !== 'win32';
this.availableDictionaries = this.availableDictionaries.map((dict) => dict.replace('-', '_'));
}
}
function getSpellCheckerDictionaries () {
return SpellChecker.getAvailableDictionaries();
}
/*
* Abricotine - Markdown Editor
* Copyright (c) 2015 Thomas Brouard
* Licensed under GNU-GPLv3
*/
var constants = require.main.require("./constants"),
files = require.main.require("./files"),
fs = require("fs"),
langmap = require("langmap"),
Menu = require("electron").Menu,
pathModule = require("path"),
spellchecker = require('spellchecker'),
sysDictionaries = spellchecker.getAvailableDictionaries();
function getConfig (config, key) {
if (config && typeof config.get === "function") {
return config.get(key) || false;
}
return false;
}
function preprocessTemplate (abrApp, element, config, abrWin) {
if (element.constructor !== Array) {
return;
}
var sendCommand = abrApp.execCommand.bind(abrApp),
replaceAttributes = function (item) {
if (item.condition) {
delete item.condition;
const doLoadConfig = function* () {
const embeddedDictionaries = spellchecker.getAvailableDictionaries();
const supportsMultipleDictionaries = embeddedDictionaries.length > 0 && process.platform !== 'win32';
const directory = getDirectory('app', 'dictionaries');
const dictionaryInstallationDirectory = directory.path();
const installedDictionaries = (yield directory.findAsync({ matching: '*.{aff,dic}' }))
.map((fileName) => path.basename(fileName, path.extname(fileName)));
const availableDictionaries = Array.from(new Set([...embeddedDictionaries, ...installedDictionaries])).sort();
yield put(spellCheckingConfigurationLoaded({
supportsMultipleDictionaries,
dictionaryInstallationDirectory,
availableDictionaries,
}));
};