|
1 | | -import { |
2 | | - convertTypeToStatus, |
3 | | - notificationState, |
4 | | -} from '@codesandbox/common/lib/utils/notifications'; |
| 1 | +import { notificationState } from '@codesandbox/common/lib/utils/notifications'; |
5 | 2 | import { blocker } from 'app/utils/blocker'; |
6 | | -import { NotificationMessage } from '@codesandbox/notifications/lib/state'; |
| 3 | +import { |
| 4 | + NotificationMessage, |
| 5 | + NotificationStatus, |
| 6 | +} from '@codesandbox/notifications/lib/state'; |
7 | 7 |
|
8 | 8 | import { KeyCode, KeyMod } from './keyCodes'; |
9 | 9 | import bootstrap from './dev-bootstrap'; |
@@ -113,6 +113,42 @@ class VSCodeManager { |
113 | 113 | }, |
114 | 114 | }); |
115 | 115 |
|
| 116 | + this.addWorkbenchAction({ |
| 117 | + id: 'view.fullscreen', |
| 118 | + label: 'Toggle Fullscreen', |
| 119 | + category: 'View', |
| 120 | + run: () => { |
| 121 | + if (document.fullscreenElement) { |
| 122 | + document.exitFullscreen(); |
| 123 | + } else { |
| 124 | + document.documentElement.requestFullscreen(); |
| 125 | + |
| 126 | + this.addNotification({ |
| 127 | + title: 'Fullscreen', |
| 128 | + message: |
| 129 | + 'You are now in fullscreen mode. Press and hold ESC to exit', |
| 130 | + status: NotificationStatus.NOTICE, |
| 131 | + timeAlive: 5000, |
| 132 | + }); |
| 133 | + |
| 134 | + if ('keyboard' in navigator) { |
| 135 | + // @ts-ignore - keyboard locking is experimental api |
| 136 | + navigator.keyboard.lock([ |
| 137 | + 'Escape', |
| 138 | + 'KeyW', |
| 139 | + 'KeyN', |
| 140 | + 'KeyT', |
| 141 | + 'ArrowLeft', |
| 142 | + 'ArrowRight', |
| 143 | + ]); |
| 144 | + } |
| 145 | + } |
| 146 | + }, |
| 147 | + keybindings: { |
| 148 | + primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.KEY_F, |
| 149 | + }, |
| 150 | + }); |
| 151 | + |
116 | 152 | this.appendMenuItem(MenuId.MenubarFileMenu, { |
117 | 153 | group: '1_new', |
118 | 154 | order: 1, |
@@ -159,6 +195,15 @@ class VSCodeManager { |
159 | 195 | order: 2, |
160 | 196 | }); |
161 | 197 |
|
| 198 | + this.appendMenuItem(MenuId.MenubarViewMenu, { |
| 199 | + group: '1_toggle_view', |
| 200 | + order: 0, |
| 201 | + command: { |
| 202 | + id: 'view.fullscreen', |
| 203 | + title: 'Toggle Fullscreen', |
| 204 | + }, |
| 205 | + }); |
| 206 | + |
162 | 207 | const addBrowserNavigationCommand = ( |
163 | 208 | id: string, |
164 | 209 | label: string, |
@@ -304,16 +349,8 @@ class VSCodeManager { |
304 | 349 | }); |
305 | 350 | } |
306 | 351 |
|
307 | | - addNotification( |
308 | | - message: string, |
309 | | - type: 'warning' | 'notice' | 'error' | 'success', |
310 | | - notification: NotificationMessage |
311 | | - ) { |
312 | | - notificationState.addNotification({ |
313 | | - message, |
314 | | - status: convertTypeToStatus(type), |
315 | | - ...notification, |
316 | | - }); |
| 352 | + addNotification(notification: NotificationMessage) { |
| 353 | + notificationState.addNotification(notification); |
317 | 354 | } |
318 | 355 |
|
319 | 356 | /** |
|
0 commit comments