@json-editor/json-editor 2.5.4 → 2.7.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.
Files changed (91) hide show
  1. package/.github/workflows/build.yml +12 -3
  2. package/CHANGELOG.md +51 -14
  3. package/README.md +159 -20
  4. package/dist/jsoneditor.js +2 -2
  5. package/dist/nonmin/jsoneditor.js +5483 -3610
  6. package/dist/nonmin/jsoneditor.js.map +1 -1
  7. package/docs/cleave.html +1 -1
  8. package/docs/datetime.html +1 -1
  9. package/docs/describedby.html +1 -1
  10. package/docs/form-submission.html +76 -0
  11. package/docs/index.html +2 -2
  12. package/docs/materialize_css.html +1 -1
  13. package/docs/meta_schema.json +0 -1
  14. package/docs/radio.html +1 -1
  15. package/docs/select2.html +1 -1
  16. package/docs/selectize.html +1 -1
  17. package/docs/starrating.html +1 -1
  18. package/docs/wysiwyg.html +1 -1
  19. package/package.json +28 -26
  20. package/release-notes.md +5 -3
  21. package/src/core.js +36 -37
  22. package/src/defaults.js +9 -2
  23. package/src/editor.js +6 -2
  24. package/src/editors/array.js +12 -1
  25. package/src/editors/autocomplete.js +4 -3
  26. package/src/editors/button.js +1 -1
  27. package/src/editors/multiple.js +2 -0
  28. package/src/editors/multiselect.js +14 -5
  29. package/src/editors/object.js +10 -6
  30. package/src/editors/radio.js +6 -1
  31. package/src/editors/string.js +7 -1
  32. package/src/editors/table.js +21 -2
  33. package/src/editors/upload.js +1 -1
  34. package/src/editors/uuid.js +2 -12
  35. package/src/iconlib.js +1 -1
  36. package/src/schemaloader.js +232 -109
  37. package/src/style.css +3 -0
  38. package/src/style.css.js +1 -1
  39. package/src/theme.js +5 -4
  40. package/src/themes/bootstrap3.js +3 -2
  41. package/src/themes/bootstrap4.js +7 -0
  42. package/src/themes/spectre.js +2 -1
  43. package/src/utilities.js +18 -0
  44. package/src/validator.js +65 -47
  45. package/tests/codeceptjs/codecept.json +1 -1
  46. package/tests/codeceptjs/core_test.js +98 -0
  47. package/tests/codeceptjs/editors/advanced_test.js +1 -1
  48. package/tests/codeceptjs/editors/array_test.js +74 -0
  49. package/tests/codeceptjs/editors/autocomplete_test.js +16 -0
  50. package/tests/codeceptjs/editors/button_test.js +11 -4
  51. package/tests/codeceptjs/editors/integer_test.js +7 -2
  52. package/tests/codeceptjs/editors/jodit_test.js +3 -3
  53. package/tests/codeceptjs/editors/object_test.js +84 -13
  54. package/tests/codeceptjs/editors/range_test.js +12 -0
  55. package/tests/codeceptjs/editors/stepper_test.js +12 -0
  56. package/tests/codeceptjs/editors/uuid_test.js +31 -4
  57. package/tests/codeceptjs/editors/validation_test.js +1 -1
  58. package/tests/docker-compose.yml +1 -1
  59. package/tests/fixtures/definitions.json +22 -0
  60. package/tests/fixtures/properties.json +20 -0
  61. package/tests/fixtures/validation.json +207 -0
  62. package/tests/pages/array-checkboxes-infotext.html +52 -0
  63. package/tests/pages/array-move-events.html +4 -2
  64. package/tests/pages/array-unique-items-sort.html +78 -0
  65. package/tests/pages/autocomplete.html +69 -0
  66. package/tests/pages/button-icons.html +38 -0
  67. package/tests/pages/core.html +4 -2
  68. package/tests/pages/error-messages.html +47 -0
  69. package/tests/pages/grid-strict.html +6 -10
  70. package/tests/pages/grid.html +0 -4
  71. package/tests/pages/issues/issue-gh-812.html +4 -2
  72. package/tests/pages/meta_schema.json +14 -1
  73. package/tests/pages/object-required-properties.html +37 -14
  74. package/tests/pages/object-show-opt-in.html +110 -0
  75. package/tests/pages/object-with-dependencies-array.html +29 -19
  76. package/tests/pages/range.html +60 -0
  77. package/tests/pages/ready.html +43 -0
  78. package/tests/pages/references.html +162 -0
  79. package/tests/pages/stepper-manual.html +57 -0
  80. package/tests/pages/string-simplemde-editor.html +81 -0
  81. package/tests/pages/table-move-events.html +4 -1
  82. package/tests/pages/urn.html +11 -8
  83. package/tests/pages/uuid.html +89 -50
  84. package/tests/pages/validation-messages.json +705 -0
  85. package/tests/unit/core.spec.js +79 -66
  86. package/tests/unit/editor.spec.js +20 -8
  87. package/tests/unit/editors/array.spec.js +3 -2
  88. package/tests/unit/editors/object.spec.js +3 -1
  89. package/tests/unit/editors/table.spec.js +4 -2
  90. package/tests/unit/schemaloader.spec.js +77 -105
  91. package/tests/unit/validator.spec.js +10 -0
