Search code examples
ruby-on-railsjsontinymcehunspell

TinyMCE Spellcheck expected JSON Response in Rails


I am using TinyMCE and I have rolled my own spellchecker using FFI-Hunspell.

I am just rendering this hardcoded response but when I click the spell check button in the WYSIWYG editor, it says that there aren't any misspelled words.

render :json => {:id => "#{params[:id]}", :result => {"presents" => ["presnts"], "motor" => ["moors"]}}.to_json

So, what is the JSON supposed to look like?


Solution

  • I am using the tinymce_rails gem. I would have thought it was using the newer version. Anyways, I found this link that describes in detail how the request/response should look: https://github.com/spohlenz/tinymce-rails. Effectively, the response for the older version of tinyMCE is this:

    render :json => ({:id => nil, :result => ['badk', 'wirds'], :error => nil}).to_json

    Also, it actually uses a second request to get the suggestions. And those should look like:

    render :json => ({:id => nil, :result => ['bad', 'bed'], :error => nil}).to_json