Detect if caret is on an empty line


I want to implement a way to insert images into a document. I already know how to insert the images, but I want to show a button whenever the caret is on an empty line. So my real question is: how do I detect if the caret is on an empty line?

Thanks in advance!

This should work:

let {head, empty} = pm.selection
return empty && pm.doc.resolve(head).parent.content.size == 0
1 Like

Thanks, that was fast :slight_smile: And it works!