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