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

12 lines
78 KiB
JavaScript
Raw Normal View History

System.register([],(function(t,e){"use strict";return{execute:function(){var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e,r){return t(r={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&&r.path)}},r.exports),r.exports}var check=function(t){return t&&t.Math==Math&&t},n=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof r&&r)||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]})),i={}.propertyIsEnumerable,a=Object.getOwnPropertyDescriptor,c={f:a&&!i.call({1:2},1)?function propertyIsEnumerable(t){var e=a(this,t);return!!e&&e.enumerable}:i},createPropertyDescriptor=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},u={}.toString,classofRaw=function(t){return u.call(t).slice(8,-1)},s="".split,l=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?s.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 l(requireObjectCoercible(t))},isObject=function(t){return"object"==typeof t?null!==t:"function"==typeof t},toPrimitive=function(t,e){if(!isObject(t))return t;var r,n;if(e&&"function"==typeof(r=t.toString)&&!isObject(n=r.call(t)))return n;if("function"==typeof(r=t.valueOf)&&!isObject(n=r.call(t)))return n;if(!e&&"function"==typeof(r=t.toString)&&!isObject(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")},f={}.hasOwnProperty,has=function(t,e){return f.call(t,e)},h=n.document,p=isObject(h)&&isObject(h.createElement),documentCreateElement=function(t){return p?h.createElement(t):{}},d=!o&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),g=Object.getOwnPropertyDescriptor,v={f:o?g:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),d)try{return g(t,e)}catch(t){}if(has(t,e))return createPropertyDescriptor(!c.f.call(t,e),t[e])}},anObject=function(t){if(!isObject(t))throw TypeError(String(t)+" is not an object");return t},y=Object.defineProperty,m={f:o?y:function defineProperty(t,e,r){if(anObject(t),e=toPrimitive(e,!0),anObject(r),d)try{return y(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(t[e]=r.value),t}},b=o?function(t,e,r){return m.f(t,e,createPropertyDescriptor(1,r))}:function(t,e,r){return t[e]=r,t},setGlobal=function(t,e){try{b(n,t,e)}catch(r){n[t]=e}return e},w="__core-js_shared__",x=n[w]||setGlobal(w,{}),S=Function.toString;"function"!=typeof x.inspectSource&&(x.inspectSource=function(t){return S.call(t)});var E,O,k,j=x.inspectSource,A=n.WeakMap,L="function"==typeof A&&/native code/.test(j(A)),R=createCommonjsModule((function(t){(t.exports=function(t,e){return x[t]||(x[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),P=0,_=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++P+_).toString(36)},T=R("keys"),sharedKey=function(t){return T[t]||(T[t]=uid(t))},I={},C=n.WeakMap;if(L){var U=new C,M=U.get,G=U.has,N=U.set;E=function(t,e){return N.call(U,t,e),e},O=function(t){return M.call(U,t)||{}},k=function(t){return G.call(U,t)}}else{var B=sharedKey("state");I[B]=!0,E=function(t,e){return b(t,B,e),e},O=function(t){return has(t,B)?t[B]:{}},k=function(t){return has(t,B)}}var q,D={set:E,get:O,has:k,enforce:function(t){return k(t)?O(t):E(t,{})},getterFor:function(t){return function(e){var r;if(!isObject(e)||(r=O(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},$=
2020-09-06 06:32:10 +00:00
/**
* Localizing script for SVG-edit UI.
* @module locale
2020-09-08 23:35:47 +00:00
* @license MIT
*
* @copyright 2010 Narendra Sisodya
2020-09-08 23:35:47 +00:00
* @copyright 2010 Alexis Deveria
*
*/
jQuery;var za=function(){var t=_asyncToGenerator(regeneratorRuntime.mark((function _callee2(t,r){var n;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(r,".js"));case 3:n=o.sent,o.next=12;break;case 6:return o.prev=6,o.t0=o.catch(0),console.error("Missing translation (".concat(r,") for extension ").concat(t," - using 'en'")),o.next=11,e.import("./extensions/ext-".concat(t,"/locale/en.js"));case 11:n=o.sent;case 12:return o.abrupt("return",n.default);case 13:case"end":return o.stop()}}),_callee2,null,[[0,6]])})));return function loadExtensionTranslation(e,r){return t.apply(this,arguments)}}();t("default",{name:"imagelib",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee2(){var r,n,o,i,a,c,u,s,l,f,h,p,d,g,v,y,m,b,w,x,S;return regeneratorRuntime.wrap((function _callee2$(E){for(;;)switch(E.prev=E.next){case 0:return x=function _showBrowser(){var t=r("#imgbrowse");if(t.length)r("#imgbrowse_holder").show();else{r("<div id=imgbrowse_holder><div id=imgbrowse class=toolbar_button></div></div>").insertAfter("#svg_docprops"),t=r("#imgbrowse");var e=a.select_lib,n=r("<ul id=imglib_opts>").appendTo(t),o=r('<iframe src="javascript:0"/>').prependTo(t).hide().wrap("<div id=lib_framewrap>"),i=r("<h1>").prependTo(t).text(e).css({position:"absolute",top:0,left:0,width:"100%"}),u=r("<button>"+c.common.cancel+"</button>").appendTo(t).on("click touchend",(function(){r("#imgbrowse_holder").hide()})).css({position:"absolute",top:5,right:-10}),s=r("<span>").css({position:"absolute",top:5,left:10}).appendTo(t),l=r("<button hidden>"+a.show_list+"</button>").appendTo(s).on("click touchend",(function(){o.attr("src","about:blank").hide(),n.show(),i.text(e),l.hide()})).css({"margin-right":5}).hide();r("<select><option value=s>"+a.import_single+"</option><option value=m>"+a.import_multi+"</option><option value=o>"+a.open+"</option></select>").appendTo(s).change((function(){switch(p=r(this).val()){case"s":case"o":w(!1);break;case"m":w(!0)}})).css({"margin-top":10}),u.prepend(r.getSvgIcon("cancel",!0)),l.prepend(r.getSvgIcon("tool_imagelib",!0)),a.imgLibs.forEach((function(t){var e=t.name,a=t.url,c=t.description;r("<li>").appendTo(n).text(e).on("click touchend",(function(){o.attr("src",a).show(),i.text(e),n.hide(),l.show()})).append("<span>".concat(c,"</span>"))}))}},w=function _toggleMulti(t){r("#lib_framewrap, #imglib_opts").css({right:t?200:10}),v||(v=r("<div id=imglib_preview>").css({position:"absolute",top:45,right:10,width:180,bottom:45,background:"#fff",overflow:"auto"}).insertAfter("#lib_framewrap"),y=r("<button disabled>Import selected</button>").appendTo("#imgbrowse").on("click touchend",(function(){r.each(d,(function(t){var e=this[0],r=this[1];"svg"===e?u.importSvgString(r):f(r),u.moveSelectedElements(20*t,20*t,!1)})),v.empty(),d=[],r("#imgbrowse_holder").hide()})).css({position:"absolute",bottom:10,right:-10})),v.toggle(t),y.toggle(t)},b=function _onMessage3(){return(b=_asyncToGenerator(regeneratorRuntime.mark((function _callee(t){var e,a,m,b,w,x,S,E,O,k,j,A,L,R,P,_,T;return regeneratorRuntime.wrap((function _callee$(I){for(;;)switch(I.prev=I.next){case 0:if(e=t.origin,(a=t.data)&&["string","object"].includes(_typeof(a))){I.next=3;break}return I.abrupt("return");case 3:if(I.prev=3,"imagelib"===(a="object"===_typeof(a)?a:JSON.parse(a)).namespace){I.next=7;break}return I.abrupt("return");case 7:if(s.includes("*")||s.includes(e)){I.next=10;break}return console.log("Origin ".concat(e," not whitelisted for posting to ").concat(window.origin)),I.abrupt("return");case 10:if(x="href"in a,(w="name"in a)||!g){I.next=15;break}return g=!1,I.abrupt("return");case 15:x&&(m=a.href,a=a.data),r("#dialog_box").hide(),b=w?"meta":a.charAt(0),I.next=28;break;case 20:if(I.prev=20,I.t0=I.catch(3),"string"!=typeof a){I.next=28;break}if("{"===(S=a.charAt(0))||!g){I.next=27;break}return g=!1,I.abrupt("return");case 27:"|"===S&&(E=a.indexOf("|",1),m=a.substr(1,E-1),a=a.substr(E+1),b=a.charAt(0));ca