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

11 lines
56 KiB
JavaScript
Raw Normal View History

2021-03-08 18:08:35 +00:00
function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function asyncGeneratorStep(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}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)}))}}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t){var e={exports:{}};return t(e,e.exports),e.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}()||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)},f=e.document,l=isObject(f)&&isObject(f.createElement),documentCreateElement=function(t){return l?f.createElement(t):{}},p=!r&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),h=Object.getOwnPropertyDescriptor,d={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},v=Object.defineProperty,y={f:r?v:function defineProperty(t,e,r){if(anObject(t),e=toPrimitive(e,!0),anObject(r),p)try{return v(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 y.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,x,S,_=m.inspectSource,E=e.WeakMap,O="function"==typeof E&&/native code/.test(_(E)),j=createCommonjsModule((function(t){(t.exports=function(t,e){return m[t]||(m[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.9.0",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),A=0,I=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++A+I).toString(36)},P=j("keys"),sharedKey=function(t){return P[t]||(P[t]=uid(t))},k={},T=e.WeakMap;if(O){var N=m.state||(m.state=new T),L=N.get,R=N.has,M=N.set;w=functio
2020-09-06 06:32:10 +00:00
/**
2020-09-11 23:27:47 +00:00
* @file ext-connector.js
*
2020-09-06 06:32:10 +00:00
* @license MIT
*
* @copyright 2010 Alexis Deveria
*
2021-03-08 18:08:35 +00:00
*/var No=function(){var t=_asyncToGenerator(regeneratorRuntime.mark((function _callee(t){var e;return regeneratorRuntime.wrap((function _callee$(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,__variableDynamicImportRuntime0__("./locale/".concat(encodeURIComponent(t),".js"));case 3:e=r.sent,r.next=12;break;case 6:return r.prev=6,r.t0=r.catch(0),console.error("Missing translation (".concat(t,") - using 'en'")),r.next=11,Promise.resolve().then((function(){return Ro}));case 11:e=r.sent;case 12:return r.abrupt("return",e.default);case 13:case"end":return r.stop()}}),_callee,null,[[0,6]])})));return function loadExtensionTranslation(e){return t.apply(this,arguments)}}(),Lo={name:"connector",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee2(){var r,n,o,i,a,c,u,s,f,l,p,h,d,v,y,g,m,b,w,x,S,_,E,O,j,A,I,P;return regeneratorRuntime.wrap((function _callee2$(k){for(;;)switch(k.prev=k.next){case 0:return A=function _init(){i(y).find("*").each((function(){var t=this.getAttributeNS(v,"connector");if(t){this.setAttribute("class","se_connector");var e=t.split(" "),r=n.getStrokedBBox([o(e[0])]),a=n.getStrokedBBox([o(e[1])]);i(this).data("c_start",e[0]).data("c_end",e[1]).data("start_bb",r).data("end_bb",a),n.getEditorNS(!0)}}))},j=function _updateConnectors(t){if(O(t),m.length)for(var e=m.length;e--;){var r=m[e],o=r.connector,i=r.elem,a=r.is_start?"start":"end",c=n.getStrokedBBox([i]);c.x=r.start_x,c.y=r.start_y,s(o,a+"_bb",c),s(o,a+"_off");var u=r.is_start?"end":"start",f=s(o,u+"_bb"),l=f.x+f.width/2,p=f.y+f.height/2,h=w(l,p,c,x(a,o));_(o,r.is_start?0:"end",h.x,h.y,!0);var d=w(h.x,h.y,s(o,u+"_bb"),x(u,o));if(_(o,r.is_start?"end":0,d.x,d.y,!0),navigator.userAgent.includes("AppleWebKit")){for(var v=o.points,y=v.numberOfItems,g=[],b=0;b<y;b++)h=v.getItem(b),g[b]=h.x+","+h.y;o.setAttribute("points",g.join(" "))}}},O=function _findConnectors(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b,e=i(y).find(".se_connector");m=[],e.each((function(){var e;function add(){t.includes(this)&&(e=!0)}var r=[];["start","end"].forEach((function(t,e){var o=s(this,"c_"+t);null==o?(o=document.getElementById(this.attributes["se:connector"].value.split(" ")[e]),s(this,"c_"+t,o.id),s(this,t+"_bb",n.getStrokedBBox([o]))):o=document.getElementById(o),r.push(o)}),this);for(var o=0;o<2;o++){var a=r[o];if(e=!1,i(a).parents().each(add),a&&a.parentNode){if(t.includes(a)||e){var c=n.getStrokedBBox([a]);m.push({elem:a,connector:this,is_start:0===o,start_x:c.x,start_y:c.y})}}else i(this).remove()}}))},E=function _updateLine(t,e){for(var r=m.length;r--;){var n=m[r],o=n.connector,i=n.is_start?"start":"end",a=s(o,i+"_bb");a.x=n.start_x+t,a.y=n.start_y+e,s(o,i+"_bb",a);var c=n.is_start?"end":"start",u=s(o,c+"_bb"),f=u.x+u.width/2,l=u.y+u.height/2,p=w(f,l,a,x(i,o));_(o,n.is_start?0:"end",p.x,p.y,!0);var h=w(p.x,p.y,s(o,c+"_bb"),x(c,o));_(o,n.is_start?"end":0,h.x,h.y,!0)}},_=function _setPoint(t,e,r,n,o){var i=t.points,c=a.createSVGPoint();c.x=r,c.y=n,"end"===e&&(e=i.numberOfItems-1);try{i.replaceItem(c,e)}catch(o){for(var u=t.getAttribute("points").split(" "),s=0;s<u.length;s++)s===e&&(u[s]=r+","+n);t.setAttribute("points",u.join(" "))}if(o){var f=i.getItem(0),l=i.getItem(i.numberOfItems-1);_(t,1,(l.x+f.x)/2,(l.y+f.y)/2)}},S=function _showPanel(t){var e=i("#connector_rules");e.length||(e=i('<style id="connector_rules"></style>').appendTo("head")),e.text(t?"#tool_clone, #tool_topath, #tool_angle, #xy_panel { display: none !important; }":""),i("#connector_panel").toggle(t)},x=function _getOffset(t,e){var r=e.getAttribute("marker-"+t),n=5*e.getAttribute("stroke-width");return r?n:0},w=function _getBBintersect(t,e,r,n){n&&(n-=0,(r=i.extend({},r)).width+=n,r.height+=n,r.x-=n/2,r.y-=n/2);var o,a=r.x+r.width/2,c=r.y+r.height/2,u=t-a,s=e-c;return{x:a+u*(o=Math.abs(s/u)<r.height/r.width?r.width/2/Math.abs(u):s?r.height/2/Math.abs(s):0),y:c+s*o}},n=(r=e).svgCanvas,o=n.getElem,i=t.$,a=t.svgroot,c=n.addSVGElementFromJson,u=t.selectorManager,s=i.data,y=t.svgcontent,g=!1,m=[],b=[],function(){var t=n.groupSelec
2020-09-06 06:32:10 +00:00
//# sourceMappingURL=ext-connector.js.map