diff --git a/src/index.ts b/src/index.ts index 593b415..223df15 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,6 +33,7 @@ type Requires = 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 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 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(scopes: Scope, Root]>) {