Skip to content

Commit 7220fd8

Browse files
committed
Add hotkey for hot reload (useful for colab)
1 parent 77741fe commit 7220fd8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

mesop/web/src/editor/editor.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class Editor {
8181
private router: Router,
8282
errorHandler: ErrorHandler,
8383
private editorService: EditorService,
84+
private channel: Channel,
8485
) {
8586
iconRegistry.setDefaultFontSetClass('material-symbols-rounded');
8687
(errorHandler as GlobalErrorHandlerService).setOnError((error) => {
@@ -143,7 +144,9 @@ class Editor {
143144
this.editorService.clearFocusedComponent();
144145
return;
145146
}
146-
// Bind these combinations:
147+
// Hotkey for toggle selection mode
148+
//
149+
// Binds:
147150
// cmd + shift + e (MacOs)
148151
// ctrl + shift + e (Other platforms)
149152
if (
@@ -152,6 +155,22 @@ class Editor {
152155
event.shiftKey
153156
) {
154157
this.editorService.toggleSelectionMode();
158+
event.preventDefault();
159+
return;
160+
}
161+
// Hotkey for hot reload
162+
//
163+
// Binds:
164+
// cmd + shift + r (MacOs)
165+
// ctrl + shift + r (Other platforms)
166+
if (
167+
event.key === 'r' &&
168+
(isMac() ? event.metaKey : event.ctrlKey) &&
169+
event.shiftKey
170+
) {
171+
this.channel.hotReload();
172+
event.preventDefault();
173+
return;
155174
}
156175
}
157176
}

0 commit comments

Comments
 (0)