diff --git a/packages/stage/src/StageCore.ts b/packages/stage/src/StageCore.ts index 8227385c..b4a3e4bf 100644 --- a/packages/stage/src/StageCore.ts +++ b/packages/stage/src/StageCore.ts @@ -139,9 +139,15 @@ export default class StageCore extends EventEmitter { setTimeout(() => this.emit('sort', data)); }); - this.multiDr.on('update', (data: UpdateEventData) => { - setTimeout(() => this.emit('update', data)); - }); + this.multiDr + .on('update', (data: UpdateEventData) => { + setTimeout(() => this.emit('update', data)); + }) + .on('select', async (id: Id) => { + const el = await this.getTargetElement(id); + this.select(el); // 选中 + setTimeout(() => this.emit('select', el)); // set node + }); } public getElementsFromPoint(event: MouseEvent) { diff --git a/packages/stage/src/StageMultiDragResize.ts b/packages/stage/src/StageMultiDragResize.ts index dd27e6d9..39c2ccca 100644 --- a/packages/stage/src/StageMultiDragResize.ts +++ b/packages/stage/src/StageMultiDragResize.ts @@ -124,6 +124,13 @@ export default class StageMultiDragResize extends EventEmitter { }) .on('dragGroupEnd', () => { this.update(); + }) + .on('clickGroup', (params) => { + const { inputTarget, targets } = params; + // 如果此时mask不处于多选状态下,且有多个元素被选中,同时点击的元素在选中元素中的其中一项,代表多选态切换为该元素的单选态 + if (!this.mask.isMultiSelectStatus && targets.length > 1 && targets.includes(inputTarget)) { + this.emit('select', inputTarget.id.replace(DRAG_EL_ID_PREFIX, '')); + } }); }