Determine if transaction is an undo event

Is there a “public” way to know if a transaction is the result of an undo() command? The prosemirror-history plugin adds its own meta to the transaction, which is exactly what I want to inspect, but since that plugin doesn’t export its key, I get the feeling that I shouldn’t do the following:

const isUndo = tr.meta.history$?.redo === false;

However, this way is much less work than overriding the beforeinput DOM event handler or keeping track of the event count via undoDepth(state).

No. What do you need this for?

I’m trying to restore certain metadata on undo(), and the algorithm I have right now just compares saved steps to the transaction’s doc (which I’m not convinced is the right thing to do, but that’s a separate topic I’m drafting) to determine if I should restore the metadata.

I ran into a very edge case where the content of my clipboard just happened to match the content of the most recently saved step. So, when I pasted my clipboard into the editor at the correct position, the metadata was restored unexpectedly.

Anyway, this isn’t a pain point at all; I was mostly just curious. Thanks for responding, @marijn.