Editor scrolling:

- Improve TinyMCE resizing when a floated block is at the end of the content.
- Improve setting the padding/margin under the toolbar on loading.
- Add custom event on TinyMCE resizing and use it to adjust the pinning (if needed).
Part props avryl, see #28328.
Built from https://develop.svn.wordpress.org/trunk@29279


git-svn-id: http://core.svn.wordpress.org/trunk@29061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz
2014-07-24 01:33:15 +00:00
parent 795c97d08b
commit da0b98a8f0
10 changed files with 142 additions and 96 deletions

View File

@@ -42,6 +42,7 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
return;
}
e = e || {};
body = doc.body;
docElm = doc.documentElement;
resizeHeight = settings.autoresize_min_height;
@@ -60,6 +61,11 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
marginBottom = editor.dom.getStyle( body, 'margin-bottom', true );
myHeight = body.offsetHeight + parseInt( marginTop, 10 ) + parseInt( marginBottom, 10 );
// IE < 11, other?
if ( myHeight && myHeight < docElm.offsetHeight ) {
myHeight = docElm.offsetHeight;
}
// Make sure we have a valid height
if ( isNaN( myHeight ) || myHeight <= 0 ) {
// Get height differently depending on the browser used
@@ -93,6 +99,8 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
if ( tinymce.isWebKit && deltaSize < 0 ) {
resize( e );
}
editor.fire( 'wp-autoresize', { height: resizeHeight } );
}
}
@@ -102,7 +110,7 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
*/
function wait( times, interval, callback ) {
setTimeout( function() {
resize({});
resize();
if ( times-- ) {
wait( times, interval, callback );
@@ -123,14 +131,20 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
// Add appropriate listeners for resizing the content area
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
resize();
}
}
function off() {
var doc;
// Don't turn off if the setting is 'on'
if ( ! settings.wp_autoresize_on ) {
doc = editor.getDoc();
editor.dom.removeClass( editor.getBody(), 'wp-autoresize' );
editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize );
doc.body.style.overflowY = 'auto';
doc.documentElement.style.overflowY = 'auto'; // Old IE
oldSize = 0;
}
}
@@ -158,6 +172,11 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
}
}
// Reset the stored size
editor.on( 'show', function() {
oldSize = 0;
});
// Register the command
editor.addCommand( 'wpAutoResize', resize );

View File

