mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-13 04:03:07 +00:00
docs: add workspace docs
This commit is contained in:
parent
fadce950f9
commit
840e70e3d0
23
docs/docs/api/model/window.md
Normal file
23
docs/docs/api/model/window.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
title: Window
|
||||||
|
sidebar_position: 12
|
||||||
|
---
|
||||||
|
|
||||||
|
> **@types** [IPublicModelWindow](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/window.ts)<br/>
|
||||||
|
> **@since** v1.1.0
|
||||||
|
|
||||||
|
|
||||||
|
## 基本介绍
|
||||||
|
|
||||||
|
低代码设计器窗口模型
|
||||||
|
|
||||||
|
## 方法签名
|
||||||
|
|
||||||
|
### importSchema(schema: IPublicTypeNodeSchema)
|
||||||
|
当前窗口导入 schema
|
||||||
|
|
||||||
|
### changeViewType(viewName: string)
|
||||||
|
修改当前窗口视图类型
|
||||||
|
|
||||||
|
### async save
|
||||||
|
调用当前窗口视图保存钩子
|
||||||
34
docs/docs/api/workspace.md
Normal file
34
docs/docs/api/workspace.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
title: workspace - 应用级 API
|
||||||
|
sidebar_position: 12
|
||||||
|
---
|
||||||
|
|
||||||
|
> **@types** [IPublicApiWorkspace](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/workspace.ts)<br/>
|
||||||
|
> **@since** v1.1.0
|
||||||
|
|
||||||
|
|
||||||
|
## 模块简介
|
||||||
|
|
||||||
|
通过该模块可以开发应用级低代码设计器。
|
||||||
|
|
||||||
|
## 变量
|
||||||
|
|
||||||
|
### isActive
|
||||||
|
|
||||||
|
是否启用 workspace 模式
|
||||||
|
|
||||||
|
### window
|
||||||
|
|
||||||
|
当前设计器窗口模型
|
||||||
|
|
||||||
|
关联模型 [IPublicModelWindow](./model/window)
|
||||||
|
|
||||||
|
## 方法签名
|
||||||
|
|
||||||
|
### registerResourceType
|
||||||
|
注册资源
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
/** 注册资源 */
|
||||||
|
registerResourceType(resourceName: string, resourceType: 'editor', options: IPublicResourceOptions): void;
|
||||||
|
```
|
||||||
@ -17,7 +17,7 @@ export class Window implements IPublicModelWindow {
|
|||||||
this[windowSymbol].changeViewType(viewName);
|
this[windowSymbol].changeViewType(viewName);
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
async save() {
|
||||||
return this[windowSymbol].save();
|
return await this[windowSymbol].save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1,13 @@
|
|||||||
export interface IPublicApiWorkspace {}
|
import { IPublicModelWindow } from '../model';
|
||||||
|
import { IPublicResourceOptions } from '../type';
|
||||||
|
|
||||||
|
export interface IPublicApiWorkspace {
|
||||||
|
/** 是否启用 workspace 模式 */
|
||||||
|
isActive: boolean;
|
||||||
|
|
||||||
|
/** 当前设计器窗口 */
|
||||||
|
window: IPublicModelWindow;
|
||||||
|
|
||||||
|
/** 注册资源 */
|
||||||
|
registerResourceType(resourceName: string, resourceType: 'editor', options: IPublicResourceOptions): void;
|
||||||
|
}
|
||||||
@ -1 +1,14 @@
|
|||||||
export interface IPublicModelWindow {}
|
import { IPublicTypeNodeSchema } from '../type';
|
||||||
|
|
||||||
|
export interface IPublicModelWindow {
|
||||||
|
/** 当前窗口导入 schema */
|
||||||
|
importSchema(schema: IPublicTypeNodeSchema): void;
|
||||||
|
|
||||||
|
/** 修改当前窗口视图类型 */
|
||||||
|
changeViewType(viewName: string): void;
|
||||||
|
|
||||||
|
/** 调用当前窗口视图保存钩子 */
|
||||||
|
save(): Promise<{
|
||||||
|
[viewName: string]: IPublicTypeNodeSchema | any;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
@ -72,4 +72,5 @@ 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';
|
export * from './plugin-register-options';
|
||||||
|
export * from './resource-options';
|
||||||
32
packages/types/src/shell/type/resource-options.ts
Normal file
32
packages/types/src/shell/type/resource-options.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
export interface IPublicViewFunctions {
|
||||||
|
/** 视图初始化 */
|
||||||
|
init?: () => Promise<void>;
|
||||||
|
/** 资源保存时调用视图的钩子 */
|
||||||
|
save?: () => Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IPublicEditorView {
|
||||||
|
/** 资源名字 */
|
||||||
|
viewName: string;
|
||||||
|
(ctx: any): IPublicViewFunctions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IPublicResourceOptions {
|
||||||
|
/** 资源名字 */
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
/** 资源描述 */
|
||||||
|
description?: string;
|
||||||
|
|
||||||
|
/** 默认视图类型 */
|
||||||
|
defaultViewType: string;
|
||||||
|
|
||||||
|
/** 资源视图 */
|
||||||
|
editorViews: IPublicEditorView[];
|
||||||
|
|
||||||
|
/** save 钩子 */
|
||||||
|
save?: () => Promise<void>;
|
||||||
|
|
||||||
|
/** import 钩子 */
|
||||||
|
import?: () => Promise<void>;
|
||||||
|
}
|
||||||
@ -26,7 +26,7 @@ export class EditorWindow {
|
|||||||
const saveResult = await this.editorViews.get(name)?.save();
|
const saveResult = await this.editorViews.get(name)?.save();
|
||||||
value[name] = saveResult;
|
value[name] = saveResult;
|
||||||
}
|
}
|
||||||
this.resource.save(value);
|
return await this.resource.save(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Editor } from '@alilc/lowcode-editor-core';
|
|||||||
import {
|
import {
|
||||||
Skeleton as InnerSkeleton,
|
Skeleton as InnerSkeleton,
|
||||||
} from '@alilc/lowcode-editor-skeleton';
|
} from '@alilc/lowcode-editor-skeleton';
|
||||||
|
import { IPublicResourceOptions } from '@alilc/lowcode-types';
|
||||||
import { EditorWindow } from './editor-window/context';
|
import { EditorWindow } from './editor-window/context';
|
||||||
import { Resource } from './resource';
|
import { Resource } from './resource';
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ export class Workspace {
|
|||||||
|
|
||||||
private resources: Map<string, Resource> = new Map();
|
private resources: Map<string, Resource> = new Map();
|
||||||
|
|
||||||
registerResourceType(resourceName: string, resourceType: 'editor' | 'webview', options: ResourceOptions): void {
|
registerResourceType(resourceName: string, resourceType: 'editor' | 'webview', options: IPublicResourceOptions): void {
|
||||||
if (resourceType === 'editor') {
|
if (resourceType === 'editor') {
|
||||||
const resource = new Resource(options);
|
const resource = new Resource(options);
|
||||||
this.resources.set(resourceName, resource);
|
this.resources.set(resourceName, resource);
|
||||||
@ -62,23 +63,3 @@ export class Workspace {
|
|||||||
|
|
||||||
openEditorWindow() {}
|
openEditorWindow() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ResourceOptions {
|
|
||||||
description: string;
|
|
||||||
defaultViewType?: string;
|
|
||||||
editorViews?: EditorViewOptions[];
|
|
||||||
init: (ctx: any) => Promise<void>;
|
|
||||||
dispose: (ctx: any) => Promise<void>;
|
|
||||||
import: (ctx: any) => Promise<any>;
|
|
||||||
save: (value: any) => Promise<any>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ViewFunctions {
|
|
||||||
init: () => Promise<void>;
|
|
||||||
save: () => Promise<void>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type EditorViewOptions = {
|
|
||||||
viewName: string;
|
|
||||||
(ctx: any): ViewFunctions;
|
|
||||||
};
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user