@marijn: you mean retrieving the react component from that DOM subtree ? That is not needed. Only the DOM node to which the react component has been mounted to is needed for unmounting:
ReactDOM.unmountComponentAtNode(domContainerNode)
and domContainerNode elements can easily be found with a DOM query in the hook, from the root of the subtree to be deleted.
ProseMirror will ādropā whole subtrees at a time, without recursing through them, so an unmount-related callback would not be called for every node, but only for each subtree thatās dropped. So youād want to scan those in the callback, to find the relevant React components.
Hey guys - I have been trying to render React components as NodeView too. I have created this repo to show what I am currently doing:
Use a NodeView to render the component
Instead of using ReactDOM.render, I am using ReactDOM.createPortal. I return the portal component to my editor component which then renders it on the page for it to access my appās context
Iāve wrapped the NodeView in a React context so that its props are available within the component using hooks
Thank you for the idea. Actually Iām trying to replicate this, but now I think prosemirror is split into different modules. So now where can we find { Block } coz we canāt find Block in prosemirror/dist/model ?