diff --git a/packages/designer/src/plugin/plugin-context.ts b/packages/designer/src/plugin/plugin-context.ts index f43134c75..94e296fd1 100644 --- a/packages/designer/src/plugin/plugin-context.ts +++ b/packages/designer/src/plugin/plugin-context.ts @@ -17,6 +17,8 @@ import { IPublicTypePluginDeclaration, IPublicApiCanvas, IPublicApiWorkspace, + IPublicEnumPluginRegisterLevel, + IPublicModelWindow, } from '@alilc/lowcode-types'; import { IPluginContextOptions, @@ -41,6 +43,8 @@ export default class PluginContext implements pluginEvent: IPublicApiEvent; canvas: IPublicApiCanvas; workspace: IPublicApiWorkspace; + registerLevel: IPublicEnumPluginRegisterLevel; + editorWindow: IPublicModelWindow; constructor( options: IPluginContextOptions, diff --git a/packages/shell/src/model/resource.ts b/packages/shell/src/model/resource.ts index b2b065398..43f28fbd8 100644 --- a/packages/shell/src/model/resource.ts +++ b/packages/shell/src/model/resource.ts @@ -25,6 +25,10 @@ export class Resource implements IPublicModelResource { return this[resourceSymbol].resourceType.name; } + get config() { + return this[resourceSymbol].config; + } + get type() { return this[resourceSymbol].resourceType.type; } diff --git a/packages/shell/src/model/window.ts b/packages/shell/src/model/window.ts index 6af2534dd..f539e9567 100644 --- a/packages/shell/src/model/window.ts +++ b/packages/shell/src/model/window.ts @@ -44,7 +44,10 @@ export class Window implements IPublicModelWindow { } get currentEditorView() { - return new EditorView(this[windowSymbol].editorView).toProxy() as any; + if (this[windowSymbol].editorView) { + return new EditorView(this[windowSymbol].editorView).toProxy() as any; + } + return null; } get editorViews() { diff --git a/packages/types/src/shell/model/resource.ts b/packages/types/src/shell/model/resource.ts index e18f3d503..1f59845e6 100644 --- a/packages/types/src/shell/model/resource.ts +++ b/packages/types/src/shell/model/resource.ts @@ -18,6 +18,10 @@ export interface IBaseModelResource< get children(): Resource[]; get viewName(): string | undefined; + + get config(): { + disableBehaviors?: ('copy' | 'remove')[]; + } | undefined; } export type IPublicModelResource = IBaseModelResource; diff --git a/packages/types/src/shell/model/window.ts b/packages/types/src/shell/model/window.ts index 5f77b0cbf..a33be6ceb 100644 --- a/packages/types/src/shell/model/window.ts +++ b/packages/types/src/shell/model/window.ts @@ -23,7 +23,7 @@ export interface IPublicModelWindow< * 窗口当前视图 * @since v1.1.7 */ - currentEditorView: IPublicModelEditorView; + currentEditorView: IPublicModelEditorView | null; /** * 窗口全部视图实例 diff --git a/packages/types/src/shell/type/resource-list.ts b/packages/types/src/shell/type/resource-list.ts index 5831d7b50..7abdcc7b1 100644 --- a/packages/types/src/shell/type/resource-list.ts +++ b/packages/types/src/shell/type/resource-list.ts @@ -24,6 +24,10 @@ export interface IPublicResourceData { /** 资源子元素 */ children?: IPublicResourceData[]; + + config?: { + disableBehaviors?: ('copy' | 'remove')[]; + }; } export type IPublicResourceList = IPublicResourceData[]; \ No newline at end of file diff --git a/packages/workspace/src/context/base-context.ts b/packages/workspace/src/context/base-context.ts index b12a78183..b359a6139 100644 --- a/packages/workspace/src/context/base-context.ts +++ b/packages/workspace/src/context/base-context.ts @@ -101,7 +101,7 @@ export class BasicContext implements IBasicContext { preference: IPluginPreferenceMananger; workspace: IWorkspace; - constructor(innerWorkspace: IWorkspace, viewName: string, registerLevel: IPublicEnumPluginRegisterLevel, public editorWindow?: IEditorWindow) { + constructor(innerWorkspace: IWorkspace, viewName: string, readonly registerLevel: IPublicEnumPluginRegisterLevel, public editorWindow?: IEditorWindow) { const editor = new Editor(viewName, true); const innerSkeleton = new InnerSkeleton(editor, viewName); diff --git a/packages/workspace/src/resource.ts b/packages/workspace/src/resource.ts index e51993c81..8c59aed1e 100644 --- a/packages/workspace/src/resource.ts +++ b/packages/workspace/src/resource.ts @@ -74,6 +74,10 @@ export class Resource implements IResource { return this.resourceData?.children?.map(d => new Resource(d, this.workspace.getResourceType(d.resourceName || this.resourceType.name), this.workspace)) || []; } + get config() { + return this.resourceData.config; + } + constructor(readonly resourceData: IPublicResourceData, readonly resourceType: IResourceType, readonly workspace: IWorkspace) { this.context = new BasicContext(workspace, `resource-${resourceData.resourceName || resourceType.name}`, IPublicEnumPluginRegisterLevel.Resource); this.resourceTypeInstance = resourceType.resourceTypeModel(this.context.innerPlugins._getLowCodePluginContext({