Browse Source

Final cleanup of cells.

Brian E. Granger 8 years ago
parent
commit
b37435210d
1 changed files with 34 additions and 18 deletions
  1. 34 18
      packages/cells/src/widget.ts

+ 34 - 18
packages/cells/src/widget.ts

@@ -158,7 +158,9 @@ class Cell extends Widget {
     super();
     this.addClass(CELL_CLASS);
     let model = this._model = options.model;
-    let contentFactory = this.contentFactory = (options.contentFactory || Cell.defaultContentFactory);
+    let contentFactory = this.contentFactory = (
+      options.contentFactory || Cell.defaultContentFactory
+    );
     this.layout = new PanelLayout();
 
     // Header
@@ -214,6 +216,13 @@ class Cell extends Widget {
     return this._model;
   }
 
+  /**
+   * Get the input area for the cell.
+   */
+  get inputArea(): InputArea {
+    return this._input;
+  }
+
   /**
    * The read only state of the cell.
    */
@@ -288,22 +297,6 @@ class Cell extends Widget {
     this.toggleClass(READONLY_CLASS, this._readOnly);
   }
 
-  /**
-   * Render an input instead of the text editor.
-   */
-  protected renderInput(widget: Widget): void {
-    this.addClass(RENDERED_CLASS);
-    this._input.renderInput(widget);
-  }
-
-  /**
-   * Show the text editor.
-   */
-  protected showEditor(): void {
-    this.removeClass(RENDERED_CLASS);
-    this._input.showEditor();
-  }
-
   protected finishCell(options: Cell.IOptions): void {
     this.addFooter();
   }
@@ -488,6 +481,13 @@ class CodeCell extends Cell {
    */
   readonly model: ICodeCellModel;
 
+  /**
+   * Get the output area for the cell.
+   */
+  get outputArea(): OutputArea {
+    return this._output;
+  }
+
   /** 
    * The view state of output being collapsed.
   */
@@ -685,6 +685,22 @@ class MarkdownCell extends Cell {
     this._handleRendered();
   }
 
+  /**
+   * Render an input instead of the text editor.
+   */
+  protected renderInput(widget: Widget): void {
+    this.addClass(RENDERED_CLASS);
+    this.inputArea.renderInput(widget);
+  }
+
+  /**
+   * Show the text editor instead of rendered input.
+   */
+  protected showEditor(): void {
+    this.removeClass(RENDERED_CLASS);
+    this.inputArea.showEditor();
+  }
+
   /**
    * Dispose of the resource held by the widget.
    */
@@ -719,7 +735,7 @@ class MarkdownCell extends Cell {
   }
 
   /**
-   * Update the output.
+   * Update the rendered input.
    */
   private _updateRenderedInput(): void {
     let model = this.model;