From edf04727eecd9bd3f1c6ce5a36fd55442e69e5c8 Mon Sep 17 00:00:00 2001 From: Carlos Rufo Date: Thu, 17 Apr 2025 17:20:02 +0800 Subject: [PATCH] Update ComponentDrag to use command reference in event props (#6487) * refactor: update ComponentDrag to use command reference in event props * fix: pass event to opts in onDrag method for better event handling --- packages/core/src/commands/view/ComponentDrag.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/src/commands/view/ComponentDrag.ts b/packages/core/src/commands/view/ComponentDrag.ts index 562648379..d997e4d11 100644 --- a/packages/core/src/commands/view/ComponentDrag.ts +++ b/packages/core/src/commands/view/ComponentDrag.ts @@ -6,6 +6,7 @@ import type Component from '../../dom_components/model/Component'; import type EditorModel from '../../editor/model/Editor'; import { getComponentModel, getComponentView } from '../../utils/mixins'; import type ComponentView from '../../dom_components/view/ComponentView'; +import type CommandAbstract from './CommandAbstract'; const evName = 'dmode'; @@ -71,7 +72,7 @@ export default { guidesTarget: this.guidesTarget, guidesStatic: this.guidesStatic, guidesMatched: this.getGuidesMatched(guidesActive), - opts: this.opts, + command: this, }; }, @@ -394,7 +395,7 @@ export default { this.guidesStatic = this.getGuidesStatic(); }, - onDrag() { + onDrag(event) { const { guidesTarget, opts } = this; this.updateGuides(guidesTarget); @@ -402,6 +403,7 @@ export default { opts.guidesInfo && this.renderGuideInfo(guidesTarget?.filter((item) => item.active) ?? []); opts.onDrag?.(this._getDragData()); + this.opts.event = event; this.em.trigger(`${evName}:move`, this.getEventOpts()); }, @@ -659,7 +661,7 @@ export interface ComponentDragEventProps { /** * The options used for the drag event. */ - opts: ComponentDragOpts; + command: ComponentDragProps & CommandAbstract; } /**