From c61e8f87de1a590146e7e760a38d38a94891d4ff Mon Sep 17 00:00:00 2001 From: Carlos Date: Wed, 9 Apr 2025 19:16:50 +0800 Subject: [PATCH] fix: support multiple selection in drag event handling for move command --- .../src/dom_components/model/Component.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/core/src/dom_components/model/Component.ts b/packages/core/src/dom_components/model/Component.ts index a38981d42..adc946493 100644 --- a/packages/core/src/dom_components/model/Component.ts +++ b/packages/core/src/dom_components/model/Component.ts @@ -1147,16 +1147,18 @@ export default class Component extends StyleableModel { attributes: { class: `${ppfx}no-touch-actions`, draggable: true }, label: em.getIcon('move'), command: (ed) => { - // tld-move event needs to be called with a target and a drag event - const target = ed.getSelected(); - const rect = target?.view?.el.getBoundingClientRect(); - const clientX = rect ? rect.left + rect.width / 2 : 0; - const clientY = rect ? rect.top + rect.height / 2 : 0; - - // TODO: support multiple selection - ed.runCommand('tlb-move', { - target, - event: new DragEvent('dragstart', { clientX, clientY }), + const targets = ed.getSelectedAll(); + + targets.forEach((target) => { + const rect = target?.view?.el.getBoundingClientRect(); + const clientX = rect ? rect.left + rect.width / 2 : 0; + const clientY = rect ? rect.top + rect.height / 2 : 0; + + // tld-move event needs to be called with a target and a drag event + ed.runCommand('tlb-move', { + target, + event: new DragEvent('dragstart', { clientX, clientY }), + }); }); }, });