|
@@ -1,4 +1,5 @@
|
|
|
import { nanoid } from 'nanoid';
|
|
import { nanoid } from 'nanoid';
|
|
|
|
|
+import { FlowNodeBaseType } from '@flowgram.ai/fixed-layout-editor';
|
|
|
|
|
|
|
|
import { FlowNodeRegistry } from '../../typings';
|
|
import { FlowNodeRegistry } from '../../typings';
|
|
|
import iconEnd from '../../assets/icon-end.jpg';
|
|
import iconEnd from '../../assets/icon-end.jpg';
|
|
@@ -23,7 +24,34 @@ export const EndNodeRegistry: FlowNodeRegistry = {
|
|
|
formMeta,
|
|
formMeta,
|
|
|
canAdd(ctx, from) {
|
|
canAdd(ctx, from) {
|
|
|
// You can only add to the last node of the branch
|
|
// You can only add to the last node of the branch
|
|
|
- return from.isLast;
|
|
|
|
|
|
|
+ if (!from.isLast) return false;
|
|
|
|
|
+ /**
|
|
|
|
|
+ * condition
|
|
|
|
|
+ * blockIcon
|
|
|
|
|
+ * inlineBlocks
|
|
|
|
|
+ * block1
|
|
|
|
|
+ * blockOrderIcon
|
|
|
|
|
+ * <---- [add end]
|
|
|
|
|
+ * block2
|
|
|
|
|
+ * blockOrderIcon
|
|
|
|
|
+ * end
|
|
|
|
|
+ */
|
|
|
|
|
+ // originParent can determine whether it is condition , and then determine whether it is the last one
|
|
|
|
|
+ // https://github.com/bytedance/flowgram.ai/pull/146
|
|
|
|
|
+ if (
|
|
|
|
|
+ from.parent &&
|
|
|
|
|
+ from.parent.parent?.flowNodeType === FlowNodeBaseType.INLINE_BLOCKS &&
|
|
|
|
|
+ from.parent.originParent &&
|
|
|
|
|
+ !from.parent.originParent.isLast
|
|
|
|
|
+ ) {
|
|
|
|
|
+ const allBranches = from.parent.parent!.blocks;
|
|
|
|
|
+ // Determine whether the last node of all branch is end, All branches are not allowed to be end
|
|
|
|
|
+ const branchEndCount = allBranches.filter(
|
|
|
|
|
+ (block) => block.blocks[block.blocks.length - 1]?.getNodeMeta().isNodeEnd
|
|
|
|
|
+ ).length;
|
|
|
|
|
+ return branchEndCount < allBranches.length - 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
},
|
|
},
|
|
|
canDelete(ctx, node) {
|
|
canDelete(ctx, node) {
|
|
|
return node.parent === ctx.document.root;
|
|
return node.parent === ctx.document.root;
|