@json-editor/json-editor 2.5.4 → 2.7.0
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/.github/workflows/build.yml +12 -3
- package/CHANGELOG.md +51 -14
- package/README.md +159 -20
- package/dist/jsoneditor.js +2 -2
- package/dist/nonmin/jsoneditor.js +5483 -3610
- package/dist/nonmin/jsoneditor.js.map +1 -1
- package/docs/cleave.html +1 -1
- package/docs/datetime.html +1 -1
- package/docs/describedby.html +1 -1
- package/docs/form-submission.html +76 -0
- package/docs/index.html +2 -2
- package/docs/materialize_css.html +1 -1
- package/docs/meta_schema.json +0 -1
- package/docs/radio.html +1 -1
- package/docs/select2.html +1 -1
- package/docs/selectize.html +1 -1
- package/docs/starrating.html +1 -1
- package/docs/wysiwyg.html +1 -1
- package/package.json +28 -26
- package/release-notes.md +5 -3
- package/src/core.js +36 -37
- package/src/defaults.js +9 -2
- package/src/editor.js +6 -2
- package/src/editors/array.js +12 -1
- package/src/editors/autocomplete.js +4 -3
- package/src/editors/button.js +1 -1
- package/src/editors/multiple.js +2 -0
- package/src/editors/multiselect.js +14 -5
- package/src/editors/object.js +10 -6
- package/src/editors/radio.js +6 -1
- package/src/editors/string.js +7 -1
- package/src/editors/table.js +21 -2
- package/src/editors/upload.js +1 -1
- package/src/editors/uuid.js +2 -12
- package/src/iconlib.js +1 -1
- package/src/schemaloader.js +232 -109
- package/src/style.css +3 -0
- package/src/style.css.js +1 -1
- package/src/theme.js +5 -4
- package/src/themes/bootstrap3.js +3 -2
- package/src/themes/bootstrap4.js +7 -0
- package/src/themes/spectre.js +2 -1
- package/src/utilities.js +18 -0
- package/src/validator.js +65 -47
- package/tests/codeceptjs/codecept.json +1 -1
- package/tests/codeceptjs/core_test.js +98 -0
- package/tests/codeceptjs/editors/advanced_test.js +1 -1
- package/tests/codeceptjs/editors/array_test.js +74 -0
- package/tests/codeceptjs/editors/autocomplete_test.js +16 -0
- package/tests/codeceptjs/editors/button_test.js +11 -4
- package/tests/codeceptjs/editors/integer_test.js +7 -2
- package/tests/codeceptjs/editors/jodit_test.js +3 -3
- package/tests/codeceptjs/editors/object_test.js +84 -13
- package/tests/codeceptjs/editors/range_test.js +12 -0
- package/tests/codeceptjs/editors/stepper_test.js +12 -0
- package/tests/codeceptjs/editors/uuid_test.js +31 -4
- package/tests/codeceptjs/editors/validation_test.js +1 -1
- package/tests/docker-compose.yml +1 -1
- package/tests/fixtures/definitions.json +22 -0
- package/tests/fixtures/properties.json +20 -0
- package/tests/fixtures/validation.json +207 -0
- package/tests/pages/array-checkboxes-infotext.html +52 -0
- package/tests/pages/array-move-events.html +4 -2
- package/tests/pages/array-unique-items-sort.html +78 -0
- package/tests/pages/autocomplete.html +69 -0
- package/tests/pages/button-icons.html +38 -0
- package/tests/pages/core.html +4 -2
- package/tests/pages/error-messages.html +47 -0
- package/tests/pages/grid-strict.html +6 -10
- package/tests/pages/grid.html +0 -4
- package/tests/pages/issues/issue-gh-812.html +4 -2
- package/tests/pages/meta_schema.json +14 -1
- package/tests/pages/object-required-properties.html +37 -14
- package/tests/pages/object-show-opt-in.html +110 -0
- package/tests/pages/object-with-dependencies-array.html +29 -19
- package/tests/pages/range.html +60 -0
- package/tests/pages/ready.html +43 -0
- package/tests/pages/references.html +162 -0
- package/tests/pages/stepper-manual.html +57 -0
- package/tests/pages/string-simplemde-editor.html +81 -0
- package/tests/pages/table-move-events.html +4 -1
- package/tests/pages/urn.html +11 -8
- package/tests/pages/uuid.html +89 -50
- package/tests/pages/validation-messages.json +705 -0
- package/tests/unit/core.spec.js +79 -66
- package/tests/unit/editor.spec.js +20 -8
- package/tests/unit/editors/array.spec.js +3 -2
- package/tests/unit/editors/object.spec.js +3 -1
- package/tests/unit/editors/table.spec.js +4 -2
- package/tests/unit/schemaloader.spec.js +77 -105
- package/tests/unit/validator.spec.js +10 -0
package/tests/unit/core.spec.js
CHANGED
|
@@ -33,6 +33,7 @@ describe('JSONEditor', function () {
|
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
it('should create an editor', () => {
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
36
37
|
console.log('Attempting to create new JSONEditor')
|
|
37
38
|
editor = new JSONEditor(element, { schema: schema })
|
|
38
39
|
expect(editor).toBeTruthy()
|
|
@@ -130,14 +131,16 @@ describe('JSONEditor', function () {
|
|
|
130
131
|
max_depth: 4
|
|
131
132
|
})
|
|
132
133
|
expect(editor).toBeTruthy()
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
editor.promise.then(() => {
|
|
135
|
+
expect(editor.getValue()).toEqual({
|
|
135
136
|
foo: {
|
|
136
137
|
foo: {
|
|
137
|
-
foo: {
|
|
138
|
+
foo: {
|
|
139
|
+
foo: {}
|
|
140
|
+
}
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
|
-
}
|
|
143
|
+
})
|
|
141
144
|
})
|
|
142
145
|
})
|
|
143
146
|
|
|
@@ -172,11 +175,13 @@ describe('JSONEditor', function () {
|
|
|
172
175
|
max_depth: depthWithEnum
|
|
173
176
|
})
|
|
174
177
|
expect(editor).toBeTruthy()
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
editor.promise.then(() => {
|
|
179
|
+
expect(editor.getValue()).toEqual({
|
|
180
|
+
field_on_level_one: {
|
|
181
|
+
propertyWithEnum: 'bar',
|
|
182
|
+
something_else: {}
|
|
183
|
+
}
|
|
184
|
+
})
|
|
180
185
|
})
|
|
181
186
|
})
|
|
182
187
|
|
|
@@ -186,7 +191,9 @@ describe('JSONEditor', function () {
|
|
|
186
191
|
max_depth: 0
|
|
187
192
|
})
|
|
188
193
|
expect(editor).toBeTruthy()
|
|
189
|
-
|
|
194
|
+
editor.promise.then(() => {
|
|
195
|
+
expect(editor.getValue()).toEqual({ foo1: { foo2: { foo3: { foo4: { bar: 'end schema' } } } } })
|
|
196
|
+
})
|
|
190
197
|
})
|
|
191
198
|
|
|
192
199
|
it('renders all schema as default', () => {
|
|
@@ -194,7 +201,9 @@ describe('JSONEditor', function () {
|
|
|
194
201
|
schema: nestedObject
|
|
195
202
|
})
|
|
196
203
|
expect(editor).toBeTruthy()
|
|
197
|
-
|
|
204
|
+
editor.promise.then(() => {
|
|
205
|
+
expect(editor.getValue()).toEqual({ foo1: { foo2: { foo3: { foo4: { bar: 'end schema' } } } } })
|
|
206
|
+
})
|
|
198
207
|
})
|
|
199
208
|
})
|
|
200
209
|
|
|
@@ -205,15 +214,16 @@ describe('JSONEditor', function () {
|
|
|
205
214
|
schema: someTypes,
|
|
206
215
|
use_default_values: false
|
|
207
216
|
})
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
+
editor.promise.then(() => {
|
|
218
|
+
expect(editor.getValue()).toEqual({
|
|
219
|
+
boolean: undefined,
|
|
220
|
+
enum: undefined,
|
|
221
|
+
integer: undefined,
|
|
222
|
+
number: undefined,
|
|
223
|
+
string: undefined,
|
|
224
|
+
object: {},
|
|
225
|
+
array: []
|
|
226
|
+
})
|
|
217
227
|
})
|
|
218
228
|
})
|
|
219
229
|
|
|
@@ -222,43 +232,44 @@ describe('JSONEditor', function () {
|
|
|
222
232
|
schema: someTypes,
|
|
223
233
|
use_default_values: false
|
|
224
234
|
})
|
|
235
|
+
editor.promise.then(() => {
|
|
236
|
+
expect(editor.getValue()).toEqual({
|
|
237
|
+
boolean: undefined,
|
|
238
|
+
enum: undefined,
|
|
239
|
+
integer: undefined,
|
|
240
|
+
number: undefined,
|
|
241
|
+
string: undefined,
|
|
242
|
+
object: {},
|
|
243
|
+
array: []
|
|
244
|
+
})
|
|
225
245
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
integer: undefined,
|
|
230
|
-
number: undefined,
|
|
231
|
-
string: undefined,
|
|
232
|
-
object: {},
|
|
233
|
-
array: []
|
|
234
|
-
})
|
|
246
|
+
fillField('root[integer]', 3)
|
|
247
|
+
fillField('root[number]', 4)
|
|
248
|
+
fillField('root[string]', 'foo')
|
|
235
249
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
250
|
+
expect(editor.getValue()).toEqual({
|
|
251
|
+
boolean: undefined,
|
|
252
|
+
enum: undefined,
|
|
253
|
+
integer: 3,
|
|
254
|
+
number: 4,
|
|
255
|
+
string: 'foo',
|
|
256
|
+
object: {},
|
|
257
|
+
array: []
|
|
258
|
+
})
|
|
239
259
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
integer: 3,
|
|
244
|
-
number: 4,
|
|
245
|
-
string: 'foo',
|
|
246
|
-
object: {},
|
|
247
|
-
array: []
|
|
248
|
-
})
|
|
249
|
-
|
|
250
|
-
fillField('root[integer]', '')
|
|
251
|
-
fillField('root[number]', '')
|
|
252
|
-
fillField('root[string]', '')
|
|
260
|
+
fillField('root[integer]', '')
|
|
261
|
+
fillField('root[number]', '')
|
|
262
|
+
fillField('root[string]', '')
|
|
253
263
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
264
|
+
expect(editor.getValue()).toEqual({
|
|
265
|
+
boolean: undefined,
|
|
266
|
+
enum: undefined,
|
|
267
|
+
integer: undefined,
|
|
268
|
+
number: undefined,
|
|
269
|
+
string: '',
|
|
270
|
+
object: {},
|
|
271
|
+
array: []
|
|
272
|
+
})
|
|
262
273
|
})
|
|
263
274
|
})
|
|
264
275
|
|
|
@@ -276,10 +287,11 @@ describe('JSONEditor', function () {
|
|
|
276
287
|
use_default_values: false,
|
|
277
288
|
remove_empty_properties: true
|
|
278
289
|
})
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
290
|
+
editor.promise.then(() => {
|
|
291
|
+
expect(editor.getValue()).toEqual({
|
|
292
|
+
string_with_default: 'foobar',
|
|
293
|
+
enum_with_default: 'foobar'
|
|
294
|
+
})
|
|
283
295
|
})
|
|
284
296
|
})
|
|
285
297
|
})
|
|
@@ -289,15 +301,16 @@ describe('JSONEditor', function () {
|
|
|
289
301
|
schema: someTypes,
|
|
290
302
|
use_default_values: true
|
|
291
303
|
})
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
304
|
+
editor.promise.then(() => {
|
|
305
|
+
expect(editor.getValue()).toEqual({
|
|
306
|
+
boolean: false,
|
|
307
|
+
enum: 'foo',
|
|
308
|
+
integer: 0,
|
|
309
|
+
number: 0,
|
|
310
|
+
string: '',
|
|
311
|
+
object: {},
|
|
312
|
+
array: []
|
|
313
|
+
})
|
|
301
314
|
})
|
|
302
315
|
})
|
|
303
316
|
})
|
|
@@ -27,7 +27,9 @@ describe('Editor', () => {
|
|
|
27
27
|
},
|
|
28
28
|
startval: 5
|
|
29
29
|
})
|
|
30
|
-
|
|
30
|
+
editor.promise.then(() => {
|
|
31
|
+
expect(editor.getValue()).toBe(5)
|
|
32
|
+
})
|
|
31
33
|
})
|
|
32
34
|
|
|
33
35
|
it('Array start value test', () => {
|
|
@@ -44,7 +46,9 @@ describe('Editor', () => {
|
|
|
44
46
|
},
|
|
45
47
|
startval: [1, 2, 3, 4, 5]
|
|
46
48
|
})
|
|
47
|
-
|
|
49
|
+
editor.promise.then(() => {
|
|
50
|
+
expect(JSON.stringify(editor.getValue())).toBe('[1,2,3,4,5]')
|
|
51
|
+
})
|
|
48
52
|
})
|
|
49
53
|
|
|
50
54
|
it('Starrating start value test', () => {
|
|
@@ -58,7 +62,9 @@ describe('Editor', () => {
|
|
|
58
62
|
},
|
|
59
63
|
startval: 5
|
|
60
64
|
})
|
|
61
|
-
|
|
65
|
+
editor.promise.then(() => {
|
|
66
|
+
expect(editor.root.value).toBe(5)
|
|
67
|
+
})
|
|
62
68
|
})
|
|
63
69
|
|
|
64
70
|
it('Starrating Array start value test', () => {
|
|
@@ -76,7 +82,9 @@ describe('Editor', () => {
|
|
|
76
82
|
},
|
|
77
83
|
startval: [1, 2, 3, 4, 5]
|
|
78
84
|
})
|
|
79
|
-
|
|
85
|
+
editor.promise.then(() => {
|
|
86
|
+
expect(JSON.stringify(editor.getValue())).toBe('[1,2,3,4,5]')
|
|
87
|
+
})
|
|
80
88
|
})
|
|
81
89
|
|
|
82
90
|
it('oneOf Editor Test', () => {
|
|
@@ -101,8 +109,10 @@ describe('Editor', () => {
|
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
111
|
})
|
|
104
|
-
|
|
105
|
-
|
|
112
|
+
editor.promise.then(() => {
|
|
113
|
+
const e = editor.getEditor('root.one_or_many')
|
|
114
|
+
e.switchEditor(1)
|
|
115
|
+
})
|
|
106
116
|
})
|
|
107
117
|
})
|
|
108
118
|
|
|
@@ -153,8 +163,10 @@ describe('Number Editor', () => {
|
|
|
153
163
|
editor = new JSONEditor(element, {
|
|
154
164
|
schema: spec.schema
|
|
155
165
|
})
|
|
156
|
-
editor.
|
|
157
|
-
|
|
166
|
+
editor.promise.then(() => {
|
|
167
|
+
editor.setValue(spec.input)
|
|
168
|
+
expect(editor.getValue()).toBe(spec.value)
|
|
169
|
+
})
|
|
158
170
|
})
|
|
159
171
|
})
|
|
160
172
|
})
|
|
@@ -75,11 +75,12 @@ describe('Array Editor', () => {
|
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
fixture.forEach(spec => {
|
|
78
|
-
it(spec.title, () => {
|
|
78
|
+
it(spec.title, async () => {
|
|
79
79
|
editor = new JSONEditor(element, {
|
|
80
80
|
schema: spec.schema
|
|
81
81
|
})
|
|
82
|
-
editor.
|
|
82
|
+
await editor.load()
|
|
83
|
+
editor.setValue(spec.value)
|
|
83
84
|
expect(editor.getValue()).toEqual(spec.value)
|
|
84
85
|
})
|
|
85
86
|
})
|
|
@@ -84,8 +84,10 @@ describe('Table Editor', () => {
|
|
|
84
84
|
editor = new JSONEditor(element, {
|
|
85
85
|
schema: spec.schema
|
|
86
86
|
})
|
|
87
|
-
editor.
|
|
88
|
-
|
|
87
|
+
editor.promise.then(() => {
|
|
88
|
+
editor.setValue(spec.value)
|
|
89
|
+
expect(editor.getValue()).toEqual(spec.value)
|
|
90
|
+
})
|
|
89
91
|
})
|
|
90
92
|
})
|
|
91
93
|
})
|