diff --git a/source/Editor.js b/source/Editor.js index dfb9b87..339a0e5 100644 --- a/source/Editor.js +++ b/source/Editor.js @@ -295,7 +295,7 @@ undoStack, // = [], undoStackLength, // = 0, isInUndoState, // = false, - docWasChanged = function docWasChanged () { + docWasChanged = function () { if ( isInUndoState ) { isInUndoState = false; fireEvent( 'undoStateChange', { @@ -1253,6 +1253,16 @@ setSelection( createRange( nodeAfterSplit, 0 ) ); 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 docWasChanged(); },