mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-26 03:48:12 +00:00
feat: update the ts definition of the shell module
This commit is contained in:
parent
810ef478e5
commit
9cec5d833c
@ -48,6 +48,7 @@ module.exports = {
|
|||||||
"afterLineComment": false,
|
"afterLineComment": false,
|
||||||
"allowBlockStart": true,
|
"allowBlockStart": true,
|
||||||
}],
|
}],
|
||||||
|
"no-unused-vars": ['error', { "destructuredArrayIgnorePattern": "^_" }],
|
||||||
"@typescript-eslint/member-ordering": [
|
"@typescript-eslint/member-ordering": [
|
||||||
"error",
|
"error",
|
||||||
{ "default": ["signature", "field", "constructor", "method"] }
|
{ "default": ["signature", "field", "constructor", "method"] }
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Component } from 'react';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import TreeNode from '../controllers/tree-node';
|
import TreeNode from '../controllers/tree-node';
|
||||||
import TreeNodeView from './tree-node';
|
import TreeNodeView from './tree-node';
|
||||||
import { IPublicModelPluginContext, IPublicModelExclusiveGroup } from '@alilc/lowcode-types';
|
import { IPublicModelPluginContext, IPublicModelExclusiveGroup, IPublicTypeDisposable } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export default class TreeBranches extends Component<{
|
export default class TreeBranches extends Component<{
|
||||||
treeNode: TreeNode;
|
treeNode: TreeNode;
|
||||||
@ -73,7 +73,7 @@ class TreeNodeChildren extends Component<{
|
|||||||
keywords: null,
|
keywords: null,
|
||||||
dropDetail: null,
|
dropDetail: null,
|
||||||
};
|
};
|
||||||
offLocationChanged: () => void;
|
offLocationChanged: IPublicTypeDisposable;
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { treeNode, pluginContext } = this.props;
|
const { treeNode, pluginContext } = this.props;
|
||||||
const { project } = pluginContext;
|
const { project } = pluginContext;
|
||||||
|
|||||||
@ -2,12 +2,14 @@ import { IPublicModelDragon, IPublicModelDropLocation, IPublicModelScrollTarget,
|
|||||||
import { IPublicTypeLocationData, IPublicTypeScrollable } from '../type';
|
import { IPublicTypeLocationData, IPublicTypeScrollable } from '../type';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* canvas - 画布 API
|
||||||
* @since v1.1.0
|
* @since v1.1.0
|
||||||
*/
|
*/
|
||||||
export interface IPublicApiCanvas {
|
export interface IPublicApiCanvas {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创一个滚动控制器 Scroller,赋予一个视图滚动的基本能力,
|
* 创一个滚动控制器 Scroller,赋予一个视图滚动的基本能力,
|
||||||
|
*
|
||||||
* a Scroller is a controller that gives a view (IPublicTypeScrollable) the ability scrolling
|
* a Scroller is a controller that gives a view (IPublicTypeScrollable) the ability scrolling
|
||||||
* to some cordination by api scrollTo.
|
* to some cordination by api scrollTo.
|
||||||
*
|
*
|
||||||
@ -20,6 +22,7 @@ export interface IPublicApiCanvas {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个 ScrollTarget,与 Scroller 一起发挥作用,详见 createScroller 中的描述
|
* 创建一个 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
|
* @since v1.1.0
|
||||||
*/
|
*/
|
||||||
@ -27,6 +30,7 @@ export interface IPublicApiCanvas {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个文档插入位置对象,该对象用来描述一个即将插入的节点在文档中的位置
|
* 创建一个文档插入位置对象,该对象用来描述一个即将插入的节点在文档中的位置
|
||||||
|
*
|
||||||
* 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
|
* @since v1.1.0
|
||||||
*/
|
*/
|
||||||
@ -34,6 +38,7 @@ export interface IPublicApiCanvas {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取拖拽操作对象的实例
|
* 获取拖拽操作对象的实例
|
||||||
|
*
|
||||||
* 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
|
* @since v1.1.0
|
||||||
*/
|
*/
|
||||||
@ -41,6 +46,7 @@ export interface IPublicApiCanvas {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取活动追踪器实例
|
* 获取活动追踪器实例
|
||||||
|
*
|
||||||
* 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.
|
||||||
@ -50,6 +56,7 @@ export interface IPublicApiCanvas {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否处于 LiveEditing 状态
|
* 是否处于 LiveEditing 状态
|
||||||
|
*
|
||||||
* check if canvas is in liveEditing state
|
* check if canvas is in liveEditing state
|
||||||
* @since v1.1.0
|
* @since v1.1.0
|
||||||
*/
|
*/
|
||||||
@ -57,6 +64,7 @@ export interface IPublicApiCanvas {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全局剪贴板实例
|
* 获取全局剪贴板实例
|
||||||
|
*
|
||||||
* get clipboard instance
|
* get clipboard instance
|
||||||
*
|
*
|
||||||
* @since v1.1.0
|
* @since v1.1.0
|
||||||
|
|||||||
@ -76,8 +76,25 @@ export interface IPublicApiMaterial {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 在设计器辅助层增加一个扩展 action
|
* 在设计器辅助层增加一个扩展 action
|
||||||
|
*
|
||||||
* add an action button in canvas context menu area
|
* add an action button in canvas context menu area
|
||||||
* @param action
|
* @param action
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* import { plugins } from '@alilc/lowcode-engine';
|
||||||
|
* import { IPublicModelPluginContext } from '@alilc/lowcode-types';
|
||||||
|
*
|
||||||
|
* const removeCopyAction = (ctx: IPublicModelPluginContext) => {
|
||||||
|
* return {
|
||||||
|
* async init() {
|
||||||
|
* const { removeBuiltinComponentAction } = ctx.material;
|
||||||
|
* removeBuiltinComponentAction('copy');
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* };
|
||||||
|
* removeCopyAction.pluginName = 'removeCopyAction';
|
||||||
|
* await plugins.register(removeCopyAction);
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
addBuiltinComponentAction(action: IPublicTypeComponentAction): void;
|
addBuiltinComponentAction(action: IPublicTypeComponentAction): void;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import { IPublicModelWindow } from '../model';
|
import { IPublicModelWindow } from '../model';
|
||||||
import { IPublicApiPlugins, IPublicModelResource, IPublicResourceList, IPublicTypeDisposable, IPublicTypeResourceType } from '@alilc/lowcode-types';
|
import { IPublicApiPlugins, IPublicModelResource, IPublicResourceList, IPublicTypeDisposable, IPublicTypeResourceType } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export interface IPublicApiWorkspace {
|
export interface IPublicApiWorkspace<
|
||||||
|
Plugins = IPublicApiPlugins
|
||||||
|
> {
|
||||||
|
|
||||||
/** 是否启用 workspace 模式 */
|
/** 是否启用 workspace 模式 */
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
@ -9,7 +11,7 @@ export interface IPublicApiWorkspace {
|
|||||||
/** 当前设计器窗口 */
|
/** 当前设计器窗口 */
|
||||||
window: IPublicModelWindow;
|
window: IPublicModelWindow;
|
||||||
|
|
||||||
plugins: IPublicApiPlugins;
|
plugins: Plugins;
|
||||||
|
|
||||||
/** 当前设计器的编辑窗口 */
|
/** 当前设计器的编辑窗口 */
|
||||||
windows: IPublicModelWindow[];
|
windows: IPublicModelWindow[];
|
||||||
|
|||||||
@ -27,6 +27,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为空
|
* 是否为空
|
||||||
|
*
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get isEmptyNode(): boolean;
|
get isEmptyNode(): boolean;
|
||||||
@ -44,6 +45,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除指定节点
|
* 删除指定节点
|
||||||
|
*
|
||||||
* delete the node
|
* delete the node
|
||||||
* @param node
|
* @param node
|
||||||
*/
|
*/
|
||||||
@ -51,6 +53,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入一个节点
|
* 插入一个节点
|
||||||
|
*
|
||||||
* insert a node at specific position
|
* insert a node at specific position
|
||||||
* @param node 待插入节点
|
* @param node 待插入节点
|
||||||
* @param at 插入下标
|
* @param at 插入下标
|
||||||
@ -60,6 +63,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回指定节点的下标
|
* 返回指定节点的下标
|
||||||
|
*
|
||||||
* get index of node in current children
|
* get index of node in current children
|
||||||
* @param node
|
* @param node
|
||||||
* @returns
|
* @returns
|
||||||
@ -68,6 +72,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 类似数组 splice 操作
|
* 类似数组 splice 操作
|
||||||
|
*
|
||||||
* provide the same function with {Array.prototype.splice}
|
* provide the same function with {Array.prototype.splice}
|
||||||
* @param start
|
* @param start
|
||||||
* @param deleteCount
|
* @param deleteCount
|
||||||
@ -77,6 +82,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回指定下标的节点
|
* 返回指定下标的节点
|
||||||
|
*
|
||||||
* get node with index
|
* get node with index
|
||||||
* @param index
|
* @param index
|
||||||
* @returns
|
* @returns
|
||||||
@ -85,6 +91,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否包含指定节点
|
* 是否包含指定节点
|
||||||
|
*
|
||||||
* check if node exists in current children
|
* check if node exists in current children
|
||||||
* @param node
|
* @param node
|
||||||
* @returns
|
* @returns
|
||||||
@ -93,6 +100,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 类似数组的 forEach
|
* 类似数组的 forEach
|
||||||
|
*
|
||||||
* provide the same function with {Array.prototype.forEach}
|
* provide the same function with {Array.prototype.forEach}
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
@ -100,12 +108,14 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 类似数组的 reverse
|
* 类似数组的 reverse
|
||||||
|
*
|
||||||
* provide the same function with {Array.prototype.reverse}
|
* provide the same function with {Array.prototype.reverse}
|
||||||
*/
|
*/
|
||||||
reverse(): Node[];
|
reverse(): Node[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类似数组的 map
|
* 类似数组的 map
|
||||||
|
*
|
||||||
* provide the same function with {Array.prototype.map}
|
* provide the same function with {Array.prototype.map}
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
@ -141,6 +151,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 类似数组的 reduce
|
* 类似数组的 reduce
|
||||||
|
*
|
||||||
* provide the same function with {Array.prototype.reduce}
|
* provide the same function with {Array.prototype.reduce}
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
@ -148,6 +159,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入 schema
|
* 导入 schema
|
||||||
|
*
|
||||||
* import schema
|
* import schema
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
@ -155,6 +167,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出 schema
|
* 导出 schema
|
||||||
|
*
|
||||||
* export schema
|
* export schema
|
||||||
* @param stage
|
* @param stage
|
||||||
*/
|
*/
|
||||||
@ -162,6 +175,7 @@ export interface IPublicModelNodeChildren<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行新增、删除、排序等操作
|
* 执行新增、删除、排序等操作
|
||||||
|
*
|
||||||
* excute remove/add/sort operations
|
* excute remove/add/sort operations
|
||||||
* @param remover
|
* @param remover
|
||||||
* @param adder
|
* @param adder
|
||||||
|
|||||||
@ -79,7 +79,7 @@ export function compatibleLegaoSchema(props: any): any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getNodeSchemaById(schema: IPublicTypeNodeSchema, nodeId: string): IPublicTypeNodeSchema | undefined {
|
export function getNodeSchemaById(schema: IPublicTypeNodeSchema, nodeId: string): IPublicTypeNodeSchema | undefined {
|
||||||
let found: NodeSIPublicTypeNodeSchemachema | undefined;
|
let found: IPublicTypeNodeSchema | undefined;
|
||||||
if (schema.id === nodeId) {
|
if (schema.id === nodeId) {
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ export function getNodeSchemaById(schema: IPublicTypeNodeSchema, nodeId: string)
|
|||||||
|
|
||||||
function getNodeSchemaFromPropsById(props: any, nodeId: string): IPublicTypeNodeSchema | undefined {
|
function getNodeSchemaFromPropsById(props: any, nodeId: string): IPublicTypeNodeSchema | undefined {
|
||||||
let found: IPublicTypeNodeSchema | undefined;
|
let found: IPublicTypeNodeSchema | undefined;
|
||||||
for (const [key, value] of Object.entries(props)) {
|
for (const [_key, value] of Object.entries(props)) {
|
||||||
if (isJSSlot(value)) {
|
if (isJSSlot(value)) {
|
||||||
// value 是数组类型 { type: 'JSSlot', value: IPublicTypeNodeSchema[] }
|
// value 是数组类型 { type: 'JSSlot', value: IPublicTypeNodeSchema[] }
|
||||||
if (Array.isArray(value.value)) {
|
if (Array.isArray(value.value)) {
|
||||||
@ -123,7 +123,7 @@ function getNodeSchemaFromPropsById(props: any, nodeId: string): IPublicTypeNode
|
|||||||
* TODO: not sure if this is used anywhere
|
* TODO: not sure if this is used anywhere
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
export function applyActivities(pivotSchema: IPublicTypeRootSchema, activities: any, options?: any): IPublicTypeRootSchema {
|
export function applyActivities(pivotSchema: IPublicTypeRootSchema, activities: any): IPublicTypeRootSchema {
|
||||||
let schema = { ...pivotSchema };
|
let schema = { ...pivotSchema };
|
||||||
if (!Array.isArray(activities)) {
|
if (!Array.isArray(activities)) {
|
||||||
activities = [activities];
|
activities = [activities];
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
IPluginPreferenceMananger,
|
IPluginPreferenceMananger,
|
||||||
IPublicApiEvent,
|
IPublicApiEvent,
|
||||||
|
IPublicApiWorkspace,
|
||||||
IPublicModelPluginContext,
|
IPublicModelPluginContext,
|
||||||
IPublicTypePluginMeta,
|
IPublicTypePluginMeta,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
@ -59,6 +60,7 @@ export class BasicContext implements IPublicModelPluginContext {
|
|||||||
canvas: Canvas;
|
canvas: Canvas;
|
||||||
pluginEvent: IPublicApiEvent;
|
pluginEvent: IPublicApiEvent;
|
||||||
preference: IPluginPreferenceMananger;
|
preference: IPluginPreferenceMananger;
|
||||||
|
workspace: IPublicApiWorkspace;
|
||||||
|
|
||||||
constructor(innerWorkspace: InnerWorkspace, viewName: string, public editorWindow?: EditorWindow) {
|
constructor(innerWorkspace: InnerWorkspace, viewName: string, public editorWindow?: EditorWindow) {
|
||||||
const editor = new Editor(viewName, true);
|
const editor = new Editor(viewName, true);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Designer } from '@alilc/lowcode-designer';
|
import { Designer, LowCodePluginManager } from '@alilc/lowcode-designer';
|
||||||
import { createModuleEventBus, Editor, IEventBus, makeObservable, obx } from '@alilc/lowcode-editor-core';
|
import { createModuleEventBus, Editor, IEventBus, makeObservable, obx } from '@alilc/lowcode-editor-core';
|
||||||
import { Plugins } from '@alilc/lowcode-shell';
|
import { Plugins } from '@alilc/lowcode-shell';
|
||||||
import { IPublicApiWorkspace, IPublicResourceList, IPublicTypeResourceType } from '@alilc/lowcode-types';
|
import { IPublicApiWorkspace, IPublicResourceList, IPublicTypeResourceType } from '@alilc/lowcode-types';
|
||||||
@ -15,7 +15,11 @@ enum event {
|
|||||||
|
|
||||||
const CHANGE_EVENT = 'resource.list.change';
|
const CHANGE_EVENT = 'resource.list.change';
|
||||||
|
|
||||||
export class Workspace implements IPublicApiWorkspace {
|
interface IWorkspace extends Omit<IPublicApiWorkspace<
|
||||||
|
LowCodePluginManager
|
||||||
|
>, 'resourceList'> {}
|
||||||
|
|
||||||
|
export class Workspace implements IWorkspace {
|
||||||
context: BasicContext;
|
context: BasicContext;
|
||||||
|
|
||||||
private emitter: IEventBus = createModuleEventBus('workspace');
|
private emitter: IEventBus = createModuleEventBus('workspace');
|
||||||
@ -134,7 +138,7 @@ export class Workspace implements IPublicApiWorkspace {
|
|||||||
this.emitChangeWindow();
|
this.emitChangeWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
removeEditorWindow(resourceName: string, title: string) {
|
removeEditorWindow(resourceName: string) {
|
||||||
const index = this.windows.findIndex(d => (d.resource.name === resourceName && d.title));
|
const index = this.windows.findIndex(d => (d.resource.name === resourceName && d.title));
|
||||||
this.remove(index);
|
this.remove(index);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user