TinyMCE 4.0.5 spell check not working

白昼怎懂夜的黑 提交于 2019-12-12 10:33:00

问题


I am currently using TinyMCE 4.0.5 with jQuery package and noticed that spell check is not working

i am using a simple set up

tinymce.init({
         selector: "textarea",
         plugins : "spellchecker",
});

With this set up i can see the option 'SpellCheck' under 'Tools' but when i click on 'SpellCheck' it throws an error 'Error: GENERAL'

Also there is an error in the error log "File does not exist: PATH/tinymce/js/tinymce/plugins/spellchecker//

but i can see the following file in the above path PATH/tinymce/js/tinymce/plugins/spellchecker/plugin.min.js


回答1:


According to what I've found elsewhere, the spellchecker plugin was powered by Google service - which has been retired. So at this time there does not appear to be an integrated TinyMCE spellchecker solution.

However, you CAN enable the browser's built-in spellchecker by doing the following:

tinymce.init({
    browser_spellcheck : true,
});

Be sure to remove spellchecker from your toolbar and your plugins list.




回答2:


Ran into this and solution is even more weird then problem itself: the thing is, that when plugin misses spellchecker_rpc_url parameter, it simply queries the same directory he's in, that's why we get

File does not exist: PATH/tinymce/js/tinymce/plugins/spellchecker/

Set spellchecker_rpc_url parameter to your script URL and this error message will be gone.




回答3:


The current version of the tinyMCE PHP speller checker (2.0.6.1) seems to be for tinyMCE 3.x not 4.x. I had the same issue as you when setting up 4.0.12. Even if I set my spellchecker_rpc_url to point to rpc.php from the 2.0.6.1 php, it doesn't work because the code doesn't line up with the JSON request being sent by tinyMCE.

There is unreleased work on the tinyMCE spell checker git hub https://github.com/tinymce/tinymce_spellchecker_php If you download this and use this instead you should have more luck. Beware though, the Google API doesn't exist any more, so you'll have to use enchant or pspell.

There is also a proposed solution to updating the 2.0.6.1 code to work with 4.x on this post http://www.tinymce.com/develop/bugtracker_view.php?id=6309%29.




回答4:


I did a lot of R&D how to make it work with PHP and details are given below:

  1. Download the community version of tinyMCE form the tinyMCE website. In the download directory, there is a folder spellcheck under plugin folder in which there is a file plugin.min.js. Reference to this file needs to add in the client side code.

  2. Download the PHP spell check code from the given URL i.e https://www.tinymce.com/docs/get-started/spellchecking/#phpspellcheckercomponent

Host the same on PHP server. And make sure that the enchant option is enabled on PHP server.

You can check the same via phpserverurl/spellchecker/info.php, find the enchant module [to check the enchant option is enabled or not, on PHP server][1][1]: https://i.stack.imgur.com/fBzDm.png

If the file phpserverurl/spellchecker/info.php does not exist, then create a new file there and write the following code:

<?php
phpinfo();
?>

Client-side code for tinyMCE:

// Scripts reference

tinymce.init
({
mode: "exact",
selector: 'textarea',
height: 540,
with: 'auto',
menubar: false,
toolbar: 'spellchecker | formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | undo redo | removeformat',
toolbar_items_size: 'small',
branding: false, // To disable "Powered by TinyMCE"
statusbar: false,
plugins: "spellchecker",
spellchecker_rpc_url: 'phpserverurl/spellchecker/spellchecker.php', // this is url of php server where spellchecker code is hosted spellchecker_languages: 'en'
});


Click on spellcheck icon when the editor is rendered and it will give you the suggestions to correct the misspelled words.

If your tinyMCE code and spellchecker code is hosted on a different server then add a line of code in the header of spellchecker.php file i.e given below

header ("Access-Control-Allow-Origin: *");
header ("Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS");
header ("Access-Control-Allow-Headers: *");

In order to resolve the cross-domain request, otherwise, there is no need to add the above line of code.

Thanks.



来源:https://stackoverflow.com/questions/18626276/tinymce-4-0-5-spell-check-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!