This PR removes hardcoded 0 value which assumes that a selection at the beginning of a document Selection.atStart has a position of 0. Depending on the document type, a valid selection at the start of the document may begin at a value larger than that (relevant comment: https://github.com/ueberdosis/tiptap/pull/1595#issuecomment-896444524).
Mainly fixes issue of autofocusing editor on mount and on yjs content load: selection is at beginning of document before yjs content load, and is at end of document after yjs load. Expected behavior is that selection stays at beginning of document.
absolutePositionToRelativePosition might still contain additional bugs because 1. there are other pos == 0 statements in the function logic 2. unknown whether (initial) selections at end of the document Selection.atEnd have problems.
This PR removes hardcoded
0
value which assumes that a selection at the beginning of a documentSelection.atStart
has a position of0
. Depending on the document type, a valid selection at the start of the document may begin at a value larger than that (relevant comment: https://github.com/ueberdosis/tiptap/pull/1595#issuecomment-896444524).Mainly fixes issue of autofocusing editor on mount and on yjs content load: selection is at beginning of document before yjs content load, and is at end of document after yjs load. Expected behavior is that selection stays at beginning of document.
absolutePositionToRelativePosition
might still contain additional bugs because 1. there are otherpos == 0
statements in the function logic 2. unknown whether (initial) selections at end of the documentSelection.atEnd
have problems.