Is there a way to judge the position when the cursor just at the end of of multiline paragraph?

I’m tring to using coordsAtPos function to get the info of the cursor positions. But I found an issue when I put the cursor at the end of a multiline paragraph (just after char l) like the image below showed:

and when I put the cursor at the second line just before char m it remained the same position:

Is there a way for me to distinguish between the two position? Cause coordsAtPos(39) may return two different possible value as expected. Any ideas will help.

No, ProseMirror represents selections as just document positions, without further information, and as such doesn’t distinguish between these two cursor positions.

Just browsing old messages.

It seems plausible that calling two coordsAtPos (pos and pos + 1,) we could infer this information - if

  1. both positions are asserted to belong to the same node and,
  2. the returned x coordinate is very different between the two (sensitive to document width - in other words, "not a pixel neighbor, given the block we are dealing with can only contain characters and not things which can take up entire lines)

Then we’d be able to know if we are the beginning or start of a multiline block.

Its not perfect but seems sensible. I personally have no use case for this atm though. In addition I also think OP’s problem can be solved in other ways (either detecting these sorts of drag / drop operations - text editor instance sensitive - and breaking from transformPaste given it runs later) or copying over internal prosemirror handlers / overriding them.)