Skip to content

Commit de3c5da

Browse files
authored
feat(fixed-layout): add simple-split node (bytedance#224)
* feat(fixed-layout): add simple-split node * fix(fixed-layout): svg overflow visible
1 parent a98244c commit de3c5da

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

packages/canvas-engine/document/src/typings/flow.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export enum FlowNodeBaseType {
3434
}
3535

3636
export enum FlowNodeSplitType {
37+
SIMPLE_SPLIT = 'simpleSplit', // 无 BlockOrderIcon
3738
DYNAMIC_SPLIT = 'dynamicSplit', // 动态分支
3839
STATIC_SPLIT = 'staticSplit', // 静态分支
3940
}

packages/canvas-engine/fixed-layout-core/src/activities/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export * from './loop';
1010
export * from './root';
1111
export * from './empty';
1212
export * from './end';
13+
export * from './simple-split';
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import {
2+
type FlowNodeRegistry,
3+
FlowNodeSplitType,
4+
FlowNodeBaseType,
5+
FlowNodeJSON,
6+
FlowNodeEntity,
7+
} from '@flowgram.ai/document';
8+
9+
/**
10+
* 可以动态添加分支的分支节点, 无 BlockOrderIcon 节点
11+
* simpleSplit: (最原始的 id)
12+
* blockIcon
13+
* inlineBlocks
14+
* block1
15+
* block2
16+
*/
17+
export const SimpleSplitRegistry: FlowNodeRegistry = {
18+
type: FlowNodeSplitType.SIMPLE_SPLIT,
19+
extend: FlowNodeSplitType.DYNAMIC_SPLIT,
20+
onBlockChildCreate(
21+
originParent: FlowNodeEntity,
22+
blockData: FlowNodeJSON,
23+
addedNodes: FlowNodeEntity[] = [] // 新创建的节点都要存在这里
24+
) {
25+
const { document } = originParent;
26+
const parent = document.getNode(`$inlineBlocks$${originParent.id}`);
27+
// 块节点会生成一个空的 Block 节点用来切割 Block
28+
const proxyBlock = document.addNode({
29+
id: `$block$${blockData.id}`,
30+
type: FlowNodeBaseType.BLOCK,
31+
originParent,
32+
parent,
33+
});
34+
const realBlock = document.addNode(
35+
{
36+
...blockData,
37+
type: blockData.type || FlowNodeBaseType.BLOCK,
38+
parent: proxyBlock,
39+
},
40+
addedNodes
41+
);
42+
addedNodes.push(proxyBlock, realBlock);
43+
return proxyBlock;
44+
},
45+
// addChild(node, json, options = {}) {
46+
// const { index } = options;
47+
// const document = node.document;
48+
// return document.addBlock(node, json, undefined, undefined, index);
49+
// }
50+
};

packages/canvas-engine/fixed-layout-core/src/flow-registers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
StartRegistry,
3232
StaticSplitRegistry,
3333
TryCatchRegistry,
34+
SimpleSplitRegistry,
3435
} from './activities';
3536

3637
@injectable()
@@ -50,6 +51,7 @@ export class FlowRegisters
5051
StartRegistry, // 开始节点
5152
DynamicSplitRegistry, // 动态分支(并行、排他)
5253
StaticSplitRegistry, // 静态分支(审批)
54+
SimpleSplitRegistry, // 简单分支 (不带 orderIcon 节点)
5355
BlockRegistry, // 单条 block 注册
5456
InlineBlocksRegistry, // 多个 block 组成的 block 列表
5557
BlockIconRegistry, // icon 节点,如条件分支的菱形图标

packages/client/fixed-layout-editor/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
background-color: var(--g-editor-background);
2626
}
2727

28+
.gedit-playground .flow-lines-container {
29+
overflow: visible;
30+
}
31+
2832
.gedit-transition-ease {
2933
transition: left, top 0.3s ease;
3034
}

0 commit comments

Comments
 (0)