Skip to content

handling changes to prosemirror stored marks #2

Open
@jjallaire

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions