Grouping transaction to be undone together

Hi :slight_smile: I’d like to know if it’s possible to group transactions so that undo would revert them both. The transactions could be a few seconds apart, so I can’t rely on the newGroupDelay option.

For example, I have a given editor state A. The user initiates an action that updates the text in transaction B. A few seconds later we update the text through code with transaction C. So the order is: A → B → C. ^ several seconds pass in between

When the user performs an undo, we rollback to B, so now the editor state is A → B. However, I want to make it so that undoing C would undo B as well, returning to A. Effectively, I’d like to retrospectively group B and C together.

Is it possible is some way?

No, this isn’t possible. How would this work if other changes happen between B and C?

Yeah that makes sense.

So let’s say I don’t have to group B and C together, but B and whatever transaction will come after it.

In essence, I never want the user to land back at B either by undos or redos.

That’s not a feature that exists. You can use appendTransaction to synchronously follow up a transaction with some changes that cannot be undone separately, but I don’t see a conceptually tidy way to do something like that in an asynchronously applied set of updates.