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

13 lines
78 KiB
JavaScript
Raw Normal View History

var t="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},e=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof t&&t)||Function("return this")(),fails=function(t){try{return!!t()}catch(t){return!0}},r=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),n={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i={f:o&&!n.call({1:2},1)?function propertyIsEnumerable(t){var e=o(this,t);return!!e&&e.enumerable}:n},createPropertyDescriptor=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},a={}.toString,classofRaw=function(t){return a.call(t).slice(8,-1)},c="".split,u=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?c.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 u(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")},s={}.hasOwnProperty,has=function(t,e){return s.call(t,e)},l=e.document,f=isObject(l)&&isObject(l.createElement),documentCreateElement=function(t){return f?l.createElement(t):{}},h=!r&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),p=Object.getOwnPropertyDescriptor,d={f:r?p:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),h)try{return p(t,e)}catch(t){}if(has(t,e))return createPropertyDescriptor(!i.f.call(t,e),t[e])}},anObject=function(t){if(!isObject(t))throw TypeError(String(t)+" is not an object");return t},g=Object.defineProperty,v={f:r?g:function defineProperty(t,e,r){if(anObject(t),e=toPrimitive(e,!0),anObject(r),h)try{return g(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}},y=r?function(t,e,r){return v.f(t,e,createPropertyDescriptor(1,r))}:function(t,e,r){return t[e]=r,t},setGlobal=function(t,r){try{y(e,t,r)}catch(n){e[t]=r}return r},m=e["__core-js_shared__"]||setGlobal("__core-js_shared__",{}),b=Function.toString;"function"!=typeof m.inspectSource&&(m.inspectSource=function(t){return b.call(t)});var w,x,S,E=m.inspectSource,O=e.WeakMap,k="function"==typeof O&&/native code/.test(E(O)),j=createCommonjsModule((function(t){(t.exports=function(t,e){return m[t]||(m[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),A=0,L=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++A+L).toString(36)},R=j("keys"),sharedKey=function(t){return R[t]||(R[t]=uid(t))},P={},_=e.WeakMap;if(k){var I=new _,T=I.get,U=I.has,C=I.set;w=function(t,e){return C.call(I,t,e),e},x=function(t){return T.call(I,t)||{}},S=function(t){return U.call(I,t)}}else{var M=sharedKey("state");P[M]=!0,w=function(t,e){return y(t,M,e),e},x=function(t){return has(t,M)?t[M]:{}},S=function(t){return has(t,M)}}var G,N={set:w,get:x,has:S,enforce:function(t){return S(t)?x(t):w(t,{})},getterFor:function(t){return function(e){var r;if(!isObject(e)||(r=x(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},B=createCommonjsModule((function(t){var r=N.get,n=N.enforce,
2020-09-06 06:32:10 +00:00
/**
* Localizing script for SVG-edit UI.
* @module locale
2020-09-06 06:32:10 +00:00
* @license MIT
*
* @copyright 2010 Narendra Sisodya
2020-09-06 06:32:10 +00:00
* @copyright 2010 Alexis Deveria
*
*/
jQuery;var wa=function(){var t=_asyncToGenerator(regeneratorRuntime.mark((function _callee2(t,e){var r;return regeneratorRuntime.wrap((function _callee2$(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,import("./extensions/ext-".concat(t,"/locale/").concat(e,".js"));case 3:r=n.sent,n.next=12;break;case 6:return n.prev=6,n.t0=n.catch(0),console.error("Missing translation (".concat(e,") for extension ").concat(t," - using 'en'")),n.next=11,import("./extensions/ext-".concat(t,"/locale/en.js"));case 11:r=n.sent;case 12:return n.abrupt("return",r.default);case 13:case"end":return n.stop()}}),_callee2,null,[[0,6]])})));return function loadExtensionTranslation(e,r){return t.apply(this,arguments)}}(),xa={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,_,I;return regeneratorRuntime.wrap((function _callee$(T){for(;;)switch(T.prev=T.next){case 0:if(e=t.origin,(a=t.data)&&["string","object"].includes(_typeof(a))){T.next=3;break}return T.abrupt("return");case 3:if(T.prev=3,"imagelib"===(a="object"===_typeof(a)?a:JSON.parse(a)).namespace){T.next=7;break}return T.abrupt("return");case 7:if(s.includes("*")||s.includes(e)){T.next=10;break}return console.log("Origin ".concat(e," not whitelisted for posting to ").concat(window.origin)),T.abrupt("return");case 10:if(x="href"in a,(w="name"in a)||!g){T.next=15;break}return g=!1,T.abrupt("return");case 15:x&&(m=a.href,a=a.data),r("#dialog_box").hide(),b=w?"meta":a.charAt(0),T.next=28;break;case 20:if(T.prev=20,T.t0=T.catch(3),"string"!=typeof a){T.next=28;break}if("{"===(S=a.charAt(0))||!g){T.next=27;break}return g=!1,T.abrupt("return");case 27:"|"===S&&(E=a.indexOf("|",1),m=a.substr(1,E-1),a=a.substr(E+1),b=a.charAt(0));case 28:T.t1=b,
2020-09-06 06:32:10 +00:00
//# sourceMappingURL=ext-imagelib.js.map