How to get the content of the editor if the editor content is stored in a tree?

The documentation mentions that state.doc.text.toString() will return the document as a string with newlines - unfortunately this only works for relatively small documents. Larger documents will have the document in a tree under state.doc.text.children. It doesn’t seem like there is a built-in way to reliably get the content of the editor in all cases. Is the best way to either use state.doc.text.toString() if state.doc.text.children is not defined and otherwise traverse the tree and assemble the document yourself?

Where in the docs does it say this? (Because that is wrong, it should be state.doc.toString().)

1 Like

:person_facepalming: Thank you!