0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 23:40:35 -05:00

Scroll cursor into view on enter.

This commit is contained in:
Neil Jenkins 2011-12-09 13:15:15 +11:00
parent ffe8d95cc1
commit 14ee0d0ad5

View file

@ -295,7 +295,7 @@
undoStack, // = [], undoStack, // = [],
undoStackLength, // = 0, undoStackLength, // = 0,
isInUndoState, // = false, isInUndoState, // = false,
docWasChanged = function docWasChanged () { docWasChanged = function () {
if ( isInUndoState ) { if ( isInUndoState ) {
isInUndoState = false; isInUndoState = false;
fireEvent( 'undoStateChange', { fireEvent( 'undoStateChange', {
@ -1253,6 +1253,16 @@
setSelection( createRange( nodeAfterSplit, 0 ) ); setSelection( createRange( nodeAfterSplit, 0 ) );
updatePath( 0, true ); updatePath( 0, true );
// Scroll into view
if ( nodeAfterSplit.nodeType === TEXT_NODE ) {
nodeAfterSplit = nodeAfterSplit.parentNode;
}
if ( nodeAfterSplit.offsetTop + nodeAfterSplit.offsetHeight >
( doc.documentElement.scrollTop || body.scrollTop ) +
body.offsetHeight ) {
nodeAfterSplit.scrollIntoView( false );
}
// We're not still in an undo state // We're not still in an undo state
docWasChanged(); docWasChanged();
}, },