mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-11 10:26:03 +00:00
chore: 兼容 editor, 实际提供的是 event 对象
This commit is contained in:
parent
e75cdc99a7
commit
7b8e1d862d
@ -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,10 +40,12 @@ 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);
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
@ -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:
|
||||||
/**
|
/**
|
||||||
* 内核触发的事件名
|
* 内核触发的事件名
|
||||||
*/
|
*/
|
||||||
@ -41,3 +42,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,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,
|
||||||
};
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user