[wp-trac] [WordPress Trac] #30094: wp.mce.views.toViews() not handling nested shortcodes

WordPress Trac noreply at wordpress.org
Fri Oct 24 20:32:15 UTC 2014


#30094: wp.mce.views.toViews() not handling nested shortcodes
----------------------------------------+-----------------------------
 Reporter:  csixty4                     |      Owner:
     Type:  defect (bug)                |     Status:  new
 Priority:  normal                      |  Milestone:  Awaiting Review
Component:  TinyMCE                     |    Version:  4.0
 Severity:  normal                      |   Keywords:
  Focuses:  javascript, administration  |
----------------------------------------+-----------------------------
 Working on a custom shortcode implementation that uses a wp.mce.View for a
 display in TinyMCE. Our QA tester noticed a rendering issue when there was
 an audio shortcode nested inside our shortcode, ex: [a][audio
 mp3="https://archive.org/download/jcalebgreenemp3sample/4_2nd_Perception_of_LightMoon_Mist_and_Rainbow_64kb.mp3"][/audio][/a]

 This loop at the start of wp.mce.view.toViews() processes the audio
 shortcode first:
 {{{
 _.each( views, function( view, viewType ) {
 }}}

 Why? Some implementation detail of underscore.js I'm sure. Most likely
 because wp.mce.views.register() was called for  the 'audio' shortcode
 early on, and its property was added to the views object before ours.

 Further down in wp.mce.view.toViews(), this loop breaks the content into
 an array of "pieces" around the shortcodes:

 {{{
                                         // Iterate through the string
 progressively matching views
                                         // and slicing the string as we
 go.
                                         while ( remaining && (result =
 view.toView( remaining )) ) {
                                                 // Any text before the
 match becomes an unprocessed piece.
                                                 if ( result.index ) {
                                                         pieces.push({
 content: remaining.substring( 0, result.index ) });
                                                 }
 }}}

 The "piece" before the audio shortcode is the opening tag of our custom
 shortcode, which is now separated from its closing tag and rendered
 incorrectly in the editor without it (see attached).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30094>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list