From e9747c6af0717c6fd3392ceb98df0667994e00a7 Mon Sep 17 00:00:00 2001 From: sunven <604164227@qq.com> Date: Fri, 1 Dec 2023 00:00:10 +0800 Subject: [PATCH] fix: stencil addGroup --- examples/x6-example-features/src/pages/stencil/index.tsx | 2 ++ packages/x6-plugin-stencil/src/index.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/x6-example-features/src/pages/stencil/index.tsx b/examples/x6-example-features/src/pages/stencil/index.tsx index 50443b212f2..460816c74a6 100644 --- a/examples/x6-example-features/src/pages/stencil/index.tsx +++ b/examples/x6-example-features/src/pages/stencil/index.tsx @@ -111,6 +111,8 @@ export default class Example extends React.Component { stencil.load([r, c, c2, r2.clone()], 'group1') stencil.load([c2.clone(), r2, r3, c3], 'group2') + stencil.addGroup({ name: 'group3' }) + stencil.load([c2.clone()], 'group3') } refContainer = (container: HTMLDivElement) => { diff --git a/packages/x6-plugin-stencil/src/index.ts b/packages/x6-plugin-stencil/src/index.ts index 4c2b11f25b3..9ef9c1837e1 100644 --- a/packages/x6-plugin-stencil/src/index.ts +++ b/packages/x6-plugin-stencil/src/index.ts @@ -169,7 +169,11 @@ export class Stencil extends View implements Graph.Plugin { } else { this.options.groups = groups } - groups.forEach((group) => this.initGroup(group)) + groups.forEach((group) => { + this.initGroup(group) + const graph = this.graphs[group.name] + graph.on('cell:mousedown', this.onDragStart, this) + }) } removeGroup(groupName: string | string[]) {