mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
Merge pull request #10612 from hsm-lv/fix-dialog-ctx
fix: 修复编辑器预览模式弹窗的上下文信息会丢失的问题
This commit is contained in:
commit
9ee12b4160
@ -166,7 +166,6 @@ export default class Editor extends Component<EditorProps> {
|
|||||||
theme: props.theme,
|
theme: props.theme,
|
||||||
isSubEditor,
|
isSubEditor,
|
||||||
amisDocHost: props.amisDocHost,
|
amisDocHost: props.amisDocHost,
|
||||||
ctx: props.ctx,
|
|
||||||
superEditorData,
|
superEditorData,
|
||||||
appLocale: props.appLocale,
|
appLocale: props.appLocale,
|
||||||
appCorpusData: props?.amisEnv?.replaceText,
|
appCorpusData: props?.amisEnv?.replaceText,
|
||||||
@ -174,6 +173,7 @@ export default class Editor extends Component<EditorProps> {
|
|||||||
},
|
},
|
||||||
config
|
config
|
||||||
);
|
);
|
||||||
|
this.store.setCtx(props.ctx);
|
||||||
this.store.setSchema(value);
|
this.store.setSchema(value);
|
||||||
if (showCustomRenderersPanel !== undefined) {
|
if (showCustomRenderersPanel !== undefined) {
|
||||||
this.store.setShowCustomRenderersPanel(showCustomRenderersPanel);
|
this.store.setShowCustomRenderersPanel(showCustomRenderersPanel);
|
||||||
|
@ -114,7 +114,8 @@ export default class IFramePreview extends React.Component<IFramePreviewProps> {
|
|||||||
...rest,
|
...rest,
|
||||||
key: editable ? 'edit-mode' : 'preview-mode',
|
key: editable ? 'edit-mode' : 'preview-mode',
|
||||||
theme: env.theme,
|
theme: env.theme,
|
||||||
data: data ?? store.ctx,
|
data: data,
|
||||||
|
context: store.ctx,
|
||||||
locale: appLocale,
|
locale: appLocale,
|
||||||
editorDialogMountNode: this.getDialogMountRef
|
editorDialogMountNode: this.getDialogMountRef
|
||||||
},
|
},
|
||||||
|
@ -686,7 +686,8 @@ class SmartPreview extends React.Component<SmartPreviewProps> {
|
|||||||
...rest,
|
...rest,
|
||||||
key: editable ? 'edit-mode' : 'preview-mode',
|
key: editable ? 'edit-mode' : 'preview-mode',
|
||||||
theme: env.theme,
|
theme: env.theme,
|
||||||
data: data ?? store.ctx,
|
data: data,
|
||||||
|
context: store.ctx,
|
||||||
locale: appLocale,
|
locale: appLocale,
|
||||||
editorDialogMountNode: this.getDialogMountRef
|
editorDialogMountNode: this.getDialogMountRef
|
||||||
},
|
},
|
||||||
|
@ -5,7 +5,8 @@ import {
|
|||||||
mapTree,
|
mapTree,
|
||||||
eachTree,
|
eachTree,
|
||||||
extendObject,
|
extendObject,
|
||||||
createObject
|
createObject,
|
||||||
|
extractObjectChain
|
||||||
} from 'amis-core';
|
} from 'amis-core';
|
||||||
import {cast, getEnv, Instance, types} from 'mobx-state-tree';
|
import {cast, getEnv, Instance, types} from 'mobx-state-tree';
|
||||||
import {
|
import {
|
||||||
@ -1060,6 +1061,15 @@ export const MainStore = types
|
|||||||
},
|
},
|
||||||
|
|
||||||
setCtx(value: any) {
|
setCtx(value: any) {
|
||||||
|
if (value?.__super) {
|
||||||
|
// context 不支持链式,如果这样下发了,需要转成普通对象。
|
||||||
|
// 目前平台会下发这种数据,为了防止数据丢失做个处理
|
||||||
|
value = extractObjectChain(value).reduce(
|
||||||
|
(obj, item) => Object.assign(obj, item),
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
self.ctx = value;
|
self.ctx = value;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user