feat(fixed-layout): add simple-split node

This commit is contained in:
xiamidaxia 2025-05-13 16:47:22 +08:00
parent a98244c6a3
commit ec02e939a4
4 changed files with 54 additions and 0 deletions

View File

@ -34,6 +34,7 @@ export enum FlowNodeBaseType {
} }
export enum FlowNodeSplitType { export enum FlowNodeSplitType {
SIMPLE_SPLIT = 'simpleSplit', // 无 BlockOrderIcon
DYNAMIC_SPLIT = 'dynamicSplit', // 动态分支 DYNAMIC_SPLIT = 'dynamicSplit', // 动态分支
STATIC_SPLIT = 'staticSplit', // 静态分支 STATIC_SPLIT = 'staticSplit', // 静态分支
} }

View File

@ -10,3 +10,4 @@ export * from './loop';
export * from './root'; export * from './root';
export * from './empty'; export * from './empty';
export * from './end'; export * from './end';
export * from './simple-split';

View File

@ -0,0 +1,50 @@
import {
type FlowNodeRegistry,
FlowNodeSplitType,
FlowNodeBaseType,
FlowNodeJSON,
FlowNodeEntity,
} from '@flowgram.ai/document';
/**
* , BlockOrderIcon
* simpleSplit: ( id)
* blockIcon
* inlineBlocks
* block1
* block2
*/
export const SimpleSplitRegistry: FlowNodeRegistry = {
type: FlowNodeSplitType.SIMPLE_SPLIT,
extend: FlowNodeSplitType.DYNAMIC_SPLIT,
onBlockChildCreate(
originParent: FlowNodeEntity,
blockData: FlowNodeJSON,
addedNodes: FlowNodeEntity[] = [] // 新创建的节点都要存在这里
) {
const { document } = originParent;
const parent = document.getNode(`$inlineBlocks$${originParent.id}`);
// 块节点会生成一个空的 Block 节点用来切割 Block
const proxyBlock = document.addNode({
id: `$block$${blockData.id}`,
type: FlowNodeBaseType.BLOCK,
originParent,
parent,
});
const realBlock = document.addNode(
{
...blockData,
type: blockData.type || FlowNodeBaseType.BLOCK,
parent: proxyBlock,
},
addedNodes
);
addedNodes.push(proxyBlock, realBlock);
return proxyBlock;
},
// addChild(node, json, options = {}) {
// const { index } = options;
// const document = node.document;
// return document.addBlock(node, json, undefined, undefined, index);
// }
};

View File

@ -31,6 +31,7 @@ import {
StartRegistry, StartRegistry,
StaticSplitRegistry, StaticSplitRegistry,
TryCatchRegistry, TryCatchRegistry,
SimpleSplitRegistry,
} from './activities'; } from './activities';
@injectable() @injectable()
@ -50,6 +51,7 @@ export class FlowRegisters
StartRegistry, // 开始节点 StartRegistry, // 开始节点
DynamicSplitRegistry, // 动态分支(并行、排他) DynamicSplitRegistry, // 动态分支(并行、排他)
StaticSplitRegistry, // 静态分支(审批) StaticSplitRegistry, // 静态分支(审批)
SimpleSplitRegistry, // 简单分支 (不带 orderIcon 节点)
BlockRegistry, // 单条 block 注册 BlockRegistry, // 单条 block 注册
InlineBlocksRegistry, // 多个 block 组成的 block 列表 InlineBlocksRegistry, // 多个 block 组成的 block 列表
BlockIconRegistry, // icon 节点,如条件分支的菱形图标 BlockIconRegistry, // icon 节点,如条件分支的菱形图标