Skip to content
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

let delte connection working #86

Merged
merged 1 commit into from
Apr 17, 2024
Merged
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
22 changes: 15 additions & 7 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 @@ -31,15 +31,23 @@
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
Loading