- Linting (ESLint): Prefer addEventListener, exponentiation operator, avoiding catastrophic regexes, prefer spread, prefer startsWith/endsWith, no fn ref in iterator
- npm: Update devDeps (rollup and eslint-config-ash-nazg)
This commit is contained in:
63
dist/canvg.js
vendored
63
dist/canvg.js
vendored
@@ -1097,7 +1097,7 @@ var canvg = (function (exports) {
|
||||
if (!this.hasValue()) return 0;
|
||||
var n = parseFloat(this.value);
|
||||
|
||||
if (String(this.value).match(/%$/)) {
|
||||
if (String(this.value).endsWith('%')) {
|
||||
n /= 100.0;
|
||||
}
|
||||
|
||||
@@ -1205,15 +1205,15 @@ var canvg = (function (exports) {
|
||||
value: function toPixels(viewPort, processPercent) {
|
||||
if (!this.hasValue()) return 0;
|
||||
var s = String(this.value);
|
||||
if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort);
|
||||
if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0;
|
||||
if (s.match(/px$/)) return this.numValue();
|
||||
if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
|
||||
if (s.match(/pc$/)) return this.numValue() * 15;
|
||||
if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54;
|
||||
if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4;
|
||||
if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort);
|
||||
if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
|
||||
if (s.endsWith('em')) return this.numValue() * this.getEM(viewPort);
|
||||
if (s.endsWith('ex')) return this.numValue() * this.getEM(viewPort) / 2.0;
|
||||
if (s.endsWith('px')) return this.numValue();
|
||||
if (s.endsWith('pt')) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
|
||||
if (s.endsWith('pc')) return this.numValue() * 15;
|
||||
if (s.endsWith('cm')) return this.numValue() * this.getDPI(viewPort) / 2.54;
|
||||
if (s.endsWith('mm')) return this.numValue() * this.getDPI(viewPort) / 25.4;
|
||||
if (s.endsWith('in')) return this.numValue() * this.getDPI(viewPort);
|
||||
if (s.endsWith('%')) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
|
||||
var n = this.numValue();
|
||||
if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);
|
||||
return n;
|
||||
@@ -1225,8 +1225,8 @@ var canvg = (function (exports) {
|
||||
value: function toMilliseconds() {
|
||||
if (!this.hasValue()) return 0;
|
||||
var s = String(this.value);
|
||||
if (s.match(/s$/)) return this.numValue() * 1000;
|
||||
if (s.match(/ms$/)) return this.numValue();
|
||||
if (s.endsWith('ms')) return this.numValue();
|
||||
if (s.endsWith('s')) return this.numValue() * 1000;
|
||||
return this.numValue();
|
||||
} // angle extensions
|
||||
// get the angle as radians
|
||||
@@ -1236,9 +1236,9 @@ var canvg = (function (exports) {
|
||||
value: function toRadians() {
|
||||
if (!this.hasValue()) return 0;
|
||||
var s = String(this.value);
|
||||
if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0);
|
||||
if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0);
|
||||
if (s.match(/rad$/)) return this.numValue();
|
||||
if (s.endsWith('deg')) return this.numValue() * (Math.PI / 180.0);
|
||||
if (s.endsWith('grad')) return this.numValue() * (Math.PI / 200.0);
|
||||
if (s.endsWith('rad')) return this.numValue();
|
||||
return this.numValue() * (Math.PI / 180.0);
|
||||
}
|
||||
}, {
|
||||
@@ -1734,10 +1734,10 @@ var canvg = (function (exports) {
|
||||
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
|
||||
} else {
|
||||
// align
|
||||
if (align.match(/^xMid/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
|
||||
if (align.match(/YMid$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
|
||||
if (align.match(/^xMax/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
|
||||
if (align.match(/YMax$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
|
||||
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
|
||||
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
|
||||
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
|
||||
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
|
||||
} // scale
|
||||
|
||||
|
||||
@@ -1893,7 +1893,7 @@ var canvg = (function (exports) {
|
||||
key: "getHrefAttribute",
|
||||
value: function getHrefAttribute() {
|
||||
for (var a in this.attributes) {
|
||||
if (a.match(/:href$/)) {
|
||||
if (a.endsWith(':href')) {
|
||||
return this.attributes[a];
|
||||
}
|
||||
}
|
||||
@@ -2516,9 +2516,9 @@ var canvg = (function (exports) {
|
||||
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
|
||||
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
|
||||
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
|
||||
.replace(/([0-9])([+-])/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/(\.[0-9]*)(\.)/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm, '$1 $3 $4 '); // shorthand elliptical arc path syntax
|
||||
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
|
||||
|
||||
|
||||
d = svg.compressSpaces(d); // compress multiple spaces
|
||||
@@ -3861,14 +3861,14 @@ var canvg = (function (exports) {
|
||||
_this20.img.crossOrigin = 'Anonymous';
|
||||
}
|
||||
|
||||
_this20.img.onload = function () {
|
||||
_this20.img.addEventListener('load', function () {
|
||||
_this20.loaded = true;
|
||||
};
|
||||
});
|
||||
|
||||
_this20.img.onerror = function () {
|
||||
_this20.img.addEventListener('error', function () {
|
||||
svg.log('ERROR: image "' + href + '" not found');
|
||||
_this20.loaded = true;
|
||||
};
|
||||
});
|
||||
|
||||
_this20.img.src = href;
|
||||
} else {
|
||||
@@ -4577,7 +4577,7 @@ var canvg = (function (exports) {
|
||||
|
||||
|
||||
if (svg.opts.ignoreMouse !== true) {
|
||||
ctx.canvas.onclick = function (e) {
|
||||
ctx.canvas.addEventListener('click', function (e) {
|
||||
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
|
||||
|
||||
var _mapXY = mapXY(_construct(svg.Point, args)),
|
||||
@@ -4585,9 +4585,8 @@ var canvg = (function (exports) {
|
||||
y = _mapXY.y;
|
||||
|
||||
svg.Mouse.onclick(x, y);
|
||||
};
|
||||
|
||||
ctx.canvas.onmousemove = function (e) {
|
||||
});
|
||||
ctx.canvas.addEventListener('mousemove', function (e) {
|
||||
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
|
||||
|
||||
var _mapXY2 = mapXY(_construct(svg.Point, args)),
|
||||
@@ -4595,7 +4594,7 @@ var canvg = (function (exports) {
|
||||
y = _mapXY2.y;
|
||||
|
||||
svg.Mouse.onmousemove(x, y);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
var e = svg.CreateElement(dom.documentElement);
|
||||
|
||||
2
dist/extensions/ext-connector.js
vendored
2
dist/extensions/ext-connector.js
vendored
@@ -37,6 +37,8 @@ var svgEditorExtension_connector = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* eslint-disable unicorn/no-fn-reference-in-iterator */
|
||||
|
||||
/**
|
||||
* ext-connector.js
|
||||
*
|
||||
|
||||
36
dist/extensions/ext-mathjax.js
vendored
36
dist/extensions/ext-mathjax.js
vendored
@@ -65,27 +65,37 @@ var svgEditorExtension_mathjax = (function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
// eslint-disable-line promise/avoid-new
|
||||
var script = document.createElement('script');
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
function scriptOnError() {
|
||||
reject(new Error("Failed to import: ".concat(url)));
|
||||
destructor();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function scriptOnLoad() {
|
||||
resolve();
|
||||
destructor();
|
||||
}
|
||||
|
||||
var destructor = function destructor() {
|
||||
script.onerror = null;
|
||||
script.onload = null;
|
||||
script.removeEventListener('error', scriptOnError);
|
||||
script.removeEventListener('load', scriptOnLoad);
|
||||
script.remove();
|
||||
script.src = '';
|
||||
};
|
||||
|
||||
script.defer = 'defer';
|
||||
addScriptAtts(script, atts);
|
||||
|
||||
script.onerror = function () {
|
||||
reject(new Error("Failed to import: ".concat(url)));
|
||||
destructor();
|
||||
};
|
||||
|
||||
script.onload = function () {
|
||||
resolve();
|
||||
destructor();
|
||||
};
|
||||
|
||||
script.addEventListener('error', scriptOnError);
|
||||
script.addEventListener('load', scriptOnLoad);
|
||||
script.src = url;
|
||||
document.head.append(script);
|
||||
});
|
||||
|
||||
63
dist/extensions/ext-server_moinsave.js
vendored
63
dist/extensions/ext-server_moinsave.js
vendored
@@ -1097,7 +1097,7 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
if (!this.hasValue()) return 0;
|
||||
var n = parseFloat(this.value);
|
||||
|
||||
if (String(this.value).match(/%$/)) {
|
||||
if (String(this.value).endsWith('%')) {
|
||||
n /= 100.0;
|
||||
}
|
||||
|
||||
@@ -1205,15 +1205,15 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
value: function toPixels(viewPort, processPercent) {
|
||||
if (!this.hasValue()) return 0;
|
||||
var s = String(this.value);
|
||||
if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort);
|
||||
if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0;
|
||||
if (s.match(/px$/)) return this.numValue();
|
||||
if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
|
||||
if (s.match(/pc$/)) return this.numValue() * 15;
|
||||
if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54;
|
||||
if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4;
|
||||
if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort);
|
||||
if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
|
||||
if (s.endsWith('em')) return this.numValue() * this.getEM(viewPort);
|
||||
if (s.endsWith('ex')) return this.numValue() * this.getEM(viewPort) / 2.0;
|
||||
if (s.endsWith('px')) return this.numValue();
|
||||
if (s.endsWith('pt')) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
|
||||
if (s.endsWith('pc')) return this.numValue() * 15;
|
||||
if (s.endsWith('cm')) return this.numValue() * this.getDPI(viewPort) / 2.54;
|
||||
if (s.endsWith('mm')) return this.numValue() * this.getDPI(viewPort) / 25.4;
|
||||
if (s.endsWith('in')) return this.numValue() * this.getDPI(viewPort);
|
||||
if (s.endsWith('%')) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
|
||||
var n = this.numValue();
|
||||
if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);
|
||||
return n;
|
||||
@@ -1225,8 +1225,8 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
value: function toMilliseconds() {
|
||||
if (!this.hasValue()) return 0;
|
||||
var s = String(this.value);
|
||||
if (s.match(/s$/)) return this.numValue() * 1000;
|
||||
if (s.match(/ms$/)) return this.numValue();
|
||||
if (s.endsWith('ms')) return this.numValue();
|
||||
if (s.endsWith('s')) return this.numValue() * 1000;
|
||||
return this.numValue();
|
||||
} // angle extensions
|
||||
// get the angle as radians
|
||||
@@ -1236,9 +1236,9 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
value: function toRadians() {
|
||||
if (!this.hasValue()) return 0;
|
||||
var s = String(this.value);
|
||||
if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0);
|
||||
if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0);
|
||||
if (s.match(/rad$/)) return this.numValue();
|
||||
if (s.endsWith('deg')) return this.numValue() * (Math.PI / 180.0);
|
||||
if (s.endsWith('grad')) return this.numValue() * (Math.PI / 200.0);
|
||||
if (s.endsWith('rad')) return this.numValue();
|
||||
return this.numValue() * (Math.PI / 180.0);
|
||||
}
|
||||
}, {
|
||||
@@ -1734,10 +1734,10 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
|
||||
} else {
|
||||
// align
|
||||
if (align.match(/^xMid/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
|
||||
if (align.match(/YMid$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
|
||||
if (align.match(/^xMax/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
|
||||
if (align.match(/YMax$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
|
||||
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
|
||||
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
|
||||
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
|
||||
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
|
||||
} // scale
|
||||
|
||||
|
||||
@@ -1893,7 +1893,7 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
key: "getHrefAttribute",
|
||||
value: function getHrefAttribute() {
|
||||
for (var a in this.attributes) {
|
||||
if (a.match(/:href$/)) {
|
||||
if (a.endsWith(':href')) {
|
||||
return this.attributes[a];
|
||||
}
|
||||
}
|
||||
@@ -2516,9 +2516,9 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
|
||||
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
|
||||
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
|
||||
.replace(/([0-9])([+-])/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/(\.[0-9]*)(\.)/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm, '$1 $3 $4 '); // shorthand elliptical arc path syntax
|
||||
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
|
||||
|
||||
|
||||
d = svg.compressSpaces(d); // compress multiple spaces
|
||||
@@ -3861,14 +3861,14 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
_this20.img.crossOrigin = 'Anonymous';
|
||||
}
|
||||
|
||||
_this20.img.onload = function () {
|
||||
_this20.img.addEventListener('load', function () {
|
||||
_this20.loaded = true;
|
||||
};
|
||||
});
|
||||
|
||||
_this20.img.onerror = function () {
|
||||
_this20.img.addEventListener('error', function () {
|
||||
svg.log('ERROR: image "' + href + '" not found');
|
||||
_this20.loaded = true;
|
||||
};
|
||||
});
|
||||
|
||||
_this20.img.src = href;
|
||||
} else {
|
||||
@@ -4577,7 +4577,7 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
|
||||
|
||||
if (svg.opts.ignoreMouse !== true) {
|
||||
ctx.canvas.onclick = function (e) {
|
||||
ctx.canvas.addEventListener('click', function (e) {
|
||||
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
|
||||
|
||||
var _mapXY = mapXY(_construct(svg.Point, args)),
|
||||
@@ -4585,9 +4585,8 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
y = _mapXY.y;
|
||||
|
||||
svg.Mouse.onclick(x, y);
|
||||
};
|
||||
|
||||
ctx.canvas.onmousemove = function (e) {
|
||||
});
|
||||
ctx.canvas.addEventListener('mousemove', function (e) {
|
||||
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
|
||||
|
||||
var _mapXY2 = mapXY(_construct(svg.Point, args)),
|
||||
@@ -4595,7 +4594,7 @@ var svgEditorExtension_server_moinsave = (function () {
|
||||
y = _mapXY2.y;
|
||||
|
||||
svg.Mouse.onmousemove(x, y);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
var e = svg.CreateElement(dom.documentElement);
|
||||
|
||||
63
dist/extensions/ext-server_opensave.js
vendored
63
dist/extensions/ext-server_opensave.js
vendored
@@ -1097,7 +1097,7 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
if (!this.hasValue()) return 0;
|
||||
var n = parseFloat(this.value);
|
||||
|
||||
if (String(this.value).match(/%$/)) {
|
||||
if (String(this.value).endsWith('%')) {
|
||||
n /= 100.0;
|
||||
}
|
||||
|
||||
@@ -1205,15 +1205,15 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
value: function toPixels(viewPort, processPercent) {
|
||||
if (!this.hasValue()) return 0;
|
||||
var s = String(this.value);
|
||||
if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort);
|
||||
if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0;
|
||||
if (s.match(/px$/)) return this.numValue();
|
||||
if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
|
||||
if (s.match(/pc$/)) return this.numValue() * 15;
|
||||
if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54;
|
||||
if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4;
|
||||
if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort);
|
||||
if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
|
||||
if (s.endsWith('em')) return this.numValue() * this.getEM(viewPort);
|
||||
if (s.endsWith('ex')) return this.numValue() * this.getEM(viewPort) / 2.0;
|
||||
if (s.endsWith('px')) return this.numValue();
|
||||
if (s.endsWith('pt')) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
|
||||
if (s.endsWith('pc')) return this.numValue() * 15;
|
||||
if (s.endsWith('cm')) return this.numValue() * this.getDPI(viewPort) / 2.54;
|
||||
if (s.endsWith('mm')) return this.numValue() * this.getDPI(viewPort) / 25.4;
|
||||
if (s.endsWith('in')) return this.numValue() * this.getDPI(viewPort);
|
||||
if (s.endsWith('%')) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
|
||||
var n = this.numValue();
|
||||
if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);
|
||||
return n;
|
||||
@@ -1225,8 +1225,8 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
value: function toMilliseconds() {
|
||||
if (!this.hasValue()) return 0;
|
||||
var s = String(this.value);
|
||||
if (s.match(/s$/)) return this.numValue() * 1000;
|
||||
if (s.match(/ms$/)) return this.numValue();
|
||||
if (s.endsWith('ms')) return this.numValue();
|
||||
if (s.endsWith('s')) return this.numValue() * 1000;
|
||||
return this.numValue();
|
||||
} // angle extensions
|
||||
// get the angle as radians
|
||||
@@ -1236,9 +1236,9 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
value: function toRadians() {
|
||||
if (!this.hasValue()) return 0;
|
||||
var s = String(this.value);
|
||||
if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0);
|
||||
if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0);
|
||||
if (s.match(/rad$/)) return this.numValue();
|
||||
if (s.endsWith('deg')) return this.numValue() * (Math.PI / 180.0);
|
||||
if (s.endsWith('grad')) return this.numValue() * (Math.PI / 200.0);
|
||||
if (s.endsWith('rad')) return this.numValue();
|
||||
return this.numValue() * (Math.PI / 180.0);
|
||||
}
|
||||
}, {
|
||||
@@ -1734,10 +1734,10 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
|
||||
} else {
|
||||
// align
|
||||
if (align.match(/^xMid/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
|
||||
if (align.match(/YMid$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
|
||||
if (align.match(/^xMax/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
|
||||
if (align.match(/YMax$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
|
||||
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
|
||||
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
|
||||
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
|
||||
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
|
||||
} // scale
|
||||
|
||||
|
||||
@@ -1893,7 +1893,7 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
key: "getHrefAttribute",
|
||||
value: function getHrefAttribute() {
|
||||
for (var a in this.attributes) {
|
||||
if (a.match(/:href$/)) {
|
||||
if (a.endsWith(':href')) {
|
||||
return this.attributes[a];
|
||||
}
|
||||
}
|
||||
@@ -2516,9 +2516,9 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
|
||||
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
|
||||
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
|
||||
.replace(/([0-9])([+-])/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/(\.[0-9]*)(\.)/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm, '$1 $3 $4 '); // shorthand elliptical arc path syntax
|
||||
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
|
||||
|
||||
|
||||
d = svg.compressSpaces(d); // compress multiple spaces
|
||||
@@ -3861,14 +3861,14 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
_this20.img.crossOrigin = 'Anonymous';
|
||||
}
|
||||
|
||||
_this20.img.onload = function () {
|
||||
_this20.img.addEventListener('load', function () {
|
||||
_this20.loaded = true;
|
||||
};
|
||||
});
|
||||
|
||||
_this20.img.onerror = function () {
|
||||
_this20.img.addEventListener('error', function () {
|
||||
svg.log('ERROR: image "' + href + '" not found');
|
||||
_this20.loaded = true;
|
||||
};
|
||||
});
|
||||
|
||||
_this20.img.src = href;
|
||||
} else {
|
||||
@@ -4577,7 +4577,7 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
|
||||
|
||||
if (svg.opts.ignoreMouse !== true) {
|
||||
ctx.canvas.onclick = function (e) {
|
||||
ctx.canvas.addEventListener('click', function (e) {
|
||||
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
|
||||
|
||||
var _mapXY = mapXY(_construct(svg.Point, args)),
|
||||
@@ -4585,9 +4585,8 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
y = _mapXY.y;
|
||||
|
||||
svg.Mouse.onclick(x, y);
|
||||
};
|
||||
|
||||
ctx.canvas.onmousemove = function (e) {
|
||||
});
|
||||
ctx.canvas.addEventListener('mousemove', function (e) {
|
||||
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
|
||||
|
||||
var _mapXY2 = mapXY(_construct(svg.Point, args)),
|
||||
@@ -4595,7 +4594,7 @@ var svgEditorExtension_server_opensave = (function () {
|
||||
y = _mapXY2.y;
|
||||
|
||||
svg.Mouse.onmousemove(x, y);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
var e = svg.CreateElement(dom.documentElement);
|
||||
|
||||
6
dist/extensions/imagelib/index.js
vendored
6
dist/extensions/imagelib/index.js
vendored
@@ -43,8 +43,7 @@
|
||||
|
||||
if (!href.includes('.svg')) {
|
||||
var img = new Image();
|
||||
|
||||
img.onload = function () {
|
||||
img.addEventListener('load', function () {
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = this.width;
|
||||
canvas.height = this.height; // load the raster image into the canvas
|
||||
@@ -67,8 +66,7 @@
|
||||
href: href,
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
img.src = href;
|
||||
} else {
|
||||
// Do ajax request for image's href value
|
||||
|
||||
86
dist/index-es.js
vendored
86
dist/index-es.js
vendored
@@ -8328,7 +8328,7 @@ var getPathBBox = function getPathBBox(path$$1) {
|
||||
|
||||
var getCalc = function getCalc(j, P1, P2, P3) {
|
||||
return function (t) {
|
||||
return Math.pow(1 - t, 3) * P0[j] + 3 * Math.pow(1 - t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
|
||||
return 1 - Math.pow(t, 3) * P0[j] + 3 * 1 - Math.pow(t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -9458,27 +9458,37 @@ function importScript(url) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
// eslint-disable-line promise/avoid-new
|
||||
var script = document.createElement('script');
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
function scriptOnError() {
|
||||
reject(new Error("Failed to import: ".concat(url)));
|
||||
destructor();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function scriptOnLoad() {
|
||||
resolve();
|
||||
destructor();
|
||||
}
|
||||
|
||||
var destructor = function destructor() {
|
||||
script.onerror = null;
|
||||
script.onload = null;
|
||||
script.removeEventListener('error', scriptOnError);
|
||||
script.removeEventListener('load', scriptOnLoad);
|
||||
script.remove();
|
||||
script.src = '';
|
||||
};
|
||||
|
||||
script.defer = 'defer';
|
||||
addScriptAtts(script, atts);
|
||||
|
||||
script.onerror = function () {
|
||||
reject(new Error("Failed to import: ".concat(url)));
|
||||
destructor();
|
||||
};
|
||||
|
||||
script.onload = function () {
|
||||
resolve();
|
||||
destructor();
|
||||
};
|
||||
|
||||
script.addEventListener('error', scriptOnError);
|
||||
script.addEventListener('load', scriptOnLoad);
|
||||
script.src = url;
|
||||
document.head.append(script);
|
||||
});
|
||||
@@ -9510,11 +9520,30 @@ function importModule(url) {
|
||||
// eslint-disable-line promise/avoid-new
|
||||
var vector = '$importModule$' + Math.random().toString(32).slice(2);
|
||||
var script = document.createElement('script');
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
function scriptOnError() {
|
||||
reject(new Error("Failed to import: ".concat(url)));
|
||||
destructor();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function scriptOnLoad() {
|
||||
resolve(window[vector]);
|
||||
destructor();
|
||||
}
|
||||
|
||||
var destructor = function destructor() {
|
||||
delete window[vector];
|
||||
script.onerror = null;
|
||||
script.onload = null;
|
||||
script.removeEventListener('error', scriptOnError);
|
||||
script.removeEventListener('load', scriptOnLoad);
|
||||
script.remove();
|
||||
URL.revokeObjectURL(script.src);
|
||||
script.src = '';
|
||||
@@ -9523,17 +9552,8 @@ function importModule(url) {
|
||||
addScriptAtts(script, atts);
|
||||
script.defer = 'defer';
|
||||
script.type = 'module';
|
||||
|
||||
script.onerror = function () {
|
||||
reject(new Error("Failed to import: ".concat(url)));
|
||||
destructor();
|
||||
};
|
||||
|
||||
script.onload = function () {
|
||||
resolve(window[vector]);
|
||||
destructor();
|
||||
};
|
||||
|
||||
script.addEventListener('error', scriptOnError);
|
||||
script.addEventListener('load', scriptOnLoad);
|
||||
var absURL = toAbsoluteURL(url);
|
||||
var loader = "import * as m from '".concat(absURL.replace(/'/g, "\\'"), "'; window.").concat(vector, " = ").concat(returnDefault ? 'm.default || ' : '', "m;"); // export Module
|
||||
|
||||
@@ -17434,7 +17454,9 @@ function SvgCanvas(container, config) {
|
||||
|
||||
if (elem) {
|
||||
cleanupElement(elem);
|
||||
var attrs = Array.from(elem.attributes);
|
||||
|
||||
var attrs = _toConsumableArray(elem.attributes);
|
||||
|
||||
var childs = elem.childNodes;
|
||||
attrs.sort(function (a, b) {
|
||||
return a.name > b.name ? -1 : 1;
|
||||
@@ -35854,13 +35876,11 @@ editor.init = function () {
|
||||
var imgHeight = 100;
|
||||
var img = new Image();
|
||||
img.style.opacity = 0;
|
||||
|
||||
img.onload = function () {
|
||||
img.addEventListener('load', function () {
|
||||
imgWidth = img.offsetWidth || img.naturalWidth || img.width;
|
||||
imgHeight = img.offsetHeight || img.naturalHeight || img.height;
|
||||
insertNewImage(imgWidth, imgHeight);
|
||||
};
|
||||
|
||||
});
|
||||
img.src = result;
|
||||
};
|
||||
|
||||
@@ -36336,7 +36356,7 @@ editor.loadFromDataURI = function (str) {
|
||||
if (pre) {
|
||||
base64 = true;
|
||||
} else {
|
||||
pre = str.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/);
|
||||
pre = str.match(/^data:image\/svg\+xml(?:;|;utf8)?,/);
|
||||
}
|
||||
|
||||
if (pre) {
|
||||
|
||||
2
dist/index-es.min.js
vendored
2
dist/index-es.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index-es.min.js.map
vendored
2
dist/index-es.min.js.map
vendored
File diff suppressed because one or more lines are too long
86
dist/index-umd.js
vendored
86
dist/index-umd.js
vendored
@@ -8334,7 +8334,7 @@
|
||||
|
||||
var getCalc = function getCalc(j, P1, P2, P3) {
|
||||
return function (t) {
|
||||
return Math.pow(1 - t, 3) * P0[j] + 3 * Math.pow(1 - t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
|
||||
return 1 - Math.pow(t, 3) * P0[j] + 3 * 1 - Math.pow(t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -9464,27 +9464,37 @@
|
||||
return new Promise(function (resolve, reject) {
|
||||
// eslint-disable-line promise/avoid-new
|
||||
var script = document.createElement('script');
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
function scriptOnError() {
|
||||
reject(new Error("Failed to import: ".concat(url)));
|
||||
destructor();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function scriptOnLoad() {
|
||||
resolve();
|
||||
destructor();
|
||||
}
|
||||
|
||||
var destructor = function destructor() {
|
||||
script.onerror = null;
|
||||
script.onload = null;
|
||||
script.removeEventListener('error', scriptOnError);
|
||||
script.removeEventListener('load', scriptOnLoad);
|
||||
script.remove();
|
||||
script.src = '';
|
||||
};
|
||||
|
||||
script.defer = 'defer';
|
||||
addScriptAtts(script, atts);
|
||||
|
||||
script.onerror = function () {
|
||||
reject(new Error("Failed to import: ".concat(url)));
|
||||
destructor();
|
||||
};
|
||||
|
||||
script.onload = function () {
|
||||
resolve();
|
||||
destructor();
|
||||
};
|
||||
|
||||
script.addEventListener('error', scriptOnError);
|
||||
script.addEventListener('load', scriptOnLoad);
|
||||
script.src = url;
|
||||
document.head.append(script);
|
||||
});
|
||||
@@ -9516,11 +9526,30 @@
|
||||
// eslint-disable-line promise/avoid-new
|
||||
var vector = '$importModule$' + Math.random().toString(32).slice(2);
|
||||
var script = document.createElement('script');
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
function scriptOnError() {
|
||||
reject(new Error("Failed to import: ".concat(url)));
|
||||
destructor();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function scriptOnLoad() {
|
||||
resolve(window[vector]);
|
||||
destructor();
|
||||
}
|
||||
|
||||
var destructor = function destructor() {
|
||||
delete window[vector];
|
||||
script.onerror = null;
|
||||
script.onload = null;
|
||||
script.removeEventListener('error', scriptOnError);
|
||||
script.removeEventListener('load', scriptOnLoad);
|
||||
script.remove();
|
||||
URL.revokeObjectURL(script.src);
|
||||
script.src = '';
|
||||
@@ -9529,17 +9558,8 @@
|
||||
addScriptAtts(script, atts);
|
||||
script.defer = 'defer';
|
||||
script.type = 'module';
|
||||
|
||||
script.onerror = function () {
|
||||
reject(new Error("Failed to import: ".concat(url)));
|
||||
destructor();
|
||||
};
|
||||
|
||||
script.onload = function () {
|
||||
resolve(window[vector]);
|
||||
destructor();
|
||||
};
|
||||
|
||||
script.addEventListener('error', scriptOnError);
|
||||
script.addEventListener('load', scriptOnLoad);
|
||||
var absURL = toAbsoluteURL(url);
|
||||
var loader = "import * as m from '".concat(absURL.replace(/'/g, "\\'"), "'; window.").concat(vector, " = ").concat(returnDefault ? 'm.default || ' : '', "m;"); // export Module
|
||||
|
||||
@@ -17440,7 +17460,9 @@
|
||||
|
||||
if (elem) {
|
||||
cleanupElement(elem);
|
||||
var attrs = Array.from(elem.attributes);
|
||||
|
||||
var attrs = _toConsumableArray(elem.attributes);
|
||||
|
||||
var childs = elem.childNodes;
|
||||
attrs.sort(function (a, b) {
|
||||
return a.name > b.name ? -1 : 1;
|
||||
@@ -35860,13 +35882,11 @@
|
||||
var imgHeight = 100;
|
||||
var img = new Image();
|
||||
img.style.opacity = 0;
|
||||
|
||||
img.onload = function () {
|
||||
img.addEventListener('load', function () {
|
||||
imgWidth = img.offsetWidth || img.naturalWidth || img.width;
|
||||
imgHeight = img.offsetHeight || img.naturalHeight || img.height;
|
||||
insertNewImage(imgWidth, imgHeight);
|
||||
};
|
||||
|
||||
});
|
||||
img.src = result;
|
||||
};
|
||||
|
||||
@@ -36342,7 +36362,7 @@
|
||||
if (pre) {
|
||||
base64 = true;
|
||||
} else {
|
||||
pre = str.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/);
|
||||
pre = str.match(/^data:image\/svg\+xml(?:;|;utf8)?,/);
|
||||
}
|
||||
|
||||
if (pre) {
|
||||
|
||||
2
dist/index-umd.min.js
vendored
2
dist/index-umd.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index-umd.min.js.map
vendored
2
dist/index-umd.min.js.map
vendored
File diff suppressed because one or more lines are too long
6
dist/jspdf.plugin.svgToPdf.js
vendored
6
dist/jspdf.plugin.svgToPdf.js
vendored
@@ -428,14 +428,16 @@
|
||||
});
|
||||
};
|
||||
|
||||
var numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE][+-]?\d+)?/g;
|
||||
var numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE]\d+|[eE][+-]\d+)?/g;
|
||||
|
||||
var getLinesOptionsOfPoly = function getLinesOptionsOfPoly(node) {
|
||||
var nums = node.getAttribute('points');
|
||||
nums = nums && nums.match(numRgx) || [];
|
||||
|
||||
if (nums && nums.length) {
|
||||
nums = nums.map(Number);
|
||||
nums = nums.map(function (n) {
|
||||
return Number(n);
|
||||
});
|
||||
|
||||
if (nums.length % 2) {
|
||||
nums.length--;
|
||||
|
||||
Reference in New Issue
Block a user