浏览代码

Aligned the view Document to the latest utils/dom/scroll module API.

Aleksander Nowodzinski 8 年之前
父节点
当前提交
3e733de7ea

+ 2 - 2
packages/ckeditor5-engine/src/view/document.js

@@ -20,7 +20,7 @@ import KeyObserver from './observer/keyobserver';
 import FakeSelectionObserver from './observer/fakeselectionobserver';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
-import scrollUtils from '@ckeditor/ckeditor5-utils/src/dom/scroll';
+import { scrollViewportToShowTarget } from '@ckeditor/ckeditor5-utils/src/dom/scroll';
 
 /**
  * Document class creates an abstract layer over the content editable area.
@@ -308,7 +308,7 @@ export default class Document {
 		const range = this.selection.getFirstRange();
 
 		if ( range ) {
-			scrollUtils.scrollViewportToShowTarget( {
+			scrollViewportToShowTarget( {
 				target: this.domConverter.viewRangeToDom( range ),
 				viewportOffset: 20
 			} );

+ 4 - 7
packages/ckeditor5-engine/tests/view/document/document.js

@@ -19,7 +19,7 @@ import DomConverter from '../../../src/view/domconverter';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import count from '@ckeditor/ckeditor5-utils/src/count';
 import log from '@ckeditor/ckeditor5-utils/src/log';
-import scrollUtils from '@ckeditor/ckeditor5-utils/src/dom/scroll';
+import global from '@ckeditor/ckeditor5-utils/src/dom/global';
 
 testUtils.createSinonSandbox();
 
@@ -326,24 +326,21 @@ describe( 'Document', () => {
 
 	describe( 'scrollToTheSelection()', () => {
 		it( 'does nothing when there are no ranges in the selection', () => {
-			const stub = testUtils.sinon.stub( scrollUtils, 'scrollViewportToShowTarget' );
+			const stub = testUtils.sinon.stub( global.window, 'scrollTo' );
 
 			viewDocument.scrollToTheSelection();
 			sinon.assert.notCalled( stub );
 		} );
 
 		it( 'scrolls to the first range in selection with an offset', () => {
-			const stub = testUtils.sinon.stub( scrollUtils, 'scrollViewportToShowTarget' );
+			const stub = testUtils.sinon.stub( global.window, 'scrollTo' );
 			const root = viewDocument.createRoot( document.createElement( 'div' ) );
 			const range = ViewRange.createIn( root );
 
 			viewDocument.selection.addRange( range );
 
 			viewDocument.scrollToTheSelection();
-			sinon.assert.calledWithMatch( stub, {
-				target: viewDocument.domConverter.viewRangeToDom( range ),
-				viewportOffset: 20
-			} );
+			sinon.assert.calledWithMatch( stub, sinon.match.number, sinon.match.number );
 		} );
 	} );