Refactore initialization of monac editor
This commit is contained in:
parent
5d647ff4de
commit
1ced61a5cd
1 changed files with 16 additions and 10 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue