Editor: Improve scrolling behavior and prevent autosave logic from causing dirty state when just switching between Visual and Text tabs.
Props pento. See #41962, #42029. Fixes #42530 for trunk. Built from https://develop.svn.wordpress.org/trunk@42183 git-svn-id: http://core.svn.wordpress.org/trunk@42013 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6c64136035
commit
9986ebdc0b
|
@ -581,6 +581,8 @@ window.wp = window.wp || {};
|
|||
|
||||
removeSelectionMarker( startNode );
|
||||
removeSelectionMarker( endNode );
|
||||
|
||||
editor.save();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -623,7 +625,9 @@ window.wp = window.wp || {};
|
|||
|
||||
edTools = $( '#wp-content-editor-tools' ),
|
||||
edToolsHeight = 0,
|
||||
edToolsOffsetTop = 0;
|
||||
edToolsOffsetTop = 0,
|
||||
|
||||
$scrollArea;
|
||||
|
||||
if ( edTools.length ) {
|
||||
edToolsHeight = edTools.height();
|
||||
|
@ -648,9 +652,16 @@ window.wp = window.wp || {};
|
|||
* subtracting the height. This gives the scroll position where the top of the editor tools aligns with
|
||||
* the top of the viewport (under the Master Bar)
|
||||
*/
|
||||
var adjustedScroll = Math.max( selectionPosition - visibleAreaHeight / 2, edToolsOffsetTop - edToolsHeight );
|
||||
var adjustedScroll;
|
||||
if ( editor.settings.wp_autoresize_on ) {
|
||||
$scrollArea = $( 'html,body' );
|
||||
adjustedScroll = Math.max( selectionPosition - visibleAreaHeight / 2, edToolsOffsetTop - edToolsHeight );
|
||||
} else {
|
||||
$scrollArea = $( editor.contentDocument ).find( 'html,body' );
|
||||
adjustedScroll = elementTop;
|
||||
}
|
||||
|
||||
$( 'html,body' ).animate( {
|
||||
$scrollArea.animate( {
|
||||
scrollTop: parseInt( adjustedScroll, 10 )
|
||||
}, 100 );
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-42181';
|
||||
$wp_version = '5.0-alpha-42183';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue