From 05f3b06f978fa7ccb503abc68277ca93f9b0a3d0 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Mon, 7 Aug 2023 10:26:10 +0400 Subject: [PATCH] Add getLastDragResult --- src/canvas/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/canvas/index.ts b/src/canvas/index.ts index 2a2c06b01..6f7278b11 100644 --- a/src/canvas/index.ts +++ b/src/canvas/index.ts @@ -49,6 +49,8 @@ import { isUndefined } from 'underscore'; import { Module } from '../abstract'; +import { Coordinates } from '../common'; +import Component from '../dom_components/model/Component'; import EditorModel from '../editor/model/Editor'; import { getElement, getViewEl } from '../utils/mixins'; import defaults, { CanvasConfig } from './config/config'; @@ -56,7 +58,6 @@ import Canvas from './model/Canvas'; import Frame from './model/Frame'; import CanvasView, { FitViewportOptions } from './view/CanvasView'; import FrameView from './view/FrameView'; -import { Coordinates } from '../common'; export type CanvasEvent = 'canvas:dragenter' | 'canvas:dragover' | 'canvas:drop' | 'canvas:dragend' | 'canvas:dragdata'; @@ -696,6 +697,14 @@ export default class CanvasModule extends Module { return this.canvas.frames.add(new Frame(this, { ...props }), opts); } + /** + * Get the last created Component from a drag & drop to the canvas. + * @returns {[Component]|undefined} + */ + getLastDragResult(): Component | undefined { + return this.em.get('dragResult'); + } + destroy() { this.canvas.stopListening(); this.canvasView?.remove();