Calculate diff content from a transaction

I would like to execute some extra function after undo and I need to access the content being undone as the parameters.

I checked the docs there’s sth like below

    undoManager.on("stack-item-popped", (event) => {
      console.log("undo", event);

    // OR

    doc.on('afterTransaction', function(tr: Transaction, doc: Y.Doc))

However I’m not sure how to calculate the content based on a YEvent or a Transaction? Anyone shedding lights?

Here’s what I have. I don’t really understand the all the data structure. But I suppose a “Transaction” should contain every I need to calculate a diff string?

1 Like