Mutate data before it's processed by Prosemirror

Hello. So we’re using Tiptap in our projects (which uses Prosemirror under the hood) and we plan on adding in new blocks to our editor while at the same time supporting existing data. What this means in practice is that we want to decoare existing document data with data that wraps around it (i.e. decoration).

So if you imagine you have existing data that looks like so:

{
  "doc": [
    { "type": "paragraph", ... }
    { "type": "blockquote", ... }
  ]
}

Then, before the data is rendered, the goal would be to turn it into something like this:

{
  "doc": [
    { type: "block", content: [
      { "type": "paragraph", ... }
    ]},

    { type: "block", content: [
      { "type": "blockquote", ... }
    ]},
  ]
}

I have been banging my head against the wall to understand how I can decorate data like this before Prosemirror attempts to render it.

Any suggestions?

– edit –

The data that I have coming into the editor isn’t coming as one JSON clump. It’s instead managed through yjs by way of HocusPocus. This means I can only deal with the data as it comes into PM.