File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments