var myBinding = editor.addCommand(monaco.KeyCode.F9, function () { alert('F9 pressed!'); });
// You can't dispose `addCommand` // If you need to dispose it you might use `addAction` or `registerCommand` changeModelContent = e => { console.log('内容改变', this.editor.getValue()); let caretOffset = e.changes[0].rangeOffset; //获取光标位置 console.log(caretOffset) }; editor.onDidChangeModelContent(this.changeModelContent);