Quellcode durchsuchen

Initialize the output type in the output model

Steven Silvester vor 9 Jahren
Ursprung
Commit
91a8cc826c
2 geänderte Dateien mit 33 neuen und 6 gelöschten Zeilen
  1. 0 5
      src/notebook/notebook/serialize.ts
  2. 33 1
      src/notebook/output-area/model.ts

+ 0 - 5
src/notebook/notebook/serialize.ts

@@ -120,11 +120,6 @@ export
 function messageToModel(msg: IKernelMessage) {
   let m: Output = msg.content;
   let type = msg.header.msg_type as OutputType;
-  if (type === 'execute_result') {
-    m.output_type = 'display_data';
-  } else {
-    m.output_type = type;
-  }
   return buildOutputModel(m);
 }
 

+ 33 - 1
src/notebook/output-area/model.ts

@@ -43,7 +43,6 @@ type StreamType = "stdout" | "stderr";
  */
 export
 class OutputBaseModel {
-
   /**
    * A signal emitted when state of the output changes.
    */
@@ -61,6 +60,14 @@ class OutputBaseModel {
 */
 export
 class DisplayDataModel extends OutputBaseModel {
+  /**
+   * Construct a new display data model.
+   */
+  constructor() {
+    super();
+    this.outputType = 'display_data';
+  }
+
   /**
    * The raw data for the output.
    */
@@ -83,6 +90,14 @@ class DisplayDataModel extends OutputBaseModel {
 */
 export
 class ExecuteResultModel extends OutputBaseModel {
+  /**
+   * Construct a new execute result model.
+   */
+  constructor() {
+    super();
+    this.outputType = 'execute_result';
+  }
+
   /**
    * The raw data for the output.
    */
@@ -111,6 +126,15 @@ class ExecuteResultModel extends OutputBaseModel {
 */
 export
 class StreamModel extends OutputBaseModel {
+  /**
+   * Construct a new stream model.
+   */
+  constructor() {
+    super();
+    this.outputType = 'stream';
+  }
+
+
   /**
   * The type of stream.
   */
@@ -138,6 +162,14 @@ function isStreamModel(model: OutputBaseModel): model is StreamModel {
 */
 export
 class ExecuteErrorModel extends OutputBaseModel {
+  /**
+   * Construct a new execute error model.
+   */
+  constructor() {
+    super();
+    this.outputType = 'error';
+  }
+
   /**
   * The name of the error.
   */