弹框支持选择外部组件

Change-Id: Ib8f64cedad9502f3c35169e782dc4df25450366d
This commit is contained in:
pianruijie 2022-07-19 21:22:58 +08:00
parent 84b802a404
commit 9446269317
4 changed files with 14 additions and 4 deletions

View File

@ -30,6 +30,7 @@ export interface EditorProps extends PluginEventListener {
theme?: string;
showCustomRenderersPanel?: boolean;
amisDocHost?: string;
superEditorData?: any;
withSuperDataSchema?: boolean;
dataBindingChange?: (
value: string,
@ -114,8 +115,8 @@ export default class Editor extends Component<EditorProps> {
value,
isSubEditor = false,
onChange,
data,
showCustomRenderersPanel,
superEditorData,
...rest
} = props;
@ -129,6 +130,7 @@ export default class Editor extends Component<EditorProps> {
isSubEditor,
amisDocHost: props.amisDocHost,
ctx: props.ctx,
superEditorData
},
config
);

View File

@ -67,7 +67,6 @@ export class RightPanels extends React.Component<
const id = store.activeId;
const node = store.getNodeById(id);
const panelKey = store.getPanelKey();
const renderPanel = (panel: PanelItem) => {
return panel.render ? (
panel.render({

View File

@ -2,6 +2,8 @@ import React from 'react';
import {EditorManager} from '../manager';
import {EditorStoreType} from '../store/editor';
import {render} from 'amis';
import {createObject} from 'amis-core';
import {observer} from 'mobx-react';
import Editor from './Editor';
import {
@ -96,6 +98,7 @@ export class SubEditor extends React.Component<SubEditorProps> {
const {store, manager} = this.props;
const subEditorContext = store.subEditorContext;
const config = manager.config;
const superEditorData = store.isSubEditor ? createObject(store.superEditorData, store.subEditorContext?.data?.__super) : store.subEditorContext?.data?.__super;
return {
size: 'full',
@ -134,6 +137,7 @@ export class SubEditor extends React.Component<SubEditorProps> {
ref={store.subEditorRef}
onChange={onChange}
data={store.subEditorContext?.data}
superEditorData={superEditorData}
schemaFilter={manager.config.schemaFilter}
theme={manager.env.theme}
afterResolveEditorInfo={this.afterResolveEditorInfo}
@ -200,7 +204,6 @@ export class SubEditor extends React.Component<SubEditorProps> {
render() {
const {store, theme, manager} = this.props;
return render(
{
type: 'dialog',

View File

@ -1,4 +1,4 @@
import {findTree, getVariable, mapObject} from 'amis-core';
import {findTree, getVariable, mapObject, createObject} from 'amis-core';
import {cast, getEnv, Instance, types} from 'mobx-state-tree';
import {
diff,
@ -188,6 +188,8 @@ export const EditorStore = types
// 弹出子编辑器相关的信息
subEditorContext: types.maybe(types.frozen<SubEditorContext>()),
// 子编辑器中可能需要拿到父编辑器的数据
superEditorData: types.maybe(types.frozen()),
calculateStarted: false,
@ -846,6 +848,10 @@ export const EditorStore = types
item => item.versionId === self.versionId
);
return idx < self.schemaHistory.length - 1;
},
get getSuperEditorData() {
return self.superEditorData || {}
}
};
})