I have an onUpArrow
handler that needs to check whether the cursor is at the very beginning of the first line in a Draft.js editor. The editor may contain multiple lines/blocks.
I found that SelectionState
methods such as getAnchorOffset()
and getStartOffset()
can tell me that the cursor is at the start of a line by returning 0
, but that value is returned at the start of any line/block, not just the first one in the editor.
This issue makes reference to "get start or end of document or to get the exact cursor position" but it doesn't appear this made it into the Draft source.
Does anyone know a way to detect whether the cursor is at the very start of the editor content?
based on your check, and this editorState.getCurrentContent().getBlockMap().first().getKey() === selectionState.getAnchor/FocusKey()