Converting between documents with different schemas / converting from document to steps

Main Question

In my messaging app, I’m using prosemirror with a schema based on prosemirror-schema-list. My app now needs to be able to integrate with other messaging providers like slack / discord etc.
Each of these have wildly different rules for representing rich text, but I should be able to represent the structure and rules for each as a prosemirror schema.

The issue is that I can’t find a way to convert a document from one schema to another. My current best idea for a solution would be:

  1. walk through my initial schema-A document
  2. create steps while walking through
  3. convert these steps back to a schema-B document

Step 3 should be handled by prosemirror-transform, but is there any existing way to accomplish step 1 and 2?

Is converting to steps even an approach that makes sense or are there easier solutions that I’m missing?

Since a document is basically an AST, are there any modules like compilers / walkers that prosemirror already uses?

Extra context and details

The biggest pain-point so far are the differing nesting rules between rich text editors.

So for example for a simple list the structure is

  • my schema: bulletList > listItem > paragraph
  • slack: rich_text_list > rich_text_section

Or for lists with indentations:

  • my schema: bulletList > listItem > bulletList > listItem > paragraph
  • slack: rich_text_list > rich_text_section with a property of indent: 1

Slacks format doesn’t allow for a rich_text_section in another rich_text_section so there is no clear 1 to 1 mapping between nodes.

If you are converting documents, there’s no need to create steps. Just write a function that walks through a document and converts each node to its equivalent representation in the other schema. If there’s no equivalent representation, you’ll have to get creative on how to handle that, but this isn’t something the library will help you with.