Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge branch t/ckedtor5-engine/660 to master
Browse files Browse the repository at this point in the history
Feature: Viewport will be scrolled to the selection upon user input. See ckeditor/ckeditor5-engine#660.
  • Loading branch information
Reinmar committed Aug 15, 2017
2 parents 755c774 + a792518 commit 17f815e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/enter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class Enter extends Plugin {
this.listenTo( editingView, 'enter', ( evt, data ) => {
editor.execute( 'enter' );
data.preventDefault();
editingView.scrollToTheSelection();
}, { priority: 'low' } );
}
}
12 changes: 12 additions & 0 deletions tests/enter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ describe( 'Enter feature', () => {
expect( domEvt.preventDefault.calledOnce ).to.be.true;
} );

it( 'scrolls the editing document to the selection after executing the command', () => {
const view = editor.editing.view;
const domEvt = getDomEvent();
const executeSpy = editor.execute = sinon.spy();
const scrollSpy = sinon.stub( view, 'scrollToTheSelection' );

view.fire( 'enter', new DomEventData( editingView, domEvt ) );

sinon.assert.calledOnce( scrollSpy );
sinon.assert.callOrder( executeSpy, scrollSpy );
} );

function getDomEvent() {
return {
preventDefault: sinon.spy()
Expand Down

0 comments on commit 17f815e

Please sign in to comment.