Selaa lähdekoodia

Added: deltaType parameter in model.Document#event:change.

Szymon Cofalik 8 vuotta sitten
vanhempi
commit
0efaf05d5c

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

@@ -166,11 +166,9 @@ export default class Document {
 
 		this.history.addDelta( operation.delta );
 
-		const batch = operation.delta && operation.delta.batch;
-
 		if ( changes ) {
 			// `NoOperation` returns no changes, do not fire event for it.
-			this.fire( 'change', operation.type, changes, batch );
+			this.fire( 'change', operation.type, changes, operation.delta.batch, operation.delta.type );
 		}
 	}
 

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

@@ -114,6 +114,7 @@ describe( 'Document', () => {
 			const data = { data: 'x' };
 			const batch = new Batch();
 			const delta = new Delta();
+			delta.type = 'type';
 
 			let operation = {
 				type: type,
@@ -133,7 +134,8 @@ 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 );
+			expect( changeCallback.args[ 0 ][ 3 ] ).to.deep.equal( batch );
+			expect( changeCallback.args[ 0 ][ 4 ] ).to.equal( delta.type );
 		} );
 
 		it( 'should throw an error on the operation base version and the document version is different', () => {