浏览代码

Scroll the view document to the selection on enter if the BlockQuote feature handles the keystroke.

Aleksander Nowodzinski 8 年之前
父节点
当前提交
e6a8ec0826
共有 2 个文件被更改,包括 18 次插入0 次删除
  1. 1 0
      packages/ckeditor5-block-quote/src/blockquote.js
  2. 17 0
      packages/ckeditor5-block-quote/tests/integration.js

+ 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

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