How to use the spellchecker.isMisspelled function in spellchecker

To help you get started, we’ve selected a few spellchecker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Algram / Hypha / app / js / util.js View on Github external
spellCheck: function (text) {
			if (checker.isMisspelled(text)) {
				//if this is a misspelling, get suggestions
				let options = checker.getCorrectionsForMisspelling(text);
				// get the number of suggestions if any
				let numSuggestions = options.length ? options.length : 0;
				// restrict it to 3 suggestions
				let maxItems = numSuggestions > 3 ? 3 : numSuggestions;
				let lastSuggestion = null;
				// if there are suggestions
				if (maxItems > 0) {
					for (var i = maxItems - 1; i >= 0; i--) {
						let item = options[i];
						template.unshift({
							label: item,
							click: function (menuItem, browserWindow) {
								remote.getCurrentWebContents().replaceMisspelling(menuItem.label);
							}
github Algram / Hypha / app / js / util.js View on Github external
// build the new template for the context menu
			menu = Menu.buildFromTemplate(template);
			//reset the template object
			template = [{
				label: 'Copy',
				role: 'copy',
			}, {
				label: 'Paste',
				role: 'paste',
			}, {
				label: 'Cut',
				role: 'cut',
			}];

			return !checker.isMisspelled(text);
		}
	});
github IsmaelMartinez / teams-for-linux / app / browser / rightClickMenuWithSpellcheck.js View on Github external
isMisspelled: function (text) {
		var misspelled = spellchecker.isMisspelled(text);

		// The idea is to make this as fast as possible. For the many, many calls which
		//   don't result in the red squiggly, we minimize the number of checks.
		if (!misspelled) {
			return false;
		}

		// Only if we think we've found an error do we check the locale and skip list.
		if (appLocale.match(EN_VARIANT) && ENGLISH_SKIP_WORDS.includes(text)) {
			return false;
		}

		return true;
	},
	getSuggestions: function (text) {
github irccloud / irccloud-desktop / app / render / spellcheck.js View on Github external
function isMisspelled (word) {
    if (contractionMap[word.toLocaleLowerCase()]) {
      return false;
    }
    return nodeSpellcheck.isMisspelled(word);
  }
github RocketChat / Rocket.Chat.Electron / src / preload / SpellCheck.js View on Github external
isCorrect(text) {
		if (!this.enabledDictionaries.length || this.contractions[text.toLocaleLowerCase()]) {
			return true;
		}

		if (this.multiLanguage) {
			for (let i = 0; i < this.enabledDictionaries.length; i++) {
				checker.setDictionary(this.enabledDictionaries[i]);
				if (!checker.isMisspelled(text)) {
					return true;
				}
			}
		} else {
			return !checker.isMisspelled(text);
		}
		return false;
	}
github johnjones4 / grammarlint / lib / modules / spelling.js View on Github external
return function(next1) {
                const noPunc = utils.normalizeWord(word);
                if (noPunc && noPunc.length > 0 && options.skipWords.indexOf(noPunc) < 0 && SpellChecker.isMisspelled(noPunc)) {
                  errors.push({
                    'line': i,
                    'index': words.slice(0,j).join(' ').length + 1,
                    'length': word.length,
                    'detail': noPunc + ' (Maybe: ' + SpellChecker.getCorrectionsForMisspelling(noPunc) + ')'
                  });
                  next1()
                } else {
                  next1();
                }
              };
            }),
github brave / browser-laptop / app / spellCheck.js View on Github external
const isMisspelled = (word) =>
  !appStore.getState().getIn(['dictionary', 'ignoredWords']).includes(word) &&
  !appStore.getState().getIn(['dictionary', 'addedWords']).includes(word) &&
  spellchecker.isMisspelled(word)
github PaulRBerg / CoinMarketCap-Desktop / src / scripts / renderer / preload / events.js View on Github external
spellCheck: (text) => {
        return !SpellChecker.isMisspelled(text);
      }
    });