diff --git a/examples/notebook/package.json b/examples/notebook/package.json index 994b21b2783d..6e1229e52e10 100644 --- a/examples/notebook/package.json +++ b/examples/notebook/package.json @@ -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" diff --git a/packages/cells/src/celldragutils.ts b/packages/cells/src/celldragutils.ts index fd6e7cc1309c..d67bd588df2f 100644 --- a/packages/cells/src/celldragutils.ts +++ b/packages/cells/src/celldragutils.ts @@ -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 @@ -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, diff --git a/packages/console/src/widget.ts b/packages/console/src/widget.ts index 3fcd06dae6bb..0e4a2c8b4bb3 100644 --- a/packages/console/src/widget.ts +++ b/packages/console/src/widget.ts @@ -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( @@ -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); @@ -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 ); @@ -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); @@ -817,7 +821,7 @@ export class CodeConsole extends Widget { private _promptCellCreated = new Signal(this); private _dragData: { pressX: number; pressY: number; index: number } = null; private _drag: Drag = null; - private _focussedCell: Cell = null; + private _focusedCell: Cell = null; } /**