Make WordPress Core

Ticket #31412: 31412.24.patch

File 31412.24.patch, 2.3 KB (added by iseulde, 10 years ago)
  • src/wp-includes/js/mce-view.js

     
    9191                setMarkers: function( content ) {
    9292                        var pieces = [ { content: content } ],
    9393                                self = this,
     94                                instance,
    9495                                current;
    9596
    9697                        _.each( views, function( view, type ) {
     
    115116                                                        pieces.push( { content: remaining.substring( 0, result.index ) } );
    116117                                                }
    117118
    118                                                 self.createInstance( type, result.content, result.options );
     119                                                instance = self.createInstance( type, result.content, result.options );
    119120
    120121                                                // Add the processed piece for the match.
    121122                                                pieces.push( {
    122                                                         content: '<p data-wpview-marker="' + encodeURIComponent( result.content ) + '">' + result.content + '</p>',
     123                                                        content: '<p data-wpview-marker="' + instance.encodedText + '">' + instance.text + '</p>',
    123124                                                        processed: true
    124125                                                } );
    125126
     
    149150                 */
    150151                createInstance: function( type, text, options ) {
    151152                        var View = this.get( type ),
    152                                 encodedText = encodeURIComponent( text ),
    153                                 instance = this.getInstance( encodedText );
     153                                encodedText,
     154                                instance;
     155
     156                        text = tinymce.DOM.decode( text ),
     157                        encodedText = encodeURIComponent( text ),
     158                        instance = this.getInstance( encodedText );
    154159
    155160                        if ( instance ) {
    156161                                return instance;
     
    754759                        if ( this.url ) {
    755760                                this.loader = false;
    756761                                this.shortcode = wp.media.embed.shortcode( {
    757                                         url: this.url
     762                                        url: this.text
    758763                                } );
    759764                        }
    760765
     
    804809
    805810                edit: function( text, update ) {
    806811                        var media = wp.media.embed,
    807                                 frame = media.edit( text, !! this.url ),
     812                                frame = media.edit( text, this.url ),
    808813                                self = this,
    809814                                events = 'change:url change:width change:height';
    810815
     
    819824                        frame.state( 'embed' ).on( 'select', function() {
    820825                                var data = frame.state( 'embed' ).metadata;
    821826
    822                                 if ( data.width ) {
    823                                         delete self.url;
    824                                 } else {
    825                                         self.url = data.url;
    826                                 }
    827 
    828                                 if ( self.url  ) {
     827                                if ( self.url && ! data.width ) {
    829828                                        update( data.url );
    830829                                } else {
    831830                                        update( media.shortcode( data ).string() );
     
    866865                                        index: match.index + match[1].length,
    867866                                        content: match[2],
    868867                                        options: {
    869                                                 url: match[2]
     868                                                url: true
    870869                                        }
    871870                                };
    872871                        }