8
0
Просмотр исходного кода

Used position instead of parent as a schema path.

Oskar Wróbel 8 лет назад
Родитель
Сommit
b2721fc1a6
1 измененных файлов с 10 добавлено и 10 удалено
  1. 10 10
      packages/ckeditor5-engine/src/controller/deletecontent.js

+ 10 - 10
packages/ckeditor5-engine/src/controller/deletecontent.js

@@ -111,8 +111,8 @@ function mergeBranches( batch, startPos, endPos ) {
 	// <a><b>x[]</b></a><c><d>{}y</d></c>
 	// will become:
 	// <a><b>xy</b>[]</a><c>{}</c>
-	startPos = Position.createAfter( startParent );
-	endPos = Position.createBefore( endParent );
+	const nextStartPos = Position.createAfter( startParent );
+	let nextEndPos = Position.createBefore( endParent );
 
 	if ( endParent.isEmpty ) {
 		batch.remove( endParent );
@@ -125,20 +125,20 @@ function mergeBranches( batch, startPos, endPos ) {
 
 		// Move the end parent only if needed.
 		// E.g. not in this case: <p>ab</p>[]{}<p>cd</p>
-		if ( !endPos.isEqual( startPos ) ) {
-			batch.move( endParent, startPos );
+		if ( !nextEndPos.isEqual( nextStartPos ) ) {
+			batch.move( endParent, nextStartPos );
 		}
 
 		// To then become:
 		// <a><b>xy</b>[]</a><c>{}</c>
-		batch.merge( startPos );
+		batch.merge( nextStartPos );
 
 		// We need to check and strip disallowed attributes in direct children because after merge
 		// some attributes could end up in a parent where are disallowed.
 		//
 		// e.g. bold is disallowed for <H1>
 		// <h1>Fo{o</h1><p>b}a<b>r</b><p> -> <h1>Fo{}a<b>r</b><h1> -> <h1>Fo{}ar<h1>.
-		removeDisallowedAttributes( batch, Array.from( startParent.getChildren() ), [ startParent ] );
+		removeDisallowedAttributes( batch, Array.from( startParent.getChildren() ), startPos );
 	}
 
 	// Removes empty end ancestors:
@@ -146,16 +146,16 @@ function mergeBranches( batch, startPos, endPos ) {
 	// becomes:
 	// <a>fo[]</a><b><a>{}</a></b>
 	// So we can remove <a> and <b>.
-	while ( endPos.parent.isEmpty ) {
-		const parentToRemove = endPos.parent;
+	while ( nextEndPos.parent.isEmpty ) {
+		const parentToRemove = nextEndPos.parent;
 
-		endPos = Position.createBefore( parentToRemove );
+		nextEndPos = Position.createBefore( parentToRemove );
 
 		batch.remove( parentToRemove );
 	}
 
 	// Continue merging next level.
-	mergeBranches( batch, startPos, endPos );
+	mergeBranches( batch, nextStartPos, nextEndPos );
 }
 
 function shouldAutoparagraph( doc, position ) {