Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jupyter-js-notebook

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jupyter-js-notebook - npm Package Compare versions

Comparing version 0.9.1 to 0.10.0

45

lib/cells/model.d.ts

@@ -1,2 +0,2 @@

import { IInputAreaModel } from '../input-area';
import { IInputAreaModel, IInputAreaOptions } from '../input-area';
import { IOutputAreaModel } from '../output-area';

@@ -18,2 +18,7 @@ import { IObservableList } from 'phosphor-observablelist';

/**
* The options for creating a cell.
*/
export interface ICellOptions extends IInputAreaOptions {
}
/**
* The definition of a model object for a base cell.

@@ -43,2 +48,5 @@ */

* The input area of the cell.
*
* #### Notes
* This is a read-only property.
*/

@@ -51,2 +59,6 @@ input: IInputAreaModel;

/**
* Whether the cell is read only.
*/
readOnly: boolean;
/**
* Select the cell model.

@@ -90,2 +102,6 @@ */

/**
* Construct a new base cell model.
*/
constructor(options?: ICellOptions);
/**
* A signal emitted when the state of the model changes.

@@ -100,26 +116,30 @@ */

* Get the input area model.
*/
input: IInputAreaModel;
/**
* Get the dirty state of the cell.
*
* #### Notes
* This is a pure delegate to the [[inputProperty]].
* This is a delegate to the dirty state of the [input].
*/
/**
* Set the input area model.
* Set the dirty state of the cell.
*
* #### Notes
* This is a pure delegate to the [[inputProperty]].
* This is a delegate to the dirty state of the [input].
*/
input: IInputAreaModel;
dirty: boolean;
/**
* Get the dirty state of the cell.
* Get the read only state of the cell.
*
* #### Notes
* This is a pure delegate to the dirty state of the [input].
* This is a delegate to the read only state of the [input].
*/
/**
* Set the dirty state of the cell.
* Set the read only state of the cell.
*
* #### Notes
* This is a pure delegate to the dirty state of the [input].
* This is a delegate to the read only state of the [input].
*/
dirty: boolean;
readOnly: boolean;
/**

@@ -143,6 +163,7 @@ * Select the cell model.

/**
* Get the output area model.
* Construct a new code cell model.
*/
constructor(options?: ICellOptions);
/**
* Set the output area model.
* Get the output area model.
*/

@@ -149,0 +170,0 @@ output: IOutputAreaModel;

@@ -9,2 +9,4 @@ // Copyright (c) Jupyter Development Team.

};
var input_area_1 = require('../input-area');
var output_area_1 = require('../output-area');
var phosphor_properties_1 = require('phosphor-properties');

@@ -16,3 +18,9 @@ var phosphor_signaling_1 = require('phosphor-signaling');

