Skip to content

Commit

Permalink
[se] Move CommuteRelatedRange to UndoRedoWoorksheet; Use _forwardTran…
Browse files Browse the repository at this point in the history
…sformation in Commute; Add window.onunhandledrejection;
  • Loading branch information
konovalovsergey committed Jan 16, 2025
1 parent 088215a commit 0dc8fef
Show file tree
Hide file tree
Showing 7 changed files with 287 additions and 136 deletions.
29 changes: 13 additions & 16 deletions cell/model/CollaborativeEditing.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,29 +1024,24 @@
return res;
};
CCollaborativeEditing.prototype.PreUndo = function () {
let logicDocument = this.m_oLogicDocument;

logicDocument.sendEvent("asc_onBeforeUndoRedoInCollaboration");
logicDocument.DrawingDocument.EndTrackTable(null, true);
logicDocument.TurnOffCheckChartSelection();
let res = AscCommon.CCollaborativeEditingBase.prototype.PreUndo.apply(this);

this.oRedoObjectParam = new AscCommonExcel.RedoObjectParam();
History.UndoRedoPrepare(this.oRedoObjectParam, false);
return this.private_SaveDocumentState();
//todo встроить в GetReverseOwnChanges
if (this.CoHistory.OwnRanges.length > 0) {
let range = this.CoHistory.OwnRanges[this.CoHistory.OwnRanges.length - 1];
let change = this.CoHistory.Changes[range.Position];
if (change && change.oData && change.oData.snapshot) {
this.oRedoObjectParam.snapshot = change.oData.snapshot
}
}
return res;
}
CCollaborativeEditing.prototype.PostUndo = function (state, changes) {
this.private_RestoreDocumentState(state);
this.private_RecalculateDocument(changes);

let logicDocument = this.m_oLogicDocument;
logicDocument.TurnOnCheckChartSelection();
logicDocument.UpdateSelection();
logicDocument.UpdateInterface();
logicDocument.UpdateRulers();
logicDocument.sendEvent("asc_onUndoRedoInCollaboration");

let Point = {Items: []}
if (changes.length > 0) {
//изменение не последнее потому что могут добавиться при корректировке
let elem = changes.find(function(elem){
if(elem && elem.Point) {
return true;
Expand All @@ -1057,6 +1052,8 @@
}
}
History.UndoRedoEnd(Point, this.oRedoObjectParam, false);

AscCommon.CCollaborativeEditingBase.prototype.PostUndo.apply(this, arguments);
}

AscCommon.CCollaborativeHistory.prototype.CommuteRelated = function(oClass, oChange, nStartPosition)
Expand Down
4 changes: 2 additions & 2 deletions cell/model/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ CHistory.prototype.Create_NewPoint = function()
}
}
//this.workbook.handlers.trigger("cleanCutData");
this.Add(AscCommonExcel.g_oUndoRedoCell, AscCH.historyitem_Unknown, null, null, new AscDFH.CChangesPointChange(AscCommonExcel.g_oUndoRedoCell, this.Points[this.Index]), true);
this.Add(AscCommonExcel.g_oUndoRedoCell, AscCH.historyitem_Unknown, null, null, new AscDFH.CChangesPointChange(AscCommonExcel.g_oUndoRedoCell, this.Points[this.Index], this.workbook._getSnapshot()), true);
return true;
};
/**
Expand Down Expand Up @@ -1507,7 +1507,7 @@ CHistory.prototype.GetSerializeArray = function()
};
CHistory.prototype._CheckCanNotAddChanges = function() {
try {
if (this.CanNotAddChanges) {
if (this.CanNotAddChanges && !this.CollectChanges) {
var tmpErr = new Error();
if (tmpErr.stack) {
AscCommon.sendClientLog("error", "changesError: " + tmpErr.stack, this.workbook.oApi);
Expand Down
Loading

0 comments on commit 0dc8fef

Please sign in to comment.