Skip to content

Commit 9d0dcab

Browse files
authored
Merge pull request #86 from caadxyz/main
let delte connection working
2 parents 462a2ac + 8cf887d commit 9d0dcab

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

src/presets/classic/index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,23 @@ export function setup<Schemes extends BSchemes>(nodes: ItemDefinition<Schemes>[]
3131
label: 'Delete',
3232
key: 'delete',
3333
async handler() {
34-
const nodeId = context.id
35-
const connections = editor.getConnections().filter(c => {
36-
return c.source === nodeId || c.target === nodeId
37-
})
34+
if ('source' in context && 'target' in context) {
35+
// connection
36+
const connectionId = context.id
3837

39-
for (const connection of connections) {
40-
await editor.removeConnection(connection.id)
38+
await editor.removeConnection(connectionId)
39+
} else {
40+
// node
41+
const nodeId = context.id
42+
const connections = editor.getConnections().filter(c => {
43+
return c.source === nodeId || c.target === nodeId
44+
})
45+
46+
for (const connection of connections) {
47+
await editor.removeConnection(connection.id)
48+
}
49+
await editor.removeNode(nodeId)
4150
}
42-
await editor.removeNode(nodeId)
4351
}
4452
}
4553

0 commit comments

Comments
 (0)