Browse Source

Merge branch t/engine/1186

Internal: Update API usage after merge t/1186 on engine.
Piotr Jasiun 8 years ago
parent
commit
6b3d8fd357

+ 1 - 1
packages/ckeditor5-core/src/command.js

@@ -66,7 +66,7 @@ export default class Command {
 		this.decorate( 'execute' );
 
 		// By default every command is refreshed when changes are applied to the model.
-		this.listenTo( this.editor.document, 'changesDone', () => {
+		this.listenTo( this.editor.model.document, 'changesDone', () => {
 			this.refresh();
 		} );
 

+ 8 - 11
packages/ckeditor5-core/src/editor/editor.js

@@ -12,7 +12,7 @@ import PluginCollection from '../plugincollection';
 import CommandCollection from '../commandcollection';
 import Locale from '@ckeditor/ckeditor5-utils/src/locale';
 import DataController from '@ckeditor/ckeditor5-engine/src/controller/datacontroller';
-import Document from '@ckeditor/ckeditor5-engine/src/model/document';
+import Model from '@ckeditor/ckeditor5-engine/src/model/model';
 
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
@@ -74,23 +74,20 @@ export default class Editor {
 		this.t = this.locale.t;
 
 		/**
-		 * The editor's model document.
+		 * The editor's model.
 		 *
-		 * The center of the editor's abstract data model. The document contains
-		 * {@link module:engine/model/document~Document#getRoot all editing roots},
-		 * {@link module:engine/model/document~Document#selection} and allows
-		 * applying changes to through the {@link module:engine/model/document~Document#batch batch interface}.
+		 * The center of the editor's abstract data model.
 		 *
-		 * Besides the model document, the editor usually contains two controllers –
+		 * Besides the model, the editor usually contains two controllers –
 		 * {@link #data data controller} and {@link #editing editing controller}.
 		 * The former is used e.g. when setting or retrieving editor data and contains a useful
 		 * set of methods for operating on the content. The latter controls user input and rendering
 		 * the content for editing.
 		 *
 		 * @readonly
-		 * @member {module:engine/model/document~Document}
+		 * @member {module:engine/model/model~Model}
 		 */
-		this.document = new Document();
+		this.model = new Model();
 
 		/**
 		 * The {@link module:engine/controller/datacontroller~DataController data controller}.
@@ -98,7 +95,7 @@ export default class Editor {
 		 * @readonly
 		 * @member {module:engine/controller/datacontroller~DataController}
 		 */
-		this.data = new DataController( this.document );
+		this.data = new DataController( this.model );
 
 		/**
 		 * Defines whether this editor is in read-only mode.
@@ -174,7 +171,7 @@ export default class Editor {
 
 		return this.plugins.destroy()
 			.then( () => {
-				this.document.destroy();
+				this.model.destroy();
 				this.data.destroy();
 			} );
 	}

+ 1 - 1
packages/ckeditor5-core/src/editor/standardeditor.js

@@ -41,7 +41,7 @@ export default class StandardEditor extends Editor {
 		this.element = element;
 
 		// Documented in Editor.
-		this.editing = new EditingController( this.document );
+		this.editing = new EditingController( this.model );
 		this.editing.view.bind( 'isReadOnly' ).to( this );
 
 		/**

+ 3 - 3
packages/ckeditor5-core/tests/_utils-tests/classictesteditor.js

@@ -42,7 +42,7 @@ describe( 'ClassicTestEditor', () => {
 		it( 'creates model and view roots', () => {
 			const editor = new ClassicTestEditor( editorElement );
 
-			expect( editor.document.getRoot() ).to.have.property( 'name', '$root' );
+			expect( editor.model.document.getRoot() ).to.have.property( 'name', '$root' );
 			expect( editor.editing.view.getRoot() ).to.have.property( 'name', 'div' );
 			expect( editor.data.processor ).to.be.instanceof( HtmlDataProcessor );
 		} );
@@ -81,13 +81,13 @@ describe( 'ClassicTestEditor', () => {
 
 			class PluginTextInRoot extends Plugin {
 				init() {
-					this.editor.document.schema.allow( { name: '$text', inside: '$root' } );
+					this.editor.model.schema.allow( { name: '$text', inside: '$root' } );
 				}
 			}
 
 			return ClassicTestEditor.create( editorElement, { plugins: [ PluginTextInRoot ] } )
 				.then( editor => {
-					expect( getData( editor.document, { withoutSelection: true } ) ).to.equal( 'foo' );
+					expect( getData( editor.model, { withoutSelection: true } ) ).to.equal( 'foo' );
 				} );
 		} );
 

+ 6 - 6
packages/ckeditor5-core/tests/_utils-tests/modeltesteditor.js

@@ -28,7 +28,7 @@ describe( 'ModelTestEditor', () => {
 		it( 'creates model and view roots', () => {
 			const editor = new ModelTestEditor( { foo: 1 } );
 
-			expect( editor.document.getRoot() ).to.have.property( 'name', '$root' );
+			expect( editor.model.document.getRoot() ).to.have.property( 'name', '$root' );
 			expect( editor.data.processor ).to.be.instanceof( HtmlDataProcessor );
 		} );
 	} );
@@ -76,16 +76,16 @@ describe( 'ModelTestEditor', () => {
 				.then( newEditor => {
 					editor = newEditor;
 
-					editor.document.schema.allow( { name: '$text', inside: '$root' } );
+					editor.model.schema.allow( { name: '$text', inside: '$root' } );
 				} );
 		} );
 
 		it( 'should set data of the first root', () => {
-			editor.document.createRoot( '$root', 'secondRoot' );
+			editor.model.document.createRoot( '$root', 'secondRoot' );
 
 			editor.setData( 'foo' );
 
-			expect( getData( editor.document, { rootName: 'main', withoutSelection: true } ) ).to.equal( 'foo' );
+			expect( getData( editor.model, { rootName: 'main', withoutSelection: true } ) ).to.equal( 'foo' );
 		} );
 	} );
 
@@ -97,12 +97,12 @@ describe( 'ModelTestEditor', () => {
 				.then( newEditor => {
 					editor = newEditor;
 
-					editor.document.schema.allow( { name: '$text', inside: '$root' } );
+					editor.model.schema.allow( { name: '$text', inside: '$root' } );
 				} );
 		} );
 
 		it( 'should set data of the first root', () => {
-			setData( editor.document, 'foo' );
+			setData( editor.model, 'foo' );
 
 			expect( editor.getData() ).to.equal( 'foo' );
 		} );

+ 1 - 1
packages/ckeditor5-core/tests/_utils-tests/virtualtesteditor.js

@@ -26,7 +26,7 @@ describe( 'VirtualTestEditor', () => {
 		it( 'creates model and view roots', () => {
 			const editor = new VirtualTestEditor( { foo: 1 } );
 
-			expect( editor.document.getRoot() ).to.have.property( 'name', '$root' );
+			expect( editor.model.document.getRoot() ).to.have.property( 'name', '$root' );
 			expect( editor.editing.view.getRoot() ).to.have.property( 'name', 'div' );
 			expect( editor.data.processor ).to.be.instanceof( HtmlDataProcessor );
 		} );

+ 1 - 1
packages/ckeditor5-core/tests/_utils/classictesteditor.js

@@ -23,7 +23,7 @@ export default class ClassicTestEditor extends StandardEditor {
 	constructor( element, config ) {
 		super( element, config );
 
-		this.document.createRoot();
+		this.model.document.createRoot();
 		this.editing.createRoot( 'div' );
 		this.data.processor = new HtmlDataProcessor();
 

+ 1 - 1
packages/ckeditor5-core/tests/_utils/modeltesteditor.js

@@ -18,7 +18,7 @@ export default class ModelTestEditor extends Editor {
 	constructor( config ) {
 		super( config );
 
-		this.document.createRoot();
+		this.model.document.createRoot();
 
 		this.data.processor = new HtmlDataProcessor();
 	}

+ 1 - 1
packages/ckeditor5-core/tests/_utils/virtualtesteditor.js

@@ -18,7 +18,7 @@ export default class VirtualTestEditor extends StandardEditor {
 	constructor( config ) {
 		super( null, config );
 
-		this.document.createRoot();
+		this.model.document.createRoot();
 
 		this.editing.createRoot( 'div' );
 

+ 2 - 2
packages/ckeditor5-core/tests/command.js

@@ -34,10 +34,10 @@ describe( 'Command', () => {
 			expect( command.isEnabled ).to.be.false;
 		} );
 
-		it( 'adds a listener which refreshed the command on editor.document#changesDone', () => {
+		it( 'adds a listener which refreshed the command on editor.model.document#changesDone', () => {
 			sinon.spy( command, 'refresh' );
 
-			editor.document.fire( 'changesDone' );
+			editor.model.document.fire( 'changesDone' );
 
 			expect( command.refresh.calledOnce ).to.be.true;
 		} );

+ 1 - 1
packages/ckeditor5-core/tests/editor/editor.js

@@ -193,7 +193,7 @@ describe( 'Editor', () => {
 			const editor = new Editor();
 
 			const spy1 = sinon.spy( editor.data, 'destroy' );
-			const spy2 = sinon.spy( editor.document, 'destroy' );
+			const spy2 = sinon.spy( editor.model, 'destroy' );
 			const spy3 = sinon.spy( editor.plugins, 'destroy' );
 
 			return editor.destroy()

+ 8 - 8
packages/ckeditor5-core/tests/editor/standardeditor.js

@@ -148,20 +148,20 @@ describe( 'StandardEditor', () => {
 
 					editor.data.processor = new HtmlDataProcessor();
 
-					editor.document.schema.allow( { name: '$text', inside: '$root' } );
+					editor.model.schema.allow( { name: '$text', inside: '$root' } );
 				} );
 		} );
 
 		it( 'should set data of the first root', () => {
-			editor.document.createRoot();
-			editor.document.createRoot( '$root', 'secondRoot' );
+			editor.model.document.createRoot();
+			editor.model.document.createRoot( '$root', 'secondRoot' );
 
 			editor.editing.createRoot( 'div' );
 			editor.editing.createRoot( 'div', 'secondRoot' );
 
 			editor.setData( 'foo' );
 
-			expect( getData( editor.document, { rootName: 'main', withoutSelection: true } ) ).to.equal( 'foo' );
+			expect( getData( editor.model, { rootName: 'main', withoutSelection: true } ) ).to.equal( 'foo' );
 		} );
 	} );
 
@@ -175,18 +175,18 @@ describe( 'StandardEditor', () => {
 
 					editor.data.processor = new HtmlDataProcessor();
 
-					editor.document.schema.allow( { name: '$text', inside: '$root' } );
+					editor.model.schema.allow( { name: '$text', inside: '$root' } );
 				} );
 		} );
 
 		it( 'should get data of the first root', () => {
-			editor.document.createRoot();
-			editor.document.createRoot( '$root', 'secondRoot' );
+			editor.model.document.createRoot();
+			editor.model.document.createRoot( '$root', 'secondRoot' );
 
 			editor.editing.createRoot( 'div' );
 			editor.editing.createRoot( 'div', 'secondRoot' );
 
-			setData( editor.document, 'foo' );
+			setData( editor.model, 'foo' );
 
 			expect( editor.getData() ).to.equal( 'foo' );
 		} );