Procházet zdrojové kódy

Modernize ConsoleWidget and ConsolePanel, add render mim plugin to lab page.

Afshin Darian před 8 roky
rodič
revize
51ec30e3d2
5 změnil soubory, kde provedl 27 přidání a 28 odebrání
  1. 1 1
      jupyterlab/index.js
  2. 6 6
      src/console/history.ts
  3. 3 3
      src/console/panel.ts
  4. 16 18
      src/console/widget.ts
  5. 1 0
      src/tsconfig.json

+ 1 - 1
jupyterlab/index.js

@@ -32,7 +32,7 @@ lab.registerPlugins([
   require('jupyterlab/lib/mainmenu/plugin').mainMenuProvider,
   // require('jupyterlab/lib/markdownwidget/plugin').markdownHandlerExtension,
   // require('jupyterlab/lib/notebook/plugin').notebookHandlerExtension,
-  // require('jupyterlab/lib/rendermime/plugin').renderMimeProvider
+  require('jupyterlab/lib/rendermime/plugin').renderMimeProvider,
   // require('jupyterlab/lib/running/plugin').runningSessionsExtension,
   require('jupyterlab/lib/services/plugin').servicesProvider
   // require('jupyterlab/lib/shortcuts/plugin').shortcutsExtension,

+ 6 - 6
src/console/history.ts

@@ -2,16 +2,16 @@
 // Distributed under the terms of the Modified BSD License.
 
 import {
-  IDisposable
-} from 'phosphor-disposable';
+  IKernel, KernelMessage
+} from 'jupyter-js-services';
 
 import {
-  clearSignalData
-} from 'phosphor-signaling';
+  IDisposable
+} from 'phosphor/lib/core/disposable';
 
 import {
-  IKernel, KernelMessage
-} from 'jupyter-js-services';
+  clearSignalData
+} from 'phosphor/lib/core/signaling';
 
 
 /**

+ 3 - 3
src/console/panel.ts

@@ -7,11 +7,11 @@ import {
 
 import {
   Message
-} from 'phosphor-messaging';
+} from 'phosphor/lib/core/messaging';
 
 import {
   Panel
-} from 'phosphor-panel';
+} from 'phosphor/lib/ui/panel';
 
 import {
   showDialog
@@ -49,7 +49,7 @@ class ConsolePanel extends Panel {
       session: options.session,
       rendermime: options.rendermime
     });
-    this.addChild(this._console);
+    this.addWidget(this._console);
   }
 
   /**

+ 16 - 18
src/console/widget.ts

@@ -6,20 +6,20 @@ import {
 } from 'jupyter-js-services';
 
 import {
-  Message
-} from 'phosphor-messaging';
+  clearSignalData
+} from 'phosphor/lib/core/signaling';
 
 import {
-  PanelLayout
-} from 'phosphor-panel';
+  Message
+} from 'phosphor/lib/core/messaging';
 
 import {
-  clearSignalData
-} from 'phosphor-signaling';
+  PanelLayout
+} from 'phosphor/lib/ui/panel';
 
 import {
   Widget
-} from 'phosphor-widget';
+} from 'phosphor/lib/ui/widget';
 
 import {
   InspectionHandler
@@ -27,7 +27,7 @@ import {
 
 import {
   nbformat
-} from '../notebook';
+} from '../notebook/notebook/nbformat';
 
 import {
   CodeCellWidget, CodeCellModel, RawCellModel, RawCellWidget
@@ -54,8 +54,6 @@ import {
 } from './history';
 
 
-
-
 /**
  * The class name added to console widgets.
  */
@@ -104,7 +102,7 @@ class ConsoleWidget extends Widget {
 
     // Because a completion widget may be passed in, check if it is attached.
     if (!completion.isAttached) {
-      completion.attach(document.body);
+      Widget.attach(completion, document.body);
     }
 
     // Set up the completion handler.
@@ -120,7 +118,7 @@ class ConsoleWidget extends Widget {
     banner.addClass(BANNER_CLASS);
     banner.readOnly = true;
     banner.model.source = '...';
-    layout.addChild(banner);
+    layout.addWidget(banner);
 
     // Set the banner text and the mimetype.
     this.initialize();
@@ -155,8 +153,8 @@ class ConsoleWidget extends Widget {
    */
   get prompt(): CodeCellWidget {
     let layout = this.layout as PanelLayout;
-    let last = layout.childCount() - 1;
-    return last > 0 ? layout.childAt(last) as CodeCellWidget : null;
+    let last = layout.widgets.length - 1;
+    return last > 0 ? layout.widgets.at(last) as CodeCellWidget : null;
   }
 
   /**
@@ -245,8 +243,8 @@ class ConsoleWidget extends Widget {
   serialize(): nbformat.ICodeCell[] {
     let output: nbformat.ICodeCell[] = [];
     let layout = this.layout as PanelLayout;
-    for (let i = 1; i < layout.childCount(); i++) {
-      let widget = layout.childAt(i) as CodeCellWidget;
+    for (let i = 1; i < layout.widgets.length; i++) {
+      let widget = layout.widgets.at(i) as CodeCellWidget;
       output.push(widget.model.toJSON());
     }
     return output;
@@ -354,7 +352,7 @@ class ConsoleWidget extends Widget {
     prompt = this._renderer.createPrompt(this._rendermime);
     prompt.mimetype = this._mimetype;
     prompt.addClass(PROMPT_CLASS);
-    layout.addChild(prompt);
+    layout.addWidget(prompt);
 
     // Hook up completion and history handling.
     let editor = prompt.editor;
@@ -375,7 +373,7 @@ class ConsoleWidget extends Widget {
    */
   private _handleInfo(info: KernelMessage.IInfoReply): void {
     let layout = this.layout as PanelLayout;
-    let banner = layout.childAt(0) as RawCellWidget;
+    let banner = layout.widgets.at(0) as RawCellWidget;
     banner.model.source = info.banner;
     this._mimetype = mimetypeForLanguage(info.language_info);
     this.prompt.mimetype = this._mimetype;

+ 1 - 0
src/tsconfig.json

@@ -13,6 +13,7 @@
     "application/index",
     "clipboard/index",
     "clipboard/plugin",
+    "console/index",
     "commandpalette/plugin",
     "common/activitymonitor",
     "common/observablelist",