CKEDITOR.plugins.add("ipsimage",{icons:"ipsimage",hidpi:!0,init:function(c){c.addCommand("ipsImage",{allowedContent:"img",exec:function(b){var a=b.getSelection().getSelectedElement(),c="",f=getComputedStyle(a.$,null).getPropertyValue("float");"A"===a.$.parentNode.tagName&&(c=a.$.parentNode.href,f=getComputedStyle(a.$.parentNode,null).getPropertyValue("float"));var l=a.$.alt;Debug.log(a.$);var e=parseInt(getComputedStyle(a.$,null).getPropertyValue("border-left-width").replace("px","")),m=parseInt(getComputedStyle(a.$,
null).getPropertyValue("margin-left").replace("px","")),g=parseInt(getComputedStyle(a.$,null).getPropertyValue("padding-left").replace("px","")),h=a.$.width,k=a.$.height;if(!_.isUndefined(a.$.style.width)&&""!==a.$.style.width){var d=parseInt(a.$.style.width.replace("px",""));0<d&&(h=d)}_.isUndefined(a.$.style.height)||""===a.$.style.height||(d=parseInt(a.$.style.height.replace("px","")),0<d&&(k=d));b={editorId:b.name,editorUniqueId:b.id,actualWidth:a.$.naturalWidth,actualHeight:a.$.naturalHeight,
width:h+2*(e+g),height:k+2*(e+g),border:e,margin:m,"float":f,link:c,imageAlt:l};Debug.log(b);b="?app\x3dcore\x26module\x3dsystem\x26controller\x3deditor\x26do\x3dimage\x26"+$.param(b);ips.ui.dialog.create({title:ips.getString("editorImageButton"),fixed:!1,size:"narrow",url:b,destructOnClose:!0}).show()}});c.on("doubleclick",function(b){b=CKEDITOR.plugins.ipslink.getSelectedLink(c)||b.data.element;!b.isReadOnly()&&b.is("img")&&(c.getSelection().selectElement(b),c.execCommand("ipsImage"))});c.contextMenu&&
(c.addMenuGroup("ipsImage"),c.addMenuItem("editIpsImage",{label:ips.getString("editorImageButtonEdit"),icon:this.path+"icons"+(CKEDITOR.env.hidpi?"/hidpi":"")+"/ipsimage.png",command:"ipsImage",group:"ipsImage"}),c.contextMenu.addListener(function(b){if(b.getAscendant("img",!0))return{editIpsImage:CKEDITOR.TRISTATE_OFF}}))}});