diff --git a/badges/coverage-badge.svg b/badges/coverage-badge.svg index 29f7a0bf..c77a98d4 100644 --- a/badges/coverage-badge.svg +++ b/badges/coverage-badge.svg @@ -1 +1 @@ -Statements 44.92%Statements 44.92%Branches 33.59%Branches 33.59%Lines 46.07%Lines 46.07%Functions 51.19%Functions 51.19% +Statements 37.51%Statements 37.51%Branches 28.8%Branches 28.8%Lines 38.46%Lines 38.46%Functions 47.27%Functions 47.27% diff --git a/badges/tests-badge.svg b/badges/tests-badge.svg index 126a9c3c..5034b1b9 100644 --- a/badges/tests-badge.svg +++ b/badges/tests-badge.svg @@ -1 +1 @@ -TestsTests130/131130/131 \ No newline at end of file +TestsTests131/131131/131 \ No newline at end of file diff --git a/dist/extensions/ext-connector.js b/dist/extensions/ext-connector.js index 3116c1c4..b37d72b3 100644 --- a/dist/extensions/ext-connector.js +++ b/dist/extensions/ext-connector.js @@ -1,8 +1,6 @@ var svgEditorExtension_connector = (function () { 'use strict'; - /* eslint-disable unicorn/no-fn-reference-in-iterator */ - /** * @file ext-connector.js * diff --git a/dist/extensions/imagelib/openclipart.js b/dist/extensions/imagelib/openclipart.js index 3d8d397f..b4d038b8 100644 --- a/dist/extensions/imagelib/openclipart.js +++ b/dist/extensions/imagelib/openclipart.js @@ -765,8 +765,7 @@ while (node.childNodes[j]) { const cn = node.childNodes[j]; cn.remove(); // `j` should stay the same as removing will cause node to be present - } // eslint-disable-next-line unicorn/no-fn-reference-in-iterator - + } attVal.childNodes.forEach(_childrenToJML(node)); } else { @@ -792,13 +791,11 @@ } if (attVal.head) { - // eslint-disable-next-line unicorn/no-fn-reference-in-iterator attVal.head.forEach(_appendJML(head)); } } if (attVal.body) { - // eslint-disable-next-line unicorn/no-fn-reference-in-iterator attVal.body.forEach(_appendJMLOrText(body)); } } @@ -1067,7 +1064,7 @@ // Todo: Fix to allow application of stylesheets of style tags within fragments? - return nodes.length <= 1 ? nodes[0] // eslint-disable-next-line unicorn/no-fn-reference-in-iterator + return nodes.length <= 1 ? nodes[0] // eslint-disable-next-line : nodes.reduce(_fragReducer, doc.createDocumentFragment()); // nodes; } diff --git a/dist/index-es.js b/dist/index-es.js index 287fb42b..4177c70a 100644 --- a/dist/index-es.js +++ b/dist/index-es.js @@ -4826,7 +4826,7 @@ const getElem = supportsSelectors() ? function (id) { }, 9, null).singleNodeValue; } : function (id) { // jQuery lookup: twice as slow as xpath in FF - return $$1(svgroot_).find('[id=' + id + ']')[0]; + return $$1(svgroot_).find(`[id=${id}]`)[0]; }; /** * Assigns multiple attributes to an element. @@ -5721,7 +5721,6 @@ class Command { * @implements {module:history.HistoryCommand} */ - class MoveElementCommand extends Command { /** * @param {Element} elem - The DOM element that was moved @@ -6051,7 +6050,7 @@ class BatchCommand extends Command { unapply(handler) { super.unapply(handler, () => { - this.stack.forEach(stackItem => { + this.stack.reverse().forEach(stackItem => { console.assert(stackItem, 'stack item should not be null'); stackItem && stackItem.unapply(handler); }); @@ -6282,6 +6281,7 @@ class UndoManager { var hstry = /*#__PURE__*/Object.freeze({ __proto__: null, HistoryEventTypes: HistoryEventTypes, + Command: Command, MoveElementCommand: MoveElementCommand, InsertElementCommand: InsertElementCommand, RemoveElementCommand: RemoveElementCommand, @@ -12953,7 +12953,7 @@ const init$6 = function (config, svgFactory) { const getSelectorManager = () => selectorManager_; -/* eslint-disable indent, unicorn/no-fn-reference-in-iterator */ +/* eslint-disable indent */ let $$a = jQueryPluginSVG(jQuery); const { MoveElementCommand: MoveElementCommand$1, @@ -27221,7 +27221,7 @@ const jPicker = function ($) { return $; }; -/* eslint-disable unicorn/no-fn-reference-in-iterator */ +/* globals jQuery */ const $$b = jQuery; let langParam; /** diff --git a/dist/index-es.min.js b/dist/index-es.min.js index 8967276a..f7e58833 100644 --- a/dist/index-es.min.js +++ b/dist/index-es.min.js @@ -25,7 +25,7 @@ function P(e){const t=e.fn.attr;return e.fn.attr=function(e,n){const i=this.leng * @license MIT * * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller - */let B,U={};const D=function(){return U},F=function(e){const t=B.getRoundDigits();return isNaN(e)?Array.isArray(e)?F(e[0])+","+F(e[1]):Number.parseFloat(e).toFixed(t)-0:Number(Number(e).toFixed(t))},z=function(e,t){return t=t||B.getBaseUnit(),F(e/U[t])},H=function(e,t,n){e.setAttribute(t,n)},q=function(e,t){if(!isNaN(t))return t-0;if("%"===t.substr(-1)){const n=t.substr(0,t.length-1)/100,i=B.getWidth(),s=B.getHeight();return j.includes(e)?n*i:V.includes(e)?n*s:n*Math.sqrt(i*i+s*s)/Math.sqrt(2)}const n=t.substr(-2);return t.substr(0,t.length-2)*U[n]},X=function(e,t,n){if(R.includes(e))return!isNaN(t)||(t=t.toLowerCase(),Object.keys(U).some(e=>new RegExp("^-?[\\d\\.]+"+e+"$").test(t)));if("id"===e){let e=!1;try{const i=B.getElement(t);e=Qe(i)||i===n}catch(e){}return e}return!0},W=document.createElementNS(t.SVG,"svg"),$=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Y=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},Q=function(...e){const t=e.reduceRight((e,t)=>t.multiply(e));return Math.abs(t.a)<1e-14&&(t.a=0),Math.abs(t.b)<1e-14&&(t.b=0),Math.abs(t.c)<1e-14&&(t.c=0),Math.abs(t.d)<1e-14&&(t.d=0),Math.abs(t.e)<1e-14&&(t.e=0),Math.abs(t.f)<1e-14&&(t.f=0),t},K=function(e){if(!e)return!1;let t=e.numberOfItems;for(;t--;){const n=e.getItem(t);if(1===n.type&&!Y(n.matrix))return!0}return!1},Z=function(e,t,n,i,s){const o=$(e,t,s),r=$(e+n,t,s),a=$(e,t+i,s),l=$(e+n,t+i,s),c=Math.min(o.x,r.x,a.x,l.x),u=Math.max(o.x,r.x,a.x,l.x),d=Math.min(o.y,r.y,a.y,l.y);return{tl:o,tr:r,bl:a,br:l,aabox:{x:c,y:d,width:u-c,height:Math.max(o.y,r.y,a.y,l.y)-d}}},J=function(e,t,n){if(Qe(e))return W.createSVGTransformFromMatrix(W.createSVGMatrix());if(t=t||0,n=n||e.numberOfItems-1,(t=Number.parseInt(t))>(n=Number.parseInt(n))){const e=n;n=t,t=e}let i=W.createSVGMatrix();for(let s=t;s<=n;++s){const t=s>=0&&se.x&&t.ye.y},ie=P(jQuery),se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",oe="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath".split(",");let re=null,ae=null,le=null,ce=null;const ue=function(e){re=e,ae=e.getDOMDocument(),le=e.getDOMContainer(),ce=e.getSVGRoot()},de=e=>e.replace(/()/,"$1$2"),he=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};function pe(e){if(e=me(e),window.btoa)return window.btoa(e);const t=new Array(4*Math.floor((e.length+2)/3));let n=0,i=0;do{const s=e.charCodeAt(n++),o=e.charCodeAt(n++),r=e.charCodeAt(n++),a=s>>2,l=(3&s)<<4|o>>4;let c=(15&o)<<2|r>>6,u=63&r;Number.isNaN(o)?(c=64,u=64):Number.isNaN(r)&&(u=64),t[i++]=se.charAt(a),t[i++]=se.charAt(l),t[i++]=se.charAt(c),t[i++]=se.charAt(u)}while(n>4,l=(15&s)<<4|o>>2,c=(3&o)<<6|r;t+=String.fromCharCode(a),64!==o&&(t+=String.fromCharCode(l)),64!==r&&(t+=String.fromCharCode(c))}while(nSVG-edit "],{type:"text/html"});return ye(e)}(),ve=function(e){let t,n;e.includes("0?n=n[0]:(n=e.ownerDocument.createElementNS(t.SVG,"defs"),e.firstChild?e.insertBefore(n,e.firstChild.nextSibling):e.append(n)),n},Ge=function(e){const t=e.pathSegList,n=t.numberOfItems,i=[[],[]],s=t.getItem(0);let o=[s.x,s.y];const r=function(e,t,n,i){return function(s){return 1-s**3*o[e]+3-s**2*s*t[e]+3*(1-s)*s**2*n[e]+s**3*i[e]}};for(let e=0;e0&&e<1&&i[n].push(a(e));continue}const d=l**2-4*u*c;if(d<0)continue;const h=(-l+Math.sqrt(d))/(2*c);h>0&&h<1&&i[n].push(a(h));const p=(-l-Math.sqrt(d))/(2*c);p>0&&p<1&&i[n].push(a(p))}o=s}else i[0].push(n.x),i[1].push(n.y)}const a=Math.min.apply(null,i[0]),l=Math.max.apply(null,i[0])-a,c=Math.min.apply(null,i[1]);return{x:a,y:c,width:l,height:Math.max.apply(null,i[1])-c}};function Pe(e){if(b)try{return e.getBBox()}catch(e){}const t=ie.data(e,"ref");let n,i,s=null;t?(i=ie(t).children().clone().attr("visibility","hidden"),ie(ce).append(i),s=i.filter("line, path")):s=ie(e).find("line, path");let o=!1;if(s.length)if(s.each((function(){const e=this.getBBox();e.width&&e.height||(o=!0)})),o){const s=t?i:ie(e).children();n=Re(s)}else n=e.getBBox();else n=e.getBBox();return t&&i.remove(),n}const Ne=function(e){const t=e||re.geSelectedElements()[0];if(1!==e.nodeType)return null;const n=t.nodeName;let i=null;switch(n){case"text":""===t.textContent?(t.textContent="a",i=t.getBBox(),t.textContent=""):t.getBBox&&(i=t.getBBox());break;case"path":y?t.getBBox&&(i=t.getBBox()):i=Ge(t);break;case"g":case"a":i=Pe(t);break;default:if("use"===n&&(i=Pe(t)),"use"===n||"foreignObject"===n&&w()){if(i||(i=t.getBBox()),!w()){const{x:e,y:n,width:s,height:o}=i;i={width:s,height:o,x:e+Number.parseFloat(t.getAttribute("x")||0),y:n+Number.parseFloat(t.getAttribute("y")||0)}}}else if(oe.includes(n))if(t)try{i=t.getBBox()}catch(e){const n=t.getExtentOfChar(0),s=t.getComputedTextLength();i={x:n.x,y:n.y,width:s,height:n.height}}else{const e=ie(t).closest("foreignObject");e.length&&e[0].getBBox&&(i=e[0].getBBox())}}return i&&(i=xe(i)),i},Ie=function(e){let t="";return ie.each(e,(function(e,[n,i]){t+=n;for(let e=0;e-.001&&n<.001||(n<-89.99||n>89.99))}(o,r)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))a=Me(e,t,n),i=a;else if("rect"===e.tagName){const s=e.getAttribute("rx"),o=e.getAttribute("ry");(s||o)&&(a=Me(e,t,n),i=a)}}if(!a){const{matrix:e}=J(s);i=Z(i.x,i.y,i.width,i.height,e).aabox}}return i};function Ve(e){const t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}const Re=function(e,t,n){if(!e||!e.length)return!1;let i;if(ie.each(e,(function(){i||this.parentNode&&(i=je(this,t,n))})),void 0===i)return null;let s=i.x+i.width,o=i.y+i.height,r=i.x,a=i.y;if(1===e.length){const t=Ve(e[0]);r-=t,a-=t,s+=t,o+=t}else ie.each(e,(function(e,i){const l=je(i,t,n);if(l){const e=Ve(i);r=Math.min(r,l.x-e),a=Math.min(a,l.y-e),1===i.nodeType&&(s=Math.max(s,l.x+l.width+e),o=Math.max(o,l.y+l.height+e))}}));return i.x=r,i.y=a,i.width=s-r,i.height=o-a,i},Be=function(e){e||(e=ie(re.getSVGContent()).children());const t=[];return ie(e).children().each((function(e,n){n.getBBox&&t.push(n)})),t.reverse()},Ue=function(e){return e||(e=Be()),Re(e,re.addSVGElementFromJson,re.pathActions)},De=function(e,t){if(!e)return 0;const n=e.numberOfItems;for(let i=0;i{e.getAttribute(t)===String(n)&&e.removeAttribute(t)})},We=function(e){const t=re.getBaseUnit();let n=re.getSnappingStep();return"px"!==t&&(n*=D()[t]),e=Math.round(e/n)*n},$e=function(e){return String(e).replace(/[.\\+*?[^\]$(){}=!<>|:-]/g,"\\$&")},Ye=function(e){ie(e).click((function(e){e.preventDefault()}))},Qe=e=>null==e;var Ke=Object.freeze({__proto__:null,init:ue,dropXMLInternalSubset:de,toXml:he,fromXml:function(e){return ie("

").html(e).text()},encode64:pe,decode64:ge,decodeUTF8:fe,encodeUTF8:me,dataURLToObjectURL:_e,createObjectURL:ye,blankPageObjectURL:be,convertToXMLReferences:function(e){let t="";return[...e].forEach(e=>{const n=e.charCodeAt();t+=n<=127?e:`&#${n};`}),t},text2xml:ve,bboxToObj:xe,walkTree:we,walkTreePost:Se,getUrlFromAttr:ke,get getHref(){return Ce},get setHref(){return Ae},findDefs:Ee,getPathBBox:Ge,getBBox:Ne,getPathDFromSegments:Ie,getPathDFromElement:Te,getExtraAttributesForConvertToPath:Le,getBBoxOfElementAsPath:Me,convertToPath:Oe,getBBoxWithTransform:je,getStrokedBBox:Re,getVisibleElements:Be,getStrokedBBoxDefaultVisible:Ue,getRotationAngleFromTransformList:De,get getRotationAngle(){return Fe},getRefElem:ze,getElem:He,assignAttributes:qe,cleanupElement:Xe,snapToGrid:We,regexEscape:$e,preventClickDefault:Ye,isNullish:Qe,mock:({getHref:e,setHref:t,getRotationAngle:n})=>{Ce=e,Ae=t,Fe=n},$q:e=>document.querySelector(e),$qq:e=>[...document.querySelectorAll(e)]}); + */let B,U={};const D=function(){return U},F=function(e){const t=B.getRoundDigits();return isNaN(e)?Array.isArray(e)?F(e[0])+","+F(e[1]):Number.parseFloat(e).toFixed(t)-0:Number(Number(e).toFixed(t))},z=function(e,t){return t=t||B.getBaseUnit(),F(e/U[t])},H=function(e,t,n){e.setAttribute(t,n)},q=function(e,t){if(!isNaN(t))return t-0;if("%"===t.substr(-1)){const n=t.substr(0,t.length-1)/100,i=B.getWidth(),s=B.getHeight();return j.includes(e)?n*i:V.includes(e)?n*s:n*Math.sqrt(i*i+s*s)/Math.sqrt(2)}const n=t.substr(-2);return t.substr(0,t.length-2)*U[n]},X=function(e,t,n){if(R.includes(e))return!isNaN(t)||(t=t.toLowerCase(),Object.keys(U).some(e=>new RegExp("^-?[\\d\\.]+"+e+"$").test(t)));if("id"===e){let e=!1;try{const i=B.getElement(t);e=Qe(i)||i===n}catch(e){}return e}return!0},W=document.createElementNS(t.SVG,"svg"),$=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Y=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},Q=function(...e){const t=e.reduceRight((e,t)=>t.multiply(e));return Math.abs(t.a)<1e-14&&(t.a=0),Math.abs(t.b)<1e-14&&(t.b=0),Math.abs(t.c)<1e-14&&(t.c=0),Math.abs(t.d)<1e-14&&(t.d=0),Math.abs(t.e)<1e-14&&(t.e=0),Math.abs(t.f)<1e-14&&(t.f=0),t},K=function(e){if(!e)return!1;let t=e.numberOfItems;for(;t--;){const n=e.getItem(t);if(1===n.type&&!Y(n.matrix))return!0}return!1},Z=function(e,t,n,i,s){const o=$(e,t,s),r=$(e+n,t,s),a=$(e,t+i,s),l=$(e+n,t+i,s),c=Math.min(o.x,r.x,a.x,l.x),u=Math.max(o.x,r.x,a.x,l.x),d=Math.min(o.y,r.y,a.y,l.y);return{tl:o,tr:r,bl:a,br:l,aabox:{x:c,y:d,width:u-c,height:Math.max(o.y,r.y,a.y,l.y)-d}}},J=function(e,t,n){if(Qe(e))return W.createSVGTransformFromMatrix(W.createSVGMatrix());if(t=t||0,n=n||e.numberOfItems-1,(t=Number.parseInt(t))>(n=Number.parseInt(n))){const e=n;n=t,t=e}let i=W.createSVGMatrix();for(let s=t;s<=n;++s){const t=s>=0&&se.x&&t.ye.y},ie=P(jQuery),se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",oe="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath".split(",");let re=null,ae=null,le=null,ce=null;const ue=function(e){re=e,ae=e.getDOMDocument(),le=e.getDOMContainer(),ce=e.getSVGRoot()},de=e=>e.replace(/()/,"$1$2"),he=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};function pe(e){if(e=me(e),window.btoa)return window.btoa(e);const t=new Array(4*Math.floor((e.length+2)/3));let n=0,i=0;do{const s=e.charCodeAt(n++),o=e.charCodeAt(n++),r=e.charCodeAt(n++),a=s>>2,l=(3&s)<<4|o>>4;let c=(15&o)<<2|r>>6,u=63&r;Number.isNaN(o)?(c=64,u=64):Number.isNaN(r)&&(u=64),t[i++]=se.charAt(a),t[i++]=se.charAt(l),t[i++]=se.charAt(c),t[i++]=se.charAt(u)}while(n>4,l=(15&s)<<4|o>>2,c=(3&o)<<6|r;t+=String.fromCharCode(a),64!==o&&(t+=String.fromCharCode(l)),64!==r&&(t+=String.fromCharCode(c))}while(nSVG-edit "],{type:"text/html"});return ye(e)}(),ve=function(e){let t,n;e.includes("0?n=n[0]:(n=e.ownerDocument.createElementNS(t.SVG,"defs"),e.firstChild?e.insertBefore(n,e.firstChild.nextSibling):e.append(n)),n},Ge=function(e){const t=e.pathSegList,n=t.numberOfItems,i=[[],[]],s=t.getItem(0);let o=[s.x,s.y];const r=function(e,t,n,i){return function(s){return 1-s**3*o[e]+3-s**2*s*t[e]+3*(1-s)*s**2*n[e]+s**3*i[e]}};for(let e=0;e0&&e<1&&i[n].push(a(e));continue}const d=l**2-4*u*c;if(d<0)continue;const h=(-l+Math.sqrt(d))/(2*c);h>0&&h<1&&i[n].push(a(h));const p=(-l-Math.sqrt(d))/(2*c);p>0&&p<1&&i[n].push(a(p))}o=s}else i[0].push(n.x),i[1].push(n.y)}const a=Math.min.apply(null,i[0]),l=Math.max.apply(null,i[0])-a,c=Math.min.apply(null,i[1]);return{x:a,y:c,width:l,height:Math.max.apply(null,i[1])-c}};function Pe(e){if(b)try{return e.getBBox()}catch(e){}const t=ie.data(e,"ref");let n,i,s=null;t?(i=ie(t).children().clone().attr("visibility","hidden"),ie(ce).append(i),s=i.filter("line, path")):s=ie(e).find("line, path");let o=!1;if(s.length)if(s.each((function(){const e=this.getBBox();e.width&&e.height||(o=!0)})),o){const s=t?i:ie(e).children();n=Re(s)}else n=e.getBBox();else n=e.getBBox();return t&&i.remove(),n}const Ne=function(e){const t=e||re.geSelectedElements()[0];if(1!==e.nodeType)return null;const n=t.nodeName;let i=null;switch(n){case"text":""===t.textContent?(t.textContent="a",i=t.getBBox(),t.textContent=""):t.getBBox&&(i=t.getBBox());break;case"path":y?t.getBBox&&(i=t.getBBox()):i=Ge(t);break;case"g":case"a":i=Pe(t);break;default:if("use"===n&&(i=Pe(t)),"use"===n||"foreignObject"===n&&w()){if(i||(i=t.getBBox()),!w()){const{x:e,y:n,width:s,height:o}=i;i={width:s,height:o,x:e+Number.parseFloat(t.getAttribute("x")||0),y:n+Number.parseFloat(t.getAttribute("y")||0)}}}else if(oe.includes(n))if(t)try{i=t.getBBox()}catch(e){const n=t.getExtentOfChar(0),s=t.getComputedTextLength();i={x:n.x,y:n.y,width:s,height:n.height}}else{const e=ie(t).closest("foreignObject");e.length&&e[0].getBBox&&(i=e[0].getBBox())}}return i&&(i=xe(i)),i},Ie=function(e){let t="";return ie.each(e,(function(e,[n,i]){t+=n;for(let e=0;e-.001&&n<.001||(n<-89.99||n>89.99))}(o,r)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))a=Me(e,t,n),i=a;else if("rect"===e.tagName){const s=e.getAttribute("rx"),o=e.getAttribute("ry");(s||o)&&(a=Me(e,t,n),i=a)}}if(!a){const{matrix:e}=J(s);i=Z(i.x,i.y,i.width,i.height,e).aabox}}return i};function Ve(e){const t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}const Re=function(e,t,n){if(!e||!e.length)return!1;let i;if(ie.each(e,(function(){i||this.parentNode&&(i=je(this,t,n))})),void 0===i)return null;let s=i.x+i.width,o=i.y+i.height,r=i.x,a=i.y;if(1===e.length){const t=Ve(e[0]);r-=t,a-=t,s+=t,o+=t}else ie.each(e,(function(e,i){const l=je(i,t,n);if(l){const e=Ve(i);r=Math.min(r,l.x-e),a=Math.min(a,l.y-e),1===i.nodeType&&(s=Math.max(s,l.x+l.width+e),o=Math.max(o,l.y+l.height+e))}}));return i.x=r,i.y=a,i.width=s-r,i.height=o-a,i},Be=function(e){e||(e=ie(re.getSVGContent()).children());const t=[];return ie(e).children().each((function(e,n){n.getBBox&&t.push(n)})),t.reverse()},Ue=function(e){return e||(e=Be()),Re(e,re.addSVGElementFromJson,re.pathActions)},De=function(e,t){if(!e)return 0;const n=e.numberOfItems;for(let i=0;i{e.getAttribute(t)===String(n)&&e.removeAttribute(t)})},We=function(e){const t=re.getBaseUnit();let n=re.getSnappingStep();return"px"!==t&&(n*=D()[t]),e=Math.round(e/n)*n},$e=function(e){return String(e).replace(/[.\\+*?[^\]$(){}=!<>|:-]/g,"\\$&")},Ye=function(e){ie(e).click((function(e){e.preventDefault()}))},Qe=e=>null==e;var Ke=Object.freeze({__proto__:null,init:ue,dropXMLInternalSubset:de,toXml:he,fromXml:function(e){return ie("

").html(e).text()},encode64:pe,decode64:ge,decodeUTF8:fe,encodeUTF8:me,dataURLToObjectURL:_e,createObjectURL:ye,blankPageObjectURL:be,convertToXMLReferences:function(e){let t="";return[...e].forEach(e=>{const n=e.charCodeAt();t+=n<=127?e:`&#${n};`}),t},text2xml:ve,bboxToObj:xe,walkTree:we,walkTreePost:Se,getUrlFromAttr:ke,get getHref(){return Ce},get setHref(){return Ae},findDefs:Ee,getPathBBox:Ge,getBBox:Ne,getPathDFromSegments:Ie,getPathDFromElement:Te,getExtraAttributesForConvertToPath:Le,getBBoxOfElementAsPath:Me,convertToPath:Oe,getBBoxWithTransform:je,getStrokedBBox:Re,getVisibleElements:Be,getStrokedBBoxDefaultVisible:Ue,getRotationAngleFromTransformList:De,get getRotationAngle(){return Fe},getRefElem:ze,getElem:He,assignAttributes:qe,cleanupElement:Xe,snapToGrid:We,regexEscape:$e,preventClickDefault:Ye,isNullish:Qe,mock:({getHref:e,setHref:t,getRotationAngle:n})=>{Ce=e,Ae=t,Fe=n},$q:e=>document.querySelector(e),$qq:e=>[...document.querySelectorAll(e)]}); /** * Adds context menu functionality. * @module contextmenu @@ -36,7 +36,7 @@ function P(e){const t=e.fn.attr;return e.fn.attr=function(e,n){const i=this.leng * Adapted from {@link https://github.com/uupaa/dynamic-import-polyfill/blob/master/importModule.js}. * @module importModule * @license MIT - */function nt(e,t){["id","class","type"].forEach(n=>{n in t&&(e[n]=t[n])})}function it(e,t){return st(e,tt({},t,{returnDefault:!0}))}async function st(e,{global:t,returnDefault:n}){return"svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules?(await ot(e),window[t]):function e(t,n={},{returnDefault:i=!1}={}){if(Array.isArray(t))return Promise.all(t.map(t=>e(t,n)));return new Promise((e,s)=>{const o="$importModule$"+Math.random().toString(32).slice(2),r=document.createElement("script");function a(){s(new Error("Failed to import: "+t)),c()}function l(){e(window[o]),c()}const c=()=>{delete window[o],r.removeEventListener("error",a),r.removeEventListener("load",l),r.remove(),URL.revokeObjectURL(r.src),r.src=""};nt(r,n),r.defer="defer",r.type="module",r.addEventListener("error",a),r.addEventListener("load",l);const u=`import * as m from '${function(e){const t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}(t).replace(/'/g,"\\'")}'; window.${o} = ${i?"m.default || ":""}m;`,d=new Blob([u],{type:"text/javascript"});r.src=URL.createObjectURL(d),document.head.append(r)})}(e,void 0,{returnDefault:n})}function ot(e,t={}){return Array.isArray(e)?Promise.all(e.map(e=>ot(e,t))):new Promise((n,i)=>{const s=document.createElement("script");function o(){i(new Error("Failed to import: "+e)),a()}function r(){n(),a()}const a=()=>{s.removeEventListener("error",o),s.removeEventListener("load",r),s.remove(),s.src=""};s.defer="defer",nt(s,t),s.addEventListener("error",o),s.addEventListener("load",r),s.src=e,document.head.append(s)})}const rt={true:!0,false:!1,null:null};function at(e,{ok:t="Ok",cancel:n="Cancel"}={}){e("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"}).css("position","absolute");const i=e("#dialog_box"),s=e("#dialog_buttons"),o=e("#dialog_content");function r(r,a,l,c,u,d){o.html("

"+a.replace(/\n/g,"

")+"

").toggleClass("prompt","prompt"===r),s.empty();const h=e('').appendTo(s);return new Promise((t,p)=>{let g,f;if("alert"!==r&&e('').appendTo(s).click((function(){i.hide(),t(!1)})),"prompt"===r)g=e('').prependTo(s),g.val(l||""),g.bind("keydown","return",(function(){h.click()}));else if("select"===r){const t=e('
');if(g=e(`').appendTo(n),f.val(d.value),d.tooltip&&n.attr("title",d.tooltip),f.prop("checked",Boolean(d.checked)),t.append(e("
").append(n))}e.each(c||[],(function(t,n){"object"==typeof n?g.append(e("