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:
- walk through my initial schema-A document
- create steps while walking through
- 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?
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
rich_text_list > rich_text_section
Or for lists with indentations:
- my schema:
bulletList > listItem > bulletList > listItem > paragraph
rich_text_list > rich_text_sectionwith a property of
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.