diff --git a/src/utils/AttributionManager.js b/src/utils/AttributionManager.js index f74e368f..b4cce013 100644 --- a/src/utils/AttributionManager.js +++ b/src/utils/AttributionManager.js @@ -24,7 +24,8 @@ import { getItemCleanStart, intersectSets, ContentFormat, - StructStore, Transaction, ID, IdSet, Item, Snapshot, Doc, AbstractContent, IdMap // eslint-disable-line + StructStore, Transaction, ID, IdSet, Item, Snapshot, Doc, AbstractContent, IdMap, // eslint-disable-line + encodeStateAsUpdate } from '../internals.js' import * as error from 'lib0/error' @@ -445,6 +446,20 @@ export class DiffAttributionManager extends ObservableV2 { this._nextDoc.off('afterTransaction', this._afterTrListener) } + acceptAllChanges () { + applyUpdate(this._prevDoc, encodeStateAsUpdate(this._nextDoc)) + } + + rejectAllChanges () { + this._prevDoc.transact(tr => { + applyUpdate(this._prevDoc, encodeStateAsUpdate(this._nextDoc)) + const um = new UndoManager(this._prevDoc) + um.undoStack.push(new StackItem(tr.deleteSet, tr.insertSet)) + um.undo() + um.destroy() + }) + } + /** * @param {ID} start * @param {ID} end