Offline merging - Rebasing steps

Hey there . I’m new to prosemirror and i’m currently working on some functionality for the offline usage of editor while doing this I ran into some issues. The issue is described below : Online user adds an image and edits the subsequent paragraph , the offline user just edits the subsequent paragraph , after merging whatever the offline user edited was getting deleted (Lost)

To Give some more inputs , i’m able to re-create the steps that were lost when the user went offline , and i’m using rebasing technique to rebase the steps of the offline user and merge it with the online document. It is during this process i noticed that the steps belonging to that particular paragraph while rebasing was returning null and due to that these steps were not applied to the online version of the document. I re-utilised the rebasing technique from the receivetransaction()(and also from the guides and blogs about rebasing in prosemirror) ,mapping through the inverses , then the online steps and finally the previously rebased steps. Would like to know if there was a specific reason why was returning null ?

Some screenshots :

Offline User

clipboard-image (6)

Online User

clipboard-image (7)

Merged Document

clipboard-image (8)

Would appreciate any help . Thanks !

That sounds like a scenario that should be supported without problem. Are you sure your rebasing implementation is correct?

Steps map to null when their entire context is deleted. I.e. if you insert something at position X, but a range around that position was deleted by another client, mapping through that deletion will cause the step to be dropped. But that doesn’t seem to fit with your scenario.

Thanks marijn for the reply. This is the piece of code that I use for rebasing the steps.

let maps = new Mapping([].concat(offlineTr.mapping.maps.slice().reverse().map(map=>map.invert())).concat(onlineTr.mapping.maps.slice()))
                (step, index) => {
                    const mapped = - index))
                    if (mapped && !rebasedTr.maybeStep(mapped).failed) {

To add more data , the editor before this state would have applied the lost online transaction as a seperate transaction by itself (onlineTr denotes the lost online transaction ). After which I’m trying to rebase the offline steps and that is when i ran into the issues that i posted about. And offlineTr refers to the local changes made by the user and rebasedTr is the transaction which will contain the rebased offline(Local) steps.

I wrote this piece of code re-utilising what was implemented in the receiveTransaction() function.