@jupyterlab/console
Advanced tools
Comparing version 0.3.2 to 0.4.0
import { KernelMessage } from '@jupyterlab/services'; | ||
import { IDisposable } from '@phosphor/disposable'; | ||
import { IClientSession } from '@jupyterlab/apputils'; | ||
import { BaseCellWidget, CodeCellWidget } from '@jupyterlab/cells'; | ||
import { Cell, CodeCell } from '@jupyterlab/cells'; | ||
/** | ||
@@ -69,3 +69,3 @@ * A handler for capturing API messages from other sessions that should be | ||
*/ | ||
cellFactory: () => CodeCellWidget; | ||
cellFactory: () => CodeCell; | ||
} | ||
@@ -79,3 +79,3 @@ /** | ||
*/ | ||
addCell(cell: BaseCellWidget): void; | ||
addCell(cell: Cell): void; | ||
/** | ||
@@ -82,0 +82,0 @@ * Trigger a rendering update on the receiver. |
import { IClientSession } from '@jupyterlab/apputils'; | ||
import { BaseCellWidget, CodeCellWidget } from '@jupyterlab/cells'; | ||
import { IEditorMimeTypeService, CodeEditor } from '@jupyterlab/codeeditor'; | ||
import { OutputAreaWidget } from '@jupyterlab/outputarea'; | ||
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor'; | ||
import { IRenderMime } from '@jupyterlab/rendermime'; | ||
@@ -20,2 +18,6 @@ import { ServiceManager } from '@jupyterlab/services'; | ||
/** | ||
* The content factory used by the console panel. | ||
*/ | ||
readonly contentFactory: ConsolePanel.IContentFactory; | ||
/** | ||
* The console widget used by the panel. | ||
@@ -105,12 +107,4 @@ */ | ||
*/ | ||
interface IContentFactory { | ||
interface IContentFactory extends CodeConsole.IContentFactory { | ||
/** | ||
* The editor factory used by the content factory. | ||
*/ | ||
readonly editorFactory: CodeEditor.Factory; | ||
/** | ||
* The factory for code console content. | ||
*/ | ||
readonly consoleContentFactory: CodeConsole.IContentFactory; | ||
/** | ||
* Create a new console panel. | ||
@@ -123,16 +117,4 @@ */ | ||
*/ | ||
class ContentFactory implements IContentFactory { | ||
class ContentFactory extends CodeConsole.ContentFactory implements IContentFactory { | ||
/** | ||
* Create a new content factory. | ||
*/ | ||
constructor(options: ContentFactory.IOptions); | ||
/** | ||
* The editor factory used by the content factory. | ||
*/ | ||
readonly editorFactory: CodeEditor.Factory; | ||
/** | ||
* The factory for code console content. | ||
*/ | ||
readonly consoleContentFactory: CodeConsole.IContentFactory; | ||
/** | ||
* Create a new console panel. | ||
@@ -143,35 +125,16 @@ */ | ||
/** | ||
* The namespace for `ContentFactory`. | ||
* A namespace for the console panel content factory. | ||
*/ | ||
namespace ContentFactory { | ||
/** | ||
* An initialization options for a console panel factory. | ||
* Options for the code console content factory. | ||
*/ | ||
interface IOptions { | ||
/** | ||
* The editor factory. This will be used to create a | ||
* consoleContentFactory if none is given. | ||
*/ | ||
editorFactory: CodeEditor.Factory; | ||
/** | ||
* The factory for output area content. | ||
*/ | ||
outputAreaContentFactory?: OutputAreaWidget.IContentFactory; | ||
/** | ||
* The factory for code cell widget content. If given, this will | ||
* take precedence over the `outputAreaContentFactory`. | ||
*/ | ||
codeCellContentFactory?: CodeCellWidget.IContentFactory; | ||
/** | ||
* The factory for raw cell widget content. | ||
*/ | ||
rawCellContentFactory?: BaseCellWidget.IContentFactory; | ||
/** | ||
* The factory for console widget content. If given, this will | ||
* take precedence over the output area and cell factories. | ||
*/ | ||
consoleContentFactory?: CodeConsole.IContentFactory; | ||
interface IOptions extends CodeConsole.ContentFactory.IOptions { | ||
} | ||
} | ||
/** | ||
* A default code console content factory. | ||
*/ | ||
const defaultContentFactory: IContentFactory; | ||
/** | ||
* The console renderer token. | ||
@@ -178,0 +141,0 @@ */ |
@@ -25,2 +25,3 @@ "use strict"; | ||
var PANEL_CLASS = 'jp-ConsolePanel'; | ||
var CONSOLE_ICON_CLASS = 'jp-ImageCodeConsole'; | ||
/** | ||
@@ -40,4 +41,3 @@ * A panel which contains a console and the ability to add other children. | ||
var rendermime = options.rendermime, mimeTypeService = options.mimeTypeService, path = options.path, basePath = options.basePath, name = options.name, manager = options.manager, modelFactory = options.modelFactory; | ||
var factory = options.contentFactory; | ||
var contentFactory = factory.consoleContentFactory; | ||
var contentFactory = _this.contentFactory = (options.contentFactory || ConsolePanel.defaultContentFactory); | ||
var count = Private.count++; | ||
@@ -58,3 +58,3 @@ if (!path) { | ||
}); | ||
_this.console = factory.createConsole({ | ||
_this.console = contentFactory.createConsole({ | ||
rendermime: rendermime, session: session, mimeTypeService: mimeTypeService, contentFactory: contentFactory, modelFactory: modelFactory | ||
@@ -71,3 +71,3 @@ }); | ||
session.propertyChanged.connect(_this._updateTitle, _this); | ||
_this.title.icon = 'jp-ImageCodeConsole'; | ||
_this.title.icon = CONSOLE_ICON_CLASS; | ||
_this.title.closable = true; | ||
@@ -104,3 +104,3 @@ _this.id = "console-" + count; | ||
ConsolePanel.prototype.onActivateRequest = function (msg) { | ||
this.console.prompt.editor.focus(); | ||
this.console.promptCell.editor.focus(); | ||
}; | ||
@@ -137,15 +137,6 @@ /** | ||
*/ | ||
var ContentFactory = (function () { | ||
/** | ||
* Create a new content factory. | ||
*/ | ||
function ContentFactory(options) { | ||
this.editorFactory = options.editorFactory; | ||
this.consoleContentFactory = (options.consoleContentFactory || | ||
new widget_1.CodeConsole.ContentFactory({ | ||
editorFactory: this.editorFactory, | ||
outputAreaContentFactory: options.outputAreaContentFactory, | ||
codeCellContentFactory: options.codeCellContentFactory, | ||
rawCellContentFactory: options.rawCellContentFactory | ||
})); | ||
var ContentFactory = (function (_super) { | ||
__extends(ContentFactory, _super); | ||
function ContentFactory() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
@@ -159,4 +150,8 @@ /** | ||
return ContentFactory; | ||
}()); | ||
}(widget_1.CodeConsole.ContentFactory)); | ||
ConsolePanel.ContentFactory = ContentFactory; | ||
/** | ||
* A default code console content factory. | ||
*/ | ||
ConsolePanel.defaultContentFactory = new ContentFactory(); | ||
/* tslint:disable */ | ||
@@ -163,0 +158,0 @@ /** |
@@ -5,9 +5,6 @@ import { Message } from '@phosphor/messaging'; | ||
import { IClientSession } from '@jupyterlab/apputils'; | ||
import { IEditorMimeTypeService, CodeEditor } from '@jupyterlab/codeeditor'; | ||
import { BaseCellWidget, CodeCellWidget, RawCellWidget, ICodeCellModel, IRawCellModel, CellModel, CodeCellModel } from '@jupyterlab/cells'; | ||
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor'; | ||
import { Cell, CodeCell, RawCell, ICodeCellModel, IRawCellModel, CellModel, CodeCellModel } from '@jupyterlab/cells'; | ||
import { nbformat, IObservableVector } from '@jupyterlab/coreutils'; | ||
import { OutputAreaWidget } from '@jupyterlab/outputarea'; | ||
import { IRenderMime } from '@jupyterlab/rendermime'; | ||
import { ForeignHandler } from './foreign'; | ||
import { ConsoleHistory, IConsoleHistory } from './history'; | ||
/** | ||
@@ -26,9 +23,9 @@ * A widget containing a Jupyter console. | ||
/** | ||
* A signal emitted when the console finished executing its prompt. | ||
* A signal emitted when the console finished executing its prompt cell. | ||
*/ | ||
readonly executed: ISignal<this, Date>; | ||
/** | ||
* A signal emitted when a new prompt is created. | ||
* A signal emitted when a new prompt cell is created. | ||
*/ | ||
readonly promptCreated: ISignal<this, CodeCellWidget>; | ||
readonly promptCellCreated: ISignal<this, CodeCell>; | ||
/** | ||
@@ -51,6 +48,2 @@ * The content factory used by the console. | ||
/** | ||
* The console banner widget. | ||
*/ | ||
readonly banner: RawCellWidget; | ||
/** | ||
* The list of content cells in the console. | ||
@@ -61,4 +54,4 @@ * | ||
*/ | ||
readonly cells: IObservableVector<BaseCellWidget>; | ||
readonly prompt: CodeCellWidget | null; | ||
readonly cells: IObservableVector<Cell>; | ||
readonly promptCell: CodeCell | null; | ||
/** | ||
@@ -74,3 +67,3 @@ * Add a new cell to the content panel. | ||
*/ | ||
addCell(cell: BaseCellWidget): void; | ||
addCell(cell: Cell): void; | ||
/** | ||
@@ -104,3 +97,3 @@ * Clear the code cells. | ||
/** | ||
* Insert a line break in the prompt. | ||
* Insert a line break in the prompt cell. | ||
*/ | ||
@@ -136,5 +129,5 @@ insertLinebreak(): void; | ||
/** | ||
* Make a new prompt. | ||
* Make a new prompt cell. | ||
*/ | ||
protected newPrompt(): void; | ||
protected newPromptCell(): void; | ||
/** | ||
@@ -149,3 +142,3 @@ * Handle `update-request` messages. | ||
/** | ||
* Execute the code in the current prompt. | ||
* Execute the code in the current prompt cell. | ||
*/ | ||
@@ -160,3 +153,3 @@ private _execute(cell); | ||
*/ | ||
private _createForeignCell(); | ||
private _createCodeCell(); | ||
/** | ||
@@ -171,3 +164,3 @@ * Create the options used to initialize a code cell widget. | ||
/** | ||
* Test whether we should execute the prompt. | ||
* Test whether we should execute the prompt cell. | ||
*/ | ||
@@ -183,5 +176,6 @@ private _shouldExecute(timeout); | ||
private _onKernelChanged(); | ||
private _mimeTypeService; | ||
private _banner; | ||
private _cells; | ||
private _content; | ||
private _executed; | ||
private _foreignHandler; | ||
@@ -191,4 +185,4 @@ private _history; | ||
private _mimetype; | ||
private _executed; | ||
private _promptCreated; | ||
private _mimeTypeService; | ||
private _promptCellCreated; | ||
} | ||
@@ -227,35 +221,11 @@ /** | ||
*/ | ||
interface IContentFactory { | ||
interface IContentFactory extends Cell.IContentFactory { | ||
/** | ||
* The editor factory. | ||
* Create a new code cell widget. | ||
*/ | ||
readonly editorFactory: CodeEditor.Factory; | ||
createCodeCell(options: CodeCell.IOptions): CodeCell; | ||
/** | ||
* The factory for code cell widget content. | ||
* Create a new raw cell widget. | ||
*/ | ||
readonly codeCellContentFactory: CodeCellWidget.IContentFactory; | ||
/** | ||
* The factory for raw cell widget content. | ||
*/ | ||
readonly rawCellContentFactory: BaseCellWidget.IContentFactory; | ||
/** | ||
* The history manager for a console widget. | ||
*/ | ||
createConsoleHistory(options: ConsoleHistory.IOptions): IConsoleHistory; | ||
/** | ||
* The foreign handler for a console widget. | ||
*/ | ||
createForeignHandler(options: ForeignHandler.IOptions): ForeignHandler; | ||
/** | ||
* Create a new banner widget. | ||
*/ | ||
createBanner(options: RawCellWidget.IOptions, parent: CodeConsole): RawCellWidget; | ||
/** | ||
* Create a new prompt widget. | ||
*/ | ||
createPrompt(options: CodeCellWidget.IOptions, parent: CodeConsole): CodeCellWidget; | ||
/** | ||
* Create a code cell whose input originated from a foreign session. | ||
*/ | ||
createForeignCell(options: CodeCellWidget.IOptions, parent: CodeConsole): CodeCellWidget; | ||
createRawCell(options: RawCell.IOptions): RawCell; | ||
} | ||
@@ -265,63 +235,35 @@ /** | ||
*/ | ||
class ContentFactory implements IContentFactory { | ||
class ContentFactory extends Cell.ContentFactory implements IContentFactory { | ||
/** | ||
* Create a new content factory. | ||
* Create a new code cell widget. | ||
* | ||
* #### Notes | ||
* If no cell content factory is passed in with the options, the one on the | ||
* notebook content factory is used. | ||
*/ | ||
constructor(options: IContentFactoryOptions); | ||
createCodeCell(options: CodeCell.IOptions): CodeCell; | ||
/** | ||
* The editor factory. | ||
* Create a new raw cell widget. | ||
* | ||
* #### Notes | ||
* If no cell content factory is passed in with the options, the one on the | ||
* notebook content factory is used. | ||
*/ | ||
readonly editorFactory: CodeEditor.Factory; | ||
/** | ||
* The factory for code cell widget content. | ||
*/ | ||
readonly codeCellContentFactory: CodeCellWidget.IContentFactory; | ||
/** | ||
* The factory for raw cell widget content. | ||
*/ | ||
readonly rawCellContentFactory: BaseCellWidget.IContentFactory; | ||
/** | ||
* The history manager for a console widget. | ||
*/ | ||
createConsoleHistory(options: ConsoleHistory.IOptions): IConsoleHistory; | ||
/** | ||
* The foreign handler for a console widget. | ||
*/ | ||
createForeignHandler(options: ForeignHandler.IOptions): ForeignHandler; | ||
/** | ||
* Create a new banner widget. | ||
*/ | ||
createBanner(options: RawCellWidget.IOptions, parent: CodeConsole): RawCellWidget; | ||
/** | ||
* Create a new prompt widget. | ||
*/ | ||
createPrompt(options: CodeCellWidget.IOptions, parent: CodeConsole): CodeCellWidget; | ||
/** | ||
* Create a new code cell widget for an input from a foreign session. | ||
*/ | ||
createForeignCell(options: CodeCellWidget.IOptions, parent: CodeConsole): CodeCellWidget; | ||
createRawCell(options: RawCell.IOptions): RawCell; | ||
} | ||
/** | ||
* An initialize options for `ContentFactory`. | ||
* A namespace for the code console content factory. | ||
*/ | ||
interface IContentFactoryOptions { | ||
namespace ContentFactory { | ||
/** | ||
* The editor factory. | ||
* An initialize options for `ContentFactory`. | ||
*/ | ||
editorFactory: CodeEditor.Factory; | ||
/** | ||
* The factory for output area content. | ||
*/ | ||
outputAreaContentFactory?: OutputAreaWidget.IContentFactory; | ||
/** | ||
* The factory for code cell widget content. If given, this will | ||
* take precedence over the `outputAreaContentFactory`. | ||
*/ | ||
codeCellContentFactory?: CodeCellWidget.IContentFactory; | ||
/** | ||
* The factory for raw cell widget content. | ||
*/ | ||
rawCellContentFactory?: BaseCellWidget.IContentFactory; | ||
interface IOptions extends Cell.IContentFactory { | ||
} | ||
} | ||
/** | ||
* A default content factory for the code console. | ||
*/ | ||
const defaultContentFactory: IContentFactory; | ||
/** | ||
* A model factory for a console widget. | ||
@@ -360,3 +302,3 @@ */ | ||
*/ | ||
constructor(options: IModelFactoryOptions); | ||
constructor(options?: IModelFactoryOptions); | ||
/** | ||
@@ -363,0 +305,0 @@ * The factory for output area models. |
@@ -21,3 +21,2 @@ "use strict"; | ||
var coreutils_1 = require("@jupyterlab/coreutils"); | ||
var outputarea_1 = require("@jupyterlab/outputarea"); | ||
var foreign_1 = require("./foreign"); | ||
@@ -38,5 +37,5 @@ var history_1 = require("./history"); | ||
/** | ||
* The class name of the active prompt | ||
* The class name of the active prompt cell. | ||
*/ | ||
var PROMPT_CLASS = 'jp-CodeConsole-prompt'; | ||
var PROMPT_CLASS = 'jp-CodeConsole-promptCell'; | ||
/** | ||
@@ -68,4 +67,6 @@ * The class name of the panel that holds cell content. | ||
var _this = _super.call(this) || this; | ||
_this._banner = null; | ||
_this._cells = null; | ||
_this._content = null; | ||
_this._executed = new signaling_1.Signal(_this); | ||
_this._foreignHandler = null; | ||
@@ -75,4 +76,4 @@ _this._history = null; | ||
_this._mimetype = 'text/x-ipython'; | ||
_this._executed = new signaling_1.Signal(_this); | ||
_this._promptCreated = new signaling_1.Signal(_this); | ||
_this._mimeTypeService = null; | ||
_this._promptCellCreated = new signaling_1.Signal(_this); | ||
_this.addClass(CONSOLE_CLASS); | ||
@@ -84,3 +85,3 @@ // Create the panels that hold the content and input. | ||
_this._input = new widgets_1.Panel(); | ||
var factory = _this.contentFactory = options.contentFactory; | ||
var contentFactory = _this.contentFactory = (options.contentFactory || CodeConsole.defaultContentFactory); | ||
var modelFactory = _this.modelFactory = (options.modelFactory || CodeConsole.defaultModelFactory); | ||
@@ -99,6 +100,6 @@ _this.rendermime = options.rendermime; | ||
model.value.text = '...'; | ||
var banner = _this.banner = factory.createBanner({ | ||
var banner = _this._banner = new cells_1.RawCell({ | ||
model: model, | ||
contentFactory: factory.rawCellContentFactory | ||
}, _this); | ||
contentFactory: contentFactory | ||
}); | ||
banner.addClass(BANNER_CLASS); | ||
@@ -108,8 +109,8 @@ banner.readOnly = true; | ||
// Set up the foreign iopub handler. | ||
_this._foreignHandler = factory.createForeignHandler({ | ||
_this._foreignHandler = new foreign_1.ForeignHandler({ | ||
session: _this.session, | ||
parent: _this, | ||
cellFactory: function () { return _this._createForeignCell(); }, | ||
cellFactory: function () { return _this._createCodeCell(); }, | ||
}); | ||
_this._history = factory.createConsoleHistory({ | ||
_this._history = new history_1.ConsoleHistory({ | ||
session: _this.session | ||
@@ -123,3 +124,3 @@ }); | ||
/** | ||
* A signal emitted when the console finished executing its prompt. | ||
* A signal emitted when the console finished executing its prompt cell. | ||
*/ | ||
@@ -132,8 +133,8 @@ get: function () { | ||
}); | ||
Object.defineProperty(CodeConsole.prototype, "promptCreated", { | ||
Object.defineProperty(CodeConsole.prototype, "promptCellCreated", { | ||
/** | ||
* A signal emitted when a new prompt is created. | ||
* A signal emitted when a new prompt cell is created. | ||
*/ | ||
get: function () { | ||
return this._promptCreated; | ||
return this._promptCellCreated; | ||
}, | ||
@@ -156,5 +157,5 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(CodeConsole.prototype, "prompt", { | ||
Object.defineProperty(CodeConsole.prototype, "promptCell", { | ||
/* | ||
* The console input prompt. | ||
* The console input prompt cell. | ||
*/ | ||
@@ -202,11 +203,15 @@ get: function () { | ||
} | ||
var cells = this._cells; | ||
var history = this._history; | ||
var foreignHandler = this._foreignHandler; | ||
var history = this._history; | ||
var cells = this._cells; | ||
this._banner = null; | ||
this._cells = null; | ||
this._content = null; | ||
this._input = null; | ||
this._mimeTypeService = null; | ||
this._foreignHandler = null; | ||
this._history = null; | ||
this._cells = null; | ||
cells.clear(); | ||
history.dispose(); | ||
foreignHandler.dispose(); | ||
history.dispose(); | ||
cells.clear(); | ||
_super.prototype.dispose.call(this); | ||
@@ -231,8 +236,8 @@ }; | ||
} | ||
var prompt = this.prompt; | ||
prompt.model.trusted = true; | ||
var promptCell = this.promptCell; | ||
promptCell.model.trusted = true; | ||
if (force) { | ||
// Create a new prompt before kernel execution to allow typeahead. | ||
this.newPrompt(); | ||
return this._execute(prompt); | ||
// Create a new prompt cell before kernel execution to allow typeahead. | ||
this.newPromptCell(); | ||
return this._execute(promptCell); | ||
} | ||
@@ -245,5 +250,5 @@ // Check whether we should execute. | ||
if (should) { | ||
// Create a new prompt before kernel execution to allow typeahead. | ||
_this.newPrompt(); | ||
return _this._execute(prompt); | ||
// Create a new prompt cell before kernel execution to allow typeahead. | ||
_this.newPromptCell(); | ||
return _this._execute(promptCell); | ||
} | ||
@@ -260,3 +265,3 @@ }); | ||
CodeConsole.prototype.inject = function (code) { | ||
var cell = this._createForeignCell(); | ||
var cell = this._createCodeCell(); | ||
cell.model.value.text = code; | ||
@@ -267,8 +272,8 @@ this.addCell(cell); | ||
/** | ||
* Insert a line break in the prompt. | ||
* Insert a line break in the prompt cell. | ||
*/ | ||
CodeConsole.prototype.insertLinebreak = function () { | ||
var prompt = this.prompt; | ||
var model = prompt.model; | ||
var editor = prompt.editor; | ||
var promptCell = this.promptCell; | ||
var model = promptCell.model; | ||
var editor = promptCell.editor; | ||
// Insert the line break at the cursor position, and move cursor forward. | ||
@@ -286,3 +291,3 @@ var pos = editor.getCursorPosition(); | ||
CodeConsole.prototype.serialize = function () { | ||
var prompt = this.prompt; | ||
var promptCell = this.promptCell; | ||
var layout = this._content.layout; | ||
@@ -293,4 +298,4 @@ // Serialize content. | ||
}); | ||
// Serialize prompt and return. | ||
return algorithm_1.toArray(output).concat(prompt.model.toJSON()); | ||
// Serialize prompt cell and return. | ||
return algorithm_1.toArray(output).concat(promptCell.model.toJSON()); | ||
}; | ||
@@ -323,7 +328,7 @@ /** | ||
// Create a prompt if necessary. | ||
if (!this.prompt) { | ||
this.newPrompt(); | ||
if (!this.promptCell) { | ||
this.newPromptCell(); | ||
} | ||
else { | ||
this.prompt.editor.focus(); | ||
this.promptCell.editor.focus(); | ||
this.update(); | ||
@@ -343,28 +348,28 @@ } | ||
CodeConsole.prototype.onActivateRequest = function (msg) { | ||
this.prompt.editor.focus(); | ||
this.promptCell.editor.focus(); | ||
this.update(); | ||
}; | ||
/** | ||
* Make a new prompt. | ||
* Make a new prompt cell. | ||
*/ | ||
CodeConsole.prototype.newPrompt = function () { | ||
var prompt = this.prompt; | ||
CodeConsole.prototype.newPromptCell = function () { | ||
var promptCell = this.promptCell; | ||
var input = this._input; | ||
// Make the last prompt read-only, clear its signals, and move to content. | ||
if (prompt) { | ||
prompt.readOnly = true; | ||
prompt.removeClass(PROMPT_CLASS); | ||
signaling_1.Signal.clearData(prompt.editor); | ||
if (promptCell) { | ||
promptCell.readOnly = true; | ||
promptCell.removeClass(PROMPT_CLASS); | ||
signaling_1.Signal.clearData(promptCell.editor); | ||
input.layout.removeWidgetAt(0); | ||
this.addCell(prompt); | ||
this.addCell(promptCell); | ||
} | ||
// Create the new prompt. | ||
// Create the new prompt cell. | ||
var factory = this.contentFactory; | ||
var options = this._createCodeCellOptions(); | ||
prompt = factory.createPrompt(options, this); | ||
prompt.model.mimeType = this._mimetype; | ||
prompt.addClass(PROMPT_CLASS); | ||
this._input.addWidget(prompt); | ||
promptCell = factory.createCodeCell(options); | ||
promptCell.model.mimeType = this._mimetype; | ||
promptCell.addClass(PROMPT_CLASS); | ||
this._input.addWidget(promptCell); | ||
// Suppress the default "Enter" key handling. | ||
var editor = prompt.editor; | ||
var editor = promptCell.editor; | ||
editor.addKeydownHandler(this._onEditorKeydown); | ||
@@ -375,3 +380,3 @@ this._history.editor = editor; | ||
} | ||
this._promptCreated.emit(prompt); | ||
this._promptCellCreated.emit(promptCell); | ||
}; | ||
@@ -388,3 +393,3 @@ /** | ||
CodeConsole.prototype._evtKeyDown = function (event) { | ||
var editor = this.prompt.editor; | ||
var editor = this.promptCell.editor; | ||
if (event.keyCode === 13 && !editor.hasFocus()) { | ||
@@ -396,3 +401,3 @@ event.preventDefault(); | ||
/** | ||
* Execute the code in the current prompt. | ||
* Execute the code in the current prompt cell. | ||
*/ | ||
@@ -443,4 +448,4 @@ CodeConsole.prototype._execute = function (cell) { | ||
this._mimetype = this._mimeTypeService.getMimeTypeByLanguage(lang); | ||
if (this.prompt) { | ||
this.prompt.model.mimeType = this._mimetype; | ||
if (this.promptCell) { | ||
this.promptCell.model.mimeType = this._mimetype; | ||
} | ||
@@ -451,6 +456,6 @@ }; | ||
*/ | ||
CodeConsole.prototype._createForeignCell = function () { | ||
CodeConsole.prototype._createCodeCell = function () { | ||
var factory = this.contentFactory; | ||
var options = this._createCodeCellOptions(); | ||
var cell = factory.createForeignCell(options, this); | ||
var cell = factory.createCodeCell(options); | ||
cell.readOnly = true; | ||
@@ -465,4 +470,3 @@ cell.model.mimeType = this._mimetype; | ||
CodeConsole.prototype._createCodeCellOptions = function () { | ||
var factory = this.contentFactory; | ||
var contentFactory = factory.codeCellContentFactory; | ||
var contentFactory = this.contentFactory; | ||
var modelFactory = this.modelFactory; | ||
@@ -482,8 +486,8 @@ var model = modelFactory.createCodeCell({}); | ||
/** | ||
* Test whether we should execute the prompt. | ||
* Test whether we should execute the prompt cell. | ||
*/ | ||
CodeConsole.prototype._shouldExecute = function (timeout) { | ||
var _this = this; | ||
var prompt = this.prompt; | ||
var model = prompt.model; | ||
var promptCell = this.promptCell; | ||
var model = promptCell.model; | ||
var code = model.value.text + '\n'; | ||
@@ -502,3 +506,3 @@ return new Promise(function (resolve, reject) { | ||
model.value.text = code + isComplete.content.indent; | ||
var editor = prompt.editor; | ||
var editor = promptCell.editor; | ||
var pos = editor.getPositionAt(model.value.text.length); | ||
@@ -544,52 +548,41 @@ editor.setCursorPosition(pos); | ||
*/ | ||
var ContentFactory = (function () { | ||
/** | ||
* Create a new content factory. | ||
*/ | ||
function ContentFactory(options) { | ||
var editorFactory = options.editorFactory; | ||
var outputAreaContentFactory = (options.outputAreaContentFactory || | ||
outputarea_1.OutputAreaWidget.defaultContentFactory); | ||
this.codeCellContentFactory = (options.codeCellContentFactory || | ||
new cells_1.CodeCellWidget.ContentFactory({ | ||
editorFactory: editorFactory, | ||
outputAreaContentFactory: outputAreaContentFactory | ||
})); | ||
this.rawCellContentFactory = (options.rawCellContentFactory || | ||
new cells_1.RawCellWidget.ContentFactory({ editorFactory: editorFactory })); | ||
var ContentFactory = (function (_super) { | ||
__extends(ContentFactory, _super); | ||
function ContentFactory() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
/** | ||
* The history manager for a console widget. | ||
* Create a new code cell widget. | ||
* | ||
* #### Notes | ||
* If no cell content factory is passed in with the options, the one on the | ||
* notebook content factory is used. | ||
*/ | ||
ContentFactory.prototype.createConsoleHistory = function (options) { | ||
return new history_1.ConsoleHistory(options); | ||
ContentFactory.prototype.createCodeCell = function (options) { | ||
if (!options.contentFactory) { | ||
options.contentFactory = this; | ||
} | ||
return new cells_1.CodeCell(options); | ||
}; | ||
/** | ||
* The foreign handler for a console widget. | ||
* Create a new raw cell widget. | ||
* | ||
* #### Notes | ||
* If no cell content factory is passed in with the options, the one on the | ||
* notebook content factory is used. | ||
*/ | ||
ContentFactory.prototype.createForeignHandler = function (options) { | ||
return new foreign_1.ForeignHandler(options); | ||
ContentFactory.prototype.createRawCell = function (options) { | ||
if (!options.contentFactory) { | ||
options.contentFactory = this; | ||
} | ||
return new cells_1.RawCell(options); | ||
}; | ||
/** | ||
* Create a new banner widget. | ||
*/ | ||
ContentFactory.prototype.createBanner = function (options, parent) { | ||
return new cells_1.RawCellWidget(options); | ||
}; | ||
/** | ||
* Create a new prompt widget. | ||
*/ | ||
ContentFactory.prototype.createPrompt = function (options, parent) { | ||
return new cells_1.CodeCellWidget(options); | ||
}; | ||
/** | ||
* Create a new code cell widget for an input from a foreign session. | ||
*/ | ||
ContentFactory.prototype.createForeignCell = function (options, parent) { | ||
return new cells_1.CodeCellWidget(options); | ||
}; | ||
return ContentFactory; | ||
}()); | ||
}(cells_1.Cell.ContentFactory)); | ||
CodeConsole.ContentFactory = ContentFactory; | ||
/** | ||
* A default content factory for the code console. | ||
*/ | ||
CodeConsole.defaultContentFactory = new ContentFactory(); | ||
/** | ||
* The default implementation of an `IModelFactory`. | ||
@@ -602,2 +595,3 @@ */ | ||
function ModelFactory(options) { | ||
if (options === void 0) { options = {}; } | ||
this.codeCellContentFactory = (options.codeCellContentFactory || | ||
@@ -604,0 +598,0 @@ cells_1.CodeCellModel.defaultContentFactory); |
{ | ||
"name": "@jupyterlab/console", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"description": "JupyterLab - Code Console", | ||
@@ -16,9 +16,9 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@jupyterlab/apputils": "^0.3.1", | ||
"@jupyterlab/cells": "^0.3.2", | ||
"@jupyterlab/codeeditor": "^0.3.1", | ||
"@jupyterlab/coreutils": "^0.3.1", | ||
"@jupyterlab/outputarea": "^0.3.2", | ||
"@jupyterlab/rendermime": "^0.3.2", | ||
"@jupyterlab/services": "^0.42.1", | ||
"@jupyterlab/apputils": "^0.4.0", | ||
"@jupyterlab/cells": "^0.4.0", | ||
"@jupyterlab/codeeditor": "^0.4.0", | ||
"@jupyterlab/coreutils": "^0.4.0", | ||
"@jupyterlab/outputarea": "^0.4.0", | ||
"@jupyterlab/rendermime": "^0.4.0", | ||
"@jupyterlab/services": "^0.43.0", | ||
"@phosphor/algorithm": "^1.0.0", | ||
@@ -25,0 +25,0 @@ "@phosphor/coreutils": "^1.0.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67875
1993
+ Added@jupyterlab/application@0.4.0(transitive)
+ Added@jupyterlab/apputils@0.4.0(transitive)
+ Added@jupyterlab/cells@0.4.0(transitive)
+ Added@jupyterlab/codeeditor@0.4.0(transitive)
+ Added@jupyterlab/codemirror@0.4.0(transitive)
+ Added@jupyterlab/coreutils@0.4.0(transitive)
+ Added@jupyterlab/outputarea@0.4.0(transitive)
+ Added@jupyterlab/rendermime@0.4.0(transitive)
+ Added@jupyterlab/services@0.43.0(transitive)
- Removed@jupyterlab/application@0.3.1(transitive)
- Removed@jupyterlab/apputils@0.3.1(transitive)
- Removed@jupyterlab/cells@0.3.2(transitive)
- Removed@jupyterlab/codeeditor@0.3.1(transitive)
- Removed@jupyterlab/codemirror@0.3.1(transitive)
- Removed@jupyterlab/coreutils@0.3.1(transitive)
- Removed@jupyterlab/outputarea@0.3.2(transitive)
- Removed@jupyterlab/rendermime@0.3.2(transitive)
- Removed@jupyterlab/services@0.42.1(transitive)
Updated@jupyterlab/apputils@^0.4.0
Updated@jupyterlab/cells@^0.4.0
Updated@jupyterlab/coreutils@^0.4.0
Updated@jupyterlab/services@^0.43.0