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

Aligned DataController with the new Batch API.

Oskar Wróbel 8 лет назад
Родитель
Сommit
bd8364c2b1

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

@@ -21,7 +21,6 @@ import { convertText, convertToModelFragment } from '../conversion/view-to-model
 import ViewDocumentFragment from '../view/documentfragment';
 
 import ModelRange from '../model/range';
-import ModelPosition from '../model/position';
 import ModelElement from '../model/element';
 
 import insertContent from './insertcontent';
@@ -196,9 +195,10 @@ export default class DataController {
 			this.model.selection.clearAttributes();
 
 			// Initial batch should be ignored by features like undo, etc.
-			this.model.batch( 'transparent' )
-				.remove( ModelRange.createIn( modelRoot ) )
-				.insert( ModelPosition.createAt( modelRoot, 0 ), this.parse( data ) );
+			const batch = this.model.batch( 'transparent' );
+
+			batch.remove( ModelRange.createIn( modelRoot ) );
+			batch.insert( this.parse( data ), modelRoot );
 		} );
 	}
 

+ 2 - 2
packages/ckeditor5-engine/src/controller/deletecontent.js

@@ -128,7 +128,7 @@ function mergeBranches( batch, startPos, endPos ) {
 		// <a><b>x[]</b></a><c><d>{}y</d></c>
 		// becomes:
 		// <a><b>x</b>[]<d>y</d></a><c>{}</c>
-		batch.move( endParent, startPos );
+		batch.insert( endParent, startPos );
 	}
 
 	// Merge two siblings:
@@ -181,7 +181,7 @@ function checkCanBeMerged( leftPos, rightPos ) {
 
 function insertParagraph( batch, position, selection ) {
 	const paragraph = new Element( 'paragraph' );
-	batch.insert( position, paragraph );
+	batch.insert( paragraph, position );
 
 	selection.setCollapsedAt( paragraph );
 }

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

@@ -256,7 +256,7 @@ class Insertion {
 
 		const livePos = LivePosition.createFromPosition( this.position );
 
-		this.batch.insert( this.position, node );
+		this.batch.insert( node, this.position );
 
 		this.position = Position.createFromPosition( livePos );
 		livePos.detach();