Description
In creating a similar prototype, one additional case I ended up needing to handle was mapping the current Prosemirror stored marks state when intercepting Prosemirror transactions and applying them as Automerge doc changes.
For example, if the user's cursor is located at the end of a bold
mark with expand: after
and they insert a character, this will normally extend the bold mark in both Prosemirror and Automerge (so far so good). However, if the user toggles the "Bold" command off prior to inserting the character, this updates the Prosemirror "stored marks" state (removing bold from it). This implies that subsequent insertions should not expand the mark (because bold was toggled off).
Similarly, if the user is in the middle of plain text and they execute the "Bold" command (with no selection) it updates the Prosemirror stored marks so that subsequent characters will be bold.
Perhaps this can be modeled in Automerge by marking/unmarking an "empty" selection at the cursor position? Or perhaps the splice logic just needs to look at the current stored marks state (that's what I did to start with).
Note that a Prosemirror transaction that updates the current stored marks will have tr.storedMarksSet === true
(and will have the actual stored marks toggled in tr.storedMarks
).
Activity