Переглянути джерело

Remove base URL references

Saul Shanabrook 6 роки тому
батько
коміт
8ad8972a8b

+ 2 - 2
packages/apputils/src/printing.ts

@@ -133,7 +133,7 @@ export namespace Printing {
    * creating an iframe and copying the DOM into it.
    */
   export function printWidget(
-    this: Widget,
+    widget: Widget,
     cssText?: string,
     callback?: PrintdCallback
   ) {
@@ -141,7 +141,7 @@ export namespace Printing {
     // const iframe = _PRINTD.getIFrame();
     // iframe.src = 'about://blank';
 
-    _PRINTD.print(this.node, [cssText], [], callback);
+    _PRINTD.print(widget.node, [cssText], [], callback);
   }
 
   /**

+ 6 - 4
packages/inspector/src/inspector.ts

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { printSymbol, printd } from '@jupyterlab/apputils';
+import { Printing } from '@jupyterlab/apputils';
 
 import { Token } from '@phosphor/coreutils';
 
@@ -90,7 +90,8 @@ export namespace IInspector {
 /**
  * A panel which contains a set of inspectors.
  */
-export class InspectorPanel extends Panel implements IInspector {
+export class InspectorPanel extends Panel
+  implements IInspector, Printing.IProvidesHandler {
   /**
    * Construct an inspector.
    */
@@ -102,8 +103,9 @@ export class InspectorPanel extends Panel implements IInspector {
   /**
    * Print in iframe
    */
-  [printSymbol]() {
-    printWidget.bind(this)('.p-mod-hidden {display: none;}');
+  [Printing.symbol]() {
+    return async () =>
+      Printing.printWidget(this, '.p-mod-hidden {display: none;}');
   }
 
   /**

+ 6 - 3
packages/json-extension/src/index.tsx

@@ -3,7 +3,7 @@
 
 import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
 
-import { printSymbol, printWidget } from '@jupyterlab/apputils';
+import { Printing } from '@jupyterlab/apputils';
 
 import { Message } from '@phosphor/messaging';
 
@@ -30,7 +30,8 @@ export const MIME_TYPE = 'application/json';
 /**
  * A renderer for JSON data.
  */
-export class RenderedJSON extends Widget implements IRenderMime.IRenderer {
+export class RenderedJSON extends Widget
+  implements IRenderMime.IRenderer, Printing.IProvidesHandler {
   /**
    * Create a new widget for rendering JSON.
    */
@@ -42,7 +43,9 @@ export class RenderedJSON extends Widget implements IRenderMime.IRenderer {
     this._mimeType = options.mimeType;
   }
 
-  [printSymbol] = printWidget;
+  [Printing.symbol]() {
+    return async () => Printing.printWidget(this);
+  }
 
   /**
    * Render JSON into this widget's node.

+ 0 - 1
packages/notebook-extension/src/index.ts

@@ -495,7 +495,6 @@ function activateNotebookHandler(
   // An object for tracking the current notebook settings.
   let editorConfig = StaticNotebook.defaultEditorConfig;
   let notebookConfig = StaticNotebook.defaultNotebookConfig;
-  // Pass URL in here.
   const factory = new NotebookWidgetFactory({
     name: FACTORY,
     fileTypes: ['notebook'],

+ 1 - 13
packages/notebook/src/widget.ts

@@ -164,7 +164,6 @@ export class StaticNotebook extends Widget {
     this.node.dataset[KERNEL_USER] = 'true';
     this.node.dataset[UNDOER] = 'true';
     this.rendermime = options.rendermime;
-    this.baseUrl = options.baseUrl;
     this.layout = new Private.NotebookPanelLayout();
     this.contentFactory =
       options.contentFactory || StaticNotebook.defaultContentFactory;
@@ -202,11 +201,6 @@ export class StaticNotebook extends Widget {
    */
   readonly rendermime: RenderMimeRegistry;
 
-  /**
-   * The base URL of the application, used to compute nbconvert URL.
-   */
-  readonly baseUrl?: string;
-
   /**
    * The model for the widget.
    */
@@ -651,11 +645,6 @@ export namespace StaticNotebook {
      * The service used to look up mime types.
      */
     mimeTypeService: IEditorMimeTypeService;
-
-    /**
-     * Base URL of the app, used to compute nbconvert URL for printing.
-     */
-    baseUrl?: string;
   }
 
   /**
@@ -2288,8 +2277,7 @@ namespace Private {
         rendermime: options.rendermime,
         languagePreference: options.languagePreference,
         contentFactory: Notebook.defaultContentFactory,
-        mimeTypeService: options.mimeTypeService,
-        baseUrl: options.baseUrl
+        mimeTypeService: options.mimeTypeService
       };
     }
   }

+ 4 - 13
packages/notebook/src/widgetfactory.ts

@@ -37,7 +37,6 @@ export class NotebookWidgetFactory extends ABCWidgetFactory<
       options.editorConfig || StaticNotebook.defaultEditorConfig;
     this._notebookConfig =
       options.notebookConfig || StaticNotebook.defaultNotebookConfig;
-    this._baseUrl = options.baseUrl;
   }
 
   /*
@@ -86,14 +85,14 @@ export class NotebookWidgetFactory extends ABCWidgetFactory<
   ): NotebookPanel {
     let rendermime = this.rendermime.clone({ resolver: context.urlResolver });
 
-    let content = this.contentFactory.createNotebook({
+    let nbOptions = {
       rendermime,
       contentFactory: this.contentFactory,
       mimeTypeService: this.mimeTypeService,
       editorConfig: this._editorConfig,
-      notebookConfig: this._notebookConfig,
-      baseUrl: this._baseUrl
-    });
+      notebookConfig: this._notebookConfig
+    };
+    let content = this.contentFactory.createNotebook(nbOptions);
 
     return new NotebookPanel({ context, content });
   }
@@ -109,7 +108,6 @@ export class NotebookWidgetFactory extends ABCWidgetFactory<
 
   private _editorConfig: StaticNotebook.IEditorConfig;
   private _notebookConfig: StaticNotebook.INotebookConfig;
-  private _baseUrl: string;
 }
 
 /**
@@ -145,12 +143,5 @@ export namespace NotebookWidgetFactory {
      * The notebook configuration.
      */
     notebookConfig?: StaticNotebook.INotebookConfig;
-
-    /**
-     * Base URL for the app.
-     *
-     * Used to compute the URL for notebook run through nbconvert.
-     */
-    baseUrl?: string;
   }
 }