@wirenboard/json-editor 2.5.3-wb13
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/.env-dist +2 -0
- package/.eslintrc +7 -0
- package/.gitattributes +1 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +9 -0
- package/.github/issue_template +25 -0
- package/.github/workflows/build.yml +58 -0
- package/.travis.yml +70 -0
- package/CHANGELOG.md +915 -0
- package/CONTRIBUTING.md +92 -0
- package/LICENSE +20 -0
- package/Makefile +26 -0
- package/README.md +1646 -0
- package/README_ADDON.md +573 -0
- package/UPGRADING.md +46 -0
- package/build/CssToJson.js +55 -0
- package/codecept.conf.js +35 -0
- package/config/.eslintrc +7 -0
- package/config/codeceptjs_helpers.js +139 -0
- package/config/helpers.js +10 -0
- package/config/karma.conf.js +93 -0
- package/config/readme.md +31 -0
- package/config/webpack.common.js +75 -0
- package/config/webpack.dev.js +15 -0
- package/config/webpack.nonmin.js +19 -0
- package/config/webpack.prod.js +25 -0
- package/dist/jsoneditor.js +14 -0
- package/dist/nonmin/jsoneditor.js +29097 -0
- package/dist/nonmin/jsoneditor.js.map +1 -0
- package/docs/ace_editor.html +56 -0
- package/docs/advanced.html +136 -0
- package/docs/basic.html +63 -0
- package/docs/basic_person.json +26 -0
- package/docs/choices.html +86 -0
- package/docs/cleave.html +132 -0
- package/docs/colorpicker.html +194 -0
- package/docs/css_integration.html +135 -0
- package/docs/datetime.html +305 -0
- package/docs/describedby.html +161 -0
- package/docs/enumsource.html +67 -0
- package/docs/images/categoriesDemo.png +0 -0
- package/docs/images/inheritance_tree.png +0 -0
- package/docs/images/jsoneditor.png +0 -0
- package/docs/imask.html +192 -0
- package/docs/index.html +579 -0
- package/docs/materialize_css.html +164 -0
- package/docs/meta_schema.json +705 -0
- package/docs/multiple_upload_base64.html +65 -0
- package/docs/person.json +73 -0
- package/docs/polyfills/assign.js +29 -0
- package/docs/radio.html +156 -0
- package/docs/recursive.html +170 -0
- package/docs/select2.html +99 -0
- package/docs/selectize.html +100 -0
- package/docs/signature.html +42 -0
- package/docs/starrating.html +137 -0
- package/docs/upload.html +131 -0
- package/docs/uuid.html +70 -0
- package/docs/wysiwyg.html +56 -0
- package/jasmine.json +11 -0
- package/json-editor-json-editor-2.5.3-wb13.tgz +0 -0
- package/package.json +100 -0
- package/release-notes.md +88 -0
- package/src/core.js +412 -0
- package/src/defaults.js +402 -0
- package/src/editor.js +707 -0
- package/src/editors/ace.js +89 -0
- package/src/editors/array/choices.js +103 -0
- package/src/editors/array/select2.js +110 -0
- package/src/editors/array/selectize.js +103 -0
- package/src/editors/array.css +9 -0
- package/src/editors/array.css.js +3 -0
- package/src/editors/array.js +818 -0
- package/src/editors/autocomplete.js +58 -0
- package/src/editors/base64.js +157 -0
- package/src/editors/button.js +97 -0
- package/src/editors/checkbox.js +95 -0
- package/src/editors/choices.css +3 -0
- package/src/editors/choices.css.js +3 -0
- package/src/editors/choices.js +69 -0
- package/src/editors/colorpicker.js +103 -0
- package/src/editors/datetime.js +141 -0
- package/src/editors/describedby.js +188 -0
- package/src/editors/enum.js +136 -0
- package/src/editors/hidden.js +127 -0
- package/src/editors/index.js +81 -0
- package/src/editors/info.js +20 -0
- package/src/editors/integer.js +19 -0
- package/src/editors/ip.js +36 -0
- package/src/editors/jodit.js +64 -0
- package/src/editors/multiple.js +409 -0
- package/src/editors/multiselect.js +218 -0
- package/src/editors/null.js +18 -0
- package/src/editors/number.js +51 -0
- package/src/editors/object.css +41 -0
- package/src/editors/object.css.js +3 -0
- package/src/editors/object.js +1290 -0
- package/src/editors/radio.js +111 -0
- package/src/editors/sceditor.js +72 -0
- package/src/editors/select.js +370 -0
- package/src/editors/select2.js +110 -0
- package/src/editors/selectize.js +112 -0
- package/src/editors/signature.js +113 -0
- package/src/editors/simplemde.js +100 -0
- package/src/editors/starrating.css +52 -0
- package/src/editors/starrating.css.js +3 -0
- package/src/editors/starrating.js +135 -0
- package/src/editors/stepper.js +27 -0
- package/src/editors/string.js +372 -0
- package/src/editors/table.js +516 -0
- package/src/editors/upload.js +321 -0
- package/src/editors/uuid.js +56 -0
- package/src/iconlib.js +24 -0
- package/src/iconlibs/bootstrap2.js +28 -0
- package/src/iconlibs/bootstrap3.js +28 -0
- package/src/iconlibs/fontawesome3.js +28 -0
- package/src/iconlibs/fontawesome4.js +28 -0
- package/src/iconlibs/fontawesome5.js +28 -0
- package/src/iconlibs/foundation2.js +24 -0
- package/src/iconlibs/foundation3.js +28 -0
- package/src/iconlibs/index.js +25 -0
- package/src/iconlibs/jqueryui.js +28 -0
- package/src/iconlibs/materialicons.js +49 -0
- package/src/iconlibs/openiconic.js +28 -0
- package/src/iconlibs/spectre.js +28 -0
- package/src/resolvers.js +128 -0
- package/src/schemaloader.js +408 -0
- package/src/style.css +150 -0
- package/src/style.css.js +3 -0
- package/src/templates/default.js +52 -0
- package/src/templates/ejs.js +13 -0
- package/src/templates/handlebars.js +1 -0
- package/src/templates/hogan.js +10 -0
- package/src/templates/index.js +21 -0
- package/src/templates/lodash.js +9 -0
- package/src/templates/markup.js +9 -0
- package/src/templates/mustache.js +9 -0
- package/src/templates/swig.js +1 -0
- package/src/templates/underscore.js +9 -0
- package/src/theme.js +659 -0
- package/src/themes/barebones.css +35 -0
- package/src/themes/barebones.css.js +3 -0
- package/src/themes/barebones.js +28 -0
- package/src/themes/bootstrap2.js +319 -0
- package/src/themes/bootstrap3.css +0 -0
- package/src/themes/bootstrap3.css.js +3 -0
- package/src/themes/bootstrap3.js +315 -0
- package/src/themes/bootstrap4.css +89 -0
- package/src/themes/bootstrap4.css.js +3 -0
- package/src/themes/bootstrap4.js +690 -0
- package/src/themes/bootstrap5.css.js +3 -0
- package/src/themes/foundation.js +569 -0
- package/src/themes/html.css +60 -0
- package/src/themes/html.css.js +3 -0
- package/src/themes/html.js +71 -0
- package/src/themes/index.js +28 -0
- package/src/themes/jqueryui.js +198 -0
- package/src/themes/materialize.js +426 -0
- package/src/themes/spectre.css +208 -0
- package/src/themes/spectre.css.js +3 -0
- package/src/themes/spectre.js +406 -0
- package/src/themes/tailwind.css +249 -0
- package/src/themes/tailwind.css.js +3 -0
- package/src/themes/tailwind.js +443 -0
- package/src/utilities.js +138 -0
- package/src/validator.js +877 -0
- package/src/validators/ip-validator.js +51 -0
- package/tests/Dockerfile +3 -0
- package/tests/README.md +48 -0
- package/tests/codeceptjs/codecept.json +42 -0
- package/tests/codeceptjs/constrains/if-then-else_test.js +143 -0
- package/tests/codeceptjs/core_test.js +217 -0
- package/tests/codeceptjs/editors/advanced_test.js +13 -0
- package/tests/codeceptjs/editors/array_any_of_test.js +50 -0
- package/tests/codeceptjs/editors/array_test.js +900 -0
- package/tests/codeceptjs/editors/button_test.js +35 -0
- package/tests/codeceptjs/editors/checkbox_test.js +21 -0
- package/tests/codeceptjs/editors/colorpicker_test.js +27 -0
- package/tests/codeceptjs/editors/datetime_test.js +33 -0
- package/tests/codeceptjs/editors/inheritance_test.js +11 -0
- package/tests/codeceptjs/editors/integer_test.js +84 -0
- package/tests/codeceptjs/editors/issues/issue-gh-812_test.js +32 -0
- package/tests/codeceptjs/editors/jodit_test.js +24 -0
- package/tests/codeceptjs/editors/multiselect_test.js +8 -0
- package/tests/codeceptjs/editors/number_test.js +82 -0
- package/tests/codeceptjs/editors/object_test.js +204 -0
- package/tests/codeceptjs/editors/option-no_default_values_test.js +42 -0
- package/tests/codeceptjs/editors/programmatic-changes_test.js +20 -0
- package/tests/codeceptjs/editors/radio_test.js +10 -0
- package/tests/codeceptjs/editors/rating_test.js +13 -0
- package/tests/codeceptjs/editors/select_test.js +22 -0
- package/tests/codeceptjs/editors/stepper_test.js +27 -0
- package/tests/codeceptjs/editors/string_test.js +118 -0
- package/tests/codeceptjs/editors/table-confirm-delete_test.js +67 -0
- package/tests/codeceptjs/editors/tabs_test.js +14 -0
- package/tests/codeceptjs/editors/uuid_test.js +21 -0
- package/tests/codeceptjs/editors/validation_test.js +14 -0
- package/tests/codeceptjs/meta-schema_test.js +17 -0
- package/tests/codeceptjs/schemaloader_test.js +13 -0
- package/tests/codeceptjs/steps.d.ts +13 -0
- package/tests/codeceptjs/steps_file.js +12 -0
- package/tests/codeceptjs/themes_test.js +519 -0
- package/tests/docker-compose.yml +34 -0
- package/tests/fixtures/basic_person.json +26 -0
- package/tests/fixtures/nested_object.json +26 -0
- package/tests/fixtures/person.json +55 -0
- package/tests/fixtures/recursive.json +8 -0
- package/tests/fixtures/some_types.json +32 -0
- package/tests/fixtures/string.json +3 -0
- package/tests/fixtures/validation.json +1140 -0
- package/tests/pages/_demo.html +475 -0
- package/tests/pages/advanced.html +137 -0
- package/tests/pages/anyof.html +80 -0
- package/tests/pages/array-anyof.html +142 -0
- package/tests/pages/array-checkboxes.html +41 -0
- package/tests/pages/array-choices.html +45 -0
- package/tests/pages/array-integers.html +37 -0
- package/tests/pages/array-move-events.html +61 -0
- package/tests/pages/array-multiselects.html +42 -0
- package/tests/pages/array-nested-arrays.html +40 -0
- package/tests/pages/array-numbers.html +37 -0
- package/tests/pages/array-objects.html +42 -0
- package/tests/pages/array-ratings.html +40 -0
- package/tests/pages/array-selectize.html +51 -0
- package/tests/pages/array-selects.html +36 -0
- package/tests/pages/array-strings.html +36 -0
- package/tests/pages/array.html +42 -0
- package/tests/pages/assets/pages.css +130 -0
- package/tests/pages/button-callbacks.html +77 -0
- package/tests/pages/checkbox-labels.html +114 -0
- package/tests/pages/colorpicker-no-3rd-party.html +43 -0
- package/tests/pages/colorpicker-use-vanilla-picker.html +50 -0
- package/tests/pages/core.html +118 -0
- package/tests/pages/datetime.html +76 -0
- package/tests/pages/form-name.html +108 -0
- package/tests/pages/grid-strict.html +311 -0
- package/tests/pages/grid.html +284 -0
- package/tests/pages/if-then-else-allOf.html +117 -0
- package/tests/pages/inheritance.html +76 -0
- package/tests/pages/integer.html +68 -0
- package/tests/pages/issues/_template.html +50 -0
- package/tests/pages/issues/issue-gh-812.html +110 -0
- package/tests/pages/issues/issue-gh-823-meta-schema.html +35 -0
- package/tests/pages/issues/issue-gh-848.html +81 -0
- package/tests/pages/meta_schema.json +705 -0
- package/tests/pages/number.html +89 -0
- package/tests/pages/object-no-additional-properties.html +65 -0
- package/tests/pages/object-no-duplicated-id.html +68 -0
- package/tests/pages/object-required-properties.html +236 -0
- package/tests/pages/object-with-dependencies-array.html +46 -0
- package/tests/pages/object-with-dependencies.html +60 -0
- package/tests/pages/object.html +79 -0
- package/tests/pages/oneof.html +103 -0
- package/tests/pages/option-no_default_values.html +58 -0
- package/tests/pages/programmatic-changes.html +120 -0
- package/tests/pages/read-only.html +105 -0
- package/tests/pages/select.html +41 -0
- package/tests/pages/stepper.html +59 -0
- package/tests/pages/string-ace-editor.html +52 -0
- package/tests/pages/string-cleave.html +46 -0
- package/tests/pages/string-custom-attributes.html +62 -0
- package/tests/pages/string-formats.html +52 -0
- package/tests/pages/string-formats2.html +57 -0
- package/tests/pages/string-jodit-editor.html +49 -0
- package/tests/pages/string-sceditor.html +62 -0
- package/tests/pages/table-move-events.html +56 -0
- package/tests/pages/table.html +46 -0
- package/tests/pages/tabs.html +131 -0
- package/tests/pages/themes.html +527 -0
- package/tests/pages/translate-property.html +247 -0
- package/tests/pages/urn.html +93 -0
- package/tests/pages/uuid.html +72 -0
- package/tests/pages/validation.html +99 -0
- package/tests/unit/.eslintrc +8 -0
- package/tests/unit/core.spec.js +309 -0
- package/tests/unit/defaults.spec.js +40 -0
- package/tests/unit/editor.spec.js +160 -0
- package/tests/unit/editors/array.spec.js +86 -0
- package/tests/unit/editors/object.spec.js +79 -0
- package/tests/unit/editors/table.spec.js +91 -0
- package/tests/unit/readme.md +35 -0
- package/tests/unit/schemaloader.spec.js +498 -0
- package/tests/unit/validator.spec.js +94 -0
- package/tests/unit/validators/ip-validator.spec.js +62 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<title>Number</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
|
+
<textarea class="value" cols="30" 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
|
+
|
|
18
|
+
<script>
|
|
19
|
+
var jsonEditorContainer = document.querySelector('.json-editor-container');
|
|
20
|
+
var value = document.querySelector('.value');
|
|
21
|
+
|
|
22
|
+
var schema = {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"title": "range",
|
|
25
|
+
"properties": {
|
|
26
|
+
"number": {
|
|
27
|
+
"title": "number",
|
|
28
|
+
"type": "number",
|
|
29
|
+
"default": 5.75,
|
|
30
|
+
"minimum": 1,
|
|
31
|
+
"maximum": 10
|
|
32
|
+
},
|
|
33
|
+
"number_number": {
|
|
34
|
+
"title": "number number",
|
|
35
|
+
"type": "number",
|
|
36
|
+
"format": "number",
|
|
37
|
+
"default": 5.75,
|
|
38
|
+
"minimum": 1,
|
|
39
|
+
"maximum": 10,
|
|
40
|
+
"step": 0.25
|
|
41
|
+
},
|
|
42
|
+
"number_range": {
|
|
43
|
+
"title": "number range",
|
|
44
|
+
"type": "number",
|
|
45
|
+
"format": "range",
|
|
46
|
+
"default": 5.75,
|
|
47
|
+
"minimum": 1,
|
|
48
|
+
"maximum": 10,
|
|
49
|
+
"step": 0.25
|
|
50
|
+
},
|
|
51
|
+
"stepper_number": {
|
|
52
|
+
"title": "stepper number",
|
|
53
|
+
"format": "stepper",
|
|
54
|
+
"type": "number",
|
|
55
|
+
"minimum": 1,
|
|
56
|
+
"maximum": 10,
|
|
57
|
+
"step": 0.25
|
|
58
|
+
},
|
|
59
|
+
"stepper_integer": {
|
|
60
|
+
"title": "stepper integer",
|
|
61
|
+
"format": "stepper",
|
|
62
|
+
"type": "integer",
|
|
63
|
+
"minimum": 1,
|
|
64
|
+
"maximum": 10,
|
|
65
|
+
"step": 0.25
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var editor = new JSONEditor(jsonEditorContainer, {
|
|
71
|
+
schema: schema,
|
|
72
|
+
theme: 'bootstrap4',
|
|
73
|
+
use_default_values: false,
|
|
74
|
+
show_errors: 'always'
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
document.querySelector('.get-value').addEventListener('click', function () {
|
|
78
|
+
value.value = JSON.stringify(editor.getValue());
|
|
79
|
+
console.log(editor.getValue());
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
document.querySelector('.set-value').addEventListener('click', function () {
|
|
83
|
+
editor.setValue({number_range: 2})
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
</body>
|
|
89
|
+
</html>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
|
|
9
|
+
<textarea class="value" cols="30" rows="10"></textarea>
|
|
10
|
+
<button class='get-value'>get value</button>
|
|
11
|
+
<div class='container'></div>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
var container = document.querySelector('.container');
|
|
15
|
+
var value = document.querySelector('.value');
|
|
16
|
+
var getValue = document.querySelector('.get-value');
|
|
17
|
+
|
|
18
|
+
var schema = {
|
|
19
|
+
"title": "Additional properties",
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
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
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var editor = new JSONEditor(container, {
|
|
51
|
+
schema: schema,
|
|
52
|
+
required_by_default: true,
|
|
53
|
+
no_additional_properties: true,
|
|
54
|
+
startval: {"aptrue":{"name":"Albert","age":0},"apfalse":{"name":"Albert","age":0}}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
getValue.addEventListener('click', function () {
|
|
58
|
+
value.value = JSON.stringify(editor.getValue());
|
|
59
|
+
console.log(editor.getValue());
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
</body>
|
|
65
|
+
</html>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
6
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
|
7
|
+
<title>object-no-duplicated-id</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<div class="container">
|
|
12
|
+
<div class="form-group">
|
|
13
|
+
<textarea id="value" class="form-control" rows="10"></textarea>
|
|
14
|
+
</div>
|
|
15
|
+
<button id="get-value" class='btn btn-secondary'>get value</button>
|
|
16
|
+
<hr>
|
|
17
|
+
<div id='form-container'></div>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
var formContainer = document.querySelector('#form-container');
|
|
22
|
+
var value = document.querySelector('#value');
|
|
23
|
+
var getValue = document.querySelector('#get-value');
|
|
24
|
+
|
|
25
|
+
var schema = {
|
|
26
|
+
"description": "A representation of a person, company, organization, or place",
|
|
27
|
+
"type": "object",
|
|
28
|
+
"properties": {
|
|
29
|
+
"cat": {
|
|
30
|
+
"title": "Cat",
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": {
|
|
33
|
+
"title": {
|
|
34
|
+
"title": "i am actually a cat",
|
|
35
|
+
"type": "string",
|
|
36
|
+
"format": "textarea"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"dog": {
|
|
41
|
+
"title": "Cat",
|
|
42
|
+
"type": "object",
|
|
43
|
+
"properties": {
|
|
44
|
+
"title": {
|
|
45
|
+
"title": "i am actually a dog",
|
|
46
|
+
"type": "string",
|
|
47
|
+
"format": "textarea"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var editor = new JSONEditor(formContainer, {
|
|
55
|
+
schema: schema,
|
|
56
|
+
theme: 'bootstrap4',
|
|
57
|
+
show_errors: 'always'
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
getValue.addEventListener('click', function () {
|
|
61
|
+
value.value = JSON.stringify(editor.getValue());
|
|
62
|
+
console.log(editor.getValue());
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
</body>
|
|
68
|
+
</html>
|
|
@@ -0,0 +1,236 @@
|
|
|
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' id='theme_stylesheet'>
|
|
8
|
+
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
|
|
12
|
+
<div class="container">
|
|
13
|
+
<div class="row">
|
|
14
|
+
<div class="col-md-8">
|
|
15
|
+
<div class='json-editor-container'></div>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="col-md-4">
|
|
18
|
+
<div>
|
|
19
|
+
<label>CSS Framework</label>
|
|
20
|
+
<select id='theme_switcher' class='form-control browser-default'>
|
|
21
|
+
<option value='barebones'>Barebones</option>
|
|
22
|
+
<option value='html'>HTML</option>
|
|
23
|
+
<option value='jqueryui'>jQuery UI</option>
|
|
24
|
+
<option value='bootstrap2'>Bootstrap 2</option>
|
|
25
|
+
<option value='bootstrap3'>Bootstrap 3</option>
|
|
26
|
+
<option value='bootstrap4'>Bootstrap 4</option>
|
|
27
|
+
<option value='foundation3'>Foundation 3</option>
|
|
28
|
+
<option value='foundation4'>Foundation 4</option>
|
|
29
|
+
<option value='foundation5'>Foundation 5</option>
|
|
30
|
+
<option value='foundation6'>Foundation 6</option>
|
|
31
|
+
<option value='materialize'>Materialize</option>
|
|
32
|
+
</select>
|
|
33
|
+
</div>
|
|
34
|
+
<textarea class="value" style="width: 100%; height: 600px;"></textarea>
|
|
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>
|
|
38
|
+
<button class='get-formatted-value'>get formatted value</button>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
var container = document.querySelector('.json-editor-container');
|
|
45
|
+
var value = document.querySelector('.value');
|
|
46
|
+
var getValue = document.querySelector('.get-value');
|
|
47
|
+
var setValue = document.querySelector('.set-value');
|
|
48
|
+
var setEmptyValue = document.querySelector('.set-empty-value');
|
|
49
|
+
var getFormattedValue = document.querySelector('.get-formatted-value');
|
|
50
|
+
|
|
51
|
+
var schema = {
|
|
52
|
+
"title": "Data Types",
|
|
53
|
+
"type": "object",
|
|
54
|
+
"format": "grid-strict",
|
|
55
|
+
"required": [
|
|
56
|
+
"number",
|
|
57
|
+
"boolean",
|
|
58
|
+
],
|
|
59
|
+
"properties": {
|
|
60
|
+
"string": {
|
|
61
|
+
"title": "string",
|
|
62
|
+
"type": "string",
|
|
63
|
+
"minLength": 5,
|
|
64
|
+
"options": {
|
|
65
|
+
"grid_columns": 4
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"number": {
|
|
69
|
+
"title": "number",
|
|
70
|
+
"type": "number",
|
|
71
|
+
"options": {
|
|
72
|
+
"grid_columns": 4
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"boolean": {
|
|
76
|
+
"title": "boolean",
|
|
77
|
+
"type": "boolean",
|
|
78
|
+
"options": {
|
|
79
|
+
"grid_columns": 4,
|
|
80
|
+
"grid_break": true
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"array": {
|
|
84
|
+
"title": "array",
|
|
85
|
+
"type": "array",
|
|
86
|
+
"options": {
|
|
87
|
+
"grid_columns": 6
|
|
88
|
+
},
|
|
89
|
+
"items": {
|
|
90
|
+
"title": "string",
|
|
91
|
+
"type": "string"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"object": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"format": "grid-strict",
|
|
97
|
+
"required": [
|
|
98
|
+
"array",
|
|
99
|
+
"string",
|
|
100
|
+
],
|
|
101
|
+
"options": {
|
|
102
|
+
"grid_columns": 6
|
|
103
|
+
},
|
|
104
|
+
"properties": {
|
|
105
|
+
"string": {
|
|
106
|
+
"title": "string",
|
|
107
|
+
"type": "string",
|
|
108
|
+
"options": {
|
|
109
|
+
"grid_columns": 4
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"number": {
|
|
113
|
+
"title": "number",
|
|
114
|
+
"type": "number",
|
|
115
|
+
"options": {
|
|
116
|
+
"grid_columns": 4
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"boolean": {
|
|
120
|
+
"title": "boolean",
|
|
121
|
+
"type": "boolean",
|
|
122
|
+
"options": {
|
|
123
|
+
"grid_columns": 4
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"array": {
|
|
127
|
+
"title": "array",
|
|
128
|
+
"type": "array",
|
|
129
|
+
"options": {
|
|
130
|
+
"grid_columns": 12
|
|
131
|
+
},
|
|
132
|
+
"items": {
|
|
133
|
+
"title": "string",
|
|
134
|
+
"type": "string"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
var setTheme = function(theme) {
|
|
143
|
+
theme = theme || '';
|
|
144
|
+
|
|
145
|
+
var mapping = {
|
|
146
|
+
barebones: '',
|
|
147
|
+
html: '',
|
|
148
|
+
bootstrap2: 'https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css',
|
|
149
|
+
bootstrap3: 'https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
|
|
150
|
+
bootstrap4: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
|
|
151
|
+
foundation3: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/3.2.5/stylesheets/foundation.css',
|
|
152
|
+
foundation4: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/4.3.2/css/foundation.min.css',
|
|
153
|
+
foundation5: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.3/css/foundation.min.css',
|
|
154
|
+
foundation6: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/6.2.4/foundation.min.css',
|
|
155
|
+
jqueryui: 'https://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css',
|
|
156
|
+
materialize: 'https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css'
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
if(typeof mapping[theme] === 'undefined') {
|
|
160
|
+
theme = 'bootstrap3';
|
|
161
|
+
document.getElementById('theme_switcher').value = theme;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var scriptMapping = {
|
|
165
|
+
materialize: [
|
|
166
|
+
'https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js',
|
|
167
|
+
'https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js'
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
var themeScripts = scriptMapping[theme],
|
|
172
|
+
head = document.getElementsByTagName('head')[0],
|
|
173
|
+
script;
|
|
174
|
+
|
|
175
|
+
if (typeof themeScripts == 'string') { themeScripts = [themeScripts]; }
|
|
176
|
+
if (Array.isArray(themeScripts)) {
|
|
177
|
+
for (var i = 0; i < themeScripts.length; i++) {
|
|
178
|
+
script = document.createElement('script');
|
|
179
|
+
script.type = 'text/javascript';
|
|
180
|
+
script.src = themeScripts[i];
|
|
181
|
+
head.appendChild(script);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
JSONEditor.defaults.options.theme = theme;
|
|
186
|
+
|
|
187
|
+
document.getElementById('theme_stylesheet').href = mapping[theme];
|
|
188
|
+
document.getElementById('theme_switcher').value = JSONEditor.defaults.options.theme;
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
if (editor) {
|
|
192
|
+
editor.destroy();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
initJsonEditor();
|
|
196
|
+
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
initJsonEditor = function () {
|
|
200
|
+
editor = new JSONEditor(container, {
|
|
201
|
+
schema: schema,
|
|
202
|
+
theme: 'bootstrap4',
|
|
203
|
+
show_opt_in: true
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
document.getElementById('theme_switcher').addEventListener('change',function() {
|
|
208
|
+
setTheme(this.value);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
window.addEventListener('load',function() {
|
|
212
|
+
|
|
213
|
+
initJsonEditor();
|
|
214
|
+
|
|
215
|
+
getValue.addEventListener('click', function () {
|
|
216
|
+
value.value = JSON.stringify(editor.getValue());
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
setValue.addEventListener('click', function () {
|
|
220
|
+
editor.setValue({"string":"test","number":0,"boolean":false,"array":["test"],"object":{"string":"","number":10,"boolean":true,"array":[]}})
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
setEmptyValue.addEventListener('click', function () {
|
|
224
|
+
editor.setValue({})
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
getFormattedValue.addEventListener('click', function () {
|
|
228
|
+
value.value = JSON.stringify(editor.getValue(), null, 2);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
setTheme(this.value);
|
|
232
|
+
});
|
|
233
|
+
</script>
|
|
234
|
+
|
|
235
|
+
</body>
|
|
236
|
+
</html>
|
|
@@ -0,0 +1,46 @@
|
|
|
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": "Person",
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"answerA": {
|
|
16
|
+
"title": "Question A:",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"minLength": 1,
|
|
19
|
+
"enum": [
|
|
20
|
+
"A",
|
|
21
|
+
"B",
|
|
22
|
+
"C"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"answerB": {
|
|
26
|
+
"title": "Question B:",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"options": {
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"answerA": [
|
|
31
|
+
"A",
|
|
32
|
+
"B"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const editor = new JSONEditor(document.getElementById('editor'), {
|
|
41
|
+
schema: schema,
|
|
42
|
+
show_errors: 'always'
|
|
43
|
+
});
|
|
44
|
+
</script>
|
|
45
|
+
</body>
|
|
46
|
+
</html>
|
|
@@ -0,0 +1,60 @@
|
|
|
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":"Template",
|
|
13
|
+
"type":"object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"enable_option": {
|
|
16
|
+
"type":"boolean",
|
|
17
|
+
"format":"checkbox"
|
|
18
|
+
},
|
|
19
|
+
"make_new": {
|
|
20
|
+
"type":"boolean",
|
|
21
|
+
"format":"checkbox",
|
|
22
|
+
"options": {
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"enable_option":true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"existing_name": {
|
|
29
|
+
"type":"string",
|
|
30
|
+
"invertDependency":["make_new"],
|
|
31
|
+
"options": {
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"enable_option":true,
|
|
34
|
+
"make_new":false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"required": ["enable_option"],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"make_new": ["enable_option"],
|
|
42
|
+
"existing_name": [
|
|
43
|
+
"enable_option",
|
|
44
|
+
"make_new"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const defaults = {
|
|
49
|
+
"enable_option":false,
|
|
50
|
+
"make_new":true,
|
|
51
|
+
"existing_name":"A Name"
|
|
52
|
+
};
|
|
53
|
+
const editor = new JSONEditor(document.getElementById('editor'), {
|
|
54
|
+
schema,
|
|
55
|
+
startval: defaults,
|
|
56
|
+
show_errors: 'always'
|
|
57
|
+
});
|
|
58
|
+
</script>
|
|
59
|
+
</body>
|
|
60
|
+
</html>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
|
|
9
|
+
<textarea class="value" cols="30" rows="10"></textarea>
|
|
10
|
+
<button class='get-value'>get value</button>
|
|
11
|
+
<div class='container'></div>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
var container = document.querySelector('.container');
|
|
15
|
+
var value = document.querySelector('.value');
|
|
16
|
+
var getValue = document.querySelector('.get-value');
|
|
17
|
+
|
|
18
|
+
var schema = {
|
|
19
|
+
"title": "Person",
|
|
20
|
+
"type": "object",
|
|
21
|
+
"required": [
|
|
22
|
+
"zodiac"
|
|
23
|
+
],
|
|
24
|
+
"properties": {
|
|
25
|
+
"zodiac": {
|
|
26
|
+
"title": "Zodiac",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"minLength": 3
|
|
29
|
+
},
|
|
30
|
+
"values": {
|
|
31
|
+
"title": "Values",
|
|
32
|
+
"propertyOrder": 4,
|
|
33
|
+
"type": "array",
|
|
34
|
+
"uniqueItems": true,
|
|
35
|
+
"items": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"enum": [
|
|
38
|
+
"value A",
|
|
39
|
+
"value B"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"single": {
|
|
44
|
+
"title": "Single",
|
|
45
|
+
"propertyOrder": 3,
|
|
46
|
+
"type": "boolean"
|
|
47
|
+
},
|
|
48
|
+
"name": {
|
|
49
|
+
"title": "Name",
|
|
50
|
+
"propertyOrder": 2,
|
|
51
|
+
"type": "string",
|
|
52
|
+
"default": "Francesco Avizzano"
|
|
53
|
+
},
|
|
54
|
+
"age": {
|
|
55
|
+
"title": "Age",
|
|
56
|
+
"propertyOrder": 1,
|
|
57
|
+
"type": "number",
|
|
58
|
+
"format": "number",
|
|
59
|
+
"default": 10,
|
|
60
|
+
"minimum": 18,
|
|
61
|
+
"maximum": 80
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var editor = new JSONEditor(container, {
|
|
67
|
+
schema: schema,
|
|
68
|
+
show_errors: 'always'
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
getValue.addEventListener('click', function () {
|
|
72
|
+
value.value = JSON.stringify(editor.getValue());
|
|
73
|
+
console.log(editor.getValue());
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
</body>
|
|
79
|
+
</html>
|