TinyMCE is on it’s way to release new major update to 4.0. You may want to see a demo for a quick highlights of updates.
Well, I just realized that I’m writing this post in TinyMCE 3.5.8. 4.0 it is still in beta stage but probably we’ll see the upgrades to 4.0 in a few months after it will have final release.
Anyway, while doing updates to JSpellChecker (see below for a list) and developing the “usage example” project, I downloaded latest TinyMCE 4.0 release and was surprised by the error’s I see after trying to perform spellcheck. The thing is that TinyMCE 4.0 spellchecker plugin has a lot of updates and actually now it’s using completely different request structure than before (in 3.x). There is no docs yet which document the new spellchecker request structure, so I did investigation of requests in java debug and in Chrome developer console.
The good news about new spellchecker API is that it seems to be more optimal, since it execute only one request in which it sends words he want to check and expect the suggestions back (for all words) for misspelled words. So, user who use editor will be able to see suggestions right after he got response. Not sure how that will impact the server-side of spellchecker, but generally I think that algorithms could be optimized and suggestions to all words could be retrieved faster (since dictionaries/indexes are already loaded at the moment we look for misspelled words). At least number of potential requests to server will be much lower.
The bad news (on the moment) is that only one language is supported on the moment (spellchecker plugin always pass “lang”=”en”). There is a bug filled and I believe it will be fixed before final release. But you are welcome to vote for it!
TinyMCE site does not provide documentation on request/response structure for the new spellchecker API (actually it does not provide it for previous version too). Information below is a result of reverse engineering of new spellchecker plugin code.
Well, so the request structure is updated and now only one request is done by spellchecker plugin.
See example spellchecker request/response comparison table below:
Before TinyMCE 4.0 | Since TinyMCE 4.0 |
---|---|
“checkWords” requestCheck the list of words passed as a second argument of the “params” array. First argument of the params array, define the “language” Example request{ "method" : "checkWords", "params" : [ "en-us", ["usa","cawboy", "apple"] ] } Example Response"id":null, "result":["cawboy"], "error":null} |
“spellcheck” requestIt is done by a single request/response now. “params” is now JsonObject not JsonArray and that make request more structured Example request{ "id" : ${request-id}, "method" : "spellcheck", "params" : { "lang": "en-us", "words": ["usa","cawboy", "apple", "blablabla"] } } Example ResponseThe “result” will contain mappings where key is misspelled word and value is suggestion list for it. It also may return empty suggestion list for a word and that will mark it as “misspelled” { "id":"${request-id}", "result": { "cawboy" : ["cowboy"], "Guugli" : ["Google"], "blablabla" : [] } } |
“getWordSuggestions” requestGet suggestion for single word, passed as the 2-nd element in the “params” array Example request{ "method" : "getWordSuggestions", "params" : [ "en-us", "Guugli" ] } Example Response{"id":null, "result":["Google"], "error":null } |
Btw, the JspellChecker code is updated to support TinyMCE 4.0 request/response format. It also contains other refactorings, updates and fixes which I will cover in the next post
