Split content by paragraphs and create one editor per each new paragraph

Hello everyone, how can I split my content in paragraphs and create a new editor for each paragraph?

source Text : editor [paragraph 1, paragraph 2, paragraph 3] =>

editor 1 [paragraph 1] editor 2 [paragraph 2] editor 3 [paragraph 3]

I would like to do that using the prosemirror object model instead to split and deal with html content from the source editor.

maybe in someway, using the prosemirror object model,… May be I need to get the nodescollection of the prosemirror document object and after that use each node to generate its corresponding editor? but programmatically I don’t know how to do that.

Thanks so much!

You can create editors holding just a specific node, even if that isn’t the top node in your schema. However, you will need to implement your own logic for things like splitting off a new editor when the user presses enter, or merging editors when backspacing through a separation. It sounds like your motivation for this is to make separating out the paragraphs easier, though, and I can assure you that separating out content from a single editor is going to be a lot less work then setting up some multi-editor approach.

1 Like

Thanks so much marijn for your kind response and additional comments, I agree with you, but we have from our UX designers some specific uses cases to implement in that way.

I am interested in your comment: ‘You can create editors holding just a specific node,’: is possible for you to share some lines of code just to have an idea how to do that by code, please?

Thanks so much!

What I’m saying is that you can pass a paragraph node as doc option when creating an editor, even if it’s not the top level node in your schema. The editor will then just edit the content of the paragraph.

Thanks so much marijn for the interest, make sense your comments.

I am new programming with prosemirror but I will be working in the code and I will post my code findings here in order to help others with the same challenge in the future if is needed,

thanks again.