[wp-trac] [WordPress Trac] #31157: TinyMCE inserts non-breaking spaces in unwanted places

WordPress Trac noreply at wordpress.org
Sun Feb 1 17:26:38 UTC 2015


#31157: TinyMCE inserts non-breaking spaces in unwanted places
--------------------------+-----------------------------------------
 Reporter:  nonverbla     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  TinyMCE       |     Version:  4.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  javascript, administration
--------------------------+-----------------------------------------

Comment (by nonverbla):

 so... I think I found a real work-around for this. I put this script after
 the tinymce script, using the 'after_wp_tiny_mce' action hook:
 {{{
 tinymce.on('AddEditor', function(event) {

   // stores the editor instance
   var editor = event.editor;

   // always do this when the editor looses focus
   editor.on('blur', function (event) {

     // get the contents, but get them raw! All other formats fail to
 return the   we are looking for
     var content = editor.getContent({format: "raw", no_events: 1});

     // now replace that sucker
     content = content.replace(/ /ig, ' ');

     //... and re-set the content
     editor.setContent( content, no_events: 1 );

   });

 });
 }}}
 Any thoughts on this approach?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31157#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list