@json-editor/json-editor 2.9.0 → 2.10.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 +2 -0
- package/CHANGELOG.md +29 -7
- package/README.md +47 -1
- package/config/codeceptjs_helpers.js +4 -8
- package/config/karma.conf.js +0 -4
- package/config/webpack.common.js +1 -1
- package/config/webpack.dev.js +1 -1
- package/config/webpack.nonmin.js +1 -1
- package/config/webpack.prod.js +0 -1
- package/dist/dev/jsoneditor.js +3687 -0
- package/dist/jsoneditor.js +2 -14
- package/dist/jsoneditor.js.LICENSE.txt +1 -1
- package/dist/jsoneditor.js.map +1 -1
- package/dist/nonmin/jsoneditor.js +25744 -26450
- package/dist/nonmin/jsoneditor.js.map +1 -1
- package/docs/css_integration.html +17 -15
- package/docs/custom-editor.html +92 -0
- package/docs/datetime.html +37 -2
- package/docs/index.html +4 -1
- package/docs/meta_schema.json +426 -398
- package/package.json +26 -24
- package/src/defaults.js +15 -1
- package/src/editor.js +23 -6
- package/src/editors/integer.js +5 -3
- package/src/editors/multiple.js +67 -8
- package/src/editors/number.js +5 -3
- package/src/editors/object.js +0 -1
- package/src/editors/radio.js +4 -6
- package/src/editors/select.js +0 -6
- package/src/iconlibs/bootstrap.js +28 -0
- package/src/iconlibs/index.js +2 -0
- package/src/resolvers.js +5 -2
- package/src/schemaloader.js +3 -1
- package/src/themes/bootstrap3.js +1 -1
- package/src/utilities.js +22 -0
- package/src/validator.js +93 -0
- package/tests/codeceptjs/constrains/contains_test.js +36 -0
- package/tests/codeceptjs/constrains/dependentSchemas_test.js +15 -0
- package/tests/codeceptjs/constrains/if-then-else_test.js +143 -0
- package/tests/codeceptjs/core_test.js +46 -46
- package/tests/codeceptjs/editors/advanced_test.js +12 -11
- package/tests/codeceptjs/editors/array_any_of_test.js +37 -37
- package/tests/codeceptjs/editors/array_test.js +784 -794
- package/tests/codeceptjs/editors/autocomplete_test.js +4 -6
- package/tests/codeceptjs/editors/button_test.js +30 -29
- package/tests/codeceptjs/editors/checkbox_test.js +19 -18
- package/tests/codeceptjs/editors/colorpicker_test.js +20 -18
- package/tests/codeceptjs/editors/datetime_test.js +11 -11
- package/tests/codeceptjs/editors/inheritance_test.js +8 -9
- package/tests/codeceptjs/editors/integer_test.js +77 -78
- package/tests/codeceptjs/editors/jodit_test.js +18 -19
- package/tests/codeceptjs/editors/multiselect_test.js +6 -6
- package/tests/codeceptjs/editors/number_test.js +72 -71
- package/tests/codeceptjs/editors/object_test.js +52 -26
- package/tests/codeceptjs/editors/option-no_default_values_test.js +6 -6
- package/tests/codeceptjs/editors/programmatic-changes_test.js +4 -5
- package/tests/codeceptjs/editors/radio_test.js +1 -1
- package/tests/codeceptjs/editors/range_test.js +2 -4
- package/tests/codeceptjs/editors/rating_test.js +1 -1
- package/tests/codeceptjs/editors/select_test.js +5 -7
- package/tests/codeceptjs/editors/stepper_test.js +8 -10
- package/tests/codeceptjs/editors/string_test.js +16 -16
- package/tests/codeceptjs/editors/table-confirm-delete_test.js +11 -13
- package/tests/codeceptjs/editors/tabs_test.js +1 -1
- package/tests/codeceptjs/editors/uuid_test.js +15 -15
- package/tests/codeceptjs/editors/validation_test.js +2 -2
- package/tests/codeceptjs/issues/issue-gh-1133_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1158-2_test.js +10 -0
- package/tests/codeceptjs/{editors/issues → issues}/issue-gh-1158_test.js +1 -3
- package/tests/codeceptjs/issues/issue-gh-1164_test.js +10 -0
- package/tests/codeceptjs/issues/issue-gh-1211_test.js +17 -0
- package/tests/codeceptjs/{editors/issues → issues}/issue-gh-1257_test.js +3 -5
- package/tests/codeceptjs/issues/issue-gh-1338_test.js +16 -0
- package/tests/codeceptjs/issues/issue-gh-1347_test.js +8 -0
- package/tests/codeceptjs/issues/issue-gh-795_test.js +13 -0
- package/tests/codeceptjs/issues/issue-gh-810_test.js +52 -0
- package/tests/codeceptjs/issues/issue-gh-812_test.js +25 -0
- package/tests/codeceptjs/meta-schema_test.js +12 -12
- package/tests/codeceptjs/schemaloader_test.js +8 -8
- package/tests/codeceptjs/themes_test.js +40 -9
- package/tests/pages/autocomplete.html +1 -0
- package/tests/pages/contains.html +38 -0
- package/tests/pages/dependentSchemas.html +52 -0
- package/tests/pages/if-else.html +57 -0
- package/tests/pages/if-then-else-allOf.html +117 -0
- package/tests/pages/if-then-else.html +64 -0
- package/tests/pages/if-then.html +57 -0
- package/tests/pages/issues/issue-gh-1133.html +64 -0
- package/tests/pages/issues/issue-gh-1158-2.html +189 -0
- package/tests/pages/issues/issue-gh-1164.html +71 -0
- package/tests/pages/issues/issue-gh-1165.html +63 -0
- package/tests/pages/issues/issue-gh-1165.json +8 -0
- package/tests/pages/issues/issue-gh-1211.html +1022 -0
- package/tests/pages/issues/issue-gh-1338.html +74 -0
- package/tests/pages/issues/issue-gh-1347.html +142 -0
- package/tests/pages/issues/issue-gh-795.html +58 -0
- package/tests/pages/issues/issue-gh-810.html +149 -0
- package/tests/pages/maxContains.html +39 -0
- package/tests/pages/meta-schema.html +28 -0
- package/tests/pages/meta_schema.json +426 -398
- package/tests/pages/minContains.html +39 -0
- package/tests/pages/number.html +18 -0
- package/tests/pages/option-dependencies.html +106 -0
- package/tests/pages/themes.html +3 -1
- package/tests/unit/core.spec.js +8 -10
- package/tests/codeceptjs/editors/issues/issue-gh-812_test.js +0 -32
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<title>minContains</title>
|
|
6
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
7
|
+
<link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
|
8
|
+
<link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
|
|
12
|
+
<div class="container">
|
|
13
|
+
<div id='editor-container'></div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
var editorContainer = document.querySelector('#editor-container')
|
|
18
|
+
var schema = {
|
|
19
|
+
'title': 'minContains',
|
|
20
|
+
'type': 'array',
|
|
21
|
+
'items': {
|
|
22
|
+
'type': 'number'
|
|
23
|
+
},
|
|
24
|
+
'contains': {
|
|
25
|
+
'type': 'number'
|
|
26
|
+
},
|
|
27
|
+
'minContains': 2
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var editor = new JSONEditor(editorContainer, {
|
|
31
|
+
schema: schema,
|
|
32
|
+
theme: 'bootstrap4',
|
|
33
|
+
iconlib: 'fontawesome',
|
|
34
|
+
show_errors: 'always'
|
|
35
|
+
})
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
</body>
|
|
39
|
+
</html>
|
package/tests/pages/number.html
CHANGED
|
@@ -63,6 +63,24 @@
|
|
|
63
63
|
"minimum": 1,
|
|
64
64
|
"maximum": 10,
|
|
65
65
|
"step": 0.25
|
|
66
|
+
},
|
|
67
|
+
"stepper_number_default": {
|
|
68
|
+
"title": "stepper number",
|
|
69
|
+
"format": "stepper",
|
|
70
|
+
"type": "number",
|
|
71
|
+
"minimum": 1,
|
|
72
|
+
"maximum": 10,
|
|
73
|
+
"step": 0.25,
|
|
74
|
+
"default": 5
|
|
75
|
+
},
|
|
76
|
+
"stepper_integer_default": {
|
|
77
|
+
"title": "stepper integer",
|
|
78
|
+
"format": "stepper",
|
|
79
|
+
"type": "integer",
|
|
80
|
+
"minimum": 1,
|
|
81
|
+
"maximum": 10,
|
|
82
|
+
"step": 1,
|
|
83
|
+
"default": 5
|
|
66
84
|
}
|
|
67
85
|
}
|
|
68
86
|
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<title>option: dependencies</title>
|
|
6
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
7
|
+
<link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
|
8
|
+
<link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
|
|
12
|
+
<div class="container">
|
|
13
|
+
<div id='editor-container'></div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
var editorContainer = document.querySelector('#editor-container')
|
|
18
|
+
var schema = {
|
|
19
|
+
"title": "Person",
|
|
20
|
+
"type": "object",
|
|
21
|
+
"required": [
|
|
22
|
+
"gender"
|
|
23
|
+
],
|
|
24
|
+
"properties": {
|
|
25
|
+
"gender": {
|
|
26
|
+
"title": "Gender",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": [
|
|
29
|
+
"female",
|
|
30
|
+
"male",
|
|
31
|
+
"other"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"maleSpecific": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"title": "Male specific question?",
|
|
37
|
+
"options": {
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"gender": "male"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"femaleSpecific": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"title": "Female specific question?",
|
|
46
|
+
"options": {
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"gender": "female"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"otherSpecific": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"title": "What is your preferred gender?",
|
|
55
|
+
"options": {
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"gender": "other"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"age": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"properties": {
|
|
64
|
+
"maleSpecificAge": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"title": "Male specific age question?",
|
|
67
|
+
"options": {
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"root.gender": "male"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"femaleSpecificAge": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"title": "Female specific age question?",
|
|
76
|
+
"options": {
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"root.gender": "female"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"otherSpecificAge": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"title": "Other specific age question?",
|
|
85
|
+
"options": {
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"root.gender": "other"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
var editor = new JSONEditor(editorContainer, {
|
|
98
|
+
schema: schema,
|
|
99
|
+
theme: 'bootstrap4',
|
|
100
|
+
iconlib: 'fontawesome',
|
|
101
|
+
show_errors: 'always'
|
|
102
|
+
})
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
</body>
|
|
106
|
+
</html>
|
package/tests/pages/themes.html
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
<option value='materialicons'>Material icons</option>
|
|
42
42
|
<option value='openiconic'>Open Iconic</option>
|
|
43
43
|
<option value='spectre'>Spectre</option>
|
|
44
|
+
<option value='bootstrap'>Bootstrap Icons</option>
|
|
44
45
|
</select>
|
|
45
46
|
</div>
|
|
46
47
|
<div class="container">
|
|
@@ -514,7 +515,8 @@
|
|
|
514
515
|
jqueryui: 'https://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css',
|
|
515
516
|
materialicons: 'https://fonts.googleapis.com/icon?family=Material+Icons',
|
|
516
517
|
openiconic: 'https://cdnjs.cloudflare.com/ajax/libs/open-iconic/1.1.1/font/css/open-iconic.min.css',
|
|
517
|
-
spectre: 'https://unpkg.com/spectre.css/dist/spectre-icons.min.css'
|
|
518
|
+
spectre: 'https://unpkg.com/spectre.css/dist/spectre-icons.min.css',
|
|
519
|
+
bootstrap: 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css'
|
|
518
520
|
};
|
|
519
521
|
|
|
520
522
|
document.querySelector('#iconlib_stylesheet').href = mapping[iconlib];
|
package/tests/unit/core.spec.js
CHANGED
|
@@ -21,15 +21,12 @@ describe('JSONEditor', function () {
|
|
|
21
21
|
|
|
22
22
|
// inject the HTML fixture for the tests
|
|
23
23
|
beforeEach(() => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
document.body.insertAdjacentHTML('afterbegin', fixture)
|
|
24
|
+
document.body.insertAdjacentHTML('afterbegin', '<div id="fixture"></div>')
|
|
27
25
|
element = document.getElementById('fixture')
|
|
28
26
|
})
|
|
29
27
|
|
|
30
|
-
// remove the html fixture from the DOM
|
|
31
28
|
afterEach(() => {
|
|
32
|
-
|
|
29
|
+
editor.destroy()
|
|
33
30
|
})
|
|
34
31
|
|
|
35
32
|
it('should create an editor', () => {
|
|
@@ -217,7 +214,7 @@ describe('JSONEditor', function () {
|
|
|
217
214
|
editor.promise.then(() => {
|
|
218
215
|
expect(editor.getValue()).toEqual({
|
|
219
216
|
boolean: undefined,
|
|
220
|
-
enum:
|
|
217
|
+
enum: 'foo',
|
|
221
218
|
integer: undefined,
|
|
222
219
|
number: undefined,
|
|
223
220
|
string: undefined,
|
|
@@ -235,7 +232,7 @@ describe('JSONEditor', function () {
|
|
|
235
232
|
editor.promise.then(() => {
|
|
236
233
|
expect(editor.getValue()).toEqual({
|
|
237
234
|
boolean: undefined,
|
|
238
|
-
enum:
|
|
235
|
+
enum: 'foo',
|
|
239
236
|
integer: undefined,
|
|
240
237
|
number: undefined,
|
|
241
238
|
string: undefined,
|
|
@@ -249,7 +246,7 @@ describe('JSONEditor', function () {
|
|
|
249
246
|
|
|
250
247
|
expect(editor.getValue()).toEqual({
|
|
251
248
|
boolean: undefined,
|
|
252
|
-
enum:
|
|
249
|
+
enum: 'foo',
|
|
253
250
|
integer: 3,
|
|
254
251
|
number: 4,
|
|
255
252
|
string: 'foo',
|
|
@@ -263,7 +260,7 @@ describe('JSONEditor', function () {
|
|
|
263
260
|
|
|
264
261
|
expect(editor.getValue()).toEqual({
|
|
265
262
|
boolean: undefined,
|
|
266
|
-
enum:
|
|
263
|
+
enum: 'foo',
|
|
267
264
|
integer: undefined,
|
|
268
265
|
number: undefined,
|
|
269
266
|
string: '',
|
|
@@ -290,7 +287,8 @@ describe('JSONEditor', function () {
|
|
|
290
287
|
editor.promise.then(() => {
|
|
291
288
|
expect(editor.getValue()).toEqual({
|
|
292
289
|
string_with_default: 'foobar',
|
|
293
|
-
enum_with_default: 'foobar'
|
|
290
|
+
enum_with_default: 'foobar',
|
|
291
|
+
enum_without_default: 'foobar'
|
|
294
292
|
})
|
|
295
293
|
})
|
|
296
294
|
})
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/* global Feature Scenario */
|
|
2
|
-
|
|
3
|
-
const assert = require('assert')
|
|
4
|
-
let value
|
|
5
|
-
|
|
6
|
-
Feature('issues')
|
|
7
|
-
|
|
8
|
-
Scenario('GitHub issue 812 should remain fixed @issue-812', async (I) => {
|
|
9
|
-
I.amOnPage('issues/issue-gh-812.html')
|
|
10
|
-
|
|
11
|
-
I.click('.get-value')
|
|
12
|
-
value = await I.grabValueFrom('.debug')
|
|
13
|
-
assert.equal(value, '{"students":[{"name":"AAA","sessions":[{"student_name":"AAA","minutes":15},{"student_name":"AAA","minutes":15}]},{"name":"BBB","sessions":[{"student_name":"BBB","minutes":20}]},{"name":"CCC","sessions":[{"student_name":"CCC","minutes":10}]}]}')
|
|
14
|
-
|
|
15
|
-
I.amAcceptingPopups()
|
|
16
|
-
I.click('//*[@id="root.students.0"]/span[2]/button[contains(@class, "json-editor-btn-delete") and @data-i="0"]')
|
|
17
|
-
I.retry({ retries: 5, minTimeout: 500 }).seeInPopup('Are you sure you want to remove this node?')
|
|
18
|
-
I.acceptPopup()
|
|
19
|
-
|
|
20
|
-
I.click('.get-value')
|
|
21
|
-
value = await I.grabValueFrom('.debug')
|
|
22
|
-
assert.equal(value, '{"students":[{"name":"BBB","sessions":[{"student_name":"BBB","minutes":20}]},{"name":"CCC","sessions":[{"student_name":"CCC","minutes":10}]}]}')
|
|
23
|
-
|
|
24
|
-
I.amAcceptingPopups()
|
|
25
|
-
I.click('//*[@id="root.students.0"]/span[2]/button[contains(@class, "json-editor-btn-delete") and @data-i="0"]')
|
|
26
|
-
I.retry({ retries: 5, minTimeout: 500 }).seeInPopup('Are you sure you want to remove this node?')
|
|
27
|
-
I.acceptPopup()
|
|
28
|
-
|
|
29
|
-
I.click('.get-value')
|
|
30
|
-
value = await I.grabValueFrom('.debug')
|
|
31
|
-
assert.equal(value, '{"students":[{"name":"CCC","sessions":[{"student_name":"CCC","minutes":10}]}]}')
|
|
32
|
-
})
|