mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-07 02:47:12 +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 { 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 { Skeleton as InnerSkeleton } from '@ali/lowcode-editor-skeleton';
|
||||||
import {
|
import {
|
||||||
Hotkey,
|
Hotkey,
|
||||||
@ -27,9 +27,10 @@ export default class PluginContext implements ILowCodePluginContext {
|
|||||||
public material: Material;
|
public material: Material;
|
||||||
public config: EngineConfig;
|
public config: EngineConfig;
|
||||||
public event: Event;
|
public event: Event;
|
||||||
|
public plugins: ILowCodePluginManager;
|
||||||
|
|
||||||
constructor(editor: Editor, options: PluginContextOptions) {
|
constructor(plugins: ILowCodePluginManager, options: PluginContextOptions) {
|
||||||
this[editorSymbol] = editor;
|
const editor = this[editorSymbol] = plugins.editor;
|
||||||
const designer = this[designerSymbol] = editor.get('designer')!;
|
const designer = this[designerSymbol] = editor.get('designer')!;
|
||||||
const skeleton = this[skeletonSymbol] = editor.get('skeleton')!;
|
const skeleton = this[skeletonSymbol] = editor.get('skeleton')!;
|
||||||
|
|
||||||
@ -41,7 +42,8 @@ export default class PluginContext implements ILowCodePluginContext {
|
|||||||
this.setters = new Setters();
|
this.setters = new Setters();
|
||||||
this.material = new Material(editor);
|
this.material = new Material(editor);
|
||||||
this.config = engineConfig;
|
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}` });
|
this.logger = getLogger({ level: 'warn', bizName: `designer:plugin:${pluginName}` });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ export class LowCodePluginManager implements ILowCodePluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _getLowCodePluginContext(options: PluginContextOptions) {
|
private _getLowCodePluginContext(options: PluginContextOptions) {
|
||||||
return new LowCodePluginContext(this.editor, options);
|
return new LowCodePluginContext(this, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async register(
|
async register(
|
||||||
|
|||||||
@ -1,12 +1,16 @@
|
|||||||
import { CompositeObject, ComponentAction } from '@ali/lowcode-types';
|
import { CompositeObject, ComponentAction } from '@ali/lowcode-types';
|
||||||
import Logger from 'zen-logger';
|
import Logger from 'zen-logger';
|
||||||
import { Skeleton } from '@ali/lowcode-editor-skeleton';
|
import {
|
||||||
import { Editor, Hotkey, EngineConfig } from '@ali/lowcode-editor-core';
|
Hotkey,
|
||||||
|
Skeleton,
|
||||||
|
Project,
|
||||||
|
Event, Material,
|
||||||
|
} from '@ali/lowcode-shell';
|
||||||
|
import { Editor, EngineConfig } from '@ali/lowcode-editor-core';
|
||||||
import {
|
import {
|
||||||
MetadataTransducer,
|
MetadataTransducer,
|
||||||
Designer,
|
Designer,
|
||||||
} from '@ali/lowcode-designer';
|
} from '@ali/lowcode-designer';
|
||||||
import { Event, Material } from '@ali/lowcode-shell';
|
|
||||||
import { Setters, Utils } from '../types';
|
import { Setters, Utils } from '../types';
|
||||||
|
|
||||||
export interface ILowCodePluginConfig {
|
export interface ILowCodePluginConfig {
|
||||||
@ -47,17 +51,15 @@ export interface IDesignerCabin {
|
|||||||
|
|
||||||
export interface ILowCodePluginContext {
|
export interface ILowCodePluginContext {
|
||||||
skeleton: Skeleton;
|
skeleton: Skeleton;
|
||||||
// designer: Designer;
|
|
||||||
// editor: Editor;
|
|
||||||
hotkey: Hotkey;
|
hotkey: Hotkey;
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
// plugins: ILowCodePluginManager;
|
plugins: ILowCodePluginManager;
|
||||||
// designerCabin: IDesignerCabin;
|
|
||||||
setters: Setters;
|
setters: Setters;
|
||||||
// utils: Utils;
|
config: EngineConfig;
|
||||||
engineConfig: EngineConfig;
|
|
||||||
material: Material;
|
material: Material;
|
||||||
event: Event;
|
event: Event;
|
||||||
|
project: Project;
|
||||||
|
// utils: Utils;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ILowCodePluginManagerPluginAccessor {
|
interface ILowCodePluginManagerPluginAccessor {
|
||||||
|
|||||||
@ -50,11 +50,6 @@ editor.set('plugins' as any, plugins);
|
|||||||
|
|
||||||
const { project: innerProject, currentSelection: selection } = designer;
|
const { project: innerProject, currentSelection: selection } = designer;
|
||||||
const { Workbench } = skeletonCabin;
|
const { Workbench } = skeletonCabin;
|
||||||
// const setters: Setters = {
|
|
||||||
// getSetter,
|
|
||||||
// registerSetter,
|
|
||||||
// getSettersMap,
|
|
||||||
// };
|
|
||||||
|
|
||||||
const hotkey = new Hotkey();
|
const hotkey = new Hotkey();
|
||||||
const project = new Project(innerProject);
|
const project = new Project(innerProject);
|
||||||
@ -64,9 +59,16 @@ const material = new Material(editor);
|
|||||||
const config = engineConfig;
|
const config = engineConfig;
|
||||||
const event = new Event(editor, { prefix: 'common' });
|
const event = new Event(editor, { prefix: 'common' });
|
||||||
const logger = getLogger({ level: 'warn', bizName: 'common' });
|
const logger = getLogger({ level: 'warn', bizName: 'common' });
|
||||||
|
const common = {
|
||||||
|
utils,
|
||||||
|
editorCabin,
|
||||||
|
designerCabin,
|
||||||
|
skeletonCabin,
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
// editor,
|
// editor,
|
||||||
|
common,
|
||||||
editorCabin,
|
editorCabin,
|
||||||
// skeleton,
|
// skeleton,
|
||||||
skeletonCabin,
|
skeletonCabin,
|
||||||
@ -85,7 +87,6 @@ export {
|
|||||||
*/
|
*/
|
||||||
// store,
|
// store,
|
||||||
hotkey,
|
hotkey,
|
||||||
utils,
|
|
||||||
config,
|
config,
|
||||||
event,
|
event,
|
||||||
logger,
|
logger,
|
||||||
@ -106,30 +107,17 @@ const getSelection = () => designer.currentDocument?.selection;
|
|||||||
editorCabin,
|
editorCabin,
|
||||||
skeletonCabin,
|
skeletonCabin,
|
||||||
designerCabin,
|
designerCabin,
|
||||||
|
common,
|
||||||
plugins,
|
plugins,
|
||||||
skeleton,
|
skeleton,
|
||||||
project,
|
project,
|
||||||
setters,
|
setters,
|
||||||
material,
|
material,
|
||||||
// get selection() {
|
|
||||||
// return getSelection();
|
|
||||||
// },
|
|
||||||
/**
|
|
||||||
* 注册一些全局的切面
|
|
||||||
*/
|
|
||||||
// hooks,
|
|
||||||
/**
|
|
||||||
* 全局的一些数据存储
|
|
||||||
*/
|
|
||||||
// store,
|
|
||||||
// hotkey,
|
|
||||||
init,
|
init,
|
||||||
utils,
|
|
||||||
config,
|
config,
|
||||||
event,
|
event,
|
||||||
logger,
|
logger,
|
||||||
hotkey,
|
hotkey,
|
||||||
// engineConfig,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理 editor.set('assets'),将组件元数据创建好
|
// 处理 editor.set('assets'),将组件元数据创建好
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user