feat(workspace): add config for resource shell model

This commit is contained in:
liujuping 2023-04-26 10:24:17 +08:00 committed by 林熠
parent 5b1423068e
commit c3d75b27da
8 changed files with 26 additions and 3 deletions

View File

@ -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,

View File

@ -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;
}

View File

@ -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() {

View File

@ -18,6 +18,10 @@ export interface IBaseModelResource<
get children(): Resource[];
get viewName(): string | undefined;
get config(): {
disableBehaviors?: ('copy' | 'remove')[];
} | undefined;
}
export type IPublicModelResource = IBaseModelResource<IPublicModelResource>;

View File

@ -23,7 +23,7 @@ export interface IPublicModelWindow<
*
* @since v1.1.7
*/
currentEditorView: IPublicModelEditorView;
currentEditorView: IPublicModelEditorView | null;
/**
*

View File

@ -24,6 +24,10 @@ export interface IPublicResourceData {
/** 资源子元素 */
children?: IPublicResourceData[];
config?: {
disableBehaviors?: ('copy' | 'remove')[];
};
}
export type IPublicResourceList = IPublicResourceData[];

View File

@ -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);

View File

@ -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({