Service Portal Pasting Images

In the past I've tried to set up image pasting before with Lars Tange's solution, but that didn't look how I liked it, as it had a specific field for pasting attachments.

I am cleaning up some of my former stories and thought I'd do a cusory search and found this post by Christopher Decugis about how he modified it to work. It works great. Below I'll go over what you need to do if you want this on your portal as well.

We don't have access to the body tag or the top level div, so you will have to do this for every page you want it to work on. We use three forms on our portal, so sc_cat_itemticket, and form. You might have more, be aware you might have to add it for each page you want to allow it work on.

On the top level div that is displayed, you need to add ng-paste="paste($event)" and then in the client script you need to add the following function;

$scope.paste = function(event){
var files = [];
var clipData = event.originalEvent.clipboardData;
angular.forEach(clipData.items, function(item, key){
if(clipData.items[key].type.match(/image.*/)){
files.push(clipData.items[key].getAsFile());
$scope.attachmentHandler.onFileSelect(files);
}
});
}