TinyMCE wpView: resize sandbox iframes on load. Fixes a problem with resizing after all images are loaded.

Props iseulde, mattheu. Fixes #31480.

git-svn-id: https://develop.svn.wordpress.org/trunk@32056 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2015-04-06 18:54:22 +00:00
parent 2f368bf396
commit e28afd4f46
1 changed files with 5 additions and 2 deletions

View File

@ -489,8 +489,7 @@ window.wp = window.wp || {};
var dom = editor.dom,
styles = '',
bodyClasses = editor.getBody().className || '',
editorHead = editor.getDoc().getElementsByTagName( 'head' )[0],
iframe, iframeDoc, observer, i;
editorHead = editor.getDoc().getElementsByTagName( 'head' )[0];
tinymce.each( dom.$( 'link[rel="stylesheet"]', editorHead ), function( link ) {
if ( link.href && link.href.indexOf( 'skins/lightgray/content.min.css' ) === -1 &&
@ -503,6 +502,8 @@ window.wp = window.wp || {};
// Seems the browsers need a bit of time to insert/set the view nodes,
// or the iframe will fail especially when switching Text => Visual.
setTimeout( function() {
var iframe, iframeDoc, observer, i;
content.innerHTML = '';
iframe = dom.add( content, 'iframe', {
@ -572,6 +573,8 @@ window.wp = window.wp || {};
}
}
$( iframe.contentWindow ).on( 'load', resize );
if ( MutationObserver ) {
observer = new MutationObserver( _.debounce( resize, 100 ) );