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

Changed: Slight refactor in `modelChangePostFixer`.

Szymon Cofalik 8 лет назад
Родитель
Сommit
d7c0347dc2
1 измененных файлов с 5 добавлено и 6 удалено
  1. 5 6
      packages/ckeditor5-list/src/converters.js

+ 5 - 6
packages/ckeditor5-list/src/converters.js

@@ -574,20 +574,19 @@ export function modelChangePostFixer( document ) {
 			return;
 		}
 
-		let sourcePos;
-
-		if ( changes.sourcePosition ) {
+		if ( type == 'remove' ) {
 			const howMany = changes.range.end.offset - changes.range.start.offset;
-			sourcePos = changes.sourcePosition._getTransformedByInsertion( changes.range.start, howMany, true );
-		}
+			const sourcePos = changes.sourcePosition._getTransformedByInsertion( changes.range.start, howMany, true );
 
-		if ( type == 'remove' ) {
 			// Fix list items after the cut-out range.
 			// This fix is needed if items in model after cut-out range have now wrong indents compared to their previous siblings.
 			_fixItemsIndent( sourcePos, document, batch );
 			// This fix is needed if two different nested lists got merged, change types of list items "below".
 			_fixItemsType( sourcePos, false, document, batch );
 		} else if ( type == 'move' ) {
+			const howMany = changes.range.end.offset - changes.range.start.offset;
+			const sourcePos = changes.sourcePosition._getTransformedByInsertion( changes.range.start, howMany, true );
+
 			// Fix list items after the cut-out range.
 			// This fix is needed if items in model after cut-out range have now wrong indents compared to their previous siblings.
 			_fixItemsIndent( sourcePos, document, batch );