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

pr675
Hufe921 2 years ago
parent a94328fa95
commit aeefca34ca

@ -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>) {

Loading…
Cancel
Save