Sfoglia il codice sorgente

Added: Delta#type.

Szymon Cofalik 9 anni fa
parent
commit
565da3f858

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

@@ -24,6 +24,13 @@ import Element from '../element';
  * @extends module:engine/model/delta/delta~Delta
  */
 export default class AttributeDelta extends Delta {
+	/**
+	 * @inheritDoc
+	 */
+	get type() {
+		return 'attribute';
+	}
+
 	/**
 	 * The attribute key that is changed by the delta or `null` if the delta has no operations.
 	 *

+ 7 - 0
packages/ckeditor5-engine/src/model/delta/delta.js

@@ -75,6 +75,13 @@ export default class Delta {
 		return Delta;
 	}
 
+	/**
+	 * Delta type.
+	 *
+	 * @readonly
+	 * @member {String} #type
+	 */
+
 	/**
 	 * Add operation to the delta.
 	 *

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

@@ -19,6 +19,13 @@ import InsertOperation from '../operation/insertoperation';
  * uses the `InsertDelta` class which inherits from the `Delta` class and may overwrite some methods.
  */
 export default class InsertDelta extends Delta {
+	/**
+	 * @inheritDoc
+	 */
+	get type() {
+		return 'insert';
+	}
+
 	/**
 	 * Position where the delta inserts nodes or `null` if there are no operations in the delta.
 	 *

+ 7 - 0
packages/ckeditor5-engine/src/model/delta/markerdelta.js

@@ -20,6 +20,13 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  * from the `Delta` class and may overwrite some methods.
  */
 export default class MarkerDelta extends Delta {
+	/**
+	 * @inheritDoc
+	 */
+	get type() {
+		return 'marker';
+	}
+
 	/**
 	 * A class that will be used when creating reversed delta.
 	 *

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

@@ -23,6 +23,13 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  * uses the `MergeDelta` class which inherits from the `Delta` class and may overwrite some methods.
  */
 export default class MergeDelta extends Delta {
+	/**
+	 * @inheritDoc
+	 */
+	get type() {
+		return 'merge';
+	}
+
 	/**
 	 * Position between to merged nodes or `null` if the delta has no operations.
 	 *

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

@@ -21,6 +21,13 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  * uses the `MoveDelta` class which inherits from the `Delta` class and may overwrite some methods.
  */
 export default class MoveDelta extends Delta {
+	/**
+	 * @inheritDoc
+	 */
+	get type() {
+		return 'move';
+	}
+
 	/**
 	 * Offset size of moved range or `null` if there are no operations in the delta.
 	 *

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

@@ -20,6 +20,13 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  * uses the `RenameDelta` class which inherits from the `Delta` class and may overwrite some methods.
  */
 export default class RenameDelta extends Delta {
+	/**
+	 * @inheritDoc
+	 */
+	get type() {
+		return 'rename';
+	}
+
 	/**
 	 * @inheritDoc
 	 */

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

@@ -23,6 +23,13 @@ import MergeDelta from '../delta/mergedelta';
  * uses `SplitDelta` class which inherits from the `Delta` class and may overwrite some methods.
  */
 export default class SplitDelta extends Delta {
+	/**
+	 * @inheritDoc
+	 */
+	get type() {
+		return 'split';
+	}
+
 	/**
 	 * Position of split or `null` if there are no operations in the delta.
 	 *

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

@@ -22,6 +22,13 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  * uses the `UnwrapDelta` class which inherits from the `Delta` class and may overwrite some methods.
  */
 export default class UnwrapDelta extends Delta {
+	/**
+	 * @inheritDoc
+	 */
+	get type() {
+		return 'unwrap';
+	}
+
 	/**
 	 * Position before unwrapped element or `null` if there are no operations in the delta.
 	 *

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

@@ -24,6 +24,13 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  * uses the `WrapDelta` class which inherits from the `Delta` class and may overwrite some methods.
  */
 export default class WrapDelta extends Delta {
+	/**
+	 * @inheritDoc
+	 */
+	get type() {
+		return 'wrap';
+	}
+
 	/**
 	 * Range to wrap or `null` if there are no operations in the delta.
 	 *

+ 6 - 0
packages/ckeditor5-engine/tests/model/delta/attributedelta.js

@@ -404,6 +404,12 @@ describe( 'AttributeDelta', () => {
 		delta = new AttributeDelta();
 	} );
 
+	describe( 'type', () => {
+		it( 'should be equal to attribute', () => {
+			expect( delta.type ).to.equal( 'attribute' );
+		} );
+	} );
+
 	describe( 'key', () => {
 		it( 'should be null if there are no operations in delta', () => {
 			expect( delta.key ).to.be.null;

+ 6 - 0
packages/ckeditor5-engine/tests/model/delta/insertdelta.js

@@ -70,6 +70,12 @@ describe( 'InsertDelta', () => {
 		} );
 	} );
 
+	describe( 'type', () => {
+		it( 'should be equal to insert', () => {
+			expect( insertDelta.type ).to.equal( 'insert' );
+		} );
+	} );
+
 	describe( 'position', () => {
 		it( 'should be null if there are no operations in delta', () => {
 			expect( insertDelta.position ).to.be.null;

+ 6 - 0
packages/ckeditor5-engine/tests/model/delta/markerdelta.js

@@ -136,6 +136,12 @@ describe( 'MarkerDelta', () => {
 		} );
 	} );
 
+	describe( 'type', () => {
+		it( 'should be equal to marker', () => {
+			expect( markerDelta.type ).to.equal( 'marker' );
+		} );
+	} );
+
 	describe( 'getReversed', () => {
 		it( 'should return correct MarkerDelta', () => {
 			markerDelta.addOperation( new MarkerOperation( 'name', null, range, 0 ) );

+ 6 - 0
packages/ckeditor5-engine/tests/model/delta/mergedelta.js

@@ -90,6 +90,12 @@ describe( 'MergeDelta', () => {
 		} );
 	} );
 
+	describe( 'type', () => {
+		it( 'should be equal to merge', () => {
+			expect( mergeDelta.type ).to.equal( 'merge' );
+		} );
+	} );
+
 	describe( 'position', () => {
 		it( 'should be null if there are no operations in delta', () => {
 			expect( mergeDelta.position ).to.be.null;

+ 6 - 0
packages/ckeditor5-engine/tests/model/delta/movedelta.js

@@ -91,6 +91,12 @@ describe( 'MoveDelta', () => {
 		} );
 	} );
 
+	describe( 'type', () => {
+		it( 'should be equal to move', () => {
+			expect( moveDelta.type ).to.equal( 'move' );
+		} );
+	} );
+
 	describe( 'sourcePosition', () => {
 		it( 'should be null if there are no operations in delta', () => {
 			expect( moveDelta.sourcePosition ).to.be.null;

+ 6 - 0
packages/ckeditor5-engine/tests/model/delta/renamedelta.js

@@ -70,6 +70,12 @@ describe( 'RenameDelta', () => {
 		} );
 	} );
 
+	describe( 'type', () => {
+		it( 'should be equal to rename', () => {
+			expect( renameDelta.type ).to.equal( 'rename' );
+		} );
+	} );
+
 	describe( 'getReversed', () => {
 		it( 'should return instance of RenameDelta', () => {
 			let reversed = renameDelta.getReversed();

+ 6 - 0
packages/ckeditor5-engine/tests/model/delta/splitdelta.js

@@ -107,6 +107,12 @@ describe( 'SplitDelta', () => {
 		} );
 	} );
 
+	describe( 'type', () => {
+		it( 'should be equal to split', () => {
+			expect( splitDelta.type ).to.equal( 'split' );
+		} );
+	} );
+
 	describe( 'position', () => {
 		it( 'should be null if there are no operations in delta', () => {
 			expect( splitDelta.position ).to.be.null;

+ 6 - 0
packages/ckeditor5-engine/tests/model/delta/unwrapdelta.js

@@ -78,6 +78,12 @@ describe( 'UnwrapDelta', () => {
 		} );
 	} );
 
+	describe( 'type', () => {
+		it( 'should be equal to unwrap', () => {
+			expect( unwrapDelta.type ).to.equal( 'unwrap' );
+		} );
+	} );
+
 	describe( 'position', () => {
 		it( 'should be null if there are no operations in delta', () => {
 			expect( unwrapDelta.position ).to.be.null;

+ 6 - 0
packages/ckeditor5-engine/tests/model/delta/wrapdelta.js

@@ -112,6 +112,12 @@ describe( 'WrapDelta', () => {
 		} );
 	} );
 
+	describe( 'type', () => {
+		it( 'should be equal to wrap', () => {
+			expect( wrapDelta.type ).to.equal( 'wrap' );
+		} );
+	} );
+
 	describe( 'range', () => {
 		it( 'should be equal to null if there are no operations in delta', () => {
 			expect( wrapDelta.range ).to.be.null;