Yandex Speller

Проверка орфографии и подсказка возможных вариантов, очень удобно если делаешь много грамматических ошибок)

(function ($) {
    CKEDITOR.replaceAll('ckeditor');
    CKEDITOR.on('instanceReady', function(ev) {
        let editor = ev.editor;
        if (!editor.spellCheckInited) {
            let editorBottomSelector = '.cke_inner';
            let editorBottom = $(editorBottomSelector);
            let spellCheckBar = $('
').addClass('spell-check-bar'); editorBottom.append(spellCheckBar); editor.spellCheckBar = spellCheckBar; editor.spellCheckInited = true; } function clearSuggestions() { let suggestions = editor.spellCheckBar.find('.suggestion'); if (suggestions.length) { suggestions.each(function(num, el) { $(el).remove(); }); } } function newSuggestion(wrong, fix, text) { let newSugg = $(''); newSugg.addClass('suggestion'); newSugg.text(wrong + ' ~> ' + fix); $(newSugg).on('click', function(ev) { text.data = text.data.replace(wrong, fix); $(ev.target).remove(); }); return newSugg; } function updateSuggestions(data, focusNode) { clearSuggestions(); if (data.length) { data.forEach(function(item) { if (item.s.length) { let newSugg = newSuggestion(item.word, item.s[0], focusNode); $(editor.spellCheckBar).append(newSugg); } }); } } function spellCheck() { let sel = editor.getSelection(); if (!sel) { return; } let nativeSel = sel._.cache.nativeSel || null; if (!nativeSel) { return; } let focusNode = nativeSel.focusNode; if (!focusNode) { return; } let text = focusNode.data; if (!text) { return; } $.get('https://speller.yandex.net/services/spellservice.json/checkText?text=' + text, function(data) { updateSuggestions(data, focusNode) }); } editor.document.on('mouseup', spellCheck); editor.on('change', spellCheck); }); })(jQuery);

.cke .spell-check-bar {
  display: block;
  padding: 0.5em;
}

.cke .spell-check-bar .suggestion {
  cursor: pointer;
  color: red;
  background: rgba(250,0,0,0.1);
  padding: 0.25em 0.5em;
  margin-left: 0;
  margin-top: 0;
  margin-right: 0.5em;
  margin-bottom: 0.5em;
  line-height: 1em;
  display: inline-block;
}

.cke .spell-check-bar .suggestion:hover {
  color: orange;
}