MCPcopy Create free account
hub / github.com/OpenDCAI/Paper2Any / splitTopLevelChildren

Function splitTopLevelChildren

frontend-workflow/src/utils/mindmapTree.ts:192–212  ·  view source on GitHub ↗
(children: MindMapTreeNode[])

Source from the content-addressed store, hash-verified

190};
191
192const splitTopLevelChildren = (children: MindMapTreeNode[]) => {
193 const left: MindMapTreeNode[] = [];
194 const right: MindMapTreeNode[] = [];
195 let leftHeight = 0;
196 let rightHeight = 0;
197
198 [...children]
199 .sort((a, b) => measureHeight(b) - measureHeight(a))
200 .forEach((child, index) => {
201 const childHeight = measureHeight(child);
202 if ((index % 2 === 0 && rightHeight <= leftHeight) || leftHeight > rightHeight) {
203 right.push(child);
204 rightHeight += childHeight;
205 } else {
206 left.push(child);
207 leftHeight += childHeight;
208 }
209 });
210
211 return { left, right };
212};
213
214const layoutGroup = (
215 children: MindMapTreeNode[],

Callers 1

buildMindMapFlowFunction · 0.85

Calls 1

measureHeightFunction · 0.85

Tested by

no test coverage detected