[wp-trac] [WordPress Trac] #27389: MCE Views for Audio/Video

WordPress Trac noreply at wordpress.org
Wed Apr 9 20:15:51 UTC 2014


#27389: MCE Views for Audio/Video
----------------------------+-------------------------
 Reporter:  wonderboymusic  |       Owner:
     Type:  task (blessed)  |      Status:  reopened
 Priority:  normal          |   Milestone:  3.9
Component:  Media           |     Version:  trunk
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |     Focuses:  javascript
----------------------------+-------------------------

Comment (by azaozz):

 Replying to [comment:27 wonderboymusic]:

 There is no need to use jQuery inside the editor (TinyMCE includes Sizzle
 too). This bit:

 {{{
 _.each( tinymce.editors, function( editor ) {
   var doc;
   if ( editor.plugins.wpview ) {
     doc = editor.getDoc();
     size += $( doc ).find( '[data-wpview-text="' + self.encodedText + '"]'
 ).length;
   }
 } );
 }}}

 would be better as:


 {{{
 _.each( tinymce.editors, function( editor ) {
   if ( editor.plugins.wpview ) {
     size += editor.dom.select( '[data-wpview-text="' + self.encodedText +
 '"]' ).length;
   }
 } );
 }}}

 Also `self.encodedText` can be quite long, might slow down or even break
 the selector? If you need to count only specific views, perhaps select all
 views first with `views = editor.dom.select( '[data-wpview-text]' );` then
 loop over them and count only the specific views by matching the attribute
 value with `editor.dom.getAttrib( viewNode, 'data-wpview-text' ) ===
 self.encodedText`.

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


More information about the wp-trac mailing list