docs: optimize api doc for model/modal-node-manager, and fix related lint issues

This commit is contained in:
JackLian 2023-01-11 10:06:42 +08:00 committed by 刘菊萍(絮黎)
parent 7d526d1e83
commit e5bfc58be8
32 changed files with 231 additions and 171 deletions

View File

@ -42,7 +42,7 @@ get dragon(): IPublicModelDragon | null;
get activeTracker(): IPublicModelActiveTracker | null;
```
## 方法签名
## 方法
### createLocation
创建一个文档插入位置对象,该对象用来描述一个即将插入的节点在文档中的位置

View File

@ -20,7 +20,7 @@ sidebar_position: 11
#### skeletonCabin
面板扩展相关,详见下方方法签名
## 方法签名
## 方法
### utils
#### isNodeSchema
是否为合法的 schema 结构

View File

@ -10,7 +10,7 @@ sidebar_position: 8
## 模块简介
配置模块,负责配置的读、写等操作。
## 方法签名
## 方法
### get
获取指定 key 的值

View File

@ -10,7 +10,7 @@ sidebar_position: 7
## 模块简介
负责事件处理 API支持自定义监听事件、触发事件。
## 方法签名
## 方法
### on
监听事件

View File

@ -9,7 +9,7 @@ sidebar_position: 5
## 模块简介
绑定快捷键 API可以自定义项目快捷键使用。
## 方法签名
## 方法
### bind
绑定快捷键

View File

@ -8,7 +8,7 @@ sidebar_position: 10
## 模块简介
提供 init 等方法
## 方法签名
## 方法
#### 1. init
初始化引擎

View File

@ -12,7 +12,7 @@ sidebar_position: 9
> 注:日志级别可以通过 url query 动态调整,详见下方[查看示例](#查看示例)。<br/>
> 参考 [zen-logger](https://web.npm.alibaba-inc.com/package/zen-logger) 实现进行封装
## 方法签名
## 方法
日志记录方法

View File

@ -22,7 +22,7 @@ get componentsMap(): { [key: string]: IPublicTypeNpmInfo | ComponentType<any> |
```
相关类型:[IPublicTypeNpmInfo](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/npm-info.ts)
## 方法签名
## 方法
### 资产包
#### setAssets

View File

@ -9,7 +9,7 @@ sidebar_position: 6
画布节点悬停模型
## 变量
## 属性
### current
@ -28,7 +28,7 @@ sidebar_position: 6
`@type {boolean}`
## 方法签名
## 方法
### capture
hover 指定节点

View File

@ -9,7 +9,7 @@ sidebar_position: 0
文档模型
## 变量
## 属性
### id
@ -95,7 +95,7 @@ sidebar_position: 0
**@since v1.1.0**
## 方法签名
## 方法
### getNodeById
根据 nodeId 返回 [Node](./node) 实例

View File

