1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-27 00:30:09 +02:00

codeeditor: move instructions under editorready deferred

This commit is contained in:
Kushagra Gour
2019-03-14 01:14:13 +05:30
parent 70c66456e4
commit cf92032b33

View File

@@ -107,7 +107,7 @@ export default class CodeEditor extends Component {
return false; return false;
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
// prop.type changed, reinit the editor // prop.type changed, reinit the editor. On any other prop, component never updates.
this.initEditor(); this.initEditor();
} }
setModel(model) { setModel(model) {
@@ -127,7 +127,9 @@ export default class CodeEditor extends Component {
window.monacoSetValTriggered = false; window.monacoSetValTriggered = false;
}, 1); }, 1);
} }
this.editorReadyDeferred.promise.then(() => {
this.instance.setValue(value); this.instance.setValue(value);
});
// We save last set value so that when editor type changes, we can // We save last set value so that when editor type changes, we can
// populate that last value // populate that last value
this.lastSetValue = value; this.lastSetValue = value;
@@ -147,13 +149,13 @@ export default class CodeEditor extends Component {
} }
} }
setOption(option, value) { setOption(option, value) {
if (this.props.type === 'monaco') {
this.editorReadyDeferred.promise.then(() => { this.editorReadyDeferred.promise.then(() => {
if (this.props.type === 'monaco') {
this.instance.updateOptions({ [option]: value }); this.instance.updateOptions({ [option]: value });
});
} else { } else {
this.instance.setOption(option, value); this.instance.setOption(option, value);
} }
});
} }
setLanguage(value) { setLanguage(value) {
if (!window.monaco) return; if (!window.monaco) return;