Browse Source

Upgrade jupyter-js-notebook

Steven Silvester 9 years ago
parent
commit
378641fdff
4 changed files with 8 additions and 45 deletions
  1. 1 0
      examples/lab/index.html
  2. 1 1
      package.json
  3. 3 41
      src/notebook/plugin.ts
  4. 3 3
      src/readonly-notebook/plugin.ts

+ 1 - 0
examples/lab/index.html

@@ -3,6 +3,7 @@
 <head>
   <title>Jupyter Plugins Demo</title>
   <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
+  <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML-full,Safe&amp;delayStartupUntil=configured"></script>
   <script id='jupyter-config-data' type="application/json">{ "baseUrl": "{{base_url}}", "wsUrl": "{{ws_url}}" }</script>
   <script src="build/bundle.js" main="index"></script>
 </head>

+ 1 - 1
package.json

@@ -8,7 +8,7 @@
     "codemirror": "^5.10.0",
     "jquery": "^2.2.0",
     "jquery-ui": "^1.10.5",
-    "jupyter-js-notebook": "^0.10.0",
+    "jupyter-js-notebook": "^0.11.0",
     "jupyter-js-services": "^0.5.0",
     "jupyter-js-ui": "^0.2.0",
     "jupyter-js-utils": "^0.3.0",

+ 3 - 41
src/notebook/plugin.ts

@@ -3,7 +3,7 @@
 'use strict';
 
 import {
-  NotebookWidget, NotebookModel, populateNotebookModel, buildOutputModel, Output, INotebookModel, getNotebookContent
+  NotebookWidget, NotebookModel, serialize, INotebookModel, deserialize
 } from 'jupyter-js-notebook';
 
 import {
@@ -75,28 +75,12 @@ function activateNotebookHandler(app: Application, manager: DocumentManager, ser
   app.commands.add([{
     id: runCellCommandId,
     handler: () => handler.runSelectedCell()
-  }, {
-    id: selectNextCellCommandId,
-    handler: () => handler.selectNextCell()
-  }, {
-    id: selectPreviousCellCommandId,
-    handler: () => handler.selectPreviousCell()
   }]);
   app.palette.add([{
     command: runCellCommandId,
     category: 'Notebook Operations',
     text: 'Run current cell',
     caption: 'Run the current cell'
-  }, {
-    command: selectNextCellCommandId,
-    category: 'Notebook Operations',
-    text: 'Select next cell',
-    caption: 'Select next cell'
-  }, {
-    command: selectPreviousCellCommandId,
-    category: 'Notebook Operations',
-    text: 'Select previous cell',
-    caption: 'Select previous cell'
   }]);
   return Promise.resolve(void 0);
 }
@@ -198,22 +182,6 @@ class NotebookFileHandler extends AbstractFileHandler<NotebookContainer> {
     if (w) w.model.runSelectedCell();
   }
 
-  /**
-   * Select the next cell on the active widget.
-   */
-  selectNextCell(): void {
-    let w = this.activeWidget;
-    if (w) w.model.selectNextCell();
-  }
-
-  /**
-   * Select the previous cell on the active widget.
-   */
-  selectPreviousCell(): void {
-    let w = this.activeWidget;
-    if (w) w.model.selectPreviousCell();
-  }
-
   /**
    * Set the dirty state of a widget (defaults to current active widget).
    */
@@ -247,7 +215,7 @@ class NotebookFileHandler extends AbstractFileHandler<NotebookContainer> {
    * Get the options used to save the widget content.
    */
   protected getSaveOptions(widget: NotebookContainer, model: IContentsModel): Promise<IContentsOpts> {
-      let content = getNotebookContent(widget.model);
+      let content = serialize(widget.model);
       return Promise.resolve({ type: 'notebook', content });
   }
 
@@ -271,13 +239,7 @@ class NotebookFileHandler extends AbstractFileHandler<NotebookContainer> {
    * Populate the notebook widget with the contents of the notebook.
    */
   protected populateWidget(widget: NotebookContainer, model: IContentsModel): Promise<IContentsModel> {
-    populateNotebookModel(widget.model, model.content);
-    if (widget.model.cells.length === 0) {
-      let cell = widget.model.createCodeCell();
-      widget.model.cells.add(cell);
-    }
-    widget.model.selectedCellIndex = 0;
-
+    deserialize(model.content, widget.model);
     return Promise.resolve(model);
   }
 

+ 3 - 3
src/readonly-notebook/plugin.ts

@@ -3,7 +3,7 @@
 'use strict';
 
 import {
-  NotebookWidget, NotebookModel, populateNotebookModel, buildOutputModel, Output, INotebookModel, getNotebookContent
+  NotebookWidget, NotebookModel, serialize, deserialize, INotebookModel
 } from 'jupyter-js-notebook';
 
 import {
@@ -78,7 +78,7 @@ class NotebookFileHandler extends AbstractFileHandler<NotebookWidget> {
    * Get the options used to save the widget content.
    */
   protected getSaveOptions(widget: NotebookWidget, model: IContentsModel): Promise<IContentsOpts> {
-      let content = getNotebookContent(widget.model);
+      let content = serialize(widget.model);
       return Promise.resolve({ type: 'notebook', content });
   }
 
@@ -95,7 +95,7 @@ class NotebookFileHandler extends AbstractFileHandler<NotebookWidget> {
    * Populate the notebook widget with the contents of the notebook.
    */
   protected populateWidget(widget: NotebookWidget, model: IContentsModel): Promise<IContentsModel> {
-    populateNotebookModel(widget.model, model.content);
+    deserialize(model.content, widget.model);
     if (widget.model.cells.length === 0) {
       let cell = widget.model.createCodeCell();
       widget.model.cells.add(cell);