Skip to content

Commit

Permalink
Addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhu94 committed Jan 12, 2019
1 parent e778602 commit a6c2504
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/notebook/package.json
Expand Up @@ -12,11 +12,11 @@
"@jupyterlab/completer": "^0.19.1",
"@jupyterlab/docmanager": "^0.19.1",
"@jupyterlab/docregistry": "^0.19.1",
"@jupyterlab/mathjax2": "^0.7.1",
"@jupyterlab/notebook": "^0.19.2",
"@jupyterlab/rendermime": "^0.19.1",
"@jupyterlab/services": "^3.2.1",
"@jupyterlab/theme-light-extension": "^0.19.1",
"@jupyterlab/mathjax2": "^0.7.1",
"@phosphor/commands": "^1.6.1",
"@phosphor/widgets": "^1.6.0",
"es6-promise": "~4.1.1"
Expand Down
5 changes: 4 additions & 1 deletion packages/cells/src/celldragutils.ts
Expand Up @@ -13,7 +13,7 @@ import { each, IterableOrArrayLike } from '@phosphor/algorithm';
import { ICodeCellModel } from './model';
import { Cell } from './widget';
import { h, VirtualDOM } from '@phosphor/virtualdom';
import { nbformat } from '../../coreutils/lib';
import { nbformat } from '@jupyterlab/coreutils';

/**
* Constants for drag
Expand Down Expand Up @@ -60,6 +60,9 @@ export namespace CellDragUtils {
* @param cells - an iterable of Cells
* @param isCellNode - a function that takes in a node and checks if
* it is a cell node.
*
* @returns index of the cell we're looking for. Returns -1 if
* the cell is not founds
*/
export function findCell(
node: HTMLElement,
Expand Down
14 changes: 9 additions & 5 deletions packages/console/src/widget.ts
Expand Up @@ -421,6 +421,10 @@ export class CodeConsole extends Widget {
cellIndex = CellDragUtils.findCell(target, this._cells, cellFilter);
}

if (cellIndex === -1) {
return;
}

const cell = this._cells.get(cellIndex);

let targetArea: CellDragUtils.ICellTargetArea = CellDragUtils.detectTargetArea(
Expand All @@ -435,7 +439,7 @@ export class CodeConsole extends Widget {
index: cellIndex
};

this._focussedCell = cell;
this._focusedCell = cell;

document.addEventListener('mouseup', this, true);
document.addEventListener('mousemove', this, true);
Expand Down Expand Up @@ -464,11 +468,11 @@ export class CodeConsole extends Widget {
* Start a drag event
*/
private _startDrag(index: number, clientX: number, clientY: number) {
const cellModel = this._focussedCell.model as ICodeCellModel;
const cellModel = this._focusedCell.model as ICodeCellModel;
let selected: nbformat.ICell[] = [cellModel.toJSON()];

const dragImage = CellDragUtils.createCellDragImage(
this._focussedCell,
this._focusedCell,
selected
);

Expand All @@ -484,7 +488,7 @@ export class CodeConsole extends Widget {
const textContent = cellModel.value.text;
this._drag.mimeData.setData('text/plain', textContent);

this._focussedCell = null;
this._focusedCell = null;

document.removeEventListener('mousemove', this, true);
document.removeEventListener('mouseup', this, true);
Expand Down Expand Up @@ -817,7 +821,7 @@ export class CodeConsole extends Widget {
private _promptCellCreated = new Signal<this, CodeCell>(this);
private _dragData: { pressX: number; pressY: number; index: number } = null;
private _drag: Drag = null;
private _focussedCell: Cell = null;
private _focusedCell: Cell = null;
}

/**
Expand Down

0 comments on commit a6c2504

Please sign in to comment.