TinyMCE adds & nbsp instead of space when using the word paste

I am using the TinyMCE editor and the insertion of a word function.

My problem is that when I have spaces, tinyMCE converts them to & nbsp and I would like to keep normal space.

Is there a filtering function or something similar that can be used in tinyMCe.init to do this?

Thanks.

+4
source share
2 answers

I found a soul, I'm not sure that it is correct, but it works. In tinyMCE.init, I added:

paste_auto_cleanup_on_paste : true, paste_postprocess : function(pl, o) { // remove extra line breaks o.node.innerHTML = o.node.innerHTML.replace(/ /ig, " "); } 

Here is the whole tinyMCE init:

 function addTinyMCE_Authors_AffiliationsWord() { jQuery('#dialog-authors_affiliations_parsing').tinymce({ script_url: '/js/tiny_mce_3.2.7_jquery/jscripts/tiny_mce/tiny_mce.js', width: "800px", height: "250px", mode: "textarea", theme : "advanced", plugins : "paste", // Theme options theme_advanced_buttons1 : "pasteword", theme_advanced_buttons2 :"", theme_advanced_buttons3 :"", theme_advanced_buttons4 :"", theme_advanced_toolbar_location : "bottom", valid_elements : "p", paste_auto_cleanup_on_paste : true, paste_postprocess : function(pl, o) { // remove &nbsp o.node.innerHTML = o.node.innerHTML.replace(/ /ig, " "); } }); } 

ENJOY ...

+8
source

Have you tried adding: entity_encoding: 'raw' when initializing tinyMce? it helped in my case.

Sincerely.

+5
source

Source: https://habr.com/ru/post/1432073/


All Articles