feat(workflow): add node duplication

This commit is contained in:
Xin Wang
2026-08-03 07:32:43 +08:00
parent 9daa46ed4d
commit c241e815cc
3 changed files with 83 additions and 16 deletions
+8 -3
View File
@@ -2,7 +2,7 @@
/**
* 画布内共享上下文。GenericNode / ConditionEdge 由 ReactFlow 渲染,拿不到外层
* 回调,统一通过这些 context 取节点规格与编辑/删除动作。
* 回调,统一通过这些 context 取节点规格与编辑/复制/删除动作。
*/
import { createContext } from "react";
@@ -17,9 +17,14 @@ export type ElementActions = {
remove: (id: string) => void;
};
const noop: ElementActions = { edit: () => {}, remove: () => {} };
export type NodeActions = ElementActions & {
duplicate: (id: string) => void;
};
export const NodeActionContext = createContext<ElementActions>(noop);
const noop: ElementActions = { edit: () => {}, remove: () => {} };
const noopNodeActions: NodeActions = { ...noop, duplicate: () => {} };
export const NodeActionContext = createContext<NodeActions>(noopNodeActions);
export const EdgeActionContext = createContext<ElementActions>(noop);
/** 调试通话中当前激活的节点 id(画布据此高亮),无激活为 null。 */