mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
Adds reload action (Ctrl+Enter)
This commit is contained in:
parent
af0106a971
commit
ebfddbd4fb
1 changed files with 19 additions and 2 deletions
|
|
@ -148,6 +148,17 @@ export class PlaygroundModel {
|
||||||
constructor() {
|
constructor() {
|
||||||
let lastState = this.state;
|
let lastState = this.state;
|
||||||
|
|
||||||
|
this.dispose.track(
|
||||||
|
monaco.editor.addEditorAction({
|
||||||
|
id: "reload",
|
||||||
|
label: "Reload",
|
||||||
|
run: (editor, ...args) => {
|
||||||
|
this.reload();
|
||||||
|
},
|
||||||
|
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
this.dispose.track({
|
this.dispose.track({
|
||||||
dispose: reaction(
|
dispose: reaction(
|
||||||
() => ({ state: this.state }),
|
() => ({ state: this.state }),
|
||||||
|
|
@ -162,13 +173,19 @@ export class PlaygroundModel {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.debouncer.run(() => {
|
const action = () => {
|
||||||
this.isDirty = false;
|
this.isDirty = false;
|
||||||
lastState = state;
|
lastState = state;
|
||||||
for (const handler of this._previewHandlers) {
|
for (const handler of this._previewHandlers) {
|
||||||
handler.handlePreview(state);
|
handler.handlePreview(state);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (state.key !== lastState.key) {
|
||||||
|
action(); // sync update
|
||||||
|
} else {
|
||||||
|
this.debouncer.run(action);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ name: "update preview" }
|
{ name: "update preview" }
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue