mirror of
https://gitee.com/ByteDance/flowgram.ai.git
synced 2025-07-07 17:43:29 +08:00
* feat(demo-fixed-layout): add case-default/break-loop/if nodes * feat(demo-fixed-layout): condition -> switch * chore: e2e fixed
43 lines
847 B
TypeScript
43 lines
847 B
TypeScript
import { nanoid } from 'nanoid';
|
|
|
|
import { FlowNodeRegistry } from '../../typings';
|
|
import iconBreak from '../../assets/icon-break.svg';
|
|
import { formMeta } from './form-meta';
|
|
|
|
/**
|
|
* Break 节点用于在 loop 中根据条件终止并跳出
|
|
*/
|
|
export const BreakLoopNodeRegistry: FlowNodeRegistry = {
|
|
type: 'breakLoop',
|
|
extend: 'end',
|
|
info: {
|
|
icon: iconBreak,
|
|
description: 'Break in current Loop.',
|
|
},
|
|
meta: {
|
|
style: {
|
|
width: 240,
|
|
},
|
|
},
|
|
/**
|
|
* Render node via formMeta
|
|
*/
|
|
formMeta,
|
|
canAdd(ctx, from) {
|
|
while (from.parent) {
|
|
if (from.parent.flowNodeType === 'loop') return true;
|
|
from = from.parent;
|
|
}
|
|
return false;
|
|
},
|
|
onAdd(ctx, from) {
|
|
return {
|
|
id: `break_${nanoid()}`,
|
|
type: 'breakLoop',
|
|
data: {
|
|
title: 'BreakLoop',
|
|
},
|
|
};
|
|
},
|
|
};
|