Ver código fonte

Merge branch 'master' into multiline-input

Jason Grout 7 anos atrás
pai
commit
79fdd0b0bd

+ 1 - 1
buildutils/src/add-sibling.ts

@@ -38,7 +38,7 @@ if (fs.existsSync(packagePath)) {
 } else {
   // Otherwise treat it as a git reposotory and try to add it.
   packageDirName = target.split('/').pop().split('.')[0];
-  let packagePath = path.join(basePath, 'packages', packageDirName);
+  packagePath = path.join(basePath, 'packages', packageDirName);
   utils.run('git clone ' + target + ' ' + packagePath);
 }
 

+ 1 - 0
package.json

@@ -31,6 +31,7 @@
     "publish": "jlpm run clean:slate && jlpm run build:packages && lerna publish --force-publish=* -m \"Publish\" && jlpm run build:update",
     "remove:dependency": "node buildutils/lib/remove-dependency.js",
     "remove:package": "node buildutils/lib/remove-package.js",
+    "remove:sibling": "node buildutils/lib/remove-package.js",
     "test": "cd test && jlpm test",
     "test:chrome": "lerna run test:chrome --stream",
     "test:firefox": "lerna run test:firefox --stream",

+ 2 - 2
packages/codemirror/src/editor.ts

@@ -40,9 +40,9 @@ import {
   Mode
 } from './mode';
 
+import 'codemirror/addon/comment/comment.js';
 import 'codemirror/addon/edit/matchbrackets.js';
 import 'codemirror/addon/edit/closebrackets.js';
-import 'codemirror/addon/comment/comment.js';
 import 'codemirror/addon/scroll/scrollpastend.js';
 import 'codemirror/addon/search/searchcursor';
 import 'codemirror/addon/search/search';
@@ -327,7 +327,7 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
    * Test whether the editor has keyboard focus.
    */
   hasFocus(): boolean {
-    return this._editor.hasFocus();
+    return this._editor.getWrapperElement().contains(document.activeElement);
   }
 
   /**

+ 5 - 6
packages/codemirror/style/index.css

@@ -36,6 +36,11 @@
 }
 
 
+.CodeMirror-dialog {
+  background-color: var(--jp-layout-color0);
+}
+
+
 /* This causes https://github.com/jupyter/jupyterlab/issues/522 */
 /* May not cause it not because we changed it! */
 .CodeMirror-lines {
@@ -58,12 +63,6 @@
 }
 
 
-/* Hide dialogs in inline editors due to poor UX with small editors. */
-.jp-CodeMirrorEditor[data-type="inline"] .CodeMirror-dialog {
-  display: none;
-}
-
-
 .CodeMirror-cursor {
   border-left: 1.4px solid var(--jp-editor-cursor-color);
 }

+ 23 - 10
packages/notebook/src/widget.ts

@@ -1316,7 +1316,9 @@ class Notebook extends StaticNotebook {
   private _ensureFocus(force=false): void {
     let activeCell = this.activeCell;
     if (this.mode === 'edit' && activeCell) {
-      activeCell.editor.focus();
+      if (!activeCell.editor.hasFocus()) {
+        activeCell.editor.focus();
+      }
     } else if (activeCell) {
       activeCell.editor.blur();
     }
@@ -1352,25 +1354,29 @@ class Notebook extends StaticNotebook {
    */
   private _evtMouseDown(event: MouseEvent): void {
 
-    // Mouse click should always ensure the notebook is focused.
-    this._ensureFocus(true);
-
     // We only handle main or secondary button actions.
     if (!(event.button === 0 || event.button === 2)) {
       return;
     }
 
     // Try to find the cell associated with the event.
+    // `event.target` sometimes gives an orphaned node in Firefox 57.
     let target = event.target as HTMLElement;
+    if (!target.parentElement) {
+      target = document.elementFromPoint(event.clientX, event.clientY) as HTMLElement;
+    }
     let index = this._findCell(target);
     let widget = this.widgets[index];
 
-
     // Switch to command mode if the click is not in an editor.
     if (index === -1 || !widget.editorWidget.node.contains(target)) {
       this.mode = 'command';
+    } else if (index !== -1) {
+      this.mode = 'edit';
     }
 
+    // Mouse click should always ensure the notebook is focused.
+    this._ensureFocus(true);
 
     // Secondary click deselects cells and possibly changes the active cell.
     if (event.button === 2) {
@@ -1381,8 +1387,6 @@ class Notebook extends StaticNotebook {
       return;
     }
 
-
-
     if (index !== -1) {
 
       if (event.shiftKey) {
@@ -1418,12 +1422,15 @@ class Notebook extends StaticNotebook {
           this._mouseMode = 'couldDrag';
           document.addEventListener('mouseup', this, true);
           document.addEventListener('mousemove', this, true);
-
           event.preventDefault();
         }
-
       }
-
+    } else {
+      // If there is a click event in the notebook, but not on any cells,
+      // deselect any current selection.
+      this.deselectAll();
+      event.preventDefault();
+      event.stopPropagation();
     }
   }
 
@@ -1730,7 +1737,13 @@ class Notebook extends StaticNotebook {
     if (!model) {
       return;
     }
+    this.deselectAll();
+
+    // `event.target` sometimes gives an orphaned node in Firefox 57.
     let target = event.target as HTMLElement;
+    if (!target.parentElement) {
+      target = document.elementFromPoint(event.clientX, event.clientY) as HTMLElement;
+    }
     let i = this._findCell(target);
     if (i === -1) {
       return;