fix set id in nodes

This commit is contained in:
Ezequiel-Vega 2022-03-22 12:34:27 -03:00
parent cb9f0e7abe
commit afa8e05f80
7 changed files with 9 additions and 12 deletions

View File

@ -42,7 +42,6 @@ export default class FreemindImporter extends Importer {
this.mindmap = new Mindmap(nameMap);
this.nodesmap = new Map<string, NodeModel>();
this.relationship = new Array<RelationshipModel>();
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);

View File

@ -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('<svg ', '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ');
}
const content = stream.toString();
return parseXMLString(content, mimeType);
};

View File

@ -17,8 +17,10 @@ describe('MM import test execution', () => {
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);
});

View File

@ -1,5 +1,5 @@
<map name="emptyNodes" version="tango">
<topic central="true" id="1" fontStyle=";;;;;;#0000cc;;;" bgColor="#ffcc33">
<topic central="true" id="0" fontStyle=";;;;;;#0000cc;;;" bgColor="#ffcc33">
<topic position="200,-50" order="0" text="objectifs journée" shape="rounded rectagle" id="1" fontStyle=";;;;Arial;8;#0000cc;;;" bgColor="#808080">
<topic position="200,-100" order="0" text="&quot;business plan&quot; associatif ?" shape="rounded rectagle" id="2" fontStyle=";;;;Arial;8;#0000cc;;;" bgColor="#808080"/>
<topic position="-290,-87" order="0" text="modèle / activités responsabilités" shape="rounded rectagle" id="3" fontStyle=";;;;Arial;8;#0000cc;;;" bgColor="#808080"/>

View File

@ -1,5 +1,5 @@
<map name="i18n" version="tango">
<topic central="true" text="i18n" id="1">
<topic central="true" text="i18n" id="0">
<topic position="200,-50" order="0" text="Este es un é con acento" shape="line" id="1"/>
<topic position="-290,-12" order="0" text="Este es una ñ" shape="line" id="2"/>
<topic position="-380,0" order="1" text="這是一個樣本 Japanise。" shape="line" id="3"/>

View File

@ -1,5 +1,5 @@
<map name="i18n2" version="tango">
<topic central="true" text="أَبْجَدِيَّة عَرَبِيَّة" id="1">
<topic central="true" text="أَبْجَدِيَّة عَرَبِيَّة" id="0">
<topic position="200,0" order="0" text="أَبْجَدِيَّة عَرَبِ" shape="line" id="1">
<note><![CDATA[[]]></note>
</topic>

View File

@ -1,5 +1,5 @@
<map name="process" version="tango">
<topic central="true" text="California" id="1">
<topic central="true" text="California" id="0">
<topic position="-200,-200" order="1" text="Northern California" shape="line" id="1">
<topic position="-200,-250" order="1" text="Oakland/Berkeley" shape="line" id="2"/>
<topic position="290,-275" order="0" text="San Mateo" shape="line" id="3"/>