Kaynağa Gözat

Merge pull request #1737 from ckeditor/t/ckeditor5-undo/97

Feature: Introduced the `type` parameter to the `model.createBatch()` method.
Piotrek Koszuliński 6 yıl önce
ebeveyn
işleme
d6a7afcaa2

+ 3 - 2
packages/ckeditor5-engine/src/model/model.js

@@ -702,10 +702,11 @@ export default class Model {
 	 * * {@link #change `change()`},
 	 * * {@link #enqueueChange `enqueueChange()`}.
 	 *
+	 * @param {'transparent'|'default'} [type='default'] The type of the batch.
 	 * @returns {module:engine/model/batch~Batch}
 	 */
-	createBatch() {
-		return new Batch();
+	createBatch( type ) {
+		return new Batch( type );
 	}
 
 	/**

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

@@ -774,7 +774,15 @@ describe( 'Model', () => {
 
 	describe( 'createBatch()', () => {
 		it( 'should return instance of Batch', () => {
-			expect( model.createBatch() ).to.be.instanceof( Batch );
+			const batch = model.createBatch();
+			expect( batch ).to.be.instanceof( Batch );
+			expect( batch.type ).to.equal( 'default' );
+		} );
+
+		it( 'should allow to define type of Batch', () => {
+			const batch = model.createBatch( 'transparent' );
+			expect( batch ).to.be.instanceof( Batch );
+			expect( batch.type ).to.equal( 'transparent' );
 		} );
 	} );