mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:39:05 +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,
|
||||
isSubEditor,
|
||||
amisDocHost: props.amisDocHost,
|
||||
ctx: props.ctx,
|
||||
superEditorData,
|
||||
appLocale: props.appLocale,
|
||||
appCorpusData: props?.amisEnv?.replaceText,
|
||||
@ -174,6 +173,7 @@ export default class Editor extends Component<EditorProps> {
|
||||
},
|
||||
config
|
||||
);
|
||||
this.store.setCtx(props.ctx);
|
||||
this.store.setSchema(value);
|
||||
if (showCustomRenderersPanel !== undefined) {
|
||||
this.store.setShowCustomRenderersPanel(showCustomRenderersPanel);
|
||||
|
@ -114,7 +114,8 @@ export default class IFramePreview extends React.Component<IFramePreviewProps> {
|
||||
...rest,
|
||||
key: editable ? 'edit-mode' : 'preview-mode',
|
||||
theme: env.theme,
|
||||
data: data ?? store.ctx,
|
||||
data: data,
|
||||
context: store.ctx,
|
||||
locale: appLocale,
|
||||
editorDialogMountNode: this.getDialogMountRef
|
||||
},
|
||||
|
@ -686,7 +686,8 @@ class SmartPreview extends React.Component<SmartPreviewProps> {
|
||||
...rest,
|
||||
key: editable ? 'edit-mode' : 'preview-mode',
|
||||
theme: env.theme,
|
||||
data: data ?? store.ctx,
|
||||
data: data,
|
||||
context: store.ctx,
|
||||
locale: appLocale,
|
||||
editorDialogMountNode: this.getDialogMountRef
|
||||
},
|
||||
|
@ -5,7 +5,8 @@ import {
|
||||
mapTree,
|
||||
eachTree,
|
||||
extendObject,
|
||||
createObject
|
||||
createObject,
|
||||
extractObjectChain
|
||||
} from 'amis-core';
|
||||
import {cast, getEnv, Instance, types} from 'mobx-state-tree';
|
||||
import {
|
||||
@ -1060,6 +1061,15 @@ export const MainStore = types
|
||||
},
|
||||
|
||||
setCtx(value: any) {
|
||||
if (value?.__super) {
|
||||
// context 不支持链式,如果这样下发了,需要转成普通对象。
|
||||
// 目前平台会下发这种数据,为了防止数据丢失做个处理
|
||||
value = extractObjectChain(value).reduce(
|
||||
(obj, item) => Object.assign(obj, item),
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
self.ctx = value;
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user