For prosemirror-changeset, is there a way to implement removeSteps using the current API?
The use case would be removing a change if it has been ‘accepted’.
I’ve tried changeSet.addSteps(changeSet.startDoc, invertedMaps) but it only works when the changeSet only has a singular change.
I suspect the correct approach would be to apply steps associated with the change I want to ‘accept’ to startDoc, and then add all other maps, equivalent to a git rebase perhaps.
Is there a reason why the constructor for ChangeSet isn’t public; wondering if this could also be valid if it was?
function acceptChange(change, changeSet) {
const changes = changeSet.changes.filter(c => c !== change)
return new ChangeSet(changeSet.config, changes) // constructor not public
}
There’s no guarantee that changed ranges can be reverted individually—for example if you wrap a paragraph in a list, that’ll result in changes before and after the paragraph, but you cannot revert just one of them. Similarly, filtering out a single changed range like that is not reliably going to give you a coherent change set.
Is this because of simplyChanges, or just that transactions can contain multiple steps so a transaction is the atomic unit here for reverting or accepting steps / changes?
Looking at the track changes example with commits, how would you revert a single commit without reverting other changes? A commit just stores maps and steps, no transactions.
const stepIds: number[] = Array.from(new Set(change.inserted.concat(change.deleted).map(s => s.data.index))).sort((a, b) => a - b)
const steps = stepIds.map(idx => diffState.steps[idx]) // Steps to rebase or revert / undo