Skip to content

Commit

Permalink
let delte connection working
Browse files Browse the repository at this point in the history
  • Loading branch information
mahaidong committed Mar 17, 2024
1 parent 462a2ac commit 626ff5b
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 626ff5b

Please sign in to comment.