diff --git a/packages/mindplot/src/components/import/FreemindImporter.ts b/packages/mindplot/src/components/import/FreemindImporter.ts index d76255c2..b984d752 100644 --- a/packages/mindplot/src/components/import/FreemindImporter.ts +++ b/packages/mindplot/src/components/import/FreemindImporter.ts @@ -42,7 +42,6 @@ export default class FreemindImporter extends Importer { this.mindmap = new Mindmap(nameMap); this.nodesmap = new Map(); this.relationship = new Array(); - let wiseTopicId = 0; const parser = new DOMParser(); const freemindDoc = parser.parseFromString(this.freemindInput, 'application/xml'); @@ -62,7 +61,7 @@ export default class FreemindImporter extends Importer { const freeNode: FreemindNode = this.freemindMap.getNode(); this.mindmap.setVersion(FreemindConstant.CODE_VERSION); - wiseTopicId++; + const wiseTopicId = parseInt(this.freemindMap.getNode().getId().split('_')[1], 10); const wiseTopic = this.mindmap.createNode('CentralTopic'); wiseTopic.setPosition(0, 0); wiseTopic.setId(wiseTopicId); diff --git a/packages/mindplot/test/unit/import/Helper.ts b/packages/mindplot/test/unit/import/Helper.ts index a78553a9..3e9d513e 100644 --- a/packages/mindplot/test/unit/import/Helper.ts +++ b/packages/mindplot/test/unit/import/Helper.ts @@ -27,11 +27,7 @@ export const parseXMLString = (xmlStr: string, mimeType: DOMParserSupportedType) export const parseXMLFile = (filePath: fs.PathOrFileDescriptor, mimeType: DOMParserSupportedType) => { const stream = fs.readFileSync(filePath, { encoding: 'utf-8' }); - let content = stream.toString(); - // Hack for SVG exported from the browser ... - if (mimeType === 'image/svg+xml') { - content = content.replace(' { const mapDocument = parseXMLFile(freemapPath, 'text/xml'); const freemap: FreemindMap = new FreemindMap().loadFromDom(mapDocument); + const freemapXml = freemap.toXml(); + const freemapStr = new XMLSerializer().serializeToString(freemapXml); - const importer = TextImporterFactory.create('mm', freemap); + const importer = TextImporterFactory.create('mm', freemapStr); await exporterAssert(testName, importer); }); diff --git a/packages/mindplot/test/unit/import/expected/emptyNodes.wxml b/packages/mindplot/test/unit/import/expected/emptyNodes.wxml index 47288b6b..50803a15 100644 --- a/packages/mindplot/test/unit/import/expected/emptyNodes.wxml +++ b/packages/mindplot/test/unit/import/expected/emptyNodes.wxml @@ -1,5 +1,5 @@ - + diff --git a/packages/mindplot/test/unit/import/expected/i18n.wxml b/packages/mindplot/test/unit/import/expected/i18n.wxml index 302aa541..91ed0e2b 100644 --- a/packages/mindplot/test/unit/import/expected/i18n.wxml +++ b/packages/mindplot/test/unit/import/expected/i18n.wxml @@ -1,5 +1,5 @@ - + diff --git a/packages/mindplot/test/unit/import/expected/i18n2.wxml b/packages/mindplot/test/unit/import/expected/i18n2.wxml index dd5b32e8..dc52227e 100644 --- a/packages/mindplot/test/unit/import/expected/i18n2.wxml +++ b/packages/mindplot/test/unit/import/expected/i18n2.wxml @@ -1,5 +1,5 @@ - + [ diff --git a/packages/mindplot/test/unit/import/expected/process.wxml b/packages/mindplot/test/unit/import/expected/process.wxml index 5a38fa1c..21972ee1 100644 --- a/packages/mindplot/test/unit/import/expected/process.wxml +++ b/packages/mindplot/test/unit/import/expected/process.wxml @@ -1,5 +1,5 @@ - +