| ... | ... |
@@ -1 +1,298 @@ |
| 1 |
-tinymce.PluginManager.add("image",function(e){function t(e,t){function n(e,n){r.parentNode&&r.parentNode.removeChild(r),t({width:e,height:n})}var r=document.createElement("img");r.onload=function(){n(Math.max(r.width,r.clientWidth),Math.max(r.height,r.clientHeight))},r.onerror=function(){n()};var i=r.style;i.visibility="hidden",i.position="fixed",i.bottom=i.left=0,i.width=i.height="auto",document.body.appendChild(r),r.src=e}function n(e,t,n){function r(e,n){return n=n||[],tinymce.each(e,function(e){var i={text:e.text||e.title};e.menu?i.menu=r(e.menu):(i.value=e.value,t(i)),n.push(i)}),n}return r(e,n||[])}function r(t){return function(){var n=e.settings.image_list;"string"==typeof n?tinymce.util.XHR.send({url:n,success:function(e){t(tinymce.util.JSON.parse(e))}}):"function"==typeof n?n(t):t(n)}}function i(r){function i(){var e,t,n,r;e=f.find("#width")[0],t=f.find("#height")[0],e&&t&&(n=e.value(),r=t.value(),f.find("#constrain")[0].checked()&&h&&g&&n&&r&&(h!=n?(r=Math.round(n/h*r),isNaN(r)||t.value(r)):(n=Math.round(r/g*n),isNaN(n)||e.value(n))),h=n,g=r)}function o(){function t(t){function n(){t.onload=t.onerror=null,e.selection&&(e.selection.select(t),e.nodeChanged())}t.onload=function(){y.width||y.height||!x||C.setAttribs(t,{width:t.clientWidth,height:t.clientHeight}),n()},t.onerror=n}var n,r;u(),i(),y=tinymce.extend(y,f.toJSON()),y.alt||(y.alt=""),y.title||(y.title=""),""===y.width&&(y.width=null),""===y.height&&(y.height=null),y.style||(y.style=null),y={src:y.src,alt:y.alt,title:y.title,width:y.width,height:y.height,style:y.style,caption:y.caption,"class":y["class"]},e.undoManager.transact(function(){function i(t){return e.schema.getTextBlockElements()[t.nodeName]}if(!y.src)return void(p&&(C.remove(p),e.focus(),e.nodeChanged()));if(""===y.title&&(y.title=null),p?C.setAttribs(p,y):(y.id="__mcenew",e.focus(),e.selection.setContent(C.createHTML("img",y)),p=C.get("__mcenew"),C.setAttrib(p,"id",null)),e.editorUpload.uploadImagesAuto(),y.caption===!1&&C.is(p.parentNode,"figure.image")&&(n=p.parentNode,C.insertAfter(p,n),C.remove(n)),y.caption!==!0)t(p);else if(!C.is(p.parentNode,"figure.image")){r=p,p=p.cloneNode(!0),n=C.create("figure",{"class":"image"}),n.appendChild(p),n.appendChild(C.create("figcaption",{contentEditable:!0},"Caption")),n.contentEditable=!1;var o=C.getParent(r,i);o?C.split(o,r,n):C.replace(n,r),e.selection.select(n)}})}function a(e){return e&&(e=e.replace(/px$/,"")),e}function s(n){var r,i,o,a=n.meta||{};v&&v.value(e.convertURL(this.value(),"src")),tinymce.each(a,function(e,t){f.find("#"+t).value(e)}),a.width||a.height||(r=e.convertURL(this.value(),"src"),i=e.settings.image_prepend_url,o=new RegExp("^(?:[a-z]+:)?//","i"),i&&!o.test(r)&&r.substring(0,i.length)!==i&&(r=i+r),this.value(r),t(e.documentBaseURI.toAbsolute(this.value()),function(e){e.width&&e.height&&x&&(h=e.width,g=e.height,f.find("#width").value(h),f.find("#height").value(g))}))}function l(e){e.meta=f.toJSON()}function c(e){if(e.margin){var t=e.margin.split(" ");switch(t.length){case 1:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[0],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[0];break;case 2:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[1];break;case 3:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[1];break;case 4:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[3]}delete e.margin}return e}function u(){function t(e){return e.length>0&&/^[0-9]+$/.test(e)&&(e+="px"),e}if(e.settings.image_advtab){var n=f.toJSON(),r=C.parseStyle(n.style);r=c(r),n.vspace&&(r["margin-top"]=r["margin-bottom"]=t(n.vspace)),n.hspace&&(r["margin-left"]=r["margin-right"]=t(n.hspace)),n.border&&(r["border-width"]=t(n.border)),f.find("#style").value(C.serializeStyle(C.parseStyle(C.serializeStyle(r))))}}function d(){if(e.settings.image_advtab){var t=f.toJSON(),n=C.parseStyle(t.style);f.find("#vspace").value(""),f.find("#hspace").value(""),n=c(n),(n["margin-top"]&&n["margin-bottom"]||n["margin-right"]&&n["margin-left"])&&(n["margin-top"]===n["margin-bottom"]?f.find("#vspace").value(a(n["margin-top"])):f.find("#vspace").value(""),n["margin-right"]===n["margin-left"]?f.find("#hspace").value(a(n["margin-right"])):f.find("#hspace").value("")),n["border-width"]&&f.find("#border").value(a(n["border-width"])),f.find("#style").value(C.serializeStyle(C.parseStyle(C.serializeStyle(n))))}}var f,p,m,h,g,v,b,y={},C=e.dom,x=e.settings.image_dimensions!==!1;p=e.selection.getNode(),m=C.getParent(p,"figure.image"),m&&(p=C.select("img",m)[0]),p&&("IMG"!=p.nodeName||p.getAttribute("data-mce-object")||p.getAttribute("data-mce-placeholder"))&&(p=null),p&&(h=C.getAttrib(p,"width"),g=C.getAttrib(p,"height"),y={src:C.getAttrib(p,"src"),alt:C.getAttrib(p,"alt"),title:C.getAttrib(p,"title"),"class":C.getAttrib(p,"class"),width:h,height:g,caption:!!m}),r&&(v={type:"listbox",label:"Image list",values:n(r,function(t){t.value=e.convertURL(t.value||t.url,"src")},[{text:"None",value:""}]),value:y.src&&e.convertURL(y.src,"src"),onselect:function(e){var t=f.find("#alt");(!t.value()||e.lastControl&&t.value()==e.lastControl.text())&&t.value(e.control.text()),f.find("#src").value(e.control.value()).fire("change")},onPostRender:function(){v=this}}),e.settings.image_class_list&&(b={name:"class",type:"listbox",label:"Class",values:n(e.settings.image_class_list,function(t){t.value&&(t.textStyle=function(){return e.formatter.getCssText({inline:"img",classes:[t.value]})})})});var w=[{name:"src",type:"filepicker",filetype:"image",label:"Source",autofocus:!0,onchange:s,onbeforecall:l},v];e.settings.image_description!==!1&&w.push({name:"alt",type:"textbox",label:"Image description"}),e.settings.image_title&&w.push({name:"title",type:"textbox",label:"Image Title"}),x&&w.push({type:"container",label:"Dimensions",layout:"flex",direction:"row",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:3,onchange:i,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:3,onchange:i,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}),w.push(b),e.settings.image_caption&&tinymce.Env.ceFalse&&w.push({name:"caption",type:"checkbox",label:"Caption"}),e.settings.image_advtab?(p&&(p.style.marginLeft&&p.style.marginRight&&p.style.marginLeft===p.style.marginRight&&(y.hspace=a(p.style.marginLeft)),p.style.marginTop&&p.style.marginBottom&&p.style.marginTop===p.style.marginBottom&&(y.vspace=a(p.style.marginTop)),p.style.borderWidth&&(y.border=a(p.style.borderWidth)),y.style=e.dom.serializeStyle(e.dom.parseStyle(e.dom.getAttrib(p,"style")))),f=e.windowManager.open({title:"Insert/edit image",data:y,bodyType:"tabpanel",body:[{title:"General",type:"form",items:w},{title:"Advanced",type:"form",pack:"start",items:[{label:"Style",name:"style",type:"textbox",onchange:d},{type:"form",layout:"grid",packV:"start",columns:2,padding:0,alignH:["left","right"],defaults:{type:"textbox",maxWidth:50,onchange:u},items:[{label:"Vertical space",name:"vspace"},{label:"Horizontal space",name:"hspace"},{label:"Border",name:"border"}]}]}],onSubmit:o})):f=e.windowManager.open({title:"Insert/edit image",data:y,body:w,onSubmit:o})}e.on("preInit",function(){function t(e){var t=e.attr("class");return t&&/\bimage\b/.test(t)}function n(e){return function(n){function r(t){t.attr("contenteditable",e?"true":null)}for(var i,o=n.length;o--;)i=n[o],t(i)&&(i.attr("contenteditable",e?"false":null),tinymce.each(i.getAll("figcaption"),r))}}e.parser.addNodeFilter("figure",n(!0)),e.serializer.addNodeFilter("figure",n(!1))}),e.addButton("image",{icon:"image",tooltip:"Insert/edit image",onclick:r(i),stateSelector:"img:not([data-mce-object],[data-mce-placeholder]),figure.image"}),e.addMenuItem("image",{icon:"image",text:"Image",onclick:r(i),context:"insert",prependToContext:!0}),e.addCommand("mceImage",r(i))});
|
|
| 2 | 1 |
\ No newline at end of file |
| 2 |
+tinymce.PluginManager.add("image", function (e) {
|
|
| 3 |
+ function t(e, t) {
|
|
| 4 |
+ function n(e, n) {
|
|
| 5 |
+ r.parentNode && r.parentNode.removeChild(r), t({ width: e, height: n });
|
|
| 6 |
+ } |
|
| 7 |
+ var r = document.createElement("img");
|
|
| 8 |
+ (r.onload = function () {
|
|
| 9 |
+ n(Math.max(r.width, r.clientWidth), Math.max(r.height, r.clientHeight)); |
|
| 10 |
+ }), |
|
| 11 |
+ (r.onerror = function () {
|
|
| 12 |
+ n(); |
|
| 13 |
+ }); |
|
| 14 |
+ var i = r.style; |
|
| 15 |
+ (i.visibility = "hidden"), (i.position = "fixed"), (i.bottom = i.left = 0), (i.width = i.height = "auto"), document.body.appendChild(r), (r.src = e); |
|
| 16 |
+ } |
|
| 17 |
+ function n(e, t, n) {
|
|
| 18 |
+ function r(e, n) {
|
|
| 19 |
+ return ( |
|
| 20 |
+ (n = n || []), |
|
| 21 |
+ tinymce.each(e, function (e) {
|
|
| 22 |
+ var i = { text: e.text || e.title };
|
|
| 23 |
+ e.menu ? (i.menu = r(e.menu)) : ((i.value = e.value), t(i)), n.push(i); |
|
| 24 |
+ }), |
|
| 25 |
+ n |
|
| 26 |
+ ); |
|
| 27 |
+ } |
|
| 28 |
+ return r(e, n || []); |
|
| 29 |
+ } |
|
| 30 |
+ function r(t) {
|
|
| 31 |
+ return function () {
|
|
| 32 |
+ var n = e.settings.image_list; |
|
| 33 |
+ "string" == typeof n |
|
| 34 |
+ ? tinymce.util.XHR.send({
|
|
| 35 |
+ url: n, |
|
| 36 |
+ success: function (e) {
|
|
| 37 |
+ t(tinymce.util.JSON.parse(e)); |
|
| 38 |
+ }, |
|
| 39 |
+ }) |
|
| 40 |
+ : "function" == typeof n |
|
| 41 |
+ ? n(t) |
|
| 42 |
+ : t(n); |
|
| 43 |
+ }; |
|
| 44 |
+ } |
|
| 45 |
+ function i(r) {
|
|
| 46 |
+ function i() {
|
|
| 47 |
+ var e, t, n, r; |
|
| 48 |
+ (e = f.find("#width")[0]),
|
|
| 49 |
+ (t = f.find("#height")[0]),
|
|
| 50 |
+ e && |
|
| 51 |
+ t && |
|
| 52 |
+ ((n = e.value()), |
|
| 53 |
+ (r = t.value()), |
|
| 54 |
+ f.find("#constrain")[0].checked() && h && g && n && r && (h != n ? ((r = Math.round((n / h) * r)), isNaN(r) || t.value(r)) : ((n = Math.round((r / g) * n)), isNaN(n) || e.value(n))),
|
|
| 55 |
+ (h = n), |
|
| 56 |
+ (g = r)); |
|
| 57 |
+ } |
|
| 58 |
+ function o() {
|
|
| 59 |
+ function t(t) {
|
|
| 60 |
+ function n() {
|
|
| 61 |
+ (t.onload = t.onerror = null), e.selection && (e.selection.select(t), e.nodeChanged()); |
|
| 62 |
+ } |
|
| 63 |
+ (t.onload = function () {
|
|
| 64 |
+ y.width || y.height || !x || C.setAttribs(t, { width: t.clientWidth, height: t.clientHeight }), n();
|
|
| 65 |
+ }), |
|
| 66 |
+ (t.onerror = n); |
|
| 67 |
+ } |
|
| 68 |
+ var n, r; |
|
| 69 |
+ u(), |
|
| 70 |
+ i(), |
|
| 71 |
+ (y = tinymce.extend(y, f.toJSON())), |
|
| 72 |
+ y.alt || (y.alt = ""), |
|
| 73 |
+ y.title || (y.title = ""), |
|
| 74 |
+ "" === y.width && (y.width = null), |
|
| 75 |
+ "" === y.height && (y.height = null), |
|
| 76 |
+ y.style || (y.style = null), |
|
| 77 |
+ (y = { src: y.src, alt: y.alt, title: y.title, width: y.width, height: y.height, style: y.style, caption: y.caption, class: y["class"] }),
|
|
| 78 |
+ e.undoManager.transact(function () {
|
|
| 79 |
+ function i(t) {
|
|
| 80 |
+ return e.schema.getTextBlockElements()[t.nodeName]; |
|
| 81 |
+ } |
|
| 82 |
+ if (!y.src) return void (p && (C.remove(p), e.focus(), e.nodeChanged())); |
|
| 83 |
+ if ( |
|
| 84 |
+ ("" === y.title && (y.title = null),
|
|
| 85 |
+ p ? C.setAttribs(p, y) : ((y.id = "__mcenew"), e.focus(), e.selection.setContent(C.createHTML("img", y)), (p = C.get("__mcenew")), C.setAttrib(p, "id", null)),
|
|
| 86 |
+ e.editorUpload.uploadImagesAuto(), |
|
| 87 |
+ y.caption === !1 && C.is(p.parentNode, "figure.image") && ((n = p.parentNode), C.insertAfter(p, n), C.remove(n)), |
|
| 88 |
+ y.caption !== !0) |
|
| 89 |
+ ) |
|
| 90 |
+ t(p); |
|
| 91 |
+ else if (!C.is(p.parentNode, "figure.image")) {
|
|
| 92 |
+ (r = p), (p = p.cloneNode(!0)), (n = C.create("figure", { class: "image" })), n.appendChild(p), n.appendChild(C.create("figcaption", { contentEditable: !0 }, "Caption")), (n.contentEditable = !1);
|
|
| 93 |
+ var o = C.getParent(r, i); |
|
| 94 |
+ o ? C.split(o, r, n) : C.replace(n, r), e.selection.select(n); |
|
| 95 |
+ } |
|
| 96 |
+ }); |
|
| 97 |
+ } |
|
| 98 |
+ function a(e) {
|
|
| 99 |
+ return e && (e = e.replace(/px$/, "")), e; |
|
| 100 |
+ } |
|
| 101 |
+ function s(n) {
|
|
| 102 |
+ var r, |
|
| 103 |
+ i, |
|
| 104 |
+ o, |
|
| 105 |
+ a = n.meta || {};
|
|
| 106 |
+ v && v.value(e.convertURL(this.value(), "src")), |
|
| 107 |
+ tinymce.each(a, function (e, t) {
|
|
| 108 |
+ f.find("#" + t).value(e);
|
|
| 109 |
+ }), |
|
| 110 |
+ a.width || |
|
| 111 |
+ a.height || |
|
| 112 |
+ ((r = e.convertURL(this.value(), "src")), |
|
| 113 |
+ (i = e.settings.image_prepend_url), |
|
| 114 |
+ (o = new RegExp("^(?:[a-z]+:)?//", "i")),
|
|
| 115 |
+ i && !o.test(r) && r.substring(0, i.length) !== i && (r = i + r), |
|
| 116 |
+ this.value(r), |
|
| 117 |
+ t(e.documentBaseURI.toAbsolute(this.value()), function (e) {
|
|
| 118 |
+ e.width && e.height && x && ((h = e.width), (g = e.height), f.find("#width").value(h), f.find("#height").value(g));
|
|
| 119 |
+ })); |
|
| 120 |
+ } |
|
| 121 |
+ function l(e) {
|
|
| 122 |
+ e.meta = f.toJSON(); |
|
| 123 |
+ } |
|
| 124 |
+ function c(e) {
|
|
| 125 |
+ if (e.margin) {
|
|
| 126 |
+ var t = e.margin.split(" ");
|
|
| 127 |
+ switch (t.length) {
|
|
| 128 |
+ case 1: |
|
| 129 |
+ (e["margin-top"] = e["margin-top"] || t[0]), (e["margin-right"] = e["margin-right"] || t[0]), (e["margin-bottom"] = e["margin-bottom"] || t[0]), (e["margin-left"] = e["margin-left"] || t[0]); |
|
| 130 |
+ break; |
|
| 131 |
+ case 2: |
|
| 132 |
+ (e["margin-top"] = e["margin-top"] || t[0]), (e["margin-right"] = e["margin-right"] || t[1]), (e["margin-bottom"] = e["margin-bottom"] || t[0]), (e["margin-left"] = e["margin-left"] || t[1]); |
|
| 133 |
+ break; |
|
| 134 |
+ case 3: |
|
| 135 |
+ (e["margin-top"] = e["margin-top"] || t[0]), (e["margin-right"] = e["margin-right"] || t[1]), (e["margin-bottom"] = e["margin-bottom"] || t[2]), (e["margin-left"] = e["margin-left"] || t[1]); |
|
| 136 |
+ break; |
|
| 137 |
+ case 4: |
|
| 138 |
+ (e["margin-top"] = e["margin-top"] || t[0]), (e["margin-right"] = e["margin-right"] || t[1]), (e["margin-bottom"] = e["margin-bottom"] || t[2]), (e["margin-left"] = e["margin-left"] || t[3]); |
|
| 139 |
+ } |
|
| 140 |
+ delete e.margin; |
|
| 141 |
+ } |
|
| 142 |
+ return e; |
|
| 143 |
+ } |
|
| 144 |
+ function u() {
|
|
| 145 |
+ function t(e) {
|
|
| 146 |
+ return e.length > 0 && /^[0-9]+$/.test(e) && (e += "px"), e; |
|
| 147 |
+ } |
|
| 148 |
+ if (e.settings.image_advtab) {
|
|
| 149 |
+ var n = f.toJSON(), |
|
| 150 |
+ r = C.parseStyle(n.style); |
|
| 151 |
+ (r = c(r)), |
|
| 152 |
+ n.vspace && (r["margin-top"] = r["margin-bottom"] = t(n.vspace)), |
|
| 153 |
+ n.hspace && (r["margin-left"] = r["margin-right"] = t(n.hspace)), |
|
| 154 |
+ n.border && (r["border-width"] = t(n.border)), |
|
| 155 |
+ f.find("#style").value(C.serializeStyle(C.parseStyle(C.serializeStyle(r))));
|
|
| 156 |
+ } |
|
| 157 |
+ } |
|
| 158 |
+ function d() {
|
|
| 159 |
+ if (e.settings.image_advtab) {
|
|
| 160 |
+ var t = f.toJSON(), |
|
| 161 |
+ n = C.parseStyle(t.style); |
|
| 162 |
+ f.find("#vspace").value(""),
|
|
| 163 |
+ f.find("#hspace").value(""),
|
|
| 164 |
+ (n = c(n)), |
|
| 165 |
+ ((n["margin-top"] && n["margin-bottom"]) || (n["margin-right"] && n["margin-left"])) && |
|
| 166 |
+ (n["margin-top"] === n["margin-bottom"] ? f.find("#vspace").value(a(n["margin-top"])) : f.find("#vspace").value(""),
|
|
| 167 |
+ n["margin-right"] === n["margin-left"] ? f.find("#hspace").value(a(n["margin-right"])) : f.find("#hspace").value("")),
|
|
| 168 |
+ n["border-width"] && f.find("#border").value(a(n["border-width"])),
|
|
| 169 |
+ f.find("#style").value(C.serializeStyle(C.parseStyle(C.serializeStyle(n))));
|
|
| 170 |
+ } |
|
| 171 |
+ } |
|
| 172 |
+ var f, |
|
| 173 |
+ p, |
|
| 174 |
+ m, |
|
| 175 |
+ h, |
|
| 176 |
+ g, |
|
| 177 |
+ v, |
|
| 178 |
+ b, |
|
| 179 |
+ y = {},
|
|
| 180 |
+ C = e.dom, |
|
| 181 |
+ x = e.settings.image_dimensions !== !1; |
|
| 182 |
+ (p = e.selection.getNode()), |
|
| 183 |
+ (m = C.getParent(p, "figure.image")), |
|
| 184 |
+ m && (p = C.select("img", m)[0]),
|
|
| 185 |
+ p && ("IMG" != p.nodeName || p.getAttribute("data-mce-object") || p.getAttribute("data-mce-placeholder")) && (p = null),
|
|
| 186 |
+ p && |
|
| 187 |
+ ((h = C.getAttrib(p, "width")), |
|
| 188 |
+ (g = C.getAttrib(p, "height")), |
|
| 189 |
+ (y = { src: C.getAttrib(p, "src"), alt: C.getAttrib(p, "alt"), title: C.getAttrib(p, "title"), class: C.getAttrib(p, "class"), width: h, height: g, caption: !!m })),
|
|
| 190 |
+ r && |
|
| 191 |
+ (v = {
|
|
| 192 |
+ type: "listbox", |
|
| 193 |
+ label: "Image list", |
|
| 194 |
+ values: n( |
|
| 195 |
+ r, |
|
| 196 |
+ function (t) {
|
|
| 197 |
+ t.value = e.convertURL(t.value || t.url, "src"); |
|
| 198 |
+ }, |
|
| 199 |
+ [{ text: "None", value: "" }]
|
|
| 200 |
+ ), |
|
| 201 |
+ value: y.src && e.convertURL(y.src, "src"), |
|
| 202 |
+ onselect: function (e) {
|
|
| 203 |
+ var t = f.find("#alt");
|
|
| 204 |
+ (!t.value() || (e.lastControl && t.value() == e.lastControl.text())) && t.value(e.control.text()), f.find("#src").value(e.control.value()).fire("change");
|
|
| 205 |
+ }, |
|
| 206 |
+ onPostRender: function () {
|
|
| 207 |
+ v = this; |
|
| 208 |
+ }, |
|
| 209 |
+ }), |
|
| 210 |
+ e.settings.image_class_list && |
|
| 211 |
+ (b = {
|
|
| 212 |
+ name: "class", |
|
| 213 |
+ type: "listbox", |
|
| 214 |
+ label: "Class", |
|
| 215 |
+ values: n(e.settings.image_class_list, function (t) {
|
|
| 216 |
+ t.value && |
|
| 217 |
+ (t.textStyle = function () {
|
|
| 218 |
+ return e.formatter.getCssText({ inline: "img", classes: [t.value] });
|
|
| 219 |
+ }); |
|
| 220 |
+ }), |
|
| 221 |
+ }); |
|
| 222 |
+ var w = [{ name: "src", type: "filepicker", filetype: "image", label: "Source", autofocus: !0, onchange: s, onbeforecall: l }, v];
|
|
| 223 |
+ e.settings.image_description !== !1 && w.push({ name: "alt", type: "textbox", label: "Image description" }),
|
|
| 224 |
+ e.settings.image_title && w.push({ name: "title", type: "textbox", label: "Image Title" }),
|
|
| 225 |
+ x && |
|
| 226 |
+ w.push({
|
|
| 227 |
+ type: "container", |
|
| 228 |
+ label: "Dimensions", |
|
| 229 |
+ layout: "flex", |
|
| 230 |
+ direction: "row", |
|
| 231 |
+ align: "center", |
|
| 232 |
+ spacing: 5, |
|
| 233 |
+ items: [ |
|
| 234 |
+ { name: "width", type: "textbox", maxLength: 5, size: 3, onchange: i, ariaLabel: "Width" },
|
|
| 235 |
+ { type: "label", text: "x" },
|
|
| 236 |
+ { name: "height", type: "textbox", maxLength: 5, size: 3, onchange: i, ariaLabel: "Height" },
|
|
| 237 |
+ { name: "constrain", type: "checkbox", checked: !0, text: "Constrain proportions" },
|
|
| 238 |
+ ], |
|
| 239 |
+ }), |
|
| 240 |
+ w.push(b), |
|
| 241 |
+ e.settings.image_caption && tinymce.Env.ceFalse && w.push({ name: "caption", type: "checkbox", label: "Caption" }),
|
|
| 242 |
+ e.settings.image_advtab |
|
| 243 |
+ ? (p && |
|
| 244 |
+ (p.style.marginLeft && p.style.marginRight && p.style.marginLeft === p.style.marginRight && (y.hspace = a(p.style.marginLeft)), |
|
| 245 |
+ p.style.marginTop && p.style.marginBottom && p.style.marginTop === p.style.marginBottom && (y.vspace = a(p.style.marginTop)), |
|
| 246 |
+ p.style.borderWidth && (y.border = a(p.style.borderWidth)), |
|
| 247 |
+ (y.style = e.dom.serializeStyle(e.dom.parseStyle(e.dom.getAttrib(p, "style"))))), |
|
| 248 |
+ (f = e.windowManager.open({
|
|
| 249 |
+ title: "Insert/edit image", |
|
| 250 |
+ data: y, |
|
| 251 |
+ bodyType: "tabpanel", |
|
| 252 |
+ body: [ |
|
| 253 |
+ { title: "General", type: "form", items: w },
|
|
| 254 |
+ {
|
|
| 255 |
+ title: "Advanced", |
|
| 256 |
+ type: "form", |
|
| 257 |
+ pack: "start", |
|
| 258 |
+ items: [ |
|
| 259 |
+ { label: "Style", name: "style", type: "textbox", onchange: d },
|
|
| 260 |
+ {
|
|
| 261 |
+ type: "form", |
|
| 262 |
+ layout: "grid", |
|
| 263 |
+ packV: "start", |
|
| 264 |
+ columns: 2, |
|
| 265 |
+ padding: 0, |
|
| 266 |
+ alignH: ["left", "right"], |
|
| 267 |
+ defaults: { type: "textbox", maxWidth: 50, onchange: u },
|
|
| 268 |
+ items: [ |
|
| 269 |
+ { label: "Vertical space", name: "vspace" },
|
|
| 270 |
+ { label: "Horizontal space", name: "hspace" },
|
|
| 271 |
+ { label: "Border", name: "border" },
|
|
| 272 |
+ ], |
|
| 273 |
+ }, |
|
| 274 |
+ ], |
|
| 275 |
+ }, |
|
| 276 |
+ ], |
|
| 277 |
+ onSubmit: o, |
|
| 278 |
+ }))) |
|
| 279 |
+ : (f = e.windowManager.open({ title: "Insert/edit image", data: y, body: w, onSubmit: o }));
|
|
| 280 |
+ } |
|
| 281 |
+ e.on("preInit", function () {
|
|
| 282 |
+ function t(e) {
|
|
| 283 |
+ var t = e.attr("class");
|
|
| 284 |
+ return t && /\bimage\b/.test(t); |
|
| 285 |
+ } |
|
| 286 |
+ function n(e) {
|
|
| 287 |
+ return function (n) {
|
|
| 288 |
+ function r(t) {
|
|
| 289 |
+ t.attr("contenteditable", e ? "true" : null);
|
|
| 290 |
+ } |
|
| 291 |
+ for (var i, o = n.length; o--;) (i = n[o]), t(i) && (i.attr("contenteditable", e ? "false" : null), tinymce.each(i.getAll("figcaption"), r));
|
|
| 292 |
+ }; |
|
| 293 |
+ } |
|
| 294 |
+ e.parser.addNodeFilter("figure", n(!0)), e.serializer.addNodeFilter("figure", n(!1));
|
|
| 295 |
+ }), |
|
| 296 |
+ e.addButton("image", { icon: "image", tooltip: "Insert/edit image", onclick: r(i), stateSelector: "img:not([data-mce-object],[data-mce-placeholder]),figure.image" }),
|
|
| 297 |
+ e.addMenuItem("image", { icon: "image", text: "Image", onclick: r(i), context: "insert", prependToContext: !0 }),
|
|
| 298 |
+ e.addCommand("mceImage", r(i));
|
|
| 299 |
+}); |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1 @@ |
| 1 |
+tinymce.PluginManager.add("image",function(e){function t(e,t){function n(e,n){r.parentNode&&r.parentNode.removeChild(r),t({width:e,height:n})}var r=document.createElement("img");r.onload=function(){n(Math.max(r.width,r.clientWidth),Math.max(r.height,r.clientHeight))},r.onerror=function(){n()};var i=r.style;i.visibility="hidden",i.position="fixed",i.bottom=i.left=0,i.width=i.height="auto",document.body.appendChild(r),r.src=e}function n(e,t,n){function r(e,n){return n=n||[],tinymce.each(e,function(e){var i={text:e.text||e.title};e.menu?i.menu=r(e.menu):(i.value=e.value,t(i)),n.push(i)}),n}return r(e,n||[])}function r(t){return function(){var n=e.settings.image_list;"string"==typeof n?tinymce.util.XHR.send({url:n,success:function(e){t(tinymce.util.JSON.parse(e))}}):"function"==typeof n?n(t):t(n)}}function i(r){function i(){var e,t,n,r;e=f.find("#width")[0],t=f.find("#height")[0],e&&t&&(n=e.value(),r=t.value(),f.find("#constrain")[0].checked()&&h&&g&&n&&r&&(h!=n?(r=Math.round(n/h*r),isNaN(r)||t.value(r)):(n=Math.round(r/g*n),isNaN(n)||e.value(n))),h=n,g=r)}function o(){function t(t){function n(){t.onload=t.onerror=null,e.selection&&(e.selection.select(t),e.nodeChanged())}t.onload=function(){y.width||y.height||!x||C.setAttribs(t,{width:t.clientWidth,height:t.clientHeight}),n()},t.onerror=n}var n,r;u(),i(),y=tinymce.extend(y,f.toJSON()),y.alt||(y.alt=""),y.title||(y.title=""),""===y.width&&(y.width=null),""===y.height&&(y.height=null),y.style||(y.style=null),y={src:y.src,alt:y.alt,title:y.title,width:y.width,height:y.height,style:y.style,caption:y.caption,"class":y["class"]},e.undoManager.transact(function(){function i(t){return e.schema.getTextBlockElements()[t.nodeName]}if(!y.src)return void(p&&(C.remove(p),e.focus(),e.nodeChanged()));if(""===y.title&&(y.title=null),p?C.setAttribs(p,y):(y.id="__mcenew",e.focus(),e.selection.setContent(C.createHTML("img",y)),p=C.get("__mcenew"),C.setAttrib(p,"id",null)),e.editorUpload.uploadImagesAuto(),y.caption===!1&&C.is(p.parentNode,"figure.image")&&(n=p.parentNode,C.insertAfter(p,n),C.remove(n)),y.caption!==!0)t(p);else if(!C.is(p.parentNode,"figure.image")){r=p,p=p.cloneNode(!0),n=C.create("figure",{"class":"image"}),n.appendChild(p),n.appendChild(C.create("figcaption",{contentEditable:!0},"Caption")),n.contentEditable=!1;var o=C.getParent(r,i);o?C.split(o,r,n):C.replace(n,r),e.selection.select(n)}})}function a(e){return e&&(e=e.replace(/px$/,"")),e}function s(n){var r,i,o,a=n.meta||{};v&&v.value(e.convertURL(this.value(),"src")),tinymce.each(a,function(e,t){f.find("#"+t).value(e)}),a.width||a.height||(r=e.convertURL(this.value(),"src"),i=e.settings.image_prepend_url,o=new RegExp("^(?:[a-z]+:)?//","i"),i&&!o.test(r)&&r.substring(0,i.length)!==i&&(r=i+r),this.value(r),t(e.documentBaseURI.toAbsolute(this.value()),function(e){e.width&&e.height&&x&&(h=e.width,g=e.height,f.find("#width").value(h),f.find("#height").value(g))}))}function l(e){e.meta=f.toJSON()}function c(e){if(e.margin){var t=e.margin.split(" ");switch(t.length){case 1:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[0],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[0];break;case 2:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[1];break;case 3:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[1];break;case 4:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[3]}delete e.margin}return e}function u(){function t(e){return e.length>0&&/^[0-9]+$/.test(e)&&(e+="px"),e}if(e.settings.image_advtab){var n=f.toJSON(),r=C.parseStyle(n.style);r=c(r),n.vspace&&(r["margin-top"]=r["margin-bottom"]=t(n.vspace)),n.hspace&&(r["margin-left"]=r["margin-right"]=t(n.hspace)),n.border&&(r["border-width"]=t(n.border)),f.find("#style").value(C.serializeStyle(C.parseStyle(C.serializeStyle(r))))}}function d(){if(e.settings.image_advtab){var t=f.toJSON(),n=C.parseStyle(t.style);f.find("#vspace").value(""),f.find("#hspace").value(""),n=c(n),(n["margin-top"]&&n["margin-bottom"]||n["margin-right"]&&n["margin-left"])&&(n["margin-top"]===n["margin-bottom"]?f.find("#vspace").value(a(n["margin-top"])):f.find("#vspace").value(""),n["margin-right"]===n["margin-left"]?f.find("#hspace").value(a(n["margin-right"])):f.find("#hspace").value("")),n["border-width"]&&f.find("#border").value(a(n["border-width"])),f.find("#style").value(C.serializeStyle(C.parseStyle(C.serializeStyle(n))))}}var f,p,m,h,g,v,b,y={},C=e.dom,x=e.settings.image_dimensions!==!1;p=e.selection.getNode(),m=C.getParent(p,"figure.image"),m&&(p=C.select("img",m)[0]),p&&("IMG"!=p.nodeName||p.getAttribute("data-mce-object")||p.getAttribute("data-mce-placeholder"))&&(p=null),p&&(h=C.getAttrib(p,"width"),g=C.getAttrib(p,"height"),y={src:C.getAttrib(p,"src"),alt:C.getAttrib(p,"alt"),title:C.getAttrib(p,"title"),"class":C.getAttrib(p,"class"),width:h,height:g,caption:!!m}),r&&(v={type:"listbox",label:"Image list",values:n(r,function(t){t.value=e.convertURL(t.value||t.url,"src")},[{text:"None",value:""}]),value:y.src&&e.convertURL(y.src,"src"),onselect:function(e){var t=f.find("#alt");(!t.value()||e.lastControl&&t.value()==e.lastControl.text())&&t.value(e.control.text()),f.find("#src").value(e.control.value()).fire("change")},onPostRender:function(){v=this}}),e.settings.image_class_list&&(b={name:"class",type:"listbox",label:"Class",values:n(e.settings.image_class_list,function(t){t.value&&(t.textStyle=function(){return e.formatter.getCssText({inline:"img",classes:[t.value]})})})});var w=[{name:"src",type:"filepicker",filetype:"image",label:"Source",autofocus:!0,onchange:s,onbeforecall:l},v];e.settings.image_description!==!1&&w.push({name:"alt",type:"textbox",label:"Image description"}),e.settings.image_title&&w.push({name:"title",type:"textbox",label:"Image Title"}),x&&w.push({type:"container",label:"Dimensions",layout:"flex",direction:"row",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:3,onchange:i,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:3,onchange:i,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}),w.push(b),e.settings.image_caption&&tinymce.Env.ceFalse&&w.push({name:"caption",type:"checkbox",label:"Caption"}),e.settings.image_advtab?(p&&(p.style.marginLeft&&p.style.marginRight&&p.style.marginLeft===p.style.marginRight&&(y.hspace=a(p.style.marginLeft)),p.style.marginTop&&p.style.marginBottom&&p.style.marginTop===p.style.marginBottom&&(y.vspace=a(p.style.marginTop)),p.style.borderWidth&&(y.border=a(p.style.borderWidth)),y.style=e.dom.serializeStyle(e.dom.parseStyle(e.dom.getAttrib(p,"style")))),f=e.windowManager.open({title:"Insert/edit image",data:y,bodyType:"tabpanel",body:[{title:"General",type:"form",items:w},{title:"Advanced",type:"form",pack:"start",items:[{label:"Style",name:"style",type:"textbox",onchange:d},{type:"form",layout:"grid",packV:"start",columns:2,padding:0,alignH:["left","right"],defaults:{type:"textbox",maxWidth:50,onchange:u},items:[{label:"Vertical space",name:"vspace"},{label:"Horizontal space",name:"hspace"},{label:"Border",name:"border"}]}]}],onSubmit:o})):f=e.windowManager.open({title:"Insert/edit image",data:y,body:w,onSubmit:o})}e.on("preInit",function(){function t(e){var t=e.attr("class");return t&&/\bimage\b/.test(t)}function n(e){return function(n){function r(t){t.attr("contenteditable",e?"true":null)}for(var i,o=n.length;o--;)i=n[o],t(i)&&(i.attr("contenteditable",e?"false":null),tinymce.each(i.getAll("figcaption"),r))}}e.parser.addNodeFilter("figure",n(!0)),e.serializer.addNodeFilter("figure",n(!1))}),e.addButton("image",{icon:"image",tooltip:"Insert/edit image",onclick:r(i),stateSelector:"img:not([data-mce-object],[data-mce-placeholder]),figure.image"}),e.addMenuItem("image",{icon:"image",text:"Image",onclick:r(i),context:"insert",prependToContext:!0}),e.addCommand("mceImage",r(i))});
|
|
| 0 | 2 |
\ No newline at end of file |