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

11 lines
43 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")},f={}.hasOwnProperty,has=function(t,e){return f.call(t,e)},s=e.document,l=isObject(s)&&isObject(s.createElement),documentCreateElement=function(t){return l?s.createElement(t):{}},p=!r&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),h=Object.getOwnPropertyDescriptor,y={f:r?h:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),p)try{return h(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},d=Object.defineProperty,v={f:r?d:function defineProperty(t,e,r){if(anObject(t),e=toPrimitive(e,!0),anObject(r),p)try{return d(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}},g=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{g(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,S,O,j=m.inspectSource,k=e.WeakMap,P="function"==typeof k&&/native code/.test(j(k)),E=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)"})})),x=0,A=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++x+A).toString(36)},_=E("keys"),sharedKey=function(t){return _[t]||(_[t]=uid(t))},L={},T=e.WeakMap;if(P){var I=new T,C=I.get,M=I.has,G=I.set;w=function(t,e){return G.call(I,t,e),e},S=function(t){return C.call(I,t)||{}},O=function(t){return M.call(I,t)}}else{var N=sharedKey("state");L[N]=!0,w=function(t,e){return g(t,N,e),e},S=function(t){return has(t,N)?t[N]:{}},O=function(t){return has(t,N)}}var R,D={set:w,get:S,has:O,enforce:function(t){return O(t)?S(t):w(t,{})},getterFor:function(t){return function(e){var r;if(!isObject(e)||(r=S(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},W=createCommonjsModule((function(t){var r=D.get,n=D.enforce,
2020-09-06 06:32:10 +00:00
/**
* @file ext-eyedropper.js
*
* @license MIT
*
* @copyright 2010 Jeff Schiller
*
*/var $n={name:"eyedropper",init:function init(t){var e=this;return function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function _next(t){asyncGeneratorStep(i,n,o,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(i,n,o,_next,_throw,"throw",t)}_next(void 0)}))}}(regeneratorRuntime.mark((function _callee(){var r,n,o,i,a,c,u,f,s,l;return regeneratorRuntime.wrap((function _callee$(p){for(;;)switch(p.prev=p.next){case 0:return s=function _getStyle(t){if("eyedropper"!==c.getMode()){var e=i("#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"),f.fillPaint=r.getAttribute("fill")||"black",f.fillOpacity=r.getAttribute("fill-opacity")||1,f.strokePaint=r.getAttribute("stroke"),f.strokeOpacity=r.getAttribute("stroke-opacity")||1,f.strokeWidth=r.getAttribute("stroke-width"),f.strokeDashArray=r.getAttribute("stroke-dasharray"),f.strokeLinecap=r.getAttribute("stroke-linecap"),f.strokeLinejoin=r.getAttribute("stroke-linejoin"),f.opacity=r.getAttribute("opacity")||1)}},r=e,p.next=4,__variableDynamicImportRuntime0__("./locale/".concat(r.curPrefs.lang,".js"));case 4:return n=p.sent,o=n.default,i=t.$,a=t.ChangeElementCommand,c=r.canvas,u=function addToHistory(t){c.undoMgr.addCommandToHistory(t)},f={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},l=[{id:"tool_eyedropper",icon:"eyedropper.png",type:"mode",events:{click:function click(){c.setMode("eyedropper")}}}],p.abrupt("return",{name:o.name,svgicons:"eyedropper-icon.xml",buttons:o.buttons.map((function(t,e){return Object.assign(l[e],t)})),selectedChanged:s,elementChanged:s,mouseDown:function mouseDown(t){if("eyedropper"===c.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)};f.fillPaint&&n(e,"fill",f.fillPaint),f.fillOpacity&&n(e,"fill-opacity",f.fillOpacity),f.strokePaint&&n(e,"stroke",f.strokePaint),f.strokeOpacity&&n(e,"stroke-opacity",f.strokeOpacity),f.strokeWidth&&n(e,"stroke-width",f.strokeWidth),f.strokeDashArray&&n(e,"stroke-dasharray",f.strokeDashArray),f.opacity&&n(e,"opacity",f.opacity),f.strokeLinecap&&n(e,"stroke-linecap",f.strokeLinecap),f.strokeLinejoin&&n(e,"stroke-linejoin",f.strokeLinejoin),u(new a(e,r))}}}});case 9:case"end":return p.stop()}}),_callee)})))()}},Kn=Object.freeze({__proto__:null,default:{name:"eyedropper",buttons:[{title:"Eye Dropper Tool",key:"I"}]}}),Qn=Object.freeze({__proto__:null,default:{name:"",buttons:[{title:"",key:"I"}]}});export default $n;
2020-09-06 06:32:10 +00:00
//# sourceMappingURL=ext-eyedropper.js.map