I tried an implementation myself but got stumped implementing transform (op1, op2, side) as it doesn’t seem like we can apply a Step to another Step. I thought about using a Transform instead, though it doesn’t seem possible to Transform a Transform either.
I’m not an expert in this space, so I’m perhaps misunderstanding the difference between the ShareDB & ProseMirror collab model. I’ve read marijn’s collab post probably forty times & believe I understand why OTs weren’t used to begin with.
Is a ShareDB integration feasible? Or is this a dead end?
I know nothing of ShareDB and whether combining it with ProseMirror is going to work, but something like step1.map(step2.getMap()) might be what you’re looking for here (though step mapping does not take a parameter like side, and as such might not cover what you want).
const a = new Delta().insert('a');
const b = new Delta().insert('b').retain(5).insert('c');
a.transform(b, true); // new Delta().retain(1).insert('b').retain(5).insert('c');
a.transform(b, false); // new Delta().insert('b').retain(6).insert('c');
Maybe i should be considering wrapping a Step[] inside a ShareDB OT?
Indeed, with map lacking a side, it doesn’t seem to work. This is my latest attempt. After this post, i’ll stop live coding. But would love to talk with anyone more about this approach.
I believe ProseMirror & ShareDB have incompatible approaches concerning collaboration. ProseMirror steps must be processed by a single source of truth in order, where as ShareDB OTs can be processed in any order. I think it’s the same problem that @marijn describes in the Collaborative Editing in ProseMirror post, if i’m understanding correctly.
Do report back if you reach a different conclusion. Best of luck.