mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 03:01:16 +00:00
feat: add skeleton item model
This commit is contained in:
parent
9947a36d17
commit
239bb29de1
@ -141,7 +141,7 @@ export interface IDocumentModel extends Omit<IPublicModelDocumentModel<
|
|||||||
|
|
||||||
insertNodes(parent: INode, thing: INode[] | IPublicTypeNodeData[], at?: number | null, copy?: boolean): INode[];
|
insertNodes(parent: INode, thing: INode[] | IPublicTypeNodeData[], at?: number | null, copy?: boolean): INode[];
|
||||||
|
|
||||||
open(): DocumentModel;
|
open(): IDocumentModel;
|
||||||
|
|
||||||
remove(): void;
|
remove(): void;
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,8 @@ export type UNSET = typeof UNSET;
|
|||||||
export interface IProp extends Omit<IPublicModelProp<
|
export interface IProp extends Omit<IPublicModelProp<
|
||||||
INode
|
INode
|
||||||
>, 'exportSchema' | 'node'>, IPropParent {
|
>, 'exportSchema' | 'node'>, IPropParent {
|
||||||
|
spread: boolean;
|
||||||
|
|
||||||
key: string | number | undefined;
|
key: string | number | undefined;
|
||||||
|
|
||||||
readonly props: IProps;
|
readonly props: IProps;
|
||||||
@ -42,6 +44,8 @@ export interface IProp extends Omit<IPublicModelProp<
|
|||||||
|
|
||||||
setupItems(): IProp[] | null;
|
setupItems(): IProp[] | null;
|
||||||
|
|
||||||
|
isVirtual(): boolean;
|
||||||
|
|
||||||
get type(): ValueTypes;
|
get type(): ValueTypes;
|
||||||
|
|
||||||
get size(): number;
|
get size(): number;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { obx, computed, makeObservable, action, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
|
import { obx, computed, makeObservable, action, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
|
||||||
import { IDesigner } from '../designer';
|
import { IDesigner } from '../designer';
|
||||||
import { DocumentModel, isDocumentModel } from '../document';
|
import { DocumentModel, isDocumentModel } from '../document';
|
||||||
import type { IDocumentModel } from "../document";
|
import type { IDocumentModel } from '../document';
|
||||||
import {
|
import {
|
||||||
IPublicTypeComponentsMap,
|
IPublicTypeComponentsMap,
|
||||||
IPublicEnumTransformStage,
|
IPublicEnumTransformStage,
|
||||||
@ -317,13 +317,13 @@ export class Project implements IProject {
|
|||||||
doc = this.createDocument();
|
doc = this.createDocument();
|
||||||
return doc.open();
|
return doc.open();
|
||||||
}
|
}
|
||||||
if (typeof doc === 'string') {
|
if (typeof doc === 'string' || typeof doc === 'number') {
|
||||||
const got = this.documents.find((item) => item.fileName === doc || item.id === doc);
|
const got = this.documents.find((item) => item.fileName === String(doc) || String(item.id) === String(doc));
|
||||||
if (got) {
|
if (got) {
|
||||||
return got.open();
|
return got.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = this.data.componentsTree.find((data) => data.fileName === doc);
|
const data = this.data.componentsTree.find((data) => data.fileName === String(doc));
|
||||||
if (data) {
|
if (data) {
|
||||||
doc = this.createDocument(data);
|
doc = this.createDocument(data);
|
||||||
return doc.open();
|
return doc.open();
|
||||||
|
|||||||
@ -56,7 +56,8 @@ export interface ISkeleton extends Omit<IPublicApiSkeleton,
|
|||||||
'onShowWidget' |
|
'onShowWidget' |
|
||||||
'onHideWidget' |
|
'onHideWidget' |
|
||||||
'remove' |
|
'remove' |
|
||||||
'hideArea'
|
'hideArea' |
|
||||||
|
'add'
|
||||||
> {
|
> {
|
||||||
editor: IEditor;
|
editor: IEditor;
|
||||||
|
|
||||||
@ -101,6 +102,8 @@ export interface ISkeleton extends Omit<IPublicApiSkeleton,
|
|||||||
): WidgetContainer;
|
): WidgetContainer;
|
||||||
|
|
||||||
createPanel(config: PanelConfig): Panel;
|
createPanel(config: PanelConfig): Panel;
|
||||||
|
|
||||||
|
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>): IWidget | Widget | Panel | Stage | Dock | PanelDock | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Skeleton {
|
export class Skeleton {
|
||||||
@ -440,7 +443,7 @@ export class Skeleton {
|
|||||||
return restConfig;
|
return restConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>) {
|
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>): IWidget | Widget | Panel | Stage | Dock | PanelDock | undefined {
|
||||||
const parsedConfig = {
|
const parsedConfig = {
|
||||||
...this.parseConfig(config),
|
...this.parseConfig(config),
|
||||||
...extraConfig,
|
...extraConfig,
|
||||||
|
|||||||
@ -211,6 +211,10 @@ export class Panel implements IWidget {
|
|||||||
this.setActive(false);
|
this.setActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disable() {}
|
||||||
|
|
||||||
|
enable(): void {}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
this.setActive(true);
|
this.setActive(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import {
|
|||||||
Selection,
|
Selection,
|
||||||
Prop,
|
Prop,
|
||||||
SimulatorHost,
|
SimulatorHost,
|
||||||
|
SkeletonItem,
|
||||||
} from '@alilc/lowcode-shell';
|
} from '@alilc/lowcode-shell';
|
||||||
import { Node as InnerNode } from '@alilc/lowcode-designer';
|
import { Node as InnerNode } from '@alilc/lowcode-designer';
|
||||||
|
|
||||||
@ -26,4 +27,5 @@ export default {
|
|||||||
Selection,
|
Selection,
|
||||||
Prop,
|
Prop,
|
||||||
SimulatorHost,
|
SimulatorHost,
|
||||||
|
SkeletonItem,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import {
|
|||||||
designerCabinSymbol,
|
designerCabinSymbol,
|
||||||
propSymbol,
|
propSymbol,
|
||||||
simulatorHostSymbol,
|
simulatorHostSymbol,
|
||||||
|
skeletonItemSymbol,
|
||||||
} from '@alilc/lowcode-shell';
|
} from '@alilc/lowcode-shell';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -26,4 +27,5 @@ export default {
|
|||||||
designerCabinSymbol,
|
designerCabinSymbol,
|
||||||
propSymbol,
|
propSymbol,
|
||||||
simulatorHostSymbol,
|
simulatorHostSymbol,
|
||||||
|
skeletonItemSymbol,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,8 +4,9 @@ import {
|
|||||||
SkeletonEvents,
|
SkeletonEvents,
|
||||||
} from '@alilc/lowcode-editor-skeleton';
|
} from '@alilc/lowcode-editor-skeleton';
|
||||||
import { skeletonSymbol } from '../symbols';
|
import { skeletonSymbol } from '../symbols';
|
||||||
import { IPublicApiSkeleton, IPublicTypeDisposable, IPublicTypeSkeletonConfig, IPublicTypeWidgetConfigArea } from '@alilc/lowcode-types';
|
import { IPublicApiSkeleton, IPublicModelSkeletonItem, IPublicTypeDisposable, IPublicTypeSkeletonConfig, IPublicTypeWidgetConfigArea } from '@alilc/lowcode-types';
|
||||||
import { getLogger } from '@alilc/lowcode-utils';
|
import { getLogger } from '@alilc/lowcode-utils';
|
||||||
|
import { SkeletonItem } from '../model/skeleton-item';
|
||||||
|
|
||||||
const innerSkeletonSymbol = Symbol('skeleton');
|
const innerSkeletonSymbol = Symbol('skeleton');
|
||||||
|
|
||||||
@ -46,12 +47,15 @@ export class Skeleton implements IPublicApiSkeleton {
|
|||||||
* @param extraConfig
|
* @param extraConfig
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>) {
|
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>): IPublicModelSkeletonItem | undefined {
|
||||||
const configWithName = {
|
const configWithName = {
|
||||||
...config,
|
...config,
|
||||||
pluginName: this.pluginName,
|
pluginName: this.pluginName,
|
||||||
};
|
};
|
||||||
return this[skeletonSymbol].add(configWithName, extraConfig);
|
const item = this[skeletonSymbol].add(configWithName, extraConfig);
|
||||||
|
if (item) {
|
||||||
|
return new SkeletonItem(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,6 +72,10 @@ export class Skeleton implements IPublicApiSkeleton {
|
|||||||
skeleton[normalizeArea(area)].container?.remove(name);
|
skeleton[normalizeArea(area)].container?.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAreaItems(areaName: IPublicTypeWidgetConfigArea): IPublicModelSkeletonItem[] {
|
||||||
|
return this[skeletonSymbol][normalizeArea(areaName)].container.items?.map(d => new SkeletonItem(d));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示面板
|
* 显示面板
|
||||||
* @param name
|
* @param name
|
||||||
@ -193,7 +201,7 @@ export class Skeleton implements IPublicApiSkeleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeArea(area: IPublicTypeWidgetConfigArea | undefined): 'leftArea' | 'rightArea' | 'topArea' | 'toolbar' | 'mainArea' | 'bottomArea' | 'leftFixedArea' | 'leftFloatArea' | 'stages' {
|
function normalizeArea(area: IPublicTypeWidgetConfigArea | undefined): 'leftArea' | 'rightArea' | 'topArea' | 'toolbar' | 'mainArea' | 'bottomArea' | 'leftFixedArea' | 'leftFloatArea' | 'stages' | 'subTopArea' {
|
||||||
switch (area) {
|
switch (area) {
|
||||||
case 'leftArea':
|
case 'leftArea':
|
||||||
case 'left':
|
case 'left':
|
||||||
@ -220,6 +228,8 @@ function normalizeArea(area: IPublicTypeWidgetConfigArea | undefined): 'leftArea
|
|||||||
return 'leftFloatArea';
|
return 'leftFloatArea';
|
||||||
case 'stages':
|
case 'stages':
|
||||||
return 'stages';
|
return 'stages';
|
||||||
|
case 'subTopArea':
|
||||||
|
return 'subTopArea';
|
||||||
default:
|
default:
|
||||||
throw new Error(`${area} not supported`);
|
throw new Error(`${area} not supported`);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import {
|
|||||||
Clipboard,
|
Clipboard,
|
||||||
SettingField,
|
SettingField,
|
||||||
Window,
|
Window,
|
||||||
|
SkeletonItem,
|
||||||
} from './model';
|
} from './model';
|
||||||
import {
|
import {
|
||||||
Project,
|
Project,
|
||||||
@ -66,4 +67,5 @@ export {
|
|||||||
SimulatorHost,
|
SimulatorHost,
|
||||||
Config,
|
Config,
|
||||||
SettingField,
|
SettingField,
|
||||||
|
SkeletonItem,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -20,3 +20,4 @@ export * from './plugin-instance';
|
|||||||
export * from './window';
|
export * from './window';
|
||||||
export * from './clipboard';
|
export * from './clipboard';
|
||||||
export * from './editor-view';
|
export * from './editor-view';
|
||||||
|
export * from './skeleton-item';
|
||||||
|
|||||||
31
packages/shell/src/model/skeleton-item.ts
Normal file
31
packages/shell/src/model/skeleton-item.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { skeletonItemSymbol } from '../symbols';
|
||||||
|
import { IPublicModelSkeletonItem } from '@alilc/lowcode-types';
|
||||||
|
import { Dock, IWidget, Panel, PanelDock, Stage, Widget } from '@alilc/lowcode-editor-skeleton';
|
||||||
|
|
||||||
|
export class SkeletonItem implements IPublicModelSkeletonItem {
|
||||||
|
private [skeletonItemSymbol]: IWidget | Widget | Panel | Stage | Dock | PanelDock;
|
||||||
|
|
||||||
|
constructor(skeletonItem: IWidget | Widget | Panel | Stage | Dock | PanelDock) {
|
||||||
|
this[skeletonItemSymbol] = skeletonItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
get name() {
|
||||||
|
return this[skeletonItemSymbol].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
disable() {
|
||||||
|
this[skeletonItemSymbol].disable?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
enable() {
|
||||||
|
this[skeletonItemSymbol].enable?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
hide() {
|
||||||
|
this[skeletonItemSymbol].hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
show() {
|
||||||
|
this[skeletonItemSymbol].show();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -36,3 +36,4 @@ export const configSymbol = Symbol('configSymbol');
|
|||||||
export const conditionGroupSymbol = Symbol('conditionGroup');
|
export const conditionGroupSymbol = Symbol('conditionGroup');
|
||||||
export const editorViewSymbol = Symbol('editorView');
|
export const editorViewSymbol = Symbol('editorView');
|
||||||
export const pluginContextSymbol = Symbol('pluginContext');
|
export const pluginContextSymbol = Symbol('pluginContext');
|
||||||
|
export const skeletonItemSymbol = Symbol('skeletonItem');
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { IPublicModelSkeletonItem } from '../model';
|
||||||
import { IPublicTypeDisposable, IPublicTypeSkeletonConfig } from '../type';
|
import { IPublicTypeDisposable, IPublicTypeSkeletonConfig } from '../type';
|
||||||
|
|
||||||
export interface IPublicApiSkeleton {
|
export interface IPublicApiSkeleton {
|
||||||
@ -9,7 +10,7 @@ export interface IPublicApiSkeleton {
|
|||||||
* @param extraConfig
|
* @param extraConfig
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>): any;
|
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>): IPublicModelSkeletonItem | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除一个面板实例
|
* 移除一个面板实例
|
||||||
|
|||||||
@ -31,3 +31,4 @@ export * from './resource';
|
|||||||
export * from './clipboard';
|
export * from './clipboard';
|
||||||
export * from './setting-field';
|
export * from './setting-field';
|
||||||
export * from './editor-view';
|
export * from './editor-view';
|
||||||
|
export * from './skeleton-item';
|
||||||
|
|||||||
6
packages/types/src/shell/model/skeleton-item.ts
Normal file
6
packages/types/src/shell/model/skeleton-item.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* @since 1.1.7
|
||||||
|
*/
|
||||||
|
export interface IPublicModelSkeletonItem {
|
||||||
|
|
||||||
|
}
|
||||||
@ -7,7 +7,9 @@ import { IEditorWindow } from '../window';
|
|||||||
import { getWebviewPlugin } from '../inner-plugins/webview';
|
import { getWebviewPlugin } from '../inner-plugins/webview';
|
||||||
|
|
||||||
export interface IViewContext extends IBasicContext {
|
export interface IViewContext extends IBasicContext {
|
||||||
|
editorWindow: IEditorWindow;
|
||||||
|
|
||||||
|
viewName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Context extends BasicContext implements IViewContext {
|
export class Context extends BasicContext implements IViewContext {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user