I have added a new action (Hot key - Ctrl + L) to clear editor window using the code below. It does call the defined clearEditor() function but editor is not refreshing/clearing out. I manually have to change tab and come back to monaco editor tab to see the results.
HTML
<ngx-monaco-editor
style="height: 100%"
(ngModelChange)="onChange($event)"
#monaco
[options]="codeEditorOptions"
[(ngModel)]="cipherCode"
(onInit)="onInit($event)">
</ngx-monaco-editor>
TS
onInit(editor: any) {
this._editor = editor;
this.enableShortcuts();
}
enableShortcuts() {
this._editor.addAction({
id: "clearQuery",
label: "Clear Current Query",
keybindings: [(window as any).monaco.KeyMod.CtrlCmd | (window as any).monaco.KeyCode.KeyL],
contextMenuGroupId: "3_execution",
run: () => {
this.clearEditor();
},
});
}
clearEditor() {
console.log("clear Called");
this.cipherCode = '';
}