@@ -22,7 +22,7 @@ jobs:
22
22
  include:
23
23
  - selenium-browser: "chrome"
24
24
  build-env: "build.prod"
25
- - build-nonmin: "chrome"
25
+ - selenium-browser: "chrome"
26
26
  build-env: "build.nonmin.travis"
27
27
  - selenium-browser: "firefox"
28
28
  build-env: "build.prod"
@@ -50,9 +50,18 @@ jobs:
50
50
  - name: Build
51
51
  run: docker-compose run -T --rm node npm run ${BUILD_ENV}
52
52
  - name: Test
53
- run: docker-compose exec -T node codeceptjs -c /repo/tests/codeceptjs/codecept.json run-multiple basic:${SELENIUM_BROWSER} --invert --grep '@optional'
53
+ run: |
54
+ docker-compose exec -T node codeceptjs -c /repo/tests/codeceptjs/codecept.json run-multiple basic:${SELENIUM_BROWSER} --invert --grep '@optional'
55
+ pwd
56
+ ls -la codeceptjs/output
57
+ - name: Test Artifacts
58
+ if: always()
59
+ uses: actions/upload-artifact@v3
60
+ with:
61
+ name: codeceptjs-output
62
+ path: tests/codeceptjs/output
63
+ retention-days: 30
54
64
  - name: Test (optional)
55
65
  continue-on-error: true
56
66
  run: docker-compose exec -T node codeceptjs -c /repo/tests/codeceptjs/codecept.json run-multiple basic:${SELENIUM_BROWSER} --grep '@optional'
57
67
 
58
-
package/CHANGELOG.md CHANGED
@@ -1,19 +1,56 @@
1
- ### 2.5.4
2
-
1
+ ### Unreleased
2
+
3
+ ### 2.7.0
4
+
5
+ - Fixed array uniqueItems sorting bug
6
+ - Configurable icons for type button editors
7
+ - Fixed autocomplete options rendering
8
+ - Editor gets .je-ready class when ready
9
+ - Regenerate unique UUID when copying arrays
10
+ - Added infoText for checkbox on "Spectre" and "Bootstrap 3" Themes
11
+ - Added configurable error messages at editor schema level feature
12
+ - Added form submission case study and linked it in the readme
13
+ - Fixed range output value rendering
14
+ - Added automated test for references
15
+ - Added SimpleMDE test page
16
+ - JSON pointers support for definitions
17
+ - Added infoText for multiselect enum
18
+ - Updated packages and fixed npm audits
19
+ - Using latest jquery in docs to resolve vulnerabilities
20
+ - fixed bug in upload editor
21
+ - Updated release-motes.md
22
+ - Added feature: override error messages in schema options
23
+ - fixed arbitrary JSON pointers not returning the schema at the pointer path
24
+ - Add infoText for enums with format `checkbox` (default)
25
+ - updated `jodit` devDependency (jodit markup changes)
26
+
27
+ ### 2.6.1
28
+
29
+ - Fix for #900 to close the properties modal when we click outside modal
30
+ - fix: Rework use of event.path to prevent a ReferenceError in Safari
31
+ - Fix for dependencies when dependency is an array
32
+
33
+ ### 2.6.0
34
+
35
+ - set show_opt_in per object editor
36
+ - stepper manual set init fix
37
+ - don't validate dependant editors when not visible (dependency not fulfilled)
38
+ - hardened tests
39
+ - bootstra3 tabs fix
40
+ - removed datetime from metaschema and readmy (deprecated)
41
+ - not forced required for radios
42
+ - audit fixes
3
43
  - pass additional pathDepth parameter to getHeader() to allow themes to render headings hierarchically
