Changed part of document

A very rudimentary solution is to use findDiffStart and findDiffEnd to find the changed start and end of two documents. This can be enough for most cases.

const from = oldState.doc.content.findDiffStart(newState.doc.content)
const to = oldState.doc.content.findDiffEnd(newState.doc.content)

if (!from || !to || from === to.b) {
  return
}

newState.doc.nodesBetween(from, to.b, (node, pos) => {
  // ..
})

An edge case for this solution is a change at the start and end of a document within a single transaction for example. To calculate exact changes you have to map over transaction steps like this.