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

12 lines
51 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,f=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 f(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")},l={}.hasOwnProperty,has=function(t,e){return l.call(t,e)},p=n.document,h=isObject(p)&&isObject(p.createElement),documentCreateElement=function(t){return h?p.createElement(t):{}},y=!o&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),d=Object.getOwnPropertyDescriptor,v={f:o?d:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),y)try{return d(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},g=Object.defineProperty,m={f:o?g:function defineProperty(t,e,r){if(anObject(t),e=toPrimitive(e,!0),anObject(r),y)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}},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__",S=n[w]||setGlobal(w,{}),x=Function.toString;"function"!=typeof S.inspectSource&&(S.inspectSource=function(t){return x.call(t)});var O,E,j,P=S.inspectSource,k=n.WeakMap,A="function"==typeof k&&/native code/.test(P(k)),T=createCommonjsModule((function(t){(t.exports=function(t,e){return S[t]||(S[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),L=0,_=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++L+_).toString(36)},I=T("keys"),sharedKey=function(t){return I[t]||(I[t]=uid(t))},R={},C=n.WeakMap;if(A){var M=new C,G=M.get,N=M.has,D=M.set;O=function(t,e){return D.call(M,t,e),e},E=function(t){return G.call(M,t)||{}},j=function(t){return N.call(M,t)}}else{var W=sharedKey("state");R[W]=!0,O=function(t,e){return b(t,W,e),e},E=function(t){return has(t,W)?t[W]:{}},j=function(t){return has(t,W)}}var U,$={set:O,get:E,has:j,enforce:function(t){return j(t)?E(t):O(t,{})},getterFor:function(t){return function(e){var r;if(!isObject(e)||(r=E(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},q=
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
* @copyright 2010 Alexis Deveria
2020-09-08 23:35:47 +00:00
*
*/
jQuery;var ii=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:"eyedropper",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee(){var r,n,o,i,a,c,u,s,f;return regeneratorRuntime.wrap((function _callee$(l){for(;;)switch(l.prev=l.next){case 0:return s=function _getStyle(t){if("eyedropper"!==a.getMode()){var e=o("#tool_eyedropper"),r=null;t.multiselected||!t.elems[0]||["svg","g","use"].includes(t.elems[0].nodeName)?e.addClass("disabled"):(r=t.elems[0],e.removeClass("disabled"),u.fillPaint=r.getAttribute("fill")||"black",u.fillOpacity=r.getAttribute("fill-opacity")||1,u.strokePaint=r.getAttribute("stroke"),u.strokeOpacity=r.getAttribute("stroke-opacity")||1,u.strokeWidth=r.getAttribute("stroke-width"),u.strokeDashArray=r.getAttribute("stroke-dasharray"),u.strokeLinecap=r.getAttribute("stroke-linecap"),u.strokeLinejoin=r.getAttribute("stroke-linejoin"),u.opacity=r.getAttribute("opacity")||1)}},r=e,l.next=4,ii("eyedropper",r.curPrefs.lang);case 4:return n=l.sent,o=t.$,i=t.ChangeElementCommand,a=r.canvas,c=function addToHistory(t){a.undoMgr.addCommandToHistory(t)},u={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},f=[{id:"tool_eyedropper",icon:"eyedropper.png",type:"mode",events:{click:function click(){a.setMode("eyedropper")}}}],l.abrupt("return",{name:n.name,svgicons:"eyedropper-icon.xml",buttons:n.buttons.map((function(t,e){return Object.assign(f[e],t)})),selectedChanged:s,elementChanged:s,mouseDown:function mouseDown(t){if("eyedropper"===a.getMode()){var e=t.event.target;if(!["svg","g","use"].includes(e.nodeName)){var r={},n=function change(t,e,n){r[e]=t.getAttribute(e),t.setAttribute(e,n)};u.fillPaint&&n(e,"fill",u.fillPaint),u.fillOpacity&&n(e,"fill-opacity",u.fillOpacity),u.strokePaint&&n(e,"stroke",u.strokePaint),u.strokeOpacity&&n(e,"stroke-opacity",u.strokeOpacity),u.strokeWidth&&n(e,"stroke-width",u.strokeWidth),u.strokeDashArray&&n(e,"stroke-dasharray",u.strokeDashArray),u.opacity&&n(e,"opacity",u.opacity),u.strokeLinecap&&n(e,"stroke-linecap",u.strokeLinecap),u.strokeLinejoin&&n(e,"stroke-linejoin",u.strokeLinejoin),c(new i(e,r))}}}});case 8:case"end":return l.stop()}}),_callee)})))()}})}}}));