|
1 | | -import { ILabShell, ILayoutRestorer, JupyterFrontEnd, JupyterFrontEndPlugin } from "@jupyterlab/application"; |
| 1 | +import { ILabShell, ILayoutRestorer, IRouter, JupyterFrontEnd, JupyterFrontEndPlugin } from "@jupyterlab/application"; |
2 | 2 | import { ICommandPalette, MainAreaWidget, WidgetTracker } from "@jupyterlab/apputils"; |
3 | 3 | import { PageConfig, URLExt } from "@jupyterlab/coreutils"; |
4 | 4 | import { IMainMenu } from '@jupyterlab/mainmenu'; |
@@ -178,7 +178,6 @@ const courseListExtension: JupyterFrontEndPlugin<void> = { |
178 | 178 | id: pluginIDs.coursesList, |
179 | 179 | autoStart: true, |
180 | 180 | optional: [ILayoutRestorer, INotebookTree], |
181 | | - |
182 | 181 | activate: ( |
183 | 182 | app: JupyterFrontEnd, |
184 | 183 | restorer: ILayoutRestorer | null, |
@@ -240,11 +239,12 @@ const courseListExtension: JupyterFrontEndPlugin<void> = { |
240 | 239 | const formgraderExtension: JupyterFrontEndPlugin<void> = { |
241 | 240 | id: pluginIDs.formgrader, |
242 | 241 | autoStart: true, |
243 | | - optional: [ILayoutRestorer, INotebookTree], |
| 242 | + optional: [ILayoutRestorer, INotebookTree, IRouter], |
244 | 243 | activate: ( |
245 | 244 | app: JupyterFrontEnd, |
246 | 245 | restorer: ILayoutRestorer | null, |
247 | | - notebookTree: INotebookTree | null |
| 246 | + notebookTree: INotebookTree | null, |
| 247 | + router: IRouter | null |
248 | 248 | ) => { |
249 | 249 | // Declare a widget variable |
250 | 250 | let widget: MainAreaWidget<FormgraderWidget>; |
@@ -290,6 +290,15 @@ const formgraderExtension: JupyterFrontEndPlugin<void> = { |
290 | 290 | } |
291 | 291 | }); |
292 | 292 |
|
| 293 | + // Open formgrader from URL. |
| 294 | + if (router) { |
| 295 | + const formgraderPattern = /(\?|&)formgrader=true/; |
| 296 | + router.register({ |
| 297 | + command: commandIDs.openFormgrader, |
| 298 | + pattern: formgraderPattern |
| 299 | + }); |
| 300 | + } |
| 301 | + |
293 | 302 | // Restore the widget state |
294 | 303 | if (restorer != null){ |
295 | 304 | restorer.restore(tracker, { |
|
0 commit comments