Schema: move nested content to block-level?

We are migrating from Redactor to ProseMirror. Loving the migration so far, but we’re hitting some edge cases. Naturally, we have a lot of user-generated content that was written without a strict schema, so we’re trying to find ways to make that html editable with ProseMirror, without losing information.

One of the early decisions we took with our PM schema, is to make images/videos block-level (actually, with a parent figure node). That is, you can’t have an image inside a paragraph or a list etc etc.

However, when we parse old content with this schema, PM will ignore images, since they’re in an invalid location. Example:

Input:     <p>hello<img src='/foo'></p>
Expected:  <p>hello</p><figure><img src='/foo'></figure>
Actual:    <p>hello</p>

I am wondering, is there any configuration in the schema spec that will allow PM to do this kind of transformation? Or should I add a pre-processing step to move the nodes around? Any other tips?

DOMParser will add wrapping nodes when necessary, but it won’t break content out of wrapping nodes. So yes, this is something that should be done with a pre-processor.

1 Like

Thanks, adding a pre-processor was easy enough.