mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-12 08:58:15 +00:00
Compare commits
22 Commits
v1.3.2-bet
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6305c2284 | ||
|
|
2892a01d29 | ||
|
|
bd85ca3ca6 | ||
|
|
44beb2a25a | ||
|
|
86d50e0946 | ||
|
|
19eb917259 | ||
|
|
501ad872c4 | ||
|
|
76b2a05049 | ||
|
|
5657d9c084 | ||
|
|
5b46d96df7 | ||
|
|
24393211b4 | ||
|
|
de95b87b1e | ||
|
|
43921cea2d | ||
|
|
557a462b9f | ||
|
|
80bb7102b6 | ||
|
|
ed7befbff0 | ||
|
|
e3a19896d7 | ||
|
|
dfe6878028 | ||
|
|
6e89d4d605 | ||
|
|
739572172a | ||
|
|
b97570f10c | ||
|
|
b29c53901e |
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# These owners will be the default owners for everything in
|
# These owners will be the default owners for everything in
|
||||||
# the repo. Unless a later match takes precedence
|
# the repo. Unless a later match takes precedence
|
||||||
* @liujuping @JackLian
|
* @liujuping @1ncounter
|
||||||
|
|
||||||
/modules/material-parser @akirakai
|
/modules/material-parser @akirakai
|
||||||
/modules/code-generator @qingniaotonghua
|
/modules/code-generator @qingniaotonghua
|
||||||
|
|||||||
2
.github/workflows/publish engine.yml
vendored
2
.github/workflows/publish engine.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: >-
|
if: >-
|
||||||
contains(github.ref, 'refs/heads/release/') &&
|
contains(github.ref, 'refs/heads/release/') &&
|
||||||
(github.actor == 'JackLian' || github.actor == 'liujuping')
|
(github.actor == '1ncounter' || github.actor == 'liujuping')
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
|
|||||||
16
.github/workflows/test packages.yml
vendored
16
.github/workflows/test packages.yml
vendored
@ -122,3 +122,19 @@ jobs:
|
|||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
run: cd packages/editor-core && npm test
|
run: cd packages/editor-core && npm test
|
||||||
|
|
||||||
|
test-plugin-command:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
|
||||||
|
- name: install
|
||||||
|
run: npm i && npm run setup:skip-build
|
||||||
|
|
||||||
|
- name: test
|
||||||
|
run: cd packages/plugin-command && npm test
|
||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: canvas - 画布 API
|
title: canvas - 画布 API
|
||||||
sidebar_position: 12
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
> **@types** [IPublicApiCanvas](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/canvas.ts)<br/>
|
> **@types** [IPublicApiCanvas](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/canvas.ts)<br/>
|
||||||
|
|||||||
101
docs/docs/api/command.md
Normal file
101
docs/docs/api/command.md
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
---
|
||||||
|
title: command - 指令 API
|
||||||
|
sidebar_position: 10
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 模块概览
|
||||||
|
|
||||||
|
该模块使得与命令系统的交互成为可能,提供了一种全面的方式来处理、执行和管理应用程序中的命令。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 接口
|
||||||
|
|
||||||
|
### IPublicApiCommand
|
||||||
|
|
||||||
|
与命令交互的接口。它提供了注册、注销、执行和管理命令的方法。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 方法
|
||||||
|
|
||||||
|
### registerCommand
|
||||||
|
|
||||||
|
注册一个新命令及其处理函数。
|
||||||
|
|
||||||
|
```
|
||||||
|
typescriptCopy code
|
||||||
|
/**
|
||||||
|
* 注册一个新的命令及其处理程序。
|
||||||
|
* @param command {IPublicTypeCommand} - 要注册的命令。
|
||||||
|
*/
|
||||||
|
registerCommand(command: IPublicTypeCommand): void;
|
||||||
|
```
|
||||||
|
|
||||||
|
### unregisterCommand
|
||||||
|
|
||||||
|
注销一个已存在的命令。
|
||||||
|
|
||||||
|
```
|
||||||
|
typescriptCopy code
|
||||||
|
/**
|
||||||
|
* 注销一个已存在的命令。
|
||||||
|
* @param name {string} - 要注销的命令的名称。
|
||||||
|
*/
|
||||||
|
unregisterCommand(name: string): void;
|
||||||
|
```
|
||||||
|
|
||||||
|
### executeCommand
|
||||||
|
|
||||||
|
根据名称和提供的参数执行命令,确保参数符合命令的定义。
|
||||||
|
|
||||||
|
```
|
||||||
|
typescriptCopy code
|
||||||
|
/**
|
||||||
|
* 根据名称和提供的参数执行命令。
|
||||||
|
* @param name {string} - 要执行的命令的名称。
|
||||||
|
* @param args {IPublicTypeCommandHandlerArgs} - 命令的参数。
|
||||||
|
*/
|
||||||
|
executeCommand(name: string, args?: IPublicTypeCommandHandlerArgs): void;
|
||||||
|
```
|
||||||
|
|
||||||
|
### batchExecuteCommand
|
||||||
|
|
||||||
|
批量执行命令,在所有命令执行后进行重绘,历史记录中只记录一次。
|
||||||
|
|
||||||
|
```
|
||||||
|
typescriptCopy code
|
||||||
|
/**
|
||||||
|
* 批量执行命令,随后进行重绘,历史记录中只记录一次。
|
||||||
|
* @param commands {Array} - 命令对象的数组,包含名称和可选参数。
|
||||||
|
*/
|
||||||
|
batchExecuteCommand(commands: { name: string; args?: IPublicTypeCommandHandlerArgs }[]): void;
|
||||||
|
```
|
||||||
|
|
||||||
|
### listCommands
|
||||||
|
|
||||||
|
列出所有已注册的命令。
|
||||||
|
|
||||||
|
```
|
||||||
|
typescriptCopy code
|
||||||
|
/**
|
||||||
|
* 列出所有已注册的命令。
|
||||||
|
* @returns {IPublicTypeListCommand[]} - 已注册命令的数组。
|
||||||
|
*/
|
||||||
|
listCommands(): IPublicTypeListCommand[];
|
||||||
|
```
|
||||||
|
|
||||||
|
### onCommandError
|
||||||
|
|
||||||
|
为命令执行过程中的错误注册错误处理回调函数。
|
||||||
|
|
||||||
|
```
|
||||||
|
typescriptCopy code
|
||||||
|
/**
|
||||||
|
* 为命令执行过程中的错误注册一个回调函数。
|
||||||
|
* @param callback {(name: string, error: Error) => void} - 错误处理的回调函数。
|
||||||
|
*/
|
||||||
|
onCommandError(callback: (name: string, error: Error) => void): void;
|
||||||
|
```
|
||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: common - 通用 API
|
title: common - 通用 API
|
||||||
sidebar_position: 11
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
> **@types** [IPublicApiCommon](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/common.ts)<br/>
|
> **@types** [IPublicApiCommon](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/common.ts)<br/>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: commonUI - UI 组件库
|
title: commonUI - UI 组件库
|
||||||
sidebar_position: 11
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
## 简介
|
## 简介
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: config - 配置 API
|
title: config - 配置 API
|
||||||
sidebar_position: 8
|
sidebar_position: 5
|
||||||
---
|
---
|
||||||
|
|
||||||
> **@types** [IPublicModelEngineConfig](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/engine-config.ts)<br/>
|
> **@types** [IPublicModelEngineConfig](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/engine-config.ts)<br/>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: config options - 配置列表
|
title: config options - 配置列表
|
||||||
sidebar_position: 13
|
sidebar_position: 5
|
||||||
---
|
---
|
||||||
|
|
||||||
> **@types** [IPublicTypeEngineOptions](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/engine-options.ts)<br/>
|
> **@types** [IPublicTypeEngineOptions](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/engine-options.ts)<br/>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: event - 事件 API
|
title: event - 事件 API
|
||||||
sidebar_position: 7
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
> **@types** [IPublicApiEvent](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/event.ts)<br/>
|
> **@types** [IPublicApiEvent](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/event.ts)<br/>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: hotkey - 快捷键 API
|
title: hotkey - 快捷键 API
|
||||||
sidebar_position: 5
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
> **@types** [IPublicApiHotkey](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/hotkey.ts)<br/>
|
> **@types** [IPublicApiHotkey](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/hotkey.ts)<br/>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: init - 初始化 API
|
title: init - 初始化 API
|
||||||
sidebar_position: 10
|
sidebar_position: 0
|
||||||
---
|
---
|
||||||
|
|
||||||
> **@since** v1.0.0
|
> **@since** v1.0.0
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: logger - 日志 API
|
title: logger - 日志 API
|
||||||
sidebar_position: 9
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
> **@types** [IPublicApiLogger](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/logger.ts)<br/>
|
> **@types** [IPublicApiLogger](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/logger.ts)<br/>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: material - 物料 API
|
title: material - 物料 API
|
||||||
sidebar_position: 2
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
> **@types** [IPublicApiMaterial](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/material.ts)<br/>
|
> **@types** [IPublicApiMaterial](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/material.ts)<br/>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"label": "模型定义 Models",
|
"label": "模型定义 Models",
|
||||||
"position": 14,
|
"position": 100,
|
||||||
"collapsed": false,
|
"collapsed": false,
|
||||||
"collapsible": true
|
"collapsible": true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: plugins - 插件 API
|
title: plugins - 插件 API
|
||||||
sidebar_position: 4
|
sidebar_position: 2
|
||||||
---
|
---
|
||||||
> **@types** [IPublicApiPlugins](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/plugins.ts)<br/>
|
> **@types** [IPublicApiPlugins](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/plugins.ts)<br/>
|
||||||
> **@since** v1.0.0
|
> **@since** v1.0.0
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: project - 模型 API
|
title: project - 模型 API
|
||||||
sidebar_position: 3
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
## 模块简介
|
## 模块简介
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: setters - 设置器 API
|
title: setters - 设置器 API
|
||||||
sidebar_position: 6
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
> **@types** [IPublicApiSetters](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/setters.ts)<br/>
|
> **@types** [IPublicApiSetters](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/setters.ts)<br/>
|
||||||
> **@since** v1.0.0
|
> **@since** v1.0.0
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: simulatorHost - 模拟器 API
|
title: simulatorHost - 模拟器 API
|
||||||
sidebar_position: 3
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
> **@types** [IPublicApiSimulatorHost](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/simulator-host.ts)<br/>
|
> **@types** [IPublicApiSimulatorHost](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/simulator-host.ts)<br/>
|
||||||
> **@since** v1.0.0
|
> **@since** v1.0.0
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: skeleton - 面板 API
|
title: skeleton - 面板 API
|
||||||
sidebar_position: 1
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
> **@types** [IPublicApiSkeleton](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/skeleton.ts)<br/>
|
> **@types** [IPublicApiSkeleton](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/skeleton.ts)<br/>
|
||||||
> **@since** v1.0.0
|
> **@since** v1.0.0
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: workspace - 应用级 API
|
title: workspace - 应用级 API
|
||||||
sidebar_position: 12
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
> **[@experimental](./#experimental)**<br/>
|
> **[@experimental](./#experimental)**<br/>
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
title: 3. 如何通过按钮展示/隐藏弹窗
|
title: 3. 如何通过按钮展示/隐藏弹窗
|
||||||
sidebar_position: 1
|
sidebar_position: 1
|
||||||
---
|
---
|
||||||
|
> 说明:这个方式依赖低代码弹窗组件是否对外保留了相关的 API,不同的物料支持的方式不一样,这里只针对综合场景的弹窗物料。
|
||||||
|
|
||||||
## 1.拖拽一个按钮
|
## 1.拖拽一个按钮
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-engine-docs",
|
"name": "@alilc/lowcode-engine-docs",
|
||||||
"version": "1.2.29",
|
"version": "1.2.31",
|
||||||
"description": "低代码引擎版本化文档",
|
"description": "低代码引擎版本化文档",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"lerna": "4.0.0",
|
"lerna": "4.0.0",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"useWorkspaces": true,
|
"useWorkspaces": true,
|
||||||
"packages": [
|
"packages": [
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-designer",
|
"name": "@alilc/lowcode-designer",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "Designer for Ali LowCode Engine",
|
"description": "Designer for Ali LowCode Engine",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
@ -15,9 +15,9 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alilc/lowcode-editor-core": "1.3.1",
|
"@alilc/lowcode-editor-core": "1.3.2",
|
||||||
"@alilc/lowcode-types": "1.3.1",
|
"@alilc/lowcode-types": "1.3.2",
|
||||||
"@alilc/lowcode-utils": "1.3.1",
|
"@alilc/lowcode-utils": "1.3.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"react": "^16",
|
"react": "^16",
|
||||||
"react-dom": "^16.7.0",
|
"react-dom": "^16.7.0",
|
||||||
|
|||||||
@ -70,7 +70,7 @@ export class Transducer {
|
|||||||
}
|
}
|
||||||
if (isDynamicSetter(setter) && isDynamic) {
|
if (isDynamicSetter(setter) && isDynamic) {
|
||||||
try {
|
try {
|
||||||
setter = setter.call(context, context);
|
setter = setter.call(context.internalToShellField(), context.internalToShellField());
|
||||||
} catch (e) { console.error(e); }
|
} catch (e) { console.error(e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -353,7 +353,6 @@ export class Prop implements IProp, IPropParent {
|
|||||||
@action
|
@action
|
||||||
setValue(val: IPublicTypeCompositeValue) {
|
setValue(val: IPublicTypeCompositeValue) {
|
||||||
if (val === this._value) return;
|
if (val === this._value) return;
|
||||||
const editor = this.owner.document?.designer.editor;
|
|
||||||
const oldValue = this._value;
|
const oldValue = this._value;
|
||||||
this._value = val;
|
this._value = val;
|
||||||
this._code = null;
|
this._code = null;
|
||||||
@ -386,11 +385,21 @@ export class Prop implements IProp, IPropParent {
|
|||||||
this.setupItems();
|
this.setupItems();
|
||||||
|
|
||||||
if (oldValue !== this._value) {
|
if (oldValue !== this._value) {
|
||||||
|
this.emitChange({ oldValue });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emitChange = ({
|
||||||
|
oldValue,
|
||||||
|
}: {
|
||||||
|
oldValue: IPublicTypeCompositeValue | UNSET;
|
||||||
|
}) => {
|
||||||
|
const editor = this.owner.document?.designer.editor;
|
||||||
const propsInfo = {
|
const propsInfo = {
|
||||||
key: this.key,
|
key: this.key,
|
||||||
prop: this,
|
prop: this,
|
||||||
oldValue,
|
oldValue,
|
||||||
newValue: this._value,
|
newValue: this.type === 'unset' ? undefined : this._value,
|
||||||
};
|
};
|
||||||
|
|
||||||
editor?.eventBus.emit(GlobalEvent.Node.Prop.InnerChange, {
|
editor?.eventBus.emit(GlobalEvent.Node.Prop.InnerChange, {
|
||||||
@ -399,8 +408,7 @@ export class Prop implements IProp, IPropParent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.owner?.emitPropChange?.(propsInfo);
|
this.owner?.emitPropChange?.(propsInfo);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
getValue(): IPublicTypeCompositeValue {
|
getValue(): IPublicTypeCompositeValue {
|
||||||
return this.export(IPublicEnumTransformStage.Serilize);
|
return this.export(IPublicEnumTransformStage.Serilize);
|
||||||
@ -462,7 +470,12 @@ export class Prop implements IProp, IPropParent {
|
|||||||
*/
|
*/
|
||||||
@action
|
@action
|
||||||
unset() {
|
unset() {
|
||||||
|
if (this._type !== 'unset') {
|
||||||
this._type = 'unset';
|
this._type = 'unset';
|
||||||
|
this.emitChange({
|
||||||
|
oldValue: this._value,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -557,6 +570,7 @@ export class Prop implements IProp, IPropParent {
|
|||||||
@action
|
@action
|
||||||
remove() {
|
remove() {
|
||||||
this.parent.delete(this);
|
this.parent.delete(this);
|
||||||
|
this.unset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { Editor, engineConfig } from '@alilc/lowcode-editor-core';
|
|||||||
import { Designer } from '../../../../src/designer/designer';
|
import { Designer } from '../../../../src/designer/designer';
|
||||||
import { DocumentModel } from '../../../../src/document/document-model';
|
import { DocumentModel } from '../../../../src/document/document-model';
|
||||||
import { Prop, isProp, isValidArrayIndex } from '../../../../src/document/node/props/prop';
|
import { Prop, isProp, isValidArrayIndex } from '../../../../src/document/node/props/prop';
|
||||||
import { IPublicEnumTransformStage } from '@alilc/lowcode-types';
|
import { GlobalEvent, IPublicEnumTransformStage } from '@alilc/lowcode-types';
|
||||||
import { shellModelFactory } from '../../../../../engine/src/modules/shell-model-factory';
|
import { shellModelFactory } from '../../../../../engine/src/modules/shell-model-factory';
|
||||||
|
|
||||||
const slotNodeImportMockFn = jest.fn();
|
const slotNodeImportMockFn = jest.fn();
|
||||||
@ -24,14 +24,24 @@ const mockOwner = {
|
|||||||
remove: slotNodeRemoveMockFn,
|
remove: slotNodeRemoveMockFn,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
designer: {},
|
designer: {
|
||||||
|
editor: {
|
||||||
|
eventBus: {
|
||||||
|
emit: jest.fn(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
isInited: true,
|
isInited: true,
|
||||||
|
emitPropChange: jest.fn(),
|
||||||
|
delete() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockPropsInst = {
|
const mockPropsInst = {
|
||||||
owner: mockOwner,
|
owner: mockOwner,
|
||||||
|
delete() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
mockPropsInst.props = mockPropsInst;
|
mockPropsInst.props = mockPropsInst;
|
||||||
|
|
||||||
describe('Prop 类测试', () => {
|
describe('Prop 类测试', () => {
|
||||||
@ -564,3 +574,124 @@ describe('其他导出函数', () => {
|
|||||||
expect(isValidArrayIndex('2', 1)).toBeFalsy();
|
expect(isValidArrayIndex('2', 1)).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('setValue with event', () => {
|
||||||
|
let propInstance;
|
||||||
|
let mockEmitChange;
|
||||||
|
let mockEventBusEmit;
|
||||||
|
let mockEmitPropChange;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// Initialize the instance of your class
|
||||||
|
propInstance = new Prop(mockPropsInst, true, 'stringProp');;
|
||||||
|
|
||||||
|
// Mock necessary methods and properties
|
||||||
|
mockEmitChange = jest.spyOn(propInstance, 'emitChange');
|
||||||
|
propInstance.owner = {
|
||||||
|
document: {
|
||||||
|
designer: {
|
||||||
|
editor: {
|
||||||
|
eventBus: {
|
||||||
|
emit: jest.fn(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
emitPropChange: jest.fn(),
|
||||||
|
delete() {},
|
||||||
|
};
|
||||||
|
mockEventBusEmit = jest.spyOn(propInstance.owner.document.designer.editor.eventBus, 'emit');
|
||||||
|
mockEmitPropChange = jest.spyOn(propInstance.owner, 'emitPropChange');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should correctly handle string values and emit changes', () => {
|
||||||
|
const oldValue = propInstance._value;
|
||||||
|
const newValue = 'new string value';
|
||||||
|
|
||||||
|
propInstance.setValue(newValue);
|
||||||
|
|
||||||
|
const expectedPartialPropsInfo = expect.objectContaining({
|
||||||
|
key: propInstance.key,
|
||||||
|
newValue, // You can specifically test only certain keys
|
||||||
|
oldValue,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(propInstance.getValue()).toBe(newValue);
|
||||||
|
expect(propInstance.type).toBe('literal');
|
||||||
|
expect(mockEmitChange).toHaveBeenCalledWith({ oldValue });
|
||||||
|
expect(mockEventBusEmit).toHaveBeenCalledWith(GlobalEvent.Node.Prop.InnerChange, expectedPartialPropsInfo);
|
||||||
|
expect(mockEmitPropChange).toHaveBeenCalledWith(expectedPartialPropsInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle object values and set type to map', () => {
|
||||||
|
const oldValue = propInstance._value;
|
||||||
|
const newValue = 234;
|
||||||
|
|
||||||
|
const expectedPartialPropsInfo = expect.objectContaining({
|
||||||
|
key: propInstance.key,
|
||||||
|
newValue, // You can specifically test only certain keys
|
||||||
|
oldValue,
|
||||||
|
});
|
||||||
|
|
||||||
|
propInstance.setValue(newValue);
|
||||||
|
|
||||||
|
expect(propInstance.getValue()).toEqual(newValue);
|
||||||
|
expect(propInstance.type).toBe('literal');
|
||||||
|
expect(mockEmitChange).toHaveBeenCalledWith({ oldValue });
|
||||||
|
expect(mockEventBusEmit).toHaveBeenCalledWith(GlobalEvent.Node.Prop.InnerChange, expectedPartialPropsInfo);
|
||||||
|
expect(mockEmitPropChange).toHaveBeenCalledWith(expectedPartialPropsInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should has event when unset call', () => {
|
||||||
|
const oldValue = propInstance._value;
|
||||||
|
|
||||||
|
propInstance.unset();
|
||||||
|
|
||||||
|
const expectedPartialPropsInfo = expect.objectContaining({
|
||||||
|
key: propInstance.key,
|
||||||
|
newValue: undefined, // You can specifically test only certain keys
|
||||||
|
oldValue,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(propInstance.getValue()).toEqual(undefined);
|
||||||
|
expect(propInstance.type).toBe('unset');
|
||||||
|
expect(mockEmitChange).toHaveBeenCalledWith({
|
||||||
|
oldValue,
|
||||||
|
newValue: undefined,
|
||||||
|
});
|
||||||
|
expect(mockEventBusEmit).toHaveBeenCalledWith(GlobalEvent.Node.Prop.InnerChange, expectedPartialPropsInfo);
|
||||||
|
expect(mockEmitPropChange).toHaveBeenCalledWith(expectedPartialPropsInfo);
|
||||||
|
|
||||||
|
propInstance.unset();
|
||||||
|
expect(mockEmitChange).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
// remove
|
||||||
|
it('should has event when remove call', () => {
|
||||||
|
const oldValue = propInstance._value;
|
||||||
|
|
||||||
|
propInstance.remove();
|
||||||
|
|
||||||
|
const expectedPartialPropsInfo = expect.objectContaining({
|
||||||
|
key: propInstance.key,
|
||||||
|
newValue: undefined, // You can specifically test only certain keys
|
||||||
|
oldValue,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(propInstance.getValue()).toEqual(undefined);
|
||||||
|
// expect(propInstance.type).toBe('unset');
|
||||||
|
expect(mockEmitChange).toHaveBeenCalledWith({
|
||||||
|
oldValue,
|
||||||
|
newValue: undefined,
|
||||||
|
});
|
||||||
|
expect(mockEventBusEmit).toHaveBeenCalledWith(GlobalEvent.Node.Prop.InnerChange, expectedPartialPropsInfo);
|
||||||
|
expect(mockEmitPropChange).toHaveBeenCalledWith(expectedPartialPropsInfo);
|
||||||
|
|
||||||
|
propInstance.remove();
|
||||||
|
expect(mockEmitChange).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-editor-core",
|
"name": "@alilc/lowcode-editor-core",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "Core Api for Ali lowCode engine",
|
"description": "Core Api for Ali lowCode engine",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
@ -16,8 +16,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alifd/next": "^1.19.16",
|
"@alifd/next": "^1.19.16",
|
||||||
"@alilc/lowcode-types": "1.3.1",
|
"@alilc/lowcode-types": "1.3.2",
|
||||||
"@alilc/lowcode-utils": "1.3.1",
|
"@alilc/lowcode-utils": "1.3.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"intl-messageformat": "^9.3.1",
|
"intl-messageformat": "^9.3.1",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { IPublicApiSetters, IPublicTypeCustomView, IPublicTypeRegisteredSetter } from '@alilc/lowcode-types';
|
import { IPublicApiSetters, IPublicModelSettingField, IPublicTypeCustomView, IPublicTypeRegisteredSetter } from '@alilc/lowcode-types';
|
||||||
import { createContent, isCustomView } from '@alilc/lowcode-utils';
|
import { createContent, isCustomView } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
const settersMap = new Map<string, IPublicTypeRegisteredSetter & {
|
const settersMap = new Map<string, IPublicTypeRegisteredSetter & {
|
||||||
@ -28,7 +28,7 @@ export function registerSetter(
|
|||||||
if (!setter.initialValue) {
|
if (!setter.initialValue) {
|
||||||
const initial = getInitialFromSetter(setter.component);
|
const initial = getInitialFromSetter(setter.component);
|
||||||
if (initial) {
|
if (initial) {
|
||||||
setter.initialValue = (field: any) => {
|
setter.initialValue = (field: IPublicModelSettingField) => {
|
||||||
return initial.call(field, field.getValue());
|
return initial.call(field, field.getValue());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ export class Setters implements ISetters {
|
|||||||
if (!setter.initialValue) {
|
if (!setter.initialValue) {
|
||||||
const initial = getInitialFromSetter(setter.component);
|
const initial = getInitialFromSetter(setter.component);
|
||||||
if (initial) {
|
if (initial) {
|
||||||
setter.initialValue = (field: any) => {
|
setter.initialValue = (field: IPublicModelSettingField) => {
|
||||||
return initial.call(field, field.getValue());
|
return initial.call(field, field.getValue());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-editor-skeleton",
|
"name": "@alilc/lowcode-editor-skeleton",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "alibaba lowcode editor skeleton",
|
"description": "alibaba lowcode editor skeleton",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
@ -19,10 +19,10 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alifd/next": "^1.20.12",
|
"@alifd/next": "^1.20.12",
|
||||||
"@alilc/lowcode-designer": "1.3.1",
|
"@alilc/lowcode-designer": "1.3.2",
|
||||||
"@alilc/lowcode-editor-core": "1.3.1",
|
"@alilc/lowcode-editor-core": "1.3.2",
|
||||||
"@alilc/lowcode-types": "1.3.1",
|
"@alilc/lowcode-types": "1.3.2",
|
||||||
"@alilc/lowcode-utils": "1.3.1",
|
"@alilc/lowcode-utils": "1.3.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"react": "^16.8.1",
|
"react": "^16.8.1",
|
||||||
"react-dom": "^16.8.1"
|
"react-dom": "^16.8.1"
|
||||||
|
|||||||
@ -225,7 +225,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
|
|||||||
|
|
||||||
const value = this.value;
|
const value = this.value;
|
||||||
|
|
||||||
let _onChange = extraProps?.onChange;
|
let onChangeAPI = extraProps?.onChange;
|
||||||
let stageName = this.stageName;
|
let stageName = this.stageName;
|
||||||
|
|
||||||
return createField(
|
return createField(
|
||||||
@ -261,7 +261,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
|
|||||||
value,
|
value,
|
||||||
});
|
});
|
||||||
field.setValue(value, true);
|
field.setValue(value, true);
|
||||||
if (_onChange) _onChange(value, field);
|
if (onChangeAPI) onChangeAPI(value, field.internalToShellField());
|
||||||
},
|
},
|
||||||
onInitial: () => {
|
onInitial: () => {
|
||||||
if (initialValue == null) {
|
if (initialValue == null) {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import {
|
|||||||
IPublicTypeTransformedComponentMetadata,
|
IPublicTypeTransformedComponentMetadata,
|
||||||
IPublicTypeOneOfType,
|
IPublicTypeOneOfType,
|
||||||
ConfigureSupportEvent,
|
ConfigureSupportEvent,
|
||||||
|
IPublicModelSettingField,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
|
|
||||||
function propConfigToFieldConfig(propConfig: IPublicTypePropConfig): IPublicTypeFieldConfig {
|
function propConfigToFieldConfig(propConfig: IPublicTypePropConfig): IPublicTypeFieldConfig {
|
||||||
@ -102,7 +103,7 @@ function propTypeToSetter(propType: IPublicTypePropType): IPublicTypeSetterType
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
isRequired,
|
isRequired,
|
||||||
initialValue: (field: any) => {
|
initialValue: (field: IPublicModelSettingField) => {
|
||||||
const data: any = {};
|
const data: any = {};
|
||||||
items.forEach((item: any) => {
|
items.forEach((item: any) => {
|
||||||
let initial = item.defaultValue;
|
let initial = item.defaultValue;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-engine",
|
"name": "@alilc/lowcode-engine",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系",
|
"description": "An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系",
|
||||||
"main": "lib/engine-core.js",
|
"main": "lib/engine-core.js",
|
||||||
"module": "es/engine-core.js",
|
"module": "es/engine-core.js",
|
||||||
@ -19,15 +19,16 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alifd/next": "^1.19.12",
|
"@alifd/next": "^1.19.12",
|
||||||
"@alilc/lowcode-designer": "1.3.1",
|
"@alilc/lowcode-designer": "1.3.2",
|
||||||
"@alilc/lowcode-editor-core": "1.3.1",
|
"@alilc/lowcode-editor-core": "1.3.2",
|
||||||
"@alilc/lowcode-editor-skeleton": "1.3.1",
|
"@alilc/lowcode-editor-skeleton": "1.3.2",
|
||||||
"@alilc/lowcode-engine-ext": "^1.0.0",
|
"@alilc/lowcode-engine-ext": "^1.0.0",
|
||||||
"@alilc/lowcode-plugin-designer": "1.3.1",
|
"@alilc/lowcode-plugin-command": "1.3.2",
|
||||||
"@alilc/lowcode-plugin-outline-pane": "1.3.1",
|
"@alilc/lowcode-plugin-designer": "1.3.2",
|
||||||
"@alilc/lowcode-shell": "1.3.1",
|
"@alilc/lowcode-plugin-outline-pane": "1.3.2",
|
||||||
"@alilc/lowcode-utils": "1.3.1",
|
"@alilc/lowcode-shell": "1.3.2",
|
||||||
"@alilc/lowcode-workspace": "1.3.1",
|
"@alilc/lowcode-utils": "1.3.2",
|
||||||
|
"@alilc/lowcode-workspace": "1.3.2",
|
||||||
"react": "^16.8.1",
|
"react": "^16.8.1",
|
||||||
"react-dom": "^16.8.1"
|
"react-dom": "^16.8.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -66,7 +66,7 @@ import { defaultPanelRegistry } from './inner-plugins/default-panel-registry';
|
|||||||
import { shellModelFactory } from './modules/shell-model-factory';
|
import { shellModelFactory } from './modules/shell-model-factory';
|
||||||
import { builtinHotkey } from './inner-plugins/builtin-hotkey';
|
import { builtinHotkey } from './inner-plugins/builtin-hotkey';
|
||||||
import { defaultContextMenu } from './inner-plugins/default-context-menu';
|
import { defaultContextMenu } from './inner-plugins/default-context-menu';
|
||||||
import { defaultCommand } from './inner-plugins/default-command';
|
import { CommandPlugin } from '@alilc/lowcode-plugin-command';
|
||||||
import { OutlinePlugin } from '@alilc/lowcode-plugin-outline-pane';
|
import { OutlinePlugin } from '@alilc/lowcode-plugin-outline-pane';
|
||||||
|
|
||||||
export * from './modules/skeleton-types';
|
export * from './modules/skeleton-types';
|
||||||
@ -84,7 +84,7 @@ async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins
|
|||||||
await plugins.register(builtinHotkey);
|
await plugins.register(builtinHotkey);
|
||||||
await plugins.register(registerDefaults, {}, { autoInit: true });
|
await plugins.register(registerDefaults, {}, { autoInit: true });
|
||||||
await plugins.register(defaultContextMenu);
|
await plugins.register(defaultContextMenu);
|
||||||
await plugins.register(defaultCommand, {});
|
await plugins.register(CommandPlugin, {});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
plugins.delete(OutlinePlugin.pluginName);
|
plugins.delete(OutlinePlugin.pluginName);
|
||||||
@ -94,7 +94,7 @@ async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins
|
|||||||
plugins.delete(builtinHotkey.pluginName);
|
plugins.delete(builtinHotkey.pluginName);
|
||||||
plugins.delete(registerDefaults.pluginName);
|
plugins.delete(registerDefaults.pluginName);
|
||||||
plugins.delete(defaultContextMenu.pluginName);
|
plugins.delete(defaultContextMenu.pluginName);
|
||||||
plugins.delete(defaultCommand.pluginName);
|
plugins.delete(CommandPlugin.pluginName);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-ignitor",
|
"name": "@alilc/lowcode-ignitor",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "点火器,bootstrap lce project",
|
"description": "点火器,bootstrap lce project",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
11
packages/plugin-command/README.md
Normal file
11
packages/plugin-command/README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# `@alilc/plugin-command`
|
||||||
|
|
||||||
|
> TODO: description
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
const pluginCommand = require('@alilc/plugin-command');
|
||||||
|
|
||||||
|
// TODO: DEMONSTRATE API
|
||||||
|
```
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { checkPropTypes } from '@alilc/lowcode-utils/src/check-prop-types';
|
import { checkPropTypes } from '@alilc/lowcode-utils/src/check-prop-types';
|
||||||
import { nodeSchemaPropType } from '../../src/inner-plugins/default-command';
|
import { nodeSchemaPropType } from '../src/node-command';
|
||||||
|
|
||||||
describe('nodeSchemaPropType', () => {
|
describe('nodeSchemaPropType', () => {
|
||||||
const componentName = 'NodeComponent';
|
const componentName = 'NodeComponent';
|
||||||
@ -10,8 +10,8 @@ describe('nodeSchemaPropType', () => {
|
|||||||
const invalidId = 123; // Not a string
|
const invalidId = 123; // Not a string
|
||||||
expect(checkPropTypes(validId, 'id', getPropType('id'), componentName)).toBe(true);
|
expect(checkPropTypes(validId, 'id', getPropType('id'), componentName)).toBe(true);
|
||||||
expect(checkPropTypes(invalidId, 'id', getPropType('id'), componentName)).toBe(false);
|
expect(checkPropTypes(invalidId, 'id', getPropType('id'), componentName)).toBe(false);
|
||||||
// isRequired
|
// is not required
|
||||||
expect(checkPropTypes(undefined, 'id', getPropType('id'), componentName)).toBe(false);
|
expect(checkPropTypes(undefined, 'id', getPropType('id'), componentName)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should validate the componentName as a string', () => {
|
it('should validate the componentName as a string', () => {
|
||||||
@ -71,7 +71,7 @@ describe('nodeSchemaPropType', () => {
|
|||||||
const invalidLoop = { type: 'JSExpression', value: 123 }; // Not a string
|
const invalidLoop = { type: 'JSExpression', value: 123 }; // Not a string
|
||||||
expect(checkPropTypes(validLoop, 'loop', getPropType('loop'), componentName)).toBe(true);
|
expect(checkPropTypes(validLoop, 'loop', getPropType('loop'), componentName)).toBe(true);
|
||||||
expect(checkPropTypes(invalidLoop, 'loop', getPropType('loop'), componentName)).toBe(false);
|
expect(checkPropTypes(invalidLoop, 'loop', getPropType('loop'), componentName)).toBe(false);
|
||||||
})
|
});
|
||||||
|
|
||||||
it('should validate the loopArgs as an array', () => {
|
it('should validate the loopArgs as an array', () => {
|
||||||
const validLoopArgs = ['item'];
|
const validLoopArgs = ['item'];
|
||||||
9
packages/plugin-command/build.json
Normal file
9
packages/plugin-command/build.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"@alilc/build-plugin-lce",
|
||||||
|
"build-plugin-fusion",
|
||||||
|
["build-plugin-moment-locales", {
|
||||||
|
"locales": ["zh-cn"]
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
||||||
19
packages/plugin-command/build.test.json
Normal file
19
packages/plugin-command/build.test.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
[
|
||||||
|
"@alilc/build-plugin-lce",
|
||||||
|
{
|
||||||
|
"filename": "editor-preset-vision",
|
||||||
|
"library": "LowcodeEditor",
|
||||||
|
"libraryTarget": "umd",
|
||||||
|
"externals": {
|
||||||
|
"react": "var window.React",
|
||||||
|
"react-dom": "var window.ReactDOM",
|
||||||
|
"prop-types": "var window.PropTypes",
|
||||||
|
"rax": "var window.Rax"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@alilc/lowcode-test-mate/plugin/index.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
22
packages/plugin-command/jest.config.js
Normal file
22
packages/plugin-command/jest.config.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const { join } = require('path');
|
||||||
|
const esModules = [].join('|');
|
||||||
|
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
|
||||||
|
|
||||||
|
const jestConfig = {
|
||||||
|
transformIgnorePatterns: [
|
||||||
|
`/node_modules/(?!${esModules})/`,
|
||||||
|
],
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
|
||||||
|
collectCoverage: true,
|
||||||
|
collectCoverageFrom: [
|
||||||
|
'src/**/*.ts',
|
||||||
|
'src/**/*.tsx',
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
// 只对本仓库内的 pkg 做 mapping
|
||||||
|
jestConfig.moduleNameMapper = {};
|
||||||
|
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';
|
||||||
|
|
||||||
|
module.exports = jestConfig;
|
||||||
39
packages/plugin-command/package.json
Normal file
39
packages/plugin-command/package.json
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "@alilc/lowcode-plugin-command",
|
||||||
|
"version": "1.3.2",
|
||||||
|
"description": "> TODO: description",
|
||||||
|
"author": "liujuping <liujup@foxmail.com>",
|
||||||
|
"homepage": "https://github.com/alibaba/lowcode-engine#readme",
|
||||||
|
"license": "ISC",
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"module": "es/index.js",
|
||||||
|
"directories": {
|
||||||
|
"lib": "lib",
|
||||||
|
"test": "__tests__"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib",
|
||||||
|
"es"
|
||||||
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/alibaba/lowcode-engine.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "build-scripts test --config build.test.json --jest-passWithNoTests",
|
||||||
|
"build": "build-scripts build"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/alibaba/lowcode-engine/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@alilc/lowcode-types": "1.3.2",
|
||||||
|
"@alilc/lowcode-utils": "1.3.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@alib/build-scripts": "^0.1.18"
|
||||||
|
}
|
||||||
|
}
|
||||||
43
packages/plugin-command/src/history-command.ts
Normal file
43
packages/plugin-command/src/history-command.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { IPublicModelPluginContext, IPublicTypePlugin } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
|
export const historyCommand: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => {
|
||||||
|
const { command, project } = ctx;
|
||||||
|
return {
|
||||||
|
init() {
|
||||||
|
command.registerCommand({
|
||||||
|
name: 'undo',
|
||||||
|
description: 'Undo the last operation.',
|
||||||
|
handler: () => {
|
||||||
|
const state = project.currentDocument?.history.getState() || 0;
|
||||||
|
const enable = !!(state & 1);
|
||||||
|
if (!enable) {
|
||||||
|
throw new Error('Can not undo.');
|
||||||
|
}
|
||||||
|
project.currentDocument?.history.back();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
command.registerCommand({
|
||||||
|
name: 'redo',
|
||||||
|
description: 'Redo the last operation.',
|
||||||
|
handler: () => {
|
||||||
|
const state = project.currentDocument?.history.getState() || 0;
|
||||||
|
const enable = !!(state & 2);
|
||||||
|
if (!enable) {
|
||||||
|
throw new Error('Can not redo.');
|
||||||
|
}
|
||||||
|
project.currentDocument?.history.forward();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
destroy() {
|
||||||
|
command.unregisterCommand('history:undo');
|
||||||
|
command.unregisterCommand('history:redo');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
historyCommand.pluginName = '___history_command___';
|
||||||
|
historyCommand.meta = {
|
||||||
|
commandScope: 'history',
|
||||||
|
};
|
||||||
25
packages/plugin-command/src/index.ts
Normal file
25
packages/plugin-command/src/index.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { IPublicModelPluginContext, IPublicTypePlugin } from '@alilc/lowcode-types';
|
||||||
|
import { nodeCommand } from './node-command';
|
||||||
|
import { historyCommand } from './history-command';
|
||||||
|
|
||||||
|
export const CommandPlugin: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => {
|
||||||
|
const { plugins } = ctx;
|
||||||
|
|
||||||
|
return {
|
||||||
|
async init() {
|
||||||
|
await plugins.register(nodeCommand, {}, { autoInit: true });
|
||||||
|
await plugins.register(historyCommand, {}, { autoInit: true });
|
||||||
|
},
|
||||||
|
destroy() {
|
||||||
|
plugins.delete(nodeCommand.pluginName);
|
||||||
|
plugins.delete(historyCommand.pluginName);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
CommandPlugin.pluginName = '___default_command___';
|
||||||
|
CommandPlugin.meta = {
|
||||||
|
commandScope: 'common',
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CommandPlugin;
|
||||||
@ -1,8 +1,4 @@
|
|||||||
import {
|
import { IPublicModelPluginContext, IPublicTypeNodeSchema, IPublicTypePlugin, IPublicTypePropType } from '@alilc/lowcode-types';
|
||||||
IPublicModelPluginContext,
|
|
||||||
IPublicTypeNodeSchema,
|
|
||||||
IPublicTypePropType,
|
|
||||||
} from '@alilc/lowcode-types';
|
|
||||||
import { isNodeSchema } from '@alilc/lowcode-utils';
|
import { isNodeSchema } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
const sampleNodeSchema: IPublicTypePropType = {
|
const sampleNodeSchema: IPublicTypePropType = {
|
||||||
@ -10,10 +6,7 @@ const sampleNodeSchema: IPublicTypePropType = {
|
|||||||
value: [
|
value: [
|
||||||
{
|
{
|
||||||
name: 'id',
|
name: 'id',
|
||||||
propType: {
|
propType: 'string',
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'componentName',
|
name: 'componentName',
|
||||||
@ -229,45 +222,7 @@ export const nodeSchemaPropType: IPublicTypePropType = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const historyCommand = (ctx: IPublicModelPluginContext) => {
|
export const nodeCommand: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => {
|
||||||
const { command, project } = ctx;
|
|
||||||
return {
|
|
||||||
init() {
|
|
||||||
command.registerCommand({
|
|
||||||
name: 'undo',
|
|
||||||
description: 'Undo the last operation.',
|
|
||||||
handler: () => {
|
|
||||||
const state = project.currentDocument?.history.getState() || 0;
|
|
||||||
const enable = !!(state & 1);
|
|
||||||
if (!enable) {
|
|
||||||
throw new Error('Can not undo.');
|
|
||||||
}
|
|
||||||
project.currentDocument?.history.back();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
command.registerCommand({
|
|
||||||
name: 'redo',
|
|
||||||
description: 'Redo the last operation.',
|
|
||||||
handler: () => {
|
|
||||||
const state = project.currentDocument?.history.getState() || 0;
|
|
||||||
const enable = !!(state & 2);
|
|
||||||
if (!enable) {
|
|
||||||
throw new Error('Can not redo.');
|
|
||||||
}
|
|
||||||
project.currentDocument?.history.forward();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
historyCommand.pluginName = '___history_command___';
|
|
||||||
historyCommand.meta = {
|
|
||||||
commandScope: 'history',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const nodeCommand = (ctx: IPublicModelPluginContext) => {
|
|
||||||
const { command, project } = ctx;
|
const { command, project } = ctx;
|
||||||
return {
|
return {
|
||||||
init() {
|
init() {
|
||||||
@ -277,10 +232,12 @@ export const nodeCommand = (ctx: IPublicModelPluginContext) => {
|
|||||||
handler: (param: {
|
handler: (param: {
|
||||||
parentNodeId: string;
|
parentNodeId: string;
|
||||||
nodeSchema: IPublicTypeNodeSchema;
|
nodeSchema: IPublicTypeNodeSchema;
|
||||||
|
index: number;
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
parentNodeId,
|
parentNodeId,
|
||||||
nodeSchema,
|
nodeSchema,
|
||||||
|
index,
|
||||||
} = param;
|
} = param;
|
||||||
const { project } = ctx;
|
const { project } = ctx;
|
||||||
const parentNode = project.currentDocument?.getNodeById(parentNodeId);
|
const parentNode = project.currentDocument?.getNodeById(parentNodeId);
|
||||||
@ -296,7 +253,11 @@ export const nodeCommand = (ctx: IPublicModelPluginContext) => {
|
|||||||
throw new Error('Invalid node.');
|
throw new Error('Invalid node.');
|
||||||
}
|
}
|
||||||
|
|
||||||
project.currentDocument?.insertNode(parentNode, nodeSchema);
|
if (index < 0 || index > (parentNode.children?.size || 0)) {
|
||||||
|
throw new Error(`Invalid index '${index}'.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
project.currentDocument?.insertNode(parentNode, nodeSchema, index);
|
||||||
},
|
},
|
||||||
parameters: [
|
parameters: [
|
||||||
{
|
{
|
||||||
@ -309,6 +270,11 @@ export const nodeCommand = (ctx: IPublicModelPluginContext) => {
|
|||||||
propType: nodeSchemaPropType,
|
propType: nodeSchemaPropType,
|
||||||
description: 'The node to be added.',
|
description: 'The node to be added.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'index',
|
||||||
|
propType: 'number',
|
||||||
|
description: 'The index of the node to be added.',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -326,6 +292,14 @@ export const nodeCommand = (ctx: IPublicModelPluginContext) => {
|
|||||||
index = 0,
|
index = 0,
|
||||||
} = param;
|
} = param;
|
||||||
|
|
||||||
|
if (!nodeId) {
|
||||||
|
throw new Error('Invalid node id.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!targetNodeId) {
|
||||||
|
throw new Error('Invalid target node id.');
|
||||||
|
}
|
||||||
|
|
||||||
const node = project.currentDocument?.getNodeById(nodeId);
|
const node = project.currentDocument?.getNodeById(nodeId);
|
||||||
const targetNode = project.currentDocument?.getNodeById(targetNodeId);
|
const targetNode = project.currentDocument?.getNodeById(targetNodeId);
|
||||||
if (!node) {
|
if (!node) {
|
||||||
@ -350,12 +324,18 @@ export const nodeCommand = (ctx: IPublicModelPluginContext) => {
|
|||||||
parameters: [
|
parameters: [
|
||||||
{
|
{
|
||||||
name: 'nodeId',
|
name: 'nodeId',
|
||||||
propType: 'string',
|
propType: {
|
||||||
|
type: 'string',
|
||||||
|
isRequired: true,
|
||||||
|
},
|
||||||
description: 'The id of the node to be moved.',
|
description: 'The id of the node to be moved.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'targetNodeId',
|
name: 'targetNodeId',
|
||||||
propType: 'string',
|
propType: {
|
||||||
|
type: 'string',
|
||||||
|
isRequired: true,
|
||||||
|
},
|
||||||
description: 'The id of the target node.',
|
description: 'The id of the target node.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -393,8 +373,8 @@ export const nodeCommand = (ctx: IPublicModelPluginContext) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
command.registerCommand({
|
command.registerCommand({
|
||||||
name: 'replace',
|
name: 'update',
|
||||||
description: 'Replace a node with another node.',
|
description: 'Update a node.',
|
||||||
handler(param: {
|
handler(param: {
|
||||||
nodeId: string;
|
nodeId: string;
|
||||||
nodeSchema: IPublicTypeNodeSchema;
|
nodeSchema: IPublicTypeNodeSchema;
|
||||||
@ -419,12 +399,12 @@ export const nodeCommand = (ctx: IPublicModelPluginContext) => {
|
|||||||
{
|
{
|
||||||
name: 'nodeId',
|
name: 'nodeId',
|
||||||
propType: 'string',
|
propType: 'string',
|
||||||
description: 'The id of the node to be replaced.',
|
description: 'The id of the node to be updated.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'nodeSchema',
|
name: 'nodeSchema',
|
||||||
propType: nodeSchemaPropType,
|
propType: nodeSchemaPropType,
|
||||||
description: 'The node to replace.',
|
description: 'The node to be updated.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -499,6 +479,14 @@ export const nodeCommand = (ctx: IPublicModelPluginContext) => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
destroy() {
|
||||||
|
command.unregisterCommand('node:add');
|
||||||
|
command.unregisterCommand('node:move');
|
||||||
|
command.unregisterCommand('node:remove');
|
||||||
|
command.unregisterCommand('node:update');
|
||||||
|
command.unregisterCommand('node:updateProps');
|
||||||
|
command.unregisterCommand('node:removeProps');
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -507,18 +495,3 @@ nodeCommand.meta = {
|
|||||||
commandScope: 'node',
|
commandScope: 'node',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultCommand = (ctx: IPublicModelPluginContext) => {
|
|
||||||
const { plugins } = ctx;
|
|
||||||
plugins.register(nodeCommand);
|
|
||||||
plugins.register(historyCommand);
|
|
||||||
|
|
||||||
return {
|
|
||||||
init() {
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultCommand.pluginName = '___default_command___';
|
|
||||||
defaultCommand.meta = {
|
|
||||||
commandScope: 'common',
|
|
||||||
};
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-plugin-designer",
|
"name": "@alilc/lowcode-plugin-designer",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "alibaba lowcode editor designer plugin",
|
"description": "alibaba lowcode editor designer plugin",
|
||||||
"files": [
|
"files": [
|
||||||
"es",
|
"es",
|
||||||
@ -18,9 +18,9 @@
|
|||||||
],
|
],
|
||||||
"author": "xiayang.xy",
|
"author": "xiayang.xy",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alilc/lowcode-designer": "1.3.1",
|
"@alilc/lowcode-designer": "1.3.2",
|
||||||
"@alilc/lowcode-editor-core": "1.3.1",
|
"@alilc/lowcode-editor-core": "1.3.2",
|
||||||
"@alilc/lowcode-utils": "1.3.1",
|
"@alilc/lowcode-utils": "1.3.2",
|
||||||
"react": "^16.8.1",
|
"react": "^16.8.1",
|
||||||
"react-dom": "^16.8.1"
|
"react-dom": "^16.8.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-plugin-outline-pane",
|
"name": "@alilc/lowcode-plugin-outline-pane",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "Outline pane for Ali lowCode engine",
|
"description": "Outline pane for Ali lowCode engine",
|
||||||
"files": [
|
"files": [
|
||||||
"es",
|
"es",
|
||||||
@ -13,8 +13,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alifd/next": "^1.19.16",
|
"@alifd/next": "^1.19.16",
|
||||||
"@alilc/lowcode-types": "1.3.1",
|
"@alilc/lowcode-types": "1.3.2",
|
||||||
"@alilc/lowcode-utils": "1.3.1",
|
"@alilc/lowcode-utils": "1.3.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"react": "^16",
|
"react": "^16",
|
||||||
"react-dom": "^16.7.0",
|
"react-dom": "^16.7.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-react-renderer",
|
"name": "@alilc/lowcode-react-renderer",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "react renderer for ali lowcode engine",
|
"description": "react renderer for ali lowcode engine",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
@ -22,7 +22,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alifd/next": "^1.21.16",
|
"@alifd/next": "^1.21.16",
|
||||||
"@alilc/lowcode-renderer-core": "1.3.1"
|
"@alilc/lowcode-renderer-core": "1.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@alib/build-scripts": "^0.1.18",
|
"@alib/build-scripts": "^0.1.18",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-react-simulator-renderer",
|
"name": "@alilc/lowcode-react-simulator-renderer",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "react simulator renderer for alibaba lowcode designer",
|
"description": "react simulator renderer for alibaba lowcode designer",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
@ -17,10 +17,10 @@
|
|||||||
"test:cov": "build-scripts test --config build.test.json --jest-coverage"
|
"test:cov": "build-scripts test --config build.test.json --jest-coverage"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alilc/lowcode-designer": "1.3.1",
|
"@alilc/lowcode-designer": "1.3.2",
|
||||||
"@alilc/lowcode-react-renderer": "1.3.1",
|
"@alilc/lowcode-react-renderer": "1.3.2",
|
||||||
"@alilc/lowcode-types": "1.3.1",
|
"@alilc/lowcode-types": "1.3.2",
|
||||||
"@alilc/lowcode-utils": "1.3.1",
|
"@alilc/lowcode-utils": "1.3.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"mobx": "^6.3.0",
|
"mobx": "^6.3.0",
|
||||||
"mobx-react": "^7.2.0",
|
"mobx-react": "^7.2.0",
|
||||||
|
|||||||
@ -614,7 +614,7 @@ function getNodeInstance(fiberNode: any, specId?: string): IPublicTypeNodeInstan
|
|||||||
|
|
||||||
function checkInstanceMounted(instance: any): boolean {
|
function checkInstanceMounted(instance: any): boolean {
|
||||||
if (isElement(instance)) {
|
if (isElement(instance)) {
|
||||||
return instance.parentElement != null;
|
return instance.parentElement != null && window.document.contains(instance);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-renderer-core",
|
"name": "@alilc/lowcode-renderer-core",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "renderer core",
|
"description": "renderer core",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
@ -16,8 +16,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alilc/lowcode-datasource-engine": "^1.0.0",
|
"@alilc/lowcode-datasource-engine": "^1.0.0",
|
||||||
"@alilc/lowcode-types": "1.3.1",
|
"@alilc/lowcode-types": "1.3.2",
|
||||||
"@alilc/lowcode-utils": "1.3.1",
|
"@alilc/lowcode-utils": "1.3.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"fetch-jsonp": "^1.1.3",
|
"fetch-jsonp": "^1.1.3",
|
||||||
@ -32,7 +32,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@alib/build-scripts": "^0.1.18",
|
"@alib/build-scripts": "^0.1.18",
|
||||||
"@alifd/next": "^1.26.0",
|
"@alifd/next": "^1.26.0",
|
||||||
"@alilc/lowcode-designer": "1.3.1",
|
"@alilc/lowcode-designer": "1.3.2",
|
||||||
"@babel/plugin-transform-typescript": "^7.16.8",
|
"@babel/plugin-transform-typescript": "^7.16.8",
|
||||||
"@testing-library/react": "^11.2.2",
|
"@testing-library/react": "^11.2.2",
|
||||||
"@types/classnames": "^2.2.11",
|
"@types/classnames": "^2.2.11",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-shell",
|
"name": "@alilc/lowcode-shell",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "Shell Layer for AliLowCodeEngine",
|
"description": "Shell Layer for AliLowCodeEngine",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
@ -13,12 +13,12 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alilc/lowcode-designer": "1.3.1",
|
"@alilc/lowcode-designer": "1.3.2",
|
||||||
"@alilc/lowcode-editor-core": "1.3.1",
|
"@alilc/lowcode-editor-core": "1.3.2",
|
||||||
"@alilc/lowcode-editor-skeleton": "1.3.1",
|
"@alilc/lowcode-editor-skeleton": "1.3.2",
|
||||||
"@alilc/lowcode-types": "1.3.1",
|
"@alilc/lowcode-types": "1.3.2",
|
||||||
"@alilc/lowcode-utils": "1.3.1",
|
"@alilc/lowcode-utils": "1.3.2",
|
||||||
"@alilc/lowcode-workspace": "1.3.1",
|
"@alilc/lowcode-workspace": "1.3.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"enzyme": "^3.11.0",
|
"enzyme": "^3.11.0",
|
||||||
"enzyme-adapter-react-16": "^1.15.5",
|
"enzyme-adapter-react-16": "^1.15.5",
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import {
|
|||||||
IDesigner,
|
IDesigner,
|
||||||
isComponentMeta,
|
isComponentMeta,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import { IPublicTypeAssetsJson } from '@alilc/lowcode-utils';
|
import { IPublicTypeAssetsJson, getLogger } from '@alilc/lowcode-utils';
|
||||||
import {
|
import {
|
||||||
IPublicTypeComponentAction,
|
IPublicTypeComponentAction,
|
||||||
IPublicTypeComponentMetadata,
|
IPublicTypeComponentMetadata,
|
||||||
@ -21,6 +21,8 @@ import { editorSymbol, designerSymbol } from '../symbols';
|
|||||||
import { ComponentMeta as ShellComponentMeta } from '../model';
|
import { ComponentMeta as ShellComponentMeta } from '../model';
|
||||||
import { ComponentType } from 'react';
|
import { ComponentType } from 'react';
|
||||||
|
|
||||||
|
const logger = getLogger({ level: 'warn', bizName: 'shell-material' });
|
||||||
|
|
||||||
const innerEditorSymbol = Symbol('editor');
|
const innerEditorSymbol = Symbol('editor');
|
||||||
export class Material implements IPublicApiMaterial {
|
export class Material implements IPublicApiMaterial {
|
||||||
private readonly [innerEditorSymbol]: IPublicModelEditor;
|
private readonly [innerEditorSymbol]: IPublicModelEditor;
|
||||||
@ -31,6 +33,10 @@ export class Material implements IPublicApiMaterial {
|
|||||||
}
|
}
|
||||||
const workspace: InnerWorkspace = globalContext.get('workspace');
|
const workspace: InnerWorkspace = globalContext.get('workspace');
|
||||||
if (workspace.isActive) {
|
if (workspace.isActive) {
|
||||||
|
if (!workspace.window.editor) {
|
||||||
|
logger.error('Material api 调用时机出现问题,请检查');
|
||||||
|
return this[innerEditorSymbol];
|
||||||
|
}
|
||||||
return workspace.window.editor;
|
return workspace.window.editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,7 +90,7 @@ export class Workspace implements IPublicApiWorkspace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get plugins() {
|
get plugins() {
|
||||||
return new Plugins(this[workspaceSymbol].plugins, true);
|
return new Plugins(this[workspaceSymbol].plugins, true).toProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
get skeleton() {
|
get skeleton() {
|
||||||
|
|||||||
@ -34,7 +34,7 @@ export function ContextMenu({ children, menus, pluginContext }: {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!menus || !menus.length) {
|
if (!menus) {
|
||||||
return (
|
return (
|
||||||
<>{ children }</>
|
<>{ children }</>
|
||||||
);
|
);
|
||||||
@ -53,6 +53,9 @@ export function ContextMenu({ children, menus, pluginContext }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ContextMenu.create = (pluginContext: IPublicModelPluginContext, menus: IPublicTypeContextMenuAction[], event: MouseEvent) => {
|
ContextMenu.create = (pluginContext: IPublicModelPluginContext, menus: IPublicTypeContextMenuAction[], event: MouseEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
const children: React.ReactNode[] = parseContextMenuAsReactNode(parseContextMenuProperties(menus, {
|
const children: React.ReactNode[] = parseContextMenuAsReactNode(parseContextMenuProperties(menus, {
|
||||||
pluginContext,
|
pluginContext,
|
||||||
}), {
|
}), {
|
||||||
|
|||||||
@ -48,8 +48,8 @@ export class Window implements IPublicModelWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get currentEditorView() {
|
get currentEditorView() {
|
||||||
if (this[windowSymbol].editorView) {
|
if (this[windowSymbol]._editorView) {
|
||||||
return new EditorView(this[windowSymbol].editorView).toProxy() as any;
|
return new EditorView(this[windowSymbol]._editorView).toProxy() as any;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-types",
|
"name": "@alilc/lowcode-types",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "Types for Ali lowCode engine",
|
"description": "Types for Ali lowCode engine",
|
||||||
"files": [
|
"files": [
|
||||||
"es",
|
"es",
|
||||||
|
|||||||
@ -15,12 +15,12 @@ export interface IPublicApiCommand {
|
|||||||
/**
|
/**
|
||||||
* 通过名称和给定参数执行一个命令,会校验参数是否符合命令定义
|
* 通过名称和给定参数执行一个命令,会校验参数是否符合命令定义
|
||||||
*/
|
*/
|
||||||
executeCommand(name: string, args: IPublicTypeCommandHandlerArgs): void;
|
executeCommand(name: string, args?: IPublicTypeCommandHandlerArgs): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量执行命令,执行完所有命令后再进行一次重绘,历史记录中只会记录一次
|
* 批量执行命令,执行完所有命令后再进行一次重绘,历史记录中只会记录一次
|
||||||
*/
|
*/
|
||||||
batchExecuteCommand(commands: { name: string; args: IPublicTypeCommandHandlerArgs }[]): void;
|
batchExecuteCommand(commands: { name: string; args?: IPublicTypeCommandHandlerArgs }[]): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列出所有已注册的命令
|
* 列出所有已注册的命令
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import { IPublicModelWindow } from '../model';
|
import { IPublicModelWindow } from '../model';
|
||||||
import { IPublicApiPlugins, IPublicModelResource, IPublicResourceList, IPublicTypeDisposable, IPublicTypeResourceType } from '@alilc/lowcode-types';
|
import { IPublicApiPlugins, IPublicApiSkeleton, IPublicModelResource, IPublicResourceList, IPublicTypeDisposable, IPublicTypeResourceType } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export interface IPublicApiWorkspace<
|
export interface IPublicApiWorkspace<
|
||||||
Plugins = IPublicApiPlugins,
|
Plugins = IPublicApiPlugins,
|
||||||
|
Skeleton = IPublicApiSkeleton,
|
||||||
ModelWindow = IPublicModelWindow,
|
ModelWindow = IPublicModelWindow,
|
||||||
Resource = IPublicModelResource,
|
Resource = IPublicModelResource,
|
||||||
> {
|
> {
|
||||||
@ -15,6 +16,8 @@ export interface IPublicApiWorkspace<
|
|||||||
|
|
||||||
plugins: Plugins;
|
plugins: Plugins;
|
||||||
|
|
||||||
|
skeleton: Skeleton;
|
||||||
|
|
||||||
/** 当前设计器的编辑窗口 */
|
/** 当前设计器的编辑窗口 */
|
||||||
windows: ModelWindow[];
|
windows: ModelWindow[];
|
||||||
|
|
||||||
|
|||||||
@ -1,22 +1,10 @@
|
|||||||
|
import { IPublicTypePropType } from './prop-types';
|
||||||
|
|
||||||
// 定义命令处理函数的参数类型
|
// 定义命令处理函数的参数类型
|
||||||
export interface IPublicTypeCommandHandlerArgs {
|
export interface IPublicTypeCommandHandlerArgs {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 定义复杂参数类型的接口
|
|
||||||
export interface IPublicTypeCommandPropType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 参数基础类型
|
|
||||||
*/
|
|
||||||
type: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 参数是否必需(可选)
|
|
||||||
*/
|
|
||||||
isRequired?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 定义命令参数的接口
|
// 定义命令参数的接口
|
||||||
export interface IPublicTypeCommandParameter {
|
export interface IPublicTypeCommandParameter {
|
||||||
|
|
||||||
@ -28,7 +16,7 @@ export interface IPublicTypeCommandParameter {
|
|||||||
/**
|
/**
|
||||||
* 参数类型或详细类型描述
|
* 参数类型或详细类型描述
|
||||||
*/
|
*/
|
||||||
propType: string | IPublicTypeCommandPropType;
|
propType: string | IPublicTypePropType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数描述
|
* 参数描述
|
||||||
|
|||||||
@ -77,5 +77,5 @@ export interface IPublicTypeFieldExtraProps {
|
|||||||
/**
|
/**
|
||||||
* onChange 事件
|
* onChange 事件
|
||||||
*/
|
*/
|
||||||
onChange?: (value: any, field: any) => void;
|
onChange?: (value: any, field: IPublicModelSettingField) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,20 @@
|
|||||||
|
import { IPublicModelSettingField } from '../model';
|
||||||
import { IPublicTypeCustomView, IPublicTypeTitleContent } from './';
|
import { IPublicTypeCustomView, IPublicTypeTitleContent } from './';
|
||||||
|
|
||||||
export interface IPublicTypeRegisteredSetter {
|
export interface IPublicTypeRegisteredSetter {
|
||||||
component: IPublicTypeCustomView;
|
component: IPublicTypeCustomView;
|
||||||
defaultProps?: object;
|
defaultProps?: object;
|
||||||
title?: IPublicTypeTitleContent;
|
title?: IPublicTypeTitleContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* for MixedSetter to check this setter if available
|
* for MixedSetter to check this setter if available
|
||||||
*/
|
*/
|
||||||
condition?: (field: any) => boolean;
|
condition?: (field: IPublicModelSettingField) => boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* for MixedSetter to manual change to this setter
|
* for MixedSetter to manual change to this setter
|
||||||
*/
|
*/
|
||||||
initialValue?: any | ((field: any) => any);
|
initialValue?: any | ((field: IPublicModelSettingField) => any);
|
||||||
recommend?: boolean;
|
recommend?: boolean;
|
||||||
// 标识是否为动态 setter,默认为 true
|
// 标识是否为动态 setter,默认为 true
|
||||||
isDynamic?: boolean;
|
isDynamic?: boolean;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-utils",
|
"name": "@alilc/lowcode-utils",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "Utils for Ali lowCode engine",
|
"description": "Utils for Ali lowCode engine",
|
||||||
"files": [
|
"files": [
|
||||||
"lib",
|
"lib",
|
||||||
@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alifd/next": "^1.19.16",
|
"@alifd/next": "^1.19.16",
|
||||||
"@alilc/lowcode-types": "1.3.1",
|
"@alilc/lowcode-types": "1.3.2",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mobx": "^6.3.0",
|
"mobx": "^6.3.0",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@alilc/lowcode-workspace",
|
"name": "@alilc/lowcode-workspace",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "Shell Layer for AliLowCodeEngine",
|
"description": "Shell Layer for AliLowCodeEngine",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
@ -15,11 +15,11 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alilc/lowcode-designer": "1.3.1",
|
"@alilc/lowcode-designer": "1.3.2",
|
||||||
"@alilc/lowcode-editor-core": "1.3.1",
|
"@alilc/lowcode-editor-core": "1.3.2",
|
||||||
"@alilc/lowcode-editor-skeleton": "1.3.1",
|
"@alilc/lowcode-editor-skeleton": "1.3.2",
|
||||||
"@alilc/lowcode-types": "1.3.1",
|
"@alilc/lowcode-types": "1.3.2",
|
||||||
"@alilc/lowcode-utils": "1.3.1",
|
"@alilc/lowcode-utils": "1.3.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"enzyme": "^3.11.0",
|
"enzyme": "^3.11.0",
|
||||||
"enzyme-adapter-react-16": "^1.15.5",
|
"enzyme-adapter-react-16": "^1.15.5",
|
||||||
|
|||||||
@ -96,7 +96,7 @@ export class BasicContext implements IBasicContext {
|
|||||||
designer: IDesigner;
|
designer: IDesigner;
|
||||||
registerInnerPlugins: () => Promise<void>;
|
registerInnerPlugins: () => Promise<void>;
|
||||||
innerSetters: InnerSetters;
|
innerSetters: InnerSetters;
|
||||||
innerSkeleton: InnerSkeleton;
|
innerSkeleton: ISkeleton;
|
||||||
innerHotkey: IHotKey;
|
innerHotkey: IHotKey;
|
||||||
innerPlugins: ILowCodePluginManager;
|
innerPlugins: ILowCodePluginManager;
|
||||||
canvas: IPublicApiCanvas;
|
canvas: IPublicApiCanvas;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export interface IEditorWindow extends Omit<IPublicModelWindow<IResource>, 'chan
|
|||||||
|
|
||||||
editorViews: Map<string, IViewContext>;
|
editorViews: Map<string, IViewContext>;
|
||||||
|
|
||||||
editorView: IViewContext;
|
_editorView: IViewContext;
|
||||||
|
|
||||||
changeViewName: (name: string, ignoreEmit?: boolean) => void;
|
changeViewName: (name: string, ignoreEmit?: boolean) => void;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
|
|
||||||
url: string | undefined;
|
url: string | undefined;
|
||||||
|
|
||||||
@obx.ref editorView: Context;
|
@obx.ref _editorView: Context;
|
||||||
|
|
||||||
@obx editorViews: Map<string, Context> = new Map<string, Context>();
|
@obx editorViews: Map<string, Context> = new Map<string, Context>();
|
||||||
|
|
||||||
@ -62,6 +62,13 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
|
|
||||||
sleep: boolean | undefined;
|
sleep: boolean | undefined;
|
||||||
|
|
||||||
|
get editorView() {
|
||||||
|
if (!this._editorView) {
|
||||||
|
return this.editorViews.values().next().value;
|
||||||
|
}
|
||||||
|
return this._editorView;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(readonly resource: IResource, readonly workspace: IWorkspace, private config: IWindowCOnfig) {
|
constructor(readonly resource: IResource, readonly workspace: IWorkspace, private config: IWindowCOnfig) {
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
this.title = config.title;
|
this.title = config.title;
|
||||||
@ -75,10 +82,10 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
updateState(state: WINDOW_STATE): void {
|
updateState(state: WINDOW_STATE): void {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case WINDOW_STATE.active:
|
case WINDOW_STATE.active:
|
||||||
this.editorView?.setActivate(true);
|
this._editorView?.setActivate(true);
|
||||||
break;
|
break;
|
||||||
case WINDOW_STATE.inactive:
|
case WINDOW_STATE.inactive:
|
||||||
this.editorView?.setActivate(false);
|
this._editorView?.setActivate(false);
|
||||||
break;
|
break;
|
||||||
case WINDOW_STATE.destroyed:
|
case WINDOW_STATE.destroyed:
|
||||||
break;
|
break;
|
||||||
@ -146,7 +153,7 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
for (let i = 0; i < editorViews.length; i++) {
|
for (let i = 0; i < editorViews.length; i++) {
|
||||||
const name = editorViews[i].viewName;
|
const name = editorViews[i].viewName;
|
||||||
await this.initViewType(name);
|
await this.initViewType(name);
|
||||||
if (!this.editorView) {
|
if (!this._editorView) {
|
||||||
this.changeViewName(name);
|
this.changeViewName(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,14 +197,14 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
};
|
};
|
||||||
|
|
||||||
changeViewName = (name: string, ignoreEmit: boolean = true) => {
|
changeViewName = (name: string, ignoreEmit: boolean = true) => {
|
||||||
this.editorView?.setActivate(false);
|
this._editorView?.setActivate(false);
|
||||||
this.editorView = this.editorViews.get(name)!;
|
this._editorView = this.editorViews.get(name)!;
|
||||||
|
|
||||||
if (!this.editorView) {
|
if (!this._editorView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.editorView.setActivate(true);
|
this._editorView.setActivate(true);
|
||||||
|
|
||||||
if (!ignoreEmit) {
|
if (!ignoreEmit) {
|
||||||
this.emitter.emit('window.change.view.type', name);
|
this.emitter.emit('window.change.view.type', name);
|
||||||
|
|||||||
@ -10,6 +10,7 @@ lerna run build \
|
|||||||
--scope @alilc/lowcode-editor-skeleton \
|
--scope @alilc/lowcode-editor-skeleton \
|
||||||
--scope @alilc/lowcode-designer \
|
--scope @alilc/lowcode-designer \
|
||||||
--scope @alilc/lowcode-plugin-designer \
|
--scope @alilc/lowcode-plugin-designer \
|
||||||
|
--scope @alilc/lowcode-plugin-command \
|
||||||
--scope @alilc/lowcode-plugin-outline-pane \
|
--scope @alilc/lowcode-plugin-outline-pane \
|
||||||
--scope @alilc/lowcode-react-renderer \
|
--scope @alilc/lowcode-react-renderer \
|
||||||
--scope @alilc/lowcode-react-simulator-renderer \
|
--scope @alilc/lowcode-react-simulator-renderer \
|
||||||
|
|||||||
@ -14,3 +14,4 @@ tnpm sync @alilc/lowcode-react-renderer
|
|||||||
tnpm sync @alilc/lowcode-react-simulator-renderer
|
tnpm sync @alilc/lowcode-react-simulator-renderer
|
||||||
tnpm sync @alilc/lowcode-engine
|
tnpm sync @alilc/lowcode-engine
|
||||||
tnpm sync @alilc/lowcode-workspace
|
tnpm sync @alilc/lowcode-workspace
|
||||||
|
tnpm sync @alilc/lowcode-plugin-command
|
||||||
Loading…
x
Reference in New Issue
Block a user