mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-06 10:27:22 +00:00
chore: 增加方法注释
This commit is contained in:
parent
9f8bb613b9
commit
c59eee0cca
@ -15,6 +15,7 @@
|
|||||||
"lint": "eslint --ext .ts,.tsx,.js,.jsx ./ --quiet",
|
"lint": "eslint --ext .ts,.tsx,.js,.jsx ./ --quiet",
|
||||||
"lint:fix": "eslint --ext .ts,.tsx,.js,.jsx ./ --quiet --fix",
|
"lint:fix": "eslint --ext .ts,.tsx,.js,.jsx ./ --quiet --fix",
|
||||||
"pub": "tnpm run watchdog:build && lerna publish patch --force-publish --exact --no-changelog",
|
"pub": "tnpm run watchdog:build && lerna publish patch --force-publish --exact --no-changelog",
|
||||||
|
"pub:premajor": "tnpm run watchdog:build && lerna publish premajor --force-publish --exact --dist-tag beta --preid beta --no-changelog",
|
||||||
"pub:prepatch": "tnpm run watchdog:build && lerna publish prepatch --force-publish --exact --dist-tag beta --preid beta --no-changelog",
|
"pub:prepatch": "tnpm run watchdog:build && lerna publish prepatch --force-publish --exact --dist-tag beta --preid beta --no-changelog",
|
||||||
"pub:prerelease": "tnpm run watchdog:build && lerna publish prerelease --force-publish --exact --dist-tag beta --preid beta --no-changelog",
|
"pub:prerelease": "tnpm run watchdog:build && lerna publish prerelease --force-publish --exact --dist-tag beta --preid beta --no-changelog",
|
||||||
"setup": "./scripts/setup.sh",
|
"setup": "./scripts/setup.sh",
|
||||||
|
|||||||
@ -29,46 +29,77 @@ export default class ComponentMeta {
|
|||||||
return new ComponentMeta(componentMeta);
|
return new ComponentMeta(componentMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件名
|
||||||
|
*/
|
||||||
get componentName(): string {
|
get componentName(): string {
|
||||||
return this[componentMetaSymbol].componentName;
|
return this[componentMetaSymbol].componentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是「容器型」组件
|
||||||
|
*/
|
||||||
get isContainer(): boolean {
|
get isContainer(): boolean {
|
||||||
return this[componentMetaSymbol].isContainer;
|
return this[componentMetaSymbol].isContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是最小渲染单元。
|
||||||
|
* 当组件需要重新渲染时:
|
||||||
|
* 若为最小渲染单元,则只渲染当前组件,
|
||||||
|
* 若不为最小渲染单元,则寻找到上层最近的最小渲染单元进行重新渲染,直至根节点。
|
||||||
|
*/
|
||||||
get isMinimalRenderUnit(): boolean {
|
get isMinimalRenderUnit(): boolean {
|
||||||
return this[componentMetaSymbol].isMinimalRenderUnit;
|
return this[componentMetaSymbol].isMinimalRenderUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为「模态框」组件
|
||||||
|
*/
|
||||||
get isModal(): boolean {
|
get isModal(): boolean {
|
||||||
return this[componentMetaSymbol].isModal;
|
return this[componentMetaSymbol].isModal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 元数据配置
|
||||||
|
*/
|
||||||
get configure() {
|
get configure() {
|
||||||
return this[componentMetaSymbol].configure;
|
return this[componentMetaSymbol].configure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
get title() {
|
get title() {
|
||||||
return this[componentMetaSymbol].title;
|
return this[componentMetaSymbol].title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图标
|
||||||
|
*/
|
||||||
get icon() {
|
get icon() {
|
||||||
return this[componentMetaSymbol].icon;
|
return this[componentMetaSymbol].icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件 npm 信息
|
||||||
|
*/
|
||||||
get npm() {
|
get npm() {
|
||||||
return this[componentMetaSymbol].npm;
|
return this[componentMetaSymbol].npm;
|
||||||
}
|
}
|
||||||
|
|
||||||
get acceptable(): boolean {
|
/**
|
||||||
return this[componentMetaSymbol].acceptable;
|
* 设置 npm 信息
|
||||||
}
|
* @param npm
|
||||||
|
*/
|
||||||
setNpm(npm: any) {
|
setNpm(npm: any) {
|
||||||
this[componentMetaSymbol].setNpm(npm);
|
this[componentMetaSymbol].setNpm(npm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取元数据
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getMetadata() {
|
getMetadata() {
|
||||||
return this[componentMetaSymbol].getMetadata();
|
return this[componentMetaSymbol].getMetadata();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,14 +13,25 @@ export default class Detecting {
|
|||||||
this[detectingSymbol] = document.designer.detecting;
|
this[detectingSymbol] = document.designer.detecting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hover 指定节点
|
||||||
|
* @param id 节点 id
|
||||||
|
*/
|
||||||
capture(id: string) {
|
capture(id: string) {
|
||||||
this[detectingSymbol].capture(this[documentSymbol].getNode(id));
|
this[detectingSymbol].capture(this[documentSymbol].getNode(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hover 离开指定节点
|
||||||
|
* @param id 节点 id
|
||||||
|
*/
|
||||||
release(id: string) {
|
release(id: string) {
|
||||||
this[detectingSymbol].release(this[documentSymbol].getNode(id));
|
this[detectingSymbol].release(this[documentSymbol].getNode(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空 hover 态
|
||||||
|
*/
|
||||||
leave() {
|
leave() {
|
||||||
this[detectingSymbol].leave(this[documentSymbol]);
|
this[detectingSymbol].leave(this[documentSymbol]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,7 +101,7 @@ export default class DocumentModel {
|
|||||||
* @param stage
|
* @param stage
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
exportSchema(stage?: TransformStage) {
|
exportSchema(stage: TransformStage = TransformStage.Render) {
|
||||||
return this[documentSymbol].export(stage);
|
return this[documentSymbol].export(stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,10 +25,30 @@ export default class Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听事件
|
||||||
|
* @param event 事件名称
|
||||||
|
* @param listener 事件回调
|
||||||
|
*/
|
||||||
on(event: string, listener: (...args: unknown[]) => void) {
|
on(event: string, listener: (...args: unknown[]) => void) {
|
||||||
this[editorSymbol].on(event, listener);
|
this[editorSymbol].on(event, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消监听事件
|
||||||
|
* @param event 事件名称
|
||||||
|
* @param listener 事件回调
|
||||||
|
*/
|
||||||
|
off(event: string, listener: (...args: unknown[]) => void) {
|
||||||
|
this[editorSymbol].off(event, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 触发事件
|
||||||
|
* @param event 事件名称
|
||||||
|
* @param args 事件参数
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
emit(event: string, ...args: unknown[]) {
|
emit(event: string, ...args: unknown[]) {
|
||||||
if (!this.options.prefix) {
|
if (!this.options.prefix) {
|
||||||
logger.warn('Event#emit has been forbidden while prefix is not specified');
|
logger.warn('Event#emit has been forbidden while prefix is not specified');
|
||||||
|
|||||||
@ -10,34 +10,65 @@ export default class History {
|
|||||||
this[historySymbol] = this[documentSymbol].getHistory();
|
this[historySymbol] = this[documentSymbol].getHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 历史记录跳转到指定位置
|
||||||
|
* @param cursor
|
||||||
|
*/
|
||||||
go(cursor: number) {
|
go(cursor: number) {
|
||||||
this[historySymbol].go(cursor);
|
this[historySymbol].go(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 历史记录后退
|
||||||
|
*/
|
||||||
back() {
|
back() {
|
||||||
this[historySymbol].back();
|
this[historySymbol].back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 历史记录前进
|
||||||
|
*/
|
||||||
forward() {
|
forward() {
|
||||||
this[historySymbol].forward();
|
this[historySymbol].forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存当前状态
|
||||||
|
*/
|
||||||
savePoint() {
|
savePoint() {
|
||||||
this[historySymbol].savePoint();
|
this[historySymbol].savePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前是否是「保存点」,即是否有状态变更但未保存
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
isSavePoint() {
|
isSavePoint() {
|
||||||
return this[historySymbol].isSavePoint();
|
return this[historySymbol].isSavePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 state,判断当前是否为「可回退」、「可前进」的状态
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getState() {
|
getState() {
|
||||||
return this[historySymbol].getState();
|
return this[historySymbol].getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听 state 变更事件
|
||||||
|
* @param func
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
onChangeState(func: () => any) {
|
onChangeState(func: () => any) {
|
||||||
return this[historySymbol].onStateChange(func);
|
return this[historySymbol].onStateChange(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听历史记录游标位置变更事件
|
||||||
|
* @param func
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
onChangeCursor(func: () => any) {
|
onChangeCursor(func: () => any) {
|
||||||
return this[historySymbol].onCursor(func);
|
return this[historySymbol].onCursor(func);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,13 @@ import { hotkey, HotkeyCallback } from '@ali/lowcode-editor-core';
|
|||||||
import { Disposable } from '@ali/lowcode-types';
|
import { Disposable } from '@ali/lowcode-types';
|
||||||
|
|
||||||
export default class Hotkey {
|
export default class Hotkey {
|
||||||
|
/**
|
||||||
|
* 绑定快捷键
|
||||||
|
* @param combos 快捷键,格式如:['command + s'] 、['ctrl + shift + s'] 等
|
||||||
|
* @param callback 回调函数
|
||||||
|
* @param action
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
bind(combos: string[] | string, callback: HotkeyCallback, action?: string): Disposable {
|
bind(combos: string[] | string, callback: HotkeyCallback, action?: string): Disposable {
|
||||||
hotkey.bind(combos, callback, action);
|
hotkey.bind(combos, callback, action);
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@ -22,22 +22,45 @@ export default class Material {
|
|||||||
this[designerSymbol] = editor.get('designer')!;
|
this[designerSymbol] = editor.get('designer')!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取组件 map 结构
|
||||||
|
*/
|
||||||
get componentsMap() {
|
get componentsMap() {
|
||||||
return this[designerSymbol].componentsMap;
|
return this[designerSymbol].componentsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置「资产包」结构
|
||||||
|
* @param assets
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
setAssets(assets: AssetsJson) {
|
setAssets(assets: AssetsJson) {
|
||||||
return this[editorSymbol].setAssets(assets);
|
return this[editorSymbol].setAssets(assets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取「资产包」结构
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getAssets() {
|
getAssets() {
|
||||||
return this[editorSymbol].get('assets');
|
return this[editorSymbol].get('assets');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载增量的「资产包」结构,该增量包会与原有的合并
|
||||||
|
* @param incrementalAssets
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
loadIncrementalAssets(incrementalAssets: AssetsJson) {
|
loadIncrementalAssets(incrementalAssets: AssetsJson) {
|
||||||
return this[designerSymbol].loadIncrementalAssets(incrementalAssets);
|
return this[designerSymbol].loadIncrementalAssets(incrementalAssets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册物料元数据管道函数
|
||||||
|
* @param transducer
|
||||||
|
* @param level
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
registerMetadataTransducer(
|
registerMetadataTransducer(
|
||||||
transducer: MetadataTransducer,
|
transducer: MetadataTransducer,
|
||||||
level?: number,
|
level?: number,
|
||||||
@ -46,14 +69,27 @@ export default class Material {
|
|||||||
registerMetadataTransducer(transducer, level, id);
|
registerMetadataTransducer(transducer, level, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有物料元数据管道函数
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getRegisteredMetadataTransducers() {
|
getRegisteredMetadataTransducers() {
|
||||||
return getRegisteredMetadataTransducers();
|
return getRegisteredMetadataTransducers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定名称的物料元数据
|
||||||
|
* @param componentName
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getComponentMeta(componentName: string) {
|
getComponentMeta(componentName: string) {
|
||||||
return ComponentMeta.create(this[designerSymbol].getComponentMeta(componentName));
|
return ComponentMeta.create(this[designerSymbol].getComponentMeta(componentName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有已注册的物料元数据
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getComponentMetasMap() {
|
getComponentMetasMap() {
|
||||||
const map = new Map<string, ComponentMeta>();
|
const map = new Map<string, ComponentMeta>();
|
||||||
const originalMap = this[designerSymbol].getComponentMetasMap();
|
const originalMap = this[designerSymbol].getComponentMetasMap();
|
||||||
@ -63,14 +99,27 @@ export default class Material {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在设计器辅助层增加一个扩展 action
|
||||||
|
* @param action
|
||||||
|
*/
|
||||||
addBuiltinComponentAction(action: ComponentAction) {
|
addBuiltinComponentAction(action: ComponentAction) {
|
||||||
addBuiltinComponentAction(action);
|
addBuiltinComponentAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除设计器辅助层的指定 action
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
removeBuiltinComponentAction(name: string) {
|
removeBuiltinComponentAction(name: string) {
|
||||||
removeBuiltinComponentAction(name);
|
removeBuiltinComponentAction(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改已有的设计器辅助层的指定 action
|
||||||
|
* @param actionName
|
||||||
|
* @param handle
|
||||||
|
*/
|
||||||
modifyBuiltinComponentAction(actionName: string, handle: (action: ComponentAction) => void) {
|
modifyBuiltinComponentAction(actionName: string, handle: (action: ComponentAction) => void) {
|
||||||
modifyBuiltinComponentAction(actionName, handle);
|
modifyBuiltinComponentAction(actionName, handle);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,66 +15,128 @@ export default class NodeChildren {
|
|||||||
return new NodeChildren(nodeChldren);
|
return new NodeChildren(nodeChldren);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回当前 children 实例所属的节点实例
|
||||||
|
*/
|
||||||
get owner(): Node | null {
|
get owner(): Node | null {
|
||||||
return Node.create(this[nodeChildrenSymbol].owner);
|
return Node.create(this[nodeChildrenSymbol].owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* children 内的节点实例数
|
||||||
|
*/
|
||||||
get size() {
|
get size() {
|
||||||
return this[nodeChildrenSymbol].size;
|
return this[nodeChildrenSymbol].size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为空
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
isEmpty() {
|
isEmpty() {
|
||||||
return this[nodeChildrenSymbol].isEmpty();
|
return this[nodeChildrenSymbol].isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除指定节点
|
||||||
|
* @param node
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
delete(node: Node) {
|
delete(node: Node) {
|
||||||
return this[nodeChildrenSymbol].delete(node[nodeSymbol]);
|
return this[nodeChildrenSymbol].delete(node[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
insert(node: Node, at?: number | null | undefined, useMutator?: boolean) {
|
/**
|
||||||
return this[nodeChildrenSymbol].insert(node[nodeSymbol], at, useMutator);
|
* 插入一个节点
|
||||||
|
* @param node 待插入节点
|
||||||
|
* @param at 插入下标
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
insert(node: Node, at?: number | null) {
|
||||||
|
return this[nodeChildrenSymbol].insert(node[nodeSymbol], at, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回指定节点的下标
|
||||||
|
* @param node
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
indexOf(node: Node) {
|
indexOf(node: Node) {
|
||||||
return this[nodeChildrenSymbol].indexOf(node[nodeSymbol]);
|
return this[nodeChildrenSymbol].indexOf(node[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类似数组 splice 操作
|
||||||
|
* @param start
|
||||||
|
* @param deleteCount
|
||||||
|
* @param node
|
||||||
|
*/
|
||||||
splice(start: number, deleteCount: number, node?: Node) {
|
splice(start: number, deleteCount: number, node?: Node) {
|
||||||
this[nodeChildrenSymbol].splice(start, deleteCount, node?.[nodeSymbol]);
|
this[nodeChildrenSymbol].splice(start, deleteCount, node?.[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回指定下标的节点
|
||||||
|
* @param index
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
get(index: number) {
|
get(index: number) {
|
||||||
return this[nodeChildrenSymbol].get(index);
|
return this[nodeChildrenSymbol].get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否包含指定节点
|
||||||
|
* @param node
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
has(node: Node) {
|
has(node: Node) {
|
||||||
return this[nodeChildrenSymbol].has(node[nodeSymbol]);
|
return this[nodeChildrenSymbol].has(node[nodeSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类似数组的 forEach
|
||||||
|
* @param fn
|
||||||
|
*/
|
||||||
forEach(fn: (node: Node, index: number) => void) {
|
forEach(fn: (node: Node, index: number) => void) {
|
||||||
this[nodeChildrenSymbol].forEach((item: InnerNode<NodeSchema>, index: number) => {
|
this[nodeChildrenSymbol].forEach((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
fn(Node.create(item)!, index);
|
fn(Node.create(item)!, index);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类似数组的 map
|
||||||
|
* @param fn
|
||||||
|
*/
|
||||||
map<T>(fn: (node: Node, index: number) => T[]) {
|
map<T>(fn: (node: Node, index: number) => T[]) {
|
||||||
return this[nodeChildrenSymbol].map((item: InnerNode<NodeSchema>, index: number) => {
|
return this[nodeChildrenSymbol].map((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
return fn(Node.create(item)!, index);
|
return fn(Node.create(item)!, index);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类似数组的 every
|
||||||
|
* @param fn
|
||||||
|
*/
|
||||||
every(fn: (node: Node, index: number) => boolean) {
|
every(fn: (node: Node, index: number) => boolean) {
|
||||||
return this[nodeChildrenSymbol].every((item: InnerNode<NodeSchema>, index: number) => {
|
return this[nodeChildrenSymbol].every((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
return fn(Node.create(item)!, index);
|
return fn(Node.create(item)!, index);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类似数组的 some
|
||||||
|
* @param fn
|
||||||
|
*/
|
||||||
some(fn: (node: Node, index: number) => boolean) {
|
some(fn: (node: Node, index: number) => boolean) {
|
||||||
return this[nodeChildrenSymbol].some((item: InnerNode<NodeSchema>, index: number) => {
|
return this[nodeChildrenSymbol].some((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
return fn(Node.create(item)!, index);
|
return fn(Node.create(item)!, index);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类似数组的 filter
|
||||||
|
* @param fn
|
||||||
|
*/
|
||||||
filter(fn: (node: Node, index: number) => boolean) {
|
filter(fn: (node: Node, index: number) => boolean) {
|
||||||
return this[nodeChildrenSymbol]
|
return this[nodeChildrenSymbol]
|
||||||
.filter((item: InnerNode<NodeSchema>, index: number) => {
|
.filter((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
@ -83,6 +145,10 @@ export default class NodeChildren {
|
|||||||
.map((item: InnerNode<NodeSchema>) => Node.create(item)!);
|
.map((item: InnerNode<NodeSchema>) => Node.create(item)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类似数组的 find
|
||||||
|
* @param fn
|
||||||
|
*/
|
||||||
find(fn: (node: Node, index: number) => boolean) {
|
find(fn: (node: Node, index: number) => boolean) {
|
||||||
return Node.create(
|
return Node.create(
|
||||||
this[nodeChildrenSymbol].find((item: InnerNode<NodeSchema>, index: number) => {
|
this[nodeChildrenSymbol].find((item: InnerNode<NodeSchema>, index: number) => {
|
||||||
@ -91,20 +157,39 @@ export default class NodeChildren {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类似数组的 reduce
|
||||||
|
* @param fn
|
||||||
|
*/
|
||||||
reduce(fn: (acc: any, cur: Node) => any, initialValue: any) {
|
reduce(fn: (acc: any, cur: Node) => any, initialValue: any) {
|
||||||
return this[nodeChildrenSymbol].reduce((acc: any, cur: InnerNode) => {
|
return this[nodeChildrenSymbol].reduce((acc: any, cur: InnerNode) => {
|
||||||
return fn(acc, Node.create(cur)!);
|
return fn(acc, Node.create(cur)!);
|
||||||
}, initialValue);
|
}, initialValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入 schema
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
importSchema(data?: NodeData | NodeData[]) {
|
importSchema(data?: NodeData | NodeData[]) {
|
||||||
this[nodeChildrenSymbol].import(data);
|
this[nodeChildrenSymbol].import(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
exportSchema(stage?: TransformStage) {
|
/**
|
||||||
|
* 导出 schema
|
||||||
|
* @param stage
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
exportSchema(stage: TransformStage = TransformStage.Render) {
|
||||||
return this[nodeChildrenSymbol].export(stage);
|
return this[nodeChildrenSymbol].export(stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行新增、删除、排序等操作
|
||||||
|
* @param remover
|
||||||
|
* @param adder
|
||||||
|
* @param sorter
|
||||||
|
*/
|
||||||
mergeChildren(
|
mergeChildren(
|
||||||
remover: (node: Node, idx: number) => boolean,
|
remover: (node: Node, idx: number) => boolean,
|
||||||
adder: (children: Node[]) => any,
|
adder: (children: Node[]) => any,
|
||||||
|
|||||||
@ -26,63 +26,99 @@ export default class Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回节点 id
|
* 节点 id
|
||||||
*/
|
*/
|
||||||
get id() {
|
get id() {
|
||||||
return this[nodeSymbol].id;
|
return this[nodeSymbol].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点标题
|
||||||
|
*/
|
||||||
get title() {
|
get title() {
|
||||||
return this[nodeSymbol].title;
|
return this[nodeSymbol].title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为「容器型」节点
|
||||||
|
*/
|
||||||
get isContainer() {
|
get isContainer() {
|
||||||
return this[nodeSymbol].isContainer();
|
return this[nodeSymbol].isContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为根节点
|
||||||
|
*/
|
||||||
get isRoot() {
|
get isRoot() {
|
||||||
return this[nodeSymbol].isRoot();
|
return this[nodeSymbol].isRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为 Page 节点
|
||||||
|
*/
|
||||||
get isPage() {
|
get isPage() {
|
||||||
return this[nodeSymbol].isPage();
|
return this[nodeSymbol].isPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为 Component 节点
|
||||||
|
*/
|
||||||
get isComponent() {
|
get isComponent() {
|
||||||
return this[nodeSymbol].isComponent();
|
return this[nodeSymbol].isComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为插槽节点
|
||||||
|
*/
|
||||||
get isSlot() {
|
get isSlot() {
|
||||||
return this[nodeSymbol].isSlot();
|
return this[nodeSymbol].isSlot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为父类/分支节点
|
||||||
|
*/
|
||||||
get isParental() {
|
get isParental() {
|
||||||
return this[nodeSymbol].isParental();
|
return this[nodeSymbol].isParental();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为叶子节点
|
||||||
|
*/
|
||||||
get isLeaf() {
|
get isLeaf() {
|
||||||
return this[nodeSymbol].isLeaf();
|
return this[nodeSymbol].isLeaf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下标
|
||||||
|
*/
|
||||||
get index() {
|
get index() {
|
||||||
return this[nodeSymbol].index;
|
return this[nodeSymbol].index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图标
|
||||||
|
*/
|
||||||
get icon() {
|
get icon() {
|
||||||
return this[nodeSymbol].icon;
|
return this[nodeSymbol].icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点所在树的层级深度,根节点深度为 0
|
||||||
|
*/
|
||||||
get zLevel() {
|
get zLevel() {
|
||||||
return this[nodeSymbol].zLevel;
|
return this[nodeSymbol].zLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回节点 componentName
|
* 节点 componentName
|
||||||
*/
|
*/
|
||||||
get componentName() {
|
get componentName() {
|
||||||
return this[nodeSymbol].componentName;
|
return this[nodeSymbol].componentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点的物料元数据
|
||||||
|
*/
|
||||||
get componentMeta() {
|
get componentMeta() {
|
||||||
return ComponentMeta.create(this[nodeSymbol].componentMeta);
|
return ComponentMeta.create(this[nodeSymbol].componentMeta);
|
||||||
}
|
}
|
||||||
@ -127,14 +163,23 @@ export default class Node {
|
|||||||
return NodeChildren.create(this[nodeSymbol].children);
|
return NodeChildren.create(this[nodeSymbol].children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点上挂载的插槽节点们
|
||||||
|
*/
|
||||||
get slots(): Node[] {
|
get slots(): Node[] {
|
||||||
return this[nodeSymbol].slots.map((node: InnerNode) => Node.create(node)!);
|
return this[nodeSymbol].slots.map((node: InnerNode) => Node.create(node)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前节点为插槽节点时,返回节点对应的属性实例
|
||||||
|
*/
|
||||||
get slotFor() {
|
get slotFor() {
|
||||||
return Prop.create(this[nodeSymbol].slotFor);
|
return Prop.create(this[nodeSymbol].slotFor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回节点的属性集
|
||||||
|
*/
|
||||||
get props() {
|
get props() {
|
||||||
return Props.create(this[nodeSymbol].props);
|
return Props.create(this[nodeSymbol].props);
|
||||||
}
|
}
|
||||||
@ -153,18 +198,34 @@ export default class Node {
|
|||||||
return this[nodeSymbol].getDOMNode();
|
return this[nodeSymbol].getDOMNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回节点的尺寸、位置信息
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getRect() {
|
getRect() {
|
||||||
return this[nodeSymbol].getRect();
|
return this[nodeSymbol].getRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有挂载插槽节点
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
hasSlots() {
|
hasSlots() {
|
||||||
return this[nodeSymbol].hasSlots();
|
return this[nodeSymbol].hasSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否设定了渲染条件
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
hasCondition() {
|
hasCondition() {
|
||||||
return this[nodeSymbol].hasCondition();
|
return this[nodeSymbol].hasCondition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否设定了循环数据
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
hasLoop() {
|
hasLoop() {
|
||||||
return this[nodeSymbol].hasLoop();
|
return this[nodeSymbol].hasLoop();
|
||||||
}
|
}
|
||||||
@ -248,7 +309,7 @@ export default class Node {
|
|||||||
* @param options
|
* @param options
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
exportSchema(stage?: TransformStage, options?: any) {
|
exportSchema(stage: TransformStage = TransformStage.Render, options?: any) {
|
||||||
return this[nodeSymbol].export(stage, options);
|
return this[nodeSymbol].export(stage, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,9 @@ export default class Project {
|
|||||||
return this[projectSymbol].documents.map((doc) => DocumentModel.create(doc)!);
|
return this[projectSymbol].documents.map((doc) => DocumentModel.create(doc)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模拟器的 host
|
||||||
|
*/
|
||||||
get simulatorHost() {
|
get simulatorHost() {
|
||||||
return SimulatorHost.create(this[projectSymbol].simulator as any || this[simulatorHostSymbol]);
|
return SimulatorHost.create(this[projectSymbol].simulator as any || this[simulatorHostSymbol]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,27 +15,56 @@ export default class Prop {
|
|||||||
return new Prop(prop);
|
return new Prop(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
get id() {
|
get id() {
|
||||||
return this[propSymbol].id;
|
return this[propSymbol].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* key 值
|
||||||
|
*/
|
||||||
get key() {
|
get key() {
|
||||||
return this[propSymbol].key;
|
return this[propSymbol].key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回当前 prop 的路径
|
||||||
|
*/
|
||||||
|
get path() {
|
||||||
|
return this[propSymbol].path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回所属的节点实例
|
||||||
|
*/
|
||||||
get node(): Node | null {
|
get node(): Node | null {
|
||||||
return Node.create(this[propSymbol].getNode());
|
return Node.create(this[propSymbol].getNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置值
|
||||||
|
* @param val
|
||||||
|
*/
|
||||||
setValue(val: CompositeValue) {
|
setValue(val: CompositeValue) {
|
||||||
this[propSymbol].setValue(val);
|
this[propSymbol].setValue(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取值
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getValue() {
|
getValue() {
|
||||||
return this[propSymbol].getValue();
|
return this[propSymbol].getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
exportSchema(stage: TransformStage) {
|
/**
|
||||||
|
* 导出值
|
||||||
|
* @param stage
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
exportSchema(stage: TransformStage = TransformStage.Render) {
|
||||||
return this[propSymbol].export(stage);
|
return this[propSymbol].export(stage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -16,10 +16,16 @@ export default class Props {
|
|||||||
return new Props(props);
|
return new Props(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
get id() {
|
get id() {
|
||||||
return this[propsSymbol].id;
|
return this[propsSymbol].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回当前 props 的路径
|
||||||
|
*/
|
||||||
get path() {
|
get path() {
|
||||||
return this[propsSymbol].path;
|
return this[propsSymbol].path;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,34 +15,65 @@ export default class Selection {
|
|||||||
this[selectionSymbol] = document.selection;
|
this[selectionSymbol] = document.selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回选中的节点 id
|
||||||
|
*/
|
||||||
get selected() {
|
get selected() {
|
||||||
return this[selectionSymbol].selected;
|
return this[selectionSymbol].selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选中指定节点(覆盖方式)
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
select(id: string) {
|
select(id: string) {
|
||||||
this[selectionSymbol].select(id);
|
this[selectionSymbol].select(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量选中指定节点们
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
selectAll(ids: string[]) {
|
selectAll(ids: string[]) {
|
||||||
this[selectionSymbol].selectAll(ids);
|
this[selectionSymbol].selectAll(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除选中的指定节点
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
remove(id: string) {
|
remove(id: string) {
|
||||||
this[selectionSymbol].remove(id);
|
this[selectionSymbol].remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除所有选中节点
|
||||||
|
*/
|
||||||
clear() {
|
clear() {
|
||||||
this[selectionSymbol].clear();
|
this[selectionSymbol].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否选中了指定节点
|
||||||
|
* @param id
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
has(id: string) {
|
has(id: string) {
|
||||||
return this[selectionSymbol].has(id);
|
return this[selectionSymbol].has(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选中指定节点(增量方式)
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
add(id: string) {
|
add(id: string) {
|
||||||
this[selectionSymbol].add(id);
|
this[selectionSymbol].add(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取选中的节点实例
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getNodes() {
|
getNodes() {
|
||||||
return this[selectionSymbol].getNodes().map((node: InnerNode) => Node.create(node));
|
return this[selectionSymbol].getNodes().map((node: InnerNode) => Node.create(node));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,14 +2,29 @@ import { getSetter, registerSetter, getSettersMap, RegisteredSetter } from '@ali
|
|||||||
import { CustomView } from '@ali/lowcode-types';
|
import { CustomView } from '@ali/lowcode-types';
|
||||||
|
|
||||||
export default class Setters {
|
export default class Setters {
|
||||||
|
/**
|
||||||
|
* 获取指定 setter
|
||||||
|
* @param type
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getSetter(type: string) {
|
getSetter(type: string) {
|
||||||
return getSetter(type);
|
return getSetter(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取已注册的所有 settersMap
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getSettersMap() {
|
getSettersMap() {
|
||||||
return getSettersMap();
|
return getSettersMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册一个 setter
|
||||||
|
* @param typeOrMaps
|
||||||
|
* @param setter
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
registerSetter(
|
registerSetter(
|
||||||
typeOrMaps: string | { [key: string]: CustomView | RegisteredSetter },
|
typeOrMaps: string | { [key: string]: CustomView | RegisteredSetter },
|
||||||
setter?: CustomView | RegisteredSetter | undefined,
|
setter?: CustomView | RegisteredSetter | undefined,
|
||||||
|
|||||||
@ -26,30 +26,59 @@ export default class SettingPropEntry {
|
|||||||
return this.node;
|
return this.node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置值
|
||||||
|
* @param val
|
||||||
|
*/
|
||||||
setValue(val: CompositeValue) {
|
setValue(val: CompositeValue) {
|
||||||
this[settingPropEntrySymbol].setValue(val);
|
this[settingPropEntrySymbol].setValue(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取值
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getValue() {
|
getValue() {
|
||||||
return this[settingPropEntrySymbol].getValue();
|
return this[settingPropEntrySymbol].getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设置属性集
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getProps() {
|
getProps() {
|
||||||
return SettingTopEntry.create(this[settingPropEntrySymbol].getProps() as SettingEntry) as any;
|
return SettingTopEntry.create(this[settingPropEntrySymbol].getProps() as SettingEntry) as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否绑定了变量
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
isUseVariable() {
|
isUseVariable() {
|
||||||
return this[settingPropEntrySymbol].isUseVariable();
|
return this[settingPropEntrySymbol].isUseVariable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置绑定变量
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
setUseVariable(flag: boolean) {
|
setUseVariable(flag: boolean) {
|
||||||
this[settingPropEntrySymbol].setUseVariable(flag);
|
this[settingPropEntrySymbol].setUseVariable(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个设置 field 实例
|
||||||
|
* @param config
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
createField(config: FieldConfig) {
|
createField(config: FieldConfig) {
|
||||||
return SettingPropEntry.create(this[settingPropEntrySymbol].createField(config));
|
return SettingPropEntry.create(this[settingPropEntrySymbol].createField(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取值,当为变量时,返回 mock
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getMockOrValue() {
|
getMockOrValue() {
|
||||||
return this[settingPropEntrySymbol].getMockOrValue();
|
return this[settingPropEntrySymbol].getMockOrValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,9 @@ export default class SettingTopEntry {
|
|||||||
return new SettingTopEntry(prop);
|
return new SettingTopEntry(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回所属的节点实例
|
||||||
|
*/
|
||||||
get node(): Node | null {
|
get node(): Node | null {
|
||||||
return Node.create(this[settingTopEntrySymbol].getNode());
|
return Node.create(this[settingTopEntrySymbol].getNode());
|
||||||
}
|
}
|
||||||
@ -24,10 +27,20 @@ export default class SettingTopEntry {
|
|||||||
return this.node;
|
return this.node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定 propName 的值
|
||||||
|
* @param propName
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
getPropValue(propName: string | number) {
|
getPropValue(propName: string | number) {
|
||||||
return this[settingTopEntrySymbol].getPropValue(propName);
|
return this[settingTopEntrySymbol].getPropValue(propName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置指定 propName 的值
|
||||||
|
* @param propName
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
setPropValue(propName: string | number, value: any) {
|
setPropValue(propName: string | number, value: any) {
|
||||||
this[settingTopEntrySymbol].setPropValue(propName, value);
|
this[settingTopEntrySymbol].setPropValue(propName, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,18 +15,34 @@ export default class SimulatorHost {
|
|||||||
return new SimulatorHost(host);
|
return new SimulatorHost(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 contentWindow
|
||||||
|
*/
|
||||||
get contentWindow() {
|
get contentWindow() {
|
||||||
return this[simulatorHostSymbol].contentWindow;
|
return this[simulatorHostSymbol].contentWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 contentDocument
|
||||||
|
*/
|
||||||
get contentDocument() {
|
get contentDocument() {
|
||||||
return this[simulatorHostSymbol].contentDocument;
|
return this[simulatorHostSymbol].contentDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 host 配置值
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
set(key: string, value: any) {
|
set(key: string, value: any) {
|
||||||
this[simulatorHostSymbol].set(key, value);
|
this[simulatorHostSymbol].set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 host 配置值
|
||||||
|
* @param key
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
get(key: string) {
|
get(key: string) {
|
||||||
return this[simulatorHostSymbol].get(key);
|
return this[simulatorHostSymbol].get(key);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,10 +12,21 @@ export default class Skeleton {
|
|||||||
this[skeletonSymbol] = skeleton;
|
this[skeletonSymbol] = skeleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加一个面板实例
|
||||||
|
* @param config
|
||||||
|
* @param extraConfig
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
add(config: IWidgetBaseConfig, extraConfig?: Record<string, any>) {
|
add(config: IWidgetBaseConfig, extraConfig?: Record<string, any>) {
|
||||||
return this[skeletonSymbol].add(config, extraConfig);
|
return this[skeletonSymbol].add(config, extraConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除一个面板实例
|
||||||
|
* @param config
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
remove(config: IWidgetBaseConfig) {
|
remove(config: IWidgetBaseConfig) {
|
||||||
const { area, name } = config;
|
const { area, name } = config;
|
||||||
const skeleton = this[skeletonSymbol];
|
const skeleton = this[skeletonSymbol];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user