Browse Source

Enlarge should not go outside the container element.

Piotr Jasiun 8 years ago
parent
commit
d051b655df
1 changed files with 5 additions and 22 deletions
  1. 5 22
      packages/ckeditor5-engine/src/view/range.js

+ 5 - 22
packages/ckeditor5-engine/src/view/range.js

@@ -98,8 +98,8 @@ export default class Range {
 	 * @returns {module:engine/view/range~Range} Enlarged range.
 	 */
 	getEnlarged() {
-		const start = this.start.getLastMatchingPosition( enlargeShrinkStartSkip, { direction: 'backward' } );
-		const end = this.end.getLastMatchingPosition( enlargeShrinkEndSkip );
+		const start = this.start.getLastMatchingPosition( enlargeShrinkSkip, { direction: 'backward' } );
+		const end = this.end.getLastMatchingPosition( enlargeShrinkSkip );
 
 		return new Range( start, end );
 	}
@@ -121,8 +121,8 @@ export default class Range {
 	 * @returns {module:engine/view/range~Range} Shrink range.
 	 */
 	getTrimmed() {
-		let start = this.start.getLastMatchingPosition( enlargeShrinkStartSkip );
-		let end = this.end.getLastMatchingPosition( enlargeShrinkEndSkip, { direction: 'backward' } );
+		let start = this.start.getLastMatchingPosition( enlargeShrinkSkip );
+		let end = this.end.getLastMatchingPosition( enlargeShrinkSkip, { direction: 'backward' } );
 		let nodeAfterStart = start.nodeAfter;
 		let nodeBeforeEnd = end.nodeBefore;
 
@@ -408,27 +408,10 @@ export default class Range {
 }
 
 // Function used by getEnlagred and getShrinked methods.
-function enlargeShrinkStartSkip( value ) {
+function enlargeShrinkSkip( value ) {
 	if ( value.item.is( 'attributeElement' ) || value.item.is( 'uiElement' ) ) {
 		return true;
 	}
 
-	if ( value.item.is( 'containerElement' ) && value.type == 'elementStart' ) {
-		return true;
-	}
-
-	return false;
-}
-
-// Function used by getEnlagred and getShrinked methods.
-function enlargeShrinkEndSkip( value ) {
-	if ( value.item.is( 'attributeElement' ) || value.item.is( 'uiElement' ) ) {
-		return true;
-	}
-
-	if ( value.item.is( 'containerElement' ) && value.type == 'elementEnd' ) {
-		return true;
-	}
-
 	return false;
 }