@jupyterlab/fileeditor 4.0.0-alpha.8 → 4.0.0-alpha.9
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/widget.d.ts +8 -35
- package/lib/widget.js +26 -103
- package/lib/widget.js.map +1 -1
- package/package.json +9 -9
package/lib/widget.d.ts
CHANGED
|
@@ -1,39 +1,7 @@
|
|
|
1
|
-
import { CodeEditor,
|
|
1
|
+
import { CodeEditor, IEditorMimeTypeService, IEditorServices } from '@jupyterlab/codeeditor';
|
|
2
2
|
import { ABCWidgetFactory, DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry';
|
|
3
3
|
import { Message } from '@lumino/messaging';
|
|
4
4
|
import { Widget } from '@lumino/widgets';
|
|
5
|
-
/**
|
|
6
|
-
* A code editor wrapper for the file editor.
|
|
7
|
-
*/
|
|
8
|
-
export declare class FileEditorCodeWrapper extends CodeEditorWrapper {
|
|
9
|
-
/**
|
|
10
|
-
* Construct a new editor widget.
|
|
11
|
-
*/
|
|
12
|
-
constructor(options: FileEditor.IOptions);
|
|
13
|
-
/**
|
|
14
|
-
* Get the context for the editor widget.
|
|
15
|
-
*/
|
|
16
|
-
get context(): DocumentRegistry.Context;
|
|
17
|
-
/**
|
|
18
|
-
* A promise that resolves when the file editor is ready.
|
|
19
|
-
*/
|
|
20
|
-
get ready(): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Handle actions that should be taken when the context is ready.
|
|
23
|
-
*/
|
|
24
|
-
private _onContextReady;
|
|
25
|
-
/**
|
|
26
|
-
* Handle a change in context model content.
|
|
27
|
-
*/
|
|
28
|
-
private _onContentChanged;
|
|
29
|
-
/**
|
|
30
|
-
* Handle a change to the collaborators on the model
|
|
31
|
-
* by updating UI elements associated with them.
|
|
32
|
-
*/
|
|
33
|
-
private _onCollaboratorsChanged;
|
|
34
|
-
protected _context: DocumentRegistry.Context;
|
|
35
|
-
private _ready;
|
|
36
|
-
}
|
|
37
5
|
/**
|
|
38
6
|
* A widget for editors.
|
|
39
7
|
*/
|
|
@@ -77,15 +45,20 @@ export declare class FileEditor extends Widget {
|
|
|
77
45
|
* Ensure that the widget has focus.
|
|
78
46
|
*/
|
|
79
47
|
private _ensureFocus;
|
|
48
|
+
/**
|
|
49
|
+
* Handle actions that should be taken when the context is ready.
|
|
50
|
+
*/
|
|
51
|
+
private _onContextReady;
|
|
80
52
|
/**
|
|
81
53
|
* Handle a change to the path.
|
|
82
54
|
*/
|
|
83
55
|
private _onPathChanged;
|
|
84
|
-
private editorWidget;
|
|
85
56
|
model: CodeEditor.IModel;
|
|
86
57
|
editor: CodeEditor.IEditor;
|
|
87
|
-
|
|
58
|
+
private _context;
|
|
59
|
+
private _editorWidget;
|
|
88
60
|
private _mimeTypeService;
|
|
61
|
+
private _ready;
|
|
89
62
|
}
|
|
90
63
|
/**
|
|
91
64
|
* The namespace for editor widget statics.
|
package/lib/widget.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import {
|
|
3
|
+
import { CodeEditorWrapper } from '@jupyterlab/codeeditor';
|
|
4
4
|
import { ABCWidgetFactory, DocumentWidget } from '@jupyterlab/docregistry';
|
|
5
5
|
import { textEditorIcon } from '@jupyterlab/ui-components';
|
|
6
6
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
@@ -13,105 +13,6 @@ const CODE_RUNNER = 'jpCodeRunner';
|
|
|
13
13
|
* The data attribute added to a widget that can undo.
|
|
14
14
|
*/
|
|
15
15
|
const UNDOER = 'jpUndoer';
|
|
16
|
-
/**
|
|
17
|
-
* A code editor wrapper for the file editor.
|
|
18
|
-
*/
|
|
19
|
-
export class FileEditorCodeWrapper extends CodeEditorWrapper {
|
|
20
|
-
/**
|
|
21
|
-
* Construct a new editor widget.
|
|
22
|
-
*/
|
|
23
|
-
constructor(options) {
|
|
24
|
-
super({
|
|
25
|
-
factory: options.factory,
|
|
26
|
-
model: options.context.model
|
|
27
|
-
});
|
|
28
|
-
this._ready = new PromiseDelegate();
|
|
29
|
-
const context = (this._context = options.context);
|
|
30
|
-
const editor = this.editor;
|
|
31
|
-
this.addClass('jp-FileEditorCodeWrapper');
|
|
32
|
-
this.node.dataset[CODE_RUNNER] = 'true';
|
|
33
|
-
this.node.dataset[UNDOER] = 'true';
|
|
34
|
-
editor.model.value.text = context.model.toString();
|
|
35
|
-
void context.ready.then(() => {
|
|
36
|
-
this._onContextReady();
|
|
37
|
-
});
|
|
38
|
-
if (context.model.modelDB.isCollaborative) {
|
|
39
|
-
const modelDB = context.model.modelDB;
|
|
40
|
-
void modelDB.connected.then(() => {
|
|
41
|
-
const collaborators = modelDB.collaborators;
|
|
42
|
-
if (!collaborators) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
// Setup the selection style for collaborators
|
|
46
|
-
const localCollaborator = collaborators.localCollaborator;
|
|
47
|
-
this.editor.uuid = localCollaborator.sessionId;
|
|
48
|
-
this.editor.selectionStyle = Object.assign(Object.assign({}, CodeEditor.defaultSelectionStyle), { color: localCollaborator.color });
|
|
49
|
-
collaborators.changed.connect(this._onCollaboratorsChanged, this);
|
|
50
|
-
// Trigger an initial onCollaboratorsChanged event.
|
|
51
|
-
this._onCollaboratorsChanged();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Get the context for the editor widget.
|
|
57
|
-
*/
|
|
58
|
-
get context() {
|
|
59
|
-
return this._context;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* A promise that resolves when the file editor is ready.
|
|
63
|
-
*/
|
|
64
|
-
get ready() {
|
|
65
|
-
return this._ready.promise;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Handle actions that should be taken when the context is ready.
|
|
69
|
-
*/
|
|
70
|
-
_onContextReady() {
|
|
71
|
-
if (this.isDisposed) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const contextModel = this._context.model;
|
|
75
|
-
const editor = this.editor;
|
|
76
|
-
const editorModel = editor.model;
|
|
77
|
-
// Set the editor model value.
|
|
78
|
-
editorModel.value.text = contextModel.toString();
|
|
79
|
-
// Prevent the initial loading from disk from being in the editor history.
|
|
80
|
-
editor.clearHistory();
|
|
81
|
-
// Wire signal connections.
|
|
82
|
-
contextModel.contentChanged.connect(this._onContentChanged, this);
|
|
83
|
-
// Resolve the ready promise.
|
|
84
|
-
this._ready.resolve(undefined);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Handle a change in context model content.
|
|
88
|
-
*/
|
|
89
|
-
_onContentChanged() {
|
|
90
|
-
const editorModel = this.editor.model;
|
|
91
|
-
const oldValue = editorModel.value.text;
|
|
92
|
-
const newValue = this._context.model.toString();
|
|
93
|
-
if (oldValue !== newValue) {
|
|
94
|
-
editorModel.value.text = newValue;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Handle a change to the collaborators on the model
|
|
99
|
-
* by updating UI elements associated with them.
|
|
100
|
-
*/
|
|
101
|
-
_onCollaboratorsChanged() {
|
|
102
|
-
// If there are selections corresponding to non-collaborators,
|
|
103
|
-
// they are stale and should be removed.
|
|
104
|
-
const collaborators = this._context.model.modelDB.collaborators;
|
|
105
|
-
if (!collaborators) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
for (const key of this.editor.model.selections.keys()) {
|
|
109
|
-
if (!collaborators.has(key)) {
|
|
110
|
-
this.editor.model.selections.delete(key);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
16
|
/**
|
|
116
17
|
* A widget for editors.
|
|
117
18
|
*/
|
|
@@ -121,12 +22,22 @@ export class FileEditor extends Widget {
|
|
|
121
22
|
*/
|
|
122
23
|
constructor(options) {
|
|
123
24
|
super();
|
|
25
|
+
this._ready = new PromiseDelegate();
|
|
124
26
|
this.addClass('jp-FileEditor');
|
|
125
27
|
const context = (this._context = options.context);
|
|
126
28
|
this._mimeTypeService = options.mimeTypeService;
|
|
127
|
-
const editorWidget = (this.
|
|
29
|
+
const editorWidget = (this._editorWidget = new CodeEditorWrapper({
|
|
30
|
+
factory: options.factory,
|
|
31
|
+
model: context.model
|
|
32
|
+
}));
|
|
33
|
+
this._editorWidget.addClass('jp-FileEditorCodeWrapper');
|
|
34
|
+
this._editorWidget.node.dataset[CODE_RUNNER] = 'true';
|
|
35
|
+
this._editorWidget.node.dataset[UNDOER] = 'true';
|
|
128
36
|
this.editor = editorWidget.editor;
|
|
129
37
|
this.model = editorWidget.model;
|
|
38
|
+
void context.ready.then(() => {
|
|
39
|
+
this._onContextReady();
|
|
40
|
+
});
|
|
130
41
|
// Listen for changes to the path.
|
|
131
42
|
context.pathChanged.connect(this._onPathChanged, this);
|
|
132
43
|
this._onPathChanged();
|
|
@@ -137,13 +48,13 @@ export class FileEditor extends Widget {
|
|
|
137
48
|
* Get the context for the editor widget.
|
|
138
49
|
*/
|
|
139
50
|
get context() {
|
|
140
|
-
return this.
|
|
51
|
+
return this._context;
|
|
141
52
|
}
|
|
142
53
|
/**
|
|
143
54
|
* A promise that resolves when the file editor is ready.
|
|
144
55
|
*/
|
|
145
56
|
get ready() {
|
|
146
|
-
return this.
|
|
57
|
+
return this.ready;
|
|
147
58
|
}
|
|
148
59
|
/**
|
|
149
60
|
* Handle the DOM events for the widget.
|
|
@@ -196,6 +107,18 @@ export class FileEditor extends Widget {
|
|
|
196
107
|
this.editor.focus();
|
|
197
108
|
}
|
|
198
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Handle actions that should be taken when the context is ready.
|
|
112
|
+
*/
|
|
113
|
+
_onContextReady() {
|
|
114
|
+
if (this.isDisposed) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// Prevent the initial loading from disk from being in the editor history.
|
|
118
|
+
this.editor.clearHistory();
|
|
119
|
+
// Resolve the ready promise.
|
|
120
|
+
this._ready.resolve(undefined);
|
|
121
|
+
}
|
|
199
122
|
/**
|
|
200
123
|
* Handle a change to the path.
|
|
201
124
|
*/
|
package/lib/widget.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,
|
|
1
|
+
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAEL,iBAAiB,EAGlB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAEhB,cAAc,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,GAAG,cAAc,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,GAAG,UAAU,CAAC;AAE1B;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,MAAM;IACpC;;OAEG;IACH,YAAY,OAA4B;QACtC,KAAK,EAAE,CAAC;QAkIF,WAAM,GAAG,IAAI,eAAe,EAAQ,CAAC;QAjI3C,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAE/B,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;QAEhD,MAAM,YAAY,GAAG,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,iBAAiB,CAAC;YAC/D,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,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AC;IAED;;OAEG;IACO,eAAe,CACvB,OAAqC;QAErC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,iBAAiB,CAAC;QAC7D,MAAM,OAAO,GAAuB,OAAO,CAAC,EAAE;YAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC;YAC7B,OAAO;YACP,OAAO;YACP,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe;SAChD,CAAC,CAAC;QAEH,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,cAAc,CAAC;QACpC,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC;IAChB,CAAC;CAGF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/fileeditor",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.9",
|
|
4
4
|
"description": "JupyterLab - Editor Widget",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -41,25 +41,25 @@
|
|
|
41
41
|
"watch": "tsc -b --watch"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@jupyterlab/apputils": "^4.0.0-alpha.
|
|
45
|
-
"@jupyterlab/codeeditor": "^4.0.0-alpha.
|
|
46
|
-
"@jupyterlab/docregistry": "^4.0.0-alpha.
|
|
47
|
-
"@jupyterlab/statusbar": "^4.0.0-alpha.
|
|
48
|
-
"@jupyterlab/translation": "^4.0.0-alpha.
|
|
49
|
-
"@jupyterlab/ui-components": "^4.0.0-alpha.
|
|
44
|
+
"@jupyterlab/apputils": "^4.0.0-alpha.9",
|
|
45
|
+
"@jupyterlab/codeeditor": "^4.0.0-alpha.9",
|
|
46
|
+
"@jupyterlab/docregistry": "^4.0.0-alpha.9",
|
|
47
|
+
"@jupyterlab/statusbar": "^4.0.0-alpha.9",
|
|
48
|
+
"@jupyterlab/translation": "^4.0.0-alpha.9",
|
|
49
|
+
"@jupyterlab/ui-components": "^4.0.0-alpha.24",
|
|
50
50
|
"@lumino/coreutils": "^1.12.0",
|
|
51
51
|
"@lumino/messaging": "^1.10.1",
|
|
52
52
|
"@lumino/widgets": "^1.31.1",
|
|
53
53
|
"react": "^17.0.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@jupyterlab/testutils": "^4.0.0-alpha.
|
|
56
|
+
"@jupyterlab/testutils": "^4.0.0-alpha.9",
|
|
57
57
|
"@types/jest": "^26.0.10",
|
|
58
58
|
"jest": "^26.4.2",
|
|
59
59
|
"rimraf": "~3.0.0",
|
|
60
60
|
"ts-jest": "^26.3.0",
|
|
61
61
|
"typedoc": "~0.22.10",
|
|
62
|
-
"typescript": "~4.
|
|
62
|
+
"typescript": "~4.6.3"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|