[wp-trac] [WordPress Trac] #23198: Pass post format as a class to TinyMCE init

WordPress Trac noreply at wordpress.org
Tue Jan 22 00:50:37 UTC 2013


#23198: Pass post format as a class to TinyMCE init
--------------------------------+------------------
 Reporter:  helen               |       Owner:
     Type:  enhancement         |      Status:  new
 Priority:  normal              |   Milestone:  3.6
Component:  TinyMCE             |     Version:
 Severity:  normal              |  Resolution:
 Keywords:  easy-fix has-patch  |
--------------------------------+------------------

Comment (by azaozz):

 > i will try to cook up some jQuery to update the applied classes, fun!

 You will need to hook that up to TinyMCE. Something like:

 {{{
 if ( typeof tinymce != 'undefined ) {
   // get the new class
   jQuery('#post-formats-select input.post-format').on('change',
 function(){
     var ed = tinymce.get('content'), edBody, format;

     if ( ! ed )
       return;

     if ( this.id ) {
       edBody = ed.getBody();
       format = this.id; // also need to handle 'post-format-0'

       edBody.className = edBody.className.replace(/\bpost-format-[^ ]+/,
 '');
       edBody.className += format;
     }
   });
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23198#comment:26>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list