瀏覽代碼

Introduced batch as a third parameter of the change event.

Piotr Jasiun 10 年之前
父節點
當前提交
80576997e4

+ 3 - 1
packages/ckeditor5-engine/src/treemodel/document.js

@@ -91,7 +91,8 @@ CKEDITOR.define( [
 
 			this.version++;
 
-			this.fire( 'change', operation.type, changes );
+			const batch = operation.delta && operation.delta.batch;
+			this.fire( 'change', operation.type, changes, batch );
 		}
 
 		/**
@@ -178,6 +179,7 @@ CKEDITOR.define( [
 		 * is `undefined` it means that new attribute was inserted. Otherwise it contains changed or removed attribute.
 		 * @param {treeModel.Attribute} [changeInfo.newAttr] Only for 'attr' type. If the type is 'attr' and `newAttr`
 		 * is `undefined` it means that attribute was removed. Otherwise it contains changed or inserted attribute.
+		 * @param {treeModel.Batch} {@link treeModel.Batch} of changes which this change is a part of.
 		 */
 	}
 

+ 3 - 0
packages/ckeditor5-engine/tests/treemodel/document/document.js

@@ -81,9 +81,11 @@ describe( 'Document', () => {
 			const changeCallback = sinon.spy();
 			const type = 't';
 			const data = { data: 'x' };
+			const batch = 'batch';
 
 			let operation = {
 				type: type,
+				delta: { batch: batch },
 				baseVersion: 0,
 				_execute: sinon.stub().returns( data )
 			};
@@ -97,6 +99,7 @@ describe( 'Document', () => {
 			sinon.assert.calledOnce( changeCallback );
 			expect( changeCallback.args[ 0 ][ 1 ] ).to.equal( type );
 			expect( changeCallback.args[ 0 ][ 2 ] ).to.equal( data );
+			expect( changeCallback.args[ 0 ][ 3 ] ).to.equal( batch );
 		} );
 
 		it( 'should throw an error on the operation base version and the document version is different', () => {