How do I get the text node at the current cursor position?

I want to get the text node that the current cursor is at (let’s assume it’s an empty selection). If I do view.state.selection.$anchor.parent, this returns the parent of the text node (this is expected since according to the documentation text nodes are “flat”). However, I don’t see a way to get the text node itself. What am I missing?

What do you want to do with the node? Text nodes are conceptually not coherent nodes, they just cover a piece of text that happens to have the same marks. You can get the text before and after a resolved position with nodeBefore and nodeAfter, but I’ve never had a situation where I needed the actual text node around it.