Make WordPress Core

Changeset 28273


Ignore:
Timestamp:
05/06/2014 04:50:52 AM (11 years ago)
Author:
nacin
Message:

Fix persistence of <track> elements in the body of a [video] shotcode in TinyMCE views.

Merges [28183] and [28169] to the 3.9 branch.

props azaozz, wonderboymusic.
fixes #27915.

Location:
branches/3.9
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3.9

  • branches/3.9/src/wp-includes/css/media-views.css

    r28101 r28273  
    17821782}
    17831783
    1784 .media-embed .setting input.hidden {
     1784.media-embed .setting input.hidden,
     1785.media-embed .setting textarea.hidden {
    17851786    display: none;
    17861787}
  • branches/3.9/src/wp-includes/js/mce-view.js

    r28272 r28273  
    484484         */
    485485        getHtml: function() {
    486             var attrs = _.defaults(
    487                 this.shortcode.attrs.named,
    488                 wp.media[ this.shortcode.tag ].defaults
    489             );
    490             return this.template({ model: attrs });
     486            var attrs = this.shortcode.attrs.named;
     487            attrs.content = this.shortcode.content;
     488
     489            return this.template({ model: _.defaults(
     490                attrs,
     491                wp.media[ this.shortcode.tag ].defaults )
     492            });
    491493        },
    492494
  • branches/3.9/src/wp-includes/js/tinymce/plugins/wpview/plugin.js

    r28084 r28273  
    333333            // Empty the wrap node
    334334            if ( 'textContent' in node ) {
    335                 node.textContent = '';
     335                node.textContent = '\u00a0';
    336336            } else {
    337                 node.innerText = '';
    338             }
    339 
    340             // This makes all views into block tags (as we use <div>).
    341             // Can use 'PostProcess' and a regex instead.
    342             dom.replace( dom.create( 'p', null, window.decodeURIComponent( dom.getAttrib( node, 'data-wpview-text' ) ) ), node );
     337                node.innerText = '\u00a0';
     338            }
    343339        });
    344340    });
     341
     342    editor.on( 'PostProcess', function( event ) {
     343        if ( event.content ) {
     344            event.content = event.content.replace( /<div [^>]*?data-wpview-text="([^"]*)"[^>]*>[\s\S]*?<\/div>/g, function( match, shortcode ) {
     345                if ( shortcode ) {
     346                    return '<p>' + window.decodeURIComponent( shortcode ) + '</p>';
     347                }
     348                return ''; // If error, remove the view wrapper
     349            });
     350        }
     351    });
    345352
    346353    editor.on( 'keydown', function( event ) {
Note: See TracChangeset for help on using the changeset viewer.