0

I read the API document

I want to get the cursor position (row, column), such as : image

But seems there is no API for this function, is there any way to implement it?


the demo code here


before ask question I have searched this one QA: Get absolute (index) position of cursor in Monaco Editor

but when I execute:

console.log(monacoRef.current.editor.getPosition()) 

I get the error:

Property 'getPosition' does not exist on type 'typeof editor'. ts(2339) 

1 Answer 1

2

you can use onDidChangeCursorSelection event to get current carret position.

sample :

 editor.onDidChangeCursorSelection(e => { console.log(e) }) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.