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