@json-editor/json-editor 2.5.2 → 2.6.1
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/.eslintrc +5 -2
- package/.github/PULL_REQUEST_TEMPLATE.md +6 -6
- package/.github/workflows/build.yml +58 -0
- package/CHANGELOG.md +41 -1
- package/CONTRIBUTING.md +1 -1
- package/README.md +39 -4
- package/README_ADDON.md +65 -0
- package/config/codeceptjs_helpers.js +4 -0
- package/dist/jsoneditor.js +2 -2
- package/dist/nonmin/jsoneditor.js +3711 -3324
- 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/index.html +4 -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 +27 -26
- package/release-notes.md +9 -9
- package/src/core.js +1 -0
- package/src/defaults.js +182 -94
- package/src/editor.js +28 -9
- package/src/editors/array.js +20 -16
- package/src/editors/autocomplete.js +1 -0
- package/src/editors/base64.js +5 -4
- package/src/editors/button.js +2 -2
- package/src/editors/checkbox.js +3 -3
- package/src/editors/datetime.js +2 -2
- package/src/editors/info.js +1 -1
- package/src/editors/multiple.js +8 -2
- package/src/editors/multiselect.js +5 -3
- package/src/editors/object.js +35 -21
- package/src/editors/radio.js +9 -4
- package/src/editors/select.js +6 -6
- package/src/editors/signature.js +3 -2
- package/src/editors/starrating.js +5 -5
- package/src/editors/string.js +6 -4
- package/src/editors/table.js +24 -14
- package/src/editors/upload.js +4 -3
- package/src/editors/uuid.js +1 -1
- package/src/iconlibs/index.js +2 -0
- package/src/iconlibs/openiconic.js +28 -0
- package/src/schemaloader.js +112 -28
- package/src/theme.js +6 -3
- package/src/themes/bootstrap3.js +4 -4
- package/src/themes/bootstrap4.js +11 -3
- package/src/themes/html.js +1 -2
- package/src/themes/materialize.js +1 -1
- package/src/themes/spectre.js +11 -8
- package/src/themes/tailwind.js +1 -1
- package/src/validator.js +128 -16
- package/tests/codeceptjs/core_test.js +125 -1
- package/tests/codeceptjs/editors/array_test.js +13 -11
- package/tests/codeceptjs/editors/button_test.js +6 -1
- package/tests/codeceptjs/editors/issues/issue-gh-812_test.js +32 -0
- package/tests/codeceptjs/editors/number_test.js +1 -1
- package/tests/codeceptjs/editors/object_test.js +216 -100
- package/tests/codeceptjs/editors/programmatic-changes_test.js +3 -1
- package/tests/codeceptjs/editors/radio_test.js +10 -0
- package/tests/codeceptjs/editors/rating_test.js +10 -11
- package/tests/codeceptjs/editors/select_test.js +17 -15
- package/tests/codeceptjs/editors/stepper_test.js +13 -1
- package/tests/codeceptjs/editors/string_test.js +81 -80
- package/tests/codeceptjs/editors/table-confirm-delete_test.js +58 -56
- package/tests/codeceptjs/editors/tabs_test.js +12 -10
- package/tests/codeceptjs/editors/validation_test.js +10 -8
- package/tests/codeceptjs/meta-schema_test.js +13 -14
- package/tests/codeceptjs/schemaloader_test.js +13 -0
- package/tests/codeceptjs/steps_file.js +4 -3
- package/tests/codeceptjs/themes_test.js +31 -0
- package/tests/docker-compose.yml +4 -3
- package/tests/fixtures/validation.json +382 -1
- package/tests/pages/_demo.html +2 -0
- package/tests/pages/anyof.html +80 -0
- package/tests/pages/issues/issue-gh-812.html +110 -0
- package/tests/pages/issues/issue-gh-848.html +81 -0
- package/tests/pages/meta_schema.json +0 -1
- package/tests/pages/object-no-additional-properties.html +27 -12
- package/tests/pages/object-required-properties.html +43 -9
- package/tests/pages/object-show-opt-in.html +110 -0
- package/tests/pages/object-with-dependencies-array.html +56 -0
- package/tests/pages/oneof.html +103 -0
- package/tests/pages/read-only.html +19 -4
- package/tests/pages/stepper-manual.html +57 -0
- package/tests/pages/themes.html +2 -0
- package/tests/pages/translate-property.html +247 -0
- package/tests/pages/urn.html +93 -0
- package/tests/unit/core.spec.js +2 -0
- package/tests/unit/defaults.spec.js +4 -2
- package/tests/unit/editor.spec.js +2 -0
- package/tests/unit/editors/array.spec.js +86 -0
- package/tests/unit/editors/table.spec.js +91 -0
- package/tests/unit/schemaloader.spec.js +362 -3
- package/tests/unit/validator.spec.js +14 -2
|
@@ -16,27 +16,42 @@
|
|
|
16
16
|
var getValue = document.querySelector('.get-value');
|
|
17
17
|
|
|
18
18
|
var schema = {
|
|
19
|
-
"title": "
|
|
19
|
+
"title": "Additional properties",
|
|
20
20
|
"type": "object",
|
|
21
|
-
"required": [
|
|
22
|
-
"name"
|
|
23
|
-
],
|
|
24
21
|
"properties": {
|
|
25
|
-
"
|
|
26
|
-
"type": "
|
|
27
|
-
"
|
|
28
|
-
"
|
|
22
|
+
"aptrue": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"additionalProperties": true,
|
|
25
|
+
"description": "with additionalProperties: true",
|
|
26
|
+
"properties": {
|
|
27
|
+
"name": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"default": "albert"
|
|
30
|
+
},
|
|
31
|
+
"age": {
|
|
32
|
+
"type": "number",
|
|
33
|
+
"default": 15
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"apfalse": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"description": "without additionalProperties",
|
|
40
|
+
"properties": {
|
|
41
|
+
"name": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"default": "albert"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
29
46
|
}
|
|
30
47
|
}
|
|
31
48
|
};
|
|
32
49
|
|
|
33
50
|
var editor = new JSONEditor(container, {
|
|
34
51
|
schema: schema,
|
|
52
|
+
required_by_default: true,
|
|
35
53
|
no_additional_properties: true,
|
|
36
|
-
startval:{
|
|
37
|
-
"name": "Jeremy Dorn",
|
|
38
|
-
"age": 34
|
|
39
|
-
}
|
|
54
|
+
startval: {"aptrue":{"name":"Albert","age":0},"apfalse":{"name":"Albert","age":0}}
|
|
40
55
|
});
|
|
41
56
|
|
|
42
57
|
getValue.addEventListener('click', function () {
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
</div>
|
|
34
34
|
<textarea class="value" style="width: 100%; height: 600px;"></textarea>
|
|
35
35
|
<button class='get-value'>get value</button>
|
|
36
|
+
<button class='set-value'>set value</button>
|
|
37
|
+
<button class='set-empty-value'>set empty value</button>
|
|
36
38
|
<button class='get-formatted-value'>get formatted value</button>
|
|
37
39
|
</div>
|
|
38
40
|
</div>
|
|
@@ -42,6 +44,8 @@
|
|
|
42
44
|
var container = document.querySelector('.json-editor-container');
|
|
43
45
|
var value = document.querySelector('.value');
|
|
44
46
|
var getValue = document.querySelector('.get-value');
|
|
47
|
+
var setValue = document.querySelector('.set-value');
|
|
48
|
+
var setEmptyValue = document.querySelector('.set-empty-value');
|
|
45
49
|
var getFormattedValue = document.querySelector('.get-formatted-value');
|
|
46
50
|
|
|
47
51
|
var schema = {
|
|
@@ -58,22 +62,33 @@
|
|
|
58
62
|
"type": "string",
|
|
59
63
|
"minLength": 5,
|
|
60
64
|
"options": {
|
|
61
|
-
"grid_columns":
|
|
65
|
+
"grid_columns": 3
|
|
62
66
|
}
|
|
63
67
|
},
|
|
64
68
|
"number": {
|
|
65
69
|
"title": "number",
|
|
66
70
|
"type": "number",
|
|
67
71
|
"options": {
|
|
68
|
-
"grid_columns":
|
|
72
|
+
"grid_columns": 3
|
|
69
73
|
}
|
|
70
74
|
},
|
|
71
75
|
"boolean": {
|
|
72
76
|
"title": "boolean",
|
|
73
77
|
"type": "boolean",
|
|
74
78
|
"options": {
|
|
75
|
-
"grid_columns":
|
|
76
|
-
|
|
79
|
+
"grid_columns": 3,
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"radio": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"format": "radio",
|
|
85
|
+
"title": "Radio Buttons",
|
|
86
|
+
"enum": [
|
|
87
|
+
"Home",
|
|
88
|
+
"Work"
|
|
89
|
+
],
|
|
90
|
+
"options": {
|
|
91
|
+
"grid_columns": 3
|
|
77
92
|
}
|
|
78
93
|
},
|
|
79
94
|
"array": {
|
|
@@ -102,21 +117,33 @@
|
|
|
102
117
|
"title": "string",
|
|
103
118
|
"type": "string",
|
|
104
119
|
"options": {
|
|
105
|
-
"grid_columns":
|
|
120
|
+
"grid_columns": 3
|
|
106
121
|
}
|
|
107
122
|
},
|
|
108
123
|
"number": {
|
|
109
124
|
"title": "number",
|
|
110
125
|
"type": "number",
|
|
111
126
|
"options": {
|
|
112
|
-
"grid_columns":
|
|
127
|
+
"grid_columns": 3
|
|
113
128
|
}
|
|
114
129
|
},
|
|
115
130
|
"boolean": {
|
|
116
131
|
"title": "boolean",
|
|
117
132
|
"type": "boolean",
|
|
118
133
|
"options": {
|
|
119
|
-
"grid_columns":
|
|
134
|
+
"grid_columns": 3
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"radio": {
|
|
138
|
+
"type": "string",
|
|
139
|
+
"format": "radio",
|
|
140
|
+
"title": "Radio Buttons",
|
|
141
|
+
"enum": [
|
|
142
|
+
"Home",
|
|
143
|
+
"Work"
|
|
144
|
+
],
|
|
145
|
+
"options": {
|
|
146
|
+
"grid_columns": 3
|
|
120
147
|
}
|
|
121
148
|
},
|
|
122
149
|
"array": {
|
|
@@ -196,8 +223,7 @@
|
|
|
196
223
|
editor = new JSONEditor(container, {
|
|
197
224
|
schema: schema,
|
|
198
225
|
theme: 'bootstrap4',
|
|
199
|
-
show_opt_in: true
|
|
200
|
-
// display_required_only: true
|
|
226
|
+
show_opt_in: true
|
|
201
227
|
});
|
|
202
228
|
}
|
|
203
229
|
|
|
@@ -213,6 +239,14 @@
|
|
|
213
239
|
value.value = JSON.stringify(editor.getValue());
|
|
214
240
|
});
|
|
215
241
|
|
|
242
|
+
setValue.addEventListener('click', function () {
|
|
243
|
+
editor.setValue({"string":"test","number":0,"boolean":false,"array":["test"],"object":{"string":"","number":10,"boolean":true,"array":[]}})
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
setEmptyValue.addEventListener('click', function () {
|
|
247
|
+
editor.setValue({})
|
|
248
|
+
});
|
|
249
|
+
|
|
216
250
|
getFormattedValue.addEventListener('click', function () {
|
|
217
251
|
value.value = JSON.stringify(editor.getValue(), null, 2);
|
|
218
252
|
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Object Required Properties</title>
|
|
5
|
+
<meta charset="utf-8"/>
|
|
6
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
7
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<div class="container">
|
|
12
|
+
<label for="show-opt-in">
|
|
13
|
+
<span>show_opt_in</span>
|
|
14
|
+
<input id="show-opt-in" type="checkbox">
|
|
15
|
+
</label>
|
|
16
|
+
<div id='json-editor-container'></div>
|
|
17
|
+
<label for="value"></label>
|
|
18
|
+
<textarea id="value" class="value" style="width: 100%; height: 300px;"></textarea>
|
|
19
|
+
<button id='get-value'>get value</button>
|
|
20
|
+
<button id='get-formatted-value'>get formatted value</button>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
var container = document.querySelector('#json-editor-container')
|
|
25
|
+
var value = document.querySelector('#value')
|
|
26
|
+
var getValue = document.querySelector('#get-value')
|
|
27
|
+
var getFormattedValue = document.querySelector('#get-formatted-value')
|
|
28
|
+
var showOptIn = document.querySelector('#show-opt-in')
|
|
29
|
+
var schema = {
|
|
30
|
+
'type': 'object',
|
|
31
|
+
'title': 'option_show_opt_in_false',
|
|
32
|
+
'options': {
|
|
33
|
+
'show_opt_in': false
|
|
34
|
+
},
|
|
35
|
+
'properties': {
|
|
36
|
+
'option_show_opt_in_undefined': {
|
|
37
|
+
'type': 'object',
|
|
38
|
+
'title': 'option_show_opt_in_undefined',
|
|
39
|
+
'properties': {
|
|
40
|
+
'string': {
|
|
41
|
+
'title': 'optional_string',
|
|
42
|
+
'type': 'string'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
'option_show_opt_in_true': {
|
|
47
|
+
'type': 'object',
|
|
48
|
+
'title': 'option_show_opt_in_true',
|
|
49
|
+
'options': {
|
|
50
|
+
'show_opt_in': true
|
|
51
|
+
},
|
|
52
|
+
'properties': {
|
|
53
|
+
'string': {
|
|
54
|
+
'title': 'optional_string',
|
|
55
|
+
'type': 'string'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
'option_show_opt_in_false': {
|
|
60
|
+
'type': 'object',
|
|
61
|
+
'title': 'option_show_opt_in_false',
|
|
62
|
+
'options': {
|
|
63
|
+
'show_opt_in': false
|
|
64
|
+
},
|
|
65
|
+
'properties': {
|
|
66
|
+
'string': {
|
|
67
|
+
'title': 'optional_string',
|
|
68
|
+
'type': 'string'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
window.addEventListener('DOMContentLoaded', function () {
|
|
76
|
+
|
|
77
|
+
var editor = null
|
|
78
|
+
|
|
79
|
+
var initJSONEditor = function (show_opt_in) {
|
|
80
|
+
if (editor) {
|
|
81
|
+
editor.destroy()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
editor = new JSONEditor(container, {
|
|
85
|
+
schema: schema,
|
|
86
|
+
theme: 'bootstrap4',
|
|
87
|
+
disable_collapse: true,
|
|
88
|
+
disable_edit_json: true,
|
|
89
|
+
show_opt_in: show_opt_in || false
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
initJSONEditor(false)
|
|
94
|
+
|
|
95
|
+
showOptIn.addEventListener('click', function (event) {
|
|
96
|
+
initJSONEditor(event.target.checked)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
getValue.addEventListener('click', function () {
|
|
100
|
+
value.value = JSON.stringify(editor.getValue())
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
getFormattedValue.addEventListener('click', function () {
|
|
104
|
+
value.value = JSON.stringify(editor.getValue(), null, 2)
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
</body>
|
|
110
|
+
</html>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
6
|
+
</head>
|
|
7
|
+
|
|
8
|
+
<body>
|
|
9
|
+
<div id="editor"></div>
|
|
10
|
+
<script>
|
|
11
|
+
const schema = {
|
|
12
|
+
'title': 'Test',
|
|
13
|
+
'type': 'object',
|
|
14
|
+
'properties': {
|
|
15
|
+
'question_1': {
|
|
16
|
+
'type': 'string',
|
|
17
|
+
'title': 'Question 1',
|
|
18
|
+
'enum': ['a', 'b', 'c', 'd']
|
|
19
|
+
},
|
|
20
|
+
'question_1_feedback': {
|
|
21
|
+
'type': 'info',
|
|
22
|
+
'title': 'Question 1 is correct',
|
|
23
|
+
"options": {
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"question_1": ['b', 'd']
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
'question_2': {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"uniqueItems": true,
|
|
32
|
+
'title': 'Question 2',
|
|
33
|
+
"items": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
'enum': ['a', 'b', 'c', 'd']
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
'question_2_feedback': {
|
|
39
|
+
'type': 'info',
|
|
40
|
+
'title': 'Question 2 is correct',
|
|
41
|
+
"options": {
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"question_2": [['b', 'c']]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const editor = new JSONEditor(document.getElementById('editor'), {
|
|
51
|
+
schema: schema,
|
|
52
|
+
show_errors: 'always'
|
|
53
|
+
});
|
|
54
|
+
</script>
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<title>oneOf</title>
|
|
6
|
+
<link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
|
7
|
+
<link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
|
|
8
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
|
|
12
|
+
<div class="container">
|
|
13
|
+
<textarea class="value form-control" rows="10"></textarea>
|
|
14
|
+
<button class='get-value'>Get Value</button>
|
|
15
|
+
<button class='set-value'>Set Value</button>
|
|
16
|
+
<div class='json-editor-container'></div>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
var jsonEditorContainer = document.querySelector('.json-editor-container');
|
|
22
|
+
var value = document.querySelector('.value');
|
|
23
|
+
|
|
24
|
+
var schema = {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"properties": {
|
|
27
|
+
"p4": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"minLength": 4
|
|
30
|
+
},
|
|
31
|
+
"p5": {
|
|
32
|
+
"oneOf": [
|
|
33
|
+
{
|
|
34
|
+
"type": "object",
|
|
35
|
+
"properties": {
|
|
36
|
+
"p1": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"minLength": 4
|
|
39
|
+
},
|
|
40
|
+
"p2": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"minLength": 4
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"required": [
|
|
46
|
+
"p1",
|
|
47
|
+
"p2"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"type": "object",
|
|
52
|
+
"properties": {
|
|
53
|
+
"p3": {
|
|
54
|
+
"type": "number"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": [
|
|
58
|
+
"p3"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"options": {
|
|
63
|
+
"keep_oneof_values": false
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"required": [
|
|
68
|
+
"p4",
|
|
69
|
+
"p5"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var editor = new JSONEditor(jsonEditorContainer, {
|
|
74
|
+
schema: schema,
|
|
75
|
+
theme: 'bootstrap4',
|
|
76
|
+
show_errors: 'always',
|
|
77
|
+
iconlib: 'fontawesome5',
|
|
78
|
+
object_layout: 'normal',
|
|
79
|
+
disable_collapse: true,
|
|
80
|
+
disable_edit_json: true,
|
|
81
|
+
disable_properties: true,
|
|
82
|
+
use_default_values: false,
|
|
83
|
+
required_by_default: true,
|
|
84
|
+
disable_array_reorder: true,
|
|
85
|
+
disable_array_delete_all_rows: true,
|
|
86
|
+
disable_array_delete_last_row: true,
|
|
87
|
+
keep_oneof_values: false,
|
|
88
|
+
no_additional_properties: true
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
document.querySelector('.get-value').addEventListener('click', function () {
|
|
92
|
+
value.value = JSON.stringify(editor.getValue());
|
|
93
|
+
console.log(editor.getValue());
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
document.querySelector('.set-value').addEventListener('click', function () {
|
|
97
|
+
editor.setValue({number_range: 2})
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
</body>
|
|
103
|
+
</html>
|
|
@@ -55,6 +55,22 @@
|
|
|
55
55
|
"type": "boolean",
|
|
56
56
|
"readOnly": true
|
|
57
57
|
},
|
|
58
|
+
checkbox: {
|
|
59
|
+
"title": "checkbox",
|
|
60
|
+
"format": "checkbox",
|
|
61
|
+
"type": "boolean",
|
|
62
|
+
"readOnly": true
|
|
63
|
+
},
|
|
64
|
+
radio: {
|
|
65
|
+
"title": "radio",
|
|
66
|
+
"format": "radio",
|
|
67
|
+
"type": "string",
|
|
68
|
+
"enum": [
|
|
69
|
+
"yes",
|
|
70
|
+
"no"
|
|
71
|
+
],
|
|
72
|
+
"readOnly": true
|
|
73
|
+
},
|
|
58
74
|
rating: {
|
|
59
75
|
"title": "rating",
|
|
60
76
|
"readOnly": true,
|
|
@@ -63,10 +79,9 @@
|
|
|
63
79
|
"maximum": "5",
|
|
64
80
|
"exclusiveMaximum": false
|
|
65
81
|
},
|
|
66
|
-
|
|
67
|
-
"title": "
|
|
68
|
-
"format": "
|
|
69
|
-
"type": "boolean",
|
|
82
|
+
button: {
|
|
83
|
+
"title": "button",
|
|
84
|
+
"format": "button",
|
|
70
85
|
"readOnly": true
|
|
71
86
|
}
|
|
72
87
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<title>Stepper</title>
|
|
6
|
+
<link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
|
7
|
+
<link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
|
|
8
|
+
<script src="https://cdn.jsdelivr.net/npm/mathjs@5.3.1/dist/math.min.js" class="external_mathjs"></script>
|
|
9
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
|
|
13
|
+
<div class="container">
|
|
14
|
+
<textarea class="value form-control" rows="10"></textarea>
|
|
15
|
+
<button class='get-value'>Get Value</button>
|
|
16
|
+
<button class='set-value'>Set Value</button>
|
|
17
|
+
<div class='json-editor-container'></div>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
var jsonEditorContainer = document.querySelector('.json-editor-container');
|
|
23
|
+
var value = document.querySelector('.value');
|
|
24
|
+
|
|
25
|
+
var schema = {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"title": "range",
|
|
28
|
+
"properties": {
|
|
29
|
+
"stepper": {
|
|
30
|
+
'type': 'integer',
|
|
31
|
+
'format': 'stepper',
|
|
32
|
+
"default": ""
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var editor = new JSONEditor(jsonEditorContainer, {
|
|
38
|
+
schema: schema,
|
|
39
|
+
theme: 'bootstrap4',
|
|
40
|
+
use_default_values: false,
|
|
41
|
+
required_by_default: true,
|
|
42
|
+
show_errors: 'always'
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
document.querySelector('.get-value').addEventListener('click', function () {
|
|
46
|
+
value.value = JSON.stringify(editor.getValue());
|
|
47
|
+
console.log(editor.getValue());
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
document.querySelector('.set-value').addEventListener('click', function () {
|
|
51
|
+
editor.setValue({number_range: 2})
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
package/tests/pages/themes.html
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
<option value='foundation3'>Foundation 3</option>
|
|
39
39
|
<option value='jqueryui'>jQuery UI</option>
|
|
40
40
|
<option value='materialicons'>Material icons</option>
|
|
41
|
+
<option value='openiconic'>Open Iconic</option>
|
|
41
42
|
<option value='spectre'>Spectre</option>
|
|
42
43
|
</select>
|
|
43
44
|
</div>
|
|
@@ -510,6 +511,7 @@
|
|
|
510
511
|
foundation3: 'https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css',
|
|
511
512
|
jqueryui: 'https://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css',
|
|
512
513
|
materialicons: 'https://fonts.googleapis.com/icon?family=Material+Icons',
|
|
514
|
+
openiconic: 'https://cdnjs.cloudflare.com/ajax/libs/open-iconic/1.1.1/font/css/open-iconic.min.css',
|
|
513
515
|
spectre: 'https://unpkg.com/spectre.css/dist/spectre-icons.min.css'
|
|
514
516
|
};
|
|
515
517
|
|