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