Ticket #29048: 29048.6.patch
File 29048.6.patch, 7.3 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
2705 2705 ) ); 2706 2706 } 2707 2707 2708 wp_send_json_success( $parsed ); 2708 wp_send_json_success( array( 2709 'body' => $parsed 2710 ) ); 2709 2711 } 2710 2712 2711 2713 function wp_ajax_parse_media_shortcode() { … … 2729 2731 ) ); 2730 2732 } 2731 2733 2732 ob_start(); 2733 2734 $head = ''; 2734 2735 $styles = wpview_media_sandbox_styles(); 2736 2735 2737 foreach ( $styles as $style ) { 2736 printf( '<link rel="stylesheet" href="%s"/>', $style );2738 $head .= '<link type="text/css" rel="stylesheet" href="' . $style . '">'; 2737 2739 } 2738 2740 2739 echo $shortcode;2740 2741 2741 if ( ! empty( $wp_scripts ) ) { 2742 2742 $wp_scripts->done = array(); 2743 2743 } 2744 2744 2745 ob_start(); 2746 2747 echo $shortcode; 2748 2745 2749 if ( 'playlist' === $_REQUEST['type'] ) { 2746 2750 wp_underscore_playlist_templates(); 2747 2751 … … 2750 2754 wp_print_scripts( 'wp-mediaelement' ); 2751 2755 } 2752 2756 2753 wp_send_json_success( ob_get_clean() ); 2757 wp_send_json_success( array( 2758 'head' => $head, 2759 'body' => ob_get_clean() 2760 ) ); 2754 2761 } -
src/wp-includes/js/mce-view.js
123 123 } ); 124 124 }, 125 125 /* jshint scripturl: true */ 126 setIframes: function ( html ) { 127 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 126 setIframes: function ( head, body ) { 127 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, 128 importStyles = this.type === 'video' || this.type === 'audio' || this.type === 'playlist'; 128 129 129 if ( h tml.indexOf( '<script' ) !== -1 ) {130 if ( head || body.indexOf( '<script' ) !== -1 ) { 130 131 this.getNodes( function ( editor, node, content ) { 131 132 var dom = editor.dom, 133 styles = '', 134 bodyClasses = editor.getBody().className || '', 132 135 iframe, iframeDoc, i, resize; 133 136 134 137 content.innerHTML = ''; 135 138 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 136 155 // Seems Firefox needs a bit of time to insert/set the view nodes, or the iframe will fail 137 156 // especially when switching Text => Visual. 138 157 setTimeout( function() { … … 156 175 '<html>' + 157 176 '<head>' + 158 177 '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' + 178 head + 179 styles + 159 180 '<style>' + 160 181 'html {' + 161 182 'background: transparent;' + … … 164 185 '}' + 165 186 'body#wpview-iframe-sandbox {' + 166 187 'background: transparent;' + 167 'padding: 1px 0;' + 168 'margin: -1px 0 0;' + 188 'padding: 1px 0 !important;' + 189 'margin: -1px 0 0 !important;' + 190 '}' + 191 'body#wpview-iframe-sandbox:before,' + 192 'body#wpview-iframe-sandbox:after {' + 193 'display: none;' + 194 'content: "";' + 169 195 '}' + 170 196 '</style>' + 171 197 '</head>' + 172 '<body id="wpview-iframe-sandbox" >' +173 html+198 '<body id="wpview-iframe-sandbox" class="' + bodyClasses + '">' + 199 body + 174 200 '</body>' + 175 201 '</html>' 176 202 ); … … 195 221 setTimeout( resize, i * 700 ); 196 222 } 197 223 } 224 225 if ( importStyles ) { 226 editor.on( 'wp-body-class-change', function() { 227 iframeDoc.body.className = editor.getBody().className; 228 }); 229 } 198 230 }, 50 ); 199 231 }); 200 232 } else { 201 this.setContent( html);233 this.setContent( body ); 202 234 } 203 235 }, 204 236 setError: function( message, dashicon ) { … … 560 592 561 593 setNodes: function () { 562 594 if ( this.parsed ) { 563 this.setIframes( this.parsed );595 this.setIframes( this.parsed.head, this.parsed.body ); 564 596 } else { 565 597 this.fail(); 566 598 } … … 579 611 .done( function( response ) { 580 612 if ( response ) { 581 613 self.parsed = response; 582 self.setIframes( response );614 self.setIframes( response.head, response.body ); 583 615 } else { 584 616 self.fail( true ); 585 617 } -
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 8 1 .mejs-container { 9 2 clear: both; 10 3 } … … 278 271 279 272 .wp-audio-playlist .me-cannotplay span { 280 273 padding: 5px 15px; 281 } 282 No newline at end of file 274 } -
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
260 260 261 261 editor.on( 'init', function() { 262 262 var scrolled = false, 263 selection = editor.selection; 263 selection = editor.selection, 264 MutationObserver = window.MutationObserver || window.WebKitMutationObserver; 264 265 265 266 // When a view is selected, ensure content that is being pasted 266 267 // or inserted is added to a text node (instead of the view). … … 333 334 scrolled = false; 334 335 } 335 336 }, 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 } 336 347 }); 337 348 338 349 editor.on( 'PreProcess', function( event ) { -
src/wp-includes/media.php
3310 3310 */ 3311 3311 function wpview_media_sandbox_styles() { 3312 3312 $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" );3315 3313 $mediaelement = includes_url( "js/mediaelement/mediaelementplayer.min.css?$version" ); 3316 3314 $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" ); 3317 3315 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 ); 3328 3317 }