How to get the editor Instance from create() ?
Closed this issue · 6 comments
monaco.editor.create(..);
fails with Uncaught TypeError: Cannot read property 'addEventListener' of null
How to access the created Editor Instance ?
I also tried to use editorMounted
. But that doesn't work. There is no reaction.
<MonacoEditor width="100%" height="354" :options="options" @change="onChange" @editorMounted="onEditorMounted"></MonacoEditor>
editorMounted
seems not to be executed.
I want to add an Action with
editor.addAction({
// An unique identifier of the contributed action.
id: 'my-unique-id',
// A label of the action that will be presented to the user.
label: 'My Label!!!',
// An optional array of keybindings for the action.
keybindings: [
monaco.KeyMod.CtrlCmd | monaco.KeyCode.F10,
// chord
monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_K, monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_M)
],
// A precondition for this action.
precondition: null,
// A rule to evaluate on top of the precondition in order to dispatch the keybindings.
keybindingContext: null,
contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5,
// Method that will be executed when the action is triggered.
// @param editor The editor instance is passed in as a convinience
run: function(ed) {
alert("i'm running => " + ed.getPosition());
return null;
}
});
@dschiller editorMounted is not an event, just a property
The Docu describe it as: editorMounted(editor, monaco) an event emitted when the editor has been mounted (similar to mounted of Vue).
How can I achieve the Possibility to add an Action with editor.addAction({...})
?
@dschiller I will modify the doc
You just need to make the following changes
@editorMounted => :editorMounted
I'll close the current issue
<MonacoEditor width="100%" height="354" :options="options" @change="onChange" :editorMounted="onEditorMounted"></MonacoEditor>
Crazy. Sure - a Property. Now I understand. Was confused by your =>
Chars. Thank you!