你可以使用onDidChangeCursorPosition或onDidChangeCursorSelection.听这样的事件.
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));
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
531 次 |
| 最近记录: |