mirror of
https://github.com/yjs/yjs.git
synced 2026-01-09 15:58:01 -05:00
[AttributionManager] implement acceptAllChanges and rejectAllChanges. closes #761
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user