Platinum Partner

Adding Spellchecker To TinyMCE Rails Plugin

Add the spellechecker plugin to TinyMCE using Aspell

1) Install Aspell:

sudo apt-get install aspell

2) Make sure the english dictionary is installed with 

aspell dicts

3) Add 'spellchecker' to the ':options => :plugins' array of users_tiny_mce in the controller.

4) add the following to the ':options' hash:


:spellchecker_languages => "+English=en",

:spellchecker_rpc_url   => '/spellchecker'


5) Set ':theme => :advanced' and make sure 'spellchecker' is in one of the ':theme_advanced_buttons_[1|2|3|4]' strings

6) Set up the route in config/routes.rb:


map.spellcheck '/spellchecker', :controller => 'admin/dashboard', :action => 'spellchecker'


7) Add the spellchecker action to the controller:


class Admin::DashboardController < ApplicationController

  include TinyMCE::SpellChecker

  def spellchecker
    language, words, method = params[:params][0], params[:params][1], params[:method] unless params[:params].blank?
    return render :nothing => true if language.blank? || words.blank? || method.blank?
    headers["Content-Type"] = "text/plain"
    headers["charset"]      = "utf-8"
    suggestions             = check_spelling(words, method, language)
    results                 = {"id" => nil, "result" => suggestions, "error" => nil}
    render :json => results
  end

end
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}