mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 20:18:03 +08:00
弹框支持选择外部组件
Change-Id: Ib8f64cedad9502f3c35169e782dc4df25450366d
This commit is contained in:
parent
84b802a404
commit
9446269317
@ -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
|
||||
);
|
||||
|
@ -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({
|
||||
|
@ -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',
|
||||
|
@ -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 || {}
|
||||
}
|
||||
};
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user