diff --git a/packages/designer/src/plugin/plugin-context.ts b/packages/designer/src/plugin/plugin-context.ts index 1b585d810..45fa348f2 100644 --- a/packages/designer/src/plugin/plugin-context.ts +++ b/packages/designer/src/plugin/plugin-context.ts @@ -1,5 +1,5 @@ import { Editor, EngineConfig, engineConfig } from '@ali/lowcode-editor-core'; -import { Designer } from '@ali/lowcode-designer'; +import { Designer, ILowCodePluginManager } from '@ali/lowcode-designer'; import { Skeleton as InnerSkeleton } from '@ali/lowcode-editor-skeleton'; import { Hotkey, @@ -27,9 +27,10 @@ export default class PluginContext implements ILowCodePluginContext { public material: Material; public config: EngineConfig; public event: Event; + public plugins: ILowCodePluginManager; - constructor(editor: Editor, options: PluginContextOptions) { - this[editorSymbol] = editor; + constructor(plugins: ILowCodePluginManager, options: PluginContextOptions) { + const editor = this[editorSymbol] = plugins.editor; const designer = this[designerSymbol] = editor.get('designer')!; const skeleton = this[skeletonSymbol] = editor.get('skeleton')!; @@ -41,7 +42,8 @@ export default class PluginContext implements ILowCodePluginContext { this.setters = new Setters(); this.material = new Material(editor); this.config = engineConfig; - this.event = new Event(editor, { prefix: `plugin:${pluginName}` }); + this.plugins = plugins; + this.event = new Event(editor, { prefix: 'common' }); this.logger = getLogger({ level: 'warn', bizName: `designer:plugin:${pluginName}` }); } } diff --git a/packages/designer/src/plugin/plugin-manager.ts b/packages/designer/src/plugin/plugin-manager.ts index 7d70ed670..74e1a103e 100644 --- a/packages/designer/src/plugin/plugin-manager.ts +++ b/packages/designer/src/plugin/plugin-manager.ts @@ -27,7 +27,7 @@ export class LowCodePluginManager implements ILowCodePluginManager { } private _getLowCodePluginContext(options: PluginContextOptions) { - return new LowCodePluginContext(this.editor, options); + return new LowCodePluginContext(this, options); } async register( diff --git a/packages/designer/src/plugin/plugin-types.ts b/packages/designer/src/plugin/plugin-types.ts index aac8528ae..d7801f03c 100644 --- a/packages/designer/src/plugin/plugin-types.ts +++ b/packages/designer/src/plugin/plugin-types.ts @@ -1,12 +1,16 @@ import { CompositeObject, ComponentAction } from '@ali/lowcode-types'; import Logger from 'zen-logger'; -import { Skeleton } from '@ali/lowcode-editor-skeleton'; -import { Editor, Hotkey, EngineConfig } from '@ali/lowcode-editor-core'; +import { + Hotkey, + Skeleton, + Project, + Event, Material, +} from '@ali/lowcode-shell'; +import { Editor, EngineConfig } from '@ali/lowcode-editor-core'; import { MetadataTransducer, Designer, } from '@ali/lowcode-designer'; -import { Event, Material } from '@ali/lowcode-shell'; import { Setters, Utils } from '../types'; export interface ILowCodePluginConfig { @@ -47,17 +51,15 @@ export interface IDesignerCabin { export interface ILowCodePluginContext { skeleton: Skeleton; - // designer: Designer; - // editor: Editor; hotkey: Hotkey; logger: Logger; - // plugins: ILowCodePluginManager; - // designerCabin: IDesignerCabin; + plugins: ILowCodePluginManager; setters: Setters; - // utils: Utils; - engineConfig: EngineConfig; + config: EngineConfig; material: Material; event: Event; + project: Project; + // utils: Utils; } interface ILowCodePluginManagerPluginAccessor { diff --git a/packages/engine/src/engine-core.ts b/packages/engine/src/engine-core.ts index d30af7d84..ac90ba345 100644 --- a/packages/engine/src/engine-core.ts +++ b/packages/engine/src/engine-core.ts @@ -50,11 +50,6 @@ editor.set('plugins' as any, plugins); const { project: innerProject, currentSelection: selection } = designer; const { Workbench } = skeletonCabin; -// const setters: Setters = { -// getSetter, -// registerSetter, -// getSettersMap, -// }; const hotkey = new Hotkey(); const project = new Project(innerProject); @@ -64,9 +59,16 @@ const material = new Material(editor); const config = engineConfig; const event = new Event(editor, { prefix: 'common' }); const logger = getLogger({ level: 'warn', bizName: 'common' }); +const common = { + utils, + editorCabin, + designerCabin, + skeletonCabin, +}; export { // editor, + common, editorCabin, // skeleton, skeletonCabin, @@ -85,7 +87,6 @@ export { */ // store, hotkey, - utils, config, event, logger, @@ -106,30 +107,17 @@ const getSelection = () => designer.currentDocument?.selection; editorCabin, skeletonCabin, designerCabin, + common, plugins, skeleton, project, setters, material, - // get selection() { - // return getSelection(); - // }, - /** - * 注册一些全局的切面 - */ - // hooks, - /** - * 全局的一些数据存储 - */ - // store, - // hotkey, init, - utils, config, event, logger, hotkey, - // engineConfig, }; // 处理 editor.set('assets'),将组件元数据创建好