@flowgram.ai/free-auto-layout-plugin 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +27 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -2371,7 +2371,7 @@ var LayoutPosition = class {
|
|
|
2371
2371
|
updateNodePosition(params) {
|
|
2372
2372
|
const { layoutNode, step } = params;
|
|
2373
2373
|
const { transform } = layoutNode.entity.transform;
|
|
2374
|
-
const centerToTopEdgeOffset =
|
|
2374
|
+
const centerToTopEdgeOffset = (layoutNode.size.height - layoutNode.padding.top - layoutNode.padding.bottom) / 2;
|
|
2375
2375
|
const layoutPosition = {
|
|
2376
2376
|
x: layoutNode.position.x + layoutNode.offset.x,
|
|
2377
2377
|
y: layoutNode.position.y + layoutNode.offset.y - centerToTopEdgeOffset
|
|
@@ -2400,6 +2400,7 @@ var DagreLayout = class {
|
|
|
2400
2400
|
layout() {
|
|
2401
2401
|
this.graphSetData();
|
|
2402
2402
|
this.dagreLayout();
|
|
2403
|
+
this.alignTopEdgeIfNeeded();
|
|
2403
2404
|
this.layoutSetPosition();
|
|
2404
2405
|
}
|
|
2405
2406
|
dagreLayout() {
|
|
@@ -2484,6 +2485,28 @@ var DagreLayout = class {
|
|
|
2484
2485
|
};
|
|
2485
2486
|
});
|
|
2486
2487
|
}
|
|
2488
|
+
alignTopEdgeIfNeeded() {
|
|
2489
|
+
const { alignTopEdge } = this.store.options;
|
|
2490
|
+
const { rankdir, marginy = 0 } = this.store.config;
|
|
2491
|
+
if (!alignTopEdge || rankdir !== "LR" && rankdir !== "RL") {
|
|
2492
|
+
return;
|
|
2493
|
+
}
|
|
2494
|
+
const rankGroups = this.rankGroup(this.graph);
|
|
2495
|
+
rankGroups.forEach((indexSet) => {
|
|
2496
|
+
const graphNodes = Array.from(indexSet).map((id) => this.graph.node(id)).filter(Boolean);
|
|
2497
|
+
if (graphNodes.length === 0) {
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
const minTop = Math.min(...graphNodes.map((node) => node.y - node.height / 2));
|
|
2501
|
+
const deltaY = marginy - minTop;
|
|
2502
|
+
if (deltaY === 0) {
|
|
2503
|
+
return;
|
|
2504
|
+
}
|
|
2505
|
+
graphNodes.forEach((node) => {
|
|
2506
|
+
node.y += deltaY;
|
|
2507
|
+
});
|
|
2508
|
+
});
|
|
2509
|
+
}
|
|
2487
2510
|
normalizeNumber(number) {
|
|
2488
2511
|
return Number.isNaN(number) ? 0 : number;
|
|
2489
2512
|
}
|
|
@@ -2548,6 +2571,9 @@ var DagreLayout = class {
|
|
|
2548
2571
|
const rankGroup = /* @__PURE__ */ new Map();
|
|
2549
2572
|
g.nodes().forEach((i) => {
|
|
2550
2573
|
const graphNode = g.node(i);
|
|
2574
|
+
if (!graphNode || typeof graphNode.rank !== "number") {
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2551
2577
|
const rank2 = graphNode.rank;
|
|
2552
2578
|
if (!rankGroup.has(rank2)) {
|
|
2553
2579
|
rankGroup.set(rank2, /* @__PURE__ */ new Set());
|