From b7d32fe8a1943a80915427eddd7af6cb5f9b342b Mon Sep 17 00:00:00 2001 From: JackLian Date: Tue, 3 Jan 2023 18:36:44 +0800 Subject: [PATCH] fix: error when dragging in outline view --- docs/docs/api/model/drop-location.md | 54 +++++++++++++++++++ packages/designer/src/designer/location.ts | 4 -- packages/shell/src/model/drop-location.ts | 4 ++ .../types/src/shell/model/drop-location.ts | 25 +++++++-- 4 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 docs/docs/api/model/drop-location.md diff --git a/docs/docs/api/model/drop-location.md b/docs/docs/api/model/drop-location.md new file mode 100644 index 000000000..37497741c --- /dev/null +++ b/docs/docs/api/model/drop-location.md @@ -0,0 +1,54 @@ +--- +title: DropLocation +sidebar_position: 13 +--- + +> **@types** [IPublicModelDropLocation](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/drop-location.ts)
+> **@since** v1.1.0 + + +## 基本介绍 + +拖拽放置位置模型 + +## 变量 + +### target + +拖拽放置位置目标 + +`@type {IPublicModelNode}` + +相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts) + +### detail + +拖拽放置位置详情 + +`@type {IPublicTypeLocationDetail}` + +相关类型:[IPublicTypeLocationDetail](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/location-detail.ts) + +### event + +拖拽放置位置对应的事件 + +`@type {IPublicTypeLocationDetail}` + +相关类型:[IPublicModelLocateEvent](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/location-event.ts) + +## 方法签名 + +### clone + +获取一份当前对象的克隆 + +```typescript +/** + * 获取一份当前对象的克隆 + * get a clone object of current dropLocation + */ +clone(event: IPublicModelLocateEvent): IPublicModelDropLocation; +``` + +相关类型:[IPublicModelLocateEvent](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/location-event.ts) \ No newline at end of file diff --git a/packages/designer/src/designer/location.ts b/packages/designer/src/designer/location.ts index a690b28d5..59d32f048 100644 --- a/packages/designer/src/designer/location.ts +++ b/packages/designer/src/designer/location.ts @@ -101,10 +101,6 @@ export function getWindow(elem: Element | Document): Window { } export interface IDropLocation extends IPublicModelDropLocation { - readonly target: INode; - - readonly event: ILocateEvent; - readonly source: string; get document(): IPublicModelDocumentModel; diff --git a/packages/shell/src/model/drop-location.ts b/packages/shell/src/model/drop-location.ts index f1d1d3157..e4b13a668 100644 --- a/packages/shell/src/model/drop-location.ts +++ b/packages/shell/src/model/drop-location.ts @@ -27,6 +27,10 @@ export class DropLocation implements IPublicModelDropLocation { return this[dropLocationSymbol].detail; } + get event(): IPublicModelLocateEvent { + return this[dropLocationSymbol].event; + } + clone(event: IPublicModelLocateEvent): IPublicModelDropLocation { return new DropLocation(this[dropLocationSymbol].clone(event)); } diff --git a/packages/types/src/shell/model/drop-location.ts b/packages/types/src/shell/model/drop-location.ts index d1e57ccbf..11ae888ac 100644 --- a/packages/types/src/shell/model/drop-location.ts +++ b/packages/types/src/shell/model/drop-location.ts @@ -1,10 +1,29 @@ import { IPublicTypeLocationDetail } from '../type'; -import { IPublicModelLocateEvent } from './'; +import { IPublicModelLocateEvent, IPublicModelNode } from './'; export interface IPublicModelDropLocation { - get target(): any; - readonly detail: IPublicTypeLocationDetail; + /** + * 拖拽位置目标 + * get target of dropLocation + */ + get target(): IPublicModelNode; + /** + * 拖拽放置位置详情 + * get detail of dropLocation + */ + get detail(): IPublicTypeLocationDetail; + + /** + * 拖拽放置位置对应的事件 + * get event of dropLocation + */ + get event(): IPublicModelLocateEvent; + + /** + * 获取一份当前对象的克隆 + * get a clone object of current dropLocation + */ clone(event: IPublicModelLocateEvent): IPublicModelDropLocation; }