@ -18,7 +18,7 @@ import { IPublicModelDragon } from '@alilc/lowcode-types';
**@since** v1.1.0
## 变量
## 属性
### dragging
@ -31,7 +31,7 @@ import { IPublicModelDragon } from '@alilc/lowcode-types';
get dragging(): boolean;
```
## 方法签名
## 方法
### onDragstart

View File

@ -11,7 +11,7 @@ sidebar_position: 13
拖拽放置位置模型
## 变量
## 属性
### target
@ -37,7 +37,7 @@ sidebar_position: 13
相关类型:[IPublicModelLocateEvent](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/location-event.ts)
## 方法签名
## 方法
### clone

View File

@ -9,7 +9,7 @@ sidebar_position: 5
操作历史记录模型
## 方法签名
## 方法
### go
历史记录跳转到指定位置

View File

@ -9,40 +9,86 @@ sidebar_position: 7
模态节点管理器模型
## 方法签名
## 方法
### setNodes
setNodes()
设置模态节点,触发内部事件
```typescript
/**
* 设置模态节点,触发内部事件
* set modal nodes, trigger internal events
*/
setNodes(): void;
```
### getModalNodes
getModalNodes()
获取模态节点(们)
```typescript
/**
* 获取模态节点(们)
* get modal nodes
*/
getModalNodes(): IPublicModelNode[];
```
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
### getVisibleModalNode
getVisibleModalNode()
获取当前可见的模态节点
```typescript
/**
* 获取当前可见的模态节点
* get current visible modal node
*/
getVisibleModalNode(): IPublicModelNode | null;
```
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
### hideModalNodes
hideModalNodes()
隐藏模态节点(们)
```typescript
/**
* 隐藏模态节点(们)
* hide modal nodes
*/
hideModalNodes(): void;
```
### setVisible
setVisible(node: Node)
设置指定节点为可见态
```typescript
/**
* 设置指定节点为可见态
* set specfic model node as visible
* @param node Node
*/
setVisible(node: IPublicModelNode): void;
```
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
### setInvisible
setInvisible(node: Node)
设置指定节点为不可见态
```typescript
/**
* 设置指定节点为不可见态
* set specfic model node as invisible
* @param node Node
*/
setInvisible(node: IPublicModelNode): void;
```
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)

View File

@ -8,7 +8,7 @@ sidebar_position: 2
## 基本介绍
节点孩子模型
## 变量
## 属性
### owner
返回当前 children 实例所属的节点实例
@ -41,7 +41,7 @@ children 内的节点实例数
**@since v1.1.0**
## 方法签名
## 方法
### delete
删除指定节点

View File

@ -9,7 +9,7 @@ sidebar_position: 1
节点模型
## 变量
## 属性
### id
节点 id
@ -263,7 +263,7 @@ sidebar_position: 1
**@since v1.1.0**
## 方法签名
## 方法
### getRect

View File

@ -17,38 +17,24 @@ sidebar_position: 12
插件名字
```typescript
get name(): string;
```
`@type {string}`
### dep
插件依赖
```typescript
get dep(): string[];
```
`@type {string[]}`
### disabled
插件是否禁用
```typescript
get disabled(): boolean
set disabled(disabled: boolean): void;
```
`@type {boolean}`
### meta
插件 meta 信息
```typescript
get meta(): IPublicTypePluginMeta
```
- [IPublicTypePluginMeta](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/plugin-meta.ts)
`@type {IPublicTypePluginMeta}`
相关类型:[IPublicTypePluginMeta](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/plugin-meta.ts)

View File

@ -9,7 +9,7 @@ sidebar_position: 3
属性模型
## 变量
## 属性
### id
@ -46,7 +46,7 @@ key 值
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
## 方法签名
## 方法
### setValue

View File

@ -9,7 +9,7 @@ sidebar_position: 4
属性集模型
## 变量
## 属性
### id
id
@ -32,7 +32,7 @@ id
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
## 方法签名
## 方法
### getProp
获取指定 path 的属性模型实例

View File

@ -7,7 +7,7 @@ sidebar_position: 12
> **@types** [IPublicModelWindow](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/resource.ts)<br/>
> **@since** v1.1.0
## 变量
## 属性
### title

View File

@ -9,7 +9,7 @@ sidebar_position: 6
画布节点选中模型
## 变量
## 属性
### selected
返回选中的节点 id
@ -25,7 +25,7 @@ sidebar_position: 6
**@since v1.1.0**
## 方法签名
## 方法
### select
选中指定节点(覆盖方式)

View File

@ -12,7 +12,7 @@ sidebar_position: 12
低代码设计器窗口模型
## 变量
## 属性
### id
@ -38,7 +38,7 @@ sidebar_position: 12
关联模型 [IPublicModelResource](./resource)
## 方法签名
## 方法
### importSchema
当前窗口导入 schema, 会调用当前窗口对应资源的 import 钩子

View File

@ -8,7 +8,7 @@ sidebar_position: 4
## 模块简介
插件管理器,提供编排模块中管理插件的能力。
## 方法签名
## 方法
### register
注册插件

View File

@ -69,7 +69,7 @@ get simulatorHost(): IPublicApiSimulatorHost | null;
相关类型:[IPublicApiSimulatorHost](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/simulator-host.ts)
## 方法签名
## 方法
### openDocument
打开一个 document

View File

@ -8,7 +8,7 @@ sidebar_position: 6
## 模块简介
负责注册设置器、管理设置器的 API。注册自定义设置器之后可以在物料中进行使用。
## 方法签名
## 方法
### getSetter
获取指定 setter

View File

@ -135,7 +135,7 @@ skeleton.add({
});
```
## 方法签名
## 方法
### add

