From c905aa27c3ace6e756987d1437f8086c4d8fa0a3 Mon Sep 17 00:00:00 2001 From: liujuping Date: Fri, 10 Feb 2023 17:53:16 +0800 Subject: [PATCH] feat: added detailed definition of some skeleton.add parameters --- packages/editor-skeleton/src/skeleton.ts | 8 +++++--- packages/editor-skeleton/src/types.ts | 10 +++------- packages/shell/src/api/skeleton.ts | 6 +++--- packages/types/src/shell/api/skeleton.ts | 6 +++--- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/editor-skeleton/src/skeleton.ts b/packages/editor-skeleton/src/skeleton.ts index 90fba2e1b..22f165b1d 100644 --- a/packages/editor-skeleton/src/skeleton.ts +++ b/packages/editor-skeleton/src/skeleton.ts @@ -26,6 +26,7 @@ import { PluginClassSet, IPublicTypeWidgetBaseConfig, IPublicTypeWidgetConfigArea, + IPublicTypeSkeletonConfig, } from '@alilc/lowcode-types'; const logger = new Logger({ level: 'warn', bizName: 'skeleton' }); @@ -66,6 +67,8 @@ export class Skeleton { readonly stages: Area; + readonly widgets: IWidget[] = []; + constructor(readonly editor: Editor, readonly viewName: string = 'global') { makeObservable(this); this.leftArea = new Area( @@ -179,6 +182,7 @@ export class Skeleton { this.setupPlugins(); this.setupEvents(); } + /** * setup events * @@ -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; @@ -377,7 +379,7 @@ export class Skeleton { return restConfig; } - add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record) { + add(config: IPublicTypeSkeletonConfig, extraConfig?: Record) { const parsedConfig = { ...this.parseConfig(config), ...extraConfig, diff --git a/packages/editor-skeleton/src/types.ts b/packages/editor-skeleton/src/types.ts index e8579005c..b3e5a0408 100644 --- a/packages/editor-skeleton/src/types.ts +++ b/packages/editor-skeleton/src/types.ts @@ -6,6 +6,7 @@ import { TipContent, IPublicTypeWidgetConfigArea, IPublicTypeWidgetBaseConfig, + IPublicTypePanelDockPanelProps, } from '@alilc/lowcode-types'; import { IWidget } from './widget/widget'; @@ -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; }; } @@ -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; diff --git a/packages/shell/src/api/skeleton.ts b/packages/shell/src/api/skeleton.ts index a60746803..e9bb28328 100644 --- a/packages/shell/src/api/skeleton.ts +++ b/packages/shell/src/api/skeleton.ts @@ -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 { @@ -38,7 +38,7 @@ export class Skeleton implements IPublicApiSkeleton { * @param extraConfig * @returns */ - add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record) { + add(config: IPublicTypeSkeletonConfig, extraConfig?: Record) { const configWithName = { ...config, pluginName: this.pluginName, @@ -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)) { diff --git a/packages/types/src/shell/api/skeleton.ts b/packages/types/src/shell/api/skeleton.ts index 5c1f69c02..b22b3586c 100644 --- a/packages/types/src/shell/api/skeleton.ts +++ b/packages/types/src/shell/api/skeleton.ts @@ -1,4 +1,4 @@ -import { IPublicTypeDisposable, IPublicTypeWidgetBaseConfig } from '../type'; +import { IPublicTypeDisposable, IPublicTypeSkeletonConfig } from '../type'; export interface IPublicApiSkeleton { @@ -9,7 +9,7 @@ export interface IPublicApiSkeleton { * @param extraConfig * @returns */ - add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record): any; + add(config: IPublicTypeSkeletonConfig, extraConfig?: Record): any; /** * 移除一个面板实例 @@ -17,7 +17,7 @@ export interface IPublicApiSkeleton { * @param config * @returns */ - remove(config: IPublicTypeWidgetBaseConfig): number | undefined; + remove(config: IPublicTypeSkeletonConfig): number | undefined; /** * 展示指定 Panel 实例