Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Refactor the _insertMissingModelCaptionElement() by using range API.
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Feb 18, 2019
1 parent b5c3c16 commit 99f114f
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/imagecaption/imagecaptionediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
}
Expand Down

0 comments on commit 99f114f

Please sign in to comment.