mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-17 11:13:50 +00:00
Merge branch '2.x-211223' into chore/method-declaration
This commit is contained in:
commit
af791d1d19
@ -5,7 +5,9 @@
|
|||||||
"registry": "http://registry.antfin-inc.com",
|
"registry": "http://registry.antfin-inc.com",
|
||||||
"useWorkspaces": true,
|
"useWorkspaces": true,
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*",
|
||||||
|
"!packages/code-generator",
|
||||||
|
"!packages/material-parser"
|
||||||
],
|
],
|
||||||
"command": {
|
"command": {
|
||||||
"bootstrap": {
|
"bootstrap": {
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
"lib",
|
"lib",
|
||||||
"es"
|
"es"
|
||||||
],
|
],
|
||||||
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-scripts build --skip-demo",
|
"build": "build-scripts build --skip-demo",
|
||||||
"test": "build-scripts test --config build.test.json",
|
"test": "build-scripts test --config build.test.json",
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { autorun, reaction, mobx, untracked, globalContext, Editor } from '@ali/lowcode-editor-core';
|
import { autorun, reaction, mobx, untracked, globalContext, Editor } from '@ali/lowcode-editor-core';
|
||||||
import { NodeSchema } from '@ali/lowcode-types';
|
import { NodeSchema } from '@ali/lowcode-types';
|
||||||
|
import { History as ShellHistory } from '@ali/lowcode-shell';
|
||||||
|
|
||||||
// TODO: cache to localStorage
|
// TODO: cache to localStorage
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ export class History {
|
|||||||
this.redoer(currentSerialization.unserialize(hotData));
|
this.redoer(currentSerialization.unserialize(hotData));
|
||||||
this.emitter.emit('cursor', hotData);
|
this.emitter.emit('cursor', hotData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.wakeup();
|
this.wakeup();
|
||||||
@ -194,6 +195,10 @@ export class History {
|
|||||||
isModified() {
|
isModified() {
|
||||||
return this.isSavePoint();
|
return this.isSavePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internalToShellHistory() {
|
||||||
|
return new ShellHistory(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Session {
|
class Session {
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
"lib",
|
"lib",
|
||||||
"es"
|
"es"
|
||||||
],
|
],
|
||||||
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-scripts build --skip-demo"
|
"build": "build-scripts build --skip-demo"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
"lib",
|
"lib",
|
||||||
"es"
|
"es"
|
||||||
],
|
],
|
||||||
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-scripts build --skip-demo"
|
"build": "build-scripts build --skip-demo"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export class SettingsPrimaryPane extends Component<{ editor: Editor; config: any
|
|||||||
state = {
|
state = {
|
||||||
shouldIgnoreRoot: false,
|
shouldIgnoreRoot: false,
|
||||||
};
|
};
|
||||||
private main = new SettingsMain(this.props.editor);
|
private main = new SettingsMain(globalContext.get('editor'));
|
||||||
|
|
||||||
@obx.ref private _activeKey?: any;
|
@obx.ref private _activeKey?: any;
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ export class SettingsPrimaryPane extends Component<{ editor: Editor; config: any
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.setShouldIgnoreRoot();
|
this.setShouldIgnoreRoot();
|
||||||
|
|
||||||
this.props.editor.on('designer.selection.change', () => {
|
globalContext.get('editor').on('designer.selection.change', () => {
|
||||||
if (!engineConfig.get('stayOnTheSameSettingTab', false)) {
|
if (!engineConfig.get('stayOnTheSameSettingTab', false)) {
|
||||||
this._activeKey = null;
|
this._activeKey = null;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ export class SettingsPrimaryPane extends Component<{ editor: Editor; config: any
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setShouldIgnoreRoot() {
|
async setShouldIgnoreRoot() {
|
||||||
const designMode = await this.props.editor.get('designMode');
|
const designMode = await globalContext.get('editor').get('designMode');
|
||||||
this.setState({
|
this.setState({
|
||||||
shouldIgnoreRoot: designMode === 'live',
|
shouldIgnoreRoot: designMode === 'live',
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { ReactNode, createElement } from 'react';
|
import { ReactNode, createElement } from 'react';
|
||||||
import { makeObservable, obx } from '@ali/lowcode-editor-core';
|
import { makeObservable, obx } from '@ali/lowcode-editor-core';
|
||||||
import { uniqueId, createContent } from '@ali/lowcode-utils';
|
import { uniqueId, createContent } from '@ali/lowcode-utils';
|
||||||
|
import { getEvent } from '@ali/lowcode-shell';
|
||||||
import { DockConfig } from '../types';
|
import { DockConfig } from '../types';
|
||||||
import { Skeleton } from '../skeleton';
|
import { Skeleton } from '../skeleton';
|
||||||
import { DockView, WidgetView } from '../components/widget-views';
|
import { DockView, WidgetView } from '../components/widget-views';
|
||||||
@ -48,7 +49,7 @@ export default class Dock implements IWidget {
|
|||||||
this._body = createContent(content, {
|
this._body = createContent(content, {
|
||||||
...contentProps,
|
...contentProps,
|
||||||
config: this.config,
|
config: this.config,
|
||||||
editor: this.skeleton.editor,
|
editor: getEvent(this.skeleton.editor),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this._body = createElement(DockView, props);
|
this._body = createElement(DockView, props);
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { obx, computed, makeObservable } from '@ali/lowcode-editor-core';
|
|||||||
import { uniqueId, createContent } from '@ali/lowcode-utils';
|
import { uniqueId, createContent } from '@ali/lowcode-utils';
|
||||||
import { TitleContent } from '@ali/lowcode-types';
|
import { TitleContent } from '@ali/lowcode-types';
|
||||||
import WidgetContainer from './widget-container';
|
import WidgetContainer from './widget-container';
|
||||||
|
import { getEvent } from '@ali/lowcode-shell';
|
||||||
import { PanelConfig, HelpTipConfig } from '../types';
|
import { PanelConfig, HelpTipConfig } from '../types';
|
||||||
import { TitledPanelView, TabsPanelView, PanelView } from '../components/widget-views';
|
import { TitledPanelView, TabsPanelView, PanelView } from '../components/widget-views';
|
||||||
import { Skeleton } from '../skeleton';
|
import { Skeleton } from '../skeleton';
|
||||||
@ -51,7 +52,7 @@ export default class Panel implements IWidget {
|
|||||||
const { content, contentProps } = this.config;
|
const { content, contentProps } = this.config;
|
||||||
return createContent(content, {
|
return createContent(content, {
|
||||||
...contentProps,
|
...contentProps,
|
||||||
editor: this.skeleton.editor,
|
editor: getEvent(this.skeleton.editor),
|
||||||
config: this.config,
|
config: this.config,
|
||||||
panel: this,
|
panel: this,
|
||||||
pane: this,
|
pane: this,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { ReactNode, createElement } from 'react';
|
import { ReactNode, createElement } from 'react';
|
||||||
import { makeObservable, obx } from '@ali/lowcode-editor-core';
|
import { makeObservable, obx } from '@ali/lowcode-editor-core';
|
||||||
import { createContent, uniqueId } from '@ali/lowcode-utils';
|
import { createContent, uniqueId } from '@ali/lowcode-utils';
|
||||||
|
import { getEvent } from '@ali/lowcode-shell';
|
||||||
import { WidgetConfig, IWidgetBaseConfig } from '../types';
|
import { WidgetConfig, IWidgetBaseConfig } from '../types';
|
||||||
import { Skeleton } from '../skeleton';
|
import { Skeleton } from '../skeleton';
|
||||||
import { WidgetView } from '../components/widget-views';
|
import { WidgetView } from '../components/widget-views';
|
||||||
@ -56,7 +57,7 @@ export default class Widget implements IWidget {
|
|||||||
this._body = createContent(content, {
|
this._body = createContent(content, {
|
||||||
...contentProps,
|
...contentProps,
|
||||||
config: this.config,
|
config: this.config,
|
||||||
editor: this.skeleton.editor,
|
editor: getEvent(this.skeleton.editor),
|
||||||
});
|
});
|
||||||
return this._body;
|
return this._body;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,21 +40,18 @@ globalContext.register(editor, 'editor');
|
|||||||
const innerSkeleton = new InnerSkeleton(editor);
|
const innerSkeleton = new InnerSkeleton(editor);
|
||||||
editor.set(Skeleton, innerSkeleton);
|
editor.set(Skeleton, innerSkeleton);
|
||||||
editor.set('skeleton' as any, innerSkeleton);
|
editor.set('skeleton' as any, innerSkeleton);
|
||||||
|
engineConfig.set('skeleton' as any, innerSkeleton);
|
||||||
|
|
||||||
const designer = new Designer({ editor });
|
const designer = new Designer({ editor });
|
||||||
editor.set(Designer, designer);
|
editor.set(Designer, designer);
|
||||||
editor.set('designer' as any, designer);
|
editor.set('designer' as any, designer);
|
||||||
|
engineConfig.set('designer' as any, designer);
|
||||||
|
|
||||||
const plugins = new LowCodePluginManager(editor).toProxy();
|
const plugins = new LowCodePluginManager(editor).toProxy();
|
||||||
editor.set('plugins' as any, plugins);
|
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 +61,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 +89,6 @@ export {
|
|||||||
*/
|
*/
|
||||||
// store,
|
// store,
|
||||||
hotkey,
|
hotkey,
|
||||||
utils,
|
|
||||||
config,
|
config,
|
||||||
event,
|
event,
|
||||||
logger,
|
logger,
|
||||||
@ -106,30 +109,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'),将组件元数据创建好
|
||||||
|
|||||||
@ -18,3 +18,4 @@ export type RootNode = designerCabin.RootNode;
|
|||||||
export type EditingTarget = designerCabin.EditingTarget;
|
export type EditingTarget = designerCabin.EditingTarget;
|
||||||
export type SaveHandler = designerCabin.SaveHandler;
|
export type SaveHandler = designerCabin.SaveHandler;
|
||||||
export type ComponentMeta = designerCabin.ComponentMeta;
|
export type ComponentMeta = designerCabin.ComponentMeta;
|
||||||
|
export type SettingField = designerCabin.SettingField;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export {
|
export {
|
||||||
Title,
|
Title,
|
||||||
|
Tip,
|
||||||
shallowIntl,
|
shallowIntl,
|
||||||
createIntl,
|
createIntl,
|
||||||
createSetterContent,
|
createSetterContent,
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
"es",
|
"es",
|
||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
|
"private": true,
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
"stylePath": "style.js",
|
"stylePath": "style.js",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { Editor, engineConfig } from '@ali/lowcode-editor-core';
|
import { Editor, engineConfig, globalContext } from '@ali/lowcode-editor-core';
|
||||||
import { DesignerView, Designer } from '@ali/lowcode-designer';
|
import { DesignerView, Designer } from '@ali/lowcode-designer';
|
||||||
import { Asset } from '@ali/lowcode-utils';
|
import { Asset } from '@ali/lowcode-utils';
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
@ -46,7 +46,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async setupAssets() {
|
private async setupAssets() {
|
||||||
const { editor } = this.props;
|
const editor = globalContext.get('editor');
|
||||||
try {
|
try {
|
||||||
const assets = await editor.onceGot('assets');
|
const assets = await editor.onceGot('assets');
|
||||||
const renderEnv = engineConfig.get('renderEnv') || editor.get('renderEnv');
|
const renderEnv = engineConfig.get('renderEnv') || editor.get('renderEnv');
|
||||||
@ -85,7 +85,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
}
|
}
|
||||||
|
|
||||||
private handleDesignerMount = (designer: Designer): void => {
|
private handleDesignerMount = (designer: Designer): void => {
|
||||||
const { editor } = this.props;
|
const editor = globalContext.get('editor');
|
||||||
editor.set('designer', designer);
|
editor.set('designer', designer);
|
||||||
editor.emit('designer.ready', designer);
|
editor.emit('designer.ready', designer);
|
||||||
editor.onGot('schema', (schema) => {
|
editor.onGot('schema', (schema) => {
|
||||||
@ -94,7 +94,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
|
|||||||
};
|
};
|
||||||
|
|
||||||
render(): React.ReactNode {
|
render(): React.ReactNode {
|
||||||
const { editor } = this.props;
|
const editor = globalContext.get('editor');
|
||||||
const {
|
const {
|
||||||
componentMetadatas,
|
componentMetadatas,
|
||||||
utilsMetadata,
|
utilsMetadata,
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-scripts build --skip-demo"
|
"build": "build-scripts build --skip-demo"
|
||||||
},
|
},
|
||||||
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ali/lowcode-designer": "1.0.74",
|
"@ali/lowcode-designer": "1.0.74",
|
||||||
"@ali/lowcode-editor-core": "1.0.74",
|
"@ali/lowcode-editor-core": "1.0.74",
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { PureComponent } from 'react';
|
import { PureComponent } from 'react';
|
||||||
|
import { globalContext } from '@ali/lowcode-editor-core';
|
||||||
import { PluginProps } from '@ali/lowcode-types';
|
import { PluginProps } from '@ali/lowcode-types';
|
||||||
import { OutlinePane } from './pane';
|
import { OutlinePane } from './pane';
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ export class OutlineBackupPane extends PureComponent<PluginProps> {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<OutlinePane
|
<OutlinePane
|
||||||
editor={this.props.editor}
|
editor={globalContext.get('editor')}
|
||||||
config={{
|
config={{
|
||||||
name: Backup,
|
name: Backup,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { observer } from '@ali/lowcode-editor-core';
|
import { observer, globalContext } from '@ali/lowcode-editor-core';
|
||||||
import { intl } from '../locale';
|
import { intl } from '../locale';
|
||||||
import { OutlineMain } from '../main';
|
import { OutlineMain } from '../main';
|
||||||
import TreeView from './tree';
|
import TreeView from './tree';
|
||||||
@ -8,7 +8,7 @@ import { IEditor } from '@ali/lowcode-types';
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class OutlinePane extends Component<{ config: any; editor: IEditor }> {
|
export class OutlinePane extends Component<{ config: any; editor: IEditor }> {
|
||||||
private main = new OutlineMain(this.props.editor, this.props.config.name || this.props.config.pluginKey);
|
private main = new OutlineMain(globalContext.get('editor'), this.props.config.name || this.props.config.pluginKey);
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.main.purge();
|
this.main.purge();
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
"lib",
|
"lib",
|
||||||
"es"
|
"es"
|
||||||
],
|
],
|
||||||
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-scripts build --skip-demo",
|
"build": "build-scripts build --skip-demo",
|
||||||
"test": "build-scripts test --config build.test.json",
|
"test": "build-scripts test --config build.test.json",
|
||||||
|
|||||||
@ -42,7 +42,7 @@ export default class DocumentModel {
|
|||||||
this[editorSymbol] = document.designer.editor as Editor;
|
this[editorSymbol] = document.designer.editor as Editor;
|
||||||
this.selection = new Selection(document);
|
this.selection = new Selection(document);
|
||||||
this.detecting = new Detecting(document);
|
this.detecting = new Detecting(document);
|
||||||
this.history = new History(document);
|
this.history = new History(document.getHistory());
|
||||||
this.canvas = new Canvas(document.designer);
|
this.canvas = new Canvas(document.designer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Editor as InnerEditor } from '@ali/lowcode-editor-core';
|
import { Editor as InnerEditor, globalContext } from '@ali/lowcode-editor-core';
|
||||||
import { getLogger } from '@ali/lowcode-utils';
|
import { getLogger } from '@ali/lowcode-utils';
|
||||||
import { editorSymbol } from './symbols';
|
import { editorSymbol } from './symbols';
|
||||||
|
|
||||||
@ -12,6 +12,7 @@ export default class Event {
|
|||||||
private readonly [editorSymbol]: InnerEditor;
|
private readonly [editorSymbol]: InnerEditor;
|
||||||
private readonly options: EventOptions;
|
private readonly options: EventOptions;
|
||||||
|
|
||||||
|
// TODO:
|
||||||
/**
|
/**
|
||||||
* 内核触发的事件名
|
* 内核触发的事件名
|
||||||
*/
|
*/
|
||||||
@ -31,6 +32,10 @@ export default class Event {
|
|||||||
* @param listener 事件回调
|
* @param listener 事件回调
|
||||||
*/
|
*/
|
||||||
on(event: string, listener: (...args: unknown[]) => void) {
|
on(event: string, listener: (...args: unknown[]) => void) {
|
||||||
|
if (event.startsWith('designer')) {
|
||||||
|
logger.warn('designer events are disabled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
this[editorSymbol].on(event, listener);
|
this[editorSymbol].on(event, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,3 +62,7 @@ export default class Event {
|
|||||||
this[editorSymbol].emit(`${this.options.prefix}:${event}`, ...args);
|
this[editorSymbol].emit(`${this.options.prefix}:${event}`, ...args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getEvent(editor: InnerEditor, options: any = { prefix: 'common' }) {
|
||||||
|
return new Event(editor, options);
|
||||||
|
}
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
import { History as InnerHistory, DocumentModel as InnerDocumentModel } from '@ali/lowcode-designer';
|
import { History as InnerHistory, DocumentModel as InnerDocumentModel } from '@ali/lowcode-designer';
|
||||||
import { documentSymbol, historySymbol } from './symbols';
|
import { historySymbol } from './symbols';
|
||||||
|
|
||||||
export default class History {
|
export default class History {
|
||||||
private readonly [documentSymbol]: InnerDocumentModel;
|
|
||||||
private readonly [historySymbol]: InnerHistory;
|
private readonly [historySymbol]: InnerHistory;
|
||||||
|
|
||||||
constructor(document: InnerDocumentModel) {
|
constructor(history: InnerHistory) {
|
||||||
this[documentSymbol] = document;
|
this[historySymbol] = history;
|
||||||
this[historySymbol] = this[documentSymbol].getHistory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import Detecting from './detecting';
|
import Detecting from './detecting';
|
||||||
// import Dragon from './dragon';
|
// import Dragon from './dragon';
|
||||||
import DocumentModel from './document-model';
|
import DocumentModel from './document-model';
|
||||||
import Event from './event';
|
import Event, { getEvent } from './event';
|
||||||
import History from './history';
|
import History from './history';
|
||||||
import Material from './material';
|
import Material from './material';
|
||||||
import Node from './node';
|
import Node from './node';
|
||||||
@ -35,4 +35,5 @@ export {
|
|||||||
Hotkey,
|
Hotkey,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
SettingPropEntry,
|
SettingPropEntry,
|
||||||
|
getEvent,
|
||||||
};
|
};
|
||||||
@ -120,7 +120,10 @@ export default class Project {
|
|||||||
* 当前 project 内的 document 变更事件
|
* 当前 project 内的 document 变更事件
|
||||||
*/
|
*/
|
||||||
onChangeDocument(fn: (doc: DocumentModel) => void) {
|
onChangeDocument(fn: (doc: DocumentModel) => void) {
|
||||||
// TODO: 思考一下是否要实现补偿触发能力
|
if (this[projectSymbol].currentDocument) {
|
||||||
|
fn(DocumentModel.create(this[projectSymbol].currentDocument)!);
|
||||||
|
return () => {};
|
||||||
|
}
|
||||||
return this[projectSymbol].onCurrentDocumentChange((originalDoc) => {
|
return this[projectSymbol].onCurrentDocumentChange((originalDoc) => {
|
||||||
fn(DocumentModel.create(originalDoc)!);
|
fn(DocumentModel.create(originalDoc)!);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
"es",
|
"es",
|
||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
|
"private": true,
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -3,10 +3,13 @@ const fs = require('fs');
|
|||||||
const { join } = require('path');
|
const { join } = require('path');
|
||||||
|
|
||||||
const packagesDir = join(__dirname, '../packages');
|
const packagesDir = join(__dirname, '../packages');
|
||||||
|
const blacklistPkgNames = ['code-generator', 'material-parser'];
|
||||||
|
|
||||||
const dirs = fs.readdirSync(packagesDir);
|
const dirs = fs.readdirSync(packagesDir);
|
||||||
dirs
|
dirs
|
||||||
.filter(dir => !dir.startsWith('.'))
|
.filter(dir => {
|
||||||
|
return !dir.startsWith('.') && !blacklistPkgNames.includes(dir);
|
||||||
|
})
|
||||||
.forEach(dir => {
|
.forEach(dir => {
|
||||||
const pkgDir = join(packagesDir, dir);
|
const pkgDir = join(packagesDir, dir);
|
||||||
const pkg = JSON.parse(fs.readFileSync(join(pkgDir, 'package.json'), 'utf-8'));
|
const pkg = JSON.parse(fs.readFileSync(join(pkgDir, 'package.json'), 'utf-8'));
|
||||||
|
|||||||
@ -1,4 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
eslintType: 'typescript/react',
|
|
||||||
enableStylelint: false,
|
|
||||||
};
|
|
||||||
Loading…
x
Reference in New Issue
Block a user