Refactore initialization of monac editor

This commit is contained in:
Stanislav Romanov 2022-10-17 11:46:00 +03:00
parent 5d647ff4de
commit 1ced61a5cd

View file

@ -48,17 +48,10 @@ export default class MonacoEditorComponent extends Component {
@action
initEditor(el) {
const model = getModel(
this.args.value,
this.args.language,
this.args.uri,
this.args.schema
);
this.editor = editor.create(el, {
model,
const options = {
// theme: 'vs-dark', //TODO: add checking global theme
readOnly: this.args.readOnly ?? false,
language: this.args.language,
// wordWrap: 'on',
// wrappingIndent: 'same',
lineNumbers: 'off',
@ -67,7 +60,20 @@ export default class MonacoEditorComponent extends Component {
minimap: {
enabled: false,
},
});
};
if (this.args.uri) {
options.model = getModel(
this.args.value,
this.args.language,
this.args.uri,
this.args.schema
);
} else if (this.args.value) {
options.value = this.args.value;
}
this.editor = editor.create(el, options);
// Autoresize height of element
const onDidContentSizeChangeHandler = this.editor.onDidContentSizeChange(