Afshin Darian 8 лет назад
Родитель
Сommit
85b3d2dd33

+ 16 - 0
packages/apputils-extension/src/index.ts

@@ -28,6 +28,10 @@ import {
   activatePalette
 } from './palette';
 
+import {
+  activateSettingEditor
+} from './settingeditor';
+
 
 /**
  * The command IDs used by the apputils plugin.
@@ -103,6 +107,17 @@ const palettePlugin: JupyterLabPlugin<ICommandPalette> = {
 };
 
 
+/**
+ * The default setting editor extension.
+ */
+const settingEditorPlugin: JupyterLabPlugin<void> = {
+  activate: activateSettingEditor,
+  id: 'jupyter.extensions.setting-editor',
+  requires: [ILayoutRestorer, ISettingRegistry],
+  autoStart: true
+};
+
+
 /**
  * The default layout restorer provider.
  */
@@ -158,6 +173,7 @@ const plugins: JupyterLabPlugin<any>[] = [
   linkerPlugin,
   mainMenuPlugin,
   palettePlugin,
+  settingEditorPlugin,
   settingPlugin,
   stateDBPlugin
 ];

+ 0 - 1
packages/apputils-extension/src/palette.ts

@@ -24,7 +24,6 @@ import {
 /**
  * The command IDs used by the apputils extension.
  */
-export
 namespace CommandIDs {
   export
   const activate = 'command-palette:activate';

+ 63 - 0
packages/apputils-extension/src/settingeditor.ts

@@ -0,0 +1,63 @@
+/*-----------------------------------------------------------------------------
+| Copyright (c) Jupyter Development Team.
+| Distributed under the terms of the Modified BSD License.
+|----------------------------------------------------------------------------*/
+
+import {
+  JupyterLab
+} from '@jupyterlab/application';
+
+import {
+  ILayoutRestorer
+} from '@jupyterlab/apputils';
+
+import {
+  ISettingRegistry
+} from '@jupyterlab/coreutils';
+
+
+import {
+  Widget
+} from '@phosphor/widgets';
+
+/**
+ * An interface for modifying and saving application settings.
+ */
+class SettingEditor extends Widget {
+}
+
+
+/**
+ * The command IDs used by the setting editor.
+ */
+namespace CommandIDs {
+  export
+  const activate = 'setting-editor:activate';
+};
+
+
+/**
+ * Activate the command palette.
+ */
+export
+function activateSettingEditor(app: JupyterLab, restorer: ILayoutRestorer, settings: ISettingRegistry): void {
+  const { commands, shell } = app;
+  const editor = new SettingEditor();
+
+  // Let the application restorer track the setting editor for restoration of
+  // application state.
+  restorer.add(editor, 'setting-editor');
+
+  editor.id = 'setting-editor';
+  editor.title.label = 'Settings';
+
+  commands.addCommand(CommandIDs.activate, {
+    execute: () => {
+      if (editor.parent === null) {
+        shell.addToMainArea(editor);
+      }
+      shell.activateById(editor.id);
+    },
+    label: 'Activate Setting Editor'
+  });
+}

+ 2 - 2
packages/fileeditor-extension/src/index.ts

@@ -162,7 +162,7 @@ function activate(app: JupyterLab, registry: IDocumentRegistry, restorer: ILayou
   }
 
   commands.addCommand(CommandIDs.lineNumbers, {
-    execute: (): Promise<void> => {
+    execute: () => {
       lineNumbers = !lineNumbers;
       tracker.forEach(widget => { widget.editor.lineNumbers = lineNumbers; });
       return settings.set(id, 'lineNumbers', lineNumbers);
@@ -173,7 +173,7 @@ function activate(app: JupyterLab, registry: IDocumentRegistry, restorer: ILayou
   });
 
   commands.addCommand(CommandIDs.wordWrap, {
-    execute: (): Promise<void> => {
+    execute: () => {
       wordWrap = !wordWrap;
       tracker.forEach(widget => { widget.editor.wordWrap = wordWrap; });
       return settings.set(id, 'wordWrap', wordWrap);