Open dnmd opened 5 years ago
Did you solve the issue? I have same question like you got. Calling createModel is not available.
No I haven't...
@dnmd You can wait until monaco editor is loaded, and use below way to create the model:
monaco.editor.createModel(model.value, model.language, uri)
No, it's not working.
Also not working for me. Got the editor instance via (onInit)="editorInitialized($event)". Here is the code from the ts file of the component:
import * as monaco from 'monaco-editor';
...
editorInitialized(editor) {
let model = monaco.editor.createModel("Hello");
editor.setModel(model)
}
But the editor simply gets blank when loaded. Maybe the global editor "scope" of the monaco.editor.createModel call and the scope of the monaco.editor.IStandaloneCodeEditor instance from ngx-monaco-editor is different? Can somebody help?
Turns out, it works when using the monaco instance that ngx-monaco-editor loads internally:
...
editorInitialized(editor) {
let monaco = window.monaco;
let model = monaco.editor.createModel("Hello");
editor.setModel(model)
}
As per instructions from the monaco editor repo, the preferred method of creating tabs is;
monaco.editor.create({ ... , model: null })
monaco.editor.createModel(...)
.editorInstance.setModel(modelInstance)
for each model, you can save its view state (cursor, scroll position, etc) via -
editorInstance.saveViewState()
and restore it viaeditorInstance.restoreViewState()
.But I get stuck at the second step, as I am not able to create multiple instance. Am I missing something or is this simply not implemented (yet)? Thanks in advance