MCPcopy
hub / github.com/1Panel-dev/MaxKB / copy_node

Function copy_node

ui/src/workflow/common/shortcut.ts:94–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92 options: { keyboard: keyboardOptions },
93 } = keyboard
94 const copy_node = () => {
95 CHILDREN_TRANSLATION_DISTANCE = TRANSLATION_DISTANCE
96 if (!keyboardOptions?.enabled) return true
97 if (graph.textEditElement) return true
98 const { guards } = lf.options
99 const elements = graph.getSelectElements(false)
100 const enabledClone = guards && guards.beforeClone ? guards.beforeClone(elements) : true
101 if (!enabledClone || (elements.nodes.length === 0 && elements.edges.length === 0)) {
102 selected = null
103 return true
104 }
105 const base_nodes = elements.nodes.filter(
106 (node: any) => node.type === WorkflowType.Start || node.type === WorkflowType.Base,
107 )
108 if (base_nodes.length > 0) {
109 MsgError(base_nodes[0]?.properties?.stepName + t('workflow.tip.cannotCopy'))
110 return
111 }
112 selected = cloneDeep(elements)
113 selected.nodes.forEach((node: any) => translationNodeData(node, TRANSLATION_DISTANCE))
114 selected.edges.forEach((edge: any) => translationEdgeData(edge, TRANSLATION_DISTANCE))
115 copyClick(JSON.stringify(selected))
116 return false
117 }
118 // 3. 求节点包围盒
119 const getBounds = (nodes: any[]) => {
120 if (!nodes.length) {

Callers

nothing calls this directly

Calls 4

MsgErrorFunction · 0.90
copyClickFunction · 0.90
translationNodeDataFunction · 0.85
translationEdgeDataFunction · 0.85

Tested by

no test coverage detected