diff --git a/src/canvas/model/Frame.ts b/src/canvas/model/Frame.ts index 272228c1e..7ce2d9910 100644 --- a/src/canvas/model/Frame.ts +++ b/src/canvas/model/Frame.ts @@ -6,13 +6,14 @@ import { isComponent, isObject } from '../../utils/mixins'; import FrameView from '../view/FrameView'; import Frames from './Frames'; import Page from '../../pages/model/Page'; +import { BoxRect } from '../../common'; const keyAutoW = '__aw'; const keyAutoH = '__ah'; const getDimension = (frame: Frame, type: 'width' | 'height') => { const dim = frame.get(type); - const viewDim = frame.view?.el['width' ? 'offsetWidth' : 'offsetHeight']; + const viewDim = frame.view?.el[type === 'width' ? 'offsetWidth' : 'offsetHeight']; if (isNumber(dim)) { return dim; @@ -114,6 +115,18 @@ export default class Frame extends ModuleModel { return this.get('head'); } + getBoxRect(): BoxRect { + const { x, y } = this.attributes; + const { width, height } = this; + + return { + x, + y, + width, + height, + }; + } + onRemove() { this.getComponent().remove({ root: 1 }); }