4
44
  - add Open Iconic iconlib
5
- - read-only base64 editors respect enum values when calling setValue()
6
- - Added autocomplete example
7
- - fix #976 falsy values and use_default_values = false
8
- - Updated CONTRIBUTING.md
9
- - Added URN support
10
- - Added support for multiple values in dependencies
11
- - Added support for const
12
- - fix #848 oneOf and anyOf error messages
13
- - fixes #379 and #923 - strip #fragment from URI so json pointers resolve correctly
14
- - Human readable error_required message #914
15
45
  - switched CI to Github Actions
16
- - npm audit fix #956
46
+ - read-only base64 editors respect enum values when calling setValue()
47
+ - fix bug in validator.fitTest where anyOf schemata were not handled correctly
48
+ - fixes accessibility support for thead that consist of an empty string
49
+ - fix bug in validation where invalid schemata with a good fitTestResult were preferred to valid schemata
50
+
51
+ ### 2.5.4
52
+
53
+ - fixes #997 add accessibility support for string input types
17
54
 
18
55
  ### 2.5.3
19
56
 
@@ -81,7 +118,7 @@
81
118
  - Fix of #701 - editors/number.js and editors/integer.js don't change values when validation is failed
82
119
  - Fix of #716 - add ignore for allOf to fall in line with existing ignores of anyOf/oneOf for additionalProperties validation
83
120
  - Fix of #714 - Checkboxes inside object tables duplicate labels from heading
84
- - Added copy button to arrays in table format
121
+ - Added copy button to arrays in table format
85
122
 
86
123
  ### 2.1.0
87
124
  - fixed vulnerability in "http-server" package (origin/feature/merges-20200227, feature/merges-20200227) - using latest node LTS
package/README.md CHANGED
@@ -11,6 +11,7 @@ Some pull requests added from the original repo.
11
11
  JSON Editor takes a JSON Schema and uses it to generate an HTML form.
12
12
  It has full support for JSON Schema version 3 and 4 and can integrate with several popular CSS frameworks (bootstrap, spectre, tailwind).
13
13
 
