From 22490b4cd759b8a530d9d36f4ad22d959916a344 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 12 Feb 2022 10:16:15 -0800 Subject: [PATCH] Introduce workaround to fix maps with order sequence holes --- .../playground/map-render/html/viewmode.html | 1 + .../samples/{bug7.wxml => sample8.wxml} | 0 .../persistence/XMLSerializerPela.ts | 18 ++++++++++-------- 3 files changed, 11 insertions(+), 8 deletions(-) rename packages/editor/test/playground/map-render/samples/{bug7.wxml => sample8.wxml} (100%) diff --git a/packages/editor/test/playground/map-render/html/viewmode.html b/packages/editor/test/playground/map-render/html/viewmode.html index 6122f96e..d2351e79 100644 --- a/packages/editor/test/playground/map-render/html/viewmode.html +++ b/packages/editor/test/playground/map-render/html/viewmode.html @@ -24,6 +24,7 @@ + diff --git a/packages/editor/test/playground/map-render/samples/bug7.wxml b/packages/editor/test/playground/map-render/samples/sample8.wxml similarity index 100% rename from packages/editor/test/playground/map-render/samples/bug7.wxml rename to packages/editor/test/playground/map-render/samples/sample8.wxml diff --git a/packages/mindplot/src/components/persistence/XMLSerializerPela.ts b/packages/mindplot/src/components/persistence/XMLSerializerPela.ts index cabe08c4..9f163618 100644 --- a/packages/mindplot/src/components/persistence/XMLSerializerPela.ts +++ b/packages/mindplot/src/components/persistence/XMLSerializerPela.ts @@ -226,14 +226,6 @@ class XMLSerializerPela implements XMLMindmapSerializer { 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) { $assert(dom, 'dom 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; }