View File

@ -57,7 +57,7 @@ get resourceList(): IPublicModelResource;
关联模型 [IPublicModelResource](./model/resource)
## 方法签名
## 方法
### registerResourceType
注册资源

View File

@ -753,7 +753,7 @@ export class DocumentModel implements IDocumentModel {
}));
}
onNodeCreate(func: (node: Node) => void) {
onNodeCreate(func: (node: INode) => void) {
const wrappedFunc = wrapWithEventSwitch(func);
this.emitter.on('nodecreate', wrappedFunc);
return () => {
@ -761,7 +761,7 @@ export class DocumentModel implements IDocumentModel {
};
}
onNodeDestroy(func: (node: Node) => void) {
onNodeDestroy(func: (node: INode) => void) {
const wrappedFunc = wrapWithEventSwitch(func);
this.emitter.on('nodedestroy', wrappedFunc);
return () => {

View File

@ -1,15 +1,15 @@
import { Node } from './node';
import { INode, Node } from './node';
import { DocumentModel } from '../document-model';
import { IPublicModelModalNodesManager } from '@alilc/lowcode-types';
import { createModuleEventBus, IEventBus } from '@alilc/lowcode-editor-core';
export function getModalNodes(node: Node) {
export function getModalNodes(node: INode | Node) {
if (!node) return [];
let nodes: any = [];
if (node.componentMeta.isModal) {
nodes.push(node);
}
const children = node.getChildren();
const { children } = node;
if (children) {
children.forEach((child) => {
nodes = nodes.concat(getModalNodes(child));
@ -20,14 +20,17 @@ export function getModalNodes(node: Node) {
export interface IModalNodesManager extends IPublicModelModalNodesManager {
getModalNodes(): INode[];
getVisibleModalNode(): INode | null;
}
export class ModalNodesManager implements IModalNodesManager {
public willDestroy: any;
willDestroy: any;
private page: DocumentModel;
private modalNodes: Node[];
private modalNodes: INode[];
private nodeRemoveEvents: any;
@ -45,26 +48,27 @@ export class ModalNodesManager implements IModalNodesManager {
];
}
getModalNodes() {
getModalNodes(): INode[] {
return this.modalNodes;
}
getVisibleModalNode() {
return this.getModalNodes().find((node: Node) => node.getVisible());
getVisibleModalNode(): INode | null {
const visibleNode = this.getModalNodes().find((node: INode) => node.getVisible());
return visibleNode || null;
}
hideModalNodes() {
this.modalNodes.forEach((node: Node) => {
this.modalNodes.forEach((node: INode) => {
node.setVisible(false);
});
}
setVisible(node: Node) {
setVisible(node: INode) {
this.hideModalNodes();
node.setVisible(true);
}
setInvisible(node: Node) {
setInvisible(node: INode) {
node.setVisible(false);
}
@ -82,7 +86,7 @@ export class ModalNodesManager implements IModalNodesManager {
};
}
private addNode(node: Node) {
private addNode(node: INode) {
if (node.componentMeta.isModal) {
this.hideModalNodes();
this.modalNodes.push(node);
@ -92,7 +96,7 @@ export class ModalNodesManager implements IModalNodesManager {
}
}
private removeNode(node: Node) {
private removeNode(node: INode) {
if (node.componentMeta.isModal) {
const index = this.modalNodes.indexOf(node);
if (index >= 0) {
@ -106,24 +110,24 @@ export class ModalNodesManager implements IModalNodesManager {
}
}
private addNodeEvent(node: Node) {
this.nodeRemoveEvents[node.getId()] =
private addNodeEvent(node: INode) {
this.nodeRemoveEvents[node.id] =
node.onVisibleChange(() => {
this.emitter.emit('visibleChange');
});
}
private removeNodeEvent(node: Node) {
if (this.nodeRemoveEvents[node.getId()]) {
this.nodeRemoveEvents[node.getId()]();
delete this.nodeRemoveEvents[node.getId()];
private removeNodeEvent(node: INode) {
if (this.nodeRemoveEvents[node.id]) {
this.nodeRemoveEvents[node.id]();
delete this.nodeRemoveEvents[node.id];
}
}
setNodes() {
const nodes = getModalNodes(this.page.getRoot()!);
const nodes = getModalNodes(this.page.rootNode!);
this.modalNodes = nodes;
this.modalNodes.forEach((node: Node) => {
this.modalNodes.forEach((node: INode) => {
this.addNodeEvent(node);
});

View File

@ -36,6 +36,11 @@ export interface NodeStatus {
export interface INode extends IPublicModelNode {
/**
*
*/
get children(): INodeChildren | null;
setVisible(flag: boolean): void;
getVisible(): boolean;
@ -70,6 +75,10 @@ export interface INode extends IPublicModelNode {
internalSetSlotFor(slotFor: Prop | null | undefined): void;
addSlot(slotNode: INode): void;
get componentMeta(): ComponentMeta;
onVisibleChange(func: (flag: boolean) => any): () => void;
}
/**
@ -204,6 +213,74 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
isInited = false;
_settingEntry: SettingTopEntry;
get settingEntry(): SettingTopEntry {
if (this._settingEntry) return this._settingEntry;
this._settingEntry = this.document.designer.createSettingEntry([this]);
return this._settingEntry;
}
private autoruns?: Array<() => void>;
private _isRGLContainer = false;
set isRGLContainer(status: boolean) {
this._isRGLContainer = status;
}
get isRGLContainer(): boolean {
return !!this._isRGLContainer;
}
set isRGLContainerNode(status: boolean) {
this._isRGLContainer = status;
}
get isRGLContainerNode(): boolean {
return !!this._isRGLContainer;
}
private _slotFor?: Prop | null = null;
@obx.shallow _slots: INode[] = [];
get slots() {
return this._slots;
}
/* istanbul ignore next */
@obx.ref private _conditionGroup: IPublicModelExclusiveGroup | null = null;
/* istanbul ignore next */
get conditionGroup(): IPublicModelExclusiveGroup | null {
return this._conditionGroup;
}
private purged = false;
/**
*
*/
get isPurged() {
return this.purged;
}
private purging: boolean = false;
/**
*
*/
get isPurging() {
return this.purging;
}
@obx.shallow status: NodeStatus = {
inPlaceEditing: false,
locking: false,
pseudo: false,
};
constructor(readonly document: IDocumentModel, nodeSchema: Schema, options: any = {}) {
makeObservable(this);
const { componentName, id, children, props, ...extras } = nodeSchema;
@ -237,14 +314,6 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
});
}
_settingEntry: SettingTopEntry;
get settingEntry(): SettingTopEntry {
if (this._settingEntry) return this._settingEntry;
this._settingEntry = this.document.designer.createSettingEntry([this]);
return this._settingEntry;
}
/**
* prop reaction
*/
@ -268,8 +337,6 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
return this.document.designer.transformProps(props, this, IPublicEnumTransformStage.Upgrade);
}
private autoruns?: Array<() => void>;
private setupAutoruns() {
const autoruns = this.componentMeta.getMetadata().configure.advanced?.autoruns;
if (!autoruns || autoruns.length < 1) {
@ -296,24 +363,6 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
return children || [];
}
private _isRGLContainer = false;
set isRGLContainer(status: boolean) {
this._isRGLContainer = status;
}
get isRGLContainer(): boolean {
return !!this._isRGLContainer;
}
set isRGLContainerNode(status: boolean) {
this._isRGLContainer = status;
}
get isRGLContainerNode(): boolean {
return !!this._isRGLContainer;
}
isContainer(): boolean {
return this.isContainerNode;
}
@ -449,8 +498,6 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
}
}
private _slotFor?: Prop | null = null;
internalSetSlotFor(slotFor: Prop | null | undefined) {
this._slotFor = slotFor;
}
@ -536,24 +583,10 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
return this.props.export(IPublicEnumTransformStage.Serilize).props || null;
}
@obx.shallow _slots: INode[] = [];
hasSlots() {
return this._slots.length > 0;
}
get slots() {
return this._slots;
}
/* istanbul ignore next */
@obx.ref private _conditionGroup: IPublicModelExclusiveGroup | null = null;
/* istanbul ignore next */
get conditionGroup(): IPublicModelExclusiveGroup | null {
return this._conditionGroup;
}
/* istanbul ignore next */
setConditionGroup(grp: IPublicModelExclusiveGroup | string | null) {
if (!grp) {
@ -929,15 +962,6 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
this.children?.delete(node);
}
private purged = false;
/**
*
*/
get isPurged() {
return this.purged;
}
/**
*
*/
@ -952,18 +976,10 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
// this.document.destroyNode(this);
}
private purging: boolean = false;
internalPurgeStart() {
this.purging = true;
}
/**
*
*/
get isPurging() {
return this.purging;
}
/**
* action
*/
@ -1044,12 +1060,6 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
this.children?.mergeChildren(remover, adder, sorter);
}
@obx.shallow status: NodeStatus = {
inPlaceEditing: false,
locking: false,
pseudo: false,
};
/**
* @deprecated
*/

View File

@ -1,6 +1,9 @@
import { ModalNodesManager as InnerModalNodesManager } from '@alilc/lowcode-designer';
import {
IModalNodesManager as InnerModalNodesManager,
INode as InnerNode,
} from '@alilc/lowcode-designer';
import { IPublicModelModalNodesManager, IPublicModelNode } from '@alilc/lowcode-types';
import { Node } from './node';
import { Node as ShellNode } from './node';
import { nodeSymbol, modalNodesManagerSymbol } from '../symbols';
export class ModalNodesManager implements IPublicModelModalNodesManager {
@ -28,18 +31,24 @@ export class ModalNodesManager implements IPublicModelModalNodesManager {
/**
*
* @returns
*/
getModalNodes(): any {
return this[modalNodesManagerSymbol].getModalNodes().map((node) => Node.create(node));
getModalNodes(): IPublicModelNode[] {
const innerNodes = this[modalNodesManagerSymbol].getModalNodes();
const shellNodes: IPublicModelNode[] = [];
innerNodes?.forEach((node: InnerNode) => {
const shellNode = ShellNode.create(node);
if (shellNode) {
shellNodes.push(shellNode);
}
});
return shellNodes;
}
/**
*
* @returns
*/
getVisibleModalNode(): any {
return Node.create(this[modalNodesManagerSymbol].getVisibleModalNode());
getVisibleModalNode(): IPublicModelNode | null {
return ShellNode.create(this[modalNodesManagerSymbol].getVisibleModalNode());
}
/**
@ -54,7 +63,7 @@ export class ModalNodesManager implements IPublicModelModalNodesManager {
* @param node Node
*/
setVisible(node: IPublicModelNode): void {
this[modalNodesManagerSymbol].setVisible(node[nodeSymbol]);
this[modalNodesManagerSymbol].setVisible((node as any)[nodeSymbol]);
}
/**
@ -62,6 +71,6 @@ export class ModalNodesManager implements IPublicModelModalNodesManager {
* @param node Node
*/
setInvisible(node: IPublicModelNode): void {
this[modalNodesManagerSymbol].setInvisible(node[nodeSymbol]);
this[modalNodesManagerSymbol].setInvisible((node as any)[nodeSymbol]);
}
}

View File

@ -1,36 +1,41 @@
import { IPublicModelNode } from './';
export interface IPublicModelModalNodesManager {
/**
*
* set modal nodes, trigger internal events
*/
setNodes(): void;
/**
*
* @returns
* get modal nodes
*/
getModalNodes(): any;
getModalNodes(): IPublicModelNode[];
/**
*
* @returns
* get current visible modal node
*/
getVisibleModalNode(): any;
getVisibleModalNode(): IPublicModelNode | null;
/**
*
* hide modal nodes
*/
hideModalNodes(): void;
/**
*
* set specfic model node as visible
* @param node Node
*/
setVisible(node: IPublicModelNode): void;
/**
*
* set specfic model node as invisible
* @param node Node
*/
setInvisible(node: IPublicModelNode): void;