fix: clone payload data when call add element api #308

This commit is contained in:
Hufe921
2023-11-01 20:46:53 +08:00
parent a94328fa95
commit aeefca34ca
+4 -3
View File
@@ -1920,11 +1920,12 @@ export class CommandAdapt {
if (!payload.length) return if (!payload.length) return
const isReadonly = this.draw.isReadonly() const isReadonly = this.draw.isReadonly()
if (isReadonly) return if (isReadonly) return
const cloneElementList = deepClone(payload)
// 格式化上下文信息 // 格式化上下文信息
const { startIndex } = this.range.getRange() const { startIndex } = this.range.getRange()
const elementList = this.draw.getElementList() const elementList = this.draw.getElementList()
formatElementContext(elementList, payload, startIndex) formatElementContext(elementList, cloneElementList, startIndex)
this.draw.insertElementList(payload) this.draw.insertElementList(cloneElementList)
} }
public appendElementList( public appendElementList(
@@ -1934,7 +1935,7 @@ export class CommandAdapt {
if (!elementList.length) return if (!elementList.length) return
const isReadonly = this.draw.isReadonly() const isReadonly = this.draw.isReadonly()
if (isReadonly) return if (isReadonly) return
this.draw.appendElementList(elementList, options) this.draw.appendElementList(deepClone(elementList), options)
} }
public setValue(payload: Partial<IEditorData>) { public setValue(payload: Partial<IEditorData>) {