TinyMCE: improve setting of the sandboxing iframe inside a view.

Props mattheu, iseulde. Fixes #31412.

git-svn-id: https://develop.svn.wordpress.org/trunk@31740 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2015-03-11 23:52:15 +00:00
parent 2707b39c63
commit 484733be3a
1 changed files with 27 additions and 28 deletions

View File

@ -433,9 +433,9 @@ window.wp = window.wp || {};
*/
setContent: function( content, callback, rendered ) {
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 ) {
this.setIframes( null, content, callback, rendered );
this.setIframes( '', content, callback, rendered );
} else {
this.getNodes( function( editor, node, contentNode ) {
content = content.body || content;
@ -465,14 +465,14 @@ window.wp = window.wp || {};
importStyles = this.type === 'video' || this.type === 'audio' || this.type === 'playlist';
this.getNodes( function( editor, node, content ) {
// Seems Firefox needs a bit of time to insert/set the view nodes,
// or the iframe will fail especially when switching Text => Visual.
setTimeout( function() {
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 ) {
@ -489,9 +489,8 @@ window.wp = window.wp || {};
}
}
// Seems Firefox needs a bit of time to insert/set the view nodes,
// or the iframe will fail especially when switching Text => Visual.
setTimeout( function() {
content.innerHTML = '';
iframe = dom.add( content, 'iframe', {
/* jshint scripturl: true */
src: tinymce.Env.ie ? 'javascript:""' : '',
@ -588,9 +587,9 @@ window.wp = window.wp || {};
editor.off( 'wp-body-class-change', classChange );
} );
}
}, 50 );
callback && callback.apply( this, arguments );
}, 50 );
}, rendered );
},