Reimplementing prosemirror-view's DOM management with React #55
Replies: 8 comments 21 replies
-
Previous discussion on this approach can be found on the PR (#47) and the ProseMirror discussion forum: https://discuss.prosemirror.net/t/the-future-of-nytimes-react-prosemirror/5855 |
Beta Was this translation helpful? Give feedback.
-
Some more questions:
Starting from the first update, it looks like you leave the old view desc tree around in the time between the editor update and the React update. The code paths where an out of date view desc tree is going to cause issues are, roughly:
These are the internal bindings that are being imported: |
Beta Was this translation helpful? Give feedback.
-
🧵 for cursor wrapper functionality
I haven't really taken a crack at cursor wrapper functionality, mostly because I didn't understand what it was doing! |
Beta Was this translation helpful? Give feedback.
-
🧵 Here are all of the standard prosemirror-view-style things that don't currently work with this implementation (there might be solutions for these that I just haven't discovered yet!):
|
Beta Was this translation helpful? Give feedback.
-
🧵 for minimizing risk of users "seeing" stale DOM during a state batch Starting from the first update, it looks like you leave the old view desc tree around in the time between the editor update and the React update. The code paths where an out of date view desc tree is going to cause issues are, roughly:
|
Beta Was this translation helpful? Give feedback.
-
I have tried to work out some approaches to this, but didn't find any that felt robust and neat enough that I feel comfortable adding them to the public API. So I am sorry to say, but I think forking is going to be your best avenue for this. Possibly, that may also help frame the problem in a way where 100% compatibility with prosemirror-view isn't a goal, which may help a lot to keep the scope and messiness of this under control. You could set this up as a React-ified prosemirror-view fork that largely exposes the same API, but replaces the plain-DOM interfaces with versions that make sense in React. 3rd-party commands and such would largely still work, but some extensions would have to be tailored to it to work with it. Forking doesn't need to be all that uncomfortable—prosemirror-view moves slowly, at this point, and occasionally merging patches that look like you need them into a fork can be pretty painless. The alternative, trying to come up with (and maintain) an abstraction that makes this very, very finicky use case fit well in the main library, just feels like something I'd regret before long, due to unforeseen problems it introduces, potential future changes in your approach mooting the decisions we make this point, and just the extra complexity that that kind of thing tends to introduce. |
Beta Was this translation helpful? Give feedback.
-
I feel like I'm tracing a very spiraling path toward the end goal here, but I did end up taking a stab at a more complete |
Beta Was this translation helpful? Give feedback.
-
If that works, that'd be really cool. I kept running into poorly-supported corner cases last time I tried, but that's a while ago—browsers may have gotten better. |
Beta Was this translation helpful? Give feedback.
-
In #47, we're proposing a novel approach to integrating React and ProseMirror. Instead of using Portals to inject React components into ProseMirror-managed node views, we attempt to manage the contenteditable DOM tree entirely with React. This requires disabling the EditorView's own DOM management system, so, as a stopgap to allow experimentation, we've forked prosemirror-view in this PR. However, we'd like to eventually publish this approach without a prosemirror-view fork! So let's discuss how we can minimize the scope of changes that would need to be made to prosemirror-view in order to support this approach (as well as any other concerns or ideas about the approach!)
Tagging @eelzon, @tilgovi, @saranrapjs, and @marijnh to get this conversation started!
Beta Was this translation helpful? Give feedback.
All reactions