Przeglądaj źródła

Merge branch 'master' into t/92

Piotrek Koszuliński 7 lat temu
rodzic
commit
8d4054e825

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

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

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

@@ -18,9 +18,10 @@ import env from '@ckeditor/ckeditor5-utils/src/env';
  * @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,7 +6,7 @@
 /* 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';
@@ -17,18 +17,23 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 testUtils.createSinonSandbox();
 
 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();
 	} );
 

+ 51 - 50
packages/ckeditor5-typing/tests/input.js

@@ -26,7 +26,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();
 
@@ -55,7 +55,8 @@ describe( 'Input feature', () => {
 				model = editor.model;
 				modelRoot = model.document.getRoot();
 				view = editor.editing.view;
-				viewRoot = view.getRoot();
+				viewDocument = view.document;
+				viewRoot = viewDocument.getRoot();
 			} );
 	} );
 
@@ -79,7 +80,7 @@ describe( 'Input feature', () => {
 
 	describe( 'mutations handling', () => {
 		it( 'should handle text mutation', () => {
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foobar',
@@ -93,7 +94,7 @@ describe( 'Input feature', () => {
 		} );
 
 		it( 'should handle text mutation change', () => {
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foobar',
@@ -109,7 +110,7 @@ describe( 'Input feature', () => {
 		it( 'should handle text node insertion', () => {
 			editor.setData( '<p></p>' );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [],
@@ -129,7 +130,7 @@ describe( 'Input feature', () => {
 					italic: true
 				}
 			} );
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [],
@@ -146,7 +147,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',
@@ -168,7 +169,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: [],
@@ -190,7 +191,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: [],
@@ -204,7 +205,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' ) ],
@@ -220,7 +221,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 ) ],
@@ -234,7 +235,7 @@ describe( 'Input feature', () => {
 		} );
 
 		it( 'should do nothing when node was removed', () => {
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'children',
 					oldChildren: [ new ViewText( 'foobar' ) ],
@@ -250,7 +251,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: [],
@@ -267,9 +268,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',
@@ -287,12 +288,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',
@@ -311,9 +312,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',
@@ -332,9 +333,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',
@@ -353,9 +354,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',
@@ -373,10 +374,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',
@@ -397,7 +398,7 @@ describe( 'Input feature', () => {
 				);
 			} );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foobar',
@@ -417,7 +418,7 @@ describe( 'Input feature', () => {
 				);
 			} );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foobar',
@@ -437,7 +438,7 @@ describe( 'Input feature', () => {
 				);
 			} );
 
-			view.fire( 'mutations', [
+			viewDocument.fire( 'mutations', [
 				{
 					type: 'text',
 					oldText: 'foobar',
@@ -458,7 +459,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' } );
 		} );
@@ -467,10 +468,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',
@@ -480,7 +481,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>' );
@@ -492,7 +493,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>' );
 		} );
@@ -503,7 +504,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>' );
 		} );
@@ -514,9 +515,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>' );
 		} );
@@ -528,7 +529,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>' );
 		} );
@@ -540,13 +541,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>' );
 		} );
@@ -561,7 +562,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;
@@ -572,9 +573,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 );
@@ -585,9 +586,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 );
@@ -598,7 +599,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>' );
 		} );
@@ -608,7 +609,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>' );
 		} );

+ 3 - 3
packages/ckeditor5-typing/tests/manual/nbsp.js

@@ -26,15 +26,15 @@ ClassicEditor
 
 		document.querySelector( '#nbsp' ).addEventListener( 'click', () => {
 			editor.model.change( writer => {
-				editor.model.document.selection.collapseToStart();
+				writer.setSelection( editor.model.document.selection.getFirstRange().start );
 				writer.insertText( '\u00A0', editor.model.document.selection.getFirstPosition() );
 			} );
 		} );
 
-		editor.model.document.once( 'change', () => {
+		editor.model.document.on( 'change', () => {
 			console.clear();
 
-			const modelData = getModelData( editor.model.document, { withoutSelection: true } );
+			const modelData = getModelData( editor.model, { withoutSelection: true } );
 			console.log( 'model:', modelData.replace( /\u00A0/g, '&nbsp;' ) );
 
 			const viewData = getViewData( editor.editing.view, { withoutSelection: true } );

+ 6 - 6
packages/ckeditor5-typing/tests/manual/rtl.js

@@ -19,11 +19,11 @@ const config = {
 };
 
 window.setInterval( function() {
-	const doc1 = window.editor1.document;
-	const doc2 = window.editor2.document;
+	const doc1 = window.editor1.model.document;
+	const doc2 = window.editor2.model.document;
 
-	if ( window.editor1.editing.view.isFocused ) {
-		console.log( 'editor 1', getData( doc1 ) );
+	if ( window.editor1.editing.view.document.isFocused ) {
+		console.log( 'editor 1', getData( window.editor1.model ) );
 
 		const modelSel = doc1.selection;
 
@@ -43,8 +43,8 @@ window.setInterval( function() {
 		);
 	}
 
-	if ( window.editor2.editing.view.isFocused ) {
-		console.log( 'editor 2', getData( doc2 ) );
+	if ( window.editor2.editing.view.document.isFocused ) {
+		console.log( 'editor 2', getData( window.editor2.model ) );
 
 		const modelSel = doc2.selection;
 

+ 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,

+ 14 - 13
packages/ckeditor5-typing/tests/tickets/100.js

@@ -33,7 +33,7 @@ import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils
 // However, the code handling these mutations doesn't really care what's inside new/old children. It
 // just needs the mutations common ancestor to understand how big fragment of the tree has changed.
 describe( 'Bug ckeditor5-typing#100', () => {
-	let domElement, domRoot, editor, model, view, viewRoot;
+	let domElement, domRoot, editor, model, view, viewDocument, viewRoot;
 
 	beforeEach( () => {
 		domElement = document.createElement( 'div' );
@@ -44,7 +44,8 @@ describe( 'Bug ckeditor5-typing#100', () => {
 				editor = newEditor;
 				model = editor.model;
 				view = editor.editing.view;
-				viewRoot = view.getRoot();
+				viewDocument = view.document;
+				viewRoot = viewDocument.getRoot();
 				domRoot = view.getDomRoot();
 
 				// Mock image feature.
@@ -93,7 +94,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// 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',
@@ -140,7 +141,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// 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',
@@ -188,7 +189,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// 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',
@@ -234,7 +235,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// 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',
@@ -265,7 +266,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// 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,
@@ -293,7 +294,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// Simulate mutations and DOM change.
 		domRoot.childNodes[ 0 ].innerHTML = '<strong>text</strong><img />';
-		view.fire( 'mutations', [
+		viewDocument.fire( 'mutations', [
 			{
 				type: 'children',
 				node: paragraph,
@@ -324,7 +325,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// Simulate mutations and DOM change.
 		domRoot.childNodes[ 0 ].innerHTML = '<strong>text</strong>';
-		view.fire( 'mutations', [
+		viewDocument.fire( 'mutations', [
 			{
 				type: 'children',
 				node: paragraph,
@@ -349,7 +350,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// 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>' );
 	} );
@@ -370,7 +371,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// Simulate mutations and DOM change.
 		domRoot.childNodes[ 0 ].innerHTML = '<strong>text</strong>';
-		view.fire( 'mutations', [
+		viewDocument.fire( 'mutations', [
 			{
 				type: 'children',
 				node: paragraph,
@@ -405,7 +406,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// Simulate mutations and DOM change.
 		domRoot.childNodes[ 0 ].innerHTML = '<b>textx</b>';
-		view.fire( 'mutations', [
+		viewDocument.fire( 'mutations', [
 			// Replace `<strong>` with `<b>`.
 			{
 				type: 'children',
@@ -429,7 +430,7 @@ describe( 'Bug ckeditor5-typing#100', () => {
 
 		// 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',