From 0b51636d8af10d2166d035e1bebd52929c4875b8 Mon Sep 17 00:00:00 2001 From: Wojtek Szybisty Date: Thu, 18 May 2023 05:33:23 +0200 Subject: [PATCH] Fixed issue with mindmap format script that elements within group were not formatted along with selected element --- ea-scripts/Mindmap format.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ea-scripts/Mindmap format.md b/ea-scripts/Mindmap format.md index 4044363..fc753fb 100644 --- a/ea-scripts/Mindmap format.md +++ b/ea-scripts/Mindmap format.md @@ -55,6 +55,8 @@ if (!settings["MindMap Format"]) { ea.setScriptSettings(settings); } +const sceneElements = ea.getExcalidrawAPI().getSceneElements(); + // default X coordinate of the middle point of the arc const defaultDotX = Number(settings["curve length"].value); // The default length from the middle point of the arc on the X axis @@ -137,9 +139,16 @@ const setTextXY = (rect, text) => { }; const setChildrenXY = (parent, children, line, elementsMap) => { - children.x = parent.x + parent.width + line.points[2][0]; - children.y = - parent.y + parent.height / 2 + line.points[2][1] - children.height / 2; + x = parent.x + parent.width + line.points[2][0]; + y = parent.y + parent.height / 2 + line.points[2][1] - children.height / 2; + distX = children.x - x; + distY = children.y - y; + + ea.getElementsInTheSameGroupWithElement(children, sceneElements).forEach((el) => { + el.x = el.x - distX; + el.y = el.y - distY; + }); + if ( ["rectangle", "diamond", "ellipse"].includes(children.type) && ![null, undefined].includes(children.boundElements)