var BaseCellModel = (function () {
function BaseCellModel() {
/**
* Construct a new base cell model.
*/
function BaseCellModel(options) {
var input = new input_area_1.InputAreaModel(options);
Private.inputProperty.set(this, input);
input.stateChanged.connect(this._inputChanged, this);
}

@@ -42,18 +50,27 @@ Object.defineProperty(BaseCellModel.prototype, "stateChanged", {

* Get the input area model.
*/
get: function () {
return Private.inputProperty.get(this);
},
enumerable: true,
configurable: true
});
Object.defineProperty(BaseCellModel.prototype, "dirty", {
/**
* Get the dirty state of the cell.
*
* #### Notes
* This is a pure delegate to the [[inputProperty]].
* This is a delegate to the dirty state of the [input].
*/
get: function () {
return Private.inputProperty.get(this);
return this.input.dirty;
},
/**
* Set the input area model.
* Set the dirty state of the cell.
*
* #### Notes
* This is a pure delegate to the [[inputProperty]].
* This is a delegate to the dirty state of the [input].
*/
set: function (value) {
Private.inputProperty.set(this, value);
value.stateChanged.connect(this._inputChanged, this);
this.input.dirty = value;
},

@@ -63,20 +80,20 @@ enumerable: true,

});
Object.defineProperty(BaseCellModel.prototype, "dirty", {
Object.defineProperty(BaseCellModel.prototype, "readOnly", {
/**
* Get the dirty state of the cell.
* Get the read only state of the cell.
*
* #### Notes
* This is a pure delegate to the dirty state of the [input].
* This is a delegate to the read only state of the [input].
*/
get: function () {
return this.input.dirty;
return this.input.readOnly;
},
/**
* Set the dirty state of the cell.
* Set the read only state of the cell.
*
* #### Notes
* This is a pure delegate to the dirty state of the [input].
* This is a delegate to the read only state of the [input].
*/
set: function (value) {
this.input.dirty = value;
this.input.readOnly = value;
},

@@ -97,3 +114,3 @@ enumerable: true,

BaseCellModel.prototype._inputChanged = function (input, args) {
if (input === this.input && args.name === 'dirty') {
if (args.name === 'dirty' || args.name === 'readOnly') {
this.stateChanged.emit(args);

@@ -110,5 +127,9 @@ }

__extends(CodeCellModel, _super);
function CodeCellModel() {
_super.apply(this, arguments);
/**
* Construct a new code cell model.
*/
function CodeCellModel(options) {
_super.call(this, options);
this.type = "code";
Private.outputProperty.set(this, new output_area_1.OutputAreaModel());
}

@@ -122,8 +143,2 @@ Object.defineProperty(CodeCellModel.prototype, "output", {

},
/**
* Set the output area model.
*/
set: function (value) {
Private.outputProperty.set(this, value);
},
enumerable: true,

@@ -230,4 +245,2 @@ configurable: true

* A property descriptor holding the output area model.
*
* TODO: Do we need this execute signal?
*/

@@ -234,0 +247,0 @@ Private.outputProperty = new phosphor_properties_1.Property({

@@ -31,3 +31,3 @@ import { IChangedArgs } from 'phosphor-properties';

/**
* A flag to determine whether to allow editing.
* A property to determine whether to allow editing.
*/

@@ -96,6 +96,6 @@ readOnly?: boolean;

/**
* Get the readOnly flag for the editor model.
* Get the readOnly property for the editor model.
*/
/**
* Set the readOnly flag for the editor model.
* Set the readOnly property for the editor model.
*/

@@ -102,0 +102,0 @@ readOnly: boolean;

@@ -119,3 +119,3 @@ // Copyright (c) Jupyter Development Team.

/**
* Get the readOnly flag for the editor model.
* Get the readOnly property for the editor model.
*/

@@ -126,3 +126,3 @@ get: function () {

/**
* Set the readOnly flag for the editor model.
* Set the readOnly property for the editor model.
*/

@@ -218,7 +218,7 @@ set: function (value) {

name: 'lineNumbers',
value: true,
value: false,
notify: EditorModelPrivate.stateChangedSignal
});
/**
* The property descriptor for the editor readOnly flag.
* The property descriptor for the editor readOnly property.
*/

@@ -225,0 +225,0 @@ EditorModelPrivate.readOnlyProperty = new phosphor_properties_1.Property({

@@ -47,3 +47,3 @@ import 'codemirror/mode/meta';

/**
* A flag to determine whether to allow editing.
* A property to determine whether to allow editing.
*/

@@ -158,3 +158,2 @@ readOnly: boolean;

private _dirty;
private _initialized;
}

@@ -39,3 +39,2 @@ // Copyright (c) Jupyter Development Team.

this._dirty = false;
this._initialized = false;
this.addClass(CODEMIRROR_CLASS);

@@ -78,10 +77,5 @@ this._editor = CodeMirror(this.node);

this.updateText(value.text);
this._editor.on('change', function (instance, change) {
_this._model.text = _this._editor.getDoc().getValue();
if (!_this._initialized) {
_this._initialized = true;
}
else {
_this._model.dirty = true;
}
CodeMirror.on(this._editor.getDoc(), 'change', function (instance, change) {
_this._model.text = instance.getValue();
_this._model.dirty = true;
});

@@ -160,3 +154,8 @@ value.stateChanged.connect(this.onModelStateChanged, this);

CodeMirrorWidget.prototype.updateReadOnly = function (readOnly) {
this._editor.setOption('readOnly', readOnly);
if (readOnly) {
this._editor.setOption('readOnly', 'nocursor');
}
else {
this._editor.setOption('readOnly', false);
}
};

@@ -163,0 +162,0 @@ /**

import { IChangedArgs } from 'phosphor-properties';
import { ISignal } from 'phosphor-signaling';
import { IEditorModel, EditorModel } from '../editor';
import { IEditorModel, IEditorOptions, EditorModel } from '../editor';
/**

@@ -34,4 +34,13 @@ * The model for an input area.

dirty: boolean;
/**
* The read only state of the input cell.
*/
readOnly: boolean;
}
/**
* The options for creating an input area.
*/
export interface IInputAreaOptions extends IEditorOptions {
}
/**
* An implementation of an input area model.

@@ -41,2 +50,6 @@ */

/**
* Construct a new input area model.
*/
constructor(options?: IInputAreaOptions);
/**
* A signal emitted when the state of the model changes.

@@ -68,6 +81,6 @@ */

* Get the text editor Model.
*
* #### Notes
* This is a read-only property.
*/
/**
* Set the text editor Model.
*/
textEditor: EditorModel;

@@ -88,2 +101,9 @@ /**

/**
* Get the read only state.
*/
/**
* Set the read only state.
*/
readOnly: boolean;
/**
* Re-emit changes to the text editor dirty state.

@@ -90,0 +110,0 @@ */

@@ -6,2 +6,3 @@ // Copyright (c) Jupyter Development Team.

var phosphor_signaling_1 = require('phosphor-signaling');
var editor_1 = require('../editor');
/**

@@ -11,3 +12,9 @@ * An implementation of an input area model.

var InputAreaModel = (function () {
function InputAreaModel() {
/**
* Construct a new input area model.
*/
function InputAreaModel(options) {
var editor = new editor_1.EditorModel(options);
InputAreaModelPrivate.textEditorProperty.set(this, editor);
editor.stateChanged.connect(this._textEditorChanged, this);
}

@@ -75,2 +82,5 @@ Object.defineProperty(InputAreaModel.prototype, "stateChanged", {

* Get the text editor Model.
*
* #### Notes
* This is a read-only property.
*/

@@ -80,9 +90,2 @@ get: function () {

},
/**
* Set the text editor Model.
*/
set: function (value) {
InputAreaModelPrivate.textEditorProperty.set(this, value);
value.stateChanged.connect(this._textEditorChanged, this);
},
enumerable: true,

@@ -113,2 +116,18 @@ configurable: true

});
Object.defineProperty(InputAreaModel.prototype, "readOnly", {
/**
* Get the read only state.
*/
get: function () {
return this.textEditor.readOnly;
},
/**
* Set the read only state.
*/
set: function (value) {
this.textEditor.readOnly = value;
},
enumerable: true,
configurable: true
});
/**

@@ -132,4 +151,2 @@ * Re-emit changes to the text editor dirty state.

* A signal emitted when the state of the model changes.
*
* **See also:** [[stateChanged]]
*/

@@ -139,4 +156,2 @@ InputAreaModelPrivate.stateChangedSignal = new phosphor_signaling_1.Signal();

* A property descriptor which determines whether the input area is collapsed or displayed.
*
* **See also:** [[collapsed]]
*/

@@ -149,4 +164,2 @@ InputAreaModelPrivate.collapsedProperty = new phosphor_properties_1.Property({

* A property descriptor containing the prompt number.
*
* **See also:** [[promptNumber]]
*/

@@ -159,4 +172,2 @@ InputAreaModelPrivate.promptNumberProperty = new phosphor_properties_1.Property({

* A property descriptor containing the execution count of the input area.
*
* **See also:** [[executionCount]]
*/

@@ -169,4 +180,2 @@ InputAreaModelPrivate.executionCountProperty = new phosphor_properties_1.Property({

* A property descriptor containing the text editor Model.
*
* **See also:** [[textEditor]]
*/

@@ -173,0 +182,0 @@ InputAreaModelPrivate.textEditorProperty = new phosphor_properties_1.Property({

@@ -1,8 +0,12 @@

// IPython mode is just a slightly altered Python Mode with `?` being an
// operator. Here we define `ipython` mode in the require `python`
// callback to auto-load python mode.
"use strict";
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
'use strict';
var CodeMirror = require('codemirror');
require('codemirror/mode/python/python');
CodeMirror.defineMode("ipython", function (config, modeOptions) {
/**
* Define an IPython codemirror mode.
*
* It is a slightly altered Python Mode with a `?` operator.
*/
CodeMirror.defineMode('ipython', function (config, modeOptions) {
var pythonConf = {};

@@ -15,11 +19,11 @@ for (var prop in modeOptions) {

pythonConf.name = 'python';
pythonConf.singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\\?]");
pythonConf.singleOperators = new RegExp('^[\\+\\-\\*/%&|\\^~<>!\\?]');
if (pythonConf.version === 3) {
pythonConf.identifiers = new RegExp("^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*");
pythonConf.identifiers = new RegExp('^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*');
}
else if (pythonConf.version === 2) {
pythonConf.identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
pythonConf.identifiers = new RegExp('^[_A-Za-z][_A-Za-z0-9]*');
}
return CodeMirror.getMode(config, pythonConf);
}, 'python');
CodeMirror.defineMIME("text/x-ipython", "ipython");
});
CodeMirror.defineMIME('text/x-ipython', 'ipython');

@@ -1,9 +0,4 @@

// IPython GFM (GitHub Flavored Markdown) mode is just a slightly altered GFM
// Mode with support for latex.
//
// Latex support was supported by Codemirror GFM as of
// https://github.com/codemirror/CodeMirror/pull/567
// But was later removed in
// https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c
"use strict";
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
'use strict';
var CodeMirror = require('codemirror');

@@ -13,24 +8,33 @@ require('codemirror/mode/stex/stex');

require('codemirror/addon/mode/multiplex');
CodeMirror.defineMode("ipythongfm", function (config, modeOptions) {
var gfm_mode = CodeMirror.getMode(config, "gfm");
var tex_mode = CodeMirror.getMode(config, "stex");
/**
* Define an IPython GFM (GitHub Flavored Markdown) mode.
*
* Is just a slightly altered GFM Mode with support for latex.
* Latex support was supported by Codemirror GFM as of
* https://github.com/codemirror/CodeMirror/pull/567
* But was later removed in
* https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c
*/
CodeMirror.defineMode('ipythongfm', function (config, modeOptions) {
var gfm_mode = CodeMirror.getMode(config, 'gfm');
var tex_mode = CodeMirror.getMode(config, 'stex');
return CodeMirror.multiplexingMode(gfm_mode, {
open: "$", close: "$",
open: '$', close: '$',
mode: tex_mode,
delimStyle: "delimit"
delimStyle: 'delimit'
}, {
// not sure this works as $$ is interpreted at (opening $, closing $, as defined just above)
open: "$$", close: "$$",
open: '$$', close: '$$',
mode: tex_mode,
delimStyle: "delimit"
delimStyle: 'delimit'
}, {
open: "\\(", close: "\\)",
open: '\\(', close: '\\)',
mode: tex_mode,
delimStyle: "delimit"
delimStyle: 'delimit'
}, {
open: "\\[", close: "\\]",
open: '\\[', close: '\\]',
mode: tex_mode,
delimStyle: "delimit"
delimStyle: 'delimit'
});
}, 'gfm');
CodeMirror.defineMIME("text/x-ipythongfm", "ipythongfm");
});
CodeMirror.defineMIME('text/x-ipythongfm', 'ipythongfm');

@@ -6,5 +6,2 @@ "use strict";

var cells_1 = require('../cells');
var editor_1 = require('../editor');
var input_area_1 = require('../input-area');
var output_area_1 = require('../output-area');
var serialize_1 = require('./serialize');

@@ -91,4 +88,3 @@ /**

for (var i = 0; i < cells.length; i++) {
var cell = cells.get(i);
cell.input.textEditor.readOnly = value;
cells.get(i).readOnly = value;
}

@@ -194,13 +190,6 @@ },

NotebookModel.prototype.createCodeCell = function (source) {
var input = new input_area_1.InputAreaModel();
input.textEditor = new editor_1.EditorModel({
lineNumbers: false,
mimetype: this.defaultMimetype
return new cells_1.CodeCellModel({
mimetype: this.defaultMimetype,
readOnly: this.readOnly
});
var cell = new cells_1.CodeCellModel();
cell.input = input;
var outputArea = new output_area_1.OutputAreaModel();
cell.output = outputArea;
cell.input.textEditor.readOnly = this.readOnly;
return cell;
};

@@ -211,8 +200,6 @@ /**

NotebookModel.prototype.createMarkdownCell = function (source) {
var input = new input_area_1.InputAreaModel();
input.textEditor = new editor_1.EditorModel({ lineNumbers: false });
var cell = new cells_1.MarkdownCellModel();
cell.input = input;
cell.input.textEditor.readOnly = this.readOnly;
return cell;
return new cells_1.MarkdownCellModel({
mimetype: 'text/x-ipythongfm',
readOnly: this.readOnly
});
};

@@ -219,0 +206,0 @@ /**

@@ -72,3 +72,3 @@ // Copyright (c) Jupyter Development Team.

var m = msg.content;
var type = msg.header.msg_type;
m.output_type = msg.header.msg_type;
return buildOutputModel(m);

@@ -75,0 +75,0 @@ }

import { IChangedArgs } from 'phosphor-properties';
import { Widget } from 'phosphor-widget';
import { Panel } from 'phosphor-panel';

@@ -15,3 +16,3 @@ import { IOutputAreaModel, OutputModel } from './model';

*/
renderItem(output: OutputModel): Promise<HTMLElement>;
renderItem(widget: Widget, output: OutputModel): Promise<void>;
/**

@@ -18,0 +19,0 @@ * Change handler for model state changes.

@@ -53,5 +53,3 @@ // Copyright (c) Jupyter Development Team.

var w = new phosphor_widget_1.Widget();
_this.renderItem(out).then(function (out) {
w.node.appendChild(out);
});
_this.renderItem(w, out);
return w;

@@ -63,13 +61,22 @@ });

*/
OutputAreaWidget.prototype.renderItem = function (output) {
OutputAreaWidget.prototype.renderItem = function (widget, output) {
var bundle;
widget.addClass('jp-OutputArea-Output');
switch (output.outputType) {
case "execute_result":
bundle = output.data;
widget.addClass('jp-OutputArea-ExecuteResult');
break;
case "display_data":
bundle = output.data;
widget.addClass('jp-OutputArea-DisplayData');
break;
case "stream":
bundle = { 'jupyter/console-text': output.text };
if (output.name == 'stdout') {
widget.addClass('jp-OutputArea-Stdout');
}
else {
widget.addClass('jp-OutputArea-Stderr');
}
break;

@@ -79,2 +86,3 @@ case "error":

bundle = { 'jupyter/console-text': out.traceback || out.ename + ": " + out.evalue };
widget.addClass('jp-OutputArea-Error');
break;

@@ -85,4 +93,5 @@ default:

}
return (transform.transform(bundle, document)
.then(function (result) { return result.el; }));
return (transform.transform(bundle, document).then(function (result) {
widget.node.appendChild(result.el);
}));
};

@@ -89,0 +98,0 @@ /**

{
"name": "jupyter-js-notebook",
"version": "0.9.1",
"version": "0.10.0",
"description": "Notebook widget for Jupyter",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc