Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if ( !consumable.consume( modelElement, 'insert' ) ) {
return;
}
const modelPosition = data.range.start;
let viewPosition = conversionApi.mapper.toViewPosition( modelPosition );
// When present - use options.insertPosition function to alter insertion position.
if ( options.insertPosition ) {
viewPosition = options.insertPosition( viewPosition );
}
conversionApi.mapper.bindElements( modelElement, viewElement );
viewWriter.insert( viewPosition, viewElement );
};
}
return ( evt, data, consumable, conversionApi ) => {
const captionElement = data.item;
if ( isImage( captionElement.parent ) && ( captionElement.childCount > 0 ) ) {
if ( !consumable.consume( data.item, 'insert' ) ) {
return;
}
const imageFigure = conversionApi.mapper.toViewElement( data.range.start.parent );
const viewElement = ( elementCreator instanceof ViewElement ) ?
elementCreator.clone( true ) :
elementCreator( data, consumable, conversionApi );
const viewPosition = ViewPosition.createAt( imageFigure, 'end' );
conversionApi.mapper.bindElements( data.item, viewElement );
viewWriter.insert( viewPosition, viewElement );
}
};
}
return;
}
if ( !consumable.consume( modelElement, 'insert' ) ) {
return;
}
const modelPosition = data.range.start;
let viewPosition = conversionApi.mapper.toViewPosition( modelPosition );
if ( options.insertPosition ) {
viewPosition = options.insertPosition( viewPosition )
}
conversionApi.mapper.bindElements( modelElement, viewElement );
viewWriter.insert( viewPosition, viewElement );
};
}