mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-17 12:01:13 +02:00
CodeEditor: simulate origin in change object for monaco
This commit is contained in:
@@ -117,9 +117,13 @@ export default class CodeEditor extends Component {
|
|||||||
: this.instance.setModel(model);
|
: this.instance.setModel(model);
|
||||||
}
|
}
|
||||||
setValue(value) {
|
setValue(value) {
|
||||||
this.instance.setValue
|
if (this.props.type === 'monaco') {
|
||||||
? this.instance.setValue(value)
|
window.monacoSetValTriggered = true;
|
||||||
: this.instance.setModel(model);
|
setTimeout(() => {
|
||||||
|
window.monacoSetValTriggered = false;
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
this.instance.setValue(value);
|
||||||
}
|
}
|
||||||
getValue() {
|
getValue() {
|
||||||
return this.instance.getValue();
|
return this.instance.getValue();
|
||||||
@@ -193,7 +197,10 @@ export default class CodeEditor extends Component {
|
|||||||
});
|
});
|
||||||
window.monacoInstance = this.instance;
|
window.monacoInstance = this.instance;
|
||||||
this.instance.onDidChangeModelContent(change => {
|
this.instance.onDidChangeModelContent(change => {
|
||||||
this.props.onChange(this.instance, { ...change, origin: '+input' });
|
this.props.onChange(this.instance, {
|
||||||
|
...change,
|
||||||
|
origin: window.monacoSetValTriggered ? 'setValue' : '+input'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
this.instance.addCommand(
|
this.instance.addCommand(
|
||||||
monaco.KeyMod.WinCtrl | monaco.KeyMod.Shift | monaco.KeyCode.KEY_F,
|
monaco.KeyMod.WinCtrl | monaco.KeyMod.Shift | monaco.KeyCode.KEY_F,
|
||||||
|
Reference in New Issue
Block a user