(function(){CKEDITOR.plugins.add("imagepaste",{init:function(f){f.on("paste",function(g){var b=g.data.dataValue,c=document.createElement("div");c.innerHTML=b;for(var b=c.getElementsByTagName("img"),d=0;d<b.length;d++){var h=b[d],e=h.getAttribute("src");if(e){var a=new XMLHttpRequest,k=f.config.uploadUrl;(new FormData).append("imageUrl",e);a.open("POST",k,!0);a.setRequestHeader("Content-Type","application/x-www-form-urlencoded");a.setRequestHeader("X-Requested-With","XMLHttpRequest");a.setRequestHeader("X-Seditio-Csrf",
document.querySelector('meta[name\x3d"csrf-token"]').content||"");a.onload=function(){if(200===a.status)try{var b=JSON.parse(a.responseText);b.uploaded?h.setAttribute("src",b.url):console.log("Error uploading image:",b.error.message)}catch(c){console.log("Invalid JSON response:",a.responseText)}else console.log("Server error:",a.statusText)};a.onerror=function(){console.log("Request failed")};a.send("imageUrl\x3d"+encodeURIComponent(e))}}g.data.dataValue=c.innerHTML})}})})();