TinyMCE: improve setting of the sandboxing iframe inside a view.
Props mattheu, iseulde. Fixes #31412. Built from https://develop.svn.wordpress.org/trunk@31740 git-svn-id: http://core.svn.wordpress.org/trunk@31721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1581ca7092
commit
b5f1514b54
wp-includes
|
@ -433,9 +433,9 @@ window.wp = window.wp || {};
|
||||||
*/
|
*/
|
||||||
setContent: function( content, callback, rendered ) {
|
setContent: function( content, callback, rendered ) {
|
||||||
if ( _.isObject( content ) && content.body.indexOf( '<script' ) !== -1 ) {
|
if ( _.isObject( content ) && content.body.indexOf( '<script' ) !== -1 ) {
|
||||||
this.setIframes( content.head, content.body, callback, rendered );
|
this.setIframes( content.head || '', content.body, callback, rendered );
|
||||||
} else if ( _.isString( content ) && content.indexOf( '<script' ) !== -1 ) {
|
} else if ( _.isString( content ) && content.indexOf( '<script' ) !== -1 ) {
|
||||||
this.setIframes( null, content, callback, rendered );
|
this.setIframes( '', content, callback, rendered );
|
||||||
} else {
|
} else {
|
||||||
this.getNodes( function( editor, node, contentNode ) {
|
this.getNodes( function( editor, node, contentNode ) {
|
||||||
content = content.body || content;
|
content = content.body || content;
|
||||||
|
@ -465,33 +465,32 @@ window.wp = window.wp || {};
|
||||||
importStyles = this.type === 'video' || this.type === 'audio' || this.type === 'playlist';
|
importStyles = this.type === 'video' || this.type === 'audio' || this.type === 'playlist';
|
||||||
|
|
||||||
this.getNodes( function( editor, node, content ) {
|
this.getNodes( function( editor, node, content ) {
|
||||||
var dom = editor.dom,
|
|
||||||
styles = '',
|
|
||||||
bodyClasses = editor.getBody().className || '',
|
|
||||||
iframe, iframeDoc, observer, i;
|
|
||||||
|
|
||||||
content.innerHTML = '';
|
|
||||||
head = head || '';
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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,
|
||||||
// or the iframe will fail especially when switching Text => Visual.
|
// or the iframe will fail especially when switching Text => Visual.
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
|
var dom = editor.dom,
|
||||||
|
styles = '',
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
content.innerHTML = '';
|
||||||
|
|
||||||
iframe = dom.add( content, 'iframe', {
|
iframe = dom.add( content, 'iframe', {
|
||||||
/* jshint scripturl: true */
|
/* jshint scripturl: true */
|
||||||
src: tinymce.Env.ie ? 'javascript:""' : '',
|
src: tinymce.Env.ie ? 'javascript:""' : '',
|
||||||
|
@ -588,9 +587,9 @@ window.wp = window.wp || {};
|
||||||
editor.off( 'wp-body-class-change', classChange );
|
editor.off( 'wp-body-class-change', classChange );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}, 50 );
|
|
||||||
|
|
||||||
callback && callback.apply( this, arguments );
|
callback && callback.apply( this, arguments );
|
||||||
|
}, 50 );
|
||||||
}, rendered );
|
}, rendered );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-alpha-31739';
|
$wp_version = '4.2-alpha-31740';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
|
Loading…
Reference in New Issue