From 3db27fcb9653418f8049649a5c9170ee2cdbfee9 Mon Sep 17 00:00:00 2001 From: leaferjs Date: Thu, 30 Nov 2023 16:04:32 +0800 Subject: [PATCH] fix proxyData --- packages/display/src/UI.ts | 11 ++++++----- packages/interface/src/IUI.ts | 7 ++++--- packages/partner/paint/src/paint/image/image.ts | 4 ++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/display/src/UI.ts b/packages/display/src/UI.ts index 7ab9fd73..b751da46 100644 --- a/packages/display/src/UI.ts +++ b/packages/display/src/UI.ts @@ -1,4 +1,4 @@ -import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IAround, ILeafDataOptions, IFindMethod } from '@leafer/interface' +import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IAround, IFindMethod } from '@leafer/interface' import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, sortType, maskType, dataProcessor, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType } from '@leafer/core' import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IFindUIMethod, IEditSize, ILeafer } from '@leafer-ui/interface' @@ -19,7 +19,8 @@ export class UI extends Leaf implements IUI { @dataProcessor(UIData) declare public __: IUIData - declare public proxyData?: IUIInputData + declare public proxyData?: IUIInputData // need rewrite getter + declare public __proxyData?: IUIInputData public get app(): ILeafer { return this.leafer && this.leafer.app } @@ -230,11 +231,11 @@ export class UI extends Leaf implements IUI { Object.assign(this, data) } - public get(options?: ILeafDataOptions): IUIInputData { - return this.__.__getInputData(options) + public get(): IUIInputData { + return this.__.__getInputData() } - public getProxyData(): IUIInputData { return undefined } + public createProxyData(): IUIInputData { return undefined } // find diff --git a/packages/interface/src/IUI.ts b/packages/interface/src/IUI.ts index 6ab85e5c..f029a0f2 100644 --- a/packages/interface/src/IUI.ts +++ b/packages/interface/src/IUI.ts @@ -1,4 +1,4 @@ -import { ILeaf, ILeafComputedData, ILeafData, ILeafDataOptions, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject, IPathString, ILeaferImage, IBlob, IPathCreator, AnswerType } from '@leafer/interface' +import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject, IPathString, ILeaferImage, IBlob, IPathCreator, AnswerType } from '@leafer/interface' import { IFillAttrData, IFillInputData, IFillComputedData, @@ -275,6 +275,7 @@ export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrDa isFrame?: boolean proxyData?: IUIInputData + __proxyData?: IUIInputData children?: IUI[] @@ -283,8 +284,8 @@ export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrDa set(data: IUIInputData): void toJSON(): IUIInputData - get(options?: ILeafDataOptions): IUIInputData - getProxyData(): IUIInputData + get(): IUIInputData + createProxyData(): IUIInputData find(condition: number | string | IFindUIMethod, options?: any): IUI[] findOne(condition: number | string | IFindUIMethod, options?: any): IUI diff --git a/packages/partner/paint/src/paint/image/image.ts b/packages/partner/paint/src/paint/image/image.ts index dc9afcc6..b6bd4a6b 100644 --- a/packages/partner/paint/src/paint/image/image.ts +++ b/packages/partner/paint/src/paint/image/image.ts @@ -64,6 +64,10 @@ function hasNaturalSize(ui: IUI, attrName: string, image: ISizeData): boolean { d.__naturalWidth = image.width d.__naturalHeight = image.height if (!d.__getInput('width') || !d.__getInput('height')) { + if (ui.__proxyData) { + ui.setProxyAttr('width', ui.__.width) + ui.setProxyAttr('height', ui.__.height) + } ui.forceUpdate('width') return false }