Browse Source

Removed the composer.

Piotrek Koszuliński 9 years ago
parent
commit
65142cf94f

+ 61 - 4
packages/ckeditor5-engine/src/controller/datacontroller.js

@@ -20,6 +20,8 @@ import ModelRange from '../model/range.js';
 import ModelPosition from '../model/position.js';
 import ModelPosition from '../model/position.js';
 
 
 import insertContent from './insertcontent.js';
 import insertContent from './insertcontent.js';
+import deleteContent from './deletecontent.js';
+import modifySelection from './modifyselection.js';
 
 
 /**
 /**
  * Controller for the data pipeline. The data pipeline controls how data is retrieved from the document
  * Controller for the data pipeline. The data pipeline controls how data is retrieved from the document
@@ -112,6 +114,8 @@ export default class DataController {
 		this.viewToModel.on( 'documentFragment', convertToModelFragment(), { priority: 'lowest' } );
 		this.viewToModel.on( 'documentFragment', convertToModelFragment(), { priority: 'lowest' } );
 
 
 		this.on( 'insertContent', ( evt, data ) => insertContent( this, data.content, data.selection, data.batch ) );
 		this.on( 'insertContent', ( evt, data ) => insertContent( this, data.content, data.selection, data.batch ) );
+		this.on( 'deleteContent', ( evt, data ) => deleteContent( data.selection, data.batch, data.options ) );
+		this.on( 'modifySelection', ( evt, data ) => modifySelection( data.selection, data.options ) );
 	}
 	}
 
 
 	/**
 	/**
@@ -225,19 +229,72 @@ export default class DataController {
 	insertContent( content, selection, batch ) {
 	insertContent( content, selection, batch ) {
 		this.fire( 'insertContent', { content, selection, batch } );
 		this.fire( 'insertContent', { content, selection, batch } );
 	}
 	}
+
+	/**
+	 * See {@link engine.controller.deleteContent}.
+	 *
+	 * Note: For the sake of predictability, the resulting selection should always be collapsed.
+	 * In cases where a feature wants to modify deleting behavior so selection isn't collapsed
+	 * (e.g. a table feature may want to keep row selection after pressing <kbd>Backspace</kbd>),
+	 * then that behavior should be implemented in the view's listener. At the same time, the table feature
+	 * will need to modify this method's behavior too, e.g. to "delete contents and then collapse
+	 * the selection inside the last selected cell" or "delete the row and collapse selection somewhere near".
+	 * That needs to be done in order to ensure that other features which use `deleteContent()` will work well with tables.
+	 *
+	 * @fires engine.controller.DataController#deleteContent
+	 * @param {engine.model.Selection} selection Selection of which the content should be deleted.
+	 * @param {engine.model.Batch} batch Batch to which deltas will be added.
+	 * @param {Object} options See {@link engine.controller.deleteContent}'s options.
+	 */
+	deleteContent( selection, batch, options ) {
+		this.fire( 'deleteContent', { batch, selection, options } );
+	}
+
+	/**
+	 * See {@link engine.controller.modifySelection}.
+	 *
+	 * @fires engine.controller.DataController#modifySelection
+	 * @param {engine.model.Selection} The selection to modify.
+	 * @param {Object} options See {@link engine.controller.modifySelection}'s options.
+	 */
+	modifySelection( selection, options ) {
+		this.fire( 'modifySelection', { selection, options } );
+	}
 }
 }
 
 
 mix( DataController, EmitterMixin );
 mix( DataController, EmitterMixin );
 
 
 /**
 /**
- * Event fired when {@link engine.controller.DataController#insert} method is called.
- * The {@link engine.controller.dataController.insert default action of the composer} is implemented as a
- * listener to that event so it can be fully customized by the features.
+ * Event fired when {@link engine.controller.DataController#insertContent} method is called.
+ * The {@link engine.controller.dataController.insertContent default action of that method} is implemented as a
+ * listener to this event so it can be fully customized by the features.
  *
  *
- * @event engine.controller.DataController#insert
+ * @event engine.controller.DataController#insertContent
  * @param {Object} data
  * @param {Object} data
  * @param {engine.view.DocumentFragment} data.content The content to insert.
  * @param {engine.view.DocumentFragment} data.content The content to insert.
  * @param {engine.model.Selection} data.selection Selection into which the content should be inserted.
  * @param {engine.model.Selection} data.selection Selection into which the content should be inserted.
  * @param {engine.model.Batch} [data.batch] Batch to which deltas will be added.
  * @param {engine.model.Batch} [data.batch] Batch to which deltas will be added.
  */
  */
 
 
