Make WordPress Core

Changeset 31740


Ignore:
Timestamp:
03/11/2015 11:52:15 PM (12 years ago)
Author:
azaozz
Message:

TinyMCE: improve setting of the sandboxing iframe inside a view.
Props mattheu, iseulde. Fixes #31412.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/mce-view.js

    r31731 r31740  
    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 ) {
    … …  
    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 */
    … …  
    589588                                                } );
    590589                                        }
     590
     591                                        callback && callback.apply( this, arguments );
    591592                                }, 50 );
    592 
    593                                 callback && callback.apply( this, arguments );
    594593                        }, rendered );
    595594                },
Note: See TracChangeset for help on using the changeset viewer.