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

33 lines
58 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")},l={}.hasOwnProperty,has=function(t,e){return l.call(t,e)},s=e.document,f=isObject(s)&&isObject(s.createElement),documentCreateElement=function(t){return f?s.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,k=e.WeakMap,E="function"==typeof k&&/native code/.test(S(k)),O=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,j=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++A+j).toString(36)},I=O("keys"),sharedKey=function(t){return I[t]||(I[t]=uid(t))},L={},P=e.WeakMap;if(E){var T=m.state||(m.state=new P),R=T.get,N=T.has,C=T.set;w=functio
2020-09-06 06:32:10 +00:00
/**
2020-09-11 23:27:47 +00:00
* @file ext-markers.js
2020-09-06 06:32:10 +00:00
*
2020-09-11 23:27:47 +00:00
* @license Apache-2.0
2020-09-06 06:32:10 +00:00
*
2020-09-11 23:27:47 +00:00
* @copyright 2010 Will Schleter based on ext-arrows.js by Copyright(c) 2010 Alexis Deveria
*
* This extension provides for the addition of markers to the either end
* or the middle of a line, polyline, path, polygon.
*
* Markers may be either a graphic or arbitary text
*
* to simplify the coding and make the implementation as robust as possible,
* markers are not shared - every object has its own set of markers.
* this relationship is maintained by a naming convention between the
* ids of the markers and the ids of the object
*
* The following restrictions exist for simplicty of use and programming
* objects and their markers to have the same color
* marker size is fixed
* text marker font, size, and attributes are fixed
* an application specific attribute - se_type - is added to each marker element
* to store the type of marker
*
* @todo
* remove some of the restrictions above
* add option for keeping text aligned to horizontal
* add support for dimension extension lines
*
2021-03-08 18:08:35 +00:00
*/fixRegexpWellKnownSymbolLogic("split",2,(function(t,e,r){var n;return n="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(t,r){var n,o,i=String(requireObjectCoercible(this)),a=void 0===r?4294967295:r>>>0;if(0===a)return[];if(void 0===t)return[i];if(!isObject(n=t)||!(void 0!==(o=n[So])?o:"RegExp"==classofRaw(n)))return e.call(i,t,a);for(var c,u,l,s=[],f=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),p=0,h=new RegExp(t.source,f+"g");(c=zn.call(h,i))&&!((u=h.lastIndex)>p&&(s.push(i.slice(p,c.index)),c.length>1&&c.index<i.length&&ko.apply(s,c.slice(1)),l=c[0].length,p=u,s.length>=a));)h.lastIndex===c.index&&h.lastIndex++;return p===i.length?!l&&h.test("")||s.push(""):s.push(i.slice(p)),s.length>a?s.slice(0,a):s}:"0".split(void 0,0).length?function(t,r){return void 0===t&&0===r?[]:e.call(this,t,r)}:e,[function split(e,r){var o=requireObjectCoercible(this),i=null==e?void 0:e[t];return void 0!==i?i.call(e,o,r):n.call(String(o),e,r)},function(t,o){var i=r(n,t,this,o,n!==e);if(i.done)return i.value;var a=anObject(t),c=String(this),u=speciesConstructor(a,RegExp),l=a.unicode,s=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.unicode?"u":"")+(Oo?"y":"g"),f=new u(Oo?a:"^(?:"+a.source+")",s),p=void 0===o?4294967295:o>>>0;if(0===p)return[];if(0===c.length)return null===regexpExecAbstract(f,c)?[c]:[];for(var h=0,d=0,v=[];d<c.length;){f.lastIndex=Oo?d:0;var y,g=regexpExecAbstract(f,Oo?c:c.slice(d));if(null===g||(y=Eo(toLength(f.lastIndex+(Oo?0:d)),c.length))===h)d=advanceStringIndex(c,d,l);else{if(v.push(c.slice(h,d)),v.length===p)return v;for(var m=1;m<=g.length-1;m++)if(v.push(g[m]),v.length===p)return v;d=h=y}}return v.push(c.slice(h)),v}]}),!Oo);var Ao=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 Io}));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)}}(),jo={name:"markers",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee3(){var r,n,o,i,a,c,u,l,s,f,p,h,d,v,y,g,m,b,w,x,_,S,k,E,O;return regeneratorRuntime.wrap((function _callee3$(A){for(;;)switch(A.prev=A.next){case 0:return E=function _buildButtonList(){var t=[];return o.each(c,(function(e,r){var n=r+"_marker_list",o=!0;Object.keys(s).forEach((function(e){var i=k(String(e));t.push({id:l+r+"_"+e,svgicon:e,icon:e+".svg",title:i,type:"context",events:{click:_},panel:"marker_panel",list:n,isDefault:o}),o=!1}))})),t},k=function _getTitle(t){var e=n.langList.find((function(e){return e.id===t}));return e?e.title:t},S=function _setArrowFromButton3(){return(S=_asyncToGenerator(regeneratorRuntime.mark((function _callee2(t){var e,r,n;return regeneratorRuntime.wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.id.split("_"),r=e[1],n=e[2],e[3]&&(n+="_"+e[3]),"textmarker"===n){t.next=8;break}w(r,"\\"+n),t.next=10;break;case 8:return t.next=10,x(r);case 10:case"end":return t.stop()}}),_callee2,this)})))).apply(this,arguments)},_=function _setArrowFromButton2(t){return S.apply(this,arguments)},x=function _showTextPrompt(t){var e=o("#"+t+"_marker").val();"\\"===e.substr(0,1)&&(e="");var r=prompt("Enter text for "+t+" marker",e);r&&w(t,r)},w=function _triggerTextEntry(t,e){o("#"+t+"_marker").val(e),o("#"+t+"_marker").change()},b=function _updateReferences(t){o.each(c,(function(e,r){var n=u+r+"_"+t.id,a="marker-"+r,c=f(t,a);if(c&&c.attributes.se_type){var l=t.getAttribute(a);if(l){var s=t.id.leng
2020-09-06 06:32:10 +00:00
//# sourceMappingURL=ext-markers.js.map