浏览代码

Added: missing LiveSelection#getLastRange() method.

Szymon Cofalik 9 年之前
父节点
当前提交
028c87c7a9

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

@@ -108,6 +108,13 @@ export default class LiveSelection extends Selection {
 	/**
 	 * @inheritDoc
 	 */
+	getLastRange() {
+		return super.getLastRange() || this._getDefaultRange();
+	}
+
+	/**
+	 * @inheritDoc
+	 */
 	removeAllRanges() {
 		this.destroy();
 		super.removeAllRanges();

+ 5 - 4
packages/ckeditor5-engine/tests/model/liveselection.js

@@ -265,11 +265,12 @@ describe( 'LiveSelection', () => {
 		} );
 	} );
 
-	describe( 'getFirstPosition', () => {
-		it( 'should return start position of default range if no ranges were added', () => {
-			const firstPosition = selection.getFirstPosition();
+	describe( 'getLastRange', () => {
+		it( 'should return default range if no ranges were added', () => {
+			const lastRange = selection.getLastRange();
 
-			expect( firstPosition.isEqual( new Position( root, [ 0, 0 ] ) ) );
+			expect( lastRange.start.isEqual( new Position( root, [ 0, 0 ] ) ) );
+			expect( lastRange.end.isEqual( new Position( root, [ 0, 0 ] ) ) );
 		} );
 	} );