mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-06 10:27:22 +00:00
feat: 增加 common API
This commit is contained in:
parent
70a81d2a77
commit
eca95b288f
@ -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}` });
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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'),将组件元数据创建好
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user