Ver código fonte

Merge branch t/ckedtor5-engine/660 to master

Feature: Viewport will be scrolled to the selection upon user input. See ckeditor/ckeditor5-engine#660.
Piotrek Koszuliński 8 anos atrás
pai
commit
8a5aaca465

+ 1 - 0
packages/ckeditor5-block-quote/src/blockquote.js

@@ -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();

+ 17 - 0
packages/ckeditor5-block-quote/tests/integration.js

@@ -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', () => {