improve: control operation history boundary #540
This commit is contained in:
@@ -2304,31 +2304,7 @@ export class Draw {
|
|||||||
(isSubmitHistory && !isFirstRender) ||
|
(isSubmitHistory && !isFirstRender) ||
|
||||||
(curIndex !== undefined && this.historyManager.isStackEmpty())
|
(curIndex !== undefined && this.historyManager.isStackEmpty())
|
||||||
) {
|
) {
|
||||||
const oldElementList = getSlimCloneElementList(this.elementList)
|
this.submitHistory(curIndex)
|
||||||
const oldHeaderElementList = getSlimCloneElementList(
|
|
||||||
this.header.getElementList()
|
|
||||||
)
|
|
||||||
const oldFooterElementList = getSlimCloneElementList(
|
|
||||||
this.footer.getElementList()
|
|
||||||
)
|
|
||||||
const oldRange = deepClone(this.range.getRange())
|
|
||||||
const pageNo = this.pageNo
|
|
||||||
const oldPositionContext = deepClone(positionContext)
|
|
||||||
const zone = this.zone.getZone()
|
|
||||||
this.historyManager.execute(() => {
|
|
||||||
this.zone.setZone(zone)
|
|
||||||
this.setPageNo(pageNo)
|
|
||||||
this.position.setPositionContext(deepClone(oldPositionContext))
|
|
||||||
this.header.setElementList(deepClone(oldHeaderElementList))
|
|
||||||
this.footer.setElementList(deepClone(oldFooterElementList))
|
|
||||||
this.elementList = deepClone(oldElementList)
|
|
||||||
this.range.replaceRange(deepClone(oldRange))
|
|
||||||
this.render({
|
|
||||||
curIndex,
|
|
||||||
isSubmitHistory: false,
|
|
||||||
isSourceHistory: true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
// 信息变动回调
|
// 信息变动回调
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@@ -2359,6 +2335,35 @@ export class Draw {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public submitHistory(curIndex: number | undefined) {
|
||||||
|
const positionContext = this.position.getPositionContext()
|
||||||
|
const oldElementList = getSlimCloneElementList(this.elementList)
|
||||||
|
const oldHeaderElementList = getSlimCloneElementList(
|
||||||
|
this.header.getElementList()
|
||||||
|
)
|
||||||
|
const oldFooterElementList = getSlimCloneElementList(
|
||||||
|
this.footer.getElementList()
|
||||||
|
)
|
||||||
|
const oldRange = deepClone(this.range.getRange())
|
||||||
|
const pageNo = this.pageNo
|
||||||
|
const oldPositionContext = deepClone(positionContext)
|
||||||
|
const zone = this.zone.getZone()
|
||||||
|
this.historyManager.execute(() => {
|
||||||
|
this.zone.setZone(zone)
|
||||||
|
this.setPageNo(pageNo)
|
||||||
|
this.position.setPositionContext(deepClone(oldPositionContext))
|
||||||
|
this.header.setElementList(deepClone(oldHeaderElementList))
|
||||||
|
this.footer.setElementList(deepClone(oldFooterElementList))
|
||||||
|
this.elementList = deepClone(oldElementList)
|
||||||
|
this.range.replaceRange(deepClone(oldRange))
|
||||||
|
this.render({
|
||||||
|
curIndex,
|
||||||
|
isSubmitHistory: false,
|
||||||
|
isSourceHistory: true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
public destroy() {
|
public destroy() {
|
||||||
this.container.remove()
|
this.container.remove()
|
||||||
this.globalEvent.removeEvent()
|
this.globalEvent.removeEvent()
|
||||||
|
|||||||
@@ -420,11 +420,18 @@ export class Control {
|
|||||||
startElement.controlComponent === ControlComponent.PLACEHOLDER ||
|
startElement.controlComponent === ControlComponent.PLACEHOLDER ||
|
||||||
nextElement.controlComponent === ControlComponent.PLACEHOLDER
|
nextElement.controlComponent === ControlComponent.PLACEHOLDER
|
||||||
) {
|
) {
|
||||||
|
let isHasSubmitHistory = false
|
||||||
let index = startIndex
|
let index = startIndex
|
||||||
while (index < elementList.length) {
|
while (index < elementList.length) {
|
||||||
const curElement = elementList[index]
|
const curElement = elementList[index]
|
||||||
if (curElement.controlId !== startElement.controlId) break
|
if (curElement.controlId !== startElement.controlId) break
|
||||||
if (curElement.controlComponent === ControlComponent.PLACEHOLDER) {
|
if (curElement.controlComponent === ControlComponent.PLACEHOLDER) {
|
||||||
|
// 删除占位符时替换前一个历史记录
|
||||||
|
if (!isHasSubmitHistory) {
|
||||||
|
isHasSubmitHistory = true
|
||||||
|
this.draw.getHistoryManager().popUndo()
|
||||||
|
this.draw.submitHistory(startIndex)
|
||||||
|
}
|
||||||
this.draw.spliceElementList(elementList, index, 1)
|
this.draw.spliceElementList(elementList, index, 1)
|
||||||
} else {
|
} else {
|
||||||
index++
|
index++
|
||||||
|
|||||||
@@ -54,4 +54,8 @@ export class HistoryManager {
|
|||||||
this.undoStack = []
|
this.undoStack = []
|
||||||
this.redoStack = []
|
this.redoStack = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public popUndo() {
|
||||||
|
return this.undoStack.pop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user