8
0
Просмотр исходного кода

Adjusted to changes made in engine view.

Szymon Kupś 8 лет назад
Родитель
Сommit
abc55f2170

+ 4 - 3
packages/ckeditor5-typing/src/delete.js

@@ -26,9 +26,10 @@ export default class Delete extends Plugin {
 
 	init() {
 		const editor = this.editor;
-		const viewDocument = editor.editing.view.document;
+		const view = editor.editing.view;
+		const viewDocument = view.document;
 
-		viewDocument.addObserver( DeleteObserver );
+		view.addObserver( DeleteObserver );
 
 		editor.commands.add( 'forwardDelete', new DeleteCommand( editor, 'forward' ) );
 		editor.commands.add( 'delete', new DeleteCommand( editor, 'backward' ) );
@@ -36,7 +37,7 @@ export default class Delete extends Plugin {
 		this.listenTo( viewDocument, 'delete', ( evt, data ) => {
 			editor.execute( data.direction == 'forward' ? 'forwardDelete' : 'delete', { unit: data.unit, sequence: data.sequence } );
 			data.preventDefault();
-			viewDocument.scrollToTheSelection();
+			view.scrollToTheSelection();
 		} );
 	}
 }

+ 3 - 2
packages/ckeditor5-typing/src/deleteobserver.js

@@ -17,9 +17,10 @@ import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
  * @extends module:engine/view/observer/observer~Observer
  */
 export default class DeleteObserver extends Observer {
-	constructor( document ) {
-		super( document );
+	constructor( view ) {
+		super( view );
 
+		const document = view.document;
 		let sequence = 0;
 
 		document.on( 'keyup', ( evt, data ) => {

+ 2 - 2
packages/ckeditor5-typing/src/input.js

@@ -42,11 +42,11 @@ export default class Input extends Plugin {
 
 		editor.commands.add( 'input', inputCommand );
 
-		this.listenTo( editingView, 'keydown', ( evt, data ) => {
+		this.listenTo( editingView.document, 'keydown', ( evt, data ) => {
 			this._handleKeydown( data, inputCommand );
 		}, { priority: 'lowest' } );
 
-		this.listenTo( editingView, 'mutations', ( evt, mutations, viewSelection ) => {
+		this.listenTo( editingView.document, 'mutations', ( evt, mutations, viewSelection ) => {
 			this._handleMutations( mutations, viewSelection );
 		} );
 	}

+ 8 - 8
packages/ckeditor5-typing/tests/delete.js

@@ -8,14 +8,14 @@ import Delete from '../src/delete';
 import DomEventData from '@ckeditor/ckeditor5-engine/src/view/observer/domeventdata';
 
 describe( 'Delete feature', () => {
-	let editor, editingView;
+	let editor, viewDocument;
 
 	beforeEach( () => {
 		return VirtualTestEditor
 			.create( { plugins: [ Delete ] } )
 			.then( newEditor => {
 				editor = newEditor;
-				editingView = editor.editing.view;
+				viewDocument = editor.editing.view.document;
 			} );
 	} );
 
@@ -28,12 +28,12 @@ describe( 'Delete feature', () => {
 		expect( editor.commands.get( 'forwardDelete' ) ).to.have.property( 'direction', 'forward' );
 	} );
 
-	it( 'listens to the editing view delete event', () => {
+	it( 'listens to the editing view document delete event', () => {
 		const spy = editor.execute = sinon.spy();
-		const view = editor.editing.view;
+		const viewDocument = editor.editing.view.document;
 		const domEvt = getDomEvent();
 
-		view.fire( 'delete', new DomEventData( editingView, domEvt, {
+		viewDocument.fire( 'delete', new DomEventData( viewDocument, domEvt, {
 			direction: 'forward',
 			unit: 'character',
 			sequence: 1
@@ -44,7 +44,7 @@ describe( 'Delete feature', () => {
 
 		expect( domEvt.preventDefault.calledOnce ).to.be.true;
 
-		view.fire( 'delete', new DomEventData( editingView, getDomEvent(), {
+		viewDocument.fire( 'delete', new DomEventData( viewDocument, getDomEvent(), {
 			direction: 'backward',
 			unit: 'character',
 			sequence: 5
@@ -55,10 +55,10 @@ describe( 'Delete feature', () => {
 	} );
 
 	it( 'scrolls the editing document to the selection after executing the command', () => {
-		const scrollSpy = sinon.stub( editingView, 'scrollToTheSelection' );
+		const scrollSpy = sinon.stub( editor.editing.view, 'scrollToTheSelection' );
 		const executeSpy = editor.execute = sinon.spy();
 
-		editingView.fire( 'delete', new DomEventData( editingView, getDomEvent(), {
+		viewDocument.fire( 'delete', new DomEventData( viewDocument, getDomEvent(), {
 			direction: 'backward',
 			unit: 'character'
 		} ) );

+ 10 - 5
packages/ckeditor5-typing/tests/deleteobserver.js

@@ -6,24 +6,29 @@
 /* globals document */
 
 import DeleteObserver from '../src/deleteobserver';
-import ViewDocument from '@ckeditor/ckeditor5-engine/src/view/document';
+import View from '@ckeditor/ckeditor5-engine/src/view/view';
 import DomEventData from '@ckeditor/ckeditor5-engine/src/view/observer/domeventdata';
 import createViewRoot from '@ckeditor/ckeditor5-engine/tests/view/_utils/createroot';
 import { getCode } from '@ckeditor/ckeditor5-utils/src/keyboard';
 
 describe( 'DeleteObserver', () => {
-	let viewDocument;
+	let view, viewDocument;
 
 	beforeEach( () => {
-		viewDocument = new ViewDocument();
-		viewDocument.addObserver( DeleteObserver );
+		view = new View();
+		viewDocument = view.document;
+		view.addObserver( DeleteObserver );
+	} );
+
+	afterEach( () => {
+		view.destroy();
 	} );
 
 	// See ckeditor/ckeditor5-enter#10.
 	it( 'can be initialized', () => {
 		expect( () => {
 			createViewRoot( viewDocument );
-			viewDocument.attachDomRoot( document.createElement( 'div' ) );
+			view.attachDomRoot( document.createElement( 'div' ) );
 		} ).to.not.throw();
 	} );
 

+ 64 - 62
packages/ckeditor5-typing/tests/input.js

@@ -32,7 +32,7 @@ import { getData as getModelData, setData as setModelData } from '@ckeditor/cked
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
 describe( 'Input feature', () => {
-	let editor, model, modelRoot, view, viewRoot, listenter;
+	let editor, model, modelRoot, view, viewDocument, viewRoot, listenter;
 
 	testUtils.createSinonSandbox();
 
@@ -59,7 +59,8 @@ describe( 'Input feature', () => {
 				model = editor.model;
 				modelRoot = model.document.getRoot();
 				view = editor.editing.view;
-				viewRoot = view.getRoot();
+				viewDocument = view.document;
+				viewRoot = viewDocument.getRoot();
 			} );
 	} );
 
@@ -83,7 +84,7 @@ describe( 'Input feature', () => {
 
 	describe( 'mutations handling', () => {
 		it( 'should handle text mutation', () => {
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foobar',
@@ -97,7 +98,7 @@ describe( 'Input feature', () => {
 		} );
 
 		it( 'should handle text mutation change', () => {
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foobar',
@@ -113,7 +114,7 @@ describe( 'Input feature', () => {
 		it( 'should handle text node insertion', () => {
 			editor.setData( '<p></p>' );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [],
@@ -133,7 +134,7 @@ describe( 'Input feature', () => {
 					italic: true
 				}
 			} );
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [],
@@ -150,7 +151,7 @@ describe( 'Input feature', () => {
 		it( 'should handle multiple text mutations', () => {
 			editor.setData( '<p>foo<strong>bar</strong></p>' );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foo',
@@ -172,7 +173,7 @@ describe( 'Input feature', () => {
 		it( 'should handle multiple text node insertion', () => {
 			editor.setData( '<p></p><p></p>' );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [],
@@ -194,7 +195,7 @@ describe( 'Input feature', () => {
 		it( 'should do nothing when two nodes were inserted', () => {
 			editor.setData( '<p></p>' );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [],
@@ -208,7 +209,7 @@ describe( 'Input feature', () => {
 		} );
 
 		it( 'should do nothing when two nodes were inserted and one removed', () => {
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [ new ViewText( 'foobar' ) ],
@@ -224,7 +225,7 @@ describe( 'Input feature', () => {
 		it( 'should handle multiple children in the node', () => {
 			editor.setData( '<p>foo<img></img></p>' );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [ new ViewText( 'foo' ), viewRoot.getChild( 0 ).getChild( 1 ) ],
@@ -238,7 +239,7 @@ describe( 'Input feature', () => {
 		} );
 
 		it( 'should do nothing when node was removed', () => {
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [ new ViewText( 'foobar' ) ],
@@ -254,7 +255,7 @@ describe( 'Input feature', () => {
 		it( 'should do nothing when element was inserted', () => {
 			editor.setData( '<p></p>' );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [],
@@ -271,9 +272,9 @@ describe( 'Input feature', () => {
 			// This test case emulates spellchecker correction.
 
 			const viewSelection = new ViewSelection();
-			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 6 );
+			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 6 );
 
-			view.fire( 'mutations',
+			viewDocument.fire( 'mutations',
 				[ {
 					type: 'text',
 					oldText: 'foobar',
@@ -291,12 +292,12 @@ describe( 'Input feature', () => {
 			// This test case emulates spellchecker correction.
 
 			const viewSelection = new ViewSelection();
-			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 6 );
+			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 6 );
 
 			testUtils.sinon.spy( Writer.prototype, 'insert' );
 			testUtils.sinon.spy( Writer.prototype, 'remove' );
 
-			view.fire( 'mutations',
+			viewDocument.fire( 'mutations',
 				[ {
 					type: 'text',
 					oldText: 'foobar',
@@ -315,9 +316,9 @@ describe( 'Input feature', () => {
 			editor.setData( '<p>Foo hous a</p>' );
 
 			const viewSelection = new ViewSelection();
-			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
+			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
 
-			view.fire( 'mutations',
+			viewDocument.fire( 'mutations',
 				[ {
 					type: 'text',
 					oldText: 'Foo hous a',
@@ -336,9 +337,9 @@ describe( 'Input feature', () => {
 			editor.setData( '<p>Bar athat foo</p>' );
 
 			const viewSelection = new ViewSelection();
-			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 8 );
+			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 8 );
 
-			view.fire( 'mutations',
+			viewDocument.fire( 'mutations',
 				[ {
 					type: 'text',
 					oldText: 'Bar athat foo',
@@ -357,9 +358,9 @@ describe( 'Input feature', () => {
 			editor.setData( '<p>Foo hous e</p>' );
 
 			const viewSelection = new ViewSelection();
-			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
+			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
 
-			view.fire( 'mutations',
+			viewDocument.fire( 'mutations',
 				[ {
 					type: 'text',
 					oldText: 'Foo hous e',
@@ -377,10 +378,10 @@ describe( 'Input feature', () => {
 			editor.setData( '<p>Foo house</p>' );
 
 			const viewSelection = new ViewSelection();
-			viewSelection.setTo( viewRoot.getChild( 0 ).getChild( 0 ), 8 );
-			viewSelection.setFocus( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
+			viewSelection._setTo( viewRoot.getChild( 0 ).getChild( 0 ), 8 );
+			viewSelection._setFocus( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
 
-			view.fire( 'mutations',
+			viewDocument.fire( 'mutations',
 				[ {
 					type: 'text',
 					oldText: 'Foo house',
@@ -401,7 +402,7 @@ describe( 'Input feature', () => {
 				);
 			} );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foobar',
@@ -421,7 +422,7 @@ describe( 'Input feature', () => {
 				);
 			} );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foobar',
@@ -441,7 +442,7 @@ describe( 'Input feature', () => {
 				);
 			} );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foobar',
@@ -462,7 +463,7 @@ describe( 'Input feature', () => {
 					ModelRange.createFromParentsAndOffsets( modelRoot.getChild( 0 ), 2, modelRoot.getChild( 0 ), 4 ) );
 			} );
 
-			listenter.listenTo( view, 'keydown', () => {
+			listenter.listenTo( viewDocument, 'keydown', () => {
 				expect( getModelData( model ) ).to.equal( '<paragraph>fo[]ar</paragraph>' );
 			}, { priority: 'lowest' } );
 		} );
@@ -471,10 +472,10 @@ describe( 'Input feature', () => {
 		it( 'should remove contents and merge blocks', () => {
 			setModelData( model, '<paragraph>fo[o</paragraph><paragraph>b]ar</paragraph>' );
 
-			listenter.listenTo( view, 'keydown', () => {
+			listenter.listenTo( viewDocument, 'keydown', () => {
 				expect( getModelData( model ) ).to.equal( '<paragraph>fo[]ar</paragraph>' );
 
-				view.fire( 'mutations', [
+				viewDocument.fire( 'mutations', [
 					{
 						type: 'text',
 						oldText: 'foar',
@@ -484,7 +485,7 @@ describe( 'Input feature', () => {
 				] );
 			}, { priority: 'lowest' } );
 
-			view.fire( 'keydown', { keyCode: getCode( 'y' ) } );
+			viewDocument.fire( 'keydown', { keyCode: getCode( 'y' ) } );
 
 			expect( getModelData( model ) ).to.equal( '<paragraph>foy[]ar</paragraph>' );
 			expect( getViewData( view ) ).to.equal( '<p>foy{}ar</p>' );
@@ -496,7 +497,7 @@ describe( 'Input feature', () => {
 					ModelRange.createFromParentsAndOffsets( modelRoot.getChild( 0 ), 2, modelRoot.getChild( 0 ), 4 ) );
 			} );
 
-			view.fire( 'keydown', { keyCode: getCode( 'arrowdown' ) } );
+			viewDocument.fire( 'keydown', { keyCode: getCode( 'arrowdown' ) } );
 
 			expect( getModelData( model ) ).to.equal( '<paragraph>fo[ob]ar</paragraph>' );
 		} );
@@ -507,7 +508,7 @@ describe( 'Input feature', () => {
 					ModelRange.createFromParentsAndOffsets( modelRoot.getChild( 0 ), 2, modelRoot.getChild( 0 ), 4 ) );
 			} );
 
-			view.fire( 'keydown', { ctrlKey: true, keyCode: getCode( 'c' ) } );
+			viewDocument.fire( 'keydown', { ctrlKey: true, keyCode: getCode( 'c' ) } );
 
 			expect( getModelData( model ) ).to.equal( '<paragraph>fo[ob]ar</paragraph>' );
 		} );
@@ -518,9 +519,9 @@ describe( 'Input feature', () => {
 					ModelRange.createFromParentsAndOffsets( modelRoot.getChild( 0 ), 2, modelRoot.getChild( 0 ), 4 ) );
 			} );
 
-			view.fire( 'keydown', { keyCode: 16 } ); // Shift
-			view.fire( 'keydown', { keyCode: 35 } ); // Home
-			view.fire( 'keydown', { keyCode: 112 } ); // F1
+			viewDocument.fire( 'keydown', { keyCode: 16 } ); // Shift
+			viewDocument.fire( 'keydown', { keyCode: 35 } ); // Home
+			viewDocument.fire( 'keydown', { keyCode: 112 } ); // F1
 
 			expect( getModelData( model ) ).to.equal( '<paragraph>fo[ob]ar</paragraph>' );
 		} );
@@ -532,7 +533,7 @@ describe( 'Input feature', () => {
 					ModelRange.createFromParentsAndOffsets( modelRoot.getChild( 0 ), 2, modelRoot.getChild( 0 ), 4 ) );
 			} );
 
-			view.fire( 'keydown', { keyCode: 9 } ); // Tab
+			viewDocument.fire( 'keydown', { keyCode: 9 } ); // Tab
 
 			expect( getModelData( model ) ).to.equal( '<paragraph>fo[ob]ar</paragraph>' );
 		} );
@@ -544,13 +545,13 @@ describe( 'Input feature', () => {
 					ModelRange.createFromParentsAndOffsets( modelRoot.getChild( 0 ), 2, modelRoot.getChild( 0 ), 4 ) );
 			} );
 
-			view.fire( 'keydown', { keyCode: 229 } );
+			viewDocument.fire( 'keydown', { keyCode: 229 } );
 
 			expect( getModelData( model ) ).to.equal( '<paragraph>fo[ob]ar</paragraph>' );
 		} );
 
 		it( 'should do nothing if selection is collapsed', () => {
-			view.fire( 'keydown', { ctrlKey: true, keyCode: getCode( 'c' ) } );
+			viewDocument.fire( 'keydown', { ctrlKey: true, keyCode: getCode( 'c' ) } );
 
 			expect( getModelData( model ) ).to.equal( '<paragraph>foo[]bar</paragraph>' );
 		} );
@@ -565,7 +566,7 @@ describe( 'Input feature', () => {
 					ModelRange.createFromParentsAndOffsets( modelRoot.getChild( 0 ), 2, modelRoot.getChild( 0 ), 4 ) );
 			} );
 
-			view.fire( 'keydown', { keyCode: getCode( 'y' ) } );
+			viewDocument.fire( 'keydown', { keyCode: getCode( 'y' ) } );
 
 			expect( lockSpy.calledOnce ).to.be.true;
 			expect( unlockSpy.calledOnce ).to.be.true;
@@ -576,9 +577,9 @@ describe( 'Input feature', () => {
 			const lockSpy = testUtils.sinon.spy( buffer, 'lock' );
 			const unlockSpy = testUtils.sinon.spy( buffer, 'unlock' );
 
-			view.fire( 'keydown', { keyCode: 16 } ); // Shift
-			view.fire( 'keydown', { keyCode: 35 } ); // Home
-			view.fire( 'keydown', { keyCode: 112 } ); // F1
+			viewDocument.fire( 'keydown', { keyCode: 16 } ); // Shift
+			viewDocument.fire( 'keydown', { keyCode: 35 } ); // Home
+			viewDocument.fire( 'keydown', { keyCode: 112 } ); // F1
 
 			expect( lockSpy.callCount ).to.be.equal( 0 );
 			expect( unlockSpy.callCount ).to.be.equal( 0 );
@@ -589,9 +590,9 @@ describe( 'Input feature', () => {
 			const lockSpy = testUtils.sinon.spy( buffer, 'lock' );
 			const unlockSpy = testUtils.sinon.spy( buffer, 'unlock' );
 
-			view.fire( 'keydown', { keyCode: getCode( 'b' ) } );
-			view.fire( 'keydown', { keyCode: getCode( 'a' ) } );
-			view.fire( 'keydown', { keyCode: getCode( 'z' ) } );
+			viewDocument.fire( 'keydown', { keyCode: getCode( 'b' ) } );
+			viewDocument.fire( 'keydown', { keyCode: getCode( 'a' ) } );
+			viewDocument.fire( 'keydown', { keyCode: getCode( 'z' ) } );
 
 			expect( lockSpy.callCount ).to.be.equal( 0 );
 			expect( unlockSpy.callCount ).to.be.equal( 0 );
@@ -602,7 +603,7 @@ describe( 'Input feature', () => {
 
 			editor.commands.get( 'input' ).isEnabled = false;
 
-			view.fire( 'keydown', { keyCode: getCode( 'b' ) } );
+			viewDocument.fire( 'keydown', { keyCode: getCode( 'b' ) } );
 
 			expect( getModelData( model ) ).to.equal( '<paragraph>foo[]bar</paragraph>' );
 		} );
@@ -612,7 +613,7 @@ describe( 'Input feature', () => {
 
 			editor.commands.get( 'input' ).isEnabled = false;
 
-			view.fire( 'keydown', { keyCode: getCode( 'b' ) } );
+			viewDocument.fire( 'keydown', { keyCode: getCode( 'b' ) } );
 
 			expect( getModelData( model ) ).to.equal( '<paragraph>fo[ob]ar</paragraph>' );
 		} );
@@ -639,7 +640,8 @@ describe( 'Input feature', () => {
 					model = editor.model;
 					modelRoot = model.document.getRoot();
 					view = editor.editing.view;
-					viewRoot = view.getRoot();
+					viewDocument = view.document;
+					viewRoot = viewDocument.getRoot();
 					domRoot = view.getDomRoot();
 
 					// Mock image feature.
@@ -686,7 +688,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].innerHTML = '<i><a href="foo">text</a>x</i>';
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				// First mutation - remove all children from link element.
 				{
 					type: 'children',
@@ -733,7 +735,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].innerHTML = '<i>x<a href="foo">text</a></i>';
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				// First mutation - remove all children from link element.
 				{
 					type: 'children',
@@ -781,7 +783,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].innerHTML = 'xxx<i><a href="foo">text</a>x</i>';
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				// First mutation - remove all children from link element.
 				{
 					type: 'children',
@@ -827,7 +829,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].innerHTML = '<b>fixed text</b>';
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				// Replace `<strong>` with `<b>`.
 				{
 					type: 'children',
@@ -858,7 +860,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].childNodes[ 0 ].innerHTML = 'this is bar text';
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					node: strong,
@@ -886,7 +888,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].innerHTML = '<strong>text</strong><img />';
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					node: paragraph,
@@ -917,7 +919,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].innerHTML = '<strong>text</strong>';
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					node: paragraph,
@@ -942,7 +944,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].innerHTML = '<strong>text</strong>';
-			view.fire( 'mutations', [] );
+			viewDocument.fire( 'mutations', [] );
 
 			expect( getViewData( view ) ).to.equal( '<p><strong>text{}</strong></p>' );
 		} );
@@ -963,7 +965,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].innerHTML = '<strong>text</strong>';
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					node: paragraph,
@@ -998,7 +1000,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].innerHTML = '<b>textx</b>';
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				// Replace `<strong>` with `<b>`.
 				{
 					type: 'children',
@@ -1022,7 +1024,7 @@ describe( 'Input feature', () => {
 
 			// Simulate mutations and DOM change.
 			domRoot.childNodes[ 0 ].innerHTML = '<strong>Foo bar </strong><b>apple</b>';
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'Foo bar aple',

+ 3 - 3
packages/ckeditor5-typing/tests/spellchecking.js

@@ -233,12 +233,12 @@ describe( 'Typing – spellchecking integration', () => {
 
 function emulateSpellcheckerMutation( editor, nodeIndex, resultPositionIndex, oldText, newText ) {
 	const view = editor.editing.view;
-	const viewRoot = view.getRoot();
+	const viewRoot = view.document.getRoot();
 	const viewSelection = new ViewSelection();
 
-	viewSelection.setTo( viewRoot.getChild( nodeIndex ).getChild( 0 ), resultPositionIndex );
+	viewSelection._setTo( viewRoot.getChild( nodeIndex ).getChild( 0 ), resultPositionIndex );
 
-	view.fire( 'mutations',
+	view.document.fire( 'mutations',
 		[ {
 			type: 'text',
 			oldText,