From 53fdee374c179a537f869e4c799275beece273dc Mon Sep 17 00:00:00 2001 From: Carlos Date: Wed, 9 Apr 2025 17:57:08 +0800 Subject: [PATCH] fix: improve drag event handling by ensuring target and event are correctly set for move command --- packages/core/src/commands/index.ts | 11 ----------- packages/core/src/dom_components/model/Component.ts | 13 ++++++++++++- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/core/src/commands/index.ts b/packages/core/src/commands/index.ts index 290bd4edd..2ac6b4673 100644 --- a/packages/core/src/commands/index.ts +++ b/packages/core/src/commands/index.ts @@ -164,17 +164,6 @@ export default class CommandsModule extends Module { tb.push({ attributes: { class: `${ppfx}no-touch-actions`, draggable: true }, label: em.getIcon('move'), - command: 'tlb-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; + + ed.runCommand('tlb-move', { + target, + event: new DragEvent('dragstart', { clientX, clientY }), + }); + }, }); model.get('copyable') && tb.push({