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