Is there an event in monaco editor for text selection ? I need to respond to a user selecting part of the code in editor?
Is there a better solution to using timer to get ranges for selection ?
Documents don't seem to mention about it.
You can use onDidChangeCursorPosition
or onDidChangeCursorSelection
. to listen for such an event.
var editor = monaco.editor.create(document.getElementById("container"), {
value: "function hello() {\n\talert('Hello world!');\n}",
language: "javascript"
});
editor.onDidChangeCursorPosition((e) => {
console.log(JSON.stringify(e));
});
editor.onDidChangeCursorSelection((e) => {
console.log(JSON.stringify(e));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With