14
+ Take a look at this [example](https://json-editor.github.io/json-editor/form-submission.html) for a simple form submission case study.
14
15
  ### Online Demo
15
16
 
16
17
  Check out an interactive demo: https://json-editor.github.io/json-editor/
@@ -521,7 +522,7 @@ Some of The [hyper-schema][hyper] specification is supported as well.
521
522
 
522
523
  ### $ref and definitions
523
524
 
524
- JSON Editor supports schema references to external URLs and local definitions. Here's an example showing both:
525
+ JSON Editor supports schema references to external URLs and local definitions as well as JSON Pointers. Here's an example:
525
526
 
526
527
  ```json
527
528
  {
@@ -533,6 +534,9 @@ JSON Editor supports schema references to external URLs and local definitions.
533
534
  },
534
535
  "location": {
535
536
  "$ref": "http://mydomain.com/geo.json"
537
+ },
538
+ "birthday": {
539
+ "$ref": "http://mydomain.com/person.json#/definitions/birthdate"
536
540
  }
537
541
  },
538
542
  "definitions": {
@@ -676,7 +680,6 @@ JSON Editor uses HTML5 input types, so some of these may render as basic text in
676
680
 
677
681
  * color
678
682
  * date
679
- * datetime
680
683
  * datetime-local
681
684
  * email
682
685
  * month
@@ -753,6 +756,33 @@ __SimpleMDE__ is a simple Markdown editor with live preview. To use it, set the
753
756
  }
754
757
  ```
755
758
 
759
+ To customize the editor, add the [configuration](https://github.com/sparksuite/simplemde-markdown-editor#configuration) in the `simplemde` option:
760
+
761
+ ```json
762
+ {
763
+ "type": "string",
764
+ "format": "markdown",
765
+ "options": {
766
+ "simplemde": {
767
+ "toolbar": [
768
+ "bold",
769
+ "italic",
770
+ "heading",
771
+ "|",
772
+ "link",
773
+ "quote",
774
+ "|",
775
+ "preview",
776
+ "fullscreen",
777
+ "guide"
778
+ ],
779
+ "spellChecker": false
780
+ }
781
+ }
782
+ }
783
+ ```
784
+
785
+
756
786
  __Ace Editor__ is a syntax highlighting source code editor. You can use it by setting the format to any of the following:
757
787
 
758
788
  * actionscript
@@ -841,6 +871,55 @@ You can enable [Ace editor options](https://github.com/ajaxorg/ace/wiki/Configur
841
871
  }
842
872
  ```
843
873
 
874
+ ### Special editors
875
+
876
+ JSONEditor features specialized types of editors.
877
+
878
+ #### Button editor
879
+
880
+ Creates a button whose click callback can be defined in `JSONEditor.defaults.callbacks`. Options:
881
+
882
+ - `icon`: Renders an icon into the button. Must be supported by the iconLib used.
883
+ - `validated`: With `true` the button is disabled until the whole editor is valid.
884
+ - `action`: the name of the callback that will be invoked when the button is clicked. Callbacks
885
+ must be defined in `JSONEditor.defaults.callbacks`.
886
+
887
+ ```js
888
+ JSONEditor.defaults.callbacks = {
889
+ "button" : {
890
+ "myAction" : function (jseditor, e) {
891
+ alert('Button action')
892
+ }
893
+ }
894
+ }
895
+ ```
896
+
897
+ ```json
898
+ {
899
+ "type": "button",
900
+ "title": "Search",
901
+ "options": {
902
+ "button": {
903
+ "icon": "search",
904
+ "action": "myAction",
905
+ "validated": true
906
+ }
907
+ }
908
+ }
909
+ ```
910
+
911
+ #### Info editor
912
+
913
+ Displays a label and a description text.
914
+
915
+ ```json
916
+ {
917
+ "type": "info",
918
+ "title": "Important:",
919
+ "description": "Lorem ipsum dolor"
920
+ }
921
+ ```
922
+
844
923
  #### Booleans
845
924
 
846
925
  The default boolean editor is a select box with options "true" and "false". To use a checkbox instead, set the format to `checkbox`.
@@ -1009,23 +1088,24 @@ Editor Options
1009
1088
 
1010
1089
  Editors can accept options which alter the behavior in some way.
1011
1090
 
1012
- * `collapsed` - If set to true, the editor will start collapsed (works for objects and arrays)
1013
- * `disable_array_add` - If set to true, the "add row" button will be hidden (works for arrays)
1014
- * `disable_array_delete` - If set to true, all of the "delete" buttons will be hidden (works for arrays)
1015
- * `disable_array_delete_all_rows` - If set to true, just the "delete all rows" button will be hidden (works for arrays)
1016
- * `disable_array_delete_last_row` - If set to true, just the "delete last row" buttons will be hidden (works for arrays)
1017
- * `disable_array_reorder` - If set to true, the "move up/down" buttons will be hidden (works for arrays)
1018
- * `disable_collapse` - If set to true, the collapse button will be hidden (works for objects and arrays)
1019
- * `disable_edit_json` - If set to true, the Edit JSON button will be hidden (works for objects)
1020
- * `disable_properties` - If set to true, the Edit Properties button will be hidden (works for objects)
1021
- * `array_controls_top` - If set to true, array controls (add, delete etc) will be displayed at top of list (works for arrays)
1022
- * `enum_titles` - An array of display values to use for select box options in the same order as defined with the `enum` keyword. Works with schema using enum values.
1023
- * `expand_height` - If set to true, the input will auto expand/contract to fit the content. Works best with textareas.
1024
- * `grid_columns` - Explicitly set the number of grid columns (1-12) for the editor if it's within an object using a grid layout.
1025
- * `hidden` - If set to true, the editor will not appear in the UI (works for all types)
1026
- * `input_height` - Explicitly set the height of the input element. Should be a valid CSS width string (e.g. "100px"). Works best with textareas.
1027
- * `input_width` - Explicitly set the width of the input element. Should be a valid CSS width string (e.g. "100px"). Works for string, number, and integer data types.
1028
- * `remove_empty_properties` - If set to true for an object, empty object properties (i.e. those with falsy values) will not be returned by getValue().
1091
+ * `collapsed` - If set to true, the editor will start collapsed (works for objects and arrays)
1092
+ * `disable_array_add` - If set to true, the "add row" button will be hidden (works for arrays)
1093
+ * `disable_array_delete` - If set to true, all of the "delete" buttons will be hidden (works for arrays)
1094
+ * `disable_array_delete_all_rows` - If set to true, just the "delete all rows" button will be hidden (works for arrays)
1095
+ * `disable_array_delete_last_row` - If set to true, just the "delete last row" buttons will be hidden (works for arrays)
1096
+ * `disable_array_reorder` - If set to true, the "move up/down" buttons will be hidden (works for arrays)
1097
+ * `disable_collapse` - If set to true, the collapse button will be hidden (works for objects and arrays)
1098
+ * `disable_edit_json` - If set to true, the Edit JSON button will be hidden (works for objects)
1099
+ * `disable_properties` - If set to true, the Edit Properties button will be hidden (works for objects)
1100
+ * `array_controls_top` - If set to true, array controls (add, delete etc) will be displayed at top of list (works for arrays)
1101
+ * `enum` - See [Enum options](#enum-options)
1102
+ * `enum_titles` - An array of display values to use for select box options in the same order as defined with the `enum` keyword. Works with schema using enum values.
1103
+ * `expand_height` - If set to true, the input will auto expand/contract to fit the content. Works best with textareas.
1104
+ * `grid_columns` - Explicitly set the number of grid columns (1-12) for the editor if it's within an object using a grid layout.
1105
+ * `hidden` - If set to true, the editor will not appear in the UI (works for all types)
1106
+ * `input_height` - Explicitly set the height of the input element. Should be a valid CSS width string (e.g. "100px"). Works best with textareas.
1107
+ * `input_width` - Explicitly set the width of the input element. Should be a valid CSS width string (e.g. "100px"). Works for string, number, and integer data types.
1108
+ * `remove_empty_properties` - If set to true for an object, empty object properties (i.e. those with falsy values) will not be returned by getValue().
1029
1109
 
1030
1110
  ```json
1031
1111
  {
@@ -1060,6 +1140,43 @@ Using the option `infoText`, will create a info button, displaying the text you
1060
1140
  }
1061
1141
  ```
1062
1142
 
1143
+ Enum options
1144
+ ------------------
1145
+
1146
+ Using the option `enum`, it is possible to modify how enums with format `checkbox` (default) are displayed in the editor.
1147
+ It is an array of objects (described below), which must be in the same order as defined with the `enum` keyword.
1148
+
1149
+ Currently, the following is supported:
1150
+
1151
+ * `title`: *Optional* Display value shown instead of the enum value
1152
+ * `infoText`: *Optional* Creates an info button next to the title, displaying the text you set, on hovering.
1153
+
1154
+ It is possible also to set these options only for some enum values, to skip one enum value, define an empty object (`{}`).
1155
+
1156
+ ```json
1157
+ {
1158
+ "type": "array",
1159
+ "items": {
1160
+ "type": "string",
1161
+ "enum": ["1", "2", "3", "4"],
1162
+ "options": {
1163
+ "enum": [
1164
+ {},
1165
+ {
1166
+ "title": "Title 2"
1167
+ },
1168
+ { "infoText": "InfoText 3" },
1169
+ {
1170
+ "title": "Title 4",
1171
+ "infoText": "InfoText 4"
1172
+ }
1173
+ ]
1174
+ }
1175
+ }
1176
+ }
1177
+ ```
1178
+
1179
+ If both options `enum_titles[x]` and `enum[x].title` are set for the enum value `x`, than the title set under `enum[x].title` will be used.
1063
1180
 
1064
1181
  Dependencies
1065
1182
  ------------------
@@ -1516,7 +1633,29 @@ By default, all instances of JSON Editor will use the `en` language. To overrid
1516
1633
  JSONEditor.defaults.language = "es";
1517
1634
  ```
1518
1635
 
1519
- Button Custimization
1636
+ You can also override translations per editor in the it's schema options.
1637
+
1638
+ ````json
1639
+ "error_const": {
1640
+ "type": "string",
1641
+ "title": "error_const",
1642
+ "const": "test",
1643
+ "default": "something else",
1644
+ "options": {
1645
+ "error_messages": {
1646
+ "en": {
1647
+ "error_const": "CUSTOM EN: Value must be the constant value"
1648
+ },
1649
+ "es": {
1650
+ "error_const": "CUSTOM ES: Value must be the constant value"
1651
+ }
1652
+ }
1653
+ }
1654
+ }
1655
+ ````
1656
+
1657
+
1658
+ Button Customization
1520
1659
  -----------------
1521
1660
 
1522
1661
  All buttons have classnames in the format `json-editor-btntype-*`. Using these classnames you can choose if the button should have icon or label hidden. The icon is wrapped in an `I` tag, the label is wrapped in a `SPAN` tag.