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

Merge pull request #523 from ckeditor/t/339

Renamed batch.doc to batch.document.
Szymon Cofalik 9 лет назад
Родитель
Сommit
2b8e422285

+ 6 - 6
packages/ckeditor5-engine/src/model/batch.js

@@ -34,17 +34,17 @@ export default class Batch {
 	/**
 	/**
 	 * Creates Batch instance. Not recommended to use directly, use {@link engine.model.Document#batch} instead.
 	 * Creates Batch instance. Not recommended to use directly, use {@link engine.model.Document#batch} instead.
 	 *
 	 *
-	 * @param {engine.model.Document} doc Document which this Batch changes.
+	 * @param {engine.model.Document} document Document which this Batch changes.
 	 * @param {'transparent'|'default'} [type='default'] Type of the batch.
 	 * @param {'transparent'|'default'} [type='default'] Type of the batch.
 	 */
 	 */
-	constructor( doc, type = 'default' ) {
+	constructor( document, type = 'default' ) {
 		/**
 		/**
 		 * Document which this batch changes.
 		 * Document which this batch changes.
 		 *
 		 *
 		 * @readonly
 		 * @readonly
-		 * @member {engine.model.Document} engine.model.Batch#doc
+		 * @member {engine.model.Document} engine.model.Batch#document
 		 */
 		 */
-		this.doc = doc;
+		this.document = document;
 
 
 		/**
 		/**
 		 * Array of deltas which compose this batch.
 		 * Array of deltas which compose this batch.
@@ -123,13 +123,13 @@ export default class Batch {
  *			this.addDelta( delta );
  *			this.addDelta( delta );
  *
  *
  *			// Create operations which should be components of this delta.
  *			// Create operations which should be components of this delta.
- *			const operation = new InsertOperation( position, nodes, this.doc.version );
+ *			const operation = new InsertOperation( position, nodes, this.document.version );
  *
  *
  *			// Add operation to the delta. It is important to add operation before applying it.
  *			// Add operation to the delta. It is important to add operation before applying it.
  *			delta.addOperation( operation );
  *			delta.addOperation( operation );
  *
  *
  *			// Remember to apply every operation, no magic, you need to do it manually.
  *			// Remember to apply every operation, no magic, you need to do it manually.
- *			this.doc.applyOperation( operation );
+ *			this.document.applyOperation( operation );
  *
  *
  *			// Make this method chainable.
  *			// Make this method chainable.
  *			return this;
  *			return this;

+ 2 - 2
packages/ckeditor5-engine/src/model/delta/attributedelta.js

@@ -130,9 +130,9 @@ register( 'removeAttr', function( key, nodeOrRange ) {
 
 
 function attribute( batch, key, value, nodeOrRange ) {
 function attribute( batch, key, value, nodeOrRange ) {
 	if ( nodeOrRange instanceof Range ) {
 	if ( nodeOrRange instanceof Range ) {
-		changeRange( batch, batch.doc, key, value, nodeOrRange );
+		changeRange( batch, batch.document, key, value, nodeOrRange );
 	} else {
 	} else {
-		changeNode( batch, batch.doc, key, value, nodeOrRange );
+		changeNode( batch, batch.document, key, value, nodeOrRange );
 	}
 	}
 }
 }
 
 

+ 2 - 2
packages/ckeditor5-engine/src/model/delta/insertdelta.js

@@ -73,11 +73,11 @@ export default class InsertDelta extends Delta {
  */
  */
 register( 'insert', function( position, nodes ) {
 register( 'insert', function( position, nodes ) {
 	const delta = new InsertDelta();
 	const delta = new InsertDelta();
-	const insert = new InsertOperation( position, nodes, this.doc.version );
+	const insert = new InsertOperation( position, nodes, this.document.version );
 
 
 	this.addDelta( delta );
 	this.addDelta( delta );
 	delta.addOperation( insert );
 	delta.addOperation( insert );
-	this.doc.applyOperation( insert );
+	this.document.applyOperation( insert );
 
 
 	return this;
 	return this;
 } );
 } );

+ 4 - 4
packages/ckeditor5-engine/src/model/delta/mergedelta.js

@@ -107,14 +107,14 @@ register( 'merge', function( position ) {
 	const positionAfter = Position.createFromParentAndOffset( nodeAfter, 0 );
 	const positionAfter = Position.createFromParentAndOffset( nodeAfter, 0 );
 	const positionBefore = Position.createFromParentAndOffset( nodeBefore, nodeBefore.getChildCount() );
 	const positionBefore = Position.createFromParentAndOffset( nodeBefore, nodeBefore.getChildCount() );
 
 
-	const move = new MoveOperation( positionAfter, nodeAfter.getChildCount(), positionBefore, this.doc.version );
+	const move = new MoveOperation( positionAfter, nodeAfter.getChildCount(), positionBefore, this.document.version );
 	move.isSticky = true;
 	move.isSticky = true;
 	delta.addOperation( move );
 	delta.addOperation( move );
-	this.doc.applyOperation( move );
+	this.document.applyOperation( move );
 
 
-	const remove = new RemoveOperation( position, 1, this.doc.version );
+	const remove = new RemoveOperation( position, 1, this.document.version );
 	delta.addOperation( remove );
 	delta.addOperation( remove );
-	this.doc.applyOperation( remove );
+	this.document.applyOperation( remove );
 
 
 	return this;
 	return this;
 } );
 } );

+ 2 - 2
packages/ckeditor5-engine/src/model/delta/movedelta.js

@@ -79,9 +79,9 @@ export default class MoveDelta extends Delta {
 }
 }
 
 
 function addMoveOperation( batch, delta, sourcePosition, howMany, targetPosition ) {
 function addMoveOperation( batch, delta, sourcePosition, howMany, targetPosition ) {
-	const operation = new MoveOperation( sourcePosition, howMany, targetPosition, batch.doc.version );
+	const operation = new MoveOperation( sourcePosition, howMany, targetPosition, batch.document.version );
 	delta.addOperation( operation );
 	delta.addOperation( operation );
-	batch.doc.applyOperation( operation );
+	batch.document.applyOperation( operation );
 }
 }
 
 
 /**
 /**

+ 2 - 2
packages/ckeditor5-engine/src/model/delta/removedelta.js

@@ -29,9 +29,9 @@ export default class RemoveDelta extends MoveDelta {
 }
 }
 
 
 function addRemoveOperation( batch, delta, position, howMany ) {
 function addRemoveOperation( batch, delta, position, howMany ) {
-	const operation = new RemoveOperation( position, howMany, batch.doc.version );
+	const operation = new RemoveOperation( position, howMany, batch.document.version );
 	delta.addOperation( operation );
 	delta.addOperation( operation );
-	batch.doc.applyOperation( operation );
+	batch.document.applyOperation( operation );
 }
 }
 
 
 /**
 /**

+ 4 - 4
packages/ckeditor5-engine/src/model/delta/renamedelta.js

@@ -36,7 +36,7 @@ export default class RenameDelta extends Delta {
 function apply( batch, delta, operation ) {
 function apply( batch, delta, operation ) {
 	batch.addDelta( delta );
 	batch.addDelta( delta );
 	delta.addOperation( operation );
 	delta.addOperation( operation );
-	batch.doc.applyOperation( operation );
+	batch.document.applyOperation( operation );
 }
 }
 
 
 /**
 /**
@@ -53,17 +53,17 @@ register( 'rename', function( newName, element ) {
 
 
 	apply(
 	apply(
 		this, delta,
 		this, delta,
-		new InsertOperation( Position.createAfter( element ), newElement, this.doc.version )
+		new InsertOperation( Position.createAfter( element ), newElement, this.document.version )
 	);
 	);
 
 
 	apply(
 	apply(
 		this, delta,
 		this, delta,
-		new MoveOperation( Position.createAt( element ), element.getChildCount(), Position.createAt( newElement ), this.doc.version )
+		new MoveOperation( Position.createAt( element ), element.getChildCount(), Position.createAt( newElement ), this.document.version )
 	);
 	);
 
 
 	apply(
 	apply(
 		this, delta,
 		this, delta,
-		new RemoveOperation( Position.createBefore( element ), 1, this.doc.version )
+		new RemoveOperation( Position.createBefore( element ), 1, this.document.version )
 	);
 	);
 
 
 	return this;
 	return this;

+ 4 - 4
packages/ckeditor5-engine/src/model/delta/splitdelta.js

@@ -111,21 +111,21 @@ register( 'split', function( position ) {
 
 
 	const copy = new Element( splitElement.name, splitElement._attrs );
 	const copy = new Element( splitElement.name, splitElement._attrs );
 
 
-	const insert = new InsertOperation( Position.createAfter( splitElement ), copy, this.doc.version );
+	const insert = new InsertOperation( Position.createAfter( splitElement ), copy, this.document.version );
 
 
 	delta.addOperation( insert );
 	delta.addOperation( insert );
-	this.doc.applyOperation( insert );
+	this.document.applyOperation( insert );
 
 
 	const move = new MoveOperation(
 	const move = new MoveOperation(
 		position,
 		position,
 		splitElement.getChildCount() - position.offset,
 		splitElement.getChildCount() - position.offset,
 		Position.createFromParentAndOffset( copy, 0 ),
 		Position.createFromParentAndOffset( copy, 0 ),
-		this.doc.version
+		this.document.version
 	);
 	);
 	move.isSticky = true;
 	move.isSticky = true;
 
 
 	delta.addOperation( move );
 	delta.addOperation( move );
-	this.doc.applyOperation( move );
+	this.document.applyOperation( move );
 
 
 	return this;
 	return this;
 } );
 } );

+ 4 - 4
packages/ckeditor5-engine/src/model/delta/unwrapdelta.js

@@ -80,16 +80,16 @@ register( 'unwrap', function( element ) {
 
 
 	let sourcePosition = Position.createFromParentAndOffset( element, 0 );
 	let sourcePosition = Position.createFromParentAndOffset( element, 0 );
 
 
-	const move = new MoveOperation( sourcePosition, element.getChildCount(), Position.createBefore( element ), this.doc.version );
+	const move = new MoveOperation( sourcePosition, element.getChildCount(), Position.createBefore( element ), this.document.version );
 	move.isSticky = true;
 	move.isSticky = true;
 	delta.addOperation( move );
 	delta.addOperation( move );
-	this.doc.applyOperation( move );
+	this.document.applyOperation( move );
 
 
 	// Computing new position because we moved some nodes before `element`.
 	// Computing new position because we moved some nodes before `element`.
 	// If we would cache `Position.createBefore( element )` we remove wrong node.
 	// If we would cache `Position.createBefore( element )` we remove wrong node.
-	const remove = new RemoveOperation( Position.createBefore( element ), 1, this.doc.version );
+	const remove = new RemoveOperation( Position.createBefore( element ), 1, this.document.version );
 	delta.addOperation( remove );
 	delta.addOperation( remove );
-	this.doc.applyOperation( remove );
+	this.document.applyOperation( remove );
 
 
 	return this;
 	return this;
 } );
 } );

+ 3 - 3
packages/ckeditor5-engine/src/model/delta/weakinsertdelta.js

@@ -53,12 +53,12 @@ register( 'weakInsert', function( position, nodes ) {
 	nodes = new NodeList( nodes );
 	nodes = new NodeList( nodes );
 
 
 	for ( let node of nodes._nodes ) {
 	for ( let node of nodes._nodes ) {
-		node._attrs = new Map( this.doc.selection.getAttributes() );
+		node._attrs = new Map( this.document.selection.getAttributes() );
 	}
 	}
 
 
-	const operation = new InsertOperation( position, nodes, this.doc.version );
+	const operation = new InsertOperation( position, nodes, this.document.version );
 	delta.addOperation( operation );
 	delta.addOperation( operation );
-	this.doc.applyOperation( operation );
+	this.document.applyOperation( operation );
 
 
 	return this;
 	return this;
 } );
 } );

+ 4 - 4
packages/ckeditor5-engine/src/model/delta/wrapdelta.js

@@ -121,14 +121,14 @@ register( 'wrap', function( range, elementOrString ) {
 	const delta = new WrapDelta();
 	const delta = new WrapDelta();
 	this.addDelta( delta );
 	this.addDelta( delta );
 
 
-	let insert = new InsertOperation( range.end, element, this.doc.version );
+	let insert = new InsertOperation( range.end, element, this.document.version );
 	delta.addOperation( insert );
 	delta.addOperation( insert );
-	this.doc.applyOperation( insert );
+	this.document.applyOperation( insert );
 
 
 	let targetPosition = Position.createFromParentAndOffset( element, 0 );
 	let targetPosition = Position.createFromParentAndOffset( element, 0 );
-	let move = new MoveOperation( range.start, range.end.offset - range.start.offset, targetPosition, this.doc.version );
+	let move = new MoveOperation( range.start, range.end.offset - range.start.offset, targetPosition, this.document.version );
 	delta.addOperation( move );
 	delta.addOperation( move );
-	this.doc.applyOperation( move );
+	this.document.applyOperation( move );
 
 
 	return this;
 	return this;
 } );
 } );

+ 1 - 1
packages/ckeditor5-engine/tests/model/document/document.js

@@ -158,7 +158,7 @@ describe( 'Document', () => {
 			const batch = doc.batch();
 			const batch = doc.batch();
 
 
 			expect( batch ).to.be.instanceof( Batch );
 			expect( batch ).to.be.instanceof( Batch );
-			expect( batch ).to.have.property( 'doc' ).that.equals( doc );
+			expect( batch ).to.have.property( 'document' ).that.equals( doc );
 		} );
 		} );
 
 
 		it( 'should set given batch type', () => {
 		it( 'should set given batch type', () => {