get row and column of cursor

Hi, I’d like to do two things.

(1) Get the row and column of the cursor

The code

function sendText(editor) {
  const event = new CustomEvent('text-change', 
       { 'detail': editor.state.doc.toString() ,
         'bubbles':true, 'composed': true});
  console.log("position",  editor.state.selection.main.head) 

gives me the current position of the cursor in the source text string, When instead I say

console.log("position",  editor.state.lineAt(editor.state.selection.main.head))

following this post, I get no output. I’m having trouble calling lineAt – not defined with the
various things I’ve tried.

Here are my dependencies:

  "dependencies": {
    "@codemirror/basic-setup": "^0.19.1",
    "@codemirror/lang-html": "^0.19.4",
    "@codemirror/lang-javascript": "^0.19.3",
    "@rollup/plugin-node-resolve": "^13.1.3",
    "rollup": "^2.69.1"

(2) set the cursor position given a row and column.

For now I am computing the row and column on the client using the position in the source string. However, this is probably less efficient than what Codemirror can provide.