瀏覽代碼

Merge pull request #11 from afshin/phosphor-upgrade

Phosphor upgrade: C
Steven Silvester 8 年之前
父節點
當前提交
68ec31b67e
共有 4 個文件被更改,包括 19 次插入32 次删除
  1. 4 9
      src/cells/model.ts
  2. 1 1
      src/codeeditor/widget.ts
  3. 8 16
      src/codemirror/editor.ts
  4. 6 6
      src/codemirror/plugin.ts

+ 4 - 9
src/cells/model.ts

@@ -10,7 +10,7 @@ import {
 } from '@phosphor/coreutils';
 
 import {
-  defineSignal, ISignal
+  ISignal, Signal
 } from '@phosphor/signaling';
 
 import {
@@ -161,12 +161,12 @@ class CellModel extends CodeEditor.Model implements ICellModel {
   /**
    * A signal emitted when the state of the model changes.
    */
-  readonly contentChanged: ISignal<this, void>;
+  readonly contentChanged = new Signal<this, void>(this);
 
   /**
    * A signal emitted when a model state changes.
    */
-  readonly stateChanged: ISignal<this, IChangedArgs<any>>;
+  readonly stateChanged = new Signal<this, IChangedArgs<any>>(this);
 
   /**
    * The metadata associated with the cell.
@@ -236,8 +236,8 @@ class CellModel extends CodeEditor.Model implements ICellModel {
     this.contentChanged.emit(void 0);
   }
 
-  private _trusted = false;
   private _metadata = new ObservableJSON();
+  private _trusted = false;
 }
 
 
@@ -258,11 +258,6 @@ namespace CellModel {
 }
 
 
-// Define the signals for the `CellModel` class.
-defineSignal(CellModel.prototype, 'contentChanged');
-defineSignal(CellModel.prototype, 'stateChanged');
-
-
 /**
  * An implementation of a raw cell model.
  */

+ 1 - 1
src/codeeditor/widget.ts

@@ -102,7 +102,7 @@ class CodeEditorWidget extends Widget {
   /**
    * A message handler invoked on an `'resize'` message.
    */
-  protected onResize(msg: Widget.Widget.ResizeMessage): void {
+  protected onResize(msg: Widget.ResizeMessage): void {
     if (msg.width < 0 || msg.height < 0) {
       if (this._resizing === -1) {
         this._editor.setSize(null);

+ 8 - 16
src/codemirror/editor.ts

@@ -9,21 +9,17 @@ import {
 } from '@jupyterlab/services';
 
 import {
-  ArrayExt.findFirstIndex
-} from 'phosphor/lib/algorithm/searching';
+  ArrayExt
+} from '@phosphor/algorithm';
 
 import {
   IDisposable, DisposableDelegate
 } from '@phosphor/disposable';
 
 import {
-  Signal.clearData, defineSignal, ISignal
+  ISignal, Signal
 } from '@phosphor/signaling';
 
-import {
-  Vector
-} from 'phosphor/lib/collections/vector';
-
 import {
   CodeEditor
 } from '../codeeditor';
@@ -117,7 +113,7 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
   /**
    * A signal emitted when either the top or bottom edge is requested.
    */
-  readonly edgeRequested: ISignal<this, CodeEditor.EdgeLocation>;
+  readonly edgeRequested = new Signal<this, CodeEditor.EdgeLocation>(this);
 
   /**
    * The DOM node that hosts the editor.
@@ -237,7 +233,7 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
     }
     this._editor = null;
     this._model = null;
-    this._keydownHandlers.clear();
+    this._keydownHandlers.length = 0;
     Signal.clearData(this);
   }
 
@@ -316,9 +312,9 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
    * @returns A disposable that can be used to remove the handler.
    */
   addKeydownHandler(handler: CodeEditor.KeydownHandler): IDisposable {
-    this._keydownHandlers.pushBack(handler);
+    this._keydownHandlers.push(handler);
     return new DisposableDelegate(() => {
-      this._keydownHandlers.remove(handler);
+      ArrayExt.removeAllWhere(this._keydownHandlers, val => val === handler);
     });
   }
 
@@ -631,7 +627,7 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
   private _model: CodeEditor.IModel;
   private _editor: CodeMirror.Editor;
   protected selectionMarkers: { [key: string]: CodeMirror.TextMarker[] | undefined } = {};
-  private _keydownHandlers = new Vector<CodeEditor.KeydownHandler>();
+  private _keydownHandlers = new Array<CodeEditor.KeydownHandler>();
   private _changeGuard = false;
   private _selectionStyle: CodeEditor.ISelectionStyle;
   private _uuid = '';
@@ -651,10 +647,6 @@ namespace CodeMirrorEditor {
 }
 
 
-// Define the signals for the `CodeMirrorEditor` class.
-defineSignal(CodeMirrorEditor.prototype, 'edgeRequested');
-
-
 /**
  * The namespace for module private data.
  */

+ 6 - 6
src/codemirror/plugin.ts

@@ -97,7 +97,7 @@ namespace CommandIDs {
  * Set up the editor widget menu and commands.
  */
 function activateEditorCommands(app: JupyterLab, tracker: IEditorTracker, mainMenu: IMainMenu, palette: ICommandPalette): void {
-  let { commands, keymap } = app;
+  let { commands } = app;
 
   /**
    * Toggle editor matching brackets
@@ -130,9 +130,9 @@ function activateEditorCommands(app: JupyterLab, tracker: IEditorTracker, mainMe
    * Create a menu for the editor.
    */
   function createMenu(): Menu {
-    let settings = new Menu({ commands, keymap });
-    let theme = new Menu({ commands, keymap });
-    let menu = new Menu({ commands, keymap });
+    let settings = new Menu({ commands });
+    let theme = new Menu({ commands });
+    let menu = new Menu({ commands });
 
     menu.title.label = 'Editor';
     settings.title.label = 'Settings';
@@ -166,8 +166,8 @@ function activateEditorCommands(app: JupyterLab, tracker: IEditorTracker, mainMe
     }));
 
     menu.addItem({ type: 'separator' });
-    menu.addItem({ type: 'submenu', menu: settings });
-    menu.addItem({ type: 'submenu', menu: theme });
+    menu.addItem({ type: 'submenu', submenu: settings });
+    menu.addItem({ type: 'submenu', submenu: theme });
 
     return menu;
   }