Skip to content

Commit

Permalink
fix: delete connection error
Browse files Browse the repository at this point in the history
  • Loading branch information
mahaidong committed Apr 15, 2024
1 parent 462a2ac commit 8cf887d
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 8cf887d

Please sign in to comment.