ソースを参照

Use bind() for newInlineEditor

Earlier newInlineEditor() was not using any variables from `this`. The
current versoin does do this, so we need to bind the parent before the
passing the function around.
AbdealiJK 8 年 前
コミット
47a8e82616

+ 2 - 1
examples/console/src/index.ts

@@ -67,7 +67,8 @@ function startApp(session: Session.ISession) {
   });
 
   let rendermime = new RenderMime({ items: RenderMime.getDefaultItems() });
-  let editorFactory = editorServices.factoryService.newInlineEditor;
+  let editorFactory = editorServices.factoryService.newInlineEditor.bind(
+    editorServices.factoryService);
   let contentFactory = new ConsolePanel.ContentFactory({ editorFactory });
   let consolePanel = new ConsolePanel({
     rendermime,

+ 2 - 1
examples/notebook/src/index.ts

@@ -96,7 +96,8 @@ function createApp(manager: ServiceManager.IManager): void {
     opener
   });
   let mFactory = new NotebookModelFactory({});
-  let editorFactory = editorServices.factoryService.newInlineEditor;
+  let editorFactory = editorServices.factoryService.newInlineEditor.bind(
+    editorServices.factoryService);
   let contentFactory = new NotebookPanel.ContentFactory({ editorFactory });
 
   let wFactory = new NotebookWidgetFactory({

+ 2 - 1
src/console-extension/index.ts

@@ -121,7 +121,8 @@ const contentFactoryPlugin: JupyterLabPlugin<ConsolePanel.IContentFactory> = {
   requires: [IEditorServices],
   autoStart: true,
   activate: (app: JupyterLab, editorServices: IEditorServices) => {
-    let editorFactory = editorServices.factoryService.newInlineEditor;
+    let editorFactory = editorServices.factoryService.newInlineEditor.bind(
+      editorServices.factoryService);
     return new ConsolePanel.ContentFactory({ editorFactory });
   }
 };

+ 1 - 0
src/notebook/panel.ts

@@ -1,3 +1,4 @@
+
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 

+ 4 - 2
src/notebook/plugin.ts

@@ -87,7 +87,8 @@ const contentFactoryPlugin: JupyterLabPlugin<NotebookPanel.IContentFactory> = {
   requires: [IEditorServices],
   autoStart: true,
   activate: (app: JupyterLab, editorServices: IEditorServices) => {
-    let editorFactory = editorServices.factoryService.newInlineEditor;
+    let editorFactory = editorServices.factoryService.newInlineEditor.bind(
+      editorServices.factoryService);
     return new NotebookPanel.ContentFactory({ editorFactory });
   }
 };
@@ -130,7 +131,8 @@ function activateCellTools(app: JupyterLab, restorer: ILayoutRestorer, tracker:
   const nbConvert = CellTools.createNBConvertSelector();
   celltools.addItem({ tool: nbConvert, rank: 3 });
 
-  const editorFactory = editorServices.factoryService.newInlineEditor;
+  const editorFactory = editorServices.factoryService.newInlineEditor.bind(
+    editorServices.factoryService);
   const metadataEditor = new CellTools.MetadataEditorTool({ editorFactory });
   celltools.addItem({ tool: metadataEditor, rank: 4 });
 

+ 2 - 1
test/src/apputils/jsoneditor.spec.ts

@@ -56,7 +56,8 @@ describe('apputils', () => {
   describe('JSONEditorWidget', () => {
 
     let editor: LogEditor;
-    const editorFactory = new CodeMirrorEditorFactory().newInlineEditor;
+    let editorServices = new CodeMirrorEditorFactory();
+    const editorFactory = editorServices.newInlineEditor.bind(editorServices);
 
     beforeEach(() => {
       editor = new LogEditor({ editorFactory });

+ 2 - 1
test/src/console/utils.ts

@@ -15,7 +15,8 @@ import {
 
 
 export
-const editorFactory = editorServices.factoryService.newInlineEditor;
+const editorFactory = editorServices.factoryService.newInlineEditor.bind(
+    editorServices.factoryService);
 
 export
 const mimeTypeService = editorServices.mimeTypeService;

+ 2 - 1
test/src/notebook/celltools.spec.ts

@@ -267,7 +267,8 @@ describe('notebook/celltools', () => {
 
   describe('CellTools.MetadataEditorTool', () => {
 
-    const editorFactory = new CodeMirrorEditorFactory().newInlineEditor;
+    let editorServices = new CodeMirrorEditorFactory();
+    const editorFactory = editorServices.newInlineEditor.bind(editorServices);
 
     it('should create a new metadata editor tool', () => {
       let tool = new CellTools.MetadataEditorTool({ editorFactory });

+ 2 - 1
test/src/notebook/utils.ts

@@ -37,7 +37,8 @@ const DEFAULT_CONTENT: nbformat.INotebookContent = require('../../../examples/no
 
 
 export
-const editorFactory = editorServices.factoryService.newInlineEditor;
+const editorFactory = editorServices.factoryService.newInlineEditor.bind(
+  editorServices.factoryService);
 
 export
 const mimeTypeService = editorServices.mimeTypeService;