@jupyterlab/codeeditor 4.7.0-beta.0 → 4.7.0-beta.2
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/jsoneditor.d.ts +16 -0
- package/lib/jsoneditor.js +39 -10
- package/lib/jsoneditor.js.map +1 -1
- package/package.json +9 -9
- package/src/jsoneditor.ts +41 -10
package/lib/jsoneditor.d.ts
CHANGED
|
@@ -44,6 +44,22 @@ export declare class JSONEditor extends Widget {
|
|
|
44
44
|
* Get whether the editor is dirty.
|
|
45
45
|
*/
|
|
46
46
|
get isDirty(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Get whether the current editor content is a valid JSON object.
|
|
49
|
+
*/
|
|
50
|
+
get isValid(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Commit the current editor content to the source.
|
|
53
|
+
*
|
|
54
|
+
* @returns `true` if the editor content is in sync with the source after
|
|
55
|
+
* the call, i.e. the content was committed or there was nothing to
|
|
56
|
+
* commit; `false` if the content could not be committed because it is
|
|
57
|
+
* not a valid JSON object.
|
|
58
|
+
*
|
|
59
|
+
* #### Notes
|
|
60
|
+
* This is a no-op if the editor content has no uncommitted change.
|
|
61
|
+
*/
|
|
62
|
+
commit(): boolean;
|
|
47
63
|
/**
|
|
48
64
|
* Dispose of the editor.
|
|
49
65
|
*/
|
package/lib/jsoneditor.js
CHANGED
|
@@ -92,6 +92,36 @@ export class JSONEditor extends Widget {
|
|
|
92
92
|
get isDirty() {
|
|
93
93
|
return this._dataDirty || this._inputDirty;
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Get whether the current editor content is a valid JSON object.
|
|
97
|
+
*/
|
|
98
|
+
get isValid() {
|
|
99
|
+
return !this.hasClass(ERROR_CLASS);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Commit the current editor content to the source.
|
|
103
|
+
*
|
|
104
|
+
* @returns `true` if the editor content is in sync with the source after
|
|
105
|
+
* the call, i.e. the content was committed or there was nothing to
|
|
106
|
+
* commit; `false` if the content could not be committed because it is
|
|
107
|
+
* not a valid JSON object.
|
|
108
|
+
*
|
|
109
|
+
* #### Notes
|
|
110
|
+
* This is a no-op if the editor content has no uncommitted change.
|
|
111
|
+
*/
|
|
112
|
+
commit() {
|
|
113
|
+
if (!this._inputDirty) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
if (!this.isValid) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
this._changeGuard = true;
|
|
120
|
+
this._mergeContent();
|
|
121
|
+
this._changeGuard = false;
|
|
122
|
+
this._setValue();
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
95
125
|
/**
|
|
96
126
|
* Dispose of the editor.
|
|
97
127
|
*/
|
|
@@ -165,18 +195,20 @@ export class JSONEditor extends Widget {
|
|
|
165
195
|
*/
|
|
166
196
|
_onModelChanged(model, change) {
|
|
167
197
|
if (change.sourceChange) {
|
|
168
|
-
let valid
|
|
198
|
+
let valid;
|
|
169
199
|
try {
|
|
170
200
|
const value = JSON.parse(this.editor.model.sharedModel.getSource());
|
|
171
|
-
|
|
201
|
+
valid = JSONExt.isObject(value);
|
|
172
202
|
this._inputDirty =
|
|
173
|
-
!
|
|
203
|
+
!valid ||
|
|
204
|
+
(!this._changeGuard &&
|
|
205
|
+
!JSONExt.deepEqual(value, this._originalValue));
|
|
174
206
|
}
|
|
175
|
-
catch (
|
|
176
|
-
this.addClass(ERROR_CLASS);
|
|
207
|
+
catch (_a) {
|
|
177
208
|
this._inputDirty = true;
|
|
178
209
|
valid = false;
|
|
179
210
|
}
|
|
211
|
+
this.toggleClass(ERROR_CLASS, !valid);
|
|
180
212
|
this.revertButtonNode.hidden = !this._inputDirty;
|
|
181
213
|
this.commitButtonNode.hidden = !valid || !this._inputDirty;
|
|
182
214
|
}
|
|
@@ -199,11 +231,8 @@ export class JSONEditor extends Widget {
|
|
|
199
231
|
this._setValue();
|
|
200
232
|
}
|
|
201
233
|
else if (this.commitButtonNode.contains(target)) {
|
|
202
|
-
if (!this.commitButtonNode.hidden
|
|
203
|
-
this.
|
|
204
|
-
this._mergeContent();
|
|
205
|
-
this._changeGuard = false;
|
|
206
|
-
this._setValue();
|
|
234
|
+
if (!this.commitButtonNode.hidden) {
|
|
235
|
+
this.commit();
|
|
207
236
|
}
|
|
208
237
|
}
|
|
209
238
|
else if (this.editorHostNode.contains(target)) {
|
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;AAK3D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;GAEG;AACH,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,GAAG,cAAc,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAExC;;GAEG;AACH,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAE5C;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,MAAM;IACpC;;OAEG;IACH,YAAY,OAA4B;QACtC,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"jsoneditor.js","sourceRoot":"","sources":["../src/jsoneditor.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAK3D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;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AC;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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/codeeditor",
|
|
3
|
-
"version": "4.7.0-beta.
|
|
3
|
+
"version": "4.7.0-beta.2",
|
|
4
4
|
"description": "JupyterLab - Abstract Code Editor",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@codemirror/state": "^6.7.6",
|
|
45
45
|
"@jupyter/ydoc": "^4.0.0",
|
|
46
|
-
"@jupyterlab/apputils": "^4.8.0-beta.
|
|
47
|
-
"@jupyterlab/coreutils": "^6.7.0-beta.
|
|
48
|
-
"@jupyterlab/nbformat": "^4.7.0-beta.
|
|
49
|
-
"@jupyterlab/observables": "^5.7.0-beta.
|
|
50
|
-
"@jupyterlab/statusbar": "^4.7.0-beta.
|
|
51
|
-
"@jupyterlab/translation": "^4.7.0-beta.
|
|
52
|
-
"@jupyterlab/ui-components": "^4.7.0-beta.
|
|
46
|
+
"@jupyterlab/apputils": "^4.8.0-beta.2",
|
|
47
|
+
"@jupyterlab/coreutils": "^6.7.0-beta.2",
|
|
48
|
+
"@jupyterlab/nbformat": "^4.7.0-beta.2",
|
|
49
|
+
"@jupyterlab/observables": "^5.7.0-beta.2",
|
|
50
|
+
"@jupyterlab/statusbar": "^4.7.0-beta.2",
|
|
51
|
+
"@jupyterlab/translation": "^4.7.0-beta.2",
|
|
52
|
+
"@jupyterlab/ui-components": "^4.7.0-beta.2",
|
|
53
53
|
"@lumino/coreutils": "^2.2.3",
|
|
54
54
|
"@lumino/disposable": "^2.1.6",
|
|
55
55
|
"@lumino/dragdrop": "^2.1.9",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"react": "^18.2.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@jupyterlab/testing": "^4.7.0-beta.
|
|
62
|
+
"@jupyterlab/testing": "^4.7.0-beta.2",
|
|
63
63
|
"@types/jest": "^29.2.0",
|
|
64
64
|
"jest": "^29.2.0",
|
|
65
65
|
"rimraf": "~5.0.5",
|
package/src/jsoneditor.ts
CHANGED
|
@@ -139,6 +139,38 @@ export class JSONEditor extends Widget {
|
|
|
139
139
|
return this._dataDirty || this._inputDirty;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Get whether the current editor content is a valid JSON object.
|
|
144
|
+
*/
|
|
145
|
+
get isValid(): boolean {
|
|
146
|
+
return !this.hasClass(ERROR_CLASS);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Commit the current editor content to the source.
|
|
151
|
+
*
|
|
152
|
+
* @returns `true` if the editor content is in sync with the source after
|
|
153
|
+
* the call, i.e. the content was committed or there was nothing to
|
|
154
|
+
* commit; `false` if the content could not be committed because it is
|
|
155
|
+
* not a valid JSON object.
|
|
156
|
+
*
|
|
157
|
+
* #### Notes
|
|
158
|
+
* This is a no-op if the editor content has no uncommitted change.
|
|
159
|
+
*/
|
|
160
|
+
commit(): boolean {
|
|
161
|
+
if (!this._inputDirty) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
if (!this.isValid) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
this._changeGuard = true;
|
|
168
|
+
this._mergeContent();
|
|
169
|
+
this._changeGuard = false;
|
|
170
|
+
this._setValue();
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
|
|
142
174
|
/**
|
|
143
175
|
* Dispose of the editor.
|
|
144
176
|
*/
|
|
@@ -221,17 +253,19 @@ export class JSONEditor extends Widget {
|
|
|
221
253
|
*/
|
|
222
254
|
private _onModelChanged(model: ISharedFile, change: SourceChange): void {
|
|
223
255
|
if (change.sourceChange) {
|
|
224
|
-
let valid
|
|
256
|
+
let valid: boolean;
|
|
225
257
|
try {
|
|
226
258
|
const value = JSON.parse(this.editor.model.sharedModel.getSource());
|
|
227
|
-
|
|
259
|
+
valid = JSONExt.isObject(value);
|
|
228
260
|
this._inputDirty =
|
|
229
|
-
!
|
|
230
|
-
|
|
231
|
-
|
|
261
|
+
!valid ||
|
|
262
|
+
(!this._changeGuard &&
|
|
263
|
+
!JSONExt.deepEqual(value, this._originalValue));
|
|
264
|
+
} catch {
|
|
232
265
|
this._inputDirty = true;
|
|
233
266
|
valid = false;
|
|
234
267
|
}
|
|
268
|
+
this.toggleClass(ERROR_CLASS, !valid);
|
|
235
269
|
this.revertButtonNode.hidden = !this._inputDirty;
|
|
236
270
|
this.commitButtonNode.hidden = !valid || !this._inputDirty;
|
|
237
271
|
}
|
|
@@ -255,11 +289,8 @@ export class JSONEditor extends Widget {
|
|
|
255
289
|
if (this.revertButtonNode.contains(target)) {
|
|
256
290
|
this._setValue();
|
|
257
291
|
} else if (this.commitButtonNode.contains(target)) {
|
|
258
|
-
if (!this.commitButtonNode.hidden
|
|
259
|
-
this.
|
|
260
|
-
this._mergeContent();
|
|
261
|
-
this._changeGuard = false;
|
|
262
|
-
this._setValue();
|
|
292
|
+
if (!this.commitButtonNode.hidden) {
|
|
293
|
+
this.commit();
|
|
263
294
|
}
|
|
264
295
|
} else if (this.editorHostNode.contains(target)) {
|
|
265
296
|
this.editor.focus();
|