Update to allow commas (#1023)

* update dependencies
* allow commas for separators
This commit is contained in:
JFH
2025-02-23 14:21:25 +01:00
committed by GitHub
parent 403237c182
commit 42840d51de
6 changed files with 487 additions and 381 deletions

View File

@@ -982,7 +982,7 @@ const convertToGroup = elem => {
const vb = elem.getAttribute('viewBox')
if (vb) {
const nums = vb.split(' ')
const nums = vb.split(/[ ,]+/)
pos.x -= Number(nums[0])
pos.y -= Number(nums[1])
}

View File

@@ -427,7 +427,7 @@ const setRotationAngle = (val, preventUndo) => {
// new transform is something like: 'rotate(5 1.39625e-8 -11)'
// we round the x so it becomes 'rotate(5 0 -11)'
if (newTransform) {
const newTransformArray = newTransform.split(' ')
const newTransformArray = newTransform.split(/[ ,]+/)
const round = (num) => Math.round(Number(num) + Number.EPSILON)
const x = round(newTransformArray[1])
newTransform = `${newTransformArray[0]} ${x} ${newTransformArray[2]}`

View File

@@ -522,7 +522,7 @@ const setSvgString = (xmlString, preventUndo) => {
// determine proper size
if (content.getAttribute('viewBox')) {
const viBox = content.getAttribute('viewBox')
const vb = viBox.split(' ')
const vb = viBox.split(/[ ,]+/)
attrs.width = vb[2]
attrs.height = vb[3]
// handle content that doesn't have a viewBox
@@ -657,7 +657,7 @@ const importSvgString = (xmlString, preserveDimension) => {
const innerh = convertToNum('height', svg.getAttribute('height'))
const innervb = svg.getAttribute('viewBox')
// if no explicit viewbox, create one out of the width and height
const vb = innervb ? innervb.split(' ') : [0, 0, innerw, innerh]
const vb = innervb ? innervb.split(/[ ,]+/) : [0, 0, innerw, innerh]
for (j = 0; j < 4; ++j) {
vb[j] = Number(vb[j])
}