Forráskód Böngészése

Adding doc mode to IPaths and testing for doc mode.

Brian E. Granger 4 éve
szülő
commit
d8c6d16ae7
1 módosított fájl, 19 hozzáadás és 0 törlés
  1. 19 0
      packages/application/src/frontend.ts

+ 19 - 0
packages/application/src/frontend.ts

@@ -303,6 +303,22 @@ export namespace JupyterFrontEnd {
     widgets(area?: string): IIterator<Widget>;
   }
 
+  /**
+   * Is JupyterLab in document mode?
+   * 
+   * @param path - Full URL of JupyterLab
+   * @param paths - The current IPaths object hydrated from PageConfig.
+   */
+  export function inDocMode(path: string, paths: IPaths) {
+    const docPattern = new RegExp(`^${paths.urls.doc}`);
+    const match = path.match(docPattern);
+    if (match) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
   /**
    * The application paths dictionary token.
    */
@@ -319,11 +335,14 @@ export namespace JupyterFrontEnd {
       readonly base: string;
       readonly notFound?: string;
       readonly app: string;
+      readonly doc: string;
       readonly static: string;
       readonly settings: string;
       readonly themes: string;
       readonly tree: string;
+      readonly docTree: string;
       readonly workspaces: string;
+      readonly docWorkspaces: string;
       readonly hubPrefix?: string;
       readonly hubHost?: string;
       readonly hubUser?: string;