Skip to content

Commit

Permalink
Merge branch 'develop' into release/1.1.11-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
JackLian committed Sep 18, 2023
2 parents 3fd859b + cfc22f7 commit 536ea4d
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 9 deletions.
38 changes: 38 additions & 0 deletions docs/docs/api/model/simulatorRender.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: SimulatorRender
sidebar_position: 6
---
> **@types** [IPublicModelSimulatorRender](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/simulator-render.ts)<br/>
> **@since** v1.0.0
## 基本介绍

画布节点选中模型

## 属性
### components

画布组件列表

```typescript
/**
* 画布组件列表
*/
components: {
[key: string]: any;
}
```

## 方法

### rerender

触发画布重新渲染

```typescript
/**
* 触发画布重新渲染
*/
rerender: () => void;
```

4 changes: 2 additions & 2 deletions docs/docs/api/simulatorHost.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ get(key: string): any;
```

### rerender
刷新渲染画布
触发组件构建,并刷新渲染画布

```typescript
/**
* 刷新渲染画布
* 触发组件构建,并刷新渲染画布
* make simulator render again
*/
rerender(): void;
Expand Down
2 changes: 2 additions & 0 deletions packages/engine/src/modules/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
skeletonItemSymbol,
editorCabinSymbol,
skeletonCabinSymbol,
simulatorRenderSymbol,
} from '@alilc/lowcode-shell';

export default {
Expand All @@ -32,4 +33,5 @@ export default {
propSymbol,
simulatorHostSymbol,
skeletonItemSymbol,
simulatorRenderSymbol,
};
13 changes: 9 additions & 4 deletions packages/shell/src/api/simulator-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
BuiltinSimulatorHost,
} from '@alilc/lowcode-designer';
import { simulatorHostSymbol, nodeSymbol } from '../symbols';
import { IPublicApiSimulatorHost, IPublicModelNode } from '@alilc/lowcode-types';
import { IPublicApiSimulatorHost, IPublicModelNode, IPublicModelSimulatorRender } from '@alilc/lowcode-types';
import { SimulatorRender } from '../model/simulator-render';

export class SimulatorHost implements IPublicApiSimulatorHost {
private readonly [simulatorHostSymbol]: BuiltinSimulatorHost;
Expand Down Expand Up @@ -30,8 +31,12 @@ export class SimulatorHost implements IPublicApiSimulatorHost {
return this[simulatorHostSymbol].contentDocument;
}

get renderer(): any {
return this[simulatorHostSymbol].renderer;
get renderer(): IPublicModelSimulatorRender | undefined {
if (this[simulatorHostSymbol].renderer) {
return SimulatorRender.create(this[simulatorHostSymbol].renderer);
}

return undefined;
}

/**
Expand Down Expand Up @@ -61,7 +66,7 @@ export class SimulatorHost implements IPublicApiSimulatorHost {
}

/**
* 刷新渲染画布
* 触发组件构建,并刷新渲染画布
*/
rerender(): void {
this[simulatorHostSymbol].rerender();
Expand Down
23 changes: 23 additions & 0 deletions packages/shell/src/model/simulator-render.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { IPublicModelSimulatorRender } from '@alilc/lowcode-types';
import { simulatorRenderSymbol } from '../symbols';
import { BuiltinSimulatorRenderer } from '@alilc/lowcode-designer';

export class SimulatorRender implements IPublicModelSimulatorRender {
private readonly [simulatorRenderSymbol]: BuiltinSimulatorRenderer;

constructor(simulatorRender: BuiltinSimulatorRenderer) {
this[simulatorRenderSymbol] = simulatorRender;
}

static create(simulatorRender: BuiltinSimulatorRenderer): IPublicModelSimulatorRender {
return new SimulatorRender(simulatorRender);
}

get components() {
return this[simulatorRenderSymbol].components;
}

rerender() {
return this[simulatorRenderSymbol].rerender();
}
}
1 change: 1 addition & 0 deletions packages/shell/src/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const dragonSymbol = Symbol('dragon');
export const componentMetaSymbol = Symbol('componentMeta');
export const dropLocationSymbol = Symbol('dropLocation');
export const simulatorHostSymbol = Symbol('simulatorHost');
export const simulatorRenderSymbol = Symbol('simulatorRender');
export const dragObjectSymbol = Symbol('dragObject');
export const locateEventSymbol = Symbol('locateEvent');
export const designerCabinSymbol = Symbol('designerCabin');
Expand Down
6 changes: 3 additions & 3 deletions packages/types/src/shell/api/simulator-host.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IPublicModelNode } from '../model';

import { IPublicModelNode, IPublicModelSimulatorRender } from '../model';

export interface IPublicApiSimulatorHost {

/**
* 获取 contentWindow
* @experimental unstable api, pay extra caution when trying to use it
Expand All @@ -17,7 +17,7 @@ export interface IPublicApiSimulatorHost {
/**
* @experimental unstable api, pay extra caution when trying to use it
*/
get renderer(): any;
get renderer(): IPublicModelSimulatorRender | undefined;

/**
* 设置若干用于画布渲染的变量,比如画布大小、locale 等。
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/shell/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ export * from './clipboard';
export * from './setting-field';
export * from './editor-view';
export * from './skeleton-item';
export * from './simulator-render';
14 changes: 14 additions & 0 deletions packages/types/src/shell/model/simulator-render.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export interface IPublicModelSimulatorRender {

/**
* 画布组件列表
*/
components: {
[key: string]: any;
};

/**
* 触发画布重新渲染
*/
rerender: () => void;
}

0 comments on commit 536ea4d

Please sign in to comment.