@jupyterlab/codeeditor
Advanced tools
Comparing version 0.16.2 to 0.17.0-0
@@ -183,3 +183,3 @@ import { JSONObject } from '@phosphor/coreutils'; | ||
dispose(): void; | ||
private _onMimeTypeChanged(mimeType, args); | ||
private _onMimeTypeChanged; | ||
private _isDisposed; | ||
@@ -415,2 +415,14 @@ private _mimeTypeChanged; | ||
/** | ||
* User preferred font family for text editors. | ||
*/ | ||
fontFamily: string | null; | ||
/** | ||
* User preferred size in pixel of the font used in text editors. | ||
*/ | ||
fontSize: number | null; | ||
/** | ||
* User preferred text line height, as a multiplier of font size. | ||
*/ | ||
lineHeight: number | null; | ||
/** | ||
* Whether line numbers should be displayed. | ||
@@ -417,0 +429,0 @@ */ |
@@ -5,4 +5,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var signaling_1 = require("@phosphor/signaling"); | ||
var observables_1 = require("@jupyterlab/observables"); | ||
const signaling_1 = require("@phosphor/signaling"); | ||
const observables_1 = require("@jupyterlab/observables"); | ||
/** | ||
@@ -29,7 +29,7 @@ * A namespace for code editors. | ||
*/ | ||
var Model = /** @class */ (function () { | ||
class Model { | ||
/** | ||
* Construct a new Model. | ||
*/ | ||
function Model(options) { | ||
constructor(options) { | ||
this._isDisposed = false; | ||
@@ -44,5 +44,5 @@ this._mimeTypeChanged = new signaling_1.Signal(this); | ||
} | ||
var value = this.modelDB.createString('value'); | ||
let value = this.modelDB.createString('value'); | ||
value.text = value.text || options.value || ''; | ||
var mimeType = this.modelDB.createValue('mimeType'); | ||
let mimeType = this.modelDB.createValue('mimeType'); | ||
mimeType.set(options.mimeType || 'text/plain'); | ||
@@ -52,63 +52,43 @@ mimeType.changed.connect(this._onMimeTypeChanged, this); | ||
} | ||
Object.defineProperty(Model.prototype, "mimeTypeChanged", { | ||
/** | ||
* A signal emitted when a mimetype changes. | ||
*/ | ||
get: function () { | ||
return this._mimeTypeChanged; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Model.prototype, "value", { | ||
/** | ||
* Get the value of the model. | ||
*/ | ||
get: function () { | ||
return this.modelDB.get('value'); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Model.prototype, "selections", { | ||
/** | ||
* Get the selections for the model. | ||
*/ | ||
get: function () { | ||
return this.modelDB.get('selections'); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Model.prototype, "mimeType", { | ||
/** | ||
* A mime type of the model. | ||
*/ | ||
get: function () { | ||
return this.modelDB.getValue('mimeType'); | ||
}, | ||
set: function (newValue) { | ||
var oldValue = this.mimeType; | ||
if (oldValue === newValue) { | ||
return; | ||
} | ||
this.modelDB.setValue('mimeType', newValue); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Model.prototype, "isDisposed", { | ||
/** | ||
* Whether the model is disposed. | ||
*/ | ||
get: function () { | ||
return this._isDisposed; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* A signal emitted when a mimetype changes. | ||
*/ | ||
get mimeTypeChanged() { | ||
return this._mimeTypeChanged; | ||
} | ||
/** | ||
* Get the value of the model. | ||
*/ | ||
get value() { | ||
return this.modelDB.get('value'); | ||
} | ||
/** | ||
* Get the selections for the model. | ||
*/ | ||
get selections() { | ||
return this.modelDB.get('selections'); | ||
} | ||
/** | ||
* A mime type of the model. | ||
*/ | ||
get mimeType() { | ||
return this.modelDB.getValue('mimeType'); | ||
} | ||
set mimeType(newValue) { | ||
const oldValue = this.mimeType; | ||
if (oldValue === newValue) { | ||
return; | ||
} | ||
this.modelDB.setValue('mimeType', newValue); | ||
} | ||
/** | ||
* Whether the model is disposed. | ||
*/ | ||
get isDisposed() { | ||
return this._isDisposed; | ||
} | ||
/** | ||
* Dipose of the resources used by the model. | ||
*/ | ||
Model.prototype.dispose = function () { | ||
dispose() { | ||
if (this._isDisposed) { | ||
@@ -119,4 +99,4 @@ return; | ||
signaling_1.Signal.clearData(this); | ||
}; | ||
Model.prototype._onMimeTypeChanged = function (mimeType, args) { | ||
} | ||
_onMimeTypeChanged(mimeType, args) { | ||
this._mimeTypeChanged.emit({ | ||
@@ -127,5 +107,4 @@ name: 'mimeType', | ||
}); | ||
}; | ||
return Model; | ||
}()); | ||
} | ||
} | ||
CodeEditor.Model = Model; | ||
@@ -136,2 +115,5 @@ /** | ||
CodeEditor.defaultConfig = { | ||
fontFamily: null, | ||
fontSize: null, | ||
lineHeight: null, | ||
lineNumbers: false, | ||
@@ -138,0 +120,0 @@ lineWrap: true, |
@@ -8,3 +8,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var coreutils_1 = require("@phosphor/coreutils"); | ||
const coreutils_1 = require("@phosphor/coreutils"); | ||
require("../style/index.css"); | ||
@@ -11,0 +11,0 @@ __export(require("./editor")); |
@@ -91,23 +91,23 @@ import { IObservableJSON } from '@jupyterlab/observables'; | ||
*/ | ||
private _onSourceChanged(sender, args); | ||
private _onSourceChanged; | ||
/** | ||
* Handle change events. | ||
*/ | ||
private _onValueChanged(); | ||
private _onValueChanged; | ||
/** | ||
* Handle blur events for the text area. | ||
*/ | ||
private _evtBlur(event); | ||
private _evtBlur; | ||
/** | ||
* Handle click events for the buttons. | ||
*/ | ||
private _evtClick(event); | ||
private _evtClick; | ||
/** | ||
* Merge the user content. | ||
*/ | ||
private _mergeContent(); | ||
private _mergeContent; | ||
/** | ||
* Set the value given the owner contents. | ||
*/ | ||
private _setValue(); | ||
private _setValue; | ||
private _dataDirty; | ||
@@ -114,0 +114,0 @@ private _inputDirty; |
"use strict"; | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var coreutils_1 = require("@phosphor/coreutils"); | ||
var widgets_1 = require("@phosphor/widgets"); | ||
var React = require("react"); | ||
var ReactDOM = require("react-dom"); | ||
var editor_1 = require("./editor"); | ||
const coreutils_1 = require("@phosphor/coreutils"); | ||
const widgets_1 = require("@phosphor/widgets"); | ||
const React = __importStar(require("react")); | ||
const ReactDOM = __importStar(require("react-dom")); | ||
const editor_1 = require("./editor"); | ||
/** | ||
* The class name added to a JSONEditor instance. | ||
*/ | ||
var JSONEDITOR_CLASS = 'jp-JSONEditor'; | ||
const JSONEDITOR_CLASS = 'jp-JSONEditor'; | ||
/** | ||
* The class name added when the Metadata editor contains invalid JSON. | ||
*/ | ||
var ERROR_CLASS = 'jp-mod-error'; | ||
const ERROR_CLASS = 'jp-mod-error'; | ||
/** | ||
* The class name added to the editor host node. | ||
*/ | ||
var HOST_CLASS = 'jp-JSONEditor-host'; | ||
const HOST_CLASS = 'jp-JSONEditor-host'; | ||
/** | ||
* The class name added to the header area. | ||
*/ | ||
var HEADER_CLASS = 'jp-JSONEditor-header'; | ||
const HEADER_CLASS = 'jp-JSONEditor-header'; | ||
/** | ||
* The class name added to the title node. | ||
*/ | ||
var TITLE_CLASS = 'jp-JSONEditor-title'; | ||
const TITLE_CLASS = 'jp-JSONEditor-title'; | ||
/** | ||
* The class name added to the collapser node. | ||
*/ | ||
var COLLAPSER_CLASS = 'jp-JSONEditor-collapser'; | ||
const COLLAPSER_CLASS = 'jp-JSONEditor-collapser'; | ||
/** | ||
* The class name added to the collapser node that is enabled. | ||
*/ | ||
var COLLAPSE_ENABLED_CLASS = 'jp-mod-collapse-enabled'; | ||
const COLLAPSE_ENABLED_CLASS = 'jp-mod-collapse-enabled'; | ||
/** | ||
* The class name added to the revert button. | ||
*/ | ||
var REVERT_CLASS = 'jp-JSONEditor-revertButton'; | ||
const REVERT_CLASS = 'jp-JSONEditor-revertButton'; | ||
/** | ||
* The class name added to the commit button. | ||
*/ | ||
var COMMIT_CLASS = 'jp-JSONEditor-commitButton'; | ||
const COMMIT_CLASS = 'jp-JSONEditor-commitButton'; | ||
/** | ||
* The class name added to collapsed items. | ||
*/ | ||
var COLLAPSED_CLASS = 'jp-mod-collapsed'; | ||
const COLLAPSED_CLASS = 'jp-mod-collapsed'; | ||
/** | ||
* A widget for editing observable JSON. | ||
*/ | ||
var JSONEditor = /** @class */ (function (_super) { | ||
__extends(JSONEditor, _super); | ||
class JSONEditor extends widgets_1.Widget { | ||
/** | ||
* Construct a new JSON editor. | ||
*/ | ||
function JSONEditor(options) { | ||
var _this = _super.call(this) || this; | ||
_this._dataDirty = false; | ||
_this._inputDirty = false; | ||
_this._source = null; | ||
_this._originalValue = coreutils_1.JSONExt.emptyObject; | ||
_this._changeGuard = false; | ||
_this.addClass(JSONEDITOR_CLASS); | ||
ReactDOM.render(Private.createEditorContent(options), _this.node); | ||
var host = _this.editorHostNode; | ||
var model = new editor_1.CodeEditor.Model(); | ||
constructor(options) { | ||
super(); | ||
this._dataDirty = false; | ||
this._inputDirty = false; | ||
this._source = null; | ||
this._originalValue = coreutils_1.JSONExt.emptyObject; | ||
this._changeGuard = false; | ||
this.addClass(JSONEDITOR_CLASS); | ||
ReactDOM.render(Private.createEditorContent(options), this.node); | ||
let host = this.editorHostNode; | ||
let model = new editor_1.CodeEditor.Model(); | ||
model.value.text = 'No data!'; | ||
model.mimeType = 'application/json'; | ||
model.value.changed.connect(_this._onValueChanged, _this); | ||
_this.model = model; | ||
_this.editor = options.editorFactory({ host: host, model: model }); | ||
_this.editor.setOption('readOnly', true); | ||
_this.collapsible = !!options.collapsible; | ||
return _this; | ||
model.value.changed.connect(this._onValueChanged, this); | ||
this.model = model; | ||
this.editor = options.editorFactory({ host, model }); | ||
this.editor.setOption('readOnly', true); | ||
this.collapsible = !!options.collapsible; | ||
} | ||
Object.defineProperty(JSONEditor.prototype, "editorTitle", { | ||
/** | ||
* The title of the editor. | ||
*/ | ||
get: function () { | ||
return this.titleNode.textContent || ''; | ||
}, | ||
set: function (value) { | ||
this.titleNode.textContent = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(JSONEditor.prototype, "editorHostNode", { | ||
/** | ||
* Get the editor host node used by the JSON editor. | ||
*/ | ||
get: function () { | ||
return this.node.getElementsByClassName(HOST_CLASS)[0]; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(JSONEditor.prototype, "headerNode", { | ||
/** | ||
* Get the header node used by the JSON editor. | ||
*/ | ||
get: function () { | ||
return this.node.getElementsByClassName(HEADER_CLASS)[0]; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(JSONEditor.prototype, "titleNode", { | ||
/** | ||
* Get the title node used by the JSON editor. | ||
*/ | ||
get: function () { | ||
return this.node.getElementsByClassName(TITLE_CLASS)[0]; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(JSONEditor.prototype, "collapserNode", { | ||
/** | ||
* Get the collapser node used by the JSON editor. | ||
*/ | ||
get: function () { | ||
return this.node.getElementsByClassName(COLLAPSER_CLASS)[0]; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(JSONEditor.prototype, "revertButtonNode", { | ||
/** | ||
* Get the revert button used by the JSON editor. | ||
*/ | ||
get: function () { | ||
return this.node.getElementsByClassName(REVERT_CLASS)[0]; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(JSONEditor.prototype, "commitButtonNode", { | ||
/** | ||
* Get the commit button used by the JSON editor. | ||
*/ | ||
get: function () { | ||
return this.node.getElementsByClassName(COMMIT_CLASS)[0]; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(JSONEditor.prototype, "source", { | ||
/** | ||
* The observable source. | ||
*/ | ||
get: function () { | ||
return this._source; | ||
}, | ||
set: function (value) { | ||
if (this._source === value) { | ||
return; | ||
} | ||
if (this._source) { | ||
this._source.changed.disconnect(this._onSourceChanged, this); | ||
} | ||
this._source = value; | ||
this.editor.setOption('readOnly', value === null); | ||
if (value) { | ||
value.changed.connect(this._onSourceChanged, this); | ||
} | ||
this._setValue(); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(JSONEditor.prototype, "isDirty", { | ||
/** | ||
* Get whether the editor is dirty. | ||
*/ | ||
get: function () { | ||
return this._dataDirty || this._inputDirty; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* The title of the editor. | ||
*/ | ||
get editorTitle() { | ||
return this.titleNode.textContent || ''; | ||
} | ||
set editorTitle(value) { | ||
this.titleNode.textContent = value; | ||
} | ||
/** | ||
* Get the editor host node used by the JSON editor. | ||
*/ | ||
get editorHostNode() { | ||
return this.node.getElementsByClassName(HOST_CLASS)[0]; | ||
} | ||
/** | ||
* Get the header node used by the JSON editor. | ||
*/ | ||
get headerNode() { | ||
return this.node.getElementsByClassName(HEADER_CLASS)[0]; | ||
} | ||
/** | ||
* Get the title node used by the JSON editor. | ||
*/ | ||
get titleNode() { | ||
return this.node.getElementsByClassName(TITLE_CLASS)[0]; | ||
} | ||
/** | ||
* Get the collapser node used by the JSON editor. | ||
*/ | ||
get collapserNode() { | ||
return this.node.getElementsByClassName(COLLAPSER_CLASS)[0]; | ||
} | ||
/** | ||
* Get the revert button used by the JSON editor. | ||
*/ | ||
get revertButtonNode() { | ||
return this.node.getElementsByClassName(REVERT_CLASS)[0]; | ||
} | ||
/** | ||
* Get the commit button used by the JSON editor. | ||
*/ | ||
get commitButtonNode() { | ||
return this.node.getElementsByClassName(COMMIT_CLASS)[0]; | ||
} | ||
/** | ||
* The observable source. | ||
*/ | ||
get source() { | ||
return this._source; | ||
} | ||
set source(value) { | ||
if (this._source === value) { | ||
return; | ||
} | ||
if (this._source) { | ||
this._source.changed.disconnect(this._onSourceChanged, this); | ||
} | ||
this._source = value; | ||
this.editor.setOption('readOnly', value === null); | ||
if (value) { | ||
value.changed.connect(this._onSourceChanged, this); | ||
} | ||
this._setValue(); | ||
} | ||
/** | ||
* Get whether the editor is dirty. | ||
*/ | ||
get isDirty() { | ||
return this._dataDirty || this._inputDirty; | ||
} | ||
/** | ||
* Handle the DOM events for the widget. | ||
@@ -205,3 +164,3 @@ * | ||
*/ | ||
JSONEditor.prototype.handleEvent = function (event) { | ||
handleEvent(event) { | ||
switch (event.type) { | ||
@@ -217,8 +176,8 @@ case 'blur': | ||
} | ||
}; | ||
} | ||
/** | ||
* Handle `after-attach` messages for the widget. | ||
*/ | ||
JSONEditor.prototype.onAfterAttach = function (msg) { | ||
var node = this.editorHostNode; | ||
onAfterAttach(msg) { | ||
let node = this.editorHostNode; | ||
node.addEventListener('blur', this, true); | ||
@@ -232,28 +191,28 @@ node.addEventListener('click', this, true); | ||
} | ||
}; | ||
} | ||
/** | ||
* Handle `after-show` messages for the widget. | ||
*/ | ||
JSONEditor.prototype.onAfterShow = function (msg) { | ||
onAfterShow(msg) { | ||
this.update(); | ||
}; | ||
} | ||
/** | ||
* Handle `update-request` messages for the widget. | ||
*/ | ||
JSONEditor.prototype.onUpdateRequest = function (msg) { | ||
onUpdateRequest(msg) { | ||
this.editor.refresh(); | ||
}; | ||
} | ||
/** | ||
* Handle `before-detach` messages for the widget. | ||
*/ | ||
JSONEditor.prototype.onBeforeDetach = function (msg) { | ||
var node = this.editorHostNode; | ||
onBeforeDetach(msg) { | ||
let node = this.editorHostNode; | ||
node.removeEventListener('blur', this, true); | ||
node.removeEventListener('click', this, true); | ||
this.headerNode.removeEventListener('click', this); | ||
}; | ||
} | ||
/** | ||
* Handle a change to the metadata of the source. | ||
*/ | ||
JSONEditor.prototype._onSourceChanged = function (sender, args) { | ||
_onSourceChanged(sender, args) { | ||
if (this._changeGuard) { | ||
@@ -267,10 +226,10 @@ return; | ||
this._setValue(); | ||
}; | ||
} | ||
/** | ||
* Handle change events. | ||
*/ | ||
JSONEditor.prototype._onValueChanged = function () { | ||
var valid = true; | ||
_onValueChanged() { | ||
let valid = true; | ||
try { | ||
var value = JSON.parse(this.editor.model.value.text); | ||
let value = JSON.parse(this.editor.model.value.text); | ||
this.removeClass(ERROR_CLASS); | ||
@@ -286,7 +245,7 @@ this._inputDirty = (!this._changeGuard && !coreutils_1.JSONExt.deepEqual(value, this._originalValue)); | ||
this.commitButtonNode.hidden = !valid || !this._inputDirty; | ||
}; | ||
} | ||
/** | ||
* Handle blur events for the text area. | ||
*/ | ||
JSONEditor.prototype._evtBlur = function (event) { | ||
_evtBlur(event) { | ||
// Update the metadata if necessary. | ||
@@ -296,8 +255,8 @@ if (!this._inputDirty && this._dataDirty) { | ||
} | ||
}; | ||
} | ||
/** | ||
* Handle click events for the buttons. | ||
*/ | ||
JSONEditor.prototype._evtClick = function (event) { | ||
var target = event.target; | ||
_evtClick(event) { | ||
let target = event.target; | ||
switch (target) { | ||
@@ -318,3 +277,3 @@ case this.revertButtonNode: | ||
if (this.collapsible) { | ||
var collapser = this.collapserNode; | ||
let collapser = this.collapserNode; | ||
if (collapser.classList.contains(COLLAPSED_CLASS)) { | ||
@@ -336,12 +295,12 @@ collapser.classList.remove(COLLAPSED_CLASS); | ||
} | ||
}; | ||
} | ||
/** | ||
* Merge the user content. | ||
*/ | ||
JSONEditor.prototype._mergeContent = function () { | ||
var model = this.editor.model; | ||
var current = this._source ? this._source.toJSON() : {}; | ||
var old = this._originalValue; | ||
var user = JSON.parse(model.value.text); | ||
var source = this.source; | ||
_mergeContent() { | ||
let model = this.editor.model; | ||
let current = this._source ? this._source.toJSON() : {}; | ||
let old = this._originalValue; | ||
let user = JSON.parse(model.value.text); | ||
let source = this.source; | ||
if (!source) { | ||
@@ -351,3 +310,3 @@ return; | ||
// If it is in user and has changed from old, set in current. | ||
for (var key in user) { | ||
for (let key in user) { | ||
if (!coreutils_1.JSONExt.deepEqual(user[key], old[key] || null)) { | ||
@@ -358,3 +317,3 @@ current[key] = user[key]; | ||
// If it was in old and is not in user, remove from current. | ||
for (var key in old) { | ||
for (let key in old) { | ||
if (!(key in user)) { | ||
@@ -366,10 +325,10 @@ delete current[key]; | ||
// Set the values. | ||
for (var key in current) { | ||
for (let key in current) { | ||
source.set(key, current[key]); | ||
} | ||
}; | ||
} | ||
/** | ||
* Set the value given the owner contents. | ||
*/ | ||
JSONEditor.prototype._setValue = function () { | ||
_setValue() { | ||
this._dataDirty = false; | ||
@@ -380,4 +339,4 @@ this._inputDirty = false; | ||
this.removeClass(ERROR_CLASS); | ||
var model = this.editor.model; | ||
var content = this._source ? this._source.toJSON() : {}; | ||
let model = this.editor.model; | ||
let content = this._source ? this._source.toJSON() : {}; | ||
this._changeGuard = true; | ||
@@ -389,3 +348,3 @@ if (content === void 0) { | ||
else { | ||
var value = JSON.stringify(content, null, 4); | ||
let value = JSON.stringify(content, null, 4); | ||
model.value.text = value; | ||
@@ -402,5 +361,4 @@ this._originalValue = content; | ||
this.revertButtonNode.hidden = true; | ||
}; | ||
return JSONEditor; | ||
}(widgets_1.Widget)); | ||
} | ||
} | ||
exports.JSONEditor = JSONEditor; | ||
@@ -416,7 +374,7 @@ /** | ||
function createEditorContent(options) { | ||
var revertTitle = 'Revert changes to data'; | ||
var confirmTitle = 'Commit changes to data'; | ||
var title = options.title || ''; | ||
var collapseClass = options.collapsible ? | ||
COLLAPSER_CLASS + " " + COLLAPSE_ENABLED_CLASS : COLLAPSER_CLASS; | ||
const revertTitle = 'Revert changes to data'; | ||
const confirmTitle = 'Commit changes to data'; | ||
const title = options.title || ''; | ||
const collapseClass = options.collapsible ? | ||
`${COLLAPSER_CLASS} ${COLLAPSE_ENABLED_CLASS}` : COLLAPSER_CLASS; | ||
return (React.createElement(React.Fragment, null, | ||
@@ -423,0 +381,0 @@ React.createElement("div", { className: HEADER_CLASS }, |
@@ -47,3 +47,3 @@ import { Message } from '@phosphor/messaging'; | ||
*/ | ||
private _onSelectionsChanged(); | ||
private _onSelectionsChanged; | ||
} | ||
@@ -50,0 +50,0 @@ /** |
"use strict"; | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var widgets_1 = require("@phosphor/widgets"); | ||
const widgets_1 = require("@phosphor/widgets"); | ||
/** | ||
* The class name added to an editor widget that has a primary selection. | ||
*/ | ||
var HAS_SELECTION_CLASS = 'jp-mod-has-primary-selection'; | ||
const HAS_SELECTION_CLASS = 'jp-mod-has-primary-selection'; | ||
/** | ||
* A widget which hosts a code editor. | ||
*/ | ||
var CodeEditorWrapper = /** @class */ (function (_super) { | ||
__extends(CodeEditorWrapper, _super); | ||
class CodeEditorWrapper extends widgets_1.Widget { | ||
/** | ||
* Construct a new code editor widget. | ||
*/ | ||
function CodeEditorWrapper(options) { | ||
var _this = _super.call(this) || this; | ||
var editor = _this.editor = options.factory({ | ||
host: _this.node, | ||
constructor(options) { | ||
super(); | ||
const editor = this.editor = options.factory({ | ||
host: this.node, | ||
model: options.model, | ||
@@ -37,50 +26,45 @@ uuid: options.uuid, | ||
}); | ||
editor.model.selections.changed.connect(_this._onSelectionsChanged, _this); | ||
return _this; | ||
editor.model.selections.changed.connect(this._onSelectionsChanged, this); | ||
} | ||
Object.defineProperty(CodeEditorWrapper.prototype, "model", { | ||
/** | ||
* Get the model used by the widget. | ||
*/ | ||
get: function () { | ||
return this.editor.model; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* Get the model used by the widget. | ||
*/ | ||
get model() { | ||
return this.editor.model; | ||
} | ||
/** | ||
* Dispose of the resources held by the widget. | ||
*/ | ||
CodeEditorWrapper.prototype.dispose = function () { | ||
dispose() { | ||
if (this.isDisposed) { | ||
return; | ||
} | ||
_super.prototype.dispose.call(this); | ||
super.dispose(); | ||
this.editor.dispose(); | ||
}; | ||
} | ||
/** | ||
* Handle `'activate-request'` messages. | ||
*/ | ||
CodeEditorWrapper.prototype.onActivateRequest = function (msg) { | ||
onActivateRequest(msg) { | ||
this.editor.focus(); | ||
}; | ||
} | ||
/** | ||
* A message handler invoked on an `'after-attach'` message. | ||
*/ | ||
CodeEditorWrapper.prototype.onAfterAttach = function (msg) { | ||
_super.prototype.onAfterAttach.call(this, msg); | ||
onAfterAttach(msg) { | ||
super.onAfterAttach(msg); | ||
if (this.isVisible) { | ||
this.update(); | ||
} | ||
}; | ||
} | ||
/** | ||
* A message handler invoked on an `'after-show'` message. | ||
*/ | ||
CodeEditorWrapper.prototype.onAfterShow = function (msg) { | ||
onAfterShow(msg) { | ||
this.update(); | ||
}; | ||
} | ||
/** | ||
* A message handler invoked on a `'resize'` message. | ||
*/ | ||
CodeEditorWrapper.prototype.onResize = function (msg) { | ||
onResize(msg) { | ||
if (msg.width >= 0 && msg.height >= 0) { | ||
@@ -92,14 +76,14 @@ this.editor.setSize(msg); | ||
} | ||
}; | ||
} | ||
/** | ||
* A message handler invoked on an `'update-request'` message. | ||
*/ | ||
CodeEditorWrapper.prototype.onUpdateRequest = function (msg) { | ||
onUpdateRequest(msg) { | ||
this.editor.refresh(); | ||
}; | ||
} | ||
/** | ||
* Handle a change in model selections. | ||
*/ | ||
CodeEditorWrapper.prototype._onSelectionsChanged = function () { | ||
var _a = this.editor.getSelection(), start = _a.start, end = _a.end; | ||
_onSelectionsChanged() { | ||
const { start, end } = this.editor.getSelection(); | ||
if (start.column !== end.column || start.line !== end.line) { | ||
@@ -111,5 +95,4 @@ this.addClass(HAS_SELECTION_CLASS); | ||
} | ||
}; | ||
return CodeEditorWrapper; | ||
}(widgets_1.Widget)); | ||
} | ||
} | ||
exports.CodeEditorWrapper = CodeEditorWrapper; |
{ | ||
"name": "@jupyterlab/codeeditor", | ||
"version": "0.16.2", | ||
"version": "0.17.0-0", | ||
"description": "JupyterLab - Abstract Code Editor", | ||
@@ -30,7 +30,7 @@ "homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"prepublishOnly": "npm run build", | ||
"watch": "tsc -w" | ||
"watch": "tsc -w --listEmittedFiles" | ||
}, | ||
"dependencies": { | ||
"@jupyterlab/coreutils": "^1.1.3", | ||
"@jupyterlab/observables": "^1.0.10", | ||
"@jupyterlab/coreutils": "^2.0.0-0", | ||
"@jupyterlab/observables": "^2.0.0-0", | ||
"@phosphor/coreutils": "^1.3.0", | ||
@@ -40,10 +40,10 @@ "@phosphor/disposable": "^1.1.2", | ||
"@phosphor/signaling": "^1.2.2", | ||
"@phosphor/widgets": "^1.5.0", | ||
"react": "~16.2.0", | ||
"react-dom": "~16.2.0" | ||
"@phosphor/widgets": "^1.6.0", | ||
"react": "~16.4.0", | ||
"react-dom": "~16.4.0" | ||
}, | ||
"devDependencies": { | ||
"rimraf": "~2.6.2", | ||
"typescript": "~2.6.2" | ||
"typescript": "~2.9.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
92774
1485
+ Added@jupyterlab/coreutils@2.2.1(transitive)
+ Added@jupyterlab/observables@2.4.0(transitive)
+ Addedquerystringify@2.2.0(transitive)
+ Addedreact@16.4.2(transitive)
+ Addedreact-dom@16.4.2(transitive)
+ Addedurl-parse@1.4.7(transitive)
- Removed@jupyterlab/coreutils@1.1.3(transitive)
- Removed@jupyterlab/observables@1.0.10(transitive)
- Removedquerystringify@1.0.0(transitive)
- Removedreact@16.2.0(transitive)
- Removedreact-dom@16.2.1(transitive)
- Removedurl-parse@1.1.9(transitive)
Updated@phosphor/widgets@^1.6.0
Updatedreact@~16.4.0
Updatedreact-dom@~16.4.0