Diagrams: Pass numbers as numbers to chainpad

https://github.com/cryptpad/cryptpad/issues/1063
This commit is contained in:
Wolfgang Ginolas 2023-06-26 09:17:50 +02:00
parent 5a1738111e
commit 4e773340ce
1 changed files with 16 additions and 1 deletions

View File

@ -83,9 +83,24 @@ define([
});
};
const numbersToNumbers = function(o) {
const type = typeof o;
if (type === "object") {
for (const key in o) {
o[key] = numbersToNumbers(o[key]);
}
return o;
} else if (type === 'string' && o.match(/^[+-]?(0|(([1-9]\d*)(\.\d+)?))$/)) {
return parseFloat(o, 10);
} else {
return o;
}
}
const xmlAsJsonContent = (xml) => {
var decompressedXml = decompressDrawioXml(xml);
return x2js.xml2js(decompressedXml);
return numbersToNumbers(x2js.xml2js(decompressedXml));
};
var onDrawioChange = function(newXml) {