@flowgram.ai/free-auto-layout-plugin 0.1.0-alpha.18 → 0.1.0-alpha.19
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 +9 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -224,11 +224,16 @@ interface LayoutParams {
|
|
|
224
224
|
layoutEdges: LayoutEdge[];
|
|
225
225
|
}
|
|
226
226
|
interface LayoutOptions {
|
|
227
|
+
layoutConfig?: Partial<LayoutConfig>;
|
|
227
228
|
containerNode?: WorkflowNodeEntity;
|
|
228
229
|
getFollowNode?: GetFollowNode;
|
|
229
230
|
enableAnimation?: boolean;
|
|
230
231
|
animationDuration?: number;
|
|
231
232
|
disableFitView?: boolean;
|
|
233
|
+
filterNode?: (params: {
|
|
234
|
+
node: WorkflowNodeEntity;
|
|
235
|
+
parent?: WorkflowNodeEntity;
|
|
236
|
+
}) => boolean;
|
|
232
237
|
}
|
|
233
238
|
interface LayoutConfig {
|
|
234
239
|
/** Direction for rank nodes. Can be TB, BT, LR, or RL, where T = top, B = bottom, L = left, and R = right. */
|
|
@@ -267,6 +272,10 @@ interface AutoLayoutOptions {
|
|
|
267
272
|
layoutConfig?: Partial<LayoutConfig>;
|
|
268
273
|
}
|
|
269
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Auto layout plugin - 自动布局插件
|
|
277
|
+
* https://flowgram.ai/guide/plugin/free-auto-layout-plugin.html
|
|
278
|
+
*/
|
|
270
279
|
declare const createFreeAutoLayoutPlugin: _flowgram_ai_core.PluginCreator<AutoLayoutOptions>;
|
|
271
280
|
|
|
272
281
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -224,11 +224,16 @@ interface LayoutParams {
|
|
|
224
224
|
layoutEdges: LayoutEdge[];
|
|
225
225
|
}
|
|
226
226
|
interface LayoutOptions {
|
|
227
|
+
layoutConfig?: Partial<LayoutConfig>;
|
|
227
228
|
containerNode?: WorkflowNodeEntity;
|
|
228
229
|
getFollowNode?: GetFollowNode;
|
|
229
230
|
enableAnimation?: boolean;
|
|
230
231
|
animationDuration?: number;
|
|
231
232
|
disableFitView?: boolean;
|
|
233
|
+
filterNode?: (params: {
|
|
234
|
+
node: WorkflowNodeEntity;
|
|
235
|
+
parent?: WorkflowNodeEntity;
|
|
236
|
+
}) => boolean;
|
|
232
237
|
}
|
|
233
238
|
interface LayoutConfig {
|
|
234
239
|
/** Direction for rank nodes. Can be TB, BT, LR, or RL, where T = top, B = bottom, L = left, and R = right. */
|
|
@@ -267,6 +272,10 @@ interface AutoLayoutOptions {
|
|
|
267
272
|
layoutConfig?: Partial<LayoutConfig>;
|
|
268
273
|
}
|
|
269
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Auto layout plugin - 自动布局插件
|
|
277
|
+
* https://flowgram.ai/guide/plugin/free-auto-layout-plugin.html
|
|
278
|
+
*/
|
|
270
279
|
declare const createFreeAutoLayoutPlugin: _flowgram_ai_core.PluginCreator<AutoLayoutOptions>;
|
|
271
280
|
|
|
272
281
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2126,6 +2126,7 @@ var DefaultLayoutConfig = {
|
|
|
2126
2126
|
ranker: "network-simplex"
|
|
2127
2127
|
};
|
|
2128
2128
|
var DefaultLayoutOptions = {
|
|
2129
|
+
filterNode: void 0,
|
|
2129
2130
|
getFollowNode: void 0,
|
|
2130
2131
|
disableFitView: false,
|
|
2131
2132
|
enableAnimation: false,
|
|
@@ -2617,7 +2618,11 @@ var AutoLayoutService = class {
|
|
|
2617
2618
|
return [];
|
|
2618
2619
|
}
|
|
2619
2620
|
const childrenLayouts = (await Promise.all(layoutNodes.map((n) => this.layoutNode(n, options)))).flat();
|
|
2620
|
-
const
|
|
2621
|
+
const layoutConfig = {
|
|
2622
|
+
...this.layoutConfig,
|
|
2623
|
+
...options.layoutConfig
|
|
2624
|
+
};
|
|
2625
|
+
const layout2 = new Layout(layoutConfig);
|
|
2621
2626
|
layout2.init({ container, layoutNodes, layoutEdges }, options);
|
|
2622
2627
|
layout2.layout();
|
|
2623
2628
|
const rect = this.getLayoutNodeRect(container);
|
|
@@ -2632,7 +2637,9 @@ var AutoLayoutService = class {
|
|
|
2632
2637
|
}
|
|
2633
2638
|
/** 创建节点布局数据 */
|
|
2634
2639
|
createLayoutNode(node, options) {
|
|
2635
|
-
const
|
|
2640
|
+
const blocks = node.blocks.filter(
|
|
2641
|
+
(blockNode) => options.filterNode ? options.filterNode?.({ node: blockNode, parent: node.parent }) : true
|
|
2642
|
+
);
|
|
2636
2643
|
const edges = this.getNodesAllLines(blocks);
|
|
2637
2644
|
const layoutNodes = this.createLayoutNodes(blocks, options);
|
|
2638
2645
|
const layoutEdges = this.createLayoutEdges(edges);
|