Skip to content

Commit

Permalink
Merge pull request #86 from caadxyz/main
Browse files Browse the repository at this point in the history
let delte connection working
  • Loading branch information
Ni55aN authored Apr 17, 2024
2 parents 462a2ac + 8cf887d commit 9d0dcab
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/presets/classic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,23 @@ export function setup<Schemes extends BSchemes>(nodes: ItemDefinition<Schemes>[]
label: 'Delete',
key: 'delete',
async handler() {
const nodeId = context.id
const connections = editor.getConnections().filter(c => {
return c.source === nodeId || c.target === nodeId
})
if ('source' in context && 'target' in context) {
// connection
const connectionId = context.id

for (const connection of connections) {
await editor.removeConnection(connection.id)
await editor.removeConnection(connectionId)
} else {
// node
const nodeId = context.id
const connections = editor.getConnections().filter(c => {
return c.source === nodeId || c.target === nodeId
})

for (const connection of connections) {
await editor.removeConnection(connection.id)
}
await editor.removeNode(nodeId)
}
await editor.removeNode(nodeId)
}
}

Expand Down

0 comments on commit 9d0dcab

Please sign in to comment.