TinyMCE wpViews: always import the non-default editor styles in the sandbox iframe in views.

Props iseulde, mattheu. Fixes #31464.

git-svn-id: https://develop.svn.wordpress.org/trunk@31742 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2015-03-12 01:04:59 +00:00
parent 8220541799
commit 1c425c9eac
1 changed files with 16 additions and 22 deletions

View File

@ -461,8 +461,7 @@ window.wp = window.wp || {};
* @param {Boolean} rendered Only set for (un)rendered nodes. Optional.
*/
setIframes: function( head, body, callback, rendered ) {
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
importStyles = this.type === 'video' || this.type === 'audio' || this.type === 'playlist';
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
this.getNodes( function( editor, node, content ) {
// Seems Firefox needs a bit of time to insert/set the view nodes,
@ -473,21 +472,18 @@ window.wp = window.wp || {};
bodyClasses = editor.getBody().className || '',
iframe, iframeDoc, observer, i;
if ( importStyles ) {
if ( ! wp.mce.views.sandboxStyles ) {
tinymce.each( dom.$( 'link[rel="stylesheet"]', editor.getDoc().head ), function( link ) {
if ( link.href && link.href.indexOf( 'skins/lightgray/content.min.css' ) === -1 &&
link.href.indexOf( 'skins/wordpress/wp-content.css' ) === -1 ) {
styles += dom.getOuterHTML( link ) + '\n';
}
});
wp.mce.views.sandboxStyles = styles;
} else {
styles = wp.mce.views.sandboxStyles;
tinymce.each( dom.$(
'link[rel="stylesheet"]',
editor.getDoc().getElementsByTagName( 'head' )[0]
), function( link ) {
if (
link.href &&
link.href.indexOf( 'skins/lightgray/content.min.css' ) >= 0 &&
link.href.indexOf( 'skins/wordpress/wp-content.css' ) >= 0
) {
styles += dom.getOuterHTML( link );
}
}
} );
content.innerHTML = '';
@ -580,13 +576,11 @@ window.wp = window.wp || {};
iframeDoc.body.className = editor.getBody().className;
}
if ( importStyles ) {
editor.on( 'wp-body-class-change', classChange );
editor.on( 'wp-body-class-change', classChange );
$( node ).one( 'wp-mce-view-unbind', function() {
editor.off( 'wp-body-class-change', classChange );
} );
}
$( node ).one( 'wp-mce-view-unbind', function() {
editor.off( 'wp-body-class-change', classChange );
} );
callback && callback.apply( this, arguments );
}, 50 );