Ver código fonte

Scroll the editing document to the selection after the DeleteCommand is executed.

Aleksander Nowodzinski 8 anos atrás
pai
commit
b7ef47701c

+ 1 - 0
packages/ckeditor5-typing/src/delete.js

@@ -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 - 0
packages/ckeditor5-typing/tests/delete.js

@@ -51,6 +51,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()