|
|
@@ -1,9 +1,9 @@
|
|
|
// transplanted from https://github.com/jgraph/drawio-tools/blob/d46977060ffad70cae5a9059a2cbfcd8bcf420de/tools/convert.html
|
|
|
import pako from 'pako';
|
|
|
-import xmldoc from 'xmldoc';
|
|
|
|
|
|
+const unconpressedDataRegexp = new RegExp('<mxGraphModel');
|
|
|
const validateUncompressedData = (input: string): boolean => {
|
|
|
- return new RegExp('/<mxGraphModel/').test(input);
|
|
|
+ return unconpressedDataRegexp.test(input);
|
|
|
};
|
|
|
|
|
|
const validateCompressedData = (input: string): boolean => {
|
|
|
@@ -60,14 +60,14 @@ export const generateMxgraphData = (code: string): string => {
|
|
|
// Evaluate the code is whether uncompressed data that are generated by v21.1.0 or above
|
|
|
// see: https://github.com/jgraph/drawio/issues/3106#issuecomment-1479352026
|
|
|
const isUncompressedData = validateUncompressedData(trimedCode);
|
|
|
- if (isUncompressedData) {
|
|
|
+ if (!isUncompressedData) {
|
|
|
validateCompressedData(trimedCode);
|
|
|
}
|
|
|
|
|
|
const xml = `
|
|
|
<mxfile version="6.8.9" editor="www.draw.io" type="atlas">
|
|
|
<mxAtlasLibraries/>
|
|
|
- <diagram>${isUncompressedData ? xmldoc.XmlDocument(trimedCode) : trimedCode}</diagram>
|
|
|
+ <diagram>${trimedCode}</diagram>
|
|
|
</mxfile>
|
|
|
`;
|
|
|
|