Noob here. I’m amazed by how feature rich and powerful ProseMirror is.
I’m hitting a wall trying to change the appearance of the caret. The problem I’m trying to solve is that I have custom keyboard navigation in my editor, and some of these navigation can make the caret jump far away. I want to make it easier for the user to track the new caret position.
Is there a way for me to get the absolute position of the caret more reliably?
Currently in my plugin’s update
`
const { state } = view
if (state.selection.empty) {
const { from } = state.selection
const pos = view.coordsAtPos(from)
const editorRect = view.dom.getBoundingClientRect()
// Get the computed style of the editor
const editorStyle = window.getComputedStyle(view.dom)
const lineHeight = parseFloat(editorStyle.lineHeight)
const fontSize = parseFloat(editorStyle.fontSize)
// Calculate positions
const left = pos.left - editorRect.left
const top = pos.top - editorRect.top + (lineHeight - fontSize) / 2
`
The top position calculated is offset, and the offset varies as a function of the window size
Any suggestions would be greatly appreciated