mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-03 13:25:05 +01:00
1 line
22 KiB
JavaScript
1 line
22 KiB
JavaScript
!function(){"use strict";var t,e,n,r,i=tinymce.util.Tools.resolve("tinymce.PluginManager"),l=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]},o=function(t){return function(){return t}},a=function(t){return t},u=o(!1),c=o(!0),s=u,f=c,d=function(){return m},m=(r={fold:function(t,e){return t()},is:s,isSome:s,isNone:f,getOr:n=function(t){return t},getOrThunk:e=function(t){return t()},getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:n,orThunk:e,map:d,ap:d,each:function(){},bind:d,flatten:d,exists:s,forall:f,filter:d,equals:t=function(t){return t.isNone()},equals_:t,toArray:function(){return[]},toString:o("none()")},Object.freeze&&Object.freeze(r),r),g=function(n){var t=function(){return n},e=function(){return i},r=function(t){return t(n)},i={fold:function(t,e){return e(n)},is:function(t){return n===t},isSome:f,isNone:s,getOr:t,getOrThunk:t,getOrDie:t,getOrNull:t,getOrUndefined:t,or:e,orThunk:e,map:function(t){return g(t(n))},ap:function(t){return t.fold(d,function(t){return g(t(n))})},each:function(t){t(n)},bind:r,flatten:t,exists:r,forall:r,filter:function(t){return t(n)?i:m},equals:function(t){return t.is(n)},equals_:function(t,e){return t.fold(s,function(t){return e(n,t)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return i},v={some:g,none:d,from:function(t){return null===t||t===undefined?m:g(t)}},p=function(e){return function(t){return function(t){if(null===t)return"null";var e=typeof t;return"object"===e&&Array.prototype.isPrototypeOf(t)?"array":"object"===e&&String.prototype.isPrototypeOf(t)?"string":e}(t)===e}},w=p("string"),h=p("object"),b=p("function"),y=p("number"),O=Array.prototype.push,S=function(t){for(var e=[],n=0,r=t.length;n<r;++n){if(!Array.prototype.isPrototypeOf(t[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+t);O.apply(e,t[n])}return e},A=(Array.prototype.slice,b(Array.from)&&Array.from,function(t){var n=v.none(),e=[],r=function(t){i()?a(t):e.push(t)},i=function(){return n.isSome()},o=function(t){!function(t,e){for(var n=0,r=t.length;n<r;n++)e(t[n],n,t)}(t,a)},a=function(e){n.each(function(t){setTimeout(function(){e(t)},0)})};return t(function(t){n=v.some(t),o(e),e=[]}),{get:r,map:function(n){return A(function(e){r(function(t){e(n(t))})})},isReady:i}}),D={nu:A,pure:function(e){return A(function(t){t(e)})}},x=function(e){var t=function(t){var r;e((r=t,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this;setTimeout(function(){r.apply(n,t)},0)}))},n=function(){return D.nu(t)};return{map:function(r){return x(function(n){t(function(t){var e=r(t);n(e)})})},bind:function(n){return x(function(e){t(function(t){n(t).get(e)})})},anonBind:function(n){return x(function(e){t(function(t){n.get(e)})})},toLazy:n,toCached:function(){var e=null;return x(function(t){null===e&&(e=n()),e.get(t)})},get:t}},T={nu:x,pure:function(e){return x(function(t){t(e)})}},C=function(n){return{is:function(t){return n===t},isValue:c,isError:u,getOr:o(n),getOrThunk:o(n),getOrDie:o(n),or:function(t){return C(n)},orThunk:function(t){return C(n)},fold:function(t,e){return e(n)},map:function(t){return C(t(n))},each:function(t){t(n)},bind:function(t){return t(n)},exists:function(t){return t(n)},forall:function(t){return t(n)},toOption:function(){return v.some(n)}}},_=function(n){return{is:u,isValue:u,isError:c,getOr:a,getOrThunk:function(t){return t()},getOrDie:function(){return t=String(n),function(){throw new Error(t)}();var t},or:function(t){return t},orThunk:function(t){return t()},fold:function(t,e){return t(n)},map:function(t){return _(n)},each:l,bind:function(t){return _(n)},exists:u,forall:c,toOption:v.none}},I={value:C,error:_},U=undefined&&undefined.__assign||function(){return(U=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},N=function(o){return U({},o,{toCached:function(){return N(o.toCached())},bindFuture:function(e){return N(o.bind(function(t){return t.fold(function(t){return T.pure(I.error(t))},function(t){return e(t)})}))},bindResult:function(e){return N(o.map(function(t){return t.bind(e)}))},mapResult:function(e){return N(o.map(function(t){return t.map(e)}))},foldResult:function(e,n){return o.map(function(t){return t.fold(e,n)})},withTimeout:function(t,i){return N(T.nu(function(e){var n=!1,r=window.setTimeout(function(){n=!0,e(I.error(i()))},t);o.get(function(t){n||(window.clearTimeout(r),e(t))})}))}})},P=function(t){return N(T.nu(t))},L=P,R=Object.prototype.hasOwnProperty,k=function(a){return function(){for(var t=new Array(arguments.length),e=0;e<t.length;e++)t[e]=arguments[e];if(0===t.length)throw new Error("Can't merge zero objects");for(var n={},r=0;r<t.length;r++){var i=t[r];for(var o in i)R.call(i,o)&&(n[o]=a(n[o],i[o]))}return n}},E=k(function(t,e){return h(t)&&h(e)?E(t,e):e}),z=k(function(t,e){return e}),j="undefined"!=typeof window?window:Function("return this;")(),B=function(t,e){return function(t,e){for(var n=e!==undefined&&null!==e?e:j,r=0;r<t.length&&n!==undefined&&null!==n;++r)n=n[t[r]];return n}(t.split("."),e)},H={getOrDie:function(t,e){var n=B(t,e);if(n===undefined||null===n)throw t+" not available on this browser";return n}},M=function(){return H.getOrDie("URL")},F=function(t){return M().createObjectURL(t)},G=function(t){M().revokeObjectURL(t)},W=function(t){var e=t.imageList.map(function(t){return{name:"images",type:"selectbox",label:"Image list",items:t}}),n=t.classList.map(function(t){return{name:"classes",type:"selectbox",label:"Class",items:t}});return S([[{name:"src",type:"urlinput",filetype:"image",label:"Source"}],e.toArray(),t.hasDescription?[{name:"alt",type:"input",label:"Image description"}]:[],t.hasImageTitle?[{name:"title",type:"input",label:"Image title"}]:[],t.hasDimensions?[{name:"dimensions",type:"sizeinput"}]:[],[{type:"grid",columns:2,items:S([n.toArray(),t.hasImageCaption?[{name:"caption",type:"checkbox",label:"Show caption"}]:[]])}]])},q=function(t){return{title:"General",type:"form",items:W(t)}},$=W,J=tinymce.util.Tools.resolve("tinymce.util.Promise"),V=tinymce.util.Tools.resolve("tinymce.util.Tools"),X=tinymce.util.Tools.resolve("tinymce.util.XHR"),Z=function(t){return!1!==t.settings.image_dimensions},K=function(t){return!0===t.settings.image_advtab},Q=function(t){return t.getParam("image_prepend_url","")},Y=function(t){return t.getParam("image_class_list")},tt=function(t){return!1!==t.settings.image_description},et=function(t){return!0===t.settings.image_title},nt=function(t){return!0===t.settings.image_caption},rt=function(t){return t.getParam("image_list",!1)},it=function(t){return!!t.getParam("images_upload_url",!1)},ot=function(t){return!!t.getParam("images_upload_handler",!1)},at=function(t){return t.getParam("images_upload_url")},ut=function(t){return t.getParam("images_upload_handler")},ct=function(t){return t.getParam("images_upload_base_path")},lt=function(t){return t.getParam("images_upload_credentials")},st=function(t,e){return Math.max(parseInt(t,10),parseInt(e,10))},ft=function(t,e){var n=document.createElement("img");function r(t){n.parentNode&&n.parentNode.removeChild(n),e(t)}n.onload=function(){var t={width:st(n.width,n.clientWidth),height:st(n.height,n.clientHeight)};r(I.value(t))},n.onerror=function(){r(I.error(undefined))};var i=n.style;i.visibility="hidden",i.position="fixed",i.bottom=i.left="0px",i.width=i.height="auto",document.body.appendChild(n),n.src=t},dt=function(t){return t&&(t=t.replace(/px$/,"")),t},mt=function(t){return 0<t.length&&/^[0-9]+$/.test(t)&&(t+="px"),t},gt=function(t){if(t.margin){var e=String(t.margin).split(" ");switch(e.length){case 1:t["margin-top"]=t["margin-top"]||e[0],t["margin-right"]=t["margin-right"]||e[0],t["margin-bottom"]=t["margin-bottom"]||e[0],t["margin-left"]=t["margin-left"]||e[0];break;case 2:t["margin-top"]=t["margin-top"]||e[0],t["margin-right"]=t["margin-right"]||e[1],t["margin-bottom"]=t["margin-bottom"]||e[0],t["margin-left"]=t["margin-left"]||e[1];break;case 3:t["margin-top"]=t["margin-top"]||e[0],t["margin-right"]=t["margin-right"]||e[1],t["margin-bottom"]=t["margin-bottom"]||e[2],t["margin-left"]=t["margin-left"]||e[1];break;case 4:t["margin-top"]=t["margin-top"]||e[0],t["margin-right"]=t["margin-right"]||e[1],t["margin-bottom"]=t["margin-bottom"]||e[2],t["margin-left"]=t["margin-left"]||e[3]}delete t.margin}return t},pt=function(t,e){var n=rt(t);"string"==typeof n?X.send({url:n,success:function(t){e(JSON.parse(t))}}):"function"==typeof n?n(e):e(n)},ht=function(t,e,n){function r(){n.onload=n.onerror=null,t.selection&&(t.selection.select(n),t.nodeChanged())}n.onload=function(){e.width||e.height||!Z(t)||t.dom.setAttribs(n,{width:n.clientWidth,height:n.clientHeight}),r()},n.onerror=r},bt=function(i){return new J(function(t,e){var n=function r(){return new(H.getOrDie("FileReader"))}();n.onload=function(){t(n.result)},n.onerror=function(){e(n.error.message)},n.readAsDataURL(i)})},yt=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils").DOM,vt=function(t){return t.style.marginLeft&&t.style.marginRight&&t.style.marginLeft===t.style.marginRight?dt(t.style.marginLeft):""},wt=function(t){return t.style.marginTop&&t.style.marginBottom&&t.style.marginTop===t.style.marginBottom?dt(t.style.marginTop):""},Ot=function(t){return t.style.borderWidth?dt(t.style.borderWidth):""},St=function(t,e){return t.hasAttribute(e)?t.getAttribute(e):""},At=function(t,e){return t.style[e]?t.style[e]:""},Dt=function(t){return null!==t.parentNode&&"FIGURE"===t.parentNode.nodeName},xt=function(t,e,n){t.setAttribute(e,n)},Tt=function(t){var e,n,r,i;Dt(t)?(i=(r=t).parentNode,yt.insertAfter(r,i),yt.remove(i)):(e=t,n=yt.create("figure",{"class":"image"}),yt.insertAfter(n,e),n.appendChild(e),n.appendChild(yt.create("figcaption",{contentEditable:!0},"Caption")),n.contentEditable="false")},Ct=function(t,e){var n=t.getAttribute("style"),r=e(null!==n?n:"");0<r.length?(t.setAttribute("style",r),t.setAttribute("data-mce-style",r)):t.removeAttribute("style")},_t=function(t,r){return function(t,e,n){t.style[e]?(t.style[e]=mt(n),Ct(t,r)):xt(t,e,n)}},It=function(t,e){return t.style[e]?dt(t.style[e]):St(t,e)},Ut=function(t,e){var n=mt(e);t.style.marginLeft=n,t.style.marginRight=n},Nt=function(t,e){var n=mt(e);t.style.marginTop=n,t.style.marginBottom=n},Pt=function(t,e){var n=mt(e);t.style.borderWidth=n},Lt=function(t,e){t.style.borderStyle=e},Rt=function(t){return"FIGURE"===t.nodeName},kt=function(t,e){var n=document.createElement("img");return xt(n,"style",e.style),(vt(n)||""!==e.hspace)&&Ut(n,e.hspace),(wt(n)||""!==e.vspace)&&Nt(n,e.vspace),(Ot(n)||""!==e.border)&&Pt(n,e.border),(At(n,"borderStyle")||""!==e.borderStyle)&&Lt(n,e.borderStyle),t(n.getAttribute("style"))},Et=function(t,e){return{src:St(e,"src"),alt:St(e,"alt"),title:St(e,"title"),width:It(e,"width"),height:It(e,"height"),"class":St(e,"class"),style:t(St(e,"style")),caption:Dt(e),hspace:vt(e),vspace:wt(e),border:Ot(e),borderStyle:At(e,"borderStyle")}},zt=function(t,e,n,r,i){n[r]!==e[r]&&i(t,r,n[r])},jt=function(r,i){return function(t,e,n){r(t,n),Ct(t,i)}},Bt=function(t,e,n){var r=Et(t,n);zt(n,r,e,"caption",function(t,e,n){return Tt(t)}),zt(n,r,e,"src",xt),zt(n,r,e,"alt",xt),zt(n,r,e,"title",xt),zt(n,r,e,"width",_t(0,t)),zt(n,r,e,"height",_t(0,t)),zt(n,r,e,"class",xt),zt(n,r,e,"style",jt(function(t,e){return xt(t,"style",e)},t)),zt(n,r,e,"hspace",jt(Ut,t)),zt(n,r,e,"vspace",jt(Nt,t)),zt(n,r,e,"border",jt(Pt,t)),zt(n,r,e,"borderStyle",jt(Lt,t))},Ht=function(t,e){var n=t.dom.styles.parse(e),r=gt(n),i=t.dom.styles.parse(t.dom.styles.serialize(r));return t.dom.styles.serialize(i)},Mt=function(t){var e=t.selection.getNode(),n=t.dom.getParent(e,"figure.image");return n?t.dom.select("img",n)[0]:e&&("IMG"!==e.nodeName||e.getAttribute("data-mce-object")||e.getAttribute("data-mce-placeholder"))?null:e},Ft=function(e,t){var n=e.dom,r=n.getParent(t.parentNode,function(t){return e.schema.getTextBlockElements()[t.nodeName]});return r?n.split(r,t):t},Gt=function(e,t){var n=function(t,e){var n=document.createElement("img");if(Bt(t,z(e,{caption:!1}),n),xt(n,"alt",e.alt),e.caption){var r=yt.create("figure",{"class":"image"});return r.appendChild(n),r.appendChild(yt.create("figcaption",{contentEditable:!0},"Caption")),r.contentEditable="false",r}return n}(function(t){return Ht(e,t)},t);e.dom.setAttrib(n,"data-mce-id","__mcenew"),e.focus(),e.selection.setContent(n.outerHTML);var r=e.dom.select('*[data-mce-id="__mcenew"]')[0];if(e.dom.setAttrib(r,"data-mce-id",null),Rt(r)){var i=Ft(e,r);e.selection.select(i)}else e.selection.select(r)},Wt=function(t,e){var n=Mt(t);n?e.src?function(e,t){var n,r=Mt(e);if(Bt(function(t){return Ht(e,t)},t,r),n=r,e.dom.setAttrib(n,"src",n.getAttribute("src")),Rt(r.parentNode)){var i=r.parentNode;Ft(e,i),e.selection.select(r.parentNode)}else e.selection.select(r),ht(e,t,r)}(t,e):function(t,e){if(e){var n=t.dom.is(e.parentNode,"figure.image")?e.parentNode:e;t.dom.remove(n),t.focus(),t.nodeChanged(),t.dom.isEmpty(t.getBody())&&(t.setContent(""),t.selection.setCursorLocation())}}(t,n):e.src&&Gt(t,e)},qt=function(t){return w(t.value)?t.value:""},$t=function(t,i){var o=[];return V.each(t,function(t){var e=w(t.text)?t.text:w(t.title)?t.title:"";if(t.menu!==undefined){var n=$t(t.menu,i);o.push({text:e,items:n})}else{var r=i(t);o.push({text:e,value:r})}}),o},Jt=function(e){return void 0===e&&(e=qt),function(t){return t?v.from(t).map(function(t){return $t(t,e)}):v.none()}},Vt=function(t,n){return function(t,e){for(var n=0;n<t.length;n++){var r=e(t[n],n);if(r.isSome())return r}return v.none()}(t,function(t){return e=t,Object.prototype.hasOwnProperty.call(e,"items")?Vt(t.items,n):t.value===n?v.some(t):v.none();var e})},Xt=Jt,Zt=function(t){return Jt(qt)(t)},Kt=function(t,e){return t.bind(function(t){return Vt(t,e)})},Qt=function(){};function Yt(u){var e=function(t,r,i,e){var o,n;(o=function a(){return new(H.getOrDie("XMLHttpRequest"))}()).open("POST",u.url),o.withCredentials=u.credentials,o.upload.onprogress=function(t){e(t.loaded/t.total*100)},o.onerror=function(){i("Image upload failed due to a XHR Transport error. Code: "+o.status)},o.onload=function(){var t,e,n;o.status<200||300<=o.status?i("HTTP Error: "+o.status):(t=JSON.parse(o.responseText))&&"string"==typeof t.location?r((e=u.basePath,n=t.location,e?e.replace(/\/$/,"")+"/"+n.replace(/^\//,""):n)):i("Invalid JSON: "+o.responseText)},(n=new FormData).append("file",t.blob(),t.filename()),o.send(n)};return u=V.extend({credentials:!1,handler:e},u),{upload:function(t){return u.url||u.handler!==e?(r=t,i=u.handler,new J(function(t,e){try{i(r,t,e,Qt)}catch(n){e(n.message)}})):J.reject("Upload url missing from the settings.");var r,i}}}var te=function(t){return{title:"Advanced",items:[{type:"input",label:"Style",name:"style"},{type:"grid",columns:2,items:[{type:"input",label:"Vertical space",name:"vspace"},{type:"input",label:"Horizontal space",name:"hspace"},{type:"input",label:"Border width",name:"border"},{type:"selectbox",name:"borderstyle",label:"Border style",items:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},{text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]}]}]}},ee=function(n){var e,t,r=Xt(function(t){return n.convertURL(t.value||t.url,"src")}),i=T.nu(function(e){pt(n,function(t){e(r(t).map(function(t){return S([[{text:"None",value:""}],t])}))})}),o=Zt(Y(n)),a=K(n),u=it(n),c=ot(n),l=(t=Mt(e=n))?Et(function(t){return Ht(e,t)},t):{src:"",alt:"",title:"",width:"",height:"","class":"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:""},s=tt(n),f=et(n),d=Z(n),m=nt(n),g=at(n),p=ct(n),h=lt(n),b=ut(n),y=v.some(Q(n)).filter(function(t){return w(t)&&0<t.length});return i.map(function(t){return{image:l,imageList:t,classList:o,hasAdvTab:a,hasUploadUrl:u,hasUploadHandler:c,hasDescription:s,hasImageTitle:f,hasDimensions:d,hasImageCaption:m,url:g,basePath:p,credentials:h,handler:b,prependURL:y}})},ne=function(t){return{title:"Upload",type:"form",items:[{type:"dropzone",name:"fileinput",flex:!0}]}},re=function(t){return{src:{value:t.src,meta:{}},images:t.src,alt:t.alt,title:t.title,dimensions:{width:t.width,height:t.height},classes:t["class"],caption:t.caption?"checked":"unchecked",style:t.style,vspace:t.vspace,border:t.border,hspace:t.hspace,borderstyle:t.borderStyle,fileinput:[]}},ie=function(t){return{src:t.src.value,alt:t.alt,title:t.title,width:t.dimensions.width,height:t.dimensions.height,"class":t.classes,style:t.style,caption:"checked"===t.caption,hspace:t.hspace,vspace:t.vspace,border:t.border,borderStyle:t.borderstyle}},oe=function(t,e){var n,r,i=e.getData();(n=t,r=i.src.value,/^(?:[a-zA-Z]+:)?\/\//.test(r)?v.none():n.prependURL.bind(function(t){return r.substring(0,t.length)!==t?v.some(t+r):v.none()})).each(function(t){e.setData({src:{value:t,meta:i.src.meta}})})},ae=function(t,e){(function(t,e){var n=e.src.meta;if(n===undefined)return v.none();var r=E({},e);return t.hasDescription&&w(n.alt)&&(r.alt=n.alt),t.hasImageTitle&&w(n.title)&&(r.title=n.title),t.hasDimensions&&(w(n.width)&&(r.dimensions.width=n.width),w(n.height)&&(r.dimensions.height=n.height)),w(n["class"])&&Kt(t.classList,n["class"]).each(function(t){r.classes=t.value}),t.hasAdvTab&&(w(n.vspace)&&(r.vspace=n.vspace),w(n.border)&&(r.border=n.border),w(n.hspace)&&(r.hspace=n.hspace),w(n.borderstyle)&&(r.borderstyle=n.borderstyle)),v.some(r)})(t,e.getData()).each(function(t){return e.setData(t)})},ue=function(t,e,n,r){var i,o,a,u,c,l,s,f,d,m,g,p;oe(e,r),ae(e,r),i=t,o=e,a=n,c=(u=r).getData(),l=c.src.value,(s=c.src.meta||{}).width||s.height||!o.hasDimensions||i.imageSize(l).get(function(t){t.each(function(t){a.open&&u.setData({dimensions:t})})}),f=e,d=n,g=(m=r).getData(),p=Kt(f.imageList,g.src.value),d.prevImage=p,m.setData({images:p.map(function(t){return t.value}).getOr("")})},ce=function(t,e,n){var r,i,o,a,u,c=gt(t(n.style)),l=E({},n);return l.vspace=(r=c)["margin-top"]&&r["margin-bottom"]&&r["margin-top"]===r["margin-bottom"]?dt(String(r["margin-top"])):"",l.hspace=(i=c)["margin-right"]&&i["margin-left"]&&i["margin-right"]===i["margin-left"]?dt(String(i["margin-right"])):"",l.border=(o=c)["border-width"]?dt(String(o["border-width"])):"",l.borderstyle=(a=c)["border-style"]?String(a["border-style"]):"",l.style=(u=e)(t(u(c))),l},le=function(h,b,y){return function(t,e){var n,r,i,o,a,u,c,l,s,f,d,m,g,p;"src"===e.name?ue(h,b,y,t):"images"===e.name?(s=h,f=b,d=y,g=(m=t).getData(),(p=Kt(f.imageList,g.images)).each(function(t){""===g.alt||d.prevImage.map(function(t){return t.text===g.alt}).getOr(!1)?""===t.value?m.setData({src:t,alt:d.prevAlt}):m.setData({src:t,alt:t.text}):m.setData({src:t})}),d.prevImage=p,ue(s,f,d,m)):"alt"===e.name?y.prevAlt=t.getData().alt:"style"===e.name?(a=h,c=(u=t).getData(),l=ce(a.parseStyle,a.serializeStyle,c),u.setData(l)):"vspace"===e.name||"hspace"===e.name||"border"===e.name||"borderstyle"===e.name?(n=h,r=t,i=E(re(b.image),r.getData()),o=kt(n.normalizeCss,ie(i)),r.setData({style:o})):"fileinput"===e.name&&function(n,r,i,o){var t=o.getData();o.block("Uploading image");var a=t.fileinput[0],u=F(a),c=Yt({url:r.url,basePath:r.basePath,credentials:r.credentials,handler:r.handler}),l=function(){o.unblock(),G(u)};bt(a).then(function(t){var e=n.createBlobCache(a,u,t);c.upload(e).then(function(t){o.setData({src:{value:t,meta:{}}}),o.showTab("General"),ue(n,r,i,o),l()})["catch"](function(t){l(),n.alertErr(o,t)})})}(h,b,y,t)}},se=function(o){return function(t){var e,n,r,i={prevImage:Kt((e=t).imageList,e.image.src),prevAlt:e.image.alt,open:!0};return{title:"Insert/Edit Image",size:"normal",body:(r=t,r.hasAdvTab||r.hasUploadUrl||r.hasUploadHandler?{type:"tabpanel",tabs:S([[q(r)],r.hasAdvTab?[te(r)]:[],r.hasUploadUrl||r.hasUploadHandler?[ne(r)]:[]])}:{type:"panel",items:$(r)}),buttons:[{type:"submit",name:"ok",text:"Ok",primary:!0},{type:"cancel",name:"cancel",text:"Cancel"}],initialData:re(t.image),onSubmit:o.onSubmit(t),onChange:le(o,t,i),onClose:(n=i,function(){n.open=!1})}}},fe=function(e){var n,r,i,o,a,u,c,t={onSubmit:(c=e,function(n){return function(t){var e=E(re(n.image),t.getData());c.undoManager.transact(function(){Wt(c,ie(e))}),c.editorUpload.uploadImagesAuto(),t.close()}}),imageSize:(u=e,function(t){return L(function(n){ft(u.documentBaseURI.toAbsolute(t),function(t){var e=t.bind(function(t){return(w(t.width)||y(t.width))&&(w(t.height)||y(t.height))?I.value({width:String(t.width),height:String(t.height)}):I.error(undefined)});n(e)})})}),createBlobCache:(a=e,function(t,e,n){return a.editorUpload.blobCache.create({blob:t,blobUri:e,name:t.name?t.name.replace(/\.[^\.]+$/,""):null,base64:n.split(",")[1]})}),alertErr:(o=e,function(t,e){o.windowManager.alert(e,l,t.close)}),normalizeCss:(i=e,function(t){return Ht(i,t)}),parseStyle:(r=e,function(t){return r.dom.parseStyle(t)}),serializeStyle:(n=e,function(t,e){return n.dom.serializeStyle(t,e)})};return{open:function(){return ee(e).map(se(t)).get(function(t){e.windowManager.open(t)})}}},de=function(t){t.addCommand("mceImage",fe(t).open)},me=function(o){return function(t){for(var e,n,r=t.length,i=function(t){t.attr("contenteditable",o?"true":null)};r--;)e=t[r],(n=e.attr("class"))&&/\bimage\b/.test(n)&&(e.attr("contenteditable",o?"false":null),V.each(e.getAll("figcaption"),i))}},ge=function(t){t.on("preInit",function(){t.parser.addNodeFilter("figure",me(!0)),t.serializer.addNodeFilter("figure",me(!1))})},pe=function(e){e.ui.registry.addToggleButton("image",{icon:"image",tooltip:"Insert/edit image",onAction:fe(e).open,onSetup:function(t){return e.selection.selectorChangedWithUnbind("img:not([data-mce-object],[data-mce-placeholder]),figure.image",t.setActive).unbind}}),e.ui.registry.addMenuItem("image",{icon:"image",text:"Image",onAction:fe(e).open}),e.ui.registry.addContextMenu("image",{update:function(t){return t.src?["image"]:[]}})};i.add("image",function(t){ge(t),pe(t),de(t)}),function he(){}}(); |