Przeglądaj źródła

Refactor the _insertMissingModelCaptionElement() by using range API.

Maciej Gołaszewski 7 lat temu
rodzic
commit
9ce3f59c9f

+ 3 - 10
packages/ckeditor5-image/src/imagecaption/imagecaptionediting.js

@@ -190,16 +190,9 @@ export default class ImageCaptionEditing extends Plugin {
 
 				// Check elements with children for nested images.
 				if ( !item.is( 'image' ) && item.childCount ) {
-					// Use the walker to find all nested images despite of their nest level.
-					const walker = model.createRangeOn( item ).getWalker();
-
-					for ( const walkerValue of walker ) {
-						if ( walkerValue.type === 'elementStart' ) {
-							const walkerItem = walkerValue.item;
-
-							if ( walkerItem.is( 'image' ) && !getCaptionFromImage( walkerItem ) ) {
-								imagesWithoutCaption.push( walkerItem );
-							}
+					for ( const nestedItem of model.createRangeIn( item ).getItems() ) {
+						if ( nestedItem.is( 'image' ) && !getCaptionFromImage( nestedItem ) ) {
+							imagesWithoutCaption.push( nestedItem );
 						}
 					}
 				}