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();