fix: [planning-design] Ctrl+X 후 Ctrl+Z 복구 안 되는 문제 수정

This commit is contained in:
김보곤
2026-03-08 00:34:11 +09:00
parent 60c370370c
commit fb9c6e1de5

View File

@@ -3278,21 +3278,24 @@ function planningCanvas() {
},
sbUndo() {
if (this._sbHistoryIdx <= 0) return;
if (this._sbHistory.length === 0) return;
const page = this.sbCurrentPage;
if (!page) return;
// 처음 undo 시 현재 상태 저장
// 처음 undo 시 현재(변경 후) 상태를 히스토리 끝에 저장
const curSnap = JSON.parse(JSON.stringify(page.blocks || []));
if (this._sbHistoryIdx === this._sbHistory.length - 1) {
const snap = JSON.parse(JSON.stringify(page.blocks || []));
if (this._sbHistory.length === 0 || JSON.stringify(this._sbHistory[this._sbHistoryIdx]) !== JSON.stringify(snap)) {
this._sbHistory.push(snap);
const lastSnap = JSON.stringify(this._sbHistory[this._sbHistoryIdx]);
if (lastSnap !== JSON.stringify(curSnap)) {
this._sbHistory.push(curSnap);
this._sbHistoryIdx = this._sbHistory.length - 1;
}
}
if (this._sbHistoryIdx <= 0) return;
this._sbHistoryIdx--;
this._sbHistoryPaused = true;
page.blocks = JSON.parse(JSON.stringify(this._sbHistory[this._sbHistoryIdx]));
this.sbSelectedBlock = null;
this.sbMultiSelected = [];
this._sbHistoryPaused = false;
this.autoSave();
},
@@ -3304,6 +3307,7 @@ function planningCanvas() {
this._sbHistoryIdx++;
this._sbHistoryPaused = true;
page.blocks = JSON.parse(JSON.stringify(this._sbHistory[this._sbHistoryIdx]));
this.sbMultiSelected = [];
this.sbSelectedBlock = null;
this._sbHistoryPaused = false;
this.autoSave();