Getting raw text position of transformation

We are about to use ProseMirror in Grammarly. We have our implementation of operational transformation, and we are trying to integrate ProseMirror’s change events system with our protocol. We faced some challenges doing that because our protocol operates with changes of a text instead a whole text, and we have to know a position of a change in a raw text. Is there any good way of calculating raw text position in a transformation handler? (Taking into account that new lines are symbols as well)

You could probably write code that maps ProseMirror positions to whatever you use for positioning. But I do feel you might be better off using ProseMirror collaborative editing feature rather than trying to bolt some OT implementation onto it.

Unfortuantely we cannot consider using your implementation of colaborative editing, even if it’s much more simple than our OT imlplementation, because we already have all our APIs supporting this protocol. So, I’d really appreciate your advice since you know internals better of PM better. What we need is to determive raw text coordinates, which itself could be usefull feature if you want to operate raw texts on backend. What we are planning to do is to traverse nodes until we reach one which was changed and accumulate length of TextNodes… But I’m not sure if it’s a best way of doing this.

‘Raw text coordinates’ doesn’t really mean anything. There is no obvious way to serialize a ProseMirror document as plain text, so depending on what you are doing, you’ll have to count character offsets differently. This is a problem that can be solved, but I’m not going to solve it for you.