@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
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<title>CSS Integration JSON Editor Example</title>
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
<link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">
|
|
8
8
|
<link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-exp.min.css">
|
|
9
9
|
<link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-icons.min.css">
|
|
10
10
|
|
|
11
11
|
<script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
<script>
|
|
14
14
|
// Set the default CSS theme and icon library globally
|
|
15
15
|
JSONEditor.defaults.theme = 'spectre';
|
|
@@ -31,10 +31,12 @@
|
|
|
31
31
|
<div class='column col-md-6'>
|
|
32
32
|
<p>JSON Editor supports these popular CSS frameworks:</p>
|
|
33
33
|
<ul>
|
|
34
|
+
<li>bootstrap 3</li>
|
|
34
35
|
<li>bootstrap 4</li>
|
|
36
|
+
<li>bootstrap 5</li>
|
|
35
37
|
<li>spectre.css (shown here)</li>
|
|
36
38
|
<li>tailwind</li>
|
|
37
|
-
</ul>
|
|
39
|
+
</ul>
|
|
38
40
|
</div>
|
|
39
41
|
<div class='column col-md-6'>
|
|
40
42
|
<p>JSON Editor supports these popular icon libraries:</p>
|
|
@@ -51,17 +53,17 @@
|
|
|
51
53
|
<div class='column col-md-12'>
|
|
52
54
|
<button id='submit' class='tiny'>Submit (console.log)</button>
|
|
53
55
|
<button id='restore' class='secondary tiny'>Restore to Default</button>
|
|
54
|
-
<span id='valid_indicator' class='label'></span>
|
|
56
|
+
<span id='valid_indicator' class='label'></span>
|
|
55
57
|
</div>
|
|
56
58
|
</div>
|
|
57
59
|
<div class='columns'>
|
|
58
60
|
<div class='column col-md-12' id='editor_holder'></div>
|
|
59
61
|
</div>
|
|
60
62
|
</div>
|
|
61
|
-
|
|
63
|
+
|
|
62
64
|
<script>
|
|
63
65
|
// This is the starting value for the editor
|
|
64
|
-
// We will use this to seed the initial editor
|
|
66
|
+
// We will use this to seed the initial editor
|
|
65
67
|
// and to provide a "Restore to Default" button.
|
|
66
68
|
var starting_value = {
|
|
67
69
|
name: "John Smith",
|
|
@@ -84,41 +86,41 @@
|
|
|
84
86
|
}
|
|
85
87
|
]
|
|
86
88
|
};
|
|
87
|
-
|
|
89
|
+
|
|
88
90
|
// Initialize the editor
|
|
89
91
|
var editor = new JSONEditor(document.getElementById('editor_holder'),{
|
|
90
92
|
// Enable fetching schemas via ajax
|
|
91
93
|
ajax: true,
|
|
92
|
-
|
|
94
|
+
|
|
93
95
|
// The schema for the editor
|
|
94
96
|
schema: {
|
|
95
97
|
$ref: "person.json",
|
|
96
98
|
format: "grid"
|
|
97
99
|
},
|
|
98
|
-
|
|
100
|
+
|
|
99
101
|
// Seed the form with a starting value
|
|
100
102
|
startval: starting_value
|
|
101
103
|
});
|
|
102
|
-
|
|
104
|
+
|
|
103
105
|
// Hook up the submit button to log to the console
|
|
104
106
|
document.getElementById('submit').addEventListener('click',function() {
|
|
105
107
|
// Get the value from the editor
|
|
106
108
|
console.log(editor.getValue());
|
|
107
109
|
});
|
|
108
|
-
|
|
110
|
+
|
|
109
111
|
// Hook up the Restore to Default button
|
|
110
112
|
document.getElementById('restore').addEventListener('click',function() {
|
|
111
113
|
editor.setValue(starting_value);
|
|
112
114
|
});
|
|
113
|
-
|
|
114
|
-
// Hook up the validation indicator to update its
|
|
115
|
+
|
|
116
|
+
// Hook up the validation indicator to update its
|
|
115
117
|
// status whenever the editor changes
|
|
116
118
|
editor.on('change',function() {
|
|
117
119
|
// Get an array of errors from the validator
|
|
118
120
|
var errors = editor.validate();
|
|
119
|
-
|
|
121
|
+
|
|
120
122
|
var indicator = document.getElementById('valid_indicator');
|
|
121
|
-
|
|
123
|
+
|
|
122
124
|
// Not valid
|
|
123
125
|
if(errors.length) {
|
|
124
126
|
indicator.className = 'label alert';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<title>Custom Editor Example</title>
|
|
6
|
+
<script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.js"></script>
|
|
7
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
|
|
8
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
|
|
12
|
+
<div class="container">
|
|
13
|
+
<h1>Custom Editor Example (switch)</h1>
|
|
14
|
+
<p>Bootstrap 5 style switch editor</p>
|
|
15
|
+
|
|
16
|
+
<div id='editor_holder'></div>
|
|
17
|
+
<br>
|
|
18
|
+
<br>
|
|
19
|
+
<p>Value:</p>
|
|
20
|
+
<pre id="value"></pre>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
/* --------------------------------------------- create custom editor class */
|
|
25
|
+
|
|
26
|
+
class CustomEditor extends JSONEditor.AbstractEditor {
|
|
27
|
+
build () {
|
|
28
|
+
super.build()
|
|
29
|
+
|
|
30
|
+
// control
|
|
31
|
+
this.control = document.createElement('div')
|
|
32
|
+
this.control.classList.add('form-check')
|
|
33
|
+
this.control.classList.add('form-switch')
|
|
34
|
+
|
|
35
|
+
// input
|
|
36
|
+
this.input = document.createElement('input')
|
|
37
|
+
this.input.setAttribute('type', 'checkbox')
|
|
38
|
+
this.input.setAttribute('id', this.path + 'test')
|
|
39
|
+
this.input.classList.add('form-check-input')
|
|
40
|
+
|
|
41
|
+
// label
|
|
42
|
+
this.label = document.createElement('label')
|
|
43
|
+
this.label.setAttribute('for', this.path + 'test')
|
|
44
|
+
this.label.classList.add('form-check-label')
|
|
45
|
+
this.label.textContent = this.schema.title
|
|
46
|
+
|
|
47
|
+
// appends
|
|
48
|
+
this.container.appendChild(this.control)
|
|
49
|
+
this.control.appendChild(this.input)
|
|
50
|
+
this.control.appendChild(this.label)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
postBuild () {
|
|
54
|
+
super.postBuild()
|
|
55
|
+
|
|
56
|
+
this.input.addEventListener('change', e => {
|
|
57
|
+
e.preventDefault()
|
|
58
|
+
e.stopPropagation()
|
|
59
|
+
this.value = e.currentTarget.checked
|
|
60
|
+
this.onChange(true)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* ---------------------------------------------- add class to editors list */
|
|
66
|
+
|
|
67
|
+
JSONEditor.defaults.editors.customEditor = CustomEditor
|
|
68
|
+
|
|
69
|
+
/* ----------------------------------------------------------- add resolver */
|
|
70
|
+
|
|
71
|
+
JSONEditor.defaults.resolvers.unshift(function (schema) {
|
|
72
|
+
if (schema.type === 'boolean' && schema.format === 'custom') {
|
|
73
|
+
return 'customEditor'
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
/* ----------------------------------------------------- instanciate editor */
|
|
78
|
+
|
|
79
|
+
var editor = new JSONEditor(document.getElementById('editor_holder'), {
|
|
80
|
+
schema: {
|
|
81
|
+
'type': 'boolean',
|
|
82
|
+
'format': 'custom',
|
|
83
|
+
'title': 'Custom'
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
editor.on('change', function () {
|
|
88
|
+
document.querySelector('#value').textContent = JSON.stringify(editor.getValue(), null, 2)
|
|
89
|
+
})
|
|
90
|
+
</script>
|
|
91
|
+
</body>
|
|
92
|
+
</html>
|
package/docs/datetime.html
CHANGED
|
@@ -257,7 +257,42 @@
|
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
},
|
|
260
|
-
|
|
260
|
+
"isofsdatetime": {
|
|
261
|
+
"type": "string",
|
|
262
|
+
"format": "datetime-local",
|
|
263
|
+
"title": "Datetime (String)",
|
|
264
|
+
"description": "ISO datetime-local field with flatpickr",
|
|
265
|
+
"options": {
|
|
266
|
+
"grid_columns": 4,
|
|
267
|
+
"inputAttributes": {
|
|
268
|
+
"placeholder": "Enter datetime"
|
|
269
|
+
},
|
|
270
|
+
"flatpickr": {
|
|
271
|
+
"dateFormat": "Z",
|
|
272
|
+
"wrap": true,
|
|
273
|
+
"allowInput": true,
|
|
274
|
+
"enableSeconds": true,
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
"isofidatetime": {
|
|
279
|
+
"type": "integer",
|
|
280
|
+
"format": "datetime-local",
|
|
281
|
+
"title": "Datetime (Integer)",
|
|
282
|
+
"description": "ISO datetime-local field with flatpickr",
|
|
283
|
+
"options": {
|
|
284
|
+
"grid_columns": 4,
|
|
285
|
+
"inputAttributes": {
|
|
286
|
+
"placeholder": "Enter datetime"
|
|
287
|
+
},
|
|
288
|
+
"flatpickr": {
|
|
289
|
+
"dateFormat": "Z",
|
|
290
|
+
"wrap": true,
|
|
291
|
+
"allowInput": true,
|
|
292
|
+
"enableSeconds": true,
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
},
|
|
261
296
|
"fisdatetime": {
|
|
262
297
|
"type": "string",
|
|
263
298
|
"format": "datetime-local",
|
|
@@ -302,4 +337,4 @@
|
|
|
302
337
|
</script>
|
|
303
338
|
</body>
|
|
304
339
|
|
|
305
|
-
</html>
|
|
340
|
+
</html>
|
package/docs/index.html
CHANGED
|
@@ -76,6 +76,8 @@
|
|
|
76
76
|
<option value='jqueryui'>jQuery UI</option>
|
|
77
77
|
<option value='openiconic'>Open Iconic</option>
|
|
78
78
|
<option value='spectre'>Spectre</option>
|
|
79
|
+
<option value='spectre'>Spectre</option>
|
|
80
|
+
<option value='bootstrap'>Bootstrap</option>
|
|
79
81
|
</select>
|
|
80
82
|
</div>
|
|
81
83
|
<div>
|
|
@@ -332,7 +334,8 @@
|
|
|
332
334
|
fontawesome5: 'https://use.fontawesome.com/releases/v5.6.1/css/all.css',
|
|
333
335
|
jqueryui: 'https://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css',
|
|
334
336
|
openiconic: 'https://cdnjs.cloudflare.com/ajax/libs/open-iconic/1.1.1/font/css/open-iconic.min.css',
|
|
335
|
-
spectre: 'https://unpkg.com/spectre.css/dist/spectre-icons.min.css'
|
|
337
|
+
spectre: 'https://unpkg.com/spectre.css/dist/spectre-icons.min.css',
|
|
338
|
+
bootstrap: 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css'
|
|
336
339
|
}
|
|
337
340
|
iconlibLink.href = iconLibMap[data.options.iconlib]
|
|
338
341
|
iconlibSelect.value = data.options.iconlib
|