Skip to content

Commit

Permalink
Merge pull request #5 from retejs/feat/update-scope
Browse files Browse the repository at this point in the history
feat: update scope dynamically
Ni55aN authored Jun 1, 2024
2 parents 46378e2 + 15f4ac7 commit 7c417c0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ type Requires<Schemes extends ExpectedScheme> =
export type Scopes =
| { type: 'scopepicked', data: { ids: NodeId[] } }
| { type: 'scopereleased', data: { ids: NodeId[] } }
| { type: 'scopeupdated', data: { id: NodeId } }

/**
* Scope plugin. Responsible for user interaction with scopes (nested nodes, groups)
@@ -114,6 +115,13 @@ export class ScopesPlugin<Schemes extends ExpectedScheme, T = never> extends Sco
await resizeParent(parent, agentParams, props)
}
}
if (context.type === 'scopeupdated') {
const parent = this.editor.getNode(context.data.id)

if (parent) {
await resizeParent(parent, agentParams, props)
}
}
return context
})
}
@@ -132,6 +140,10 @@ export class ScopesPlugin<Schemes extends ExpectedScheme, T = never> extends Sco

return node && (node.selected || hasSelectedParent(id, props))
}

public async update(scopeId: NodeId) {
await this.emit({ type: 'scopeupdated', data: { id: scopeId } })
}
}

export function getPickedNodes<S extends ExpectedScheme>(scopes: Scope<Scopes, [Requires<S>, Root<S>]>) {

0 comments on commit 7c417c0

Please sign in to comment.