TinyMCE: wpviews: cache iframe heights
Cache iframe heights per instance so it can be reused. This will prevent to content from moving in the editor when undoing or redoing changes. Fixes #32593. Built from https://develop.svn.wordpress.org/trunk@32711 git-svn-id: http://core.svn.wordpress.org/trunk@32681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e9ac7f5164
commit
00e4f35300
|
@ -501,10 +501,17 @@ window.wp = window.wp || {};
|
|||
}
|
||||
} );
|
||||
|
||||
if ( self.iframeHeight ) {
|
||||
dom.add( contentNode, 'div', { style: {
|
||||
width: '100%',
|
||||
height: self.iframeHeight
|
||||
} } );
|
||||
}
|
||||
|
||||
// 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;
|
||||
var iframe, iframeDoc, observer, i, block;
|
||||
|
||||
contentNode.innerHTML = '';
|
||||
|
||||
|
@ -518,7 +525,8 @@ window.wp = window.wp || {};
|
|||
style: {
|
||||
width: '100%',
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
height: self.iframeHeight
|
||||
} );
|
||||
|
||||
dom.add( contentNode, 'div', { 'class': 'wpview-overlay' } );
|
||||
|
@ -561,20 +569,33 @@ window.wp = window.wp || {};
|
|||
iframeDoc.close();
|
||||
|
||||
function resize() {
|
||||
var $iframe, iframeDocHeight;
|
||||
var $iframe;
|
||||
|
||||
if ( block ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the iframe still exists.
|
||||
if ( iframe.contentWindow ) {
|
||||
$iframe = $( iframe );
|
||||
iframeDocHeight = $( iframeDoc.body ).height();
|
||||
self.iframeHeight = $( iframeDoc.body ).height();
|
||||
|
||||
if ( $iframe.height() !== iframeDocHeight ) {
|
||||
$iframe.height( iframeDocHeight );
|
||||
if ( $iframe.height() !== self.iframeHeight ) {
|
||||
$iframe.height( self.iframeHeight );
|
||||
editor.nodeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( self.iframeHeight ) {
|
||||
block = true;
|
||||
|
||||
setTimeout( function() {
|
||||
block = false;
|
||||
resize();
|
||||
}, 3000 );
|
||||
}
|
||||
|
||||
$( iframe.contentWindow ).on( 'load', resize );
|
||||
|
||||
if ( MutationObserver ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.3-alpha-32710';
|
||||
$wp_version = '4.3-alpha-32711';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue