@flowgram.ai/free-auto-layout-plugin 1.0.7 → 1.0.9

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/index.d.mts CHANGED
@@ -224,16 +224,29 @@ interface LayoutParams {
224
224
  layoutEdges: LayoutEdge[];
225
225
  }
226
226
  interface LayoutOptions {
227
+ /** Custom layout configuration to override default dagre settings. */
227
228
  layoutConfig?: Partial<LayoutConfig>;
229
+ /** The container node entity used as the root for the layout. */
228
230
  containerNode?: WorkflowNodeEntity;
231
+ /** Custom function to determine follow-node relationships between layout nodes. */
229
232
  getFollowNode?: GetFollowNode;
233
+ /** Whether to animate node movements during layout positioning. */
230
234
  enableAnimation?: boolean;
235
+ /** Duration of the position animation in milliseconds. Only effective when `enableAnimation` is true. */
231
236
  animationDuration?: number;
237
+ /** When true, skips the fit-view step after layout is applied. */
232
238
  disableFitView?: boolean;
239
+ /**
240
+ * When true, aligns nodes by their top edge instead of their center point.
241
+ * Defaults to false (center-aligned). Set to true to place all nodes' top edges on the same horizontal line.
242
+ */
243
+ alignTopEdge?: boolean;
244
+ /** Filter function to exclude specific nodes from the layout. Return false to skip a node. */
233
245
  filterNode?: (params: {
234
246
  node: WorkflowNodeEntity;
235
247
  parent?: WorkflowNodeEntity;
236
248
  }) => boolean;
249
+ /** Filter function to exclude specific edges from the layout. Return false to skip an edge. */
237
250
  filterLine?: (params: {
238
251
  line: WorkflowLineEntity;
239
252
  }) => boolean;
package/dist/index.d.ts CHANGED
@@ -224,16 +224,29 @@ interface LayoutParams {
224
224
  layoutEdges: LayoutEdge[];
225
225
  }
226
226
  interface LayoutOptions {
227
+ /** Custom layout configuration to override default dagre settings. */
227
228
  layoutConfig?: Partial<LayoutConfig>;
229
+ /** The container node entity used as the root for the layout. */
228
230
  containerNode?: WorkflowNodeEntity;
231
+ /** Custom function to determine follow-node relationships between layout nodes. */
229
232
  getFollowNode?: GetFollowNode;
233
+ /** Whether to animate node movements during layout positioning. */
230
234
  enableAnimation?: boolean;
235
+ /** Duration of the position animation in milliseconds. Only effective when `enableAnimation` is true. */
231
236
  animationDuration?: number;
237
+ /** When true, skips the fit-view step after layout is applied. */
232
238
  disableFitView?: boolean;
239
+ /**
240
+ * When true, aligns nodes by their top edge instead of their center point.
241
+ * Defaults to false (center-aligned). Set to true to place all nodes' top edges on the same horizontal line.
242
+ */
243
+ alignTopEdge?: boolean;
244
+ /** Filter function to exclude specific nodes from the layout. Return false to skip a node. */
233
245
  filterNode?: (params: {
234
246
  node: WorkflowNodeEntity;
235
247
  parent?: WorkflowNodeEntity;
236
248
  }) => boolean;
249
+ /** Filter function to exclude specific edges from the layout. Return false to skip an edge. */
237
250
  filterLine?: (params: {
238
251
  line: WorkflowLineEntity;
239
252
  }) => boolean;
package/dist/index.js CHANGED
@@ -2192,10 +2192,10 @@ var LayoutStore = class {
2192
2192
  const blockIdSet = new Set(blocks.map((b) => b.id));
2193
2193
  const groupFromEdges = edges.filter((edge) => blockIdSet.has(edge.to?.id ?? "")).map((edge) => {
2194
2194
  const { from, to } = edge.info;
2195
- if (!from || !to || edge.vertical) {
2195
+ if (!from || !to) {
2196
2196
  return;
2197
2197
  }
2198
- const id = `virtual_${groupId}_${to}`;
2198
+ const id = `virtual_${groupId}_from_${from}_to_${to}`;
2199
2199
  const layoutEdge = {
2200
2200
  id,
2201
2201
  entity: edge,
@@ -2211,10 +2211,10 @@ var LayoutStore = class {
2211
2211
  }).filter(Boolean);
2212
2212
  const groupToEdges = edges.filter((edge) => blockIdSet.has(edge.from?.id ?? "")).map((edge) => {
2213
2213
  const { from, to } = edge.info;
2214
- if (!from || !to || edge.vertical) {
2214
+ if (!from || !to) {
2215
2215
  return;
2216
2216
  }
2217
- const id = `virtual_${groupId}_${from}`;
2217
+ const id = `virtual_${groupId}_from_${from}_to_${to}`;
2218
2218
  const layoutEdge = {
2219
2219
  id,
2220
2220
  entity: edge,
@@ -2371,10 +2371,10 @@ var LayoutPosition = class {
2371
2371
  updateNodePosition(params) {
2372
2372
  const { layoutNode, step } = params;
2373
2373
  const { transform } = layoutNode.entity.transform;
2374
+ const centerToTopEdgeOffset = this.store.options.alignTopEdge ? 0 : (layoutNode.size.height - layoutNode.padding.top - layoutNode.padding.bottom) / 2;
2374
2375
  const layoutPosition = {
2375
2376
  x: layoutNode.position.x + layoutNode.offset.x,
2376
- // layoutNode.position.y 是中心点,但画布节点原点在上边沿的中间,所以 y 坐标需要转化后一下
2377
- y: layoutNode.position.y + layoutNode.offset.y - (layoutNode.size.height - layoutNode.padding.top - layoutNode.padding.bottom) / 2
2377
+ y: layoutNode.position.y + layoutNode.offset.y - centerToTopEdgeOffset
2378
2378
  };
2379
2379
  const deltaX = (layoutPosition.x - transform.position.x) * step / 100;
2380
2380
  const deltaY = (layoutPosition.y - transform.position.y) * step / 100;