fix(amis-editor): addChild新增reGenerateId参数控制,可避免组件id替换导致事件动作失效问题

This commit is contained in:
wibetter 2023-12-26 14:35:04 +08:00
parent 082b0d6398
commit 71bc2772b8

View File

@ -873,7 +873,7 @@ export class EditorManager {
* @param rendererIdOrSchema
* ID添加新元素schema片段添加新元素
*/
async addElem(rendererIdOrSchema: string | any) {
async addElem(rendererIdOrSchema: string | any, reGenerateId?: boolean) {
if (!rendererIdOrSchema) {
return;
}
@ -1009,7 +1009,13 @@ export class EditorManager {
regionNodeRegion,
value,
nextId,
subRenderer
subRenderer,
{
id: store.dragId,
type: store.dragType,
data: store.dragSchema
},
reGenerateId
);
if (child) {
// mobx 修改数据是异步的
@ -1541,14 +1547,15 @@ export class EditorManager {
id: string;
type: string;
data: any;
}
},
reGenerateId?: boolean
): any | null {
const store = this.store;
let index: number = -1;
const commonContext = this.buildEventContext(id);
// 填充id有些脚手架生成了复杂的布局等自动填充一下id
let curChildJson = JSONPipeIn(json, true);
let curChildJson = JSONPipeIn(json, reGenerateId ?? true); // 默认重新生成id
if (beforeId) {
const arr = commonContext.schema[region];