소스 검색

Changed: view.Range#getEnlarged moves positions at the start/end of text node before/after the text node.

Szymon Cofalik 8 년 전
부모
커밋
4d7b68ef2d
1개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 11 2
      packages/ckeditor5-engine/src/view/range.js

+ 11 - 2
packages/ckeditor5-engine/src/view/range.js

@@ -98,8 +98,17 @@ export default class Range {
 	 * @returns {module:engine/view/range~Range} Enlarged range.
 	 */
 	getEnlarged() {
-		const start = this.start.getLastMatchingPosition( enlargeShrinkSkip, { direction: 'backward' } );
-		const end = this.end.getLastMatchingPosition( enlargeShrinkSkip );
+		let start = this.start.getLastMatchingPosition( enlargeShrinkSkip, { direction: 'backward' } );
+		let end = this.end.getLastMatchingPosition( enlargeShrinkSkip );
+
+		// Fix positions, in case if they are in Text node.
+		if ( start.parent.is( 'text' ) && start.isAtStart ) {
+			start = Position.createBefore( start.parent );
+		}
+
+		if ( end.parent.is( 'text' ) && end.isAtEnd ) {
+			end = Position.createAfter( end.parent );
+		}
 
 		return new Range( start, end );
 	}