Hey all! I just finished the initial integration of ProseMirror into our teacher site here at Desmos. We’re currently using it to allow teachers to enter inline math in the descriptions and notes that they create for their activities. We plan to add several other node types to allow teachers and students to create rich documents to express their pedagogy and mathematical thinking!
To move from the math node to prosemirror, we hook into MathQuill handlers and trigger a selection transaction and a view.focus. To go the other direction, we need to know whether we are entering the node from the left or the right. In each math node, we listen for state selection changes (via a plugin), and remember whether on the last transaction the cursor was ahead of the node or behind. Then we use that info in the selectNode callback.
I’m curious about your final design choices for the Desmos node. Did you end up converting it to a leaf node, and run into issues with cursor boundaries?
I just came from Discussion: Inline nodes with content. Thanks!
We ended up making it a non-leaf node with text* content. It has a custom NodeView, which is controlled by MathQuill.
Transitioning the cursor was tricky. We ended up having to monitor every transaction on the PM view, and monitoring whether the cursor was before or after a given MathQuill node. Then, when focus entered the MathQuill node we knew whether to place the (internal, MathQuill) cursor at the beginning or the end of the content. From PM’s point of view, the whole node is selected the entire time we are editing the node.