@@ -1 +1 @@
tinymce.PluginManager.add("wpautoresize",function(a){function b(){return a.plugins.fullscreen&&a.plugins.fullscreen.isFullscreen()}function c(d){var e,f,i,j,k,l,m,n,o=tinymce.DOM;if(f=a.getDoc()){if(i=f.body,j=f.documentElement,k=g.autoresize_min_height,!i||d&&"setcontent"===d.type&&d.initial||b())return void(i&&j&&(i.style.overflowY="auto",j.style.overflowY="auto"));m=a.dom.getStyle(i,"margin-top",!0),n=a.dom.getStyle(i,"margin-bottom",!0),l=i.offsetHeight+parseInt(m,10)+parseInt(n,10),(isNaN(l)||0>=l)&&(l=tinymce.Env.ie?i.scrollHeight:tinymce.Env.webkit&&0===i.clientHeight?0:i.offsetHeight),l>g.autoresize_min_height&&(k=l),g.autoresize_max_height&&l>g.autoresize_max_height?(k=g.autoresize_max_height,i.style.overflowY="auto",j.style.overflowY="auto"):(i.style.overflowY="hidden",j.style.overflowY="hidden",i.scrollTop=0),k!==h&&(e=k-h,o.setStyle(o.get(a.id+"_ifr"),"height",k+"px"),h=k,tinymce.isWebKit&&0>e&&c(d))}}function d(a,b,e){setTimeout(function(){c({}),a--?d(a,b,e):e&&e()},b)}function e(){a.dom.hasClass(a.getBody(),"wp-autoresize")||(a.dom.addClass(a.getBody(),"wp-autoresize"),a.on("nodechange setcontent keyup FullscreenStateChanged",c))}function f(){g.wp_autoresize_on||(a.dom.removeClass(a.getBody(),"wp-autoresize"),a.off("nodechange setcontent keyup FullscreenStateChanged",c),h=0)}var g=a.settings,h=0;a.settings.inline||(g.autoresize_min_height=parseInt(a.getParam("autoresize_min_height",a.getElement().offsetHeight),10),g.autoresize_max_height=parseInt(a.getParam("autoresize_max_height",0),10),g.wp_autoresize_on&&(a.on("init",function(){a.dom.addClass(a.getBody(),"wp-autoresize")}),a.on("nodechange keyup FullscreenStateChanged",c),a.on("setcontent",function(){d(3,100)}),a.getParam("autoresize_on_init",!0)&&a.on("init",function(){d(10,200,function(){d(5,1e3)})})),a.addCommand("wpAutoResize",c),a.addCommand("wpAutoResizeOn",e),a.addCommand("wpAutoResizeOff",f))});
tinymce.PluginManager.add("wpautoresize",function(a){function b(){return a.plugins.fullscreen&&a.plugins.fullscreen.isFullscreen()}function c(d){var e,f,i,j,k,l,m,n,o=tinymce.DOM;if(f=a.getDoc()){if(d=d||{},i=f.body,j=f.documentElement,k=g.autoresize_min_height,!i||d&&"setcontent"===d.type&&d.initial||b())return void(i&&j&&(i.style.overflowY="auto",j.style.overflowY="auto"));m=a.dom.getStyle(i,"margin-top",!0),n=a.dom.getStyle(i,"margin-bottom",!0),l=i.offsetHeight+parseInt(m,10)+parseInt(n,10),l&&l<j.offsetHeight&&(l=j.offsetHeight),(isNaN(l)||0>=l)&&(l=tinymce.Env.ie?i.scrollHeight:tinymce.Env.webkit&&0===i.clientHeight?0:i.offsetHeight),l>g.autoresize_min_height&&(k=l),g.autoresize_max_height&&l>g.autoresize_max_height?(k=g.autoresize_max_height,i.style.overflowY="auto",j.style.overflowY="auto"):(i.style.overflowY="hidden",j.style.overflowY="hidden",i.scrollTop=0),k!==h&&(e=k-h,o.setStyle(o.get(a.id+"_ifr"),"height",k+"px"),h=k,tinymce.isWebKit&&0>e&&c(d),a.fire("wp-autoresize",{height:k}))}}function d(a,b,e){setTimeout(function(){c(),a--?d(a,b,e):e&&e()},b)}function e(){a.dom.hasClass(a.getBody(),"wp-autoresize")||(a.dom.addClass(a.getBody(),"wp-autoresize"),a.on("nodechange setcontent keyup FullscreenStateChanged",c),c())}function f(){var b;g.wp_autoresize_on||(b=a.getDoc(),a.dom.removeClass(a.getBody(),"wp-autoresize"),a.off("nodechange setcontent keyup FullscreenStateChanged",c),b.body.style.overflowY="auto",b.documentElement.style.overflowY="auto",h=0)}var g=a.settings,h=0;a.settings.inline||(g.autoresize_min_height=parseInt(a.getParam("autoresize_min_height",a.getElement().offsetHeight),10),g.autoresize_max_height=parseInt(a.getParam("autoresize_max_height",0),10),g.wp_autoresize_on&&(a.on("init",function(){a.dom.addClass(a.getBody(),"wp-autoresize")}),a.on("nodechange keyup FullscreenStateChanged",c),a.on("setcontent",function(){d(3,100)}),a.getParam("autoresize_on_init",!0)&&a.on("init",function(){d(10,200,function(){d(5,1e3)})})),a.on("show",function(){h=0}),a.addCommand("wpAutoResize",c),a.addCommand("wpAutoResizeOn",e),a.addCommand("wpAutoResizeOff",f))});

View File

@@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.0-beta2-20140723';
$wp_version = '4.0-beta2-20140724';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.