Make WordPress Core

Ticket #31412: 31412.25.patch

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

     
    433433                 */
    434434                setContent: function( content, callback, rendered ) {
    435435                        if ( _.isObject( content ) && content.body.indexOf( '<script' ) !== -1 ) {
    436                                 this.setIframes( content.head, content.body, callback, rendered );
     436                                this.setIframes( content.head || '', content.body, callback, rendered );
    437437                        } else if ( _.isString( content ) && content.indexOf( '<script' ) !== -1 ) {
    438                                 this.setIframes( null, content, callback, rendered );
     438                                this.setIframes( '', content, callback, rendered );
    439439                        } else {
    440440                                this.getNodes( function( editor, node, contentNode ) {
    441441                                        content = content.body || content;
     
    465465                                importStyles = this.type === 'video' || this.type === 'audio' || this.type === 'playlist';
    466466
    467467                        this.getNodes( function( editor, node, content ) {
    468                                 var dom = editor.dom,
    469                                         styles = '',
    470                                         bodyClasses = editor.getBody().className || '',
    471                                         iframe, iframeDoc, observer, i;
    472 
    473                                 content.innerHTML = '';
    474                                 head = head || '';
    475 
    476                                 if ( importStyles ) {
    477                                         if ( ! wp.mce.views.sandboxStyles ) {
    478                                                 tinymce.each( dom.$( 'link[rel="stylesheet"]', editor.getDoc().head ), function( link ) {
    479                                                         if ( link.href && link.href.indexOf( 'skins/lightgray/content.min.css' ) === -1 &&
    480                                                                 link.href.indexOf( 'skins/wordpress/wp-content.css' ) === -1 ) {
    481 
    482                                                                 styles += dom.getOuterHTML( link ) + '\n';
    483                                                         }
    484                                                 });
    485 
    486                                                 wp.mce.views.sandboxStyles = styles;
    487                                         } else {
    488                                                 styles = wp.mce.views.sandboxStyles;
    489                                         }
    490                                 }
    491 
    492468                                // Seems Firefox needs a bit of time to insert/set the view nodes,
    493469                                // or the iframe will fail especially when switching Text => Visual.
    494470                                setTimeout( function() {
     471                                        var dom = editor.dom,
     472                                                styles = '',
     473                                                bodyClasses = editor.getBody().className || '',
     474                                                iframe, iframeDoc, observer, i;
     475
     476                                        if ( importStyles ) {
     477                                                if ( ! wp.mce.views.sandboxStyles ) {
     478                                                        tinymce.each( dom.$( 'link[rel="stylesheet"]', editor.getDoc().head ), function( link ) {
     479                                                                if ( link.href && link.href.indexOf( 'skins/lightgray/content.min.css' ) === -1 &&
     480                                                                        link.href.indexOf( 'skins/wordpress/wp-content.css' ) === -1 ) {
     481
     482                                                                        styles += dom.getOuterHTML( link ) + '\n';
     483                                                                }
     484                                                        });
     485
     486                                                        wp.mce.views.sandboxStyles = styles;
     487                                                } else {
     488                                                        styles = wp.mce.views.sandboxStyles;
     489                                                }
     490                                        }
     491
     492                                        content.innerHTML = '';
     493
    495494                                        iframe = dom.add( content, 'iframe', {
    496495                                                /* jshint scripturl: true */
    497496                                                src: tinymce.Env.ie ? 'javascript:""' : '',
     
    588587                                                        editor.off( 'wp-body-class-change', classChange );
    589588                                                } );
    590589                                        }
    591                                 }, 50 );
    592590
    593                                 callback && callback.apply( this, arguments );
     591                                        callback && callback.apply( this, arguments );
     592                                }, 50 );
    594593                        }, rendered );
    595594                },
    596595