docs: api文档基础优化

This commit is contained in:
JackLian 2022-12-25 13:49:05 +08:00 committed by 刘菊萍(絮黎)
parent 56e9f04221
commit 33ed67ab57
58 changed files with 2453 additions and 1534 deletions

View File

@ -33,12 +33,6 @@ module.exports = {
position: 'left', position: 'left',
label: 'FAQ', label: 'FAQ',
}, },
{
type: 'doc',
docId: 'participate/index',
position: 'left',
label: '参与贡献',
},
{ {
type: 'doc', type: 'doc',
docId: 'article/index', docId: 'article/index',
@ -51,16 +45,6 @@ module.exports = {
position: 'left', position: 'left',
label: 'Demo 使用文档', label: 'Demo 使用文档',
}, },
{
position: 'left',
href: 'https://developer.aliyun.com/ebook/7507',
label: '技术白皮书',
},
{
position: 'left',
href: 'https://github.com/alibaba/lowcode-engine/releases',
label: '更新日志',
},
{ {
to: '/community/issue', to: '/community/issue',
position: 'left', position: 'left',
@ -80,6 +64,12 @@ module.exports = {
className: 'header-github-link', className: 'header-github-link',
'aria-label': 'GitHub repository', 'aria-label': 'GitHub repository',
}, },
{
type: 'doc',
docId: 'participate/index',
position: 'right',
label: '参与贡献',
},
{ {
type: 'search', type: 'search',
position: 'right', position: 'right',

View File

@ -22,10 +22,56 @@ module.exports = {
* 根据当前目录自动生成导航配置 * 根据当前目录自动生成导航配置
*/ */
guide: [ guide: [
{ [
type: 'autogenerated', {
dirName: 'guide', // '.' 即当前的文档文件夹 type: 'category',
}, label: '入门',
collapsed: false,
items: getDocsFromDir('guide/quickStart'),
},
{
type: 'category',
label: '创建编辑器',
collapsed: false,
items: getDocsFromDir('guide/create'),
},
{
type: 'category',
label: '扩展编辑器',
collapsed: false,
items: getDocsFromDir('guide/expand/editor'),
},
{
type: 'category',
label: '扩展运行时',
collapsed: false,
items: getDocsFromDir('guide/expand/runtime'),
},
{
type: 'category',
label: '设计原理',
collapsed: false,
items: getDocsFromDir('guide/design'),
},
{
type: 'category',
label: '附录',
collapsed: false,
items: [
{
type: 'link',
label: '更新日志',
href: 'https://github.com/alibaba/lowcode-engine/releases',
},
...getDocsFromDir('guide/appendix'),
],
},
{
type: 'link',
label: '技术白皮书',
href: 'https://developer.aliyun.com/ebook/7507',
},
],
], ],
api: [ api: [
{ {
@ -57,5 +103,4 @@ module.exports = {
dirName: 'demoUsage', dirName: 'demoUsage',
}, },
], ],
// api: getDocsFromDir('api'),
}; };

86
docs/docs/api/canvas.md Normal file
View File

@ -0,0 +1,86 @@
---
title: cavas - 画布 API
sidebar_position: 12
---
> **@types** [IPublicApiCanvas](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/canvas.ts)<br/>
> **@since** v1.1.0
## 模块简介
通过该模块可以触达对画布拖拽相关的一些能力。
## 变量
### dragon
获取拖拽操作对象的实例
```typescript
/**
* 获取拖拽操作对象的实例
* get dragon instance, you can use this to obtain draging related abilities and lifecycle hooks
* @since v1.1.0
*/
get dragon(): IPublicModelDragon | null;
```
关联模型 [IPublicModelDragon](./model/dragon)
### activeTracker
获取活动追踪器实例
```typescript
/**
* 获取活动追踪器实例
* get activeTracker instance, which is a singleton running in engine.
* it tracks document`s current focusing node/node[], and notify it`s subscribers that when
* focusing node/node[] changed.
* @since v1.1.0
*/
get activeTracker(): IPublicModelActiveTracker | null;
```
## 方法签名
### createLocation
创建一个文档插入位置对象,该对象用来描述一个即将插入的节点在文档中的位置
```typescript
/**
* 创建一个文档插入位置对象,该对象用来描述一个即将插入的节点在文档中的位置
* create a drop location for document, drop location describes a location in document
* @since v1.1.0
*/
createLocation(locationData: IPublicTypeLocationData): IPublicModelDropLocation;
```
### createScroller
创建一个滚动控制器 Scroller赋予一个视图滚动的基本能力
```typescript
/**
* 创建一个滚动控制器 Scroller赋予一个视图滚动的基本能力
* a Scroller is a controller that gives a view (IPublicModelScrollable) the ability scrolling
* to some cordination by api scrollTo.
*
* when a scroller is inited, will need to pass is a scrollable, which has a scrollTarget.
* and when scrollTo(options: { left?: number; top?: number }) is called, scroller will
* move scrollTarget`s top-left corner to (options.left, options.top) that passed in.
* @since v1.1.0
*/
createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller;
```
### createScrollTarget
创建一个 ScrollTarget与 Scroller 一起发挥作用,详见 [createScroller](#createscroller) 中的描述
```typescript
/**
* 创建一个 ScrollTarget与 Scroller 一起发挥作用,详见 createScroller 中的描述
* this works with Scroller, refer to createScroller`s description
* @since v1.1.0
*/
createScrollTarget(shell: HTMLDivElement): IPublicModelScrollTarget;
```

View File

@ -2,34 +2,87 @@
title: common - 通用 API title: common - 通用 API
sidebar_position: 11 sidebar_position: 11
--- ---
# 模块简介
通用模块里包含除了 9 大核心模块 API 之外的所有 API比如通用 utils、面板扩展相关 等。 > **@types** [IPublicApiCommon](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/common.ts)<br/>
> **@since** v1.0.0
## 模块简介
通用模块里包含除了几大核心模块 API 之外的所有 API比如通用 utils、面板扩展相关 等。
> 高能预警:之所以叫 skeletonCabin / designerCabin 跟兼容上一个版本的引擎有关系。若有必要,后面将用更有意义的命名空间来组织这些 API。 > 高能预警:之所以叫 skeletonCabin / designerCabin 跟兼容上一个版本的引擎有关系。若有必要,后面将用更有意义的命名空间来组织这些 API。
# 变量variables ## 变量
### utils #### utils
通用 utils详见下方方法签名 通用 utils详见下方方法签名
### designerCabin 相关类型:[IPublicApiCommonUtils](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/common.ts)
设计器扩展相关,详见下方方法签名
### skeletonCabin #### skeletonCabin
面板扩展相关,详见下方方法签名 面板扩展相关,详见下方方法签名
# 方法签名functions ## 方法签名
## utils ### utils
### isNodeSchema #### isNodeSchema
是否为合法的 schema 结构 是否为合法的 schema 结构
### isFormEvent ```typscript
/**
* 是否为合法的 schema 结构
* check if data is valid NodeSchema
*
* @param {*} data
* @returns {boolean}
*/
isNodeSchema(data: any): boolean;
```
#### isFormEvent
是否为表单事件类型 是否为表单事件类型
### getNodeSchemaById ```typescript
从 schema 结构中查找指定 id 节点 /**
* 是否为表单事件类型
* check if e is a form event
* @param {(KeyboardEvent | MouseEvent)} e
* @returns {boolean}
*/
isFormEvent(e: KeyboardEvent | MouseEvent): boolean;
```
### executeTransaction #### getNodeSchemaById
从 schema 结构中查找指定 id 节点
```typescript
/**
* 从 schema 结构中查找指定 id 节点
* get node schema from a larger schema with node id
* @param {IPublicTypeNodeSchema} schema
* @param {string} nodeId
* @returns {(IPublicTypeNodeSchema | undefined)}
*/
getNodeSchemaById(
schema: IPublicTypeNodeSchema,
nodeId: string,
): IPublicTypeNodeSchema | undefined;
```
相关类型:[IPublicTypeNodeSchema](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/node-schema.ts)
#### executeTransaction
批处理事务,用于优化特定场景的性能 批处理事务,用于优化特定场景的性能
*引擎版本 >= 1.0.16
```typescript
/**
* 批处理事务,用于优化特定场景的性能
* excute something in a transaction for performence
*
* @param {() => void} fn
* @param {IPublicEnumTransitionType} type
* @since v1.0.16
*/
executeTransaction(fn: () => void, type: IPublicEnumTransitionType): void;
```
**@since v1.0.16**
##### 示例
```typescript ```typescript
import { common } from '@alilc/lowcode-engine'; import { common } from '@alilc/lowcode-engine';
import { IPublicEnumTransitionType } from '@alilc/lowcode-types'; import { IPublicEnumTransitionType } from '@alilc/lowcode-types';
@ -42,9 +95,33 @@ common.utils.startTransaction(() => {
}, IPublicEnumTransitionType.repaint); }, IPublicEnumTransitionType.repaint);
``` ```
### createIntl #### createIntl
i18n 相关工具 i18n 相关工具
*引擎版本 >= 1.0.17 ```typescript
/**
* i18n 相关工具
* i18n tools
*
* @param {(string | object)} instance
* @returns {{
* intlNode(id: string, params?: object): ReactNode;
* intl(id: string, params?: object): string;
* getLocale(): string;
* setLocale(locale: string): void;
* }}
* @since v1.0.17
*/
createIntl(instance: string | object): {
intlNode(id: string, params?: object): ReactNode;
intl(id: string, params?: object): string;
getLocale(): string;
setLocale(locale: string): void;
};
```
**@since v1.0.17**
##### 示例
```typescript ```typescript
import { common } from '@alilc/lowcode-engine'; import { common } from '@alilc/lowcode-engine';
import enUS from './en-US.json'; import enUS from './en-US.json';
@ -56,16 +133,15 @@ const { intl, getLocale, setLocale } = common.utils.createIntl({
}); });
``` ```
## designerCabin
### isSettingField
是否是 SettingField 实例
### TransformStage ### skeletonCabin
转换类型枚举对象,包含 init / upgrade / render 等类型,参考 [TransformStage](https://github.com/alibaba/lowcode-engine/blob/4f4ac5115d18357a7399632860808f6cffc33fad/packages/types/src/transform-stage.ts#L1) #### Workbench
##
## skeletonCabin
### Workbench
编辑器框架 View 编辑器框架 View
# 事件events ```typescript
/**
* 编辑器框架 View
* get Workbench Component
*/
get Workbench(): Component;
```

View File

@ -2,21 +2,29 @@
title: config - 配置 API title: config - 配置 API
sidebar_position: 8 sidebar_position: 8
--- ---
> **@types** [IPublicModelEngineConfig](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/engine-config.ts)<br/>
> **@since** v1.0.0
## 模块简介 ## 模块简介
配置模块,负责配置的读、写等操作。 配置模块,负责配置的读、写等操作。
##
## 变量variables ## 方法签名
##
## 方法签名functions
### get ### get
获取指定 key 的值 获取指定 key 的值
**类型定义**
```typescript ```typescript
function get(key: string, defaultValue?: any): any /**
* 获取指定 key 的值
* get value by key
* @param key
* @param defaultValue
* @returns
*/
get(key: string, defaultValue?: any): any;
``` ```
**调用示例** #### 示例
```typescript ```typescript
import { config } from '@alilc/lowcode-engine'; import { config } from '@alilc/lowcode-engine';
@ -26,11 +34,16 @@ config.get('keyB', { a: 1 });
### set ### set
设置指定 key 的值 设置指定 key 的值
**类型定义**
```typescript ```typescript
function set(key: string, value: any) /**
* 设置指定 key 的值
* set value for certain key
* @param key
* @param value
*/
set(key: string, value: any): void;
``` ```
**调用示例** #### 示例
```typescript ```typescript
import { config } from '@alilc/lowcode-engine'; import { config } from '@alilc/lowcode-engine';
@ -40,40 +53,77 @@ config.set('keyC', 1);
### has ### has
判断指定 key 是否有值 判断指定 key 是否有值
**类型定义**
```typescript ```typescript
function has(key: string): boolean /**
* 判断指定 key 是否有值
* check if config has certain key configed
* @param key
* @returns
*/
has(key: string): boolean;
``` ```
**调用示例**
#### 示例
```typescript ```typescript
import { config } from '@alilc/lowcode-engine'; import { config } from '@alilc/lowcode-engine';
config.has('keyD'); config.has('keyD');
``` ```
###
### setConfig ### setConfig
批量设值set 的对象版本 批量设值set 的对象版本
**类型定义**
```typescript ```typescript
function setConfig(config: { [key: string]: any }) /**
* 批量设值set 的对象版本
* set multiple config key-values
* @param config
*/
setConfig(config: { [key: string]: any }): void;
``` ```
**调用示例** #### 示例
```typescript ```typescript
import { config } from '@alilc/lowcode-engine'; import { config } from '@alilc/lowcode-engine';
config.setConfig({ keyA: false, keyB: 2 }); config.setConfig({ keyA: false, keyB: 2 });
``` ```
### getPreference
获取全局 Preference 管理器,用于管理全局浏览器侧用户 Preference如 Panel 是否钉住
```typescript
/**
* 获取全局 Preference, 用于管理全局浏览器侧用户 Preference如 Panel 是否钉住
* get global user preference manager, which can be use to store
* user`s preference in user localstorage, such as a panel is pinned or not.
* @returns {IPublicModelPreference}
* @since v1.1.0
*/
getPreference(): IPublicModelPreference;
```
相关类型:[IPublicModelPreference](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/preference.ts)
**@since v1.1.0**
## 事件
### onceGot ### onceGot
获取指定 key 的值,若此时还未赋值,则等待,若已有值,则直接返回值 获取指定 key 的值,若此时还未赋值,则等待,若已有值,则直接返回值
注:此函数返回 Promise 实例 注:此函数返回 Promise 实例
**类型定义**
```typescript ```typescript
function onceGot(key: string): Promise<any> /**
* 获取指定 key 的值,若此时还未赋值,则等待,若已有值,则直接返回值
* 注:此函数返回 Promise 实例只会执行fullfill一次
* wait until value of certain key is set, will only be
* triggered once.
* @param key
* @returns
*/
onceGot(key: string): Promise<any>;
``` ```
**调用示例** #### 示例
```typescript ```typescript
import { config } from '@alilc/lowcode-engine'; import { config } from '@alilc/lowcode-engine';
@ -88,11 +138,18 @@ const value = await config.onceGot('keyA');
### onGot ### onGot
获取指定 key 的值,函数回调模式,若多次被赋值,回调会被多次调用 获取指定 key 的值,函数回调模式,若多次被赋值,回调会被多次调用
**类型定义**
```typescript ```typescript
function onGot(key: string, fn: (data: any) => void): () => void /**
* 获取指定 key 的值,函数回调模式,若多次被赋值,回调会被多次调用
* set callback for event of value set for some key
* this will be called each time the value is set
* @param key
* @param fn
* @returns
*/
onGot(key: string, fn: (data: any) => void): () => void;
``` ```
**调用示例** #### 示例
```typescript ```typescript
import { config } from '@alilc/lowcode-engine'; import { config } from '@alilc/lowcode-engine';
@ -103,5 +160,3 @@ config.onGot('keyA', (value) => {
const.set('keyA', 1); // 'The value of keyA is 1' const.set('keyA', 1); // 'The value of keyA is 1'
const.set('keyA', 2); // 'The value of keyA is 2' const.set('keyA', 2); // 'The value of keyA is 2'
``` ```
## 事件events

View File

@ -2,41 +2,63 @@
title: event - 事件 API title: event - 事件 API
sidebar_position: 7 sidebar_position: 7
--- ---
> **@types** [IPublicApiEvent](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/event.ts)<br/>
> **@since** v1.0.0
## 模块简介 ## 模块简介
负责事件处理 API支持自定义监听事件、触发事件。 负责事件处理 API支持自定义监听事件、触发事件。
## 方法签名functions ## 方法签名
### on ### on
监听事件 监听事件
**类型定义**
```typescript ```typescript
function on(event: string, listener: (...args: unknown[]) => void): void; /**
* 监听事件
* add monitor to a event
* @param event 事件名称
* @param listener 事件回调
*/
on(event: string, listener: (...args: any[]) => void): IPublicTypeDisposable;
``` ```
相关类型:[IPublicTypeDisposable](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/disposable.ts)
### off ### off
取消监听事件 取消监听事件
**类型定义**
```typescript ```typescript
function off(event: string, listener: (...args: unknown[]) => void): void; /**
* 取消监听事件
* cancel a monitor from a event
* @param event 事件名称
* @param listener 事件回调
*/
off(event: string, listener: (...args: any[]) => void): void;
``` ```
### emit ### emit
触发事件 触发事件
**类型定义**
```typescript ```typescript
function emit(event: string, ...args: unknown[]): void; /**
* 取消监听事件
* cancel a monitor from a event
* @param event 事件名称
* @param listener 事件回调
*/
off(event: string, listener: (...args: any[]) => void): void;
``` ```
## 使用示例 ## 使用示例
### 事件触发和监听 ### 事件触发和监听
```typescript ```typescript
const eventName = 'eventName'; const eventName = 'eventName';
// 事件监听 // 事件监听
// 插件中发出的事件,默认以 `common` 为前缀,监听时需要注意下
event.on(`common:${eventName}`); event.on(`common:${eventName}`);
// 触发事件 // 触发事件

View File

@ -2,29 +2,36 @@
title: hotkey - 快捷键 API title: hotkey - 快捷键 API
sidebar_position: 5 sidebar_position: 5
--- ---
> **@types** [IPublicApiHotkey](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/hotkey.ts)<br/>
> **@since** v1.0.0
## 模块简介 ## 模块简介
绑定快捷键 API可以自定义项目快捷键使用。 绑定快捷键 API可以自定义项目快捷键使用。
## 方法签名functions ## 方法签名
### bind ### bind
绑定快捷键 绑定快捷键
**类型定义**
```typescript ```typescript
function bind( /**
combos: string[] | string, * 绑定快捷键
callback: (e: KeyboardEvent, combo?: string) => any | false, * bind hotkey/hotkeys,
action?: string * @param combos 快捷键,格式如:['command + s'] 、['ctrl + shift + s'] 等
): () => void; * @param callback 回调函数
* @param action
* @returns
*/
bind(
combos: string[] | string,
callback: IPublicTypeHotkeyCallback,
action?: string,
): IPublicTypeDisposable;
``` ```
相关 types
- [IPublicTypeHotkeyCallback](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/hotkey-callback.ts)
- [IPublicTypeDisposable](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/disposable.ts)
**示例**
```typescript
hotkey.bind('command+s', (e) => {
e.preventDefault();
// command+s 快捷键按下时需要执行的逻辑
});
```
## 使用示例 ## 使用示例
### 基础示例 ### 基础示例

View File

@ -5,7 +5,7 @@ sidebar_position: 0
引擎提供的公开 API 分为`命名空间``模型`两类,其中`命名空间`用于聚合一大类的 API`模型`为各 API 涉及到的对象模型。 引擎提供的公开 API 分为`命名空间``模型`两类,其中`命名空间`用于聚合一大类的 API`模型`为各 API 涉及到的对象模型。
### 命名空间 ## 命名空间
引擎直接提供以下几大类 API 引擎直接提供以下几大类 API
@ -21,7 +21,7 @@ sidebar_position: 0
- logger 日志 API - logger 日志 API
- init 初始化 API - init 初始化 API
### 模型 ## 模型
以下模型通过前面的 API 以返回值等形式间接透出。 以下模型通过前面的 API 以返回值等形式间接透出。
- document-model 文档 - document-model 文档
@ -37,7 +37,7 @@ sidebar_position: 0
- history 操作历史 - history 操作历史
### API 设计约定 ## API 设计约定
一些 API 设计约定: 一些 API 设计约定:
1. 所有 API 命名空间都按照 variables / functions / events 来组织 1. 所有 API 命名空间都按照 variables / functions / events 来组织

View File

@ -2,6 +2,10 @@
title: init - 初始化 API title: init - 初始化 API
sidebar_position: 10 sidebar_position: 10
--- ---
> **@since** v1.0.0
## 模块简介 ## 模块简介
提供 init 等方法 提供 init 等方法
## 方法签名 ## 方法签名
@ -14,6 +18,7 @@ function init(container?: Element, options?: EngineOptions): void
``` ```
**初始化引擎的参数** **初始化引擎的参数**
```typescript ```typescript
interface EngineOptions { interface EngineOptions {
/** /**
@ -102,6 +107,9 @@ interface EngineOptions {
[key: string]: any; [key: string]: any;
} }
``` ```
> 源码详见 [EngineOptions](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/engine-config.ts)
## 使用示例 ## 使用示例
```typescript ```typescript
import { init } from '@alilc/lowcode-engine'; import { init } from '@alilc/lowcode-engine';

View File

@ -2,48 +2,79 @@
title: logger - 日志 API title: logger - 日志 API
sidebar_position: 9 sidebar_position: 9
--- ---
## 模块简介
引擎日志模块,可以按照 **日志级别 **和** 业务类型 **两个维度来定制日志,参考 [zen-logger](https://web.npm.alibaba-inc.com/package/zen-logger) 实现进行封装。
> 注:日志级别可以通过 url query 动态调整,详见下方使用示例。
## 变量variables > **@types** [IPublicApiLogger](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/logger.ts)<br/>
> **@since** v1.0.0
## 方法签名functions
### log / warn / error / info / debug
## 模块简介
引擎日志模块,可以按照 **日志级别 **和** 业务类型 **两个维度来定制日志。
> 注:日志级别可以通过 url query 动态调整,详见下方[查看示例](#查看示例)。<br/>
> 参考 [zen-logger](https://web.npm.alibaba-inc.com/package/zen-logger) 实现进行封装
## 方法签名
日志记录方法 日志记录方法
**类型定义**
```typescript ```typescript
function log(args: any[]): void /**
function warn(args: any[]): void * debug info
function error(args: any[]): void */
function info(args: any[]): void debug(...args: any | any[]): void;
function debug(args: any[]): void
/**
* normal info output
*/
info(...args: any | any[]): void;
/**
* warning info output
*/
warn(...args: any | any[]): void;
/**
* error info output
*/
error(...args: any | any[]): void;
/**
* log info output
*/
log(...args: any | any[]): void;
``` ```
**调用示例**
## 输出示例
```typescript ```typescript
import { Logger } from '@alilc/lowcode-utils'; import { Logger } from '@alilc/lowcode-utils';
const logger = new Logger({ level: 'warn', bizName: 'designer:pluginManager' }); const logger = new Logger({ level: 'warn', bizName: 'myPlugin:moduleA' });
logger.log('Awesome Low-Code Engine'); logger.log('Awesome Low-Code Engine');
``` ```
## 事件events
## 使用示例 ## 查看示例
```typescript
import { Logger } from '@alilc/lowcode-utils';
const logger = new Logger({ level: 'warn', bizName: 'designer:pluginManager' }); 开启查看方式:
// 若在 url query 中增加 `__logConf__` 可改变打印日志级别和限定业务类型日志 - 方式 1所有 logger 创建时会有默认输出的 level, 默认为 warn , 即只展示 warn , error
// 默认__logConf__=warn:* - 方式 2url 上追加 __logConf__进行开启示例如下
logger.log('log'); // 不输出
logger.warn('warn'); // 输出 ```
logger.error('error'); // 输出 https://lowcode-engine.cn/demo/demo-general/index.html?__logConf__=warn
// 开启所有 bizName的 warn 和 error
// 比如__logConf__=log:designer:pluginManager
logger.log('log'); // 输出 https://lowcode-engine.cn/demo/demo-general/index.html?__logConf__=debug
logger.warn('warn'); // 输出 // 开启所有 bizName的 debug, log, info, warn 和 error
logger.error('error'); // 输出
https://lowcode-engine.cn/demo/demo-general/index.html?__logConf__=log
// 开启所有 bizName的 log, info, warn 和 error
https://lowcode-engine.cn/demo/demo-general/index.html?__logConf__=warn|*
// 同 __logConf__=warn
https://lowcode-engine.cn/demo/demo-general/index.html?__logConf__=warn|bizName
// 开启 bizName 的 debug, log, info, warn 和 error
https://lowcode-engine.cn/demo/demo-general/index.html?__logConf__=warn|partOfBizName
// 开启 bizName like '%partOfBizName%' 的 debug, log, info, warn 和 error
``` ```

View File

@ -2,24 +2,44 @@
title: material - 物料 API title: material - 物料 API
sidebar_position: 2 sidebar_position: 2
--- ---
# 模块简介
> **@types** [IPublicApiMaterial](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/material.ts)<br/>
> **@since** v1.0.0
## 模块简介
负责物料相关的 API包括资产包、设计器辅助层、物料元数据和物料元数据管道函数。 负责物料相关的 API包括资产包、设计器辅助层、物料元数据和物料元数据管道函数。
# 变量variables ## 变量
## componentsMap ### componentsMap
获取组件 map 结构 获取组件 map 结构
```typescript
/**
* 获取组件 map 结构
* get map of components
*/
get componentsMap(): { [key: string]: IPublicTypeNpmInfo | ComponentType<any> | object } ;
```
相关类型:[IPublicTypeNpmInfo](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/npm-info.ts)
# 方法签名functions ## 方法签名
## 资产包
### setAssets ### 资产包
#### setAssets
设置「[资产包](/site/docs/specs/lowcode-spec#2-协议结构)」结构 设置「[资产包](/site/docs/specs/lowcode-spec#2-协议结构)」结构
**类型定义**
```typescript ```typescript
function setAssets(assets: AssetsJson): void; /**
* 设置「资产包」结构
* set data for Assets
* @returns void
*/
setAssets(assets: IPublicTypeAssetsJson): void;
``` ```
相关类型:[IPublicTypeAssetsJson](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/assets-json.ts)
**示例**
##### 示例
直接在项目中引用 npm 包 直接在项目中引用 npm 包
```javascript ```javascript
import { material } from '@alilc/lowcode-engine'; import { material } from '@alilc/lowcode-engine';
@ -28,7 +48,7 @@ import assets from '@alilc/mc-assets-<siteId>/assets.json';
material.setAssets(assets); material.setAssets(assets);
``` ```
通过物料中心接口动态引入资产包 通过接口动态引入资产包
```typescript ```typescript
import { material, plugins } from '@alilc/lowcode-engine'; import { material, plugins } from '@alilc/lowcode-engine';
import { IPublicModelPluginContext } from '@alilc/lowcode-types'; import { IPublicModelPluginContext } from '@alilc/lowcode-types';
@ -39,43 +59,54 @@ plugins.register((ctx: IPublicModelPluginContext) => {
name: 'ext-assets', name: 'ext-assets',
async init() { async init() {
try { try {
// 将下述链接替换为您的物料即可。无论是通过 utils 从物料中心引入,还是通过其他途径如直接引入物料描述 // 将下述链接替换为您的物料描述地址即可。
const res = await window.fetch('https://fusion.alicdn.com/assets/default@0.1.95/assets.json') const res = await window.fetch('https://fusion.alicdn.com/assets/default@0.1.95/assets.json');
const assets = await res.text() const assets = await res.text();
material.setAssets(assets) material.setAssets(assets);
} catch (err) { } catch (err) {
console.error(err) console.error(err);
} };
}, },
} };
}).catch(err => console.error(err)) }).catch(err => console.error(err));
``` ```
### getAssets #### getAssets
获取「资产包」结构 获取「资产包」结构
**类型定义**
```typescript ```typescript
function getAssets(): AssetsJson; /**
* 获取「资产包」结构
* get AssetsJson data
* @returns IPublicTypeAssetsJson
*/
getAssets(): IPublicTypeAssetsJson;
``` ```
相关类型:[IPublicTypeAssetsJson](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/assets-json.ts)
**示例** ##### 示例
```typescript ```typescript
import { material } from '@alilc/lowcode-engine'; import { material } from '@alilc/lowcode-engine';
material.getAssets(); material.getAssets();
``` ```
### loadIncrementalAssets #### loadIncrementalAssets
加载增量的「资产包」结构,该增量包会与原有的合并 加载增量的「资产包」结构,该增量包会与原有的合并
**类型定义**
```typescript ```typescript
function loadIncrementalAssets(incrementalAssets: AssetsJson): void; /**
* 加载增量的「资产包」结构,该增量包会与原有的合并
* load Assets incrementally, and will merge this with exiting assets
* @param incrementalAssets
* @returns
*/
loadIncrementalAssets(incrementalAssets: IPublicTypeAssetsJson): void;
``` ```
说明:**该增量包会与原有的合并** 相关类型:[IPublicTypeAssetsJson](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/assets-json.ts)
**示例** ##### 示例
```typescript ```typescript
import { material } from '@alilc/lowcode-engine'; import { material } from '@alilc/lowcode-engine';
import assets1 from '@alilc/mc-assets-<siteId>/assets.json'; import assets1 from '@alilc/mc-assets-<siteId>/assets.json';
@ -84,57 +115,23 @@ import assets2 from '@alilc/mc-assets-<siteId>/assets.json';
material.setAssets(assets1); material.setAssets(assets1);
material.loadIncrementalAssets(assets2); material.loadIncrementalAssets(assets2);
``` ```
## 设计器辅助层
### addBuiltinComponentAction ### 设计器辅助层
#### addBuiltinComponentAction
在设计器辅助层增加一个扩展 action 在设计器辅助层增加一个扩展 action
**类型定义**
```typescript ```typescript
function addBuiltinComponentAction(action: IPublicTypeComponentAction): void; /**
* 在设计器辅助层增加一个扩展 action
export interface IPublicTypeComponentAction { * add an action button in canvas context menu area
/** * @param action
* behaviorName */
*/ addBuiltinComponentAction(action: IPublicTypeComponentAction): void;
name: string;
/**
* 菜单名称
*/
content: string | ReactNode | ActionContentObject;
/**
* 子集
*/
items?: IPublicTypeComponentAction[];
/**
* 显示与否
* always: 无法禁用
*/
condition?: boolean | ((currentNode: any) => boolean) | 'always';
/**
* 显示在工具条上
*/
important?: boolean;
}
export interface ActionContentObject {
/**
* 图标
*/
icon?: IconType;
/**
* 描述
*/
title?: TipContent;
/**
* 执行动作
*/
action?: (currentNode: any) => void;
}
export type IconType = string | ReactElement | ComponentType<any> | IconConfig;
``` ```
相关类型:[IPublicTypeComponentAction](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/component-action.ts)
**示例** ##### 示例
新增设计扩展位,并绑定事件 新增设计扩展位,并绑定事件
```typescript ```typescript
import { material } from '@alilc/lowcode-engine'; import { material } from '@alilc/lowcode-engine';
@ -154,14 +151,27 @@ material.addBuiltinComponentAction({
``` ```
![image.png](https://img.alicdn.com/imgextra/i4/O1CN01jDbN7B1KfWVzJ16tw_!!6000000001191-2-tps-230-198.png) ![image.png](https://img.alicdn.com/imgextra/i4/O1CN01jDbN7B1KfWVzJ16tw_!!6000000001191-2-tps-230-198.png)
### removeBuiltinComponentAction #### removeBuiltinComponentAction
移除设计器辅助层的指定 action 移除设计器辅助层的指定 action
**类型定义**
```typescript ```typescript
function removeBuiltinComponentAction(name: string): void; /**
* 移除设计器辅助层的指定 action
* remove a builtin action button from canvas context menu area
* @param name
*/
removeBuiltinComponentAction(name: string): void;
``` ```
**示例** ##### 内置设计器辅助 name
- remove删除
- hide隐藏
- copy复制
- lock锁定不可编辑
- unlock解锁可编辑
##### 示例
```typescript ```typescript
import { material } from '@alilc/lowcode-engine'; import { material } from '@alilc/lowcode-engine';
@ -169,16 +179,25 @@ material.removeBuiltinComponentAction('myIconName');
``` ```
### modifyBuiltinComponentAction #### modifyBuiltinComponentAction
修改已有的设计器辅助层的指定 action 修改已有的设计器辅助层的指定 action
**类型定义**
```typescript ```typescript
function modifyBuiltinComponentAction( /**
actionName: string, * 修改已有的设计器辅助层的指定 action
handle: (action: IPublicTypeComponentAction) => void * modify a builtin action button in canvas context menu area
): void; * @param actionName
* @param handle
*/
modifyBuiltinComponentAction(
actionName: string,
handle: (action: IPublicTypeComponentAction) => void,
): void;
``` ```
**内置设计器辅助 name** 相关类型:[IPublicTypeComponentAction](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/component-action.ts)
##### 内置设计器辅助 name
- remove删除 - remove删除
- hide隐藏 - hide隐藏
@ -188,7 +207,7 @@ function modifyBuiltinComponentAction(
**示例** ##### 示例
给原始的 remove 扩展时间添加执行前后的日志 给原始的 remove 扩展时间添加执行前后的日志
```typescript ```typescript
import { material } from '@alilc/lowcode-engine'; import { material } from '@alilc/lowcode-engine';
@ -202,30 +221,43 @@ material.modifyBuiltinComponentAction('remove', (action) => {
} }
}); });
``` ```
###
## 物料元数据
### getComponentMeta
获取指定名称的物料元数据
**类型定义**
```typescript
function getComponentMeta(componentName: string): ComponentMeta;
```
**示例** ### 物料元数据
#### getComponentMeta
获取指定名称的物料元数据
```typescript
/**
* 获取指定名称的物料元数据
* get component meta by component name
* @param componentName
* @returns
*/
getComponentMeta(componentName: string): IPublicModelComponentMeta | null;
```
相关类型:[IPublicModelComponentMeta](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/component-meta.ts)
##### 示例
```typescript ```typescript
import { material } from '@alilc/lowcode-engine'; import { material } from '@alilc/lowcode-engine';
material.getComponentMeta('Input'); material.getComponentMeta('Input');
``` ```
### getComponentMetasMap #### getComponentMetasMap
获取所有已注册的物料元数据 获取所有已注册的物料元数据
**类型定义**
```typescript
function getComponentMetasMap(): new Map<string, ComponentMeta>;
```
**示例** ```typescript
/**
* 获取所有已注册的物料元数据
* get map of all component metas
* @returns
*/
getComponentMetasMap(): Map<string, IPublicModelComponentMeta>;
```
相关类型:[IPublicModelComponentMeta](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/component-meta.ts)
##### 示例
```typescript ```typescript
import { material } from '@alilc/lowcode-engine'; import { material } from '@alilc/lowcode-engine';
@ -233,19 +265,27 @@ material.getComponentMetasMap();
``` ```
## 物料元数据管道函数 ### 物料元数据管道函数
### registerMetadataTransducer #### registerMetadataTransducer
注册物料元数据管道函数,在物料信息初始化时执行。 注册物料元数据管道函数,在物料信息初始化时执行。
**类型定义**
```typescript ```typescript
function registerMetadataTransducer( /**
transducer: MetadataTransducer, // 管道函数 * 注册物料元数据管道函数,在物料信息初始化时执行。
level?: number, // 优先级 * register transducer to process component meta, which will be
id?: string | undefined, // id * excuted during component meta`s initialization
* @param transducer
* @param level
* @param id
*/
registerMetadataTransducer(
transducer: IPublicTypeMetadataTransducer,
level?: number,
id?: string | undefined
): void; ): void;
``` ```
**示例** ##### 示例
给每一个组件的配置添加高级配置面板,其中有一个是否渲染配置项 给每一个组件的配置添加高级配置面板,其中有一个是否渲染配置项
```typescript ```typescript
import { material } from '@alilc/lowcode-engine' import { material } from '@alilc/lowcode-engine'
@ -290,28 +330,37 @@ function addonCombine(metadata: TransformedComponentMetadata) {
material.registerMetadataTransducer(addonCombine, 1, 'parse-func'); material.registerMetadataTransducer(addonCombine, 1, 'parse-func');
``` ```
### getRegisteredMetadataTransducers #### getRegisteredMetadataTransducers
获取所有物料元数据管道函数 获取所有物料元数据管道函数
**类型定义**
```typescript ```typescript
function getRegisteredMetadataTransducers(): IPublicTypeMetadataTransducer[]; /**
* 获取所有物料元数据管道函数
* get all registered metadata transducers
* @returns {IPublicTypeMetadataTransducer[]}
*/
getRegisteredMetadataTransducers(): IPublicTypeMetadataTransducer[];
``` ```
**示例** ##### 示例
```typescript ```typescript
import { material } from '@alilc/lowcode-engine' import { material } from '@alilc/lowcode-engine'
material.getRegisteredMetadataTransducers('parse-func'); material.getRegisteredMetadataTransducers();
``` ```
## ## 事件
# 事件Event
### onChangeAssets ### onChangeAssets
监听 assets 变化的事件 监听 assets 变化的事件
**类型定义**
```typescript ```typescript
function onChangeAssets(fn: () => void): void; /**
* 监听 assets 变化的事件
* add callback for assets changed event
* @param fn
*/
onChangeAssets(fn: () => void): void;
``` ```
**示例** ##### 示例
```typescript ```typescript
import { material } from '@alilc/lowcode-engine'; import { material } from '@alilc/lowcode-engine';

View File

@ -0,0 +1,6 @@
{
"label": "模型定义 Models",
"position": 14,
"collapsed": false,
"collapsible": true
}

View File

@ -0,0 +1,47 @@
---
title: Detecting
sidebar_position: 6
---
> **@types** [IPublicModelDetecting](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/detecting.ts)<br/>
> **@since** v1.0.0
## 基本介绍
画布节点悬停模型
## 方法签名
### capture
capture(id: string)
hover 指定节点
### release
release(id: string)
hover 离开指定节点
### leave
leave()
清空 hover 态
### current
当前 hover 的节点
**@since v1.0.16**
### onDetectingChange
hover 节点变化事件
```typescript
/**
* hover 节点变化事件
* set callback which will be called when hovering object changed.
* @since v1.1.0
*/
onDetectingChange(fn: (node: IPublicModelNode) => void): () => void;
```
**@since v1.1.0**

View File

@ -0,0 +1,150 @@
---
title: DocumentModel
sidebar_position: 0
---
> **@types** [IPublicModelDocumentModel](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/document-model.ts)<br/>
> **@since** v1.0.0
## 基本介绍
文档模型
## 变量
### selection
画布节点选中区模型实例,具体方法参见 [画布节点选中区模型](./selection)
### detecting
画布节点 hover 区模型实例,具体方法参见 [画布节点悬停模型](./detecting)
### history
操作历史模型实例,具体方法参见 [操作历史模型](./history)
### canvas
获取当前画布中的一些信息,比如拖拽时的 dropLocation
### project
获取当前文档模型所属的 project
### root
获取文档的根节点
### nodesMap
获取文档下所有节点
### modalNodesManager
参见 [模态节点管理](./modal-nodes-manager)
## 方法签名
### getNodeById
getNodeById(nodeId: string)
根据 nodeId 返回 [Node](./node) 实例
### importSchema
importSchema(schema: RootSchema)
导入 schema
### exportSchema
exportSchema(stage: TransformStage = TransformStage.Render)
导出 schema
### insertNode
insertNode(
parent: Node,
thing: Node,
at?: number | null | undefined,
copy?: boolean | undefined,
)
插入节点
### createNode
createNode(data: any)
创建一个节点
### removeNode
removeNode(idOrNode: string | Node)
移除指定节点/节点id
### checkNesting
检查拖拽放置的目标节点是否可以放置该拖拽对象
**@since v1.0.16**
```typescript
function checkNesting(dropTarget: Node, dragObject: DragNodeObject | DragNodeDataObject): boolean {}
```
## 事件
### onAddNode
onAddNode(fn: (node: Node) => void)
当前 document 新增节点事件
```typescript
import { project } from '@alilc/lowcode-engine';
project.currentDocument.onAddNode((node) => {
console.log('node', node);
})
```
### onRemoveNode
onRemoveNode(fn: (node: Node) => void)
当前 document 删除节点事件
### onChangeDetecting
onChangeDetecting(fn: (node: Node) => void)
当前 document 的 hover 变更事件
### onChangeSelection
onChangeSelection(fn: (ids: string[]) => void)
当前 document 的选中变更事件
### onChangeNodeVisible
onChangeNodeVisible(fn: (node: Node, visible: boolean) => void)
当前 document 的节点显隐状态变更事件
### onChangeNodeChildren
onChangeNodeChildren(fn: (info?: IPublicOnChangeOptions) => void)
当前 document 的节点 children 变更事件
### onChangeNodeProp
当前 document 节点属性修改事件
```typescript
onChangeNodeProp(fn: (info: IPublicTypePropChangeOptions) => void)
```
### onImportSchema
当前 document 导入新的 schema 事件
版本 >= 1.0.15
```typescript
onImportSchema(fn: (schema: any) => void)
```

View File

@ -0,0 +1,129 @@
---
title: Dragon
sidebar_position: 99
---
> **@types** [IPublicModelDragon](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/dragon.ts)<br/>
> **@since** v1.0.0
## 基本介绍
拖拽对象
### 对应接口
```typescript
import { IPublicModelDragon } from '@alilc/lowcode-types';
```
### 支持版本
**@since** v1.1.0
## 变量
### dragging
是否正在拖动
```typescript
/**
* is dragging or not
*/
get dragging(): boolean;
```
## 方法签名
### onDragstart
绑定 dragstart 事件
```typescript
/**
* 绑定 dragstart 事件
* bind a callback function which will be called on dragging start
* @param func
* @returns
*/
onDragstart(func: (e: IPublicModelLocateEvent) => any): () => void;
```
### onDrag
绑定 drag 事件
```typescript
/**
* 绑定 drag 事件
* bind a callback function which will be called on dragging
* @param func
* @returns
*/
onDrag(func: (e: IPublicModelLocateEvent) => any): () => void;
```
### onDragend
绑定 dragend 事件
```typescript
/**
* 绑定 dragend 事件
* bind a callback function which will be called on dragging end
* @param func
* @returns
*/
onDragend(func: (o: { dragObject: IPublicModelDragObject; copy?: boolean }) => any): () => void;
```
### from
设置拖拽监听的区域 shell以及自定义拖拽转换函数 boost
```typescript
/**
* 设置拖拽监听的区域 shell以及自定义拖拽转换函数 boost
* set a html element as shell to dragon as monitoring target, and
* set boost function which is used to transform a MouseEvent to type
* IPublicTypeDragNodeDataObject.
* @param shell 拖拽监听的区域
* @param boost 拖拽转换函数
*/
from(shell: Element, boost: (e: MouseEvent) => IPublicTypeDragNodeDataObject | null): any;
```
### boost
发射拖拽对象
```typescript
/**
* 发射拖拽对象
* boost your dragObject for dragging(flying)
*
* @param dragObject 拖拽对象
* @param boostEvent 拖拽初始时事件
*/
boost(dragObject: IPublicTypeDragObject, boostEvent: MouseEvent | DragEvent, fromRglNode?: Node | IPublicModelNode): void;
```
### addSensor
添加投放感应区
```typescript
/**
* 添加投放感应区
* add sensor area
*/
addSensor(sensor: any): void;
```
### removeSensor
移除投放感应
```typescript
/**
* 移除投放感应
* remove sensor area
*/
removeSensor(sensor: any): void;
```

View File

@ -0,0 +1,58 @@
---
title: History
sidebar_position: 5
---
> **@types** [IPublicModelHistory](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/history.ts)<br/>
> **@since** v1.0.0
## 基本介绍
操作历史记录模型
## 方法签名
### go
go(cursor: number)
历史记录跳转到指定位置
### back
back()
历史记录后退
### forward
forward()
历史记录前进
### savePoint
savePoint()
保存当前状态
### isSavePoint
isSavePoint()
当前是否是「保存点」,即是否有状态变更但未保存
### getState
getState()
获取 state判断当前是否为「可回退」、「可前进」的状态
## 事件
### onChangeState
onChangeState(func: () => any)
监听 state 变更事件
### onChangeCursor
onChangeCursor(func: () => any)
监听历史记录游标位置变更事件

View File

@ -0,0 +1,48 @@
---
title: ModalNodesManager
sidebar_position: 7
---
> **@types** [IPublicModelModalNodesManager](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/modal-nodes-manager.ts)<br/>
> **@since** v1.0.0
## 基本介绍
模态节点管理器模型
## 方法签名
### setNodes
setNodes()
设置模态节点,触发内部事件
### getModalNodes
getModalNodes()
获取模态节点(们)
### getVisibleModalNode
getVisibleModalNode()
获取当前可见的模态节点
### hideModalNodes
hideModalNodes()
隐藏模态节点(们)
### setVisible
setVisible(node: Node)
设置指定节点为可见态
### setInvisible
setInvisible(node: Node)
设置指定节点为不可见态

View File

@ -0,0 +1,123 @@
---
title: NodeChildren
sidebar_position: 2
---
> **@types** [IPublicModelNodeChildren](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node-children.ts)<br/>
> **@since** v1.0.0
## 基本介绍
节点孩子模型
## 变量
### owner
返回当前 children 实例所属的节点实例
### size
children 内的节点实例数
### isEmpty
是否为空
## 方法签名
### delete
delete(node: Node)
删除指定节点
### insert
insert(node: Node, at?: number | null)
插入一个节点
### indexOf
indexOf(node: Node)
返回指定节点的下标
### splice
splice(start: number, deleteCount: number, node?: Node)
类似数组 splice 操作
### get
get(index: number)
返回指定下标的节点
### has
has(node: Node)
是否包含指定节点
### forEach
forEach(fn: (node: Node, index: number) => void)
类似数组的 forEach
### map
map<T\>(fn: (node: Node, index: number) => T[])
类似数组的 map
### every
every(fn: (node: Node, index: number) => boolean)
类似数组的 every
### some
some(fn: (node: Node, index: number) => boolean)
类似数组的 some
### filter
filter(fn: (node: Node, index: number) => boolean)
类似数组的 filter
### find
find(fn: (node: Node, index: number) => boolean)
类似数组的 find
### reduce
reduce(fn: (acc: any, cur: Node) => any, initialValue: any)
类似数组的 reduce
### importSchema
importSchema(data?: NodeData | NodeData[])
导入 schema
### exportSchema
exportSchema(stage: IPulicEnumTransformStage = IPulicEnumTransformStage.Render)
导出 schema
### mergeChildren
mergeChildren(
remover: (node: Node, idx: number) => boolean,
adder: (children: Node[]) => any,
sorter: (firstNode: Node, secondNode: Node) => number,
)
执行新增、删除、排序等操作

250
docs/docs/api/model/node.md Normal file
View File

@ -0,0 +1,250 @@
---
title: Node
sidebar_position: 1
---
> **@types** [IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)<br/>
> **@since** v1.0.0
## 基本介绍
节点模型
## 变量
### id
节点 id
### title
节点标题
### isContainer
是否为「容器型」节点
### isRoot
是否为根节点
### isEmpty
是否为空节点(无 children 或者 children 为空)
### isPage
是否为 Page 节点
### isComponent
是否为 Component 节点
### isModal
是否为「模态框」节点
### isSlot
是否为插槽节点
### isParental
是否为父类/分支节点
### isLeaf
是否为叶子节点
### isLocked
获取当前节点的锁定状态
**@since v1.0.16**
### isRGLContainer
设置为磁贴布局节点,使用方式可参考:[磁贴布局在钉钉宜搭报表设计引擎中的实现](https://mp.weixin.qq.com/s/PSTut5ahAB8nlJ9kBpBaxw)
**@since v1.0.16**
### index
下标
### icon
图标
### zLevel
节点所在树的层级深度,根节点深度为 0
### componentName
节点 componentName
### componentMeta
节点的物料元数据,参见 物料元数据
### document
获取节点所属的[文档模型](./document-model)对象
### prevSibling
获取当前节点的前一个兄弟节点
### nextSibling
获取当前节点的后一个兄弟节点
### parent
获取当前节点的父亲节点
### children
获取当前节点的孩子节点模型
### slots
节点上挂载的插槽节点们
### slotFor
当前节点为插槽节点时,返回节点对应的属性实例
### props
返回节点的属性集
### propsData
返回节点的属性集值
## 方法签名
### getDOMNode
getDOMNode()
获取节点实例对应的 dom 节点
### getRect
getRect()
返回节点的尺寸、位置信息
### hasSlots
hasSlots()
是否有挂载插槽节点
### hasCondition
hasCondition()
是否设定了渲染条件
### hasLoop
hasLoop()
是否设定了循环数据
### getProp
getProp(path: string): Prop | null
获取指定 path 的属性模型实例
### getPropValue
getPropValue(path: string)
获取指定 path 的属性模型实例值
### getExtraProp
getExtraProp(path: string): Prop | null
获取指定 path 的属性模型实例,注:导出时,不同于普通属性,该属性并不挂载在 props 之下,而是与 props 同级
### getExtraPropValue
getExtraPropValue(path: string)
获取指定 path 的属性模型实例,注:导出时,不同于普通属性,该属性并不挂载在 props 之下,而是与 props 同级
### setPropValue
setPropValue(path: string, value: CompositeValue)
设置指定 path 的属性模型实例值
### setExtraPropValue
setExtraPropValue(path: string, value: CompositeValue)
设置指定 path 的属性模型实例值
### importSchema
importSchema(data: NodeSchema)
导入节点数据
### exportSchema
exportSchema(stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Render, options?: any)
导出节点数据
### insertBefore
insertBefore(node: Node, ref?: Node | undefined, useMutator?: boolean)
在指定位置之前插入一个节点
### insertAfter
insertAfter(node: Node, ref?: Node | undefined, useMutator?: boolean)
在指定位置之后插入一个节点
### replaceChild
replaceChild(node: Node, data: any)
替换指定节点
### replaceWith
replaceWith(schema: NodeSchema)
将当前节点替换成指定节点描述
### select
select()
选中当前节点实例
### hover
hover(flag = true)
设置悬停态
### lock
设置节点锁定状态
```typescript
function lock(flag?: boolean){}
```
**@since v1.0.16**
### remove
remove()
删除当前节点实例

View File

@ -0,0 +1,53 @@
---
title: Prop
sidebar_position: 3
---
> **@types** [IPublicModelProp](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/prop.ts)<br/>
> **@since** v1.0.0
## 基本介绍
属性模型
## 变量
### id
id
### key
key 值
### path
返回当前 prop 的路径
### node
返回所属的节点实例
## 方法签名
### setValue
setValue(val: CompositeValue)
设置值
### getValue
getValue()
获取值
### remove
移除值
**@since v1.0.16**
### exportSchema
exportSchema(stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Render)
导出值

View File

@ -0,0 +1,58 @@
---
title: Props
sidebar_position: 4
---
> **@types** [IPublicModelProps](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/props.ts)<br/>
> **@since** v1.0.0
## 基本介绍
属性集模型
## 变量
### id
id
### path
返回当前 props 的路径
### node
返回当前属性集所属的节点实例
## 方法签名
### getProp
getProp(path: string): Prop | null
获取指定 path 的属性模型实例
### getPropValue
getPropValue(path: string)
获取指定 path 的属性模型实例值
### getExtraProp
getExtraProp(path: string): Prop | null
获取指定 path 的属性模型实例,注:导出时,不同于普通属性,该属性并不挂载在 props 之下,而是与 props 同级
### getExtraPropValue
getExtraPropValue(path: string)
获取指定 path 的属性模型实例值,注:导出时,不同于普通属性,该属性并不挂载在 props 之下,而是与 props 同级
### setPropValue
setPropValue(path: string, value: CompositeValue)
设置指定 path 的属性模型实例值
### setExtraPropValue
setExtraPropValue(path: string, value: CompositeValue)
设置指定 path 的属性模型实例值

View File

@ -0,0 +1,85 @@
---
title: Selection
sidebar_position: 6
---
> **@types** [IPublicModelSelection](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/selection.ts)<br/>
> **@since** v1.0.0
## 基本介绍
画布节点选中模型
## 变量
### selected
返回选中的节点 id
## 方法签名
### select
select(id: string)
选中指定节点(覆盖方式)
### selectAll
selectAll(ids: string[])
批量选中指定节点们
### remove
remove(id: string)
**取消选中**选中的指定节点,不会删除组件
### clear
clear()
**取消选中**所有选中节点,不会删除组件
### has
has(id: string)
判断是否选中了指定节点
### add
add(id: string)
选中指定节点(增量方式)
### getNodes
getNodes()
获取选中的节点实例
### getTopNodes
获取选区的顶层节点
例如选中的节点为:
- DivA
- ChildrenA
- DivB
getNodes 返回的是 [DivA、ChildrenA、DivB]getTopNodes 返回的是 [DivA、DivB],其中 ChildrenA 由于是二层节点getTopNodes 不会返回
**@since v1.0.16**
### onSelectionChange
注册 selection 变化事件回调
```typescript
/**
* 注册 selection 变化事件回调
* set callback which will be called when selection is changed
* @since v1.1.0
*/
onSelectionChange(fn: (ids: string[]) => void): () => void;
```
**@since v1.1.0**

View File

@ -2,25 +2,27 @@
title: plugins - 插件 API title: plugins - 插件 API
sidebar_position: 4 sidebar_position: 4
--- ---
> **@types** [IPublicApiPlugins](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/plugins.ts)<br/>
> **@since** v1.0.0
## 模块简介 ## 模块简介
插件管理器,提供编排模块中管理插件的能力。 插件管理器,提供编排模块中管理插件的能力。
## 变量variables
## 方法签名
## 方法签名functions
### register ### register
注册插件 注册插件
#### 类型定义
```typescript ```typescript
async function register( async function register(
pluginConfigCreator: (ctx: IPublicModelPluginContext) => IPublicTypePluginConfig, plugin: IPublicTypePlugin,
options?: ILowCodeRegisterOptions, options?: IPublicTypePluginRegisterOptions,
): Promise<void> ): Promise<void>
``` ```
pluginConfigCreator 是一个 IPublicTypePluginConfig 生成函数IPublicTypePluginConfig 中包含了该插件的 init / destroy 等钩子函数,以及 exports 函数用于返回插件对外暴露的值。 相关 types:
- [IPublicTypePlugin](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/plugin.ts)
- [IPublicTypePluginRegisterOptions](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/plugin-register-options.ts)
另外pluginConfigCreator 还必须挂载 pluginName 字段,全局确保唯一,否则 register 时会报错,可以选择性挂载 meta 字段,用于描述插件的元数据信息,比如兼容的引擎版本、支持的参数配置、依赖插件声明等。 其中第一个参数 plugin 通过低代码工具链的插件脚手架生成编写模板,开发者可以参考[这个章节](/site/docs/guide/expand/editor/cli)进行创建
> 注pluginConfigCreator 挂载 pluginName / meta 可以通过低代码工具链的插件脚手架生成,写如 package.json 后将会自动注入到代码中,具体见 [插件元数据工程化示例](#RO9YY)
#### 简单示例 #### 简单示例
@ -61,59 +63,59 @@ await plugins.register(builtinPluginRegistry);
import { plugins } from '@alilc/lowcode-engine'; import { plugins } from '@alilc/lowcode-engine';
import { IPublicModelPluginContext } from '@alilc/lowcode-types'; import { IPublicModelPluginContext } from '@alilc/lowcode-types';
const pluginA = (ctx: IPublicModelPluginContext) => { const PluginA = (ctx: IPublicModelPluginContext) => {
return { return {
async init() {}, async init() {},
exports() { return { x: 1, } }, exports() { return { x: 1, } },
}; };
} }
pluginA.pluginName = 'pluginA'; PluginA.pluginName = 'PluginA';
const pluginB = (ctx: IPublicModelPluginContext) => { const PluginB = (ctx: IPublicModelPluginContext) => {
return { return {
async init() { async init() {
// 获取 pluginA 的导出值 // 获取 pluginA 的导出值
console.log(ctx.plugins.pluginA.x); // => 1 console.log(ctx.plugins.PluginA.x); // => 1
}, },
}; };
} }
pluginA.pluginName = 'pluginA'; PluginA.pluginName = 'pluginA';
pluginB.pluginName = 'pluginB'; PluginB.pluginName = 'PluginB';
pluginB.meta = { PluginB.meta = {
dependencies: ['pluginA'], dependencies: ['PluginA'],
} }
await plugins.register(pluginA); await plugins.register(PluginA);
await plugins.register(pluginB); await plugins.register(PluginB);
``` ```
> 注ctx 是在插件 creator 中获取引擎 API 的上下文,具体定义参见 [IPublicModelPluginContext](#qEhTb) > 注ctx 是在插件中获取引擎 API 的唯一渠道,具体定义参见 [IPublicModelPluginContext](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/plugin-context.ts)
####
#### 设置兼容引擎版本示例 #### 设置兼容引擎版本示例
```typescript ```typescript
import { plugins } from '@alilc/lowcode-engine'; import { plugins } from '@alilc/lowcode-engine';
import { IPublicModelPluginContext } from '@alilc/lowcode-types'; import { IPublicModelPluginContext } from '@alilc/lowcode-types';
const builtinPluginRegistry = (ctx: IPublicModelPluginContext) => { const BuiltinPluginRegistry = (ctx: IPublicModelPluginContext) => {
return { return {
async init() { async init() {
... ...
}, },
}; };
} }
builtinPluginRegistry.pluginName = 'builtinPluginRegistry'; BuiltinPluginRegistry.pluginName = 'BuiltinPluginRegistry';
builtinPluginRegistry.meta = { BuiltinPluginRegistry.meta = {
engines: { engines: {
lowcodeEngine: '^1.0.0', // 插件需要配合 ^1.0.0 的引擎才可运行 lowcodeEngine: '^1.0.0', // 插件需要配合 ^1.0.0 的引擎才可运行
}, },
} }
await plugins.register(builtinPluginRegistry); await plugins.register(BuiltinPluginRegistry);
``` ```
#### 设置插件参数版本示例 #### 设置插件参数版本示例
```typescript ```typescript
import { plugins } from '@alilc/lowcode-engine'; import { plugins } from '@alilc/lowcode-engine';
import { IPublicModelPluginContext } from '@alilc/lowcode-types'; import { IPublicModelPluginContext } from '@alilc/lowcode-types';
const builtinPluginRegistry = (ctx: IPublicModelPluginContext, options: any) => { const BuiltinPluginRegistry = (ctx: IPublicModelPluginContext, options: any) => {
return { return {
async init() { async init() {
// 1.0.4 之后的传值方式,通过 register(xxx, options) // 1.0.4 之后的传值方式,通过 register(xxx, options)
@ -124,8 +126,8 @@ const builtinPluginRegistry = (ctx: IPublicModelPluginContext, options: any) =>
}, },
}; };
} }
builtinPluginRegistry.pluginName = 'builtinPluginRegistry'; BuiltinPluginRegistry.pluginName = 'BuiltinPluginRegistry';
builtinPluginRegistry.meta = { BuiltinPluginRegistry.meta = {
preferenceDeclaration: { preferenceDeclaration: {
title: 'pluginA 的参数定义', title: 'pluginA 的参数定义',
properties: [ properties: [
@ -154,101 +156,14 @@ builtinPluginRegistry.meta = {
} }
// 从 1.0.4 开始,支持直接在 pluginCreator 的第二个参数 options 获取入参 // 从 1.0.4 开始,支持直接在 pluginCreator 的第二个参数 options 获取入参
await plugins.register(builtinPluginRegistry, { key1: 'abc', key5: 'willNotPassToPlugin' }); await plugins.register(BuiltinPluginRegistry, { key1: 'abc', key5: 'willNotPassToPlugin' });
// 1.0.4 之前,通过 preference 来传递 / 获取值
const preference = new Map();
preference.set('builtinPluginRegistry', {
key1: 'abc',
key5: 'willNotPassToPlugin', // 因为 key5 不在插件声明可接受的参数里
});
init(document.getElementById('lce'), engineOptions, preference);
``` ```
### get ## 相关类型定义
获取插件实例
**类型定义** - [IPublicModelPluginContext](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/plugin-context.ts)
```typescript - [IPublicTypePluginConfig](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/plugin-config.ts)
function get(pluginName: string): ILowCodePlugin | undefined
```
**调用示例**
```typescript
import { plugins } from '@alilc/lowcode-engine';
plugins.get(builtinPluginRegistry);
```
###
### getAll
获取所有插件实例
**类型定义**
```typescript
function getAll(): ILowCodePlugin[]
```
**调用示例**
```typescript
import { plugins } from '@alilc/lowcode-engine';
plugins.getAll();
```
###
### has
判断是否已经加载了指定插件
**类型定义**
```typescript
function has(pluginName: string): boolean
```
**调用示例**
```typescript
import { plugins } from '@alilc/lowcode-engine';
plugins.has('builtinPluginRegistry');
```
### delete
删除指定插件
**类型定义**
```typescript
async function delete(pluginName: string): Promise<boolean>
```
**调用示例**
```typescript
import { plugins } from '@alilc/lowcode-engine';
plugins.delete('builtinPluginRegistry');
```
##
## 事件events
## 相关模块
### IPublicModelPluginContext
**类型定义**
```typescript
export interface IPublicModelPluginContext {
get skeleton(): IPublicApiSkeleton;
get hotkey(): IPublicApiHotkey;
get setters(): IPublicApiSetters;
get config(): IEngineConfig;
get material(): IPublicApiMaterial;
get event(): IPublicApiEvent;
get project(): IPublicApiProject;
get common(): IPublicApiCommon;
logger: IPublicApiLogger;
plugins: IPublicApiPlugins;
preference: IPluginPreferenceMananger;
}
```
### IPublicTypePluginConfig
**类型定义**
```typescript
export interface IPublicTypePluginConfig {
init?(): void;
destroy?(): void;
exports?(): any;
}
```
## 插件元数据工程转化示例 ## 插件元数据工程转化示例
your-plugin/package.json your-plugin/package.json
```json ```json
@ -279,8 +194,3 @@ debug.meta = {
preferenceDeclaration: { ... } preferenceDeclaration: { ... }
}; };
``` ```
###
## 使用示例
更多示例参考:[https://github.com/alibaba/lowcode-demo/blob/058450edb584d92be6cb665b1f3a9646ba464ffa/src/universal/plugin.tsx#L36](https://github.com/alibaba/lowcode-demo/blob/058450edb584d92be6cb665b1f3a9646ba464ffa/src/universal/plugin.tsx#L36)

File diff suppressed because it is too large Load Diff

View File

@ -2,37 +2,64 @@
title: setters - 设置器 API title: setters - 设置器 API
sidebar_position: 6 sidebar_position: 6
--- ---
> **@types** [IPublicApiSetters](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/setters.ts)<br/>
> **@since** v1.0.0
## 模块简介 ## 模块简介
负责注册设置器、管理设置器的 API。注册自定义设置器之后可以在物料中进行使用。 负责注册设置器、管理设置器的 API。注册自定义设置器之后可以在物料中进行使用。
## 方法签名functions ## 方法签名
### getSetter ### getSetter
获取指定 setter 获取指定 setter
**类型定义**
```typescript ```typescript
function getSetter(type: string): RegisteredSetter; /**
* 获取指定 setter
* get setter by type
* @param type
* @returns
*/
getSetter(type: string): IPublicTypeRegisteredSetter | null;
``` ```
相关类型:[IPublicTypeRegisteredSetter](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/registerd-setter.ts)
### getSettersMap ### getSettersMap
获取已注册的所有 settersMap 获取已注册的所有 settersMap
**类型定义**
```typescript ```typescript
function getSettersMap(): Map<string, RegisteredSetter> /**
* 获取已注册的所有 settersMap
* get map of all registered setters
* @returns
*/
getSettersMap(): Map<string, IPublicTypeRegisteredSetter & {
type: string;
}>;
``` ```
相关类型:[IPublicTypeRegisteredSetter](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/registerd-setter.ts)
### registerSetter ### registerSetter
注册一个 setter 注册一个 setter
**类型定义**
```typescript ```typescript
function registerSetter( /**
typeOrMaps: string | { [key: string]: CustomView | RegisteredSetter }, * 注册一个 setter
setter?: CustomView | RegisteredSetter | undefined, * register a setter
* @param typeOrMaps
* @param setter
* @returns
*/
registerSetter(
typeOrMaps: string | { [key: string]: IPublicTypeCustomView | IPublicTypeRegisteredSetter },
setter?: IPublicTypeCustomView | IPublicTypeRegisteredSetter | undefined
): void; ): void;
``` ```
相关类型:
- [IPublicTypeRegisteredSetter](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/registerd-setter.ts)
- [IPublicTypeCustomView](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/custom-view.ts)
## 使用示例 ## 使用示例
### 注册官方内置 Setter 到设计器中 ### 注册官方内置 Setter 到设计器中
```typescript ```typescript
@ -40,7 +67,7 @@ import { setters, skeleton } from '@alilc/lowcode-engine';
import { setterMap, pluginMap } from '@alilc/lowcode-engine-ext'; import { setterMap, pluginMap } from '@alilc/lowcode-engine-ext';
import { IPublicModelPluginContext } from '@alilc/lowcode-types'; import { IPublicModelPluginContext } from '@alilc/lowcode-types';
const setterRegistry = (ctx: IPublicModelPluginContext) => { const SetterRegistry = (ctx: IPublicModelPluginContext) => {
return { return {
name: 'ext-setters-registry', name: 'ext-setters-registry',
async init() { async init() {
@ -68,8 +95,8 @@ const setterRegistry = (ctx: IPublicModelPluginContext) => {
}; };
} }
setterRegistry.pluginName = 'setterRegistry'; SetterRegistry.pluginName = 'SetterRegistry';
await plugins.register(setterRegistry); await plugins.register(SetterRegistry);
``` ```
### 开发自定义 Setter ### 开发自定义 Setter
@ -112,182 +139,13 @@ export default class AltStringSetter extends React.PureComponent<AltStringSetter
} }
} }
``` ```
开发完毕之后,注册 AltStringSetter 到设计器中: 开发完毕之后,注册 AltStringSetter 到设计器中:
```typescript ```typescript
import AltStringSetter from './AltStringSetter'; import AltStringSetter from './AltStringSetter';
const registerSetter = window.AliLowCodeEngine.setters.registerSetter; import { setters } from '@alilc/lowcode-engine';
registerSetter('AltStringSetter', AltStringSetter); const { registerSetter } = registerSetter;
```
注册之后,我们就可以在物料中使用了,其中核心配置如下:
```typescript
{
"props": {
"isExtends": true,
"override": [
{
"name": "type",
"setter": "AltStringSetter"
}
]
}
}
```
完整配置如下:
```typescript
{
"componentName": "Message",
"title": "Message",
"props": [
{
"name": "title",
"propType": "string",
"description": "标题",
"defaultValue": "标题"
},
{
"name": "type",
"propType": {
"type": "oneOf",
"value": [
"success",
"warning",
"error",
"notice",
"help",
"loading"
]
},
"description": "反馈类型",
"defaultValue": "success"
}
],
"configure": {
"props": {
"isExtends": true,
"override": [
{
"name": "type",
"setter": "AltStringSetter"
}
]
}
}
}
```
## 模块简介
负责注册设置器、管理设置器的 API。注册自定义设置器之后可以在物料中进行使用。
## 方法签名functions
### getSetter
获取指定 setter
**类型定义**
```typescript
function getSetter(type: string): RegisteredSetter;
```
### getSettersMap
获取已注册的所有 settersMap
**类型定义**
```typescript
function getSettersMap(): Map<string, RegisteredSetter>
```
### registerSetter
注册一个 setter
**类型定义**
```typescript
function registerSetter(
typeOrMaps: string | { [key: string]: CustomView | RegisteredSetter },
setter?: CustomView | RegisteredSetter | undefined,
): void;
```
## 使用示例
### 注册官方内置 Setter 到设计器中
```typescript
import { setters, skeleton } from '@alilc/lowcode-engine';
import { setterMap, pluginMap } from '@alilc/lowcode-engine-ext';
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
const setterRegistry = (ctx: IPublicModelPluginContext) => {
return {
name: 'ext-setters-registry',
async init() {
// 注册 setterMap
setters.registerSetter(setterMap);
// 注册插件
// 注册事件绑定面板
skeleton.add({
area: 'centerArea',
type: 'Widget',
content: pluginMap.EventBindDialog,
name: 'eventBindDialog',
props: {},
});
// 注册变量绑定面板
skeleton.add({
area: 'centerArea',
type: 'Widget',
content: pluginMap.VariableBindDialog,
name: 'variableBindDialog',
props: {},
});
},
};
}
setterRegistry.pluginName = 'setterRegistry';
await plugins.register(setterRegistry);
```
### 开发自定义 Setter
AltStringSetter 代码如下:
```typescript
import * as React from "react";
import { Input } from "@alifd/next";
import "./index.scss";
interface AltStringSetterProps {
// 当前值
value: string;
// 默认值
initialValue: string;
// setter 唯一输出
onChange: (val: string) => void;
// AltStringSetter 特殊配置
placeholder: string;
}
export default class AltStringSetter extends React.PureComponent<AltStringSetterProps> {
componentDidMount() {
const { onChange, value, defaultValue } = this.props;
if (value == undefined && defaultValue) {
onChange(defaultValue);
}
}
// 声明 Setter 的 title
static displayName = 'AltStringSetter';
render() {
const { onChange, value, placeholder } = this.props;
return (
<Input
value={value}
placeholder={placeholder || ""}
onChange={(val: any) => onChange(val)}
></Input>
);
}
}
```
开发完毕之后,注册 AltStringSetter 到设计器中:
```typescript
import AltStringSetter from './AltStringSetter';
const registerSetter = window.AliLowCodeEngine.setters.registerSetter;
registerSetter('AltStringSetter', AltStringSetter); registerSetter('AltStringSetter', AltStringSetter);
``` ```
注册之后,我们就可以在物料中使用了,其中核心配置如下: 注册之后,我们就可以在物料中使用了,其中核心配置如下:

View File

@ -2,11 +2,25 @@
title: simulatorHost - 模拟器 API title: simulatorHost - 模拟器 API
sidebar_position: 3 sidebar_position: 3
--- ---
# 模块简介 > **@types** [IPublicApiSimulatorHost](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/simulator-host.ts)<br/>
> **@since** v1.0.0
## 模块简介
负责模拟器相关的 API包括画布尺寸、语言等。 负责模拟器相关的 API包括画布尺寸、语言等。
# 方法functions ## 方法
## set ### set
设置 host 配置值
```typescript
/**
* 设置若干用于画布渲染的变量比如画布大小、locale 等。
* set config for simulator host, eg. device locale and so on.
* @param key
* @param value
*/
set(key: string, value: any): void;
```
#### 示例
设置若干用于画布渲染的变量比如画布大小、locale 等。 设置若干用于画布渲染的变量比如画布大小、locale 等。
以设置画布大小为例: 以设置画布大小为例:
@ -21,11 +35,41 @@ project.simulatorHost.set('deviceClassName', 'my-canvas-class');
project.simulatorHost.set('deviceStyle', { canvas: { width: '300px', backgroundColor: 'red' }, viewport: { width: '280px' } }); project.simulatorHost.set('deviceStyle', { canvas: { width: '300px', backgroundColor: 'red' }, viewport: { width: '280px' } });
``` ```
## get ### get
获取模拟器中设置的变量比如画布大小、locale 等。 获取模拟器中设置的变量比如画布大小、locale 等。
```typescript ```typescript
project.simulatorHost.get('device'); /**
* 获取模拟器中设置的变量比如画布大小、locale 等。
* set config value by key
* @param key
* @returns
*/
get(key: string): any;
``` ```
## rerender ### rerender
刷新渲染画布 刷新渲染画布
```typescript
/**
* 刷新渲染画布
* make simulator render again
*/
rerender(): void;
```
### scrollToNode
滚动到指定节点
```typescript
/**
* 滚动到指定节点
* scroll to specific node
* @param node
* @since v1.1.0
*/
scrollToNode(node: IPublicModelNode): void;
```
**@since v1.1.0**

View File

@ -2,6 +2,10 @@
title: skeleton - 面板 API title: skeleton - 面板 API
sidebar_position: 1 sidebar_position: 1
--- ---
> **@types** [IPublicApiSkeleton](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/skeleton.ts)<br/>
> **@since** v1.0.0
## 模块简介 ## 模块简介
面板 API 提供了面板扩展和管理的能力,如下图蓝色内容都是扩展出来的。 面板 API 提供了面板扩展和管理的能力,如下图蓝色内容都是扩展出来的。
@ -131,21 +135,24 @@ skeleton.add({
}); });
``` ```
## 变量variables ## 方法签名
### add
## 方法签名functions
### 1. add
```tsx
add(config: IWidgetBaseConfig & {
area?: string;
}, extraConfig?: object): IWidget | Panel;
```
往指定扩展区加入一块面板 往指定扩展区加入一块面板
```typescript
/**
* 增加一个面板实例
* add a new panel
* @param config
* @param extraConfig
* @returns
*/
add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record<string, any>): any;
```
IWidgetBaseConfig 定义如下: IWidgetBaseConfig 定义如下:
| 属性名 | 含义 | 备注 | | 属性名 | 含义 | 备注 |
@ -160,74 +167,181 @@ IWidgetBaseConfig 定义如下:
| index | 面板的位置,不传默认按插件注册顺序 | | | index | 面板的位置,不传默认按插件注册顺序 | |
### 2. remove ### remove
remove(config: IWidgetBaseConfig)
移除一个面板实例 移除一个面板实例
### 3. showPanel ```typescript
/**
* 移除一个面板实例
* remove a panel
* @param config
* @returns
*/
remove(config: IPublicTypeWidgetBaseConfig): number | undefined;
```
showPanel(name: string)
### showPanel
展示指定 Panel 实例 展示指定 Panel 实例
### 4. hidePanel ```typescript
/**
* 展示指定 Panel 实例
* show panel by name
* @param name
*/
showPanel(name: string): void;
```
hidePanel(name: string) ### hidePanel
隐藏面板
### 5. showWidget ```typescript
/**
* 隐藏面板
* hide panel by name
* @param name
*/
hidePanel(name: string): void;
```
showWidget(name: string) ### showWidget
展示指定 Widget 实例 展示指定 Widget 实例
### 6. hideWidget ```typescript
/**
* 展示指定 Widget 实例
* show widget by name
* @param name
*/
showWidget(name: string): void;
```
hideWidget(name: string) ### enableWidget
将 widget 启用。
```typescript
/**
* 将 widget 启用
* enable widget
* @param name
*/
enableWidget(name: string): void;
```
### hideWidget
隐藏指定 widget 实例。 隐藏指定 widget 实例。
### 7. enableWidget ```typescript
/**
* 隐藏指定 widget 实例
* hide widget by name
* @param name
*/
hideWidget(name: string): void;
```
enableWidget(name: string) ### disableWidget
将 widget 启用。
注:该函数将会触发全局事件 'skeleton.widget.enable'
### 8. disableWidget
disableWidget(name: string)
将 widget 禁用掉,禁用后,所有鼠标事件都会被禁止掉。 将 widget 禁用掉,禁用后,所有鼠标事件都会被禁止掉。
适用场景:在该面板还在进行初始化构造时,可以先禁止掉,防止用户点击报错,待初始化完成,重新启用。 适用场景:在该面板还在进行初始化构造时,可以先禁止掉,防止用户点击报错,待初始化完成,重新启用。
## 事件events ```typescript
### 1. onShowPanel /**
* 将 widget 禁用掉,禁用后,所有鼠标事件都会被禁止掉。
* disable widgetand make it not responding any click event.
* @param name
*/
disableWidget(name: string): void;
```
onShowPanel(listener: (...args: unknown[]) => void) ### showArea
显示某个 Area
```typescript
/**
* 显示某个 Area
* show area
* @param areaName name of area
*/
showArea(areaName: string): void;
```
### hideArea
隐藏某个 Area
```typescript
/**
* 隐藏某个 Area
* hide area
* @param areaName name of area
*/
hideArea(areaName: string): void;
```
## 事件
### onShowPanel
监听 Panel 实例显示事件 监听 Panel 实例显示事件
### 2. onHidePanel ```typescript
/**
* 监听 panel 显示事件
* set callback for panel shown event
* @param listener
* @returns
*/
onShowPanel(listener: (...args: any[]) => void): () => void;
```
onHidePanel(listener: (...args: unknown[]) => void) ### onHidePanel
监听 Panel 实例隐藏事件 监听 Panel 实例隐藏事件
### 3. onShowWidget ```typescript
/**
* 监听 Panel 实例隐藏事件
* set callback for panel hidden event
* @param listener
* @returns
*/
onHidePanel(listener: (...args: any[]) => void): () => void;
```
onShowWidget(listener: (...args: unknown[]) => void)
### onShowWidget
监听 Widget 实例显示事件 监听 Widget 实例显示事件
### 4. onHideWidget ```typescript
/**
* 监听 Widget 显示事件
* set callback for widget shown event
* @param listener
* @returns
*/
onShowWidget(listener: (...args: any[]) => void): () => void;
```
onHideWidget(listener: (...args: unknown[]) => void)
### onHideWidget
监听 Widget 实例隐藏事件 监听 Widget 实例隐藏事件
```typescript
/**
* 监听 Widget 隐藏事件
* set callback for widget hidden event
* @param listener
* @returns
*/
onHideWidget(listener: (...args: any[]) => void): () => void;
```
## 使用示例 ## 使用示例
```typescript ```typescript

View File

@ -9,7 +9,8 @@ module.exports = function getDocsFromDir(dir, cateList) {
const docsDir = path.join(baseDir, dir); const docsDir = path.join(baseDir, dir);
function getMarkdownOrder(filepath) { function getMarkdownOrder(filepath) {
return (matter(fs.readFileSync(filepath, 'utf-8')).data || {}).order || 100; const data = matter(fs.readFileSync(filepath, 'utf-8')).data;
return (data || {}).sidebar_position || 100;
} }
const docs = glob.sync('*.md?(x)', { const docs = glob.sync('*.md?(x)', {
@ -26,7 +27,7 @@ module.exports = function getDocsFromDir(dir, cateList) {
const orderA = getMarkdownOrder(a); const orderA = getMarkdownOrder(a);
const orderB = getMarkdownOrder(b); const orderB = getMarkdownOrder(b);
return orderA - orderB; return orderB - orderA;
}) })
.map(filepath => { .map(filepath => {
// /Users/xxx/site/docs/guide/basic/router.md => guide/basic/router // /Users/xxx/site/docs/guide/basic/router.md => guide/basic/router

View File

@ -5,7 +5,7 @@ const { version, name } = package;
const options = { const options = {
method: 'PUT', method: 'PUT',
// 暂时使用 日常环境的 uipaas-node上线后可切换成线上环境 https://uipaas-node.alibaba-inc.com // 暂时使用 日常环境的 uipaas-node上线后可切换成线上环境 https://uipaas-node.alibaba-inc.com
hostname: 'uipaas-node.alibaba.net', hostname: 'uipaas-node.alibaba-inc.com',
path: '/staticAssets/cdn/packages', path: '/staticAssets/cdn/packages',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View File

@ -15,7 +15,7 @@ import { invariant } from '../utils';
import sequencify from './sequencify'; import sequencify from './sequencify';
import semverSatisfies from 'semver/functions/satisfies'; import semverSatisfies from 'semver/functions/satisfies';
import { import {
ILowCodeRegisterOptions, IPublicTypePluginRegisterOptions,
IPublicTypePreferenceValueType, IPublicTypePreferenceValueType,
IPublicTypePlugin, IPublicTypePlugin,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
@ -65,7 +65,7 @@ export class LowCodePluginManager implements ILowCodePluginManager {
async register( async register(
pluginModel: IPublicTypePlugin, pluginModel: IPublicTypePlugin,
options?: any, options?: any,
registerOptions?: ILowCodeRegisterOptions, registerOptions?: IPublicTypePluginRegisterOptions,
): Promise<void> { ): Promise<void> {
// registerOptions maybe in the second place // registerOptions maybe in the second place
if (isLowCodeRegisterOptions(options)) { if (isLowCodeRegisterOptions(options)) {

View File

@ -1,5 +1,5 @@
import { isPlainObject } from 'lodash'; import { isPlainObject } from 'lodash';
import { ILowCodeRegisterOptions, IPublicTypePluginDeclaration } from '@alilc/lowcode-types'; import { IPublicTypePluginRegisterOptions, IPublicTypePluginDeclaration } from '@alilc/lowcode-types';
export function isValidPreferenceKey( export function isValidPreferenceKey(
key: string, key: string,
@ -13,7 +13,7 @@ export function isValidPreferenceKey(
}); });
} }
export function isLowCodeRegisterOptions(opts: any): opts is ILowCodeRegisterOptions { export function isLowCodeRegisterOptions(opts: any): opts is IPublicTypePluginRegisterOptions {
return opts && ('autoInit' in opts || 'override' in opts); return opts && ('autoInit' in opts || 'override' in opts);
} }

View File

@ -5,7 +5,6 @@ import {
IPublicTypeProjectSchema, IPublicTypeProjectSchema,
IPublicTypeRootSchema, IPublicTypeRootSchema,
IPublicTypeComponentsMap, IPublicTypeComponentsMap,
TransformStage,
IPublicApiProject, IPublicApiProject,
IPublicModelDocumentModel, IPublicModelDocumentModel,
IPublicEnumTransformStage, IPublicEnumTransformStage,

View File

@ -3,7 +3,7 @@ import { isPlainObject } from '@alilc/lowcode-utils';
import { import {
EngineOptions, EngineOptions,
IPublicModelEngineConfig, IPublicModelEngineConfig,
IPreference, IPublicModelPreference,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
import { getLogger } from './utils/logger'; import { getLogger } from './utils/logger';
import Preference from './utils/preference'; import Preference from './utils/preference';
@ -193,7 +193,7 @@ export class EngineConfig implements IPublicModelEngineConfig, IEngineConfigPriv
* used to store preferences * used to store preferences
* *
*/ */
readonly preference: IPreference; readonly preference: IPublicModelPreference;
constructor(config?: { [key: string]: any }) { constructor(config?: { [key: string]: any }) {
this.config = config || {}; this.config = config || {};
@ -349,7 +349,7 @@ export class EngineConfig implements IPublicModelEngineConfig, IEngineConfigPriv
} }
} }
getPreference(): IPreference { getPreference(): IPublicModelPreference {
return this.preference; return this.preference;
} }
} }

View File

@ -1,6 +1,6 @@
import store from 'store'; import store from 'store';
import { getLogger } from './logger'; import { getLogger } from './logger';
import { IPreference } from '@alilc/lowcode-types'; import { IPublicModelPreference } from '@alilc/lowcode-types';
const logger = getLogger({ level: 'log', bizName: 'Preference' }); const logger = getLogger({ level: 'log', bizName: 'Preference' });
const STORAGE_KEY_PREFIX = 'ale'; const STORAGE_KEY_PREFIX = 'ale';
@ -12,7 +12,7 @@ const STORAGE_KEY_PREFIX = 'ale';
* *
* @class PreferenceStore * @class PreferenceStore
*/ */
export default class Preference implements IPreference { export default class Preference implements IPublicModelPreference {
getStorageKey(key: string, module?: string): string { getStorageKey(key: string, module?: string): string {
const moduleKey = module || '__inner__'; const moduleKey = module || '__inner__';
return `${STORAGE_KEY_PREFIX}_${moduleKey}.${key}`; return `${STORAGE_KEY_PREFIX}_${moduleKey}.${key}`;

View File

@ -17,13 +17,13 @@ import {
IPublicTypeNodeSchema, IPublicTypeNodeSchema,
IPublicEnumTransitionType, IPublicEnumTransitionType,
IPublicEnumTransformStage as InnerTransitionStage, IPublicEnumTransformStage as InnerTransitionStage,
IPublicCommonDesignerCabin, IPublicApiCommonDesignerCabin,
IPublicCommonSkeletonCabin, IPublicApiCommonSkeletonCabin,
IPublicCommonUtils, IPublicApiCommonUtils,
IPublicApiCommon, IPublicApiCommon,
IPublicEnumDragObjectType as InnerDragObjectType, IPublicEnumDragObjectType as InnerDragObjectType,
IPublicTypeLocationDetailType as InnerLocationDetailType, IPublicTypeLocationDetailType as InnerLocationDetailType,
IPublicCommonEditorCabin, IPublicApiCommonEditorCabin,
IPublicModelDragon, IPublicModelDragon,
IDesigner, IDesigner,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
@ -61,7 +61,7 @@ import {
import { Dragon } from '../model'; import { Dragon } from '../model';
import { ReactNode, Component } from 'react'; import { ReactNode, Component } from 'react';
class DesignerCabin implements IPublicCommonDesignerCabin { class DesignerCabin implements IPublicApiCommonDesignerCabin {
private readonly [editorSymbol]: Editor; private readonly [editorSymbol]: Editor;
/** /**
* @deprecated * @deprecated
@ -150,10 +150,9 @@ class DesignerCabin implements IPublicCommonDesignerCabin {
get dragon(): IPublicModelDragon | null { get dragon(): IPublicModelDragon | null {
return Dragon.create(this[designerSymbol].dragon); return Dragon.create(this[designerSymbol].dragon);
} }
} }
class SkeletonCabin implements IPublicCommonSkeletonCabin { class SkeletonCabin implements IPublicApiCommonSkeletonCabin {
private readonly [skeletonSymbol]: InnerSkeleton; private readonly [skeletonSymbol]: InnerSkeleton;
constructor(skeleton: InnerSkeleton) { constructor(skeleton: InnerSkeleton) {
@ -187,7 +186,7 @@ class SkeletonCabin implements IPublicCommonSkeletonCabin {
} }
} }
class Utils implements IPublicCommonUtils { class Utils implements IPublicApiCommonUtils {
isNodeSchema(data: any): data is IPublicTypeNodeSchema { isNodeSchema(data: any): data is IPublicTypeNodeSchema {
return innerIsNodeSchema(data); return innerIsNodeSchema(data);
} }
@ -196,11 +195,17 @@ class Utils implements IPublicCommonUtils {
return innerIsFormEvent(e); return innerIsFormEvent(e);
} }
/**
* @deprecated this is a legacy api, do not use this if not using is already
*/
compatibleLegaoSchema(props: any): any { compatibleLegaoSchema(props: any): any {
return innerCompatibleLegaoSchema(props); return innerCompatibleLegaoSchema(props);
} }
getNodeSchemaById(schema: IPublicTypeNodeSchema, nodeId: string): IPublicTypeNodeSchema | undefined { getNodeSchemaById(
schema: IPublicTypeNodeSchema,
nodeId: string,
): IPublicTypeNodeSchema | undefined {
return innerGetNodeSchemaById(schema, nodeId); return innerGetNodeSchemaById(schema, nodeId);
} }
@ -212,7 +217,10 @@ class Utils implements IPublicCommonUtils {
return innerGetOriginalExtraKey(key); return innerGetOriginalExtraKey(key);
} }
executeTransaction(fn: () => void, type: IPublicEnumTransitionType = IPublicEnumTransitionType.REPAINT): void { executeTransaction(
fn: () => void,
type: IPublicEnumTransitionType = IPublicEnumTransitionType.REPAINT,
): void {
transactionManager.executeTransaction(fn, type); transactionManager.executeTransaction(fn, type);
} }
@ -226,7 +234,7 @@ class Utils implements IPublicCommonUtils {
} }
} }
class EditorCabin implements IPublicCommonEditorCabin { class EditorCabin implements IPublicApiCommonEditorCabin {
private readonly [editorSymbol]: Editor; private readonly [editorSymbol]: Editor;
constructor(editor: Editor) { constructor(editor: Editor) {
@ -234,6 +242,7 @@ class EditorCabin implements IPublicCommonEditorCabin {
} }
/** /**
* Title * Title
* @experimental unstable API, pay extra caution when trying to use this
*/ */
get Title(): Component { get Title(): Component {
return InnerTitle; return InnerTitle;
@ -241,6 +250,7 @@ class EditorCabin implements IPublicCommonEditorCabin {
/** /**
* Tip * Tip
* @experimental unstable API, pay extra caution when trying to use this
*/ */
get Tip(): Component { get Tip(): Component {
return InnerTip; return InnerTip;

View File

@ -15,10 +15,12 @@ import {
IPublicApiMaterial, IPublicApiMaterial,
IPublicTypeMetadataTransducer, IPublicTypeMetadataTransducer,
IPublicModelComponentMeta, IPublicModelComponentMeta,
IPublicTypeNpmInfo,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
import { Workspace } from '@alilc/lowcode-workspace'; import { Workspace } from '@alilc/lowcode-workspace';
import { editorSymbol, designerSymbol } from '../symbols'; import { editorSymbol, designerSymbol } from '../symbols';
import { ComponentMeta } from '../model/component-meta'; import { ComponentMeta } from '../model/component-meta';
import { ComponentType } from 'react';
const innerEditorSymbol = Symbol('editor'); const innerEditorSymbol = Symbol('editor');
export class Material implements IPublicApiMaterial { export class Material implements IPublicApiMaterial {
@ -47,7 +49,7 @@ export class Material implements IPublicApiMaterial {
/** /**
* map * map
*/ */
get componentsMap() { get componentsMap(): { [key: string]: IPublicTypeNpmInfo | ComponentType<any> | object } {
return this[designerSymbol].componentsMap; return this[designerSymbol].componentsMap;
} }
@ -173,6 +175,6 @@ export class Material implements IPublicApiMaterial {
// 设置 assets经过 setAssets 赋值 // 设置 assets经过 setAssets 赋值
this[editorSymbol].onGot('assets', fn); this[editorSymbol].onGot('assets', fn);
// 增量设置 assets经过 loadIncrementalAssets 赋值 // 增量设置 assets经过 loadIncrementalAssets 赋值
this[editorSymbol].on('designer.incrementalAssetsReady', fn); this[editorSymbol].eventBus.on('designer.incrementalAssetsReady', fn);
} }
} }

View File

@ -5,7 +5,7 @@ import { globalContext } from '@alilc/lowcode-editor-core';
import { import {
IPublicApiPlugins, IPublicApiPlugins,
IPublicTypePlugin, IPublicTypePlugin,
ILowCodeRegisterOptions, IPublicTypePluginRegisterOptions,
IPublicTypePreferenceValueType, IPublicTypePreferenceValueType,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
import { pluginsSymbol } from '../symbols'; import { pluginsSymbol } from '../symbols';
@ -32,7 +32,7 @@ export class Plugins implements IPublicApiPlugins {
async register( async register(
pluginModel: IPublicTypePlugin, pluginModel: IPublicTypePlugin,
options?: any, options?: any,
registerOptions?: ILowCodeRegisterOptions, registerOptions?: IPublicTypePluginRegisterOptions,
): Promise<void> { ): Promise<void> {
await this[pluginsSymbol].register(pluginModel, options, registerOptions); await this[pluginsSymbol].register(pluginModel, options, registerOptions);
} }

View File

@ -13,6 +13,7 @@ import {
IPublicTypePropsTransducer, IPublicTypePropsTransducer,
IPublicEnumEventNames, IPublicEnumEventNames,
IPublicEnumTransformStage, IPublicEnumTransformStage,
IPublicTypeDisposable,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
@ -163,7 +164,7 @@ export class Project implements IPublicApiProject {
* @param fn * @param fn
* @returns * @returns
*/ */
onRemoveDocument(fn: (data: { id: string}) => void): any { onRemoveDocument(fn: (data: { id: string}) => void): IPublicTypeDisposable {
return this[editorSymbol].eventBus.on( return this[editorSymbol].eventBus.on(
IPublicEnumEventNames.DESIGNER_DOCUMENT_REMOVE, IPublicEnumEventNames.DESIGNER_DOCUMENT_REMOVE,
(data: { id: string }) => fn(data), (data: { id: string }) => fn(data),
@ -173,7 +174,7 @@ export class Project implements IPublicApiProject {
/** /**
* project document * project document
*/ */
onChangeDocument(fn: (doc: IPublicModelDocumentModel) => void) { onChangeDocument(fn: (doc: IPublicModelDocumentModel) => void): IPublicTypeDisposable {
const offFn = this[projectSymbol].onCurrentDocumentChange((originalDoc) => { const offFn = this[projectSymbol].onCurrentDocumentChange((originalDoc) => {
fn(DocumentModel.create(originalDoc)!); fn(DocumentModel.create(originalDoc)!);
}); });
@ -186,7 +187,7 @@ export class Project implements IPublicApiProject {
/** /**
* project ready * project ready
*/ */
onSimulatorHostReady(fn: (host: IPublicApiSimulatorHost) => void) { onSimulatorHostReady(fn: (host: IPublicApiSimulatorHost) => void): IPublicTypeDisposable {
const offFn = this[projectSymbol].onSimulatorReady((simulator: BuiltinSimulatorHost) => { const offFn = this[projectSymbol].onSimulatorReady((simulator: BuiltinSimulatorHost) => {
this[simulatorHostSymbol] = simulator; this[simulatorHostSymbol] = simulator;
fn(SimulatorHost.create(simulator)!); fn(SimulatorHost.create(simulator)!);
@ -200,7 +201,7 @@ export class Project implements IPublicApiProject {
/** /**
* project ready * project ready
*/ */
onSimulatorRendererReady(fn: () => void) { onSimulatorRendererReady(fn: () => void): IPublicTypeDisposable {
const offFn = this[projectSymbol].onRendererReady((renderer: any) => { const offFn = this[projectSymbol].onRendererReady((renderer: any) => {
this[simulatorRendererSymbol] = renderer; this[simulatorRendererSymbol] = renderer;
fn(); fn();

View File

@ -138,20 +138,3 @@ export interface EngineOptions {
*/ */
enableWorkspaceMode?: boolean; enableWorkspaceMode?: boolean;
} }
export interface IPreference {
/**
* set value from local storage by module and key
*/
set(key: string, value: any, module?: string): void;
/**
* get value from local storage by module and key
*/
get(key: string, module: string): any;
/**
* check if local storage contain certain key
*/
contains(key: string, module: string): boolean;
}

View File

@ -5,34 +5,44 @@ export interface IPublicApiCanvas {
/** /**
* Scroller
* a Scroller is a controller that gives a view (IPublicModelScrollable) the ability scrolling * a Scroller is a controller that gives a view (IPublicModelScrollable) the ability scrolling
* to some cordination by api scrollTo. * to some cordination by api scrollTo.
* *
* when initing aaa scroller, will need to pass is a scrollable, which has a scrollTarget. * when a scroller is inited, will need to pass is a scrollable, which has a scrollTarget.
* and when scrollTo(options: { left?: number; top?: number }) is called, scroller will * and when scrollTo(options: { left?: number; top?: number }) is called, scroller will
* move scrollTarget`s top-left corner to (options.left, options.top) that passed in. * move scrollTarget`s top-left corner to (options.left, options.top) that passed in.
* @since v1.1.0
*/ */
createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller; createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller;
/** /**
* ScrollTarget Scroller createScroller
* this works with Scroller, refer to createScroller`s description * this works with Scroller, refer to createScroller`s description
* @since v1.1.0
*/ */
createScrollTarget(shell: HTMLDivElement): IPublicModelScrollTarget; createScrollTarget(shell: HTMLDivElement): IPublicModelScrollTarget;
/** /**
*
* create a drop location for document, drop location describes a location in document * create a drop location for document, drop location describes a location in document
* @since v1.1.0
*/ */
createLocation(locationData: IPublicTypeLocationData): IPublicModelDropLocation; createLocation(locationData: IPublicTypeLocationData): IPublicModelDropLocation;
/** /**
*
* get dragon instance, you can use this to obtain draging related abilities and lifecycle hooks * get dragon instance, you can use this to obtain draging related abilities and lifecycle hooks
* @since v1.1.0
*/ */
get dragon(): IPublicModelDragon | null; get dragon(): IPublicModelDragon | null;
/** /**
*
* get activeTracker instance, which is a singleton running in engine. * get activeTracker instance, which is a singleton running in engine.
* it tracks document`s current focusing node/node[], and notify it`s subscribers that when * it tracks document`s current focusing node/node[], and notify it`s subscribers that when
* focusing node/node[] changed. * focusing node/node[] changed.
* @since v1.1.0
*/ */
get activeTracker(): IPublicModelActiveTracker | null; get activeTracker(): IPublicModelActiveTracker | null;
} }

View File

@ -3,24 +3,65 @@ import { Component, ReactNode } from 'react';
import { IPublicTypeNodeSchema } from '../type'; import { IPublicTypeNodeSchema } from '../type';
import { IPublicEnumTransitionType } from '../enum'; import { IPublicEnumTransitionType } from '../enum';
export interface IPublicCommonUtils { export interface IPublicApiCommonUtils {
/**
* schema
* check if data is valid NodeSchema
*
* @param {*} data
* @returns {boolean}
*/
isNodeSchema(data: any): boolean; isNodeSchema(data: any): boolean;
/**
*
* check if e is a form event
* @param {(KeyboardEvent | MouseEvent)} e
* @returns {boolean}
*/
isFormEvent(e: KeyboardEvent | MouseEvent): boolean; isFormEvent(e: KeyboardEvent | MouseEvent): boolean;
compatibleLegaoSchema(props: any): any; /**
* schema id
* get node schema from a larger schema with node id
* @param {IPublicTypeNodeSchema} schema
* @param {string} nodeId
* @returns {(IPublicTypeNodeSchema | undefined)}
*/
getNodeSchemaById( getNodeSchemaById(
schema: IPublicTypeNodeSchema, schema: IPublicTypeNodeSchema,
nodeId: string, nodeId: string,
): IPublicTypeNodeSchema | undefined; ): IPublicTypeNodeSchema | undefined;
// TODO: add comments
getConvertedExtraKey(key: string): string; getConvertedExtraKey(key: string): string;
// TODO: add comments
getOriginalExtraKey(key: string): string; getOriginalExtraKey(key: string): string;
/**
*
* excute something in a transaction for performence
*
* @param {() => void} fn
* @param {IPublicEnumTransitionType} type
* @since v1.0.16
*/
executeTransaction(fn: () => void, type: IPublicEnumTransitionType): void; executeTransaction(fn: () => void, type: IPublicEnumTransitionType): void;
/**
* i18n
* i18n tools
*
* @param {(string | object)} instance
* @returns {{
* intlNode(id: string, params?: object): ReactNode;
* intl(id: string, params?: object): string;
* getLocale(): string;
* setLocale(locale: string): void;
* }}
* @since v1.0.17
*/
createIntl(instance: string | object): { createIntl(instance: string | object): {
intlNode(id: string, params?: object): ReactNode; intlNode(id: string, params?: object): ReactNode;
intl(id: string, params?: object): string; intl(id: string, params?: object): string;
@ -28,33 +69,43 @@ export interface IPublicCommonUtils {
setLocale(locale: string): void; setLocale(locale: string): void;
}; };
} }
export interface IPublicCommonSkeletonCabin { export interface IPublicApiCommonSkeletonCabin {
/**
* View
* get Workbench Component
*/
get Workbench(): Component; get Workbench(): Component;
} }
export interface IPublicCommonEditorCabin { export interface IPublicApiCommonEditorCabin {
/**
* Title
* @experimental unstable API, pay extra caution when trying to use this
*/
get Tip(): Component; get Tip(): Component;
/**
* Tip
* @experimental unstable API, pay extra caution when trying to use this
*/
get Title(): Component; get Title(): Component;
} }
export interface IPublicCommonDesignerCabin { export interface IPublicApiCommonDesignerCabin {
/**
* SettingField
*
* @param {*} obj
* @returns {obj is SettingField}
* @memberof DesignerCabin
*/
isSettingField(obj: any): boolean;
} }
export interface IPublicApiCommon { export interface IPublicApiCommon {
get utils(): IPublicCommonUtils; get utils(): IPublicApiCommonUtils;
get designerCabin(): IPublicCommonDesignerCabin; /**
* @deprecated
*/
get designerCabin(): IPublicApiCommonDesignerCabin;
get editorCabin(): IPublicCommonEditorCabin; /**
* @experimental unstable API, pay extra caution when trying to use this
*/
get editorCabin(): IPublicApiCommonEditorCabin;
get skeletonCabin(): IPublicCommonSkeletonCabin; get skeletonCabin(): IPublicApiCommonSkeletonCabin;
} }

View File

@ -4,6 +4,7 @@ export interface IPublicApiEvent {
/** /**
* *
* add monitor to a event
* @param event * @param event
* @param listener * @param listener
*/ */
@ -12,6 +13,7 @@ export interface IPublicApiEvent {
/** /**
* *
* cancel a monitor from a event
* @param event * @param event
* @param listener * @param listener
*/ */
@ -19,6 +21,7 @@ export interface IPublicApiEvent {
/** /**
* *
* emit a message fot a event
* @param event * @param event
* @param args * @param args
* @returns * @returns

View File

@ -5,10 +5,15 @@ export interface IPublicApiHotkey {
/** /**
* *
* bind hotkey/hotkeys,
* @param combos ['command + s'] ['ctrl + shift + s'] * @param combos ['command + s'] ['ctrl + shift + s']
* @param callback * @param callback
* @param action * @param action
* @returns * @returns
*/ */
bind(combos: string[] | string, callback: IPublicTypeHotkeyCallback, action?: string): IPublicTypeDisposable; bind(
combos: string[] | string,
callback: IPublicTypeHotkeyCallback,
action?: string,
): IPublicTypeDisposable;
} }

View File

@ -1,31 +1,41 @@
import { IPublicTypeAssetsJson, IPublicTypeMetadataTransducer, IPublicTypeComponentAction } from '../type'; import { IPublicTypeAssetsJson, IPublicTypeMetadataTransducer, IPublicTypeComponentAction, IPublicTypeNpmInfo } from '../type';
import { IPublicModelComponentMeta } from '../model'; import { IPublicModelComponentMeta } from '../model';
import { ComponentType } from 'react';
export interface IPublicApiMaterial { export interface IPublicApiMaterial {
/**
* map
* get map of components
*/
get componentsMap(): { [key: string]: IPublicTypeNpmInfo | ComponentType<any> | object } ;
/** /**
* *
* @param assets * set data for Assets
* @returns * @returns void
*/ */
setAssets(assets: IPublicTypeAssetsJson): void; setAssets(assets: IPublicTypeAssetsJson): void;
/** /**
* *
* @returns * get AssetsJson data
* @returns IPublicTypeAssetsJson
*/ */
getAssets(): any; getAssets(): IPublicTypeAssetsJson;
/** /**
* *
* load Assets incrementally, and will merge this with exiting assets
* @param incrementalAssets * @param incrementalAssets
* @returns * @returns
*/ */
loadIncrementalAssets(incrementalAssets: IPublicTypeAssetsJson): void; loadIncrementalAssets(incrementalAssets: IPublicTypeAssetsJson): void;
/** /**
* *
* register transducer to process component meta, which will be
* excuted during component meta`s initialization
* @param transducer * @param transducer
* @param level * @param level
* @param id * @param id
@ -38,12 +48,14 @@ export interface IPublicApiMaterial {
/** /**
* *
* @returns * get all registered metadata transducers
* @returns {IPublicTypeMetadataTransducer[]}
*/ */
getRegisteredMetadataTransducers(): IPublicTypeMetadataTransducer[]; getRegisteredMetadataTransducers(): IPublicTypeMetadataTransducer[];
/** /**
* *
* get component meta by component name
* @param componentName * @param componentName
* @returns * @returns
*/ */
@ -52,30 +64,33 @@ export interface IPublicApiMaterial {
/** /**
* test if the given object is a ComponentMeta instance or not * test if the given object is a ComponentMeta instance or not
* @param obj * @param obj
* @returns * @experiemental unstable API, pay extra caution when trying to use it
*/ */
isComponentMeta(obj: any): boolean; isComponentMeta(obj: any): boolean;
/** /**
* *
* @returns * get map of all component metas
*/ */
getComponentMetasMap(): Map<string, IPublicModelComponentMeta>; getComponentMetasMap(): Map<string, IPublicModelComponentMeta>;
/** /**
* action * action
* add an action button in canvas context menu area
* @param action * @param action
*/ */
addBuiltinComponentAction(action: IPublicTypeComponentAction): void; addBuiltinComponentAction(action: IPublicTypeComponentAction): void;
/** /**
* action * action
* remove a builtin action button from canvas context menu area
* @param name * @param name
*/ */
removeBuiltinComponentAction(name: string): void; removeBuiltinComponentAction(name: string): void;
/** /**
* action * action
* modify a builtin action button in canvas context menu area
* @param actionName * @param actionName
* @param handle * @param handle
*/ */
@ -86,6 +101,7 @@ export interface IPublicApiMaterial {
/** /**
* assets * assets
* add callback for assets changed event
* @param fn * @param fn
*/ */
onChangeAssets(fn: () => void): void; onChangeAssets(fn: () => void): void;

View File

@ -1,5 +1,6 @@
import { IPublicTypePlugin } from '../model'; import { IPublicTypePlugin } from '../model';
import { IPublicTypePreferenceValueType } from '../type'; import { IPublicTypePreferenceValueType } from '../type';
import { IPublicTypePluginRegisterOptions } from '../type/plugin-register-options';
export interface IPluginPreferenceMananger { export interface IPluginPreferenceMananger {
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
@ -9,28 +10,18 @@ export interface IPluginPreferenceMananger {
) => IPublicTypePreferenceValueType | undefined; ) => IPublicTypePreferenceValueType | undefined;
} }
export interface ILowCodeRegisterOptions {
/**
* Will enable plugin registered with auto-initialization immediately
* other than plugin-manager init all plugins at certain time.
* It is helpful when plugin register is later than plugin-manager initialization.
*/
autoInit?: boolean;
/**
* allow overriding existing plugin with same name when override === true
*/
override?: boolean;
}
export type PluginOptionsType = string | number | boolean | object; export type PluginOptionsType = string | number | boolean | object;
export interface IPublicApiPlugins { export interface IPublicApiPlugins {
register( register(
pluginModel: IPublicTypePlugin, pluginModel: IPublicTypePlugin,
options?: Record<string, PluginOptionsType>, options?: Record<string, PluginOptionsType>,
registerOptions?: ILowCodeRegisterOptions, registerOptions?: IPublicTypePluginRegisterOptions,
): Promise<void>; ): Promise<void>;
/**
* @deprecated use options instead
*/
getPluginPreference( getPluginPreference(
pluginName: string, pluginName: string,
): Record<string, IPublicTypePreferenceValueType> | null | undefined; ): Record<string, IPublicTypePreferenceValueType> | null | undefined;

View File

@ -7,30 +7,34 @@ import { IPublicModelDocumentModel } from '../model';
export interface IPublicApiProject { export interface IPublicApiProject {
/** /**
* document * document
* @returns * get current document
*/ */
get currentDocument(): IPublicModelDocumentModel | null; get currentDocument(): IPublicModelDocumentModel | null;
/** /**
* project documents * project documents
* @returns * get all documents of this project
*/ * @returns
*/
get documents(): IPublicModelDocumentModel[]; get documents(): IPublicModelDocumentModel[];
/** /**
* host * host
* get simulator host
*/ */
get simulatorHost(): IPublicApiSimulatorHost | null; get simulatorHost(): IPublicApiSimulatorHost | null;
/** /**
* document * document
* @param doc * open a document
* @returns * @param doc
*/ * @returns
*/
openDocument(doc?: string | IPublicTypeRootSchema | undefined): IPublicModelDocumentModel | null; openDocument(doc?: string | IPublicTypeRootSchema | undefined): IPublicModelDocumentModel | null;
/** /**
* document * document
* create a document
* @param data * @param data
* @returns * @returns
*/ */
@ -39,12 +43,14 @@ export interface IPublicApiProject {
/** /**
* document * document
* remove a document
* @param doc * @param doc
*/ */
removeDocument(doc: IPublicModelDocumentModel): void; removeDocument(doc: IPublicModelDocumentModel): void;
/** /**
* fileName document * fileName document
* get a document by filename
* @param fileName * @param fileName
* @returns * @returns
*/ */
@ -52,6 +58,7 @@ export interface IPublicApiProject {
/** /**
* id document * id document
* get a document by id
* @param id * @param id
* @returns * @returns
*/ */
@ -59,24 +66,28 @@ export interface IPublicApiProject {
/** /**
* project * project
* export project to schema
* @returns * @returns
*/ */
exportSchema(stage: IPublicEnumTransformStage): IPublicTypeProjectSchema; exportSchema(stage: IPublicEnumTransformStage): IPublicTypeProjectSchema;
/** /**
* project * project schema
* @param schema project * import schema to project
*/ * @param schema project
*/
importSchema(schema?: IPublicTypeProjectSchema): void; importSchema(schema?: IPublicTypeProjectSchema): void;
/** /**
* document * document
* get current document
* @returns * @returns
*/ */
getCurrentDocument(): IPublicModelDocumentModel | null; getCurrentDocument(): IPublicModelDocumentModel | null;
/** /**
* *
* add a transducer to process prop
* @param transducer * @param transducer
* @param stage * @param stage
*/ */
@ -87,31 +98,37 @@ export interface IPublicApiProject {
/** /**
* *
* set callback for event onDocumentRemoved
* @param fn * @param fn
* @returns * @since v1.0.16
*/ */
onRemoveDocument(fn: (data: { id: string }) => void): any; onRemoveDocument(fn: (data: { id: string }) => void): IPublicTypeDisposable;
/** /**
* project document * project document
* set callback for event onDocumentChanged
*/ */
onChangeDocument(fn: (doc: IPublicModelDocumentModel) => void): IPublicTypeDisposable; onChangeDocument(fn: (doc: IPublicModelDocumentModel) => void): IPublicTypeDisposable;
/** /**
* project ready * project ready
* set callback for event onSimulatorHostReady
*/ */
onSimulatorHostReady(fn: (host: IPublicApiSimulatorHost) => void): IPublicTypeDisposable; onSimulatorHostReady(fn: (host: IPublicApiSimulatorHost) => void): IPublicTypeDisposable;
/** /**
* project ready * project ready
* set callback for event onSimulatorRendererReady
*/ */
onSimulatorRendererReady(fn: () => void): IPublicTypeDisposable; onSimulatorRendererReady(fn: () => void): IPublicTypeDisposable;
/** /**
* *
* https://github.com/alibaba/lowcode-engine/blob/main/specs/lowcode-spec.md#2434%E5%9B%BD%E9%99%85%E5%8C%96%E5%A4%9A%E8%AF%AD%E8%A8%80%E7%B1%BB%E5%9E%8Baa * https://github.com/alibaba/lowcode-engine/blob/main/specs/lowcode-spec.md#2434%E5%9B%BD%E9%99%85%E5%8C%96%E5%A4%9A%E8%AF%AD%E8%A8%80%E7%B1%BB%E5%9E%8Baa
*
* set I18n data for this project
* @param value object * @param value object
* @returns * @since v1.0.17
*/ */
setI18n(value: object): void; setI18n(value: object): void;
} }

View File

@ -3,6 +3,7 @@ import { IPublicTypeRegisteredSetter, IPublicTypeCustomView } from '../type';
export interface IPublicApiSetters { export interface IPublicApiSetters {
/** /**
* setter * setter
* get setter by type
* @param type * @param type
* @returns * @returns
*/ */
@ -10,6 +11,7 @@ export interface IPublicApiSetters {
/** /**
* settersMap * settersMap
* get map of all registered setters
* @returns * @returns
*/ */
getSettersMap(): Map<string, IPublicTypeRegisteredSetter & { getSettersMap(): Map<string, IPublicTypeRegisteredSetter & {
@ -18,6 +20,7 @@ export interface IPublicApiSetters {
/** /**
* setter * setter
* register a setter
* @param typeOrMaps * @param typeOrMaps
* @param setter * @param setter
* @returns * @returns

View File

@ -4,38 +4,48 @@ import { IPublicModelNode } from '../model';
export interface IPublicApiSimulatorHost { export interface IPublicApiSimulatorHost {
/** /**
* contentWindow * contentWindow
* @experimental unstable api, pay extra caution when trying to use it
*/ */
get contentWindow(): Window | undefined; get contentWindow(): Window | undefined;
/** /**
* contentDocument * contentDocument
* @experimental unstable api, pay extra caution when trying to use it
*/ */
get contentDocument(): Document | undefined; get contentDocument(): Document | undefined;
/**
* @experimental unstable api, pay extra caution when trying to use it
*/
get renderer(): any; get renderer(): any;
/** /**
* host * locale
* set config for simulator host, eg. device locale and so on.
* @param key * @param key
* @param value * @param value
*/ */
set(key: string, value: any): void; set(key: string, value: any): void;
/** /**
* host * locale
* set config value by key
* @param key * @param key
* @returns * @returns
*/ */
get(key: string): any; get(key: string): any;
/** /**
*
* scroll to specific node * scroll to specific node
* @param node * @param node
* @since v1.1.0
*/ */
scrollToNode(node: IPublicModelNode): void; scrollToNode(node: IPublicModelNode): void;
/** /**
* *
* make simulator render again
*/ */
rerender(): void; rerender(): void;
} }

View File

@ -3,6 +3,7 @@ import { IPublicTypeWidgetBaseConfig } from '../type';
export interface IPublicApiSkeleton { export interface IPublicApiSkeleton {
/** /**
* *
* add a new panel
* @param config * @param config
* @param extraConfig * @param extraConfig
* @returns * @returns
@ -10,83 +11,96 @@ export interface IPublicApiSkeleton {
add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record<string, any>): any; add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record<string, any>): any;
/** /**
* *
* @param config * remove a panel
* @returns * @param config
*/ * @returns
*/
remove(config: IPublicTypeWidgetBaseConfig): number | undefined; remove(config: IPublicTypeWidgetBaseConfig): number | undefined;
/** /**
* * Panel
* show panel by name
* @param name * @param name
*/ */
showPanel(name: string): void; showPanel(name: string): void;
/** /**
* *
* hide panel by name
* @param name * @param name
*/ */
hidePanel(name: string): void; hidePanel(name: string): void;
/** /**
* widget * Widget
* show widget by name
* @param name * @param name
*/ */
showWidget(name: string): void; showWidget(name: string): void;
/** /**
* enable widget * widget
* enable widget by name
* @param name * @param name
*/ */
enableWidget(name: string): void; enableWidget(name: string): void;
/** /**
* widget * widget
* hide widget by name
* @param name * @param name
*/ */
hideWidget(name: string): void; hideWidget(name: string): void;
/** /**
* disable widget * widget
* disable widgetand make it not responding any click event.
* @param name * @param name
*/ */
disableWidget(name: string): void; disableWidget(name: string): void;
/** /**
* Area
* show area * show area
* @param areaName name of area * @param areaName name of area
*/ */
showArea(areaName: string): void; showArea(areaName: string): void;
/** /**
* Area
* hide area * hide area
* @param areaName name of area * @param areaName name of area
*/ */
hideArea(areaName: string): void; hideArea(areaName: string): void;
/** /**
* panel * Panel
* set callback for panel shown event
* @param listener * @param listener
* @returns * @returns
*/ */
onShowPanel(listener: (...args: any[]) => void): () => void; onShowPanel(listener: (...args: any[]) => void): () => void;
/** /**
* panel * Panel
* set callback for panel hidden event
* @param listener * @param listener
* @returns * @returns
*/ */
onHidePanel(listener: (...args: any[]) => void): () => void; onHidePanel(listener: (...args: any[]) => void): () => void;
/** /**
* widget * Widget
* set callback for widget shown event
* @param listener * @param listener
* @returns * @returns
*/ */
onShowWidget(listener: (...args: any[]) => void): () => void; onShowWidget(listener: (...args: any[]) => void): () => void;
/** /**
* widget * Widget
* set callback for widget hidden event
* @param listener * @param listener
* @returns * @returns
*/ */

View File

@ -9,6 +9,7 @@ export interface IPublicModelDetecting {
/** /**
* hover * hover
* @since v1.0.16
*/ */
get current(): any; get current(): any;
@ -29,5 +30,10 @@ export interface IPublicModelDetecting {
*/ */
leave(): any; leave(): any;
/**
* hover
* set callback which will be called when hovering object changed.
* @since v1.1.0
*/
onDetectingChange(fn: (node: IPublicModelNode) => void): () => void; onDetectingChange(fn: (node: IPublicModelNode) => void): () => void;
} }

View File

@ -4,12 +4,14 @@ import { IPublicModelDragObject, IPublicModelLocateEvent, IPublicModelNode } fro
export interface IPublicModelDragon { export interface IPublicModelDragon {
/** /**
*
* is dragging or not * is dragging or not
*/ */
get dragging(): boolean; get dragging(): boolean;
/** /**
* dragstart * dragstart
* bind a callback function which will be called on dragging start
* @param func * @param func
* @returns * @returns
*/ */
@ -17,6 +19,7 @@ export interface IPublicModelDragon {
/** /**
* drag * drag
* bind a callback function which will be called on dragging
* @param func * @param func
* @returns * @returns
*/ */
@ -24,6 +27,7 @@ export interface IPublicModelDragon {
/** /**
* dragend * dragend
* bind a callback function which will be called on dragging end
* @param func * @param func
* @returns * @returns
*/ */
@ -32,13 +36,17 @@ export interface IPublicModelDragon {
/** /**
* shell boost * shell boost
* set a html element as shell to dragon as monitoring target, and
* set boost function which is used to transform a MouseEvent to type
* IPublicTypeDragNodeDataObject.
* @param shell * @param shell
* @param boost * @param boost
*/ */
from(shell: Element, boost: (e: MouseEvent) => IPublicTypeDragNodeDataObject | null): any; from(shell: Element, boost: (e: MouseEvent) => IPublicTypeDragNodeDataObject | null): any;
/** /**
* boost your dragObject for dragging(flying) *
* boost your dragObject for dragging(flying)
* *
* @param dragObject * @param dragObject
* @param boostEvent * @param boostEvent
@ -47,11 +55,13 @@ export interface IPublicModelDragon {
/** /**
* *
* add sensor area
*/ */
addSensor(sensor: any): void; addSensor(sensor: any): void;
/** /**
* *
* remove sensor area
*/ */
removeSensor(sensor: any): void; removeSensor(sensor: any): void;
} }

View File

@ -1,9 +1,10 @@
import { IPreference } from '../../engine-config'; import { IPublicModelPreference } from './';
export interface IPublicModelEngineConfig { export interface IPublicModelEngineConfig {
/** /**
* key * key
* check if config has certain key configed
* @param key * @param key
* @returns * @returns
*/ */
@ -11,6 +12,7 @@ export interface IPublicModelEngineConfig {
/** /**
* key * key
* get value by key
* @param key * @param key
* @param defaultValue * @param defaultValue
* @returns * @returns
@ -19,6 +21,7 @@ export interface IPublicModelEngineConfig {
/** /**
* key * key
* set value for certain key
* @param key * @param key
* @param value * @param value
*/ */
@ -26,6 +29,7 @@ export interface IPublicModelEngineConfig {
/** /**
* set * set
* set multiple config key-values
* @param config * @param config
*/ */
setConfig(config: { [key: string]: any }): void; setConfig(config: { [key: string]: any }): void;
@ -33,6 +37,8 @@ export interface IPublicModelEngineConfig {
/** /**
* key * key
* Promise fullfill * Promise fullfill
* wait until value of certain key is set, will only be
* triggered once.
* @param key * @param key
* @returns * @returns
*/ */
@ -40,6 +46,8 @@ export interface IPublicModelEngineConfig {
/** /**
* key * key
* set callback for event of value set for some key
* this will be called each time the value is set
* @param key * @param key
* @param fn * @param fn
* @returns * @returns
@ -48,7 +56,10 @@ export interface IPublicModelEngineConfig {
/** /**
* Preference, Preference Panel * Preference, Preference Panel
* @returns IPreference * get global user preference manager, which can be use to store
* user`s preference in user localstorage, such as a panel is pinned or not.
* @returns {IPublicModelPreference}
* @since v1.1.0
*/ */
getPreference(): IPreference; getPreference(): IPublicModelPreference;
} }

View File

@ -25,3 +25,4 @@ export * from './plugin-context';
export * from './setting-target'; export * from './setting-target';
export * from './engine-config'; export * from './engine-config';
export * from './editor'; export * from './editor';
export * from './preference';

View File

@ -0,0 +1,17 @@
export interface IPublicModelPreference {
/**
* set value from local storage by module and key
*/
set(key: string, value: any, module?: string): void;
/**
* get value from local storage by module and key
*/
get(key: string, module: string): any;
/**
* check if local storage contain certain key
*/
contains(key: string, module: string): boolean;
}

View File

@ -59,9 +59,15 @@ export interface IPublicModelSelection {
* for example: * for example:
* getNodes() returns [A, subA, B], then * getNodes() returns [A, subA, B], then
* getTopNodes() will return [A, B], subA will be removed * getTopNodes() will return [A, B], subA will be removed
* @since v1.0.16
* @returns * @returns
*/ */
getTopNodes(includeRoot?: boolean): IPublicModelNode[]; getTopNodes(includeRoot?: boolean): IPublicModelNode[];
/**
* selection
* set callback which will be called when selection is changed
* @since v1.1.0
*/
onSelectionChange(fn: (ids: string[]) => void): () => void; onSelectionChange(fn: (ids: string[]) => void): () => void;
} }

View File

@ -72,3 +72,4 @@ export * from './setter-config';
export * from './tip-config'; export * from './tip-config';
export * from './widget-config-area'; export * from './widget-config-area';
export * from './hotkey-callback'; export * from './hotkey-callback';
export * from './plugin-register-options';

View File

@ -0,0 +1,13 @@
export interface IPublicTypePluginRegisterOptions {
/**
* Will enable plugin registered with auto-initialization immediately
* other than plugin-manager init all plugins at certain time.
* It is helpful when plugin register is later than plugin-manager initialization.
*/
autoInit?: boolean;
/**
* allow overriding existing plugin with same name when override === true
*/
override?: boolean;
}

View File

@ -5,7 +5,7 @@ const { version, name } = package;
const options = { const options = {
method: 'PUT', method: 'PUT',
// 暂时使用 日常环境的 uipaas-node上线后可切换成线上环境 https://uipaas-node.alibaba-inc.com // 暂时使用 日常环境的 uipaas-node上线后可切换成线上环境 https://uipaas-node.alibaba-inc.com
hostname: 'uipaas-node.alibaba.net', hostname: 'uipaas-node.alibaba-inc.com',
path: '/staticAssets/cdn/packages', path: '/staticAssets/cdn/packages',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',