Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: delete connection error
Browse files Browse the repository at this point in the history
larrytzhang committed Apr 10, 2024
1 parent da6cf1a commit 1593247
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/presets/classic/index.ts
Original file line number Diff line number Diff line change
@@ -32,14 +32,19 @@ export function setup<Schemes extends BSchemes>(nodes: ItemDefinition<Schemes>[]
key: 'delete',
async handler() {
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)
if (editor.getConnection(nodeId)) {
editor.removeConnection(nodeId)
} else {
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)
}
}

0 comments on commit 1593247

Please sign in to comment.