Resolve image paths when writing to clipboard

Bug: T111927
Change-Id: Idf3b761481454197eecbc0f6cd5cf6199419ca6c
This commit is contained in:
Ed Sanders 2015-09-09 11:02:44 +01:00 committed by Jforrester
parent d67d110d26
commit 036b6c9edf
2 changed files with 15 additions and 2 deletions

View file

@ -90,7 +90,7 @@ ve.dm.MWExtensionNode.static.toDomElements = function ( dataElement, doc, conver
( originalMw && ve.compare( dataElement.attributes.mw, JSON.parse( originalMw ) ) )
) {
// The object in the store is also used for CE rendering so return a copy
return ve.copyDomElements( dataElement.originalDomElements, doc );
els = ve.copyDomElements( dataElement.originalDomElements, doc );
} else {
if ( converter.isForClipboard() && index !== null ) {
// For the clipboard use the current DOM contents so the user has something
@ -102,8 +102,15 @@ ve.dm.MWExtensionNode.static.toDomElements = function ( dataElement, doc, conver
el.setAttribute( 'data-mw', JSON.stringify( dataElement.attributes.mw ) );
els = [ el ];
}
return els;
}
if ( converter.isForClipboard() ) {
// Resolve image sources
$( els ).find( 'img' ).addBack( 'img' ).each( function () {
var $this = $( this );
$this.attr( 'src', ve.resolveUrl( $this.attr( 'src' ), doc ) );
} );
}
return els;
};
ve.dm.MWExtensionNode.static.getHashObject = function ( dataElement ) {

View file

@ -183,6 +183,12 @@ ve.dm.MWTransclusionNode.static.toDomElements = function ( dataElement, doc, con
els[ i ] = wrapTextNode( els[ i ] );
els[ i ].setAttribute( 'data-ve-ignore', 'true' );
}
// Resolve image sources
$( els ).find( 'img' ).addBack( 'img' ).each( function () {
var $this = $( this );
$this.attr( 'src', ve.resolveUrl( $this.attr( 'src' ), doc ) );
} );
}
return els;
};