瀏覽代碼

Added isDocumentOperation property to the RemoveOperation.

Oskar Wróbel 8 年之前
父節點
當前提交
a4599c08e9

+ 10 - 0
packages/ckeditor5-engine/src/model/operation/removeoperation.js

@@ -22,6 +22,16 @@ export default class RemoveOperation extends MoveOperation {
 	}
 
 	/**
+	 * Remove operation cannot be applied on element that is not inside the document
+	 * so this will always be a document operation.
+	 *
+	 * @member {Boolean}
+	 */
+	get isDocumentOperation() {
+		return true;
+	}
+
+	/**
 	 * See {@link module:engine/model/operation/operation~Operation#getReversed `Operation#getReversed()`}.
 	 *
 	 * @returns {module:engine/model/operation/reinsertoperation~ReinsertOperation|module:engine/model/operation/nooperation~NoOperation}

+ 11 - 0
packages/ckeditor5-engine/tests/model/operation/removeoperation.js

@@ -140,6 +140,17 @@ describe( 'RemoveOperation', () => {
 		expect( doc.graveyard.getChild( 2 ).name ).to.equal( 'y' );
 	} );
 
+	it( 'should always be a document operation', () => {
+		const op = new RemoveOperation(
+			new Position( root, [ 2 ] ),
+			2,
+			new Position( doc.graveyard, [ 0 ] ),
+			doc.version
+		);
+
+		expect( op.isDocumentOperation ).to.true;
+	} );
+
 	describe( 'toJSON', () => {
 		it( 'should create proper json object', () => {
 			const op = new RemoveOperation(