I'm using following JS code to add extra information[LINK] to clipboard while copying the text from website:
$(document).on('copy', function(e)
{
var sel = window.getSelection();
if(typeof short_url =='undefined'){
if(window.location.hash=="")
{
var url=document.location.href.split('#')[0];
}
else
{
var url=document.location.href;
}
}else{
var url=short_url;
}
var copyFooter = "<br /><br /><a href='" + url + "'>" + url + "</a>";
var copyHolder = $('<div>', {html: sel+copyFooter, style: {position: 'absolute', left: '-99999px'}});
$('body').append(copyHolder);
sel.selectAllChildren( copyHolder[0] );
window.setTimeout(function() {
copyHolder.remove();
},0);
});
Here the problem is, the text is not copied in exact format(return carriage and line breaks). Instead all text are copied as single line text.
How can the issue be resolved?