MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / resetData

Function resetData

ui/src/workflow/common/shortcut.ts:168–203  ·  view source on GitHub ↗
(data: any)

Source from the content-addressed store, hash-verified

166 }
167 }
168 const resetData = (data: any) => {
169 const idMap = new Map<string, string>()
170
171 const getOrCreateId = (oldId: string) => {
172 let newId = idMap.get(oldId)
173 if (!newId) {
174 newId = randomId()
175 idMap.set(oldId, newId)
176 }
177 return newId
178 }
179
180 for (const node of data.nodes) {
181 node.id = getOrCreateId(node.id)
182 }
183
184 for (const edge of data.edges) {
185 const oldEdgeId = edge.id
186 const oldSourceNodeId = edge.sourceNodeId
187 const oldTargetNodeId = edge.targetNodeId
188
189 edge.id = getOrCreateId(oldEdgeId)
190 edge.sourceNodeId = getOrCreateId(oldSourceNodeId)
191 edge.targetNodeId = getOrCreateId(oldTargetNodeId)
192
193 if (typeof edge.sourceAnchorId === 'string') {
194 edge.sourceAnchorId = edge.sourceAnchorId.replace(oldSourceNodeId, edge.sourceNodeId)
195 }
196
197 if (typeof edge.targetAnchorId === 'string') {
198 edge.targetAnchorId = edge.targetAnchorId.replace(oldTargetNodeId, edge.targetNodeId)
199 }
200 }
201
202 return data
203 }
204
205 const paste_node = async (e: ClipboardEvent) => {
206 if (lf.graphModel.flowId !== activeCanvasId) {

Callers 1

paste_nodeFunction · 0.85

Calls 2

getOrCreateIdFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected