Insert inline image inside list to the existing paragraph

When converting from block to inline image inside a list, insert
the image into the existing paragraph instead of wrapping it in
a new paragraph.

Bug: 65924
Change-Id: Iefbb2a9ae536f51987bdd1aa8b7269bf6245d2b0
This commit is contained in:
Moriel Schottlender 2014-06-12 18:04:51 -04:00
parent 0791d86b77
commit e2105be50b

View file

@ -214,6 +214,7 @@ ve.dm.MWImageModel.prototype.updateImageNode = function ( surfaceModel ) {
*/
ve.dm.MWImageModel.prototype.insertImageNode = function ( fragment ) {
var editAttributes, coveredNodes, newNodeRange, newFragment, newNode, i,
nearestContentOffset,
contentToInsert = [],
nodeType = this.getImageNodeType(),
originalAttrs = ve.copy( this.getOriginalImageAttributes() ),
@ -238,7 +239,18 @@ ve.dm.MWImageModel.prototype.insertImageNode = function ( fragment ) {
}
contentToInsert.push( { 'type': '/' + nodeType } );
// Insert the new image
// Check if the image is converted from block to inline, and if so
// put it inside the closest content node
if ( nodeType === 'mwInlineImage' ) {
nearestContentOffset = fragment.getDocument().data.getNearestContentOffset( fragment.getRange().start );
if ( nearestContentOffset > -1 ) {
fragment = fragment.clone( new ve.Range( nearestContentOffset ) );
fragment.insertContent( contentToInsert );
return;
}
}
// Otherwise, proceed normally and
// insert the new image
coveredNodes = fragment
.insertContent( contentToInsert )
.getCoveredNodes();