Introduce workaround to fix maps with order sequence holes

This commit is contained in:
Paulo Gustavo Veiga 2022-02-12 10:16:15 -08:00
parent 0a70199f53
commit 22490b4cd7
3 changed files with 11 additions and 8 deletions

View File

@ -24,6 +24,7 @@
<option value="sample5">sample5</option> <option value="sample5">sample5</option>
<option value="sample6">sample6</option> <option value="sample6">sample6</option>
<option value="sample7">sample7</option> <option value="sample7">sample7</option>
<option value="sample8">sample8</option>
<option value="img-support">img-support</option> <option value="img-support">img-support</option>
<option value="error-on-load">error-on-load</option> <option value="error-on-load">error-on-load</option>
<option value="complex">complex</option> <option value="complex">complex</option>

View File

@ -226,14 +226,6 @@ class XMLSerializerPela implements XMLMindmapSerializer {
return result; return result;
} }
/**
* @param dom
* @param mapId
* @throws will throw an error if dom is null or undefined
* @throws will throw an error if mapId is null or undefined
* @throws will throw an error if the document element is not consistent with a wisemap's root
* element
*/
loadFromDom(dom: Document, mapId: string) { loadFromDom(dom: Document, mapId: string) {
$assert(dom, 'dom can not be null'); $assert(dom, 'dom can not be null');
$assert(mapId, 'mapId can not be null'); $assert(mapId, 'mapId can not be null');
@ -415,6 +407,16 @@ class XMLSerializerPela implements XMLMindmapSerializer {
} }
}); });
// Workaround: for some reason, some saved maps have holes in the order.
topic
.getChildren()
.forEach((child, index) => {
if (child.getOrder() !== index) {
child.setOrder(index);
console.log('Toppic with order sequence hole. Introducing fix.');
}
});
return topic; return topic;
} }