mirror of https://github.com/xwiki-labs/cryptpad
Diagrams: Pass numbers as numbers to chainpad
https://github.com/cryptpad/cryptpad/issues/1063
This commit is contained in:
parent
5a1738111e
commit
4e773340ce
|
@ -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) => {
|
const xmlAsJsonContent = (xml) => {
|
||||||
var decompressedXml = decompressDrawioXml(xml);
|
var decompressedXml = decompressDrawioXml(xml);
|
||||||
return x2js.xml2js(decompressedXml);
|
return numbersToNumbers(x2js.xml2js(decompressedXml));
|
||||||
};
|
};
|
||||||
|
|
||||||
var onDrawioChange = function(newXml) {
|
var onDrawioChange = function(newXml) {
|
||||||
|
|
Loading…
Reference in New Issue