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 9f359ec + 4e1f5f6 commit 09dc740
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/blockquote.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default class BlockQuote extends Plugin {

if ( doc.selection.isCollapsed && positionParent.isEmpty && command.value ) {
this.editor.execute( 'blockQuote' );
this.editor.editing.view.scrollToTheSelection();

data.preventDefault();
evt.stop();
Expand Down
17 changes: 17 additions & 0 deletions tests/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,23 @@ describe( 'BlockQuote', () => {
'<paragraph>x</paragraph>'
);
} );

it( 'scrolls the view document to the selection after the command is executed', () => {
const data = fakeEventData();
const execSpy = sinon.spy( editor, 'execute' );
const scrollSpy = sinon.stub( editor.editing.view, 'scrollToTheSelection' );

setModelData( doc,
'<paragraph>x</paragraph>' +
'<blockQuote><paragraph>a</paragraph><paragraph>[]</paragraph></blockQuote>' +
'<paragraph>x</paragraph>'
);

editor.editing.view.fire( 'enter', data );

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

describe( 'backspace key support', () => {
Expand Down

0 comments on commit 09dc740

Please sign in to comment.