Ticket #31464: 31464.patch
| File 31464.patch, 3.1 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/js/mce-view.js
28 28 'use strict'; 29 29 30 30 var views = {}, 31 instances = {}; 31 instances = {}, 32 cache; 32 33 33 34 wp.mce = wp.mce || {}; 34 35 … … 434 435 if ( _.isObject( content ) && content.body.indexOf( '<script' ) !== -1 ) { 435 436 this.setIframes( content.head, content.body, callback, rendered ); 436 437 } else if ( _.isString( content ) && content.indexOf( '<script' ) !== -1 ) { 437 this.setIframes( null, content, callback, rendered );438 this.setIframes( '', content, callback, rendered ); 438 439 } else { 439 440 this.getNodes( function( editor, node, contentNode ) { 440 441 content = content.body || content; … … 460 461 * @param {Boolean} rendered Only set for (un)rendered nodes. Optional. 461 462 */ 462 463 setIframes: function( head, body, callback, rendered ) { 463 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, 464 importStyles = this.type === 'video' || this.type === 'audio' || this.type === 'playlist'; 464 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 465 465 466 466 this.getNodes( function( editor, node, content ) { 467 467 var dom = editor.dom, 468 styles = '',469 468 bodyClasses = editor.getBody().className || '', 470 469 iframe, iframeDoc, observer, i, resize; 471 470 472 471 content.innerHTML = ''; 473 head = head || '';474 472 475 if ( importStyles ) { 476 if ( ! wp.mce.views.sandboxStyles ) { 477 tinymce.each( dom.$( 'link[rel="stylesheet"]', editor.getDoc().head ), function( link ) { 478 if ( link.href && link.href.indexOf( 'skins/lightgray/content.min.css' ) === -1 && 479 link.href.indexOf( 'skins/wordpress/wp-content.css' ) === -1 ) { 480 481 styles += dom.getOuterHTML( link ) + '\n'; 482 } 483 }); 484 485 wp.mce.views.sandboxStyles = styles; 486 } else { 487 styles = wp.mce.views.sandboxStyles; 488 } 473 if ( ! cache.sandboxStyles ) { 474 tinymce.each( dom.$( 475 'link[rel="stylesheet"]', 476 editor.getDoc().getElementsByTagName( 'head' )[0] 477 ), function( link ) { 478 if ( 479 link.href && 480 link.href.indexOf( 'skins/lightgray/content.min.css' ) === -1 && 481 link.href.indexOf( 'skins/wordpress/wp-content.css' ) === -1 482 ) { 483 cache.sandboxStyles += dom.getOuterHTML( link ) + '\n'; 484 } 485 } ); 489 486 } 490 487 491 488 // Seems Firefox needs a bit of time to insert/set the view nodes, … … 516 513 '<head>' + 517 514 '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' + 518 515 head + 519 styles +516 cache.sandboxStyles + 520 517 '<style>' + 521 518 'html {' + 522 519 'background: transparent;' + … … 578 575 iframeDoc.body.className = editor.getBody().className; 579 576 } 580 577 581 if ( importStyles ) { 582 editor.on( 'wp-body-class-change', classChange ); 583 } 578 editor.on( 'wp-body-class-change', classChange ); 584 579 585 580 $( node ).one( 'wp-mce-view-unbind', function() { 586 581 observer.disconnect();