Selaa lähdekoodia

Renamed makeTransaction to createTransaction.

Piotr Jasiun 10 vuotta sitten
vanhempi
commit
46164b9cd2

+ 5 - 5
packages/ckeditor5-utils/src/document/delta/transaction-base.js

@@ -14,24 +14,24 @@ CKEDITOR.define( [ 'ckeditorerror' ], ( CKEditorError ) => {
 	 *
 	 * For example to create two separate undo steps you can call:
 	 *
-	 *		doc.makeTransaction().insert( firstPosition, 'foo' );
-	 *		doc.makeTransaction().insert( secondPosition, 'bar' );
+	 *		doc.createTransaction().insert( firstPosition, 'foo' );
+	 *		doc.createTransaction().insert( secondPosition, 'bar' );
 	 *
 	 * To create a single undo step:
 	 *
-	 *		const transaction = doc.makeTransaction()
+	 *		const transaction = doc.createTransaction()
 	 *		transaction.insert( firstPosition, 'foo' );
 	 *		transaction.insert( secontPosition, 'bar' );
 	 *
 	 * Note that all document modification methods (insert, remove, split, etc.) are chainable so you can shorten code to:
 	 *
-	 *		doc.makeTransaction().insert( firstPosition, 'foo' ).insert( secontPosition, 'bar' );
+	 *		doc.createTransaction().insert( firstPosition, 'foo' ).insert( secontPosition, 'bar' );
 	 *
 	 * @class document.Transaction
 	 */
 	class Transaction {
 		/**
-		 * Creates transaction instance. Not recommended to use directly, use {@link document.Document#makeTransaction}
+		 * Creates transaction instance. Not recommended to use directly, use {@link document.Document#createTransaction}
 		 * instead.
 		 *
 		 * @constructor

+ 5 - 4
packages/ckeditor5-utils/src/document/document.js

@@ -22,9 +22,10 @@ CKEDITOR.define( [
 	 * All changes in the document are done by {@link document.operation.Operation operations}. To create operations in
 	 * the simple way use use the {@link document.Transaction transaction} API, for example:
 	 *
-	 *		document.makeTransaction().insert( position, nodes ).split( otherPosition );
+	 *		document.createTransaction().insert( position, nodes ).split( otherPosition );
+	 *
+	 * @see #createTransaction
 	 *
-	 * @see #makeTransaction
 	 * @class document.Document
 	 */
 	class Document {
@@ -59,7 +60,7 @@ CKEDITOR.define( [
 		/**
 		 * This is the entry point for all document changes. All changes on the document are done using
 		 * {@link document.operation.Operation operations}. To create operations in the simple way use the
-		 * {@link document.Transaction} API available via {@link #makeTransaction} method.
+		 * {@link document.Transaction} API available via {@link #createTransaction} method.
 		 *
 		 * @param {document.operation.Operation} operation Operation to be applied.
 		 */
@@ -147,7 +148,7 @@ CKEDITOR.define( [
 		 *
 		 * @returns {document.Transaction} Transaction instance.
 		 */
-		makeTransaction() {
+		createTransaction() {
 			return new Tranaction( this );
 		}
 	}

+ 1 - 1
packages/ckeditor5-utils/tests/document/deltas/changedelta.js

@@ -40,7 +40,7 @@ describe( 'Transaction', () => {
 	beforeEach( () => {
 		doc = new Document();
 		root = doc.createRoot( 'root' );
-		transaction = doc.makeTransaction();
+		transaction = doc.createTransaction();
 	} );
 
 	function getOperationsCount() {

+ 1 - 1
packages/ckeditor5-utils/tests/document/deltas/insertdelta.js

@@ -28,7 +28,7 @@ describe( 'Transaction', () => {
 
 	it( 'should insert text', () => {
 		const position = new Position( [ 0 ], root );
-		doc.makeTransaction().insert( position, 'foo' );
+		doc.createTransaction().insert( position, 'foo' );
 
 		expect( root.getChildCount() ).to.equal( 3 );
 		expect( root.getChild( 0 ).character ).to.equal( 'f' );

+ 3 - 3
packages/ckeditor5-utils/tests/document/deltas/mergedelta.js

@@ -43,7 +43,7 @@ describe( 'Transaction', () => {
 
 	describe( 'merge', () => {
 		it( 'should merge foo and bar into foobar', () => {
-			doc.makeTransaction().merge( new Position( [ 1 ], root ) );
+			doc.createTransaction().merge( new Position( [ 1 ], root ) );
 
 			expect( root.getChildCount() ).to.equal( 1 );
 			expect( root.getChild( 0 ).name ).to.equal( 'p' );
@@ -60,13 +60,13 @@ describe( 'Transaction', () => {
 
 		it( 'should throw if there is no element after', () => {
 			expect( () => {
-				doc.makeTransaction().merge( new Position( [ 2 ], root ) );
+				doc.createTransaction().merge( new Position( [ 2 ], root ) );
 			} ).to.throw( CKEditorError, /^transaction-merge-no-element-after/ );
 		} );
 
 		it( 'should throw if there is no element before', () => {
 			expect( () => {
-				doc.makeTransaction().merge( new Position( [ 0, 2 ], root ) );
+				doc.createTransaction().merge( new Position( [ 0, 2 ], root ) );
 			} ).to.throw( CKEditorError, /^transaction-merge-no-element-before/ );
 		} );
 	} );

+ 2 - 2
packages/ckeditor5-utils/tests/document/deltas/removedelta.js

@@ -30,7 +30,7 @@ describe( 'Transaction', () => {
 	describe( 'remove', () => {
 		it( 'should remove one element', () => {
 			const position = new Position( [ 1 ], root );
-			doc.makeTransaction().remove( position );
+			doc.createTransaction().remove( position );
 
 			expect( root.getChildCount() ).to.equal( 5 );
 			expect( root.getChild( 0 ).character ).to.equal( 'f' );
@@ -42,7 +42,7 @@ describe( 'Transaction', () => {
 
 		it( 'should remove 3 elements', () => {
 			const position = new Position( [ 1 ], root );
-			doc.makeTransaction().remove( position, 3 );
+			doc.createTransaction().remove( position, 3 );
 
 			expect( root.getChildCount() ).to.equal( 3 );
 			expect( root.getChild( 0 ).character ).to.equal( 'f' );

+ 3 - 3
packages/ckeditor5-utils/tests/document/deltas/splitdelta.js

@@ -42,7 +42,7 @@ describe( 'Transaction', () => {
 
 	describe( 'split', () => {
 		it( 'should split foobar to foo and bar', () => {
-			doc.makeTransaction().split( new Position( [ 0, 3 ], root ) );
+			doc.createTransaction().split( new Position( [ 0, 3 ], root ) );
 
 			expect( root.getChildCount() ).to.equal( 2 );
 
@@ -64,7 +64,7 @@ describe( 'Transaction', () => {
 		} );
 
 		it( 'should create an empty paragraph if we split at the end', () => {
-			doc.makeTransaction().split( new Position( [ 0, 6 ], root ) );
+			doc.createTransaction().split( new Position( [ 0, 6 ], root ) );
 
 			expect( root.getChildCount() ).to.equal( 2 );
 
@@ -87,7 +87,7 @@ describe( 'Transaction', () => {
 
 		it( 'should throw if we try to split a root', () => {
 			expect( () => {
-				doc.makeTransaction().split( new Position( [ 0 ], root ) );
+				doc.createTransaction().split( new Position( [ 0 ], root ) );
 			} ).to.throw( CKEditorError, /^transaction-split-root/ );
 		} );
 	} );

+ 2 - 2
packages/ckeditor5-utils/tests/document/document.js

@@ -109,9 +109,9 @@ describe( 'Document', () => {
 		} );
 	} );
 
-	describe( 'makeTransaction', () => {
+	describe( 'createTransaction', () => {
 		it( 'should create a new transaction with the document property', () => {
-			const transaction = document.makeTransaction();
+			const transaction = document.createTransaction();
 
 			expect( transaction ).to.be.instanceof( Transaction );
 			expect( transaction ).to.have.property( 'doc' ).that.equals( document );