nytimes / react-prosemirror

A library for safely integrating ProseMirror and React.
Other
459 stars 17 forks source link

Wrap the DocNodeView in a ChildDescriptorContext. #116

Closed smoores-dev closed 8 months ago

smoores-dev commented 8 months ago

When rendering nested ProseMirror editors, e.g. when taking control over an atom node's content, the nested DocNodeView would register itself as the child of the atom node in the view descriptor tree. This could cause subtle issues when, e.g., ProseMirror attempts to determine whether the content is ltr or rtl, because it would treat the nested editor as the contentDOM of the atom, even if it was rendered in a portal into a non-contiguous part of the page. Presumably other issues could also arise from the fact that ProseMirror thought this node had a contentDOM when it actually does not.

This PR resolves this by simply providing a top-level ChildDescriptorContext, so that nested editors never accidentally cross the boundary up into their parents' view descriptor tree.