forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulator-host.ts
More file actions
69 lines (59 loc) · 1.51 KB
/
simulator-host.ts
File metadata and controls
69 lines (59 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import {
BuiltinSimulatorHost,
} from '@alilc/lowcode-designer';
import { simulatorHostSymbol, nodeSymbol } from '../symbols';
import { IPublicApiSimulatorHost, IPublicModelNode } from '@alilc/lowcode-types';
export class SimulatorHost implements IPublicApiSimulatorHost {
private readonly [simulatorHostSymbol]: BuiltinSimulatorHost;
constructor(simulator: BuiltinSimulatorHost) {
this[simulatorHostSymbol] = simulator;
}
static create(host: BuiltinSimulatorHost): IPublicApiSimulatorHost | null {
if (!host) return null;
return new SimulatorHost(host);
}
/**
* 获取 contentWindow
*/
get contentWindow(): Window | undefined {
return this[simulatorHostSymbol].contentWindow;
}
/**
* 获取 contentDocument
*/
get contentDocument(): Document | undefined {
return this[simulatorHostSymbol].contentDocument;
}
get renderer(): any {
return this[simulatorHostSymbol].renderer;
}
/**
* 设置 host 配置值
* @param key
* @param value
*/
set(key: string, value: any): void {
this[simulatorHostSymbol].set(key, value);
}
/**
* 获取 host 配置值
* @param key
* @returns
*/
get(key: string): any {
return this[simulatorHostSymbol].get(key);
}
/**
* scroll to specific node
* @param node
*/
scrollToNode(node: IPublicModelNode): void {
this[simulatorHostSymbol].scrollToNode((node as any)[nodeSymbol]);
}
/**
* 刷新渲染画布
*/
rerender(): void {
this[simulatorHostSymbol].rerender();
}
}