svgedit/dist/editor/system/extensions/ext-server_opensave/ext-server_opensave.js

20 lines
138 KiB
JavaScript
Raw Normal View History

2020-09-10 06:24:38 +00:00
System.register([],(function(t,e){"use strict";return{execute:function(){var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e,n){return t(n={path:e,exports:{},require:function(t,e){return function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&n.path)}},n.exports),n.exports}var check=function(t){return t&&t.Math==Math&&t},i=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof n&&n)||Function("return this")(),fails=function(t){try{return!!t()}catch(t){return!0}},o=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),s={}.propertyIsEnumerable,l=Object.getOwnPropertyDescriptor,u={f:l&&!s.call({1:2},1)?function propertyIsEnumerable(t){var e=l(this,t);return!!e&&e.enumerable}:s},createPropertyDescriptor=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},h={}.toString,classofRaw=function(t){return h.call(t).slice(8,-1)},p="".split,d=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?p.call(t,""):Object(t)}:Object,requireObjectCoercible=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},toIndexedObject=function(t){return d(requireObjectCoercible(t))},isObject=function(t){return"object"==typeof t?null!==t:"function"==typeof t},toPrimitive=function(t,e){if(!isObject(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!isObject(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!isObject(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!isObject(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")},v={}.hasOwnProperty,has=function(t,e){return v.call(t,e)},g=i.document,b=isObject(g)&&isObject(g.createElement),documentCreateElement=function(t){return b?g.createElement(t):{}},_=!o&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),w=Object.getOwnPropertyDescriptor,P={f:o?w:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),_)try{return w(t,e)}catch(t){}if(has(t,e))return createPropertyDescriptor(!u.f.call(t,e),t[e])}},anObject=function(t){if(!isObject(t))throw TypeError(String(t)+" is not an object");return t},C=Object.defineProperty,k={f:o?C:function defineProperty(t,e,n){if(anObject(t),e=toPrimitive(e,!0),anObject(n),_)try{return C(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},E=o?function(t,e,n){return k.f(t,e,createPropertyDescriptor(1,n))}:function(t,e,n){return t[e]=n,t},setGlobal=function(t,e){try{E(i,t,e)}catch(n){i[t]=e}return e},S="__core-js_shared__",T=i[S]||setGlobal(S,{}),A=Function.toString;"function"!=typeof T.inspectSource&&(T.inspectSource=function(t){return A.call(t)});var O,M,V,B=T.inspectSource,R=i.WeakMap,I="function"==typeof R&&/native code/.test(B(R)),j=createCommonjsModule((function(t){(t.exports=function(t,e){return T[t]||(T[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),N=0,D=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++N+D).toString(36)},L=j("keys"),sharedKey=function(t){return L[t]||(L[t]=uid(t))},G={},W=i.WeakMap;if(I){var z=new W,X=z.get,$=z.has,q=z.set;O=function(t,e){return q.call(z,t,e),e},M=function(t){return X.call(z,t)||{}},V=function(t){return $.call(z,t)}}else{var U=sharedKey("state");G[U]=!0,O=function(t,e){return E(t,U,e),e},M=function(t){return has(t,U)?t[U]:{}},V=function(t){return has(t,U)}}var H,Y,Q={set:O,get:M,has:V,enforce:function(t){return V(t)?M(t):O(t,{})},getterFor:function(t){return function(e){var n;if(!isObject(e)||(n=M(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},
/**
* For parsing color values.
* @module RGBColor
* @author Stoyan Stefanov <sstoo@gmail.com>
* @see https://www.phpied.com/rgb-color-parser-in-javascript/
* @license MIT
*/
var Zi={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},Ji=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function process(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return n.map((function(t){return Number.parseInt(t)}))}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function process(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return n.map((function(t){return Number.parseInt(t,16)}))}},{re:/^(\w)(\w)(\w)$/,example:["#fb0","f0f"],process:function process(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return n.map((function(t){return Number.parseInt(t+t,16)}))}}],Ki=function(){function RGBColor(t){var e=this;_classCallCheck(this,RGBColor),this.ok=!1,"#"===t.charAt(0)&&(t=t.substr(1,6)),(t=(t=t.replace(/ /g,"")).toLowerCase())in Zi&&(t=Zi[t]),Ji.forEach((function(n){var i=n.re,o=n.process,s=i.exec(t);if(s){var l=_slicedToArray(o.apply(void 0,_toConsumableArray(s)),3),u=l[0],h=l[1],p=l[2];Object.assign(e,{r:u,g:h,b:p}),e.ok=!0}})),this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b}return _createClass(RGBColor,[{key:"toRGB",value:function toRGB(){return"rgb("+this.r+", "+this.g+", "+this.b+")"}},{key:"toH
/**
* Localizing script for SVG-edit UI.
* @module locale
* @license MIT
*
* @copyright 2010 Narendra Sisodya
* @copyright 2010 Alexis Deveria
*
*/
jQuery;var po=function(){var t=_asyncToGenerator(regeneratorRuntime.mark((function _callee2(t,n){var i;return regeneratorRuntime.wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,e.import("./extensions/ext-".concat(t,"/locale/").concat(n,".js"));case 3:i=o.sent,o.next=12;break;case 6:return o.prev=6,o.t0=o.catch(0),console.error("Missing translation (".concat(n,") for extension ").concat(t," - using 'en'")),o.next=11,e.import("./extensions/ext-".concat(t,"/locale/en.js"));case 11:i=o.sent;case 12:return o.abrupt("return",i.default);case 13:case"end":return o.stop()}}),_callee2,null,[[0,6]])})));return function loadExtensionTranslation(e,n){return t.apply(this,arguments)}}();t("default",{name:"server_opensave",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee5(){var n,i,o,s,l,u,h,p,d,v,g,b,_,w,P,C,k,E,S,T,A,O,M,V;return regeneratorRuntime.wrap((function _callee5$(B){for(;;)switch(B.prev=B.next){case 0:return V=function _rebuildInput(t){t.empty();var e=n('<input type="file" name="svg_file">').appendTo(t);function submit(){return _submit.apply(this,arguments)}function _submit(){return(_submit=_asyncToGenerator(regeneratorRuntime.mark((function _callee4(){return regeneratorRuntime.wrap((function _callee4$(e){for(;;)switch(e.prev=e.next){case 0:return t.submit(),V(t),e.next=4,n.process_cancel(l.uploading);case 4:k=!0,n("#dialog_box").hide();case 6:case"end":return e.stop()}}),_callee4)})))).apply(this,arguments)}t[0]===A[0]?e.change(_asyncToGenerator(regeneratorRuntime.mark((function _callee2(){return regeneratorRuntime.wrap((function _callee2$(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.openPrep();case 2:if(e.sent){e.next=6;break}return V(t),e.abrupt("return");case 6:return e.next=8,submit();case 8:case"end":return e.stop()}}),_callee2)})))):e.change(_asyncToGenerator(regeneratorRuntime.mark((function _callee3(){return regeneratorRuntime.wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,submit();case 2:case"end":return t.stop()}}),_callee3)}))))},w=function _clientDownloadSuppor(t,e,i){return!p&&!d&&(!(""!==n("<a>")[0].download)&&(n("<a>hidden</a>").attr({download:(t||"image")+e,href:i}).css("display","none").appendTo("body")[0].click(),!0))},_=function _xhtmlEscape(t){return t.replace(/&(?!amp;)/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")},b=function _getFileNameFromTitle(){return g.getDocumentTitle().trim().replace(/[/\\:*?"<>|]/g,"_")},n=t.$,i=t.decode64,o=t.encode64,s=e,B.next=8,po("server_opensave",s.curPrefs.lang);case 8:if(l=B.sent,u=s.curConfig,h=u.extPath,p=u.avoidClientSide,d=u.avoidClientSideDownload,v=u.avoidClientSideOpen,g=s.canvas,P=h+"filesave.php",C=h+"filesave.php",k=!1,n('<iframe name="output_frame" title="'.concat(l.hiddenframe,'"\n style="width: 0; height: 0;" src="data:text/html;base64,PGh0bWw+"/>')).appendTo("body"),s.setCustomHandlers({save:function save(t,e){var i='<?xml version="1.0" encoding="UTF-8"?>\n'+e,s=b();w(s,".svg","data:image/svg+xml;charset=UTF-8;base64,"+o(i))||n("<form>").attr({method:"post",action:P,target:"output_frame"}).append('\n <input type="hidden" name="output_svg" value="'.concat(_(i),'">\n <input type="hidden" name="filename" value="').concat(_(s),'">\n ')).appendTo("body").submit().remove()},exportPDF:function exportPDF(t,e){var i=b(),o=e.output;w(i,".pdf",o)||n("<form>").attr({method:"post",action:C,target:"output_frame"}).append('\n <input type="hidden" name="output_img" value="'.concat(o,'">\n <input type="hidden" name="mime" value="application/pdf">\n <input type="hidden" name="filename" value="').concat(_(i),'">\n ')).appendTo("body").submit().remove()},exportImage:function exportImage(t,e){return _asyncToGenerator(regeneratorRuntime.mark((function _callee(){var t,i,o,s,l,u,h,p,d;return regeneratorRuntime.wrap((function _callee$(v){for(;;)switch(v.prev=v.next){case 0:return t=e.issues,i=e.mimeType,o=e.quality,n("#export_canvas").length||n("<canvas>",{id:"export_c