Skip to content

Commit

Permalink
feat: added detailed definition of some skeleton.add parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
liujuping authored and JackLian committed Feb 13, 2023
1 parent ac21100 commit c905aa2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
8 changes: 5 additions & 3 deletions packages/editor-skeleton/src/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
PluginClassSet,
IPublicTypeWidgetBaseConfig,
IPublicTypeWidgetConfigArea,
IPublicTypeSkeletonConfig,
} from '@alilc/lowcode-types';

const logger = new Logger({ level: 'warn', bizName: 'skeleton' });
Expand Down Expand Up @@ -66,6 +67,8 @@ export class Skeleton {

readonly stages: Area<StageConfig, Stage>;

readonly widgets: IWidget[] = [];

constructor(readonly editor: Editor, readonly viewName: string = 'global') {
makeObservable(this);
this.leftArea = new Area(
Expand Down Expand Up @@ -179,6 +182,7 @@ export class Skeleton {
this.setupPlugins();
this.setupEvents();
}

/**
* setup events
*
Expand Down Expand Up @@ -277,8 +281,6 @@ export class Skeleton {
this.editor.eventBus.emit(event, ...args);
}

readonly widgets: IWidget[] = [];

createWidget(config: IPublicTypeWidgetBaseConfig | IWidget) {
if (isWidget(config)) {
return config;
Expand Down Expand Up @@ -377,7 +379,7 @@ export class Skeleton {
return restConfig;
}

add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record<string, any>) {
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>) {
const parsedConfig = {
...this.parseConfig(config),
...extraConfig,
Expand Down
10 changes: 3 additions & 7 deletions packages/editor-skeleton/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TipContent,
IPublicTypeWidgetConfigArea,
IPublicTypeWidgetBaseConfig,
IPublicTypePanelDockPanelProps,
} from '@alilc/lowcode-types';
import { IWidget } from './widget/widget';

Expand Down Expand Up @@ -63,8 +64,8 @@ export function isDockConfig(obj: any): obj is DockConfig {
export interface DialogDockConfig extends IDockBaseConfig {
type: 'DialogDock';
dialogProps?: {
title?: IPublicTypeTitleContent;
[key: string]: any;
title?: IPublicTypeTitleContent;
};
}

Expand All @@ -85,16 +86,11 @@ export function isPanelConfig(obj: any): obj is PanelConfig {

export type HelpTipConfig = string | { url?: string; content?: string | ReactElement };

export interface PanelProps {
export interface PanelProps extends IPublicTypePanelDockPanelProps {
title?: IPublicTypeTitleContent;
icon?: any; // 冗余字段
description?: string | IPublicTypeI18nData;
hideTitleBar?: boolean; // panel.props 兼容,不暴露
help?: HelpTipConfig; // 显示问号帮助
width?: number; // panel.props
height?: number; // panel.props
maxWidth?: number; // panel.props
maxHeight?: number; // panel.props
hiddenWhenInit?: boolean; // when this is true, by default will be hidden
condition?: (widget: IWidget) => any;
onInit?: (widget: IWidget) => any;
Expand Down
6 changes: 3 additions & 3 deletions packages/shell/src/api/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
SkeletonEvents,
} from '@alilc/lowcode-editor-skeleton';
import { skeletonSymbol } from '../symbols';
import { IPublicApiSkeleton, IPublicTypeDisposable, IPublicTypeWidgetBaseConfig, IPublicTypeWidgetConfigArea } from '@alilc/lowcode-types';
import { IPublicApiSkeleton, IPublicTypeDisposable, IPublicTypeSkeletonConfig, IPublicTypeWidgetConfigArea } from '@alilc/lowcode-types';

const innerSkeletonSymbol = Symbol('skeleton');
export class Skeleton implements IPublicApiSkeleton {
Expand Down Expand Up @@ -38,7 +38,7 @@ export class Skeleton implements IPublicApiSkeleton {
* @param extraConfig
* @returns
*/
add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record<string, any>) {
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>) {
const configWithName = {
...config,
pluginName: this.pluginName,
Expand All @@ -51,7 +51,7 @@ export class Skeleton implements IPublicApiSkeleton {
* @param config
* @returns
*/
remove(config: IPublicTypeWidgetBaseConfig): number | undefined {
remove(config: IPublicTypeSkeletonConfig): number | undefined {
const { area, name } = config;
const skeleton = this[skeletonSymbol];
if (!normalizeArea(area)) {
Expand Down
6 changes: 3 additions & 3 deletions packages/types/src/shell/api/skeleton.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IPublicTypeDisposable, IPublicTypeWidgetBaseConfig } from '../type';
import { IPublicTypeDisposable, IPublicTypeSkeletonConfig } from '../type';

export interface IPublicApiSkeleton {

Expand All @@ -9,15 +9,15 @@ export interface IPublicApiSkeleton {
* @param extraConfig
* @returns
*/
add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record<string, any>): any;
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>): any;

/**
* 移除一个面板实例
* remove a panel
* @param config
* @returns
*/
remove(config: IPublicTypeWidgetBaseConfig): number | undefined;
remove(config: IPublicTypeSkeletonConfig): number | undefined;

/**
* 展示指定 Panel 实例
Expand Down

0 comments on commit c905aa2

Please sign in to comment.