Make WordPress Core

Ticket #29048: 29048.5.patch

File 29048.5.patch, 5.5 KB (added by azaozz, 9 years ago)
  • src/wp-includes/js/mce-view.js

     
    124124                },
    125125                /* jshint scripturl: true */
    126126                setIframes: function ( html ) {
    127                         var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
     127                        var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
     128                                importStyles = this.type === 'video' || this.type === 'audio' || this.type === 'playlist';
    128129
    129130                        if ( html.indexOf( '<script' ) !== -1 ) {
    130131                                this.getNodes( function ( editor, node, content ) {
    131132                                        var dom = editor.dom,
     133                                                styles = '',
     134                                                bodyClasses = editor.getBody().className || '',
    132135                                                iframe, iframeDoc, i, resize;
    133136
    134137                                        content.innerHTML = '';
    135138
     139                                        if ( importStyles ) {
     140                                                if ( ! wp.mce.views.sandboxStyles ) {
     141                                                        tinymce.each( dom.$( 'link[rel="stylesheet"]', editor.getDoc().head ), function( link ) {
     142                                                                if ( link.href && link.href.indexOf( 'skins/lightgray/content.min.css' ) === -1 &&
     143                                                                        link.href.indexOf( 'skins/wordpress/wp-content.css' ) === -1 ) {
     144
     145                                                                        styles += dom.getOuterHTML( link ) + '\n';
     146                                                                }
     147                                                        });
     148
     149                                                        wp.mce.views.sandboxStyles = styles;
     150                                                } else {
     151                                                        styles = wp.mce.views.sandboxStyles;
     152                                                }
     153                                        }
     154
    136155                                        // Seems Firefox needs a bit of time to insert/set the view nodes, or the iframe will fail
    137156                                        // especially when switching Text => Visual.
    138157                                        setTimeout( function() {
     
    156175                                                        '<html>' +
    157176                                                                '<head>' +
    158177                                                                        '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' +
     178                                                                        styles +
    159179                                                                        '<style>' +
    160180                                                                                'html {' +
    161181                                                                                        'background: transparent;' +
     
    164184                                                                                '}' +
    165185                                                                                'body#wpview-iframe-sandbox {' +
    166186                                                                                        'background: transparent;' +
    167                                                                                         'padding: 1px 0;' +
    168                                                                                         'margin: -1px 0 0;' +
     187                                                                                        'padding: 1px 0 !important;' +
     188                                                                                        'margin: -1px 0 0 !important;' +
    169189                                                                                '}' +
     190                                                                                'body#wpview-iframe-sandbox:before, body#wpview-iframe-sandbox:after {' +
     191                                                                                        'display: none;' +
     192                                                                                        'content: "";' +
     193                                                                                '}' +
    170194                                                                        '</style>' +
    171195                                                                '</head>' +
    172                                                                 '<body id="wpview-iframe-sandbox">' +
     196                                                                '<body id="wpview-iframe-sandbox" class="' + bodyClasses + '">' +
    173197                                                                        html +
    174198                                                                '</body>' +
    175199                                                        '</html>'
     
    195219                                                                setTimeout( resize, i * 700 );
    196220                                                        }
    197221                                                }
     222
     223                                                if ( importStyles ) {
     224                                                        editor.on( 'wp-body-class-change', function() {
     225                                                                iframeDoc.body.className = editor.getBody().className;
     226                                                        });
     227                                                }
    198228                                        }, 50 );
    199229                                });
    200230                        } else {
  • src/wp-includes/js/mediaelement/wp-mediaelement.css

     
    1 #wpview-iframe-sandbox {
    2         color: #444;
    3         font-family: "Open Sans", sans-serif;
    4         font-size: 13px;
    5         line-height: 1.4em;
    6 }
    7 
    81.mejs-container {
    92        clear: both;
    103}
     
    278271
    279272.wp-audio-playlist .me-cannotplay span {
    280273        padding: 5px 15px;
    281 }
    282  No newline at end of file
     274}
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

     
    260260
    261261        editor.on( 'init', function() {
    262262                var scrolled = false,
    263                         selection = editor.selection;
     263                        selection = editor.selection,
     264                        MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
    264265
    265266                // When a view is selected, ensure content that is being pasted
    266267                // or inserted is added to a text node (instead of the view).
     
    333334                                scrolled = false;
    334335                        }
    335336                }, true );
     337
     338                if ( MutationObserver ) {
     339                        new MutationObserver( function() {
     340                                editor.fire( 'wp-body-class-change' );
     341                        } )
     342                        .observe( editor.getBody(), {
     343                                attributes: true,
     344                                attributeFilter: ['class']
     345                        } );
     346                }
    336347        });
    337348
    338349        editor.on( 'PreProcess', function( event ) {
  • src/wp-includes/media.php

     
    33103310 */
    33113311function wpview_media_sandbox_styles() {
    33123312        $version = 'ver=' . $GLOBALS['wp_version'];
    3313         $open_sans = "//fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&subset=latin%2Clatin-ext&ver=$version";
    3314         $dashicons = includes_url( "css/dashicons.css?$version" );
    33153313        $mediaelement = includes_url( "js/mediaelement/mediaelementplayer.min.css?$version" );
    33163314        $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" );
    33173315
    3318         /**
    3319          * For use by themes that need to override the styling of MediaElement based previews in the Visual editor.
    3320          * Not intended for adding editor-style.css. Ideally these styles will be applied by using
    3321          * the 'seamless' iframe attribute in the future.
    3322          *
    3323          * @since 4.0
    3324          *
    3325          * @param array The URLs to the stylesheets that will be loaded in the sandbox iframe.
    3326          */
    3327         return apply_filters( 'wpview_media_sandbox_styles', array( $open_sans, $dashicons, $mediaelement, $wpmediaelement ) );
     3316        return array( $mediaelement, $wpmediaelement );
    33283317}