Skip to content

fix: delete connection error #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/presets/classic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
export function setup<Schemes extends BSchemes>(nodes: ItemDefinition<Schemes>[]) {
return <Items<Schemes>>(function (context, plugin) {
const area = plugin.parentScope<BaseAreaPlugin<Schemes, any>>(BaseAreaPlugin)

Check warning on line 20 in src/presets/classic/index.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 20 in src/presets/classic/index.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type
const editor = area.parentScope<NodeEditor<Schemes>>(NodeEditor)

if (context === 'root') {
Expand All @@ -32,14 +32,19 @@
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)
}
}

Expand Down
Loading