+/**
+ * Event fired when {@link engine.controller.DataController#deleteContent} method is called.
+ * The {@link engine.controller.deleteContent default action of that method} is implemented as a
+ * listener to this event so it can be fully customized by the features.
+ *
+ * @event engine.controller.DataController#deleteContent
+ * @param {Object} data
+ * @param {engine.model.Batch} data.batch
+ * @param {engine.model.Selection} data.selection
+ * @param {Object} data.options See {@link engine.controller.deleteContent}'s options.
+ */
+
+/**
+ * Event fired when {@link engine.controller.DataController#modifySelection} method is called.
+ * The {@link engine.controller.modifySelection default action of that method} is implemented as a
+ * listener to this event so it can be fully customized by the features.
+ *
+ * @event engine.controller.DataController#modifySelection
+ * @param {Object} data
+ * @param {engine.model.Selection} data.selection
+ * @param {Object} data.options See {@link engine.controller.modifySelection}'s options.
+ */

+ 8 - 8
packages/ckeditor5-engine/src/model/composer/deletecontents.js

@@ -3,23 +3,23 @@
  * For licensing, see LICENSE.md.
  * For licensing, see LICENSE.md.
  */
  */
 
 
-import LivePosition from '../liveposition.js';
-import Position from '../position.js';
-import Element from '../element.js';
-import compareArrays from '../../../utils/comparearrays.js';
+import LivePosition from '../model/liveposition.js';
+import Position from '../model/position.js';
+import Element from '../model/element.js';
+import compareArrays from '../../utils/comparearrays.js';
 
 
 /**
 /**
- * Delete contents of the selection and merge siblings. The resulting selection is always collapsed.
+ * Deletes content of the selection and merge siblings. The resulting selection is always collapsed.
  *
  *
- * @method engine.model.composer.deleteContents
- * @param {engine.model.Batch} batch Batch to which the deltas will be added.
+ * @method engine.controller.deleteContent
  * @param {engine.model.Selection} selection Selection of which the content should be deleted.
  * @param {engine.model.Selection} selection Selection of which the content should be deleted.
+ * @param {engine.model.Batch} batch Batch to which the deltas will be added.
  * @param {Object} [options]
  * @param {Object} [options]
  * @param {Boolean} [options.merge=false] Merge elements after removing the contents of the selection.
  * @param {Boolean} [options.merge=false] Merge elements after removing the contents of the selection.
  * For example, `<h>x[x</h><p>y]y</p>` will become: `<h>x^y</h>` with the option enabled
  * For example, `<h>x[x</h><p>y]y</p>` will become: `<h>x^y</h>` with the option enabled
  * and: `<h>x^</h><p>y</p>` without it.
  * and: `<h>x^</h><p>y</p>` without it.
  */
  */
-export default function deleteContents( batch, selection, options = {} ) {
+export default function deleteContent( selection, batch, options = {} ) {
 	if ( selection.isCollapsed ) {
 	if ( selection.isCollapsed ) {
 		return;
 		return;
 	}
 	}

+ 1 - 1
packages/ckeditor5-engine/src/controller/insertcontent.js

@@ -32,7 +32,7 @@ export default function insertContent( dataController, content, selection, batch
 	}
 	}
 
 
 	if ( !selection.isCollapsed ) {
 	if ( !selection.isCollapsed ) {
-		dataController.model.composer.deleteContents( batch, selection, {
+		dataController.deleteContent( selection, batch, {
 			merge: true
 			merge: true
 		} );
 		} );
 	}
 	}

+ 6 - 6
packages/ckeditor5-engine/src/model/composer/modifyselection.js

@@ -3,13 +3,13 @@
  * For licensing, see LICENSE.md.
  * For licensing, see LICENSE.md.
  */
  */
 
 
-import Position from '../position.js';
-import TreeWalker from '../treewalker.js';
-import Range from '../range.js';
-import { isInsideSurrogatePair, isInsideCombinedSymbol } from '../../../utils/unicode.js';
+import Position from '../model/position.js';
+import TreeWalker from '../model/treewalker.js';
+import Range from '../model/range.js';
+import { isInsideSurrogatePair, isInsideCombinedSymbol } from '../../utils/unicode.js';
 
 
 /**
 /**
- * Modifies the selection. Currently the supported modifications are:
+ * Modifies the selection. Currently, the supported modifications are:
  *
  *
  * * Extending. The selection focus is moved in the specified `options.direction` with a step specified in `options.unit`.
  * * Extending. The selection focus is moved in the specified `options.direction` with a step specified in `options.unit`.
  * Possible values for `unit` are:
  * Possible values for `unit` are:
@@ -29,7 +29,7 @@ import { isInsideSurrogatePair, isInsideCombinedSymbol } from '../../../utils/un
  *
  *
  * **Note:** if you extend a forward selection in a backward direction you will in fact shrink it.
  * **Note:** if you extend a forward selection in a backward direction you will in fact shrink it.
  *
  *
- * @method engine.model.composer.modifySelection
+ * @method engine.controller.modifySelection
  * @param {engine.model.Selection} selection The selection to modify.
  * @param {engine.model.Selection} selection The selection to modify.
  * @param {Object} [options]
  * @param {Object} [options]
  * @param {'forward'|'backward'} [options.direction='forward'] The direction in which the selection should be modified.
  * @param {'forward'|'backward'} [options.direction='forward'] The direction in which the selection should be modified.

+ 0 - 87
packages/ckeditor5-engine/src/model/composer/composer.js

@@ -1,87 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-import mix from '../../../utils/mix.js';
-import EmitterMixin from '../../../utils/emittermixin.js';
-import deleteContents from './deletecontents.js';
-import modifySelection from './modifyselection.js';
-
-/**
- * Set of frequently used tools to work with a document.
- * The instance of composer is available in {@link engine.model.Document#composer}.
- *
- * By default this class implements only a very basic version of those algorithms. However, all its methods can be extended
- * by features by listening to related events. The default action of those events are implemented
- * by functions available in the {@link engine.model.composer} namespace, so they can be reused
- * in the algorithms implemented by features.
- *
- * @member engine.model.composer
- * @mixes utils.EmitterMixin
- */
-export default class Composer {
-	/**
-	 * Creates an instance of the composer.
-	 */
-	constructor() {
-		this.on( 'deleteContents', ( evt, data ) => deleteContents( data.batch, data.selection, data.options ) );
-		this.on( 'modifySelection', ( evt, data ) => modifySelection( data.selection, data.options ) );
-	}
-
-	/**
-	 * See {@link engine.model.composer.deleteContents}.
-	 *
-	 * Note: For the sake of predictability, the resulting selection should always be collapsed.
-	 * In cases where a feature wants to modify deleting behavior so selection isn't collapsed
-	 * (e.g. a table feature may want to keep row selection after pressing <kbd>Backspace</kbd>),
-	 * then that behavior should be implemented in the view's listener. At the same time, the table feature
-	 * will need to modify this method's behavior too, e.g. to "delete contents and then collapse
-	 * the selection inside the last selected cell" or "delete the row and collapse selection somewhere near".
-	 * That needs to be done in order to ensure that other features which use `deleteContents()` will work well with tables.
-	 *
-	 * @fires engine.model.composer.Composer#deleteContents
-	 * @param {engine.model.Batch} batch Batch to which deltas will be added.
-	 * @param {engine.model.Selection} selection Selection of which the content should be deleted.
-	 * @param {Object} options See {@link engine.model.composer.deleteContents}'s options.
-	 */
-	deleteContents( batch, selection, options ) {
-		this.fire( 'deleteContents', { batch, selection, options } );
-	}
-
-	/**
-	 * See {@link engine.model.composer.modifySelection}.
-	 *
-	 * @fires engine.model.composer.Composer#modifySelection
-	 * @param {engine.model.Selection} The selection to modify.
-	 * @param {Object} options See {@link engine.model.composer.modifySelection}'s options.
-	 */
-	modifySelection( selection, options ) {
-		this.fire( 'modifySelection', { selection, options } );
-	}
-}
-
-mix( Composer, EmitterMixin );
-
-/**
- * Event fired when {@link engine.model.composer.Composer#deleteContents} method is called.
- * The {@link engine.model.composer.deleteContents default action of the composer} is implemented as a
- * listener to that event so it can be fully customized by the features.
- *
- * @event engine.model.composer.Composer#deleteContents
- * @param {Object} data
- * @param {engine.model.Batch} data.batch
- * @param {engine.model.Selection} data.selection
- * @param {Object} data.options See {@link engine.model.composer.deleteContents}'s options.
- */
-
-/**
- * Event fired when {@link engine.model.composer.Composer#modifySelection} method is called.
- * The {@link engine.model.composer.modifySelection default action of the composer} is implemented as a
- * listener to that event so it can be fully customized by the features.
- *
- * @event engine.model.composer.Composer#modifySelection
- * @param {Object} data
- * @param {engine.model.Selection} data.selection
- * @param {Object} data.options See {@link engine.model.composer.modifySelection}'s options.
- */

+ 0 - 10
packages/ckeditor5-engine/src/model/document.js

@@ -14,7 +14,6 @@ import Batch from './batch.js';
 import History from './history.js';
 import History from './history.js';
 import LiveSelection from './liveselection.js';
 import LiveSelection from './liveselection.js';
 import Schema from './schema.js';
 import Schema from './schema.js';
-import Composer from './composer/composer.js';
 import clone from '../../utils/lib/lodash/clone.js';
 import clone from '../../utils/lib/lodash/clone.js';
 import EmitterMixin from '../../utils/emittermixin.js';
 import EmitterMixin from '../../utils/emittermixin.js';
 import CKEditorError from '../../utils/ckeditorerror.js';
 import CKEditorError from '../../utils/ckeditorerror.js';
@@ -79,15 +78,6 @@ export default class Document {
 		this.history = new History( this );
 		this.history = new History( this );
 
 
 		/**
 		/**
-		 * Composer for this document. Set of tools to work with the document.
-		 *
-		 * The features can tune up these tools to better work on their specific cases.
-		 *
-		 * @member {engine.model.composer.Composer} engine.model.Document#composer
-		 */
-		this.composer = new Composer();
-
-		/**
 		 * Array of pending changes. See: {@link engine.model.Document#enqueueChanges}.
 		 * Array of pending changes. See: {@link engine.model.Document#enqueueChanges}.
 		 *
 		 *
 		 * @private
 		 * @private

+ 78 - 0
packages/ckeditor5-engine/tests/controller/datacontroller.js

@@ -52,6 +52,52 @@ describe( 'DataController', () => {
 			expect( getData( modelDocument ) ).to.equal( '<paragraph>ax[]b</paragraph>' );
 			expect( getData( modelDocument ) ).to.equal( '<paragraph>ax[]b</paragraph>' );
 			expect( batch.deltas.length ).to.be.above( 0 );
 			expect( batch.deltas.length ).to.be.above( 0 );
 		} );
 		} );
+
+		it( 'should add deleteContent listener', () => {
+			schema.registerItem( 'paragraph', '$block' );
+
+			setData( modelDocument, '<paragraph>f[oo</paragraph><paragraph>ba]r</paragraph>' );
+
+			const batch = modelDocument.batch();
+
+			data.fire( 'deleteContent', { batch, selection: modelDocument.selection } );
+
+			expect( getData( modelDocument ) ).to.equal( '<paragraph>f[]</paragraph><paragraph>r</paragraph>' );
+			expect( batch.deltas ).to.not.be.empty;
+		} );
+
+		it( 'should add deleteContent listener which passes ', () => {
+			schema.registerItem( 'paragraph', '$block' );
+
+			setData( modelDocument, '<paragraph>f[oo</paragraph><paragraph>ba]r</paragraph>' );
+
+			const batch = modelDocument.batch();
+
+			data.fire( 'deleteContent', {
+				batch,
+				selection: modelDocument.selection,
+				options: { merge: true }
+			} );
+
+			expect( getData( modelDocument ) ).to.equal( '<paragraph>f[]r</paragraph>' );
+		} );
+
+		it( 'should add modifySelection listener', () => {
+			schema.registerItem( 'paragraph', '$block' );
+
+			setData( modelDocument, '<paragraph>foo[]bar</paragraph>' );
+
+			data.fire( 'modifySelection', {
+				selection: modelDocument.selection,
+				options: {
+					direction: 'backward'
+				}
+			} );
+
+			expect( getData( modelDocument ) )
+				.to.equal( '<paragraph>fo[o]bar</paragraph>' );
+			expect( modelDocument.selection.isBackward ).to.true;
+		} );
 	} );
 	} );
 
 
 	describe( 'parse', () => {
 	describe( 'parse', () => {
@@ -285,4 +331,36 @@ describe( 'DataController', () => {
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );
+
+	describe( 'deleteContent', () => {
+		it( 'should fire the deleteContent event', () => {
+			const spy = sinon.spy();
+			const batch = modelDocument.batch();
+
+			data.on( 'deleteContent', spy );
+
+			data.deleteContent( modelDocument.selection, batch );
+
+			const evtData = spy.args[ 0 ][ 1 ];
+
+			expect( evtData.batch ).to.equal( batch );
+			expect( evtData.selection ).to.equal( modelDocument.selection );
+		} );
+	} );
+
+	describe( 'modifySelection', () => {
+		it( 'should fire the deleteContent event', () => {
+			const spy = sinon.spy();
+			const opts = { direction: 'backward' };
+
+			data.on( 'modifySelection', spy );
+
+			data.modifySelection( modelDocument.selection, opts );
+
+			const evtData = spy.args[ 0 ][ 1 ];
+
+			expect( evtData.selection ).to.equal( modelDocument.selection );
+			expect( evtData.options ).to.equal( opts );
+		} );
+	} );
 } );
 } );

+ 16 - 18
packages/ckeditor5-engine/tests/model/composer/deletecontents.js

@@ -3,16 +3,14 @@
  * For licensing, see LICENSE.md.
  * For licensing, see LICENSE.md.
  */
  */
 
 
-/* bender-tags: model, composer */
-
 import Document from 'ckeditor5/engine/model/document.js';
 import Document from 'ckeditor5/engine/model/document.js';
-import deleteContents from 'ckeditor5/engine/model/composer/deletecontents.js';
+import deleteContent from 'ckeditor5/engine/controller/deletecontent.js';
 import { setData, getData } from 'ckeditor5/engine/dev-utils/model.js';
 import { setData, getData } from 'ckeditor5/engine/dev-utils/model.js';
 
 
 describe( 'Delete utils', () => {
 describe( 'Delete utils', () => {
 	let doc;
 	let doc;
 
 
-	describe( 'deleteContents', () => {
+	describe( 'deleteContent', () => {
 		describe( 'in simple scenarios', () => {
 		describe( 'in simple scenarios', () => {
 			beforeEach( () => {
 			beforeEach( () => {
 				doc = new Document();
 				doc = new Document();
@@ -41,7 +39,7 @@ describe( 'Delete utils', () => {
 			it( 'deletes single character (backward selection)' , () => {
 			it( 'deletes single character (backward selection)' , () => {
 				setData( doc, 'f[o]o', { lastRangeBackward: true } );
 				setData( doc, 'f[o]o', { lastRangeBackward: true } );
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc ) ).to.equal( 'f[]o' );
 				expect( getData( doc ) ).to.equal( 'f[]o' );
 			} );
 			} );
@@ -95,7 +93,7 @@ describe( 'Delete utils', () => {
 			it( 'deletes characters (first half has attrs)', () => {
 			it( 'deletes characters (first half has attrs)', () => {
 				setData( doc, '<$text bold="true">fo[o</$text>b]ar' );
 				setData( doc, '<$text bold="true">fo[o</$text>b]ar' );
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc ) ).to.equal( '<$text bold="true">fo[]</$text>ar' );
 				expect( getData( doc ) ).to.equal( '<$text bold="true">fo[]</$text>ar' );
 				expect( doc.selection.getAttribute( 'bold' ) ).to.equal( true );
 				expect( doc.selection.getAttribute( 'bold' ) ).to.equal( true );
@@ -104,7 +102,7 @@ describe( 'Delete utils', () => {
 			it( 'deletes characters (2nd half has attrs)', () => {
 			it( 'deletes characters (2nd half has attrs)', () => {
 				setData( doc, 'fo[o<$text bold="true">b]ar</$text>' );
 				setData( doc, 'fo[o<$text bold="true">b]ar</$text>' );
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc ) ).to.equal( 'fo[]<$text bold="true">ar</$text>' );
 				expect( getData( doc ) ).to.equal( 'fo[]<$text bold="true">ar</$text>' );
 				expect( doc.selection.getAttribute( 'bold' ) ).to.undefined;
 				expect( doc.selection.getAttribute( 'bold' ) ).to.undefined;
@@ -113,7 +111,7 @@ describe( 'Delete utils', () => {
 			it( 'clears selection attrs when emptied content', () => {
 			it( 'clears selection attrs when emptied content', () => {
 				setData( doc, '<paragraph>x</paragraph><paragraph>[<$text bold="true">foo</$text>]</paragraph><paragraph>y</paragraph>' );
 				setData( doc, '<paragraph>x</paragraph><paragraph>[<$text bold="true">foo</$text>]</paragraph><paragraph>y</paragraph>' );
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc ) ).to.equal( '<paragraph>x</paragraph><paragraph>[]</paragraph><paragraph>y</paragraph>' );
 				expect( getData( doc ) ).to.equal( '<paragraph>x</paragraph><paragraph>[]</paragraph><paragraph>y</paragraph>' );
 				expect( doc.selection.getAttribute( 'bold' ) ).to.undefined;
 				expect( doc.selection.getAttribute( 'bold' ) ).to.undefined;
@@ -130,7 +128,7 @@ describe( 'Delete utils', () => {
 					}
 					}
 				);
 				);
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc ) ).to.equal( '<paragraph>x<$text bold="true">a[]b</$text>y</paragraph>' );
 				expect( getData( doc ) ).to.equal( '<paragraph>x<$text bold="true">a[]b</$text>y</paragraph>' );
 				expect( doc.selection.getAttribute( 'bold' ) ).to.equal( true );
 				expect( doc.selection.getAttribute( 'bold' ) ).to.equal( true );
@@ -203,7 +201,7 @@ describe( 'Delete utils', () => {
 					{ lastRangeBackward: true }
 					{ lastRangeBackward: true }
 				);
 				);
 
 
-				deleteContents( doc.batch(), doc.selection, { merge: true } );
+				deleteContent( doc.selection, doc.batch(), { merge: true } );
 
 
 				expect( getData( doc ) ).to.equal( '<paragraph>x</paragraph><heading1>fo[]ar</heading1><paragraph>y</paragraph>' );
 				expect( getData( doc ) ).to.equal( '<paragraph>x</paragraph><heading1>fo[]ar</heading1><paragraph>y</paragraph>' );
 			} );
 			} );
@@ -301,7 +299,7 @@ describe( 'Delete utils', () => {
 					{ rootName: 'paragraphRoot' }
 					{ rootName: 'paragraphRoot' }
 				);
 				);
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc, { rootName: 'paragraphRoot' } ) )
 				expect( getData( doc, { rootName: 'paragraphRoot' } ) )
 					.to.equal( '<paragraph>x[]z</paragraph>' );
 					.to.equal( '<paragraph>x[]z</paragraph>' );
@@ -314,7 +312,7 @@ describe( 'Delete utils', () => {
 					{ rootName: 'bodyRoot' }
 					{ rootName: 'bodyRoot' }
 				);
 				);
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc, { rootName: 'bodyRoot' } ) )
 				expect( getData( doc, { rootName: 'bodyRoot' } ) )
 					.to.equal( '<paragraph>x</paragraph><paragraph>[]</paragraph><paragraph>z</paragraph>' );
 					.to.equal( '<paragraph>x</paragraph><paragraph>[]</paragraph><paragraph>z</paragraph>' );
@@ -327,7 +325,7 @@ describe( 'Delete utils', () => {
 					{ rootName: 'bodyRoot' }
 					{ rootName: 'bodyRoot' }
 				);
 				);
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc, { rootName: 'bodyRoot' } ) )
 				expect( getData( doc, { rootName: 'bodyRoot' } ) )
 					.to.equal( '<paragraph>x</paragraph><paragraph>[]</paragraph><paragraph>z</paragraph>' );
 					.to.equal( '<paragraph>x</paragraph><paragraph>[]</paragraph><paragraph>z</paragraph>' );
@@ -340,7 +338,7 @@ describe( 'Delete utils', () => {
 					{ rootName: 'bodyRoot' }
 					{ rootName: 'bodyRoot' }
 				);
 				);
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc, { rootName: 'bodyRoot' } ) )
 				expect( getData( doc, { rootName: 'bodyRoot' } ) )
 					.to.equal( '<paragraph>x</paragraph><paragraph>[]</paragraph><paragraph>z</paragraph>' );
 					.to.equal( '<paragraph>x</paragraph><paragraph>[]</paragraph><paragraph>z</paragraph>' );
@@ -353,7 +351,7 @@ describe( 'Delete utils', () => {
 					{ rootName: 'bodyRoot' }
 					{ rootName: 'bodyRoot' }
 				);
 				);
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc, { rootName: 'bodyRoot' } ) )
 				expect( getData( doc, { rootName: 'bodyRoot' } ) )
 					.to.equal( '<paragraph>x</paragraph><paragraph>[]</paragraph><paragraph>z</paragraph>' );
 					.to.equal( '<paragraph>x</paragraph><paragraph>[]</paragraph><paragraph>z</paragraph>' );
@@ -366,7 +364,7 @@ describe( 'Delete utils', () => {
 					{ rootName: 'bodyRoot' }
 					{ rootName: 'bodyRoot' }
 				);
 				);
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc, { rootName: 'bodyRoot' } ) )
 				expect( getData( doc, { rootName: 'bodyRoot' } ) )
 					.to.equal( '<paragraph>[]</paragraph>' );
 					.to.equal( '<paragraph>[]</paragraph>' );
@@ -379,7 +377,7 @@ describe( 'Delete utils', () => {
 					{ rootName: 'restrictedRoot' }
 					{ rootName: 'restrictedRoot' }
 				);
 				);
 
 
-				deleteContents( doc.batch(), doc.selection );
+				deleteContent( doc.selection, doc.batch() );
 
 
 				expect( getData( doc, { rootName: 'restrictedRoot' } ) )
 				expect( getData( doc, { rootName: 'restrictedRoot' } ) )
 					.to.equal( '<blockWidget></blockWidget>[]<blockWidget></blockWidget>' );
 					.to.equal( '<blockWidget></blockWidget>[]<blockWidget></blockWidget>' );
@@ -390,7 +388,7 @@ describe( 'Delete utils', () => {
 			it( title, () => {
 			it( title, () => {
 				setData( doc, input );
 				setData( doc, input );
 
 
-				deleteContents( doc.batch(), doc.selection, options );
+				deleteContent( doc.selection, doc.batch(), options );
 
 
 				expect( getData( doc ) ).to.equal( output );
 				expect( getData( doc ) ).to.equal( output );
 			} );
 			} );

+ 1 - 3
packages/ckeditor5-engine/tests/model/composer/modifyselection.js

@@ -3,11 +3,9 @@
  * For licensing, see LICENSE.md.
  * For licensing, see LICENSE.md.
  */
  */
 
 
-/* bender-tags: model, composer */
-
 import Document from 'ckeditor5/engine/model/document.js';
 import Document from 'ckeditor5/engine/model/document.js';
 import Selection from 'ckeditor5/engine/model/selection.js';
 import Selection from 'ckeditor5/engine/model/selection.js';
-import modifySelection from 'ckeditor5/engine/model/composer/modifyselection.js';
+import modifySelection from 'ckeditor5/engine/controller/modifyselection.js';
 import { setData, stringify } from 'ckeditor5/engine/dev-utils/model.js';
 import { setData, stringify } from 'ckeditor5/engine/dev-utils/model.js';
 
 
 describe( 'Delete utils', () => {
 describe( 'Delete utils', () => {

+ 0 - 96
packages/ckeditor5-engine/tests/model/composer/composer.js

@@ -1,96 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: model, composer */
-
-import Document from 'ckeditor5/engine/model/document.js';
-import Composer from 'ckeditor5/engine/model/composer/composer.js';
-import { setData, getData } from 'ckeditor5/engine/dev-utils/model.js';
-
-describe( 'Composer', () => {
-	let document, composer;
-
-	beforeEach( () => {
-		document = new Document();
-		document.schema.registerItem( 'p', '$block' );
-		document.createRoot();
-
-		composer = new Composer();
-	} );
-
-	describe( 'constructor()', () => {
-		it( 'attaches deleteContents default listener', () => {
-			setData( document, '<p>f[oo</p><p>ba]r</p>' );
-
-			const batch = document.batch();
-
-			composer.fire( 'deleteContents', { batch, selection: document.selection } );
-
-			expect( getData( document ) ).to.equal( '<p>f[]</p><p>r</p>' );
-			expect( batch.deltas ).to.not.be.empty;
-		} );
-
-		it( 'attaches deleteContents default listener which passes options', () => {
-			setData( document, '<p>f[oo</p><p>ba]r</p>' );
-
-			const batch = document.batch();
-
-			composer.fire( 'deleteContents', {
-				batch,
-				selection: document.selection,
-				options: { merge: true }
-			} );
-
-			expect( getData( document ) ).to.equal( '<p>f[]r</p>' );
-		} );
-
-		it( 'attaches modifySelection default listener', () => {
-			setData( document, '<p>foo[]bar</p>' );
-
-			composer.fire( 'modifySelection', {
-				selection: document.selection,
-				options: {
-					direction: 'backward'
-				}
-			} );
-
-			expect( getData( document ) )
-				.to.equal( '<p>fo[o]bar</p>' );
-			expect( document.selection.isBackward ).to.true;
-		} );
-	} );
-
-	describe( 'deleteContents', () => {
-		it( 'fires deleteContents event', () => {
-			const spy = sinon.spy();
-			const batch = document.batch();
-
-			composer.on( 'deleteContents', spy );
-
-			composer.deleteContents( batch, document.selection );
-
-			const data = spy.args[ 0 ][ 1 ];
-
-			expect( data.batch ).to.equal( batch );
-			expect( data.selection ).to.equal( document.selection );
-		} );
-	} );
-
-	describe( 'modifySelection', () => {
-		it( 'fires deleteContents event', () => {
-			const spy = sinon.spy();
-			const opts = { direction: 'backward' };
-
-			composer.on( 'modifySelection', spy );
-
-			composer.modifySelection( document.selection, opts );
-
-			const data = spy.args[ 0 ][ 1 ];
-
-			expect( data.selection ).to.equal( document.selection );
-			expect( data.options ).to.equal( opts );
-		} );
-	} );
-} );

+ 0 - 2
packages/ckeditor5-engine/tests/model/document/document.js

@@ -7,7 +7,6 @@
 
 
 import Document from 'ckeditor5/engine/model/document.js';
 import Document from 'ckeditor5/engine/model/document.js';
 import Schema from 'ckeditor5/engine/model/schema.js';
 import Schema from 'ckeditor5/engine/model/schema.js';
-import Composer from 'ckeditor5/engine/model/composer/composer.js';
 import RootElement from 'ckeditor5/engine/model/rootelement.js';
 import RootElement from 'ckeditor5/engine/model/rootelement.js';
 import Batch from 'ckeditor5/engine/model/batch.js';
 import Batch from 'ckeditor5/engine/model/batch.js';
 import Delta from 'ckeditor5/engine/model/delta/delta.js';
 import Delta from 'ckeditor5/engine/model/delta/delta.js';
@@ -31,7 +30,6 @@ describe( 'Document', () => {
 			expect( doc.graveyard.maxOffset ).to.equal( 0 );
 			expect( doc.graveyard.maxOffset ).to.equal( 0 );
 			expect( count( doc.selection.getRanges() ) ).to.equal( 1 );
 			expect( count( doc.selection.getRanges() ) ).to.equal( 1 );
 
 
-			expect( doc.composer ).to.be.instanceof( Composer );
 			expect( doc.schema ).to.be.instanceof( Schema );
 			expect( doc.schema ).to.be.instanceof( Schema );
 		} );
 		} );
 	} );
 	} );