فهرست منبع

Add jpCodeRunner as a data-attribute.

Ian Rose 7 سال پیش
والد
کامیت
04c50df99c

+ 4 - 4
packages/console-extension/src/index.ts

@@ -57,7 +57,7 @@ namespace CommandIDs {
   const clear = 'console:clear';
 
   export
-  const run = 'console:run';
+  const runUnforced = 'console:run-unforced';
 
   export
   const runForced = 'console:run-forced';
@@ -280,9 +280,9 @@ function activateConsole(app: JupyterLab, mainMenu: IMainMenu, palette: ICommand
   });
   palette.addItem({ command, category });
 
-  command = CommandIDs.run;
+  command = CommandIDs.runUnforced;
   commands.addCommand(command, {
-    label: 'Run Cell',
+    label: 'Run Cell (unforced)',
     execute: args => {
       let current = getCurrent(args);
       if (!current) {
@@ -434,7 +434,7 @@ function activateConsole(app: JupyterLab, mainMenu: IMainMenu, palette: ICommand
   });
 
   // Add the console menu.
-  menu.addItem({ command: CommandIDs.run });
+  menu.addItem({ command: CommandIDs.runUnforced });
   menu.addItem({ command: CommandIDs.runForced });
   menu.addItem({ command: CommandIDs.linebreak });
   menu.addItem({ type: 'separator' });

+ 6 - 0
packages/console/src/widget.ts

@@ -56,6 +56,11 @@ import {
  */
 const KERNEL_USER = 'jpKernelUser';
 
+/**
+ * The data attribute added to a widget can run code.
+ */
+const CODE_RUNNER = 'jpCodeRunner';
+
 /**
  * The class name added to console widgets.
  */
@@ -108,6 +113,7 @@ class CodeConsole extends Widget {
     super();
     this.addClass(CONSOLE_CLASS);
     this.node.dataset[KERNEL_USER] = 'true';
+    this.node.dataset[CODE_RUNNER] = 'true';
     this.node.tabIndex = -1;  // Allow the widget to take focus.
 
     // Create the panels that hold the content and input.

+ 6 - 0
packages/notebook/src/widget.ts

@@ -65,6 +65,11 @@ import {
  */
 const KERNEL_USER = 'jpKernelUser';
 
+/**
+ * The data attribute added to a widget that can run code.
+ */
+const CODE_RUNNER = 'jpCodeRunner';
+
 /**
  * The class name added to notebook widgets.
  */
@@ -175,6 +180,7 @@ class StaticNotebook extends Widget {
     super();
     this.addClass(NB_CLASS);
     this.node.dataset[KERNEL_USER] = 'true';
+    this.node.dataset[CODE_RUNNER] = 'true';
     this.rendermime = options.rendermime;
     this.layout = new Private.NotebookPanelLayout();
     this.contentFactory = (

+ 12 - 12
packages/shortcuts-extension/schema/plugin.json

@@ -67,10 +67,10 @@
       },
       "type": "object"
     },
-    "console:run": {
+    "console:run-unforced": {
       "default": { },
       "properties": {
-        "command": { "default": "console:run" },
+        "command": { "default": "console:run-unforced" },
         "keys": { "default": ["Enter"] },
         "selector": { "default": ".jp-CodeConsole-promptCell" }
       },
@@ -483,7 +483,7 @@
       },
       "type": "object"
     },
-    "notebook:run-cell-and-select-next-1": {
+    "notebook:run-cell-and-select-next": {
       "default": { },
       "properties": {
         "command": { "default": "notebook:run-cell-and-select-next" },
@@ -492,15 +492,6 @@
       },
       "type": "object"
     },
-    "notebook:run-cell-and-select-next-2": {
-      "default": { },
-      "properties": {
-        "command": { "default": "notebook:run-cell-and-select-next" },
-        "keys": { "default": ["Shift Enter"] },
-        "selector": { "default": ".jp-Notebook:focus" }
-      },
-      "type": "object"
-    },
     "notebook:split-cell-at-cursor": {
       "default": { },
       "properties": {
@@ -546,6 +537,15 @@
       },
       "type": "object"
     },
+    "run:run": {
+      "default": { },
+      "properties": {
+        "command": { "default": "run:run" },
+        "keys": { "default": ["Shift Enter"] },
+        "selector": { "default": "[data-jp-code-runner]:focus" }
+      },
+      "type": "object"
+    },
     "settingeditor:open": {
       "default": { },
       "properties": {