@json-editor/json-editor 1.4.0-beta.0 → 1.17.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/.claude/settings.local.json +8 -0
- package/.env +2 -0
- package/.env-dist +2 -0
- package/.eslintrc +10 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +9 -0
- package/.github/workflows/build.yml +70 -0
- package/.travis.yml +62 -16
- package/CHANGELOG.md +483 -113
- package/CONTRIBUTING.md +43 -4
- package/Makefile +26 -0
- package/README.md +632 -121
- package/README_ADDON.md +577 -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 +146 -0
- package/config/helpers.js +10 -0
- package/config/karma.conf.js +89 -0
- package/config/readme.md +31 -0
- package/config/webpack.common.js +71 -0
- package/config/webpack.dev.js +15 -0
- package/config/webpack.nonmin.js +19 -0
- package/config/webpack.prod.js +24 -0
- package/dist/jsoneditor.js +2 -11550
- package/dist/jsoneditor.js.LICENSE.txt +15 -0
- package/dist/nonmin/jsoneditor.js +31392 -0
- package/dist/nonmin/jsoneditor.js.map +1 -0
- package/docs/basic.html +2 -2
- package/docs/basic_person.json +2 -1
- package/docs/choices.html +86 -0
- package/docs/cleave.html +11 -19
- package/docs/colorpicker.html +194 -0
- package/docs/css_integration.html +56 -54
- package/docs/custom-editor.html +92 -0
- package/docs/datetime.html +48 -21
- package/docs/describedby.html +42 -35
- package/docs/enumsource.html +67 -0
- package/docs/form-submission.html +162 -0
- package/docs/imask.html +192 -0
- package/docs/index.html +600 -582
- package/docs/materialize_css.html +1 -1
- package/docs/meta-schema.html +793 -0
- package/docs/meta_schema.json +446 -400
- package/docs/polyfills/assign.js +29 -0
- package/docs/radio.html +9 -17
- package/docs/recursive.html +15 -17
- package/docs/scripts/ajv-validator.js +8695 -0
- package/docs/select2.html +15 -9
- package/docs/selectize.html +11 -9
- package/docs/signature.html +12 -11
- package/docs/starrating.html +5 -17
- package/docs/upload.html +33 -23
- package/docs/uuid.html +70 -0
- package/docs/wysiwyg.html +14 -7
- package/jasmine.json +11 -0
- package/package.json +74 -25
- package/release-notes.md +90 -0
- package/src/core.js +411 -611
- package/src/defaults.js +381 -327
- package/src/editor.js +733 -544
- package/src/editors/ace.js +90 -0
- package/src/editors/array/choices.js +104 -0
- package/src/editors/array/select2.js +112 -0
- package/src/editors/array/selectize.js +107 -130
- package/src/editors/array.css +9 -0
- package/src/editors/array.css.js +3 -0
- package/src/editors/array.js +812 -695
- package/src/editors/autocomplete.js +59 -0
- package/src/editors/base64.js +148 -129
- package/src/editors/button.js +104 -0
- package/src/editors/checkbox.js +111 -76
- package/src/editors/choices.css +3 -0
- package/src/editors/choices.css.js +3 -0
- package/src/editors/choices.js +71 -0
- package/src/editors/colorpicker.js +105 -0
- package/src/editors/datetime.js +93 -79
- package/src/editors/describedby.js +141 -125
- package/src/editors/enum.js +131 -116
- package/src/editors/hidden.js +100 -86
- package/src/editors/index.js +81 -0
- package/src/editors/info.js +28 -0
- package/src/editors/integer.js +21 -8
- package/src/editors/ip.js +36 -0
- package/src/editors/jodit.js +66 -0
- package/src/editors/multiple.js +380 -241
- package/src/editors/multiselect.js +207 -207
- package/src/editors/null.js +15 -11
- package/src/editors/number.js +39 -30
- package/src/editors/object.css +41 -0
- package/src/editors/object.css.js +3 -0
- package/src/editors/object.js +1190 -1068
- package/src/editors/radio.js +117 -101
- package/src/editors/sceditor.js +74 -0
- package/src/editors/select.js +318 -342
- package/src/editors/select2.js +112 -0
- package/src/editors/selectize.js +89 -338
- package/src/editors/signature.js +100 -104
- package/src/editors/simplemde.js +103 -0
- package/src/{styles → editors}/starrating.css +11 -2
- package/src/editors/starrating.css.js +3 -0
- package/src/editors/starrating.js +126 -95
- package/src/editors/stepper.js +27 -0
- package/src/editors/string.js +352 -426
- package/src/editors/table.js +486 -410
- package/src/editors/upload.js +297 -131
- package/src/editors/uuid.js +49 -0
- package/src/iconlib.js +22 -27
- package/src/iconlibs/bootstrap.js +28 -0
- package/src/iconlibs/bootstrap2.js +28 -17
- package/src/iconlibs/bootstrap3.js +28 -17
- package/src/iconlibs/fontawesome3.js +28 -17
- package/src/iconlibs/fontawesome4.js +28 -18
- package/src/iconlibs/fontawesome5.js +28 -18
- package/src/iconlibs/foundation2.js +24 -17
- package/src/iconlibs/foundation3.js +28 -17
- package/src/iconlibs/index.js +27 -0
- package/src/iconlibs/jqueryui.js +28 -17
- package/src/iconlibs/materialicons.js +49 -44
- package/src/iconlibs/openiconic.js +28 -0
- package/src/iconlibs/spectre.js +28 -0
- package/src/resolvers.js +135 -0
- package/src/schemaloader.js +639 -0
- package/src/style.css +157 -0
- package/src/style.css.js +3 -0
- package/src/templates/default.js +46 -51
- package/src/templates/ejs.js +8 -10
- package/src/templates/handlebars.js +1 -3
- package/src/templates/hogan.js +7 -9
- package/src/templates/index.js +21 -0
- package/src/templates/lodash.js +6 -8
- package/src/templates/markup.js +6 -8
- package/src/templates/mustache.js +6 -8
- package/src/templates/swig.js +1 -3
- package/src/templates/underscore.js +6 -8
- package/src/theme.js +717 -433
- package/src/themes/barebones.css +35 -0
- package/src/themes/barebones.css.js +3 -0
- package/src/themes/barebones.js +31 -0
- package/src/themes/bootstrap2.js +302 -265
- package/src/themes/bootstrap3.css +53 -0
- package/src/themes/bootstrap3.css.js +3 -0
- package/src/themes/bootstrap3.js +355 -262
- package/src/themes/bootstrap4.css +89 -0
- package/src/themes/bootstrap4.css.js +3 -0
- package/src/themes/bootstrap4.js +743 -237
- package/src/themes/bootstrap5.css +97 -0
- package/src/themes/bootstrap5.css.js +3 -0
- package/src/themes/bootstrap5.js +687 -0
- package/src/themes/foundation.js +535 -472
- package/src/themes/html.css +60 -0
- package/src/themes/html.css.js +3 -0
- package/src/themes/html.js +69 -82
- package/src/themes/index.js +29 -0
- package/src/themes/jqueryui.js +181 -167
- package/src/themes/materialize.js +263 -292
- package/src/themes/spectre.css +208 -0
- package/src/themes/spectre.css.js +3 -0
- package/src/themes/spectre.js +443 -0
- package/src/themes/tailwind.css +303 -0
- package/src/themes/tailwind.css.js +3 -0
- package/src/themes/tailwind.js +469 -0
- package/src/utilities.js +127 -68
- package/src/validator.js +909 -565
- package/src/validators/ip-validator.js +51 -0
- package/tests/Dockerfile +3 -0
- package/tests/README.md +25 -5
- package/tests/codeceptjs/codecept.json +9 -2
- package/tests/codeceptjs/constrains/contains_test.js +37 -0
- package/tests/codeceptjs/constrains/dependentRequired_test.js +33 -0
- package/tests/codeceptjs/constrains/dependentSchemas_test.js +16 -0
- package/tests/codeceptjs/constrains/if-then-else_test.js +186 -0
- package/tests/codeceptjs/core_test.js +534 -63
- package/tests/codeceptjs/editors/advanced_test.js +12 -9
- package/tests/codeceptjs/editors/array_any_of_test.js +50 -0
- package/tests/codeceptjs/editors/array_test.js +923 -657
- package/tests/codeceptjs/editors/autocomplete_test.js +15 -0
- package/tests/codeceptjs/editors/button_test.js +50 -0
- package/tests/codeceptjs/editors/checkbox_test.js +21 -6
- package/tests/codeceptjs/editors/colorpicker_test.js +29 -0
- package/tests/codeceptjs/editors/datetime_test.js +33 -0
- package/tests/codeceptjs/editors/inheritance_test.js +10 -0
- package/tests/codeceptjs/editors/integer_test.js +82 -64
- package/tests/codeceptjs/editors/jodit_test.js +23 -0
- package/tests/codeceptjs/editors/multiple_test.js +27 -0
- package/tests/codeceptjs/editors/multiselect_test.js +6 -7
- package/tests/codeceptjs/editors/number_test.js +75 -60
- package/tests/codeceptjs/editors/object_test.js +322 -80
- 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/purify_test.js +26 -0
- package/tests/codeceptjs/editors/radio_test.js +9 -0
- package/tests/codeceptjs/editors/range_test.js +10 -0
- package/tests/codeceptjs/editors/rating_test.js +10 -10
- package/tests/codeceptjs/editors/select_test.js +47 -18
- package/tests/codeceptjs/editors/starrating_test.js +15 -0
- package/tests/codeceptjs/editors/stepper_test.js +37 -0
- package/tests/codeceptjs/editors/string_test.js +107 -91
- package/tests/codeceptjs/editors/table-confirm-delete_test.js +60 -54
- package/tests/codeceptjs/editors/tabs_test.js +15 -11
- package/tests/codeceptjs/editors/uuid_test.js +48 -0
- package/tests/codeceptjs/editors/validation_test.js +13 -9
- 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/issues/issue-gh-1158_test.js +8 -0
- package/tests/codeceptjs/issues/issue-gh-1164_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1171_test.js +11 -0
- package/tests/codeceptjs/issues/issue-gh-1211_test.js +17 -0
- package/tests/codeceptjs/issues/issue-gh-1257_test.js +11 -0
- package/tests/codeceptjs/issues/issue-gh-1272_test.js +21 -0
- package/tests/codeceptjs/issues/issue-gh-1330_test.js +8 -0
- package/tests/codeceptjs/issues/issue-gh-1338_test.js +18 -0
- package/tests/codeceptjs/issues/issue-gh-1347_test.js +8 -0
- package/tests/codeceptjs/issues/issue-gh-1364_test.js +13 -0
- package/tests/codeceptjs/issues/issue-gh-1367_test.js +11 -0
- package/tests/codeceptjs/issues/issue-gh-1383_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1384_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1410_test.js +13 -0
- package/tests/codeceptjs/issues/issue-gh-1422_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1431_test.js +12 -0
- package/tests/codeceptjs/issues/issue-gh-1439_test.js +12 -0
- package/tests/codeceptjs/issues/issue-gh-1452_test.js +10 -0
- package/tests/codeceptjs/issues/issue-gh-1453_test.js +18 -0
- package/tests/codeceptjs/issues/issue-gh-1461_test.js +14 -0
- package/tests/codeceptjs/issues/issue-gh-1463_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1471_test.js +17 -0
- package/tests/codeceptjs/issues/issue-gh-1485_test.js +13 -0
- package/tests/codeceptjs/issues/issue-gh-1491_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1525_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1536_test.js +12 -0
- package/tests/codeceptjs/issues/issue-gh-1538_test.js +10 -0
- package/tests/codeceptjs/issues/issue-gh-1541_test.js +8 -0
- package/tests/codeceptjs/issues/issue-gh-1559_test.js +15 -0
- package/tests/codeceptjs/issues/issue-gh-1562_test.js +12 -0
- package/tests/codeceptjs/issues/issue-gh-1586_test.js +15 -0
- package/tests/codeceptjs/issues/issue-gh-1636_test.js +9 -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 +85 -0
- package/tests/codeceptjs/schemaloader_test.js +14 -0
- package/tests/codeceptjs/steps.d.ts +13 -0
- package/tests/codeceptjs/steps_file.js +4 -4
- package/tests/codeceptjs/test-config.js +3 -0
- package/tests/codeceptjs/themes_test.js +564 -0
- package/tests/docker-compose-local.yml +5 -0
- package/tests/docker-compose.yml +11 -19
- package/tests/fixtures/basic_person.json +2 -1
- package/tests/fixtures/definitions.json +22 -0
- package/tests/fixtures/nested_object.json +26 -0
- package/tests/fixtures/properties.json +20 -0
- package/tests/fixtures/some_types.json +32 -0
- package/tests/fixtures/validation.json +1347 -0
- package/tests/pages/_demo.html +475 -0
- package/tests/pages/advanced.html +1 -1
- package/tests/pages/anyof-2.html +91 -0
- package/tests/pages/anyof.html +82 -0
- package/tests/pages/array-anyof.html +145 -0
- package/tests/pages/array-checkboxes-infotext.html +55 -0
- package/tests/pages/array-checkboxes.html +5 -2
- package/tests/pages/array-choices.html +48 -0
- package/tests/pages/array-events-table.html +70 -0
- package/tests/pages/array-events.html +75 -0
- package/tests/pages/array-header-template.html +60 -0
- package/tests/pages/array-integers.html +5 -2
- package/tests/pages/array-multiselects.html +5 -2
- package/tests/pages/array-nested-arrays.html +5 -2
- package/tests/pages/array-numbers.html +5 -2
- package/tests/pages/array-objects.html +5 -2
- package/tests/pages/array-ratings.html +5 -2
- package/tests/pages/array-selectize-create.html +63 -0
- package/tests/pages/array-selectize.html +10 -8
- package/tests/pages/array-selects.html +5 -2
- package/tests/pages/array-strings.html +5 -2
- package/tests/pages/array-table-responsive.html +66 -0
- package/tests/pages/array-unique-items-sort.html +81 -0
- package/tests/pages/array.html +5 -2
- package/tests/pages/assets/autocomplete.css +1 -0
- package/tests/pages/assets/autocomplete.min.js +1 -0
- package/tests/pages/assets/pages.css +130 -0
- package/tests/pages/autocomplete.html +72 -0
- package/tests/pages/button-callbacks.html +79 -0
- package/tests/pages/button-icons.html +39 -0
- package/tests/pages/button_state_mode_1.html +35 -0
- package/tests/pages/button_state_mode_2.html +36 -0
- package/tests/pages/checkbox-labels.html +116 -0
- package/tests/pages/colorpicker-no-3rd-party.html +45 -0
- package/tests/pages/colorpicker-use-vanilla-picker.html +52 -0
- package/tests/pages/container-attributes.html +51 -0
- package/tests/pages/contains.html +39 -0
- package/tests/pages/core.html +14 -7
- package/tests/pages/datetime.html +78 -0
- package/tests/pages/dependentRequired.html +72 -0
- package/tests/pages/dependentSchemas.html +53 -0
- package/tests/pages/disable-button-in-object-editors.html +57 -0
- package/tests/pages/editor-show-validation-errors.html +54 -0
- package/tests/pages/enforce-const.html +168 -0
- package/tests/pages/error-messages.html +48 -0
- package/tests/pages/form-name.html +111 -0
- package/tests/pages/grid-strict.html +10 -13
- package/tests/pages/grid.html +4 -7
- package/tests/pages/if-else.html +58 -0
- package/tests/pages/if-then-else-allOf.html +118 -0
- package/tests/pages/if-then-else-disable-fields.html +70 -0
- package/tests/pages/if-then-else.html +65 -0
- package/tests/pages/if-then.html +58 -0
- package/tests/pages/inheritance.html +80 -0
- package/tests/pages/integer.html +17 -10
- package/tests/pages/issues/_template.html +50 -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-1158.html +50 -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-1171.html +39 -0
- package/tests/pages/issues/issue-gh-1211.html +1022 -0
- package/tests/pages/issues/issue-gh-1233-failing.html +46 -0
- package/tests/pages/issues/issue-gh-1233-passing.html +49 -0
- package/tests/pages/issues/issue-gh-1257.html +77 -0
- package/tests/pages/issues/issue-gh-1272.html +167 -0
- package/tests/pages/issues/issue-gh-1330.html +52 -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-1364.html +64 -0
- package/tests/pages/issues/issue-gh-1367.html +49 -0
- package/tests/pages/issues/issue-gh-1383.html +31 -0
- package/tests/pages/issues/issue-gh-1383.json +14 -0
- package/tests/pages/issues/issue-gh-1384.html +31 -0
- package/tests/pages/issues/issue-gh-1384.json +36 -0
- package/tests/pages/issues/issue-gh-1410.html +57 -0
- package/tests/pages/issues/issue-gh-1422.html +68 -0
- package/tests/pages/issues/issue-gh-1431.html +49 -0
- package/tests/pages/issues/issue-gh-1439.html +69 -0
- package/tests/pages/issues/issue-gh-1452.html +98 -0
- package/tests/pages/issues/issue-gh-1453.html +45 -0
- package/tests/pages/issues/issue-gh-1461.html +55 -0
- package/tests/pages/issues/issue-gh-1463.html +41 -0
- package/tests/pages/issues/issue-gh-1466.html +63 -0
- package/tests/pages/issues/issue-gh-1471.html +49 -0
- package/tests/pages/issues/issue-gh-1485.html +59 -0
- package/tests/pages/issues/issue-gh-1491.html +59 -0
- package/tests/pages/issues/issue-gh-1525.html +62 -0
- package/tests/pages/issues/issue-gh-1536.html +55 -0
- package/tests/pages/issues/issue-gh-1538.html +56 -0
- package/tests/pages/issues/issue-gh-1541.html +51 -0
- package/tests/pages/issues/issue-gh-1541.json +9 -0
- package/tests/pages/issues/issue-gh-1559.html +68 -0
- package/tests/pages/issues/issue-gh-1562.html +170 -0
- package/tests/pages/issues/issue-gh-1586.html +48 -0
- package/tests/pages/issues/issue-gh-1636.html +52 -0
- package/tests/pages/issues/issue-gh-795.html +58 -0
- package/tests/pages/issues/issue-gh-810.html +149 -0
- package/tests/pages/issues/issue-gh-812.html +113 -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/keep_only_existing_values.html +81 -0
- package/tests/pages/load-events.html +61 -0
- package/tests/pages/maxContains.html +40 -0
- package/tests/pages/meta-schema.html +793 -0
- package/tests/pages/meta_schema.json +740 -0
- package/tests/pages/minContains.html +40 -0
- package/tests/pages/number.html +53 -6
- package/tests/pages/object-case-sensitive-property-search-false.html +42 -0
- package/tests/pages/object-case-sensitive-property-search-true.html +42 -0
- package/tests/pages/object-no-additional-properties.html +68 -0
- package/tests/pages/object-no-duplicated-id.html +70 -0
- package/tests/pages/object-required-properties.html +56 -20
- package/tests/pages/object-show-opt-in.html +111 -0
- package/tests/pages/object-with-dependencies-array.html +58 -0
- package/tests/pages/object-with-dependencies.html +62 -0
- package/tests/pages/object.html +5 -3
- package/tests/pages/oneof-2.html +91 -0
- package/tests/pages/oneof.html +105 -0
- package/tests/pages/opt-in-widget.html +134 -0
- package/tests/pages/option-dependencies.html +107 -0
- package/tests/pages/option-no_default_values.html +60 -0
- package/tests/pages/per-editor-options.html +44 -0
- package/tests/pages/placeholder-options.html +57 -0
- package/tests/pages/programmatic-changes.html +121 -0
- package/tests/pages/prompt-paste-max-length-reached.html +51 -0
- package/tests/pages/purify.html +66 -0
- package/tests/pages/range.html +62 -0
- package/tests/pages/read-only.html +60 -8
- package/tests/pages/ready.html +44 -0
- package/tests/pages/references.html +168 -0
- package/tests/pages/remove-false-properties.html +85 -0
- package/tests/pages/select-values.html +91 -0
- package/tests/pages/select.html +4 -3
- package/tests/pages/show-validation-errors.html +73 -0
- package/tests/pages/starrating.html +86 -0
- package/tests/pages/stepper-manual.html +59 -0
- package/tests/pages/stepper.html +61 -0
- package/tests/pages/string-ace-editor.html +7 -3
- package/tests/pages/string-cleave.html +48 -0
- package/tests/pages/string-custom-attributes.html +9 -6
- package/tests/pages/string-formats.html +54 -0
- package/tests/pages/string-formats2.html +59 -0
- package/tests/pages/{array-move-events.html → string-jodit-editor.html} +21 -29
- package/tests/pages/string-sceditor.html +9 -7
- package/tests/pages/string-simplemde-editor.html +83 -0
- package/tests/pages/switcher-option.html +69 -0
- package/tests/pages/table.html +4 -2
- package/tests/pages/tabs.html +1 -1
- package/tests/pages/themes.html +517 -0
- package/tests/pages/title-hidden.html +75 -0
- package/tests/pages/translate-property.html +248 -0
- package/tests/pages/urn.html +98 -0
- package/tests/pages/use-name-attributes.html +207 -0
- package/tests/pages/uuid.html +113 -0
- package/tests/pages/validation-messages.json +705 -0
- package/tests/pages/validation.html +20 -730
- package/tests/unit/.eslintrc +8 -0
- package/tests/unit/core.spec.js +320 -0
- package/tests/unit/defaults.spec.js +40 -0
- package/tests/unit/editor.spec.js +172 -0
- package/tests/unit/editors/array.spec.js +87 -0
- package/tests/unit/editors/object.spec.js +81 -0
- package/tests/unit/editors/table.spec.js +93 -0
- package/tests/unit/readme.md +35 -0
- package/tests/unit/schemaloader.spec.js +576 -0
- package/tests/unit/validator.spec.js +104 -0
- package/tests/unit/validators/ip-validator.spec.js +62 -0
- package/Gruntfile.js +0 -228
- package/dist/css/jsoneditor.min.css +0 -1
- package/dist/jsoneditor.js.map +0 -1
- package/dist/jsoneditor.min.js +0 -19
- package/dist/jsoneditor.min.js.map +0 -1
- package/src/class.js +0 -68
- package/src/editors/rating.js +0 -152
- package/src/ie9.js +0 -51
- package/src/intro.js +0 -23
- package/src/jquery.js +0 -64
- package/src/outro.js +0 -2
- package/src/themes/jsoneditor.barebones-theme.js +0 -60
package/docs/index.html
CHANGED
|
@@ -1,646 +1,664 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
2
|
+
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
-
<meta charset="utf-8"
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
5
|
<title>JSON Editor Interactive Example</title>
|
|
6
|
-
|
|
7
|
-
<!-- Favicon -->
|
|
8
|
-
<link href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACbElEQVQ4jbWTz0sqcRTFT/WGFj6KguohuolWqVSEhI5IDTkh4kA/XH0dGCHMTdhPqJ1gRFjBrEyIQohAaNEioloE/QFBtMnd6x+IkCAiks5bZDH0erR6B87m3ns+cOFe4D+oHYAAsAFgv+aNWq39u7AiSdK+w+G49vl89+Pj4y+Li4svpmneJ5PJ65aWln0Ayj/DjY2Nx263uyLLMgcHB6mqKjVNoxCCW1tbLJVKFYfDcfwVpEOSpJLH46nIssyhoSGGQiH29vbS6/UyHo8zlUqxWCyyUChUmpqaSgA6rADD6XTeBINBhkIhJhIJGoZR7u7udvX09Lg0TSsvLCwwm81yZ2eHkUjkBoBhBeR9Pl8lHA5zcnKSZ2dnnJmZCb83VVUNZzIZrq2tcWVlhfPz8xUAeSvgaHR0tBqLxVgsFnl6espYLNb63hwZGWldX1+naZqcnp7m3NxcFcCRFXCi63o1kUjw8PCQBwcHfwHy+TxzuRyFENR1vQrgxArYjcfjD+l0mnt7e9ze3ubExMTHCkKIcKFQoGEYjEQiDAaDDwB2rYCU3++/zWQyNE2TuVyOuq6XvV6vKxqNupLJZFkIQUVRKMsy7Xb7LYCUFWC32WznS0tLj5ubm1xeXubU1BT9fj/7+/s5PDzMQCDAvr4+dnZ2PjY0NJwDsH++hWhbW9tVNpt9Wl1dpa7r1DSNiqJwYGCAbrebTqfzSZKkKwDRz+F3jdlstktN0+5mZ2efhRCvgUDgtaur67m5ufmurq7uEsDYV8EfeLssFwAVb89zAeB3zRe1mgrAA+BXLfOhegA/8fZt9m/cUZutB4A/Qyb7hzbvy7sAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" />
|
|
9
|
-
|
|
10
|
-
<!-- placeholders for the theme switcher -->
|
|
11
|
-
<link rel='stylesheet' id='theme_stylesheet'>
|
|
12
|
-
<link rel='stylesheet' id='icon_stylesheet'>
|
|
13
|
-
<style>[class*="foundicon-"] {font-family: GeneralFoundicons;font-style: normal;}</style>
|
|
14
|
-
|
|
15
|
-
<!-- JSON Editor -->
|
|
16
6
|
<script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
<script src="https://cdn.jsdelivr.net/npm/ace-builds@1.14.0/src-noconflict/ace.js"></script>
|
|
8
|
+
<script src="./polyfills/assign.js"></script>
|
|
19
9
|
<script src="https://cdn.jsdelivr.net/npm/lz-string@1.4.4/libs/lz-string.min.js"></script>
|
|
20
|
-
|
|
10
|
+
<script src="./scripts/ajv-validator.js"></script>
|
|
11
|
+
<link rel='stylesheet' id='theme-link'>
|
|
12
|
+
<link rel='stylesheet' id='iconlib-link'>
|
|
13
|
+
<style>
|
|
14
|
+
.maintenance-notice {
|
|
15
|
+
background-color: #fff3cd;
|
|
16
|
+
border: 1px solid #ffeaa7;
|
|
17
|
+
border-radius: 4px;
|
|
18
|
+
padding: 12px 16px;
|
|
19
|
+
margin-bottom: 20px;
|
|
20
|
+
color: #856404;
|
|
21
|
+
}
|
|
22
|
+
.maintenance-notice a {
|
|
23
|
+
color: #533102;
|
|
24
|
+
text-decoration: underline;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
21
27
|
</head>
|
|
22
|
-
|
|
23
28
|
<body>
|
|
24
|
-
<
|
|
25
|
-
<div class=
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
<div class="container grid-xl" style="padding-top: 15px; padding-bottom: 30px;">
|
|
30
|
+
<div class="maintenance-notice">
|
|
31
|
+
<strong>Maintenance Mode:</strong> This library is in maintenance mode.
|
|
32
|
+
For active development, consider <a href="https://github.com/germanbisurgi/jedison" target="_blank">Jedison</a>.
|
|
33
|
+
</div>
|
|
34
|
+
<div class="row columns md:flex">
|
|
35
|
+
<div class='col-7 col-md-7 w-7/12'>
|
|
36
|
+
<h1>Editor</h1>
|
|
29
37
|
<p>Below is the editor generated from the JSON Schema.</p>
|
|
30
|
-
|
|
31
|
-
<div id='editor'></div>
|
|
38
|
+
<div id="json-editor-form"></div>
|
|
32
39
|
</div>
|
|
33
|
-
<div class='
|
|
40
|
+
<div class='col-5 col-md-5 w-5/12'>
|
|
34
41
|
<div>
|
|
35
|
-
<a
|
|
42
|
+
<a class="btn btn-primary" id="direct-link" title="preserves schema, value, and options">Direct Link</a>
|
|
43
|
+
<a class="btn btn-secondary" href="?" title="reload editor with default example settings">Reset</a>
|
|
44
|
+
<a class="btn btn-secondary" href="https://github.com/json-editor/json-editor" title="github" target="_blank">GitHub</a>
|
|
36
45
|
</div>
|
|
37
|
-
|
|
38
46
|
<h2>JSON Output</h2>
|
|
39
|
-
<p>You can also make changes to the JSON here and set the value in the editor by clicking
|
|
40
|
-
<
|
|
41
|
-
|
|
47
|
+
<p>You can also make changes to the JSON here and set the value in the editor by clicking "Update Form"</p>
|
|
48
|
+
<label for="output-textarea"></label>
|
|
49
|
+
<button class='btn btn-primary btn-block' id='setvalue'>Update Form</button>
|
|
50
|
+
<textarea id='output-textarea' rows="15" style="width: 100%; font-family: monospace;"
|
|
51
|
+
class='form-control'></textarea>
|
|
52
|
+
<h2>Validation</h2>
|
|
53
|
+
<label for="validate-textarea">This will update whenever the form changes to show validation errors if there
|
|
54
|
+
are any.</label><br>
|
|
55
|
+
<textarea id='validate-textarea' readonly disabled class='form-control'></textarea>
|
|
42
56
|
<h2>Options</h2>
|
|
43
|
-
<div
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
</
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
</
|
|
90
|
-
</
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
</
|
|
123
|
-
|
|
57
|
+
<div>
|
|
58
|
+
<label for="boolean-options-select">Boolean options</label><br>
|
|
59
|
+
<select multiple size="15" id="boolean-options-select" class="form-control browser-default">
|
|
60
|
+
<option value='use_default_values'>Default values based on the "type"</option>
|
|
61
|
+
<option value='use_name_attributes'>Use name attributes</option>
|
|
62
|
+
<option value='prompt_before_delete'>Prompt before delete</option>
|
|
63
|
+
<option value='case_sensitive_property_search'>Case sensitive property search</option>
|
|
64
|
+
<option value='required_by_default'>Object properties required by default</option>
|
|
65
|
+
<option value='display_required_only'>Only show required properties by default</option>
|
|
66
|
+
<option value='show_opt_in'>Show optional properties (with checkbox)</option>
|
|
67
|
+
<option value='no_additional_properties'>No additional object properties</option>
|
|
68
|
+
<option value='ajax'>Allow loading schemas via Ajax</option>
|
|
69
|
+
<option value='disable_edit_json'>Disable "Edit JSON" buttons</option>
|
|
70
|
+
<option value='disable_collapse'>Disable collapse buttons</option>
|
|
71
|
+
<option value='disable_properties'>Disable properties buttons</option>
|
|
72
|
+
<option value='disable_array_add'>Disable array add buttons</option>
|
|
73
|
+
<option value='disable_array_reorder'>Disable array move buttons</option>
|
|
74
|
+
<option value='disable_array_delete'>Disable array delete buttons</option>
|
|
75
|
+
<option value='enable_array_copy'>Add copy buttons to arrays</option>
|
|
76
|
+
<option value='array_controls_top'>Array controls will be displayed at top of list</option>
|
|
77
|
+
<option value='disable_array_delete_all_rows'>Disable array delete all rows buttons</option>
|
|
78
|
+
<option value='disable_array_delete_last_row'>Disable array delete last row buttons</option>
|
|
79
|
+
</select>
|
|
80
|
+
</div>
|
|
81
|
+
<div>
|
|
82
|
+
<label for="theme-select">theme</label><br>
|
|
83
|
+
<select id='theme-select' name="theme" class='form-control browser-default'>
|
|
84
|
+
<option value='barebones'>Barebones</option>
|
|
85
|
+
<option value='bootstrap3'>Bootstrap 3</option>
|
|
86
|
+
<option value='bootstrap4'>Bootstrap 4</option>
|
|
87
|
+
<option value='bootstrap5'>Bootstrap 5</option>
|
|
88
|
+
<option value='html'>HTML</option>
|
|
89
|
+
<option value='spectre'>Spectre</option>
|
|
90
|
+
<option value='tailwind'>Tailwind</option>
|
|
91
|
+
</select>
|
|
92
|
+
</div>
|
|
93
|
+
<div>
|
|
94
|
+
<label for="iconlib-select">iconlib</label><br>
|
|
95
|
+
<select id='iconlib-select' name="iconlib" class='form-control browser-default'>
|
|
96
|
+
<option value='fontawesome3'>fontawesome 3</option>
|
|
97
|
+
<option value='fontawesome4'>fontawesome 4</option>
|
|
98
|
+
<option value='fontawesome5'>fontawesome 5</option>
|
|
99
|
+
<option value='jqueryui'>jQuery UI</option>
|
|
100
|
+
<option value='openiconic'>Open Iconic</option>
|
|
101
|
+
<option value='spectre'>Spectre</option>
|
|
102
|
+
<option value='spectre'>Spectre</option>
|
|
103
|
+
<option value='bootstrap'>Bootstrap</option>
|
|
104
|
+
</select>
|
|
105
|
+
</div>
|
|
106
|
+
<div>
|
|
107
|
+
<label for="object-layout-select">Object Layout</label><br>
|
|
108
|
+
<select id='object-layout-select' class='form-control browser-default'>
|
|
109
|
+
<option value='normal'>normal</option>
|
|
110
|
+
<option value='grid'>grid</option>
|
|
111
|
+
</select>
|
|
112
|
+
</div>
|
|
113
|
+
<div>
|
|
114
|
+
<label for="show-errors-select">Show Errors</label><br>
|
|
115
|
+
<select id='show-errors-select' class='form-control browser-default'>
|
|
116
|
+
<option value='interaction'>On Interaction</option>
|
|
117
|
+
<option value='change'>On Field Change</option>
|
|
118
|
+
<option value='always'>Always</option>
|
|
119
|
+
<option value='never'>Never</option>
|
|
120
|
+
</select>
|
|
121
|
+
</div>
|
|
122
|
+
<div>
|
|
123
|
+
<label for="lib-select"
|
|
124
|
+
title="It's recommended that you click the Direct Link after changing these options">Include
|
|
125
|
+
External Library</label><br>
|
|
126
|
+
<select multiple size="10" id='lib-select' class='form-control browser-default'
|
|
127
|
+
title="It's reccomended that you click the Direct Link after changing these options">
|
|
128
|
+
<option value='ace_editor'>Ace Editor</option>
|
|
129
|
+
<option value='choices'>Choices</option>
|
|
130
|
+
<option value='sceditor'>SCEditor</option>
|
|
131
|
+
<option value='simplemde'>SimpleMDE</option>
|
|
132
|
+
<option value='select2'>Select2</option>
|
|
133
|
+
<option value='selectize'>Selectize</option>
|
|
134
|
+
<option value='flatpickr'>Flatpickr</option>
|
|
135
|
+
<option value='signature_pad'>Signature Pad</option>
|
|
136
|
+
<option value='mathjs'>Math.js</option>
|
|
137
|
+
<option value='cleavejs'>Cleave.js</option>
|
|
138
|
+
</select>
|
|
124
139
|
</div>
|
|
125
|
-
|
|
126
|
-
<h2>Validation</h2>
|
|
127
|
-
<p>This will update whenever the form changes to show validation errors if there are any.</p>
|
|
128
|
-
<textarea id='validate' style='width: 100%; height: 100px; font-family: monospace;' readonly disabled class='form-control'></textarea>
|
|
129
140
|
</div>
|
|
130
141
|
</div>
|
|
131
|
-
<div class='row'>
|
|
132
|
-
<div class='row'>
|
|
133
|
-
<div class='span12 col-md-12 columns twelve large-12 col s12'>
|
|
134
|
-
<h2>Schema</h2>
|
|
135
|
-
<p>You can change the schema and see how the generated form looks. After you make changes, click <button class='btn btn-primary' id='setschema'>Update Schema</button></p>
|
|
136
142
|
|
|
137
|
-
|
|
138
|
-
|
|
143
|
+
<h2>Schema</h2>
|
|
144
|
+
|
|
145
|
+
<div class="row columns md:flex">
|
|
146
|
+
<div class='col-7 col-md-7 w-7/12'>
|
|
147
|
+
<label for="schema-textarea">You can change the schema and see how the generated form looks. After you make changes, click "Update Schema"</label>
|
|
148
|
+
<button class='btn btn-primary btn-block' id='setschema'>Update Schema</button>
|
|
149
|
+
<textarea id='schema-textarea' style="height: 100vh;"></textarea>
|
|
139
150
|
</div>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// Set the value
|
|
157
|
-
editor.setValue({
|
|
158
|
-
name: "John Smith"
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// Get the value
|
|
162
|
-
var data = editor.getValue();
|
|
163
|
-
console.log(data.name); // "John Smith"
|
|
164
|
-
|
|
165
|
-
// Validate
|
|
166
|
-
var errors = editor.validate();
|
|
167
|
-
if(errors.length) {
|
|
168
|
-
// Not valid
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Listen for changes
|
|
172
|
-
editor.on("change", function() {
|
|
173
|
-
// Do something...
|
|
174
|
-
});</code></pre>
|
|
175
|
-
</div>
|
|
151
|
+
|
|
152
|
+
<div class='col-5 col-md-5 w-5/12'>
|
|
153
|
+
<label for="je-errors-textarea">
|
|
154
|
+
<span>AJV (JE meta-schema): </span>
|
|
155
|
+
<code id="je-errors-count"></code>
|
|
156
|
+
</label>
|
|
157
|
+
<textarea id='je-errors-textarea'></textarea>
|
|
158
|
+
|
|
159
|
+
<br>
|
|
160
|
+
|
|
161
|
+
<label for="ajv-errors-textarea">
|
|
162
|
+
<span>AJV (meta-schema-2020-12): </span>
|
|
163
|
+
<code id="ajv-errors-count"></code>
|
|
164
|
+
</label>
|
|
165
|
+
<textarea id='ajv-errors-textarea'></textarea>
|
|
176
166
|
</div>
|
|
177
167
|
</div>
|
|
178
168
|
</div>
|
|
179
|
-
<p> </p>
|
|
180
169
|
<script>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
170
|
+
var defaultSchema = {
|
|
171
|
+
'title': 'Person',
|
|
172
|
+
'type': 'object',
|
|
173
|
+
'required': [
|
|
174
|
+
'name',
|
|
175
|
+
'age',
|
|
176
|
+
'date',
|
|
177
|
+
'favorite_color',
|
|
178
|
+
'gender',
|
|
179
|
+
'location',
|
|
180
|
+
'pets'
|
|
181
|
+
],
|
|
182
|
+
'properties': {
|
|
183
|
+
'name': {
|
|
184
|
+
'type': 'string',
|
|
185
|
+
'description': 'First and Last name',
|
|
186
|
+
'minLength': 4,
|
|
187
|
+
'default': 'Jeremy Dorn'
|
|
188
|
+
},
|
|
189
|
+
'age': {
|
|
190
|
+
'type': 'integer',
|
|
191
|
+
'default': 25,
|
|
192
|
+
'minimum': 18,
|
|
193
|
+
'maximum': 99
|
|
194
|
+
},
|
|
195
|
+
'favorite_color': {
|
|
196
|
+
'type': 'string',
|
|
197
|
+
'format': 'color',
|
|
198
|
+
'title': 'favorite color',
|
|
199
|
+
'default': '#ffa500'
|
|
200
|
+
},
|
|
201
|
+
'gender': {
|
|
202
|
+
'type': 'string',
|
|
203
|
+
'enum': [
|
|
204
|
+
'male',
|
|
205
|
+
'female',
|
|
206
|
+
'other'
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
'date': {
|
|
210
|
+
'type': 'string',
|
|
211
|
+
'format': 'date',
|
|
212
|
+
'options': {
|
|
213
|
+
'flatpickr': {}
|
|
186
214
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
name: {
|
|
208
|
-
type: "string",
|
|
209
|
-
description: "First and Last name",
|
|
210
|
-
minLength: 4,
|
|
211
|
-
default: "Jeremy Dorn"
|
|
212
|
-
},
|
|
213
|
-
age: {
|
|
214
|
-
type: "integer",
|
|
215
|
-
default: 25,
|
|
216
|
-
minimum: 18,
|
|
217
|
-
maximum: 99
|
|
218
|
-
},
|
|
219
|
-
favorite_color: {
|
|
220
|
-
type: "string",
|
|
221
|
-
format: "color",
|
|
222
|
-
title: "favorite color",
|
|
223
|
-
default: "#ffa500"
|
|
224
|
-
},
|
|
225
|
-
gender: {
|
|
226
|
-
type: "string",
|
|
227
|
-
enum: ["male", "female"]
|
|
228
|
-
},
|
|
229
|
-
date: {
|
|
230
|
-
type: "string",
|
|
231
|
-
format: "date",
|
|
232
|
-
options: {
|
|
233
|
-
flatpickr: {
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
location: {
|
|
239
|
-
type: "object",
|
|
240
|
-
title: "Location",
|
|
241
|
-
properties: {
|
|
242
|
-
city: {
|
|
243
|
-
type: "string",
|
|
244
|
-
default: "San Francisco"
|
|
245
|
-
},
|
|
246
|
-
state: {
|
|
247
|
-
type: "string",
|
|
248
|
-
default: "CA"
|
|
249
|
-
},
|
|
250
|
-
citystate: {
|
|
251
|
-
type: "string",
|
|
252
|
-
description: "This is generated automatically from the previous two fields",
|
|
253
|
-
template: "{{city}}, {{state}}",
|
|
254
|
-
watch: {
|
|
255
|
-
city: 'location.city',
|
|
256
|
-
state: 'location.state'
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
pets: {
|
|
262
|
-
type: "array",
|
|
263
|
-
format: "table",
|
|
264
|
-
title: "Pets",
|
|
265
|
-
uniqueItems: true,
|
|
266
|
-
items: {
|
|
267
|
-
type: "object",
|
|
268
|
-
title: "Pet",
|
|
269
|
-
properties: {
|
|
270
|
-
type: {
|
|
271
|
-
type: "string",
|
|
272
|
-
enum: ["cat","dog","bird","reptile","other"],
|
|
273
|
-
default: "dog"
|
|
274
|
-
},
|
|
275
|
-
name: {
|
|
276
|
-
type: "string"
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
default: [
|
|
281
|
-
{
|
|
282
|
-
type: "dog",
|
|
283
|
-
name: "Walter"
|
|
284
|
-
}
|
|
285
|
-
]
|
|
286
|
-
}
|
|
215
|
+
},
|
|
216
|
+
'location': {
|
|
217
|
+
'type': 'object',
|
|
218
|
+
'title': 'Location',
|
|
219
|
+
'properties': {
|
|
220
|
+
'city': {
|
|
221
|
+
'type': 'string',
|
|
222
|
+
'default': 'San Francisco'
|
|
223
|
+
},
|
|
224
|
+
'state': {
|
|
225
|
+
'type': 'string',
|
|
226
|
+
'default': 'CA'
|
|
227
|
+
},
|
|
228
|
+
'citystate': {
|
|
229
|
+
'type': 'string',
|
|
230
|
+
'description': 'This is generated automatically from the previous two fields',
|
|
231
|
+
'template': '{{city}}, {{state}}',
|
|
232
|
+
'watch': {
|
|
233
|
+
'city': 'location.city',
|
|
234
|
+
'state': 'location.state'
|
|
287
235
|
}
|
|
236
|
+
}
|
|
288
237
|
}
|
|
238
|
+
},
|
|
239
|
+
'pets': {
|
|
240
|
+
'type': 'array',
|
|
241
|
+
'format': 'table',
|
|
242
|
+
'title': 'Pets',
|
|
243
|
+
'uniqueItems': true,
|
|
244
|
+
'items': {
|
|
245
|
+
'type': 'object',
|
|
246
|
+
'title': 'Pet',
|
|
247
|
+
'properties': {
|
|
248
|
+
'type': {
|
|
249
|
+
'type': 'string',
|
|
250
|
+
'enum': [
|
|
251
|
+
'cat',
|
|
252
|
+
'dog',
|
|
253
|
+
'bird',
|
|
254
|
+
'reptile',
|
|
255
|
+
'other'
|
|
256
|
+
],
|
|
257
|
+
'default': 'dog'
|
|
258
|
+
},
|
|
259
|
+
'name': {
|
|
260
|
+
'type': 'string'
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
'default': [
|
|
265
|
+
{
|
|
266
|
+
'type': 'dog',
|
|
267
|
+
'name': 'Walter'
|
|
268
|
+
}
|
|
269
|
+
]
|
|
270
|
+
}
|
|
289
271
|
}
|
|
272
|
+
}
|
|
290
273
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
274
|
+
// parse url -> merge options -> refreshUI() -> initJsoneditor() -> direct link
|
|
275
|
+
|
|
276
|
+
/* ------------------------------------------------------------------- data */
|
|
277
|
+
|
|
278
|
+
var data = {}
|
|
279
|
+
|
|
280
|
+
var defaultOptions = Object.assign({}, JSONEditor.defaults.options, {
|
|
281
|
+
iconlib: 'fontawesome5',
|
|
282
|
+
object_layout: 'normal',
|
|
283
|
+
schema: defaultSchema,
|
|
284
|
+
show_errors: 'interaction',
|
|
285
|
+
theme: 'bootstrap4',
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
var jsoneditor = null
|
|
289
|
+
var directLink = document.querySelector('#direct-link')
|
|
290
|
+
|
|
291
|
+
var booleanOptionsSelect = document.querySelector('#boolean-options-select')
|
|
292
|
+
var head = document.getElementsByTagName('head')[0]
|
|
293
|
+
var iconlibSelect = document.querySelector('#iconlib-select')
|
|
294
|
+
var iconlibLink = document.querySelector('#iconlib-link')
|
|
295
|
+
var libSelect = document.querySelector('#lib-select')
|
|
296
|
+
var jsonEditorForm = document.querySelector('#json-editor-form')
|
|
297
|
+
var objectLayoutSelect = document.querySelector('#object-layout-select')
|
|
298
|
+
var setSchema = document.querySelector('#setschema')
|
|
299
|
+
var setValue = document.querySelector('#setvalue')
|
|
300
|
+
var showErrorsSelect = document.querySelector('#show-errors-select')
|
|
301
|
+
var themeSelect = document.querySelector('#theme-select')
|
|
302
|
+
var themeLink = document.querySelector('#theme-link')
|
|
303
|
+
var validateTextarea = document.querySelector('#validate-textarea')
|
|
304
|
+
|
|
305
|
+
var aceConfig = {
|
|
306
|
+
mode: 'ace/mode/json',
|
|
307
|
+
maxLines: Infinity,
|
|
308
|
+
minLines: 5,
|
|
309
|
+
showFoldWidgets: false,
|
|
310
|
+
showPrintMargin: false
|
|
311
|
+
}
|
|
328
312
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
313
|
+
var outputTextarea = ace.edit('output-textarea', aceConfig)
|
|
314
|
+
var schemaTextarea = ace.edit('schema-textarea', aceConfig)
|
|
315
|
+
var ajvErrorsTextarea = ace.edit('ajv-errors-textarea', aceConfig)
|
|
316
|
+
var jeErrorsTextarea = ace.edit('je-errors-textarea', aceConfig)
|
|
317
|
+
var ajvErrorsCount = document.querySelector('#ajv-errors-count')
|
|
318
|
+
var jeErrorsCount = document.querySelector('#je-errors-count')
|
|
319
|
+
var ajv = new AjvValidator()
|
|
320
|
+
|
|
321
|
+
const validateSchema = () => {
|
|
322
|
+
const dataToValidate = JSON.parse(schemaTextarea.getValue())
|
|
323
|
+
let errors
|
|
324
|
+
|
|
325
|
+
// AJV validation
|
|
326
|
+
ajvErrorsCount.textContent = '0'
|
|
327
|
+
errors = ajv.validate202012(dataToValidate)
|
|
328
|
+
ajvErrorsTextarea.setValue(JSON.stringify(errors, null, 2))
|
|
329
|
+
ajvErrorsCount.textContent = JSON.stringify(errors.length)
|
|
330
|
+
schemaTextarea.clearSelection(1)
|
|
331
|
+
ajvErrorsTextarea.clearSelection(1)
|
|
332
|
+
|
|
333
|
+
// JE validation with AJV
|
|
334
|
+
jeErrorsCount.textContent = '0'
|
|
335
|
+
errors = ajv.validateJeMetaSchema(dataToValidate)
|
|
336
|
+
jeErrorsTextarea.setValue(JSON.stringify(errors, null, 2))
|
|
337
|
+
jeErrorsCount.textContent = JSON.stringify(errors.length)
|
|
338
|
+
schemaTextarea.clearSelection(1)
|
|
339
|
+
jeErrorsTextarea.clearSelection(1)
|
|
340
|
+
}
|
|
332
341
|
|
|
342
|
+
/* -------------------------------------------------------------- parse url */
|
|
343
|
+
|
|
344
|
+
var parseUrl = function () {
|
|
345
|
+
var url = window.location.search
|
|
346
|
+
var queryParamsString = url.substring(1, url.length)
|
|
347
|
+
var queryParams = queryParamsString.split('&')
|
|
348
|
+
|
|
349
|
+
if (queryParamsString.length) {
|
|
350
|
+
queryParams.forEach(function (queryParam) {
|
|
351
|
+
var splittedParam = queryParam.split('=')
|
|
352
|
+
var param = splittedParam[0]
|
|
353
|
+
var value = splittedParam[1]
|
|
354
|
+
|
|
355
|
+
// data query param
|
|
356
|
+
if (param === 'data') {
|
|
357
|
+
// compress schema and value
|
|
358
|
+
try {
|
|
359
|
+
data = JSON.parse(LZString.decompressFromBase64(value))
|
|
360
|
+
} catch (reason) {
|
|
333
361
|
}
|
|
334
362
|
}
|
|
335
|
-
)
|
|
363
|
+
})
|
|
336
364
|
}
|
|
337
365
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
url += '?schema='+LZString.compressToBase64(JSON.stringify(schema));
|
|
342
|
-
url += '&value='+LZString.compressToBase64(JSON.stringify(jsoneditor.getValue()));
|
|
343
|
-
//url += JSONEditor.plugins.selectize.enable ? '&enable_selectize=1':'';
|
|
344
|
-
|
|
345
|
-
var libs = document.getElementById('lib_switcher').querySelectorAll(':checked');
|
|
346
|
-
var result = Object.keys(libs).map(function(key) {return libs[key].value;});
|
|
347
|
-
url += '&lib_switcher=' + result.join(',');
|
|
366
|
+
mergeOptions()
|
|
367
|
+
}
|
|
348
368
|
|
|
349
|
-
|
|
350
|
-
if(!JSONEditor.defaults.options.hasOwnProperty(i)) continue;
|
|
351
|
-
if(JSONEditor.defaults.options[i]===false) continue;
|
|
352
|
-
else if(JSONEditor.defaults.options[i]===true) {
|
|
353
|
-
url += '&'+i;
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
url += '&'+i+'='+JSONEditor.defaults.options[i];
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
document.getElementById('direct_link').href = url;
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
var reload = function(keep_value) {
|
|
363
|
-
var startval = (jsoneditor && keep_value)? jsoneditor.getValue() : window.startval;
|
|
364
|
-
window.startval = undefined;
|
|
365
|
-
|
|
366
|
-
if(jsoneditor) jsoneditor.destroy();
|
|
367
|
-
jsoneditor = new JSONEditor($editor,{
|
|
368
|
-
schema: schema,
|
|
369
|
-
startval: startval
|
|
370
|
-
});
|
|
371
|
-
window.jsoneditor = jsoneditor;
|
|
372
|
-
|
|
373
|
-
// When the value of the editor changes, update the JSON output and validation message
|
|
374
|
-
jsoneditor.on('change',function() {
|
|
375
|
-
var json = jsoneditor.getValue();
|
|
376
|
-
|
|
377
|
-
$output.value = JSON.stringify(json,null,2);
|
|
378
|
-
|
|
379
|
-
var validation_errors = jsoneditor.validate();
|
|
380
|
-
// Show validation errors if there are any
|
|
381
|
-
if(validation_errors.length) {
|
|
382
|
-
$validate.value = JSON.stringify(validation_errors,null,2);
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
$validate.value = 'valid';
|
|
386
|
-
}
|
|
369
|
+
/* ----------------------------------------------------------- mergeOptions */
|
|
387
370
|
|
|
388
|
-
|
|
371
|
+
var mergeOptions = function () {
|
|
372
|
+
data.options = Object.assign(defaultOptions, data.options)
|
|
373
|
+
refreshUI()
|
|
374
|
+
}
|
|
389
375
|
|
|
390
|
-
|
|
391
|
-
|
|
376
|
+
/* -------------------------------------------------------------- refreshUI */
|
|
377
|
+
|
|
378
|
+
var refreshUI = function () {
|
|
379
|
+
// schema
|
|
380
|
+
schemaTextarea.setValue(JSON.stringify(data.options.schema, null, 2))
|
|
381
|
+
schemaTextarea.clearSelection(1)
|
|
382
|
+
validateSchema()
|
|
383
|
+
|
|
384
|
+
// theme
|
|
385
|
+
var themeMap = {
|
|
386
|
+
barebones: '',
|
|
387
|
+
bootstrap3: 'https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css',
|
|
388
|
+
bootstrap4: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
|
|
389
|
+
bootstrap5: 'https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css',
|
|
390
|
+
html: '',
|
|
391
|
+
spectre: 'https://unpkg.com/spectre.css/dist/spectre.min.css',
|
|
392
|
+
tailwind: 'https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css'
|
|
393
|
+
}
|
|
394
|
+
themeLink.href = themeMap[data.options.theme]
|
|
395
|
+
themeSelect.value = data.options.theme
|
|
396
|
+
|
|
397
|
+
// iconlLib
|
|
398
|
+
var iconLibMap = {
|
|
399
|
+
fontawesome3: 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.css',
|
|
400
|
+
fontawesome4: 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.css',
|
|
401
|
+
fontawesome5: 'https://use.fontawesome.com/releases/v5.6.1/css/all.css',
|
|
402
|
+
jqueryui: 'https://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css',
|
|
403
|
+
openiconic: 'https://cdnjs.cloudflare.com/ajax/libs/open-iconic/1.1.1/font/css/open-iconic.min.css',
|
|
404
|
+
spectre: 'https://unpkg.com/spectre.css/dist/spectre-icons.min.css',
|
|
405
|
+
bootstrap: 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css'
|
|
406
|
+
}
|
|
407
|
+
iconlibLink.href = iconLibMap[data.options.iconlib]
|
|
408
|
+
iconlibSelect.value = data.options.iconlib
|
|
392
409
|
|
|
393
|
-
|
|
394
|
-
|
|
410
|
+
// object_layout
|
|
411
|
+
objectLayoutSelect.value = data.options.object_layout
|
|
395
412
|
|
|
396
|
-
//
|
|
397
|
-
|
|
398
|
-
$output.value = '';
|
|
413
|
+
// show_errors
|
|
414
|
+
showErrorsSelect.value = data.options.show_errors
|
|
399
415
|
|
|
400
|
-
//
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
416
|
+
// boolean values
|
|
417
|
+
var booleanOptions = booleanOptionsSelect.children
|
|
418
|
+
for (var i = 0; i < booleanOptions.length; i++) {
|
|
419
|
+
var booleanValue = booleanOptions[i]
|
|
420
|
+
if (data.options[booleanValue.value]) {
|
|
421
|
+
booleanValue.selected = true
|
|
422
|
+
}
|
|
423
|
+
}
|
|
404
424
|
|
|
405
|
-
//
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
425
|
+
// libs
|
|
426
|
+
var libMapping = {
|
|
427
|
+
ace_editor: {
|
|
428
|
+
js: [
|
|
429
|
+
'https://cdn.jsdelivr.net/npm/ace-editor-builds@1.2.4/src-min-noconflict/ace.js'
|
|
430
|
+
],
|
|
431
|
+
css: []
|
|
432
|
+
},
|
|
433
|
+
choices: {
|
|
434
|
+
js: [
|
|
435
|
+
'https://cdn.jsdelivr.net/npm/choices.js/public/assets/scripts/choices.min.js'
|
|
436
|
+
],
|
|
437
|
+
css: [
|
|
438
|
+
'https://cdn.jsdelivr.net/npm/choices.js/public/assets/styles/choices.min.css'
|
|
439
|
+
]
|
|
440
|
+
},
|
|
441
|
+
cleavejs: {
|
|
442
|
+
js: [
|
|
443
|
+
'https://cdn.jsdelivr.net/npm/cleave.js@1.4.7/dist/cleave.min.js'
|
|
444
|
+
],
|
|
445
|
+
css: []
|
|
446
|
+
},
|
|
447
|
+
sceditor: {
|
|
448
|
+
js: [
|
|
449
|
+
'https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js',
|
|
450
|
+
'https://cdn.jsdelivr.net/npm/sceditor@2.1.3/minified/sceditor.min.js',
|
|
451
|
+
'https://cdn.jsdelivr.net/npm/sceditor@2.1.3/minified/formats/bbcode.js',
|
|
452
|
+
'https://cdn.jsdelivr.net/npm/sceditor@2.1.3/minified/formats/xhtml.js'
|
|
453
|
+
],
|
|
454
|
+
css: [
|
|
455
|
+
'https://cdn.jsdelivr.net/npm/sceditor@2.1.3/minified/themes/default.min.css'
|
|
456
|
+
]
|
|
457
|
+
},
|
|
458
|
+
simplemde: {
|
|
459
|
+
js: [
|
|
460
|
+
'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js'
|
|
461
|
+
],
|
|
462
|
+
css: [
|
|
463
|
+
'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css'
|
|
464
|
+
]
|
|
465
|
+
},
|
|
466
|
+
select2: {
|
|
467
|
+
js: [
|
|
468
|
+
'https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js',
|
|
469
|
+
'https://cdn.jsdelivr.net/npm/select2@4.0.6-rc.1/dist/js/select2.min.js'
|
|
470
|
+
],
|
|
471
|
+
css: [
|
|
472
|
+
'https://cdn.jsdelivr.net/npm/select2@4.0.6-rc.1/dist/css/select2.min.css'
|
|
473
|
+
]
|
|
474
|
+
},
|
|
475
|
+
selectize: {
|
|
476
|
+
js: [
|
|
477
|
+
'https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js',
|
|
478
|
+
'https://cdn.jsdelivr.net/npm/selectize@0.12.6/dist/js/standalone/selectize.min.js'
|
|
479
|
+
],
|
|
480
|
+
css: [
|
|
481
|
+
'https://cdn.jsdelivr.net/npm/selectize@0.12.6/dist/css/selectize.min.css',
|
|
482
|
+
'https://cdn.jsdelivr.net/npm/selectize@0.12.6/dist/css/selectize.default.min.css'
|
|
483
|
+
]
|
|
484
|
+
},
|
|
485
|
+
flatpickr: {
|
|
486
|
+
js: [
|
|
487
|
+
'https://cdn.jsdelivr.net/npm/flatpickr'
|
|
488
|
+
],
|
|
489
|
+
css: [
|
|
490
|
+
'https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css'
|
|
491
|
+
]
|
|
492
|
+
},
|
|
493
|
+
signature_pad: {
|
|
494
|
+
js: [
|
|
495
|
+
'https://cdn.jsdelivr.net/npm/signature_pad@2.3.2/dist/signature_pad.min.js'
|
|
496
|
+
],
|
|
497
|
+
css: []
|
|
498
|
+
},
|
|
499
|
+
mathjs: {
|
|
500
|
+
js: [
|
|
501
|
+
'https://cdn.jsdelivr.net/npm/mathjs@5.3.1/dist/math.min.js'
|
|
502
|
+
],
|
|
503
|
+
css: []
|
|
504
|
+
},
|
|
505
|
+
}
|
|
414
506
|
|
|
415
|
-
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
// Set the theme by loading the right stylesheets
|
|
419
|
-
var setTheme = function(theme,no_reload) {
|
|
420
|
-
theme = theme || '';
|
|
421
|
-
|
|
422
|
-
var mapping = {
|
|
423
|
-
barebones: '',
|
|
424
|
-
html: '',
|
|
425
|
-
bootstrap2: 'https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css',
|
|
426
|
-
bootstrap3: 'https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
|
|
427
|
-
bootstrap4: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
|
|
428
|
-
foundation3: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/3.2.5/stylesheets/foundation.css',
|
|
429
|
-
foundation4: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/4.3.2/css/foundation.min.css',
|
|
430
|
-
foundation5: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.3/css/foundation.min.css',
|
|
431
|
-
foundation6: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/6.2.4/foundation.min.css',
|
|
432
|
-
jqueryui: 'https://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css',
|
|
433
|
-
materialize: 'https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css'
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
if(typeof mapping[theme] === 'undefined') {
|
|
437
|
-
theme = 'bootstrap3';
|
|
438
|
-
document.getElementById('theme_switcher').value = theme;
|
|
439
|
-
}
|
|
507
|
+
if (data.selectedLibs || data.unselectedLibs) {
|
|
440
508
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
509
|
+
var booleanOptions = booleanOptionsSelect.children
|
|
510
|
+
for (var i = 0; i < booleanOptions.length; i++) {
|
|
511
|
+
var booleanValue = booleanOptions[i]
|
|
512
|
+
if (data.options[booleanValue.value]) {
|
|
513
|
+
booleanValue.selected = true
|
|
446
514
|
}
|
|
515
|
+
}
|
|
447
516
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
if (Array.isArray(themeScripts)) {
|
|
454
|
-
for (var i = 0; i < themeScripts.length; i++) {
|
|
455
|
-
script = document.createElement('script');
|
|
456
|
-
script.type = 'text/javascript';
|
|
457
|
-
script.src = themeScripts[i];
|
|
458
|
-
head.appendChild(script);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
517
|
+
var libSelectChildren = libSelect.children
|
|
518
|
+
for (var i = 0; i < libSelectChildren.length; i++) {
|
|
519
|
+
var child = libSelectChildren[i]
|
|
520
|
+
child.selected = data.selectedLibs.includes(child.value)
|
|
521
|
+
}
|
|
461
522
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
ace_editor: "https://cdn.jsdelivr.net/npm/ace-editor-builds@1.2.4/src-min-noconflict/ace.js",
|
|
497
|
-
cleavejs: "https://cdn.jsdelivr.net/npm/cleave.js@1.4.7/dist/cleave.min.js",
|
|
498
|
-
sceditor: [
|
|
499
|
-
"https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js",
|
|
500
|
-
"https://cdn.jsdelivr.net/npm/sceditor@2.1.3/minified/sceditor.min.js",
|
|
501
|
-
"https://cdn.jsdelivr.net/npm/sceditor@2.1.3/minified/formats/bbcode.js",
|
|
502
|
-
"https://cdn.jsdelivr.net/npm/sceditor@2.1.3/minified/formats/xhtml.js"
|
|
503
|
-
],
|
|
504
|
-
simplemde: "https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js",
|
|
505
|
-
select2: [
|
|
506
|
-
"https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js",
|
|
507
|
-
"https://cdn.jsdelivr.net/npm/select2@4.0.6-rc.1/dist/js/select2.min.js"
|
|
508
|
-
],
|
|
509
|
-
selectize: "https://cdn.jsdelivr.net/npm/selectize@0.12.6/dist/js/standalone/selectize.min.js",
|
|
510
|
-
flatpickr: "https://cdn.jsdelivr.net/npm/flatpickr",
|
|
511
|
-
signature_pad: "https://cdn.jsdelivr.net/npm/signature_pad@2.3.2/dist/signature_pad.min.js",
|
|
512
|
-
mathjs: "https://cdn.jsdelivr.net/npm/mathjs@5.3.1/dist/math.min.js"
|
|
513
|
-
}
|
|
523
|
+
// remove libraries
|
|
524
|
+
data.unselectedLibs.forEach(function (selectedLib) {
|
|
525
|
+
var concat = libMapping[selectedLib].js.concat(libMapping[selectedLib].css)
|
|
526
|
+
concat.forEach(function () {
|
|
527
|
+
var className = '.external_' + selectedLib
|
|
528
|
+
var toRemove = head.querySelector(className)
|
|
529
|
+
if (toRemove) {
|
|
530
|
+
toRemove.parentNode.removeChild(toRemove)
|
|
531
|
+
}
|
|
532
|
+
})
|
|
533
|
+
})
|
|
534
|
+
|
|
535
|
+
// add libraries
|
|
536
|
+
data.selectedLibs.forEach(function (selectedLib) {
|
|
537
|
+
// add js
|
|
538
|
+
libMapping[selectedLib].js.forEach(function (js) {
|
|
539
|
+
var scriptElement = document.createElement('script')
|
|
540
|
+
scriptElement.type = 'text/javascript'
|
|
541
|
+
scriptElement.src = js
|
|
542
|
+
scriptElement.async = false
|
|
543
|
+
scriptElement.classList.add('external_' + selectedLib)
|
|
544
|
+
head.appendChild(scriptElement)
|
|
545
|
+
})
|
|
546
|
+
// add css
|
|
547
|
+
libMapping[selectedLib].css.forEach(function (css) {
|
|
548
|
+
var linkElement = document.createElement('link')
|
|
549
|
+
linkElement.setAttribute('rel', 'stylesheet')
|
|
550
|
+
linkElement.setAttribute('type', 'text/css')
|
|
551
|
+
linkElement.setAttribute('href', css)
|
|
552
|
+
linkElement.classList.add('external_' + selectedLib)
|
|
553
|
+
head.appendChild(linkElement)
|
|
554
|
+
})
|
|
555
|
+
})
|
|
556
|
+
}
|
|
514
557
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
select2: "https://cdn.jsdelivr.net/npm/select2@4.0.6-rc.1/dist/css/select2.min.css",
|
|
518
|
-
selectize: [
|
|
519
|
-
"https://cdn.jsdelivr.net/npm/selectize@0.12.6/dist/css/selectize.min.css",
|
|
520
|
-
"https://cdn.jsdelivr.net/npm/selectize@0.12.6/dist/css/selectize.default.min.css"
|
|
521
|
-
],
|
|
522
|
-
simplemde: "https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css",
|
|
523
|
-
flatpickr: "https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css"
|
|
524
|
-
}
|
|
558
|
+
initJsoneditor()
|
|
559
|
+
}
|
|
525
560
|
|
|
526
|
-
|
|
527
|
-
libStyles = styleMapping[lib_name],
|
|
528
|
-
head = document.getElementsByTagName('head')[0],
|
|
529
|
-
script,style;
|
|
530
|
-
|
|
531
|
-
if (typeof libStyles == 'string') { libStyles = [libStyles]; }
|
|
532
|
-
if (Array.isArray(libStyles)) {
|
|
533
|
-
for (var i = 0; i < libStyles.length; i++) {
|
|
534
|
-
style = document.createElement('link');
|
|
535
|
-
style.setAttribute('rel', 'stylesheet');
|
|
536
|
-
style.setAttribute('type', 'text/css');
|
|
537
|
-
style.setAttribute('href', libStyles[i]);
|
|
538
|
-
style.classList.add('external_' + lib_name);
|
|
539
|
-
head.appendChild(style);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
561
|
+
/* --------------------------------------------------------- initJsoneditor */
|
|
542
562
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
case 'selectize':
|
|
548
|
-
JSONEditor.plugins.selectize.enable = true;
|
|
549
|
-
break;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
if(!no_reload) {
|
|
553
|
-
reload(true);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
).catch(
|
|
557
|
-
function(reason) {
|
|
558
|
-
console.log('Error loading script: ', reason)
|
|
559
|
-
}
|
|
560
|
-
);
|
|
561
|
-
}
|
|
563
|
+
var initJsoneditor = function () {
|
|
564
|
+
// destroy old JSONEditor instance if exists
|
|
565
|
+
if (jsoneditor) {
|
|
566
|
+
jsoneditor.destroy()
|
|
562
567
|
}
|
|
563
568
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
var selected = this.querySelectorAll(':checked'),
|
|
581
|
-
unselected = this.querySelectorAll(':not(:checked)');
|
|
582
|
-
|
|
583
|
-
for (var i=0;i<unselected.length;i++) {
|
|
584
|
-
var els = document.getElementsByTagName('head')[0].getElementsByClassName('external_' + unselected[i].value);
|
|
585
|
-
for (var j=els.length-1;j>=0;j--) {
|
|
586
|
-
if (unselected[i].value == 'selectize') JSONEditor.plugins.selectize.enable = false;
|
|
587
|
-
els[j].parentNode.removeChild(els[j]);
|
|
588
|
-
}
|
|
569
|
+
// new instance of JSONEditor
|
|
570
|
+
jsoneditor = new window.JSONEditor(jsonEditorForm, data.options)
|
|
571
|
+
|
|
572
|
+
// listen for changes
|
|
573
|
+
jsoneditor.on('change', function () {
|
|
574
|
+
// output
|
|
575
|
+
var json = jsoneditor.getValue()
|
|
576
|
+
outputTextarea.setValue(JSON.stringify(json, null, 2))
|
|
577
|
+
outputTextarea.clearSelection(1)
|
|
578
|
+
|
|
579
|
+
// validate
|
|
580
|
+
var validationErrors = jsoneditor.validate()
|
|
581
|
+
if (validationErrors.length) {
|
|
582
|
+
validateTextarea.value = JSON.stringify(validationErrors, null, 2)
|
|
583
|
+
} else {
|
|
584
|
+
validateTextarea.value = 'valid'
|
|
589
585
|
}
|
|
586
|
+
})
|
|
587
|
+
updateDirectLink()
|
|
588
|
+
}
|
|
590
589
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
JSONEditor.defaults.options.show_errors = this.value;
|
|
602
|
-
reload(true);
|
|
603
|
-
});
|
|
604
|
-
document.getElementById('boolean_options').addEventListener('change',function() {
|
|
605
|
-
refreshBooleanOptions();
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
// Get starting value from url
|
|
609
|
-
if(window.location.href.match('[?&]value=([^&]+)')) {
|
|
610
|
-
window.startval = JSON.parse(LZString.decompressFromBase64(window.location.href.match('[?&]value=([^&]+)')[1]));
|
|
611
|
-
}
|
|
590
|
+
/* ------------------------------------------------------- updateDirectLink */
|
|
591
|
+
|
|
592
|
+
var updateDirectLink = function () {
|
|
593
|
+
var url = window.location.href.replace(/\?.*/, '')
|
|
594
|
+
url += '?data='
|
|
595
|
+
url += LZString.compressToBase64(JSON.stringify(data))
|
|
596
|
+
directLink.href = url
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/* -------------------------------------------------------- event listeners */
|
|
612
600
|
|
|
613
|
-
|
|
614
|
-
|
|
601
|
+
setValue.addEventListener('click', function () {
|
|
602
|
+
jsoneditor.setValue(JSON.parse(outputTextarea.getValue()))
|
|
603
|
+
})
|
|
615
604
|
|
|
616
|
-
|
|
605
|
+
setSchema.addEventListener('click', function () {
|
|
606
|
+
try {
|
|
607
|
+
data.options.schema = JSON.parse(schemaTextarea.getValue())
|
|
608
|
+
validateSchema()
|
|
609
|
+
} catch (e) {
|
|
610
|
+
alert('Invalid Schema: ' + e.message)
|
|
611
|
+
return
|
|
612
|
+
}
|
|
613
|
+
refreshUI()
|
|
614
|
+
})
|
|
615
|
+
|
|
616
|
+
themeSelect.addEventListener('change', function () {
|
|
617
|
+
data.options.theme = this.value || ''
|
|
618
|
+
refreshUI()
|
|
619
|
+
})
|
|
620
|
+
|
|
621
|
+
iconlibSelect.addEventListener('change', function () {
|
|
622
|
+
data.options.iconlib = this.value || ''
|
|
623
|
+
refreshUI()
|
|
624
|
+
})
|
|
625
|
+
|
|
626
|
+
objectLayoutSelect.addEventListener('change', function () {
|
|
627
|
+
data.options.object_layout = this.value || ''
|
|
628
|
+
refreshUI()
|
|
629
|
+
})
|
|
630
|
+
|
|
631
|
+
showErrorsSelect.addEventListener('change', function () {
|
|
632
|
+
data.options.show_errors = this.value || ''
|
|
633
|
+
refreshUI()
|
|
634
|
+
})
|
|
635
|
+
|
|
636
|
+
booleanOptionsSelect.addEventListener('change', function () {
|
|
637
|
+
var booleanOptions = this.children
|
|
638
|
+
for (var i = 0; i < booleanOptions.length; i++) {
|
|
639
|
+
data.options[booleanOptions[i].value] = booleanOptions[i].selected
|
|
640
|
+
}
|
|
641
|
+
refreshUI()
|
|
642
|
+
})
|
|
617
643
|
|
|
618
|
-
|
|
619
|
-
|
|
644
|
+
libSelect.addEventListener('change', function () {
|
|
645
|
+
data.selectedLibs = []
|
|
646
|
+
data.unselectedLibs = []
|
|
620
647
|
|
|
621
|
-
|
|
622
|
-
JSONEditor.defaults.options.show_errors = document.getElementById('show_errors').value;
|
|
648
|
+
var libs = this.children
|
|
623
649
|
|
|
624
|
-
var
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
lib_switcher.options[i].selected = (lib_switcher_values.indexOf(lib_switcher.options[i].value)>-1);
|
|
630
|
-
if (lib_switcher.options[i].selected) setExternalLib(lib_switcher.options[i].value);
|
|
650
|
+
for (var i = 0; i < libs.length; i++) {
|
|
651
|
+
if (libs[i].selected) {
|
|
652
|
+
data.selectedLibs.push(libs[i].value)
|
|
653
|
+
} else {
|
|
654
|
+
data.unselectedLibs.push(libs[i].value)
|
|
631
655
|
}
|
|
632
656
|
}
|
|
657
|
+
refreshUI()
|
|
658
|
+
})
|
|
633
659
|
|
|
634
|
-
|
|
635
|
-
for(var i=0; i<boolean_options.length; i++) {
|
|
636
|
-
if(window.location.href.match(new RegExp('[?&]'+boolean_options[i].getAttribute('value')+'([&=]|$)'))) {
|
|
637
|
-
boolean_options[i].selected = true;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
refreshBooleanOptions(true);
|
|
660
|
+
parseUrl()
|
|
641
661
|
|
|
642
|
-
reload();
|
|
643
|
-
})();
|
|
644
662
|
</script>
|
|
645
663
|
</body>
|
|
646
664
|
</html>
|