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 678f6de + 4625231 commit 2cdf02f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class Delete extends Plugin {
this.listenTo( editingView, 'delete', ( evt, data ) => {
editor.execute( data.direction == 'forward' ? 'forwardDelete' : 'delete', { unit: data.unit } );
data.preventDefault();
editingView.scrollToTheSelection();
} );
}
}
13 changes: 13 additions & 0 deletions tests/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ describe( 'Delete feature', () => {
expect( spy.calledWithMatch( 'delete', { unit: 'character' } ) ).to.be.true;
} );

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

editingView.fire( 'delete', new DomEventData( editingView, getDomEvent(), {
direction: 'backward',
unit: 'character'
} ) );

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

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

0 comments on commit 2cdf02f

Please sign in to comment.