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

Props iseulde, mattheu. Fixes #31464.
Built from https://develop.svn.wordpress.org/trunk@31742


git-svn-id: http://core.svn.wordpress.org/trunk@31723 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-03-12 01:05:54 +00:00
parent 9f6cd01346
commit 04494a6c32
3 changed files with 18 additions and 24 deletions

View File

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

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.2-alpha-31741'; $wp_version = '4.2-alpha-31742';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.