Steven Silvester пре 9 година
родитељ
комит
0b1f62f17b

+ 4 - 93
src/notebook/cells/model.ts

@@ -17,6 +17,10 @@ import {
   CellType, IBaseCell, ICodeCell
 } from '../notebook/nbformat';
 
+import {
+  IMetadataCursor, MetadataCursor
+} from '../common/metadata';
+
 import {
   ObservableOutputs
 } from '../output-area';
@@ -315,99 +319,6 @@ class CodeCellModel extends CellModel implements ICodeCellModel {
 }
 
 
-/**
- * A class used to interact with user level metadata.
- */
-export
-interface IMetadataCursor extends IDisposable {
-  /**
-   * The metadata namespace.
-   */
-  name: string;
-
-  /**
-   * Get the value of the metadata.
-   */
-  getValue(): any;
-
-  /**
-   * Set the value of the metdata.
-   */
-  setValue(value: any): void;
-}
-
-
-/**
- * An implementation of a metadata cursor.
- */
-export
-class MetadataCursor implements IMetadataCursor {
-
-  /**
-   * Construct a new metadata cursor.
-   *
-   * @param name - the metadata namespace key.
-   *
-   * @param value - this initial value of the namespace.
-   *
-   * @param cb - a change callback.
-   */
-  constructor(name: string, read: () => any, write: (value: any) => void) {
-    this._name = name;
-    this._read = read;
-    this._write = write;
-  }
-
-  /**
-   * Get the namespace key of the metadata.
-   *
-   * #### Notes
-   * This is a read-only property.
-   */
-  get name(): string {
-    return this._name;
-  }
-
-  /**
-   * Get whether the cursor is disposed.
-   */
-  get isDisposed(): boolean {
-    return this._read === null;
-  }
-
-  /**
-   * Dispose of the resources used by the cursor.
-   */
-  dispose(): void {
-    if (this.isDisposed) {
-      return;
-    }
-    this._read = null;
-    this._write = null;
-  }
-
-  /**
-   * Get the value of the namespace data.
-   */
-  getValue(): any {
-    let read = this._read;
-    return read();
-  }
-
-  /**
-   * Set the value of the namespace data.
-   */
-  setValue(value: any): void {
-    let write = this._write;
-    write(value);
-  }
-
-  private _name = '';
-  private _read: () => string = null;
-  private _write: (value: string) => void = null;
-}
-
-
 /**
  * A namespace for cell private data.
  */

+ 5 - 1
src/notebook/cells/widget.ts

@@ -42,7 +42,11 @@ import {
 } from 'sanitizer';
 
 import {
-  ICodeCellModel, ICellModel, IMetadataCursor
+  IMetadataCursor
+} from '../common/metadata';
+
+import {
+  ICodeCellModel, ICellModel
 } from './model';
 
 

+ 100 - 0
src/notebook/common/metadata.ts

@@ -0,0 +1,100 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+'use strict';
+
+import {
+  IDisposable
+} from 'phosphor-disposable';
+
+
+/**
+ * A class used to interact with user level metadata.
+ */
+export
+interface IMetadataCursor extends IDisposable {
+  /**
+   * The metadata namespace.
+   */
+  name: string;
+
+  /**
+   * Get the value of the metadata.
+   */
+  getValue(): any;
+
+  /**
+   * Set the value of the metdata.
+   */
+  setValue(value: any): void;
+}
+
+
+/**
+ * An implementation of a metadata cursor.
+ */
+export
+class MetadataCursor implements IMetadataCursor {
+
+  /**
+   * Construct a new metadata cursor.
+   *
+   * @param name - the metadata namespace key.
+   *
+   * @param value - this initial value of the namespace.
+   *
+   * @param cb - a change callback.
+   */
+  constructor(name: string, read: () => any, write: (value: any) => void) {
+    this._name = name;
+    this._read = read;
+    this._write = write;
+  }
+
+  /**
+   * Get the namespace key of the metadata.
+   *
+   * #### Notes
+   * This is a read-only property.
+   */
+  get name(): string {
+    return this._name;
+  }
+
+  /**
+   * Get whether the cursor is disposed.
+   */
+  get isDisposed(): boolean {
+    return this._read === null;
+  }
+
+  /**
+   * Dispose of the resources used by the cursor.
+   */
+  dispose(): void {
+    if (this.isDisposed) {
+      return;
+    }
+    this._read = null;
+    this._write = null;
+  }
+
+  /**
+   * Get the value of the namespace data.
+   */
+  getValue(): any {
+    let read = this._read;
+    return read();
+  }
+
+  /**
+   * Set the value of the namespace data.
+   */
+  setValue(value: any): void {
+    let write = this._write;
+    write(value);
+  }
+
+  private _name = '';
+  private _read: () => string = null;
+  private _write: (value: string) => void = null;
+}

+ 0 - 0
src/notebook/kernel-selector/index.ts → src/notebook/common/selectkernel.ts


+ 1 - 1
src/notebook/index.ts

@@ -2,5 +2,5 @@
 // Distributed under the terms of the Modified BSD License.
 'use strict';
 
-export * from './kernel-selector/index';
+export * from './common/selectkernel';
 export * from './notebook/index';

+ 6 - 5
src/notebook/notebook/index.ts

@@ -2,13 +2,14 @@
 // Distributed under the terms of the Modified BSD License.
 'use strict';
 
+export * from './actions';
+export * from './default-toolbar';
 export * from './model';
+export * from './modelfactory';
 export * from './nbformat';
+export * from './panel';
+export * from './toolbar';
 export * from './trust';
 export * from './widget';
-export * from './toolbar';
-export * from './default-toolbar';
-export * from './actions';
-export * from './modelfactory';
 export * from './widgetfactory';
-export * from './panel';
+

+ 6 - 2
src/notebook/notebook/model.ts

@@ -17,11 +17,15 @@ import {
   ISignal, Signal, clearSignalData
 } from 'phosphor-signaling';
 
+
 import {
-  ICellModel, MetadataCursor, IMetadataCursor,
-  CodeCellModel, RawCellModel, MarkdownCellModel
+  ICellModel, CodeCellModel, RawCellModel, MarkdownCellModel
 } from '../cells/model';
 
+import {
+  IMetadataCursor, MetadataCursor
+} from '../common/metadata';
+
 import {
   INotebookContent, ICell, INotebookMetadata, MAJOR_VERSION,
   MINOR_VERSION, IBaseCell

+ 5 - 1
src/notebook/notebook/widget.ts

@@ -38,9 +38,13 @@ import {
 import {
   ICellModel, BaseCellWidget, MarkdownCellModel,
   CodeCellWidget, MarkdownCellWidget,
-  CodeCellModel, RawCellWidget, IMetadataCursor
+  CodeCellModel, RawCellWidget
 } from '../cells';
 
+import {
+  IMetadataCursor
+} from '../common/metadata';
+
 import {
   INotebookModel
 } from './model';

+ 1 - 1
src/notebook/notebook/widgetfactory.ts

@@ -28,7 +28,7 @@ import {
 
 import {
   findKernel
-} from '../kernel-selector';
+} from '../common/selectkernel';
 
 import {
   ToolbarItems