@jupyterlab/codeeditor 4.0.0-alpha.2 → 4.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/editor.d.ts +50 -221
- package/lib/editor.js +26 -140
- package/lib/editor.js.map +1 -1
- package/lib/factory.d.ts +2 -2
- package/lib/index.d.ts +4 -2
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/jsoneditor.d.ts +5 -9
- package/lib/jsoneditor.js +41 -39
- package/lib/jsoneditor.js.map +1 -1
- package/lib/lineCol.d.ts +92 -0
- package/lib/lineCol.js +207 -0
- package/lib/lineCol.js.map +1 -0
- package/lib/tokens.d.ts +22 -0
- package/lib/tokens.js +4 -1
- package/lib/tokens.js.map +1 -1
- package/lib/viewer.d.ts +48 -0
- package/lib/viewer.js +45 -0
- package/lib/viewer.js.map +1 -0
- package/lib/widget.d.ts +5 -31
- package/lib/widget.js +6 -43
- package/lib/widget.js.map +1 -1
- package/package.json +22 -20
- package/src/editor.ts +560 -0
- package/src/factory.ts +19 -0
- package/src/index.ts +15 -0
- package/src/jsoneditor.ts +358 -0
- package/src/lineCol.tsx +381 -0
- package/src/mimetype.ts +43 -0
- package/src/tokens.ts +57 -0
- package/src/viewer.ts +93 -0
- package/src/widget.ts +289 -0
- package/style/base.css +2 -1
- package/style/index.css +1 -0
- package/style/index.js +1 -0
- package/style/linecol.css +79 -0
package/lib/index.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* @module codeeditor
|
|
6
6
|
*/
|
|
7
7
|
export * from './editor';
|
|
8
|
-
export * from './jsoneditor';
|
|
9
|
-
export * from './widget';
|
|
10
8
|
export * from './factory';
|
|
9
|
+
export * from './jsoneditor';
|
|
10
|
+
export * from './lineCol';
|
|
11
11
|
export * from './mimetype';
|
|
12
12
|
export * from './tokens';
|
|
13
|
+
export * from './viewer';
|
|
14
|
+
export * from './widget';
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
package/lib/jsoneditor.d.ts
CHANGED
|
@@ -44,6 +44,10 @@ export declare class JSONEditor extends Widget {
|
|
|
44
44
|
* Get whether the editor is dirty.
|
|
45
45
|
*/
|
|
46
46
|
get isDirty(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Dispose of the editor.
|
|
49
|
+
*/
|
|
50
|
+
dispose(): void;
|
|
47
51
|
/**
|
|
48
52
|
* Handle the DOM events for the widget.
|
|
49
53
|
*
|
|
@@ -59,14 +63,6 @@ export declare class JSONEditor extends Widget {
|
|
|
59
63
|
* Handle `after-attach` messages for the widget.
|
|
60
64
|
*/
|
|
61
65
|
protected onAfterAttach(msg: Message): void;
|
|
62
|
-
/**
|
|
63
|
-
* Handle `after-show` messages for the widget.
|
|
64
|
-
*/
|
|
65
|
-
protected onAfterShow(msg: Message): void;
|
|
66
|
-
/**
|
|
67
|
-
* Handle `update-request` messages for the widget.
|
|
68
|
-
*/
|
|
69
|
-
protected onUpdateRequest(msg: Message): void;
|
|
70
66
|
/**
|
|
71
67
|
* Handle `before-detach` messages for the widget.
|
|
72
68
|
*/
|
|
@@ -78,7 +74,7 @@ export declare class JSONEditor extends Widget {
|
|
|
78
74
|
/**
|
|
79
75
|
* Handle change events.
|
|
80
76
|
*/
|
|
81
|
-
private
|
|
77
|
+
private _onModelChanged;
|
|
82
78
|
/**
|
|
83
79
|
* Handle blur events for the text area.
|
|
84
80
|
*/
|
package/lib/jsoneditor.js
CHANGED
|
@@ -55,13 +55,16 @@ export class JSONEditor extends Widget {
|
|
|
55
55
|
this.headerNode.appendChild(this.commitButtonNode);
|
|
56
56
|
this.node.appendChild(this.headerNode);
|
|
57
57
|
this.node.appendChild(this.editorHostNode);
|
|
58
|
-
const model = new CodeEditor.Model();
|
|
59
|
-
model.
|
|
60
|
-
model.mimeType = 'application/json';
|
|
61
|
-
model.value.changed.connect(this._onValueChanged, this);
|
|
58
|
+
const model = new CodeEditor.Model({ mimeType: 'application/json' });
|
|
59
|
+
model.sharedModel.changed.connect(this._onModelChanged, this);
|
|
62
60
|
this.model = model;
|
|
63
|
-
this.editor = options.editorFactory({
|
|
64
|
-
|
|
61
|
+
this.editor = options.editorFactory({
|
|
62
|
+
host: this.editorHostNode,
|
|
63
|
+
model,
|
|
64
|
+
config: {
|
|
65
|
+
readOnly: true
|
|
66
|
+
}
|
|
67
|
+
});
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
70
|
* The observable source.
|
|
@@ -89,6 +92,19 @@ export class JSONEditor extends Widget {
|
|
|
89
92
|
get isDirty() {
|
|
90
93
|
return this._dataDirty || this._inputDirty;
|
|
91
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Dispose of the editor.
|
|
97
|
+
*/
|
|
98
|
+
dispose() {
|
|
99
|
+
var _a;
|
|
100
|
+
if (this.isDisposed) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
(_a = this.source) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
104
|
+
this.model.dispose();
|
|
105
|
+
this.editor.dispose();
|
|
106
|
+
super.dispose();
|
|
107
|
+
}
|
|
92
108
|
/**
|
|
93
109
|
* Handle the DOM events for the widget.
|
|
94
110
|
*
|
|
@@ -121,21 +137,6 @@ export class JSONEditor extends Widget {
|
|
|
121
137
|
this.revertButtonNode.hidden = true;
|
|
122
138
|
this.commitButtonNode.hidden = true;
|
|
123
139
|
this.headerNode.addEventListener('click', this);
|
|
124
|
-
if (this.isVisible) {
|
|
125
|
-
this.update();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Handle `after-show` messages for the widget.
|
|
130
|
-
*/
|
|
131
|
-
onAfterShow(msg) {
|
|
132
|
-
this.update();
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Handle `update-request` messages for the widget.
|
|
136
|
-
*/
|
|
137
|
-
onUpdateRequest(msg) {
|
|
138
|
-
this.editor.refresh();
|
|
139
140
|
}
|
|
140
141
|
/**
|
|
141
142
|
* Handle `before-detach` messages for the widget.
|
|
@@ -162,21 +163,23 @@ export class JSONEditor extends Widget {
|
|
|
162
163
|
/**
|
|
163
164
|
* Handle change events.
|
|
164
165
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
166
|
+
_onModelChanged(model, change) {
|
|
167
|
+
if (change.sourceChange) {
|
|
168
|
+
let valid = true;
|
|
169
|
+
try {
|
|
170
|
+
const value = JSON.parse(this.editor.model.sharedModel.getSource());
|
|
171
|
+
this.removeClass(ERROR_CLASS);
|
|
172
|
+
this._inputDirty =
|
|
173
|
+
!this._changeGuard && !JSONExt.deepEqual(value, this._originalValue);
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
this.addClass(ERROR_CLASS);
|
|
177
|
+
this._inputDirty = true;
|
|
178
|
+
valid = false;
|
|
179
|
+
}
|
|
180
|
+
this.revertButtonNode.hidden = !this._inputDirty;
|
|
181
|
+
this.commitButtonNode.hidden = !valid || !this._inputDirty;
|
|
177
182
|
}
|
|
178
|
-
this.revertButtonNode.hidden = !this._inputDirty;
|
|
179
|
-
this.commitButtonNode.hidden = !valid || !this._inputDirty;
|
|
180
183
|
}
|
|
181
184
|
/**
|
|
182
185
|
* Handle blur events for the text area.
|
|
@@ -213,7 +216,7 @@ export class JSONEditor extends Widget {
|
|
|
213
216
|
_mergeContent() {
|
|
214
217
|
const model = this.editor.model;
|
|
215
218
|
const old = this._originalValue;
|
|
216
|
-
const user = JSON.parse(model.
|
|
219
|
+
const user = JSON.parse(model.sharedModel.getSource());
|
|
217
220
|
const source = this.source;
|
|
218
221
|
if (!source) {
|
|
219
222
|
return;
|
|
@@ -244,19 +247,18 @@ export class JSONEditor extends Widget {
|
|
|
244
247
|
const content = this._source ? this._source.toJSON() : {};
|
|
245
248
|
this._changeGuard = true;
|
|
246
249
|
if (content === void 0) {
|
|
247
|
-
model.
|
|
250
|
+
model.sharedModel.setSource(this._trans.__('No data!'));
|
|
248
251
|
this._originalValue = JSONExt.emptyObject;
|
|
249
252
|
}
|
|
250
253
|
else {
|
|
251
254
|
const value = JSON.stringify(content, null, 4);
|
|
252
|
-
model.
|
|
255
|
+
model.sharedModel.setSource(value);
|
|
253
256
|
this._originalValue = content;
|
|
254
257
|
// Move the cursor to within the brace.
|
|
255
258
|
if (value.length > 1 && value[0] === '{') {
|
|
256
259
|
this.editor.setCursorPosition({ line: 0, column: 1 });
|
|
257
260
|
}
|
|
258
261
|
}
|
|
259
|
-
this.editor.refresh();
|
|
260
262
|
this._changeGuard = false;
|
|
261
263
|
this.commitButtonNode.hidden = true;
|
|
262
264
|
this.revertButtonNode.hidden = true;
|
package/lib/jsoneditor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsoneditor.js","sourceRoot":"","sources":["../src/jsoneditor.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;
|
|
1
|
+
{"version":3,"file":"jsoneditor.js","sourceRoot":"","sources":["../src/jsonedit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,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,OAAO,KAAK,KAAK,CAAC,EAAE;YACtB,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;YACxD,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;SAC3C;aAAM;YACL,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAC/C,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACnC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;YAC9B,uCAAuC;YACvC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBACxC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;aACvD;SACF;QACD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC;QACpC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC;IACtC,CAAC;CASF"}
|
package/lib/lineCol.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
2
|
+
import { VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { CodeEditor } from './editor';
|
|
5
|
+
/**
|
|
6
|
+
* A namespace for LineColComponent.
|
|
7
|
+
*/
|
|
8
|
+
declare namespace LineColComponent {
|
|
9
|
+
/**
|
|
10
|
+
* Props for LineColComponent.
|
|
11
|
+
*/
|
|
12
|
+
interface IProps {
|
|
13
|
+
/**
|
|
14
|
+
* The current line number.
|
|
15
|
+
*/
|
|
16
|
+
line: number;
|
|
17
|
+
/**
|
|
18
|
+
* The current column number.
|
|
19
|
+
*/
|
|
20
|
+
column: number;
|
|
21
|
+
/**
|
|
22
|
+
* The application language translator.
|
|
23
|
+
*/
|
|
24
|
+
translator?: ITranslator;
|
|
25
|
+
/**
|
|
26
|
+
* A click handler for the LineColComponent, which
|
|
27
|
+
* we use to launch the LineFormComponent.
|
|
28
|
+
*/
|
|
29
|
+
handleClick: () => void;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A pure functional component for rendering a line/column
|
|
34
|
+
* status item.
|
|
35
|
+
*/
|
|
36
|
+
declare function LineColComponent(props: LineColComponent.IProps): React.ReactElement<LineColComponent.IProps>;
|
|
37
|
+
/**
|
|
38
|
+
* A widget implementing a line/column status item.
|
|
39
|
+
*/
|
|
40
|
+
export declare class LineCol extends VDomRenderer<LineCol.Model> {
|
|
41
|
+
/**
|
|
42
|
+
* Construct a new LineCol status item.
|
|
43
|
+
*/
|
|
44
|
+
constructor(translator?: ITranslator);
|
|
45
|
+
/**
|
|
46
|
+
* Render the status item.
|
|
47
|
+
*/
|
|
48
|
+
render(): React.ReactElement<LineColComponent.IProps> | null;
|
|
49
|
+
/**
|
|
50
|
+
* A click handler for the widget.
|
|
51
|
+
*/
|
|
52
|
+
private _handleClick;
|
|
53
|
+
/**
|
|
54
|
+
* Handle submission for the widget.
|
|
55
|
+
*/
|
|
56
|
+
private _handleSubmit;
|
|
57
|
+
protected translator: ITranslator;
|
|
58
|
+
private _popup;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A namespace for LineCol statics.
|
|
62
|
+
*/
|
|
63
|
+
export declare namespace LineCol {
|
|
64
|
+
/**
|
|
65
|
+
* A VDom model for a status item tracking the line/column of an editor.
|
|
66
|
+
*/
|
|
67
|
+
class Model extends VDomModel {
|
|
68
|
+
/**
|
|
69
|
+
* The current editor of the model.
|
|
70
|
+
*/
|
|
71
|
+
get editor(): CodeEditor.IEditor | null;
|
|
72
|
+
set editor(editor: CodeEditor.IEditor | null);
|
|
73
|
+
/**
|
|
74
|
+
* The current line of the model.
|
|
75
|
+
*/
|
|
76
|
+
get line(): number;
|
|
77
|
+
/**
|
|
78
|
+
* The current column of the model.
|
|
79
|
+
*/
|
|
80
|
+
get column(): number;
|
|
81
|
+
/**
|
|
82
|
+
* React to a change in the cursors of the current editor.
|
|
83
|
+
*/
|
|
84
|
+
private _onSelectionChanged;
|
|
85
|
+
private _getAllState;
|
|
86
|
+
private _triggerChange;
|
|
87
|
+
private _line;
|
|
88
|
+
private _column;
|
|
89
|
+
private _editor;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export {};
|
package/lib/lineCol.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { showPopup, TextItem } from '@jupyterlab/statusbar';
|
|
4
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
5
|
+
import { classes, lineFormIcon, ReactWidget, VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
/**
|
|
8
|
+
* A component for rendering a "go-to-line" form.
|
|
9
|
+
*/
|
|
10
|
+
class LineFormComponent extends React.Component {
|
|
11
|
+
/**
|
|
12
|
+
* Construct a new LineFormComponent.
|
|
13
|
+
*/
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
/**
|
|
17
|
+
* Handle a change to the value in the input field.
|
|
18
|
+
*/
|
|
19
|
+
this._handleChange = (event) => {
|
|
20
|
+
this.setState({ value: event.currentTarget.value });
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Handle submission of the input field.
|
|
24
|
+
*/
|
|
25
|
+
this._handleSubmit = (event) => {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
const value = parseInt(this._textInput.value, 10);
|
|
28
|
+
if (!isNaN(value) &&
|
|
29
|
+
isFinite(value) &&
|
|
30
|
+
1 <= value &&
|
|
31
|
+
value <= this.props.maxLine) {
|
|
32
|
+
this.props.handleSubmit(value);
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Handle focusing of the input field.
|
|
38
|
+
*/
|
|
39
|
+
this._handleFocus = () => {
|
|
40
|
+
this.setState({ hasFocus: true });
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Handle blurring of the input field.
|
|
44
|
+
*/
|
|
45
|
+
this._handleBlur = () => {
|
|
46
|
+
this.setState({ hasFocus: false });
|
|
47
|
+
};
|
|
48
|
+
this._textInput = null;
|
|
49
|
+
this.translator = props.translator || nullTranslator;
|
|
50
|
+
this._trans = this.translator.load('jupyterlab');
|
|
51
|
+
this.state = {
|
|
52
|
+
value: '',
|
|
53
|
+
hasFocus: false
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Focus the element on mount.
|
|
58
|
+
*/
|
|
59
|
+
componentDidMount() {
|
|
60
|
+
this._textInput.focus();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Render the LineFormComponent.
|
|
64
|
+
*/
|
|
65
|
+
render() {
|
|
66
|
+
return (React.createElement("div", { className: "jp-lineFormSearch" },
|
|
67
|
+
React.createElement("form", { name: "lineColumnForm", onSubmit: this._handleSubmit, noValidate: true },
|
|
68
|
+
React.createElement("div", { className: classes('jp-lineFormWrapper', 'lm-lineForm-wrapper', this.state.hasFocus ? 'jp-lineFormWrapperFocusWithin' : undefined) },
|
|
69
|
+
React.createElement("input", { type: "text", className: "jp-lineFormInput", onChange: this._handleChange, onFocus: this._handleFocus, onBlur: this._handleBlur, value: this.state.value, ref: input => {
|
|
70
|
+
this._textInput = input;
|
|
71
|
+
} }),
|
|
72
|
+
React.createElement("div", { className: "jp-baseLineForm jp-lineFormButtonContainer" },
|
|
73
|
+
React.createElement(lineFormIcon.react, { className: "jp-baseLineForm jp-lineFormButtonIcon", elementPosition: "center" }),
|
|
74
|
+
React.createElement("input", { type: "submit", className: "jp-baseLineForm jp-lineFormButton", value: "" }))),
|
|
75
|
+
React.createElement("label", { className: "jp-lineFormCaption" }, this._trans.__('Go to line number between 1 and %1', this.props.maxLine)))));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A pure functional component for rendering a line/column
|
|
80
|
+
* status item.
|
|
81
|
+
*/
|
|
82
|
+
function LineColComponent(props) {
|
|
83
|
+
const translator = props.translator || nullTranslator;
|
|
84
|
+
const trans = translator.load('jupyterlab');
|
|
85
|
+
return (React.createElement(TextItem, { onClick: props.handleClick, source: trans.__('Ln %1, Col %2', props.line, props.column), title: trans.__('Go to line number…') }));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A widget implementing a line/column status item.
|
|
89
|
+
*/
|
|
90
|
+
export class LineCol extends VDomRenderer {
|
|
91
|
+
/**
|
|
92
|
+
* Construct a new LineCol status item.
|
|
93
|
+
*/
|
|
94
|
+
constructor(translator) {
|
|
95
|
+
super(new LineCol.Model());
|
|
96
|
+
this._popup = null;
|
|
97
|
+
this.addClass('jp-mod-highlighted');
|
|
98
|
+
this.translator = translator || nullTranslator;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Render the status item.
|
|
102
|
+
*/
|
|
103
|
+
render() {
|
|
104
|
+
if (this.model === null) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
return (React.createElement(LineColComponent, { line: this.model.line, column: this.model.column, translator: this.translator, handleClick: () => this._handleClick() }));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A click handler for the widget.
|
|
113
|
+
*/
|
|
114
|
+
_handleClick() {
|
|
115
|
+
if (this._popup) {
|
|
116
|
+
this._popup.dispose();
|
|
117
|
+
}
|
|
118
|
+
const body = ReactWidget.create(React.createElement(LineFormComponent, { handleSubmit: val => this._handleSubmit(val), currentLine: this.model.line, maxLine: this.model.editor.lineCount, translator: this.translator }));
|
|
119
|
+
this._popup = showPopup({
|
|
120
|
+
body: body,
|
|
121
|
+
anchor: this,
|
|
122
|
+
align: 'right'
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Handle submission for the widget.
|
|
127
|
+
*/
|
|
128
|
+
_handleSubmit(value) {
|
|
129
|
+
this.model.editor.setCursorPosition({ line: value - 1, column: 0 });
|
|
130
|
+
this._popup.dispose();
|
|
131
|
+
this.model.editor.focus();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* A namespace for LineCol statics.
|
|
136
|
+
*/
|
|
137
|
+
(function (LineCol) {
|
|
138
|
+
/**
|
|
139
|
+
* A VDom model for a status item tracking the line/column of an editor.
|
|
140
|
+
*/
|
|
141
|
+
class Model extends VDomModel {
|
|
142
|
+
constructor() {
|
|
143
|
+
super(...arguments);
|
|
144
|
+
/**
|
|
145
|
+
* React to a change in the cursors of the current editor.
|
|
146
|
+
*/
|
|
147
|
+
this._onSelectionChanged = () => {
|
|
148
|
+
const oldState = this._getAllState();
|
|
149
|
+
const pos = this.editor.getCursorPosition();
|
|
150
|
+
this._line = pos.line + 1;
|
|
151
|
+
this._column = pos.column + 1;
|
|
152
|
+
this._triggerChange(oldState, this._getAllState());
|
|
153
|
+
};
|
|
154
|
+
this._line = 1;
|
|
155
|
+
this._column = 1;
|
|
156
|
+
this._editor = null;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The current editor of the model.
|
|
160
|
+
*/
|
|
161
|
+
get editor() {
|
|
162
|
+
return this._editor;
|
|
163
|
+
}
|
|
164
|
+
set editor(editor) {
|
|
165
|
+
var _a;
|
|
166
|
+
const oldEditor = this._editor;
|
|
167
|
+
if ((_a = oldEditor === null || oldEditor === void 0 ? void 0 : oldEditor.model) === null || _a === void 0 ? void 0 : _a.selections) {
|
|
168
|
+
oldEditor.model.selections.changed.disconnect(this._onSelectionChanged);
|
|
169
|
+
}
|
|
170
|
+
const oldState = this._getAllState();
|
|
171
|
+
this._editor = editor;
|
|
172
|
+
if (!this._editor) {
|
|
173
|
+
this._column = 1;
|
|
174
|
+
this._line = 1;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
this._editor.model.selections.changed.connect(this._onSelectionChanged);
|
|
178
|
+
const pos = this._editor.getCursorPosition();
|
|
179
|
+
this._column = pos.column + 1;
|
|
180
|
+
this._line = pos.line + 1;
|
|
181
|
+
}
|
|
182
|
+
this._triggerChange(oldState, this._getAllState());
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The current line of the model.
|
|
186
|
+
*/
|
|
187
|
+
get line() {
|
|
188
|
+
return this._line;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The current column of the model.
|
|
192
|
+
*/
|
|
193
|
+
get column() {
|
|
194
|
+
return this._column;
|
|
195
|
+
}
|
|
196
|
+
_getAllState() {
|
|
197
|
+
return [this._line, this._column];
|
|
198
|
+
}
|
|
199
|
+
_triggerChange(oldState, newState) {
|
|
200
|
+
if (oldState[0] !== newState[0] || oldState[1] !== newState[1]) {
|
|
201
|
+
this.stateChanged.emit(void 0);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
LineCol.Model = Model;
|
|
206
|
+
})(LineCol || (LineCol = {}));
|
|
207
|
+
//# sourceMappingURL=lineCol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineCol.js","sourceRoot":"","sources":["../src/lineCol.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAS,SAA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ED;;WAEG;QACH,IAAI,IAAI;YACN,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QAED;;WAEG;QACH,IAAI,MAAM;YACR,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;QAcO,YAAY;YAClB,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QAEO,cAAc,CACpB,QAA0B,EAC1B,QAA0B;YAE1B,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE;gBAC9D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;aAChC;QACH,CAAC;KAKF;IAvEY,aAAK,QAuEjB,CAAA;AACH,CAAC,EA5EgB,OAAO,KAAP,OAAO,QA4EvB"}
|
package/lib/tokens.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Token } from '@lumino/coreutils';
|
|
2
|
+
import { Widget } from '@lumino/widgets';
|
|
3
|
+
import { CodeEditor } from './editor';
|
|
2
4
|
import { IEditorFactoryService } from './factory';
|
|
3
5
|
import { IEditorMimeTypeService } from './mimetype';
|
|
4
6
|
/**
|
|
@@ -18,3 +20,23 @@ export interface IEditorServices {
|
|
|
18
20
|
*/
|
|
19
21
|
readonly mimeTypeService: IEditorMimeTypeService;
|
|
20
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Code editor cursor position token.
|
|
25
|
+
*/
|
|
26
|
+
export declare const IPositionModel: Token<IPositionModel>;
|
|
27
|
+
/**
|
|
28
|
+
* Code editor cursor position model.
|
|
29
|
+
*/
|
|
30
|
+
export interface IPositionModel {
|
|
31
|
+
/**
|
|
32
|
+
* Add a editor provider.
|
|
33
|
+
*
|
|
34
|
+
* A provider will receive the currently active widget and must return the
|
|
35
|
+
* associated editor if it can or null otherwise.
|
|
36
|
+
*/
|
|
37
|
+
addEditorProvider: (provider: (widget: Widget | null) => Promise<CodeEditor.IEditor | null>) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Callback to force updating the provider
|
|
40
|
+
*/
|
|
41
|
+
update(): void;
|
|
42
|
+
}
|
package/lib/tokens.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
import { Token } from '@lumino/coreutils';
|
|
4
|
-
/* tslint:disable */
|
|
5
4
|
/**
|
|
6
5
|
* Code editor services token.
|
|
7
6
|
*/
|
|
8
7
|
export const IEditorServices = new Token('@jupyterlab/codeeditor:IEditorServices');
|
|
8
|
+
/**
|
|
9
|
+
* Code editor cursor position token.
|
|
10
|
+
*/
|
|
11
|
+
export const IPositionModel = new Token('@jupyterlab/codeeditor:IPositionModel');
|
|
9
12
|
//# sourceMappingURL=tokens.js.map
|
package/lib/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAM1C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,KAAK,CACtC,wCAAwC,CACzC,CAAC;AAiBF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,KAAK,CACrC,uCAAuC,CACxC,CAAC"}
|
package/lib/viewer.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Widget } from '@lumino/widgets';
|
|
2
|
+
import { CodeEditor } from './editor';
|
|
3
|
+
export declare class CodeViewerWidget extends Widget {
|
|
4
|
+
/**
|
|
5
|
+
* Construct a new code viewer widget.
|
|
6
|
+
*/
|
|
7
|
+
constructor(options: CodeViewerWidget.IOptions);
|
|
8
|
+
static createCodeViewer(options: CodeViewerWidget.INoModelOptions): CodeViewerWidget;
|
|
9
|
+
get content(): string;
|
|
10
|
+
get mimeType(): string;
|
|
11
|
+
readonly model: CodeEditor.IModel;
|
|
12
|
+
readonly editor: CodeEditor.IEditor;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The namespace for code viewer widget.
|
|
16
|
+
*/
|
|
17
|
+
export declare namespace CodeViewerWidget {
|
|
18
|
+
/**
|
|
19
|
+
* The options used to create an code viewer widget.
|
|
20
|
+
*/
|
|
21
|
+
interface IOptions {
|
|
22
|
+
/**
|
|
23
|
+
* A code editor factory.
|
|
24
|
+
*/
|
|
25
|
+
factory: CodeEditor.Factory;
|
|
26
|
+
/**
|
|
27
|
+
* The content model for the viewer.
|
|
28
|
+
*/
|
|
29
|
+
model: CodeEditor.IModel;
|
|
30
|
+
/**
|
|
31
|
+
* Code editor options
|
|
32
|
+
*/
|
|
33
|
+
editorOptions?: Omit<CodeEditor.IOptions, 'host' | 'model'>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The options used to create an code viewer widget without a model.
|
|
37
|
+
*/
|
|
38
|
+
interface INoModelOptions extends Omit<IOptions, 'model'> {
|
|
39
|
+
/**
|
|
40
|
+
* The content to display in the viewer.
|
|
41
|
+
*/
|
|
42
|
+
content: string;
|
|
43
|
+
/**
|
|
44
|
+
* The mime type for the content.
|
|
45
|
+
*/
|
|
46
|
+
mimeType?: string;
|
|
47
|
+
}
|
|
48
|
+
}
|