Sorry for the poor English.
Thanks for using tiptap.
Ask about the position of the cursor on the tip tap editor.
(I'm sorry if it was the question of "prosemirror")
the purpose
I want to track the cursor position on the editor in real time.
I want to use the handleKeyDown event to get the cursor position when I enter some characters.
Question
The current cursor position was found by referring to "editor.view.state.selection. $ Anchor.pos".
However, if you press the arrow keys, the position information will appear to point to the previous position.(The same is true for Backspace.)
In this case, how can I get the correct cursor position information?
I am very happy if you can give me your advice.
Thank you.
Maybe this would help - https://github.com/scrumpy/tiptap/issues/346
Thank you for your reply!
I saw the contents of that thread.
The ultimate goal was the same.
However, I did not know how to get the correct cursor position ...
What is the tip for getting the cursor position of the user who is operating the editor?
(Should I ask questions in that thread?)
@Dangary-pleiades This should work:
new Editor({
onTransaction: ({ state }) => {
console.log(state.selection.anchor)
},
})
Thank you!
It worked as expected.
Thank you both!
Most helpful comment
@Dangary-pleiades This should work: