@jupyterlab/outputarea
Advanced tools
Comparing version 0.17.0-1 to 0.17.1
@@ -11,1 +11,2 @@ "use strict"; | ||
__export(require("./widget")); | ||
//# sourceMappingURL=index.js.map |
@@ -324,1 +324,2 @@ "use strict"; | ||
})(OutputAreaModel = exports.OutputAreaModel || (exports.OutputAreaModel = {})); | ||
//# sourceMappingURL=model.js.map |
@@ -35,3 +35,3 @@ import { Message } from '@phosphor/messaging'; | ||
/** | ||
* Te rendermime instance used by the widget. | ||
* The rendermime instance used by the widget. | ||
*/ | ||
@@ -84,6 +84,2 @@ readonly rendermime: RenderMimeRegistry; | ||
/** | ||
* Adjust the model index to the widgets index (skipping stdin widgets). | ||
*/ | ||
private _modelToLayoutIndex; | ||
/** | ||
* Create an output item with a prompt and actual output | ||
@@ -157,3 +153,3 @@ */ | ||
*/ | ||
createStdin(options: Stdin.IOptions): Widget; | ||
createStdin(options: Stdin.IOptions): IStdin; | ||
} | ||
@@ -208,2 +204,6 @@ /** | ||
export interface IStdin extends Widget { | ||
/** | ||
* The stdin value. | ||
*/ | ||
readonly value: Promise<string>; | ||
} | ||
@@ -219,2 +219,6 @@ /** | ||
/** | ||
* The value of the widget. | ||
*/ | ||
readonly value: Promise<string>; | ||
/** | ||
* Handle the DOM events for the widget. | ||
@@ -244,2 +248,4 @@ * | ||
private _input; | ||
private _value; | ||
private _promise; | ||
} | ||
@@ -246,0 +252,0 @@ export declare namespace Stdin { |
@@ -5,2 +5,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const coreutils_1 = require("@phosphor/coreutils"); | ||
const signaling_1 = require("@phosphor/signaling"); | ||
@@ -50,6 +51,2 @@ const widgets_1 = require("@phosphor/widgets"); | ||
const STDIN_INPUT_CLASS = 'jp-Stdin-input'; | ||
/** | ||
* The class name added to stdin rendered text nodes. | ||
*/ | ||
const STDIN_RENDERED_CLASS = 'jp-Stdin-rendered'; | ||
/****************************************************************************** | ||
@@ -128,3 +125,3 @@ * OutputArea | ||
// API responses that contain a pager are special cased and their type | ||
// is overriden from 'execute_reply' to 'display_data' in order to | ||
// is overridden from 'execute_reply' to 'display_data' in order to | ||
// render output. | ||
@@ -221,7 +218,5 @@ let model = this.model; | ||
onModelChanged(sender, args) { | ||
let layoutIndex; | ||
switch (args.type) { | ||
case 'add': | ||
layoutIndex = this._modelToLayoutIndex(args.newIndex); | ||
this._insertOutput(layoutIndex, args.newValues[0]); | ||
this._insertOutput(args.newIndex, args.newValues[0]); | ||
this.outputLengthChanged.emit(this.model.length); | ||
@@ -237,4 +232,3 @@ break; | ||
case 'set': | ||
layoutIndex = this._modelToLayoutIndex(args.newIndex); | ||
this._setOutput(layoutIndex, args.newValues[0]); | ||
this._setOutput(args.newIndex, args.newValues[0]); | ||
this.outputLengthChanged.emit(this.model.length); | ||
@@ -308,2 +302,15 @@ break; | ||
layout.addWidget(panel); | ||
/** | ||
* Wait for the stdin to complete, add it to the model (so it persists) | ||
* and remove the stdin widget. | ||
*/ | ||
input.value.then(value => { | ||
// Use stdin as the stream so it does not get combined with stdout. | ||
this.model.add({ | ||
output_type: 'stream', | ||
name: 'stdin', | ||
text: value + '\n' | ||
}); | ||
panel.dispose(); | ||
}); | ||
} | ||
@@ -337,19 +344,2 @@ /** | ||
/** | ||
* Adjust the model index to the widgets index (skipping stdin widgets). | ||
*/ | ||
_modelToLayoutIndex(index) { | ||
let widgets = this.widgets; | ||
let modelOutputs = -1; | ||
let i; | ||
for (i = 0; i < widgets.length; i++) { | ||
if (!widgets[i].hasClass(OUTPUT_AREA_STDIN_ITEM_CLASS)) { | ||
modelOutputs++; | ||
if (modelOutputs === index) { | ||
break; | ||
} | ||
} | ||
} | ||
return i; | ||
} | ||
/** | ||
* Create an output item with a prompt and actual output | ||
@@ -514,2 +504,3 @@ */ | ||
this._input = null; | ||
this._promise = new coreutils_1.PromiseDelegate(); | ||
this.addClass(STDIN_CLASS); | ||
@@ -519,4 +510,11 @@ this._input = this.node.getElementsByTagName('input')[0]; | ||
this._future = options.future; | ||
this._value = options.prompt + ' '; | ||
} | ||
/** | ||
* The value of the widget. | ||
*/ | ||
get value() { | ||
return this._promise.promise.then(() => this._value); | ||
} | ||
/** | ||
* Handle the DOM events for the widget. | ||
@@ -539,11 +537,9 @@ * | ||
}); | ||
let rendered = document.createElement('span'); | ||
rendered.className = STDIN_RENDERED_CLASS; | ||
if (input.type === 'password') { | ||
rendered.textContent = Array(input.value.length + 1).join('·'); | ||
this._value += Array(input.value.length + 1).join('·'); | ||
} | ||
else { | ||
rendered.textContent = input.value; | ||
this._value += input.value; | ||
} | ||
input.parentElement.replaceChild(rendered, input); | ||
this._promise.resolve(void 0); | ||
} | ||
@@ -651,1 +647,2 @@ } | ||
})(Private || (Private = {})); | ||
//# sourceMappingURL=widget.js.map |
{ | ||
"name": "@jupyterlab/outputarea", | ||
"version": "0.17.0-1", | ||
"version": "0.17.1", | ||
"description": "JupyterLab - Notebook Output Area", | ||
@@ -33,8 +33,8 @@ "homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"dependencies": { | ||
"@jupyterlab/apputils": "^0.17.0-1", | ||
"@jupyterlab/coreutils": "^2.0.0-1", | ||
"@jupyterlab/observables": "^2.0.0-1", | ||
"@jupyterlab/rendermime": "^0.17.0-1", | ||
"@jupyterlab/rendermime-interfaces": "^1.1.0-1", | ||
"@jupyterlab/services": "^3.0.0-1", | ||
"@jupyterlab/apputils": "^0.17.1", | ||
"@jupyterlab/coreutils": "^2.0.1", | ||
"@jupyterlab/observables": "^2.0.1", | ||
"@jupyterlab/rendermime": "^0.17.1", | ||
"@jupyterlab/rendermime-interfaces": "^1.1.1", | ||
"@jupyterlab/services": "^3.0.1", | ||
"@phosphor/algorithm": "^1.1.2", | ||
@@ -41,0 +41,0 @@ "@phosphor/coreutils": "^1.3.0", |
Sorry, the diff of this file is not supported yet
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
1622
110393