@json-editor/json-editor 2.5.1 → 2.6.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 (92) hide show
  1. package/.eslintrc +5 -2
  2. package/.github/PULL_REQUEST_TEMPLATE.md +6 -6
  3. package/.github/workflows/build.yml +58 -0
  4. package/CHANGELOG.md +41 -1
  5. package/CONTRIBUTING.md +1 -1
  6. package/README.md +12 -4
  7. package/README_ADDON.md +65 -0
  8. package/config/codeceptjs_helpers.js +4 -0
  9. package/dist/jsoneditor.js +2 -2
  10. package/dist/nonmin/jsoneditor.js +3849 -3304
  11. package/dist/nonmin/jsoneditor.js.map +1 -1
  12. package/docs/index.html +2 -0
  13. package/docs/meta_schema.json +0 -1
  14. package/package.json +27 -26
  15. package/release-notes.md +9 -0
  16. package/src/core.js +1 -0
  17. package/src/defaults.js +182 -94
  18. package/src/editor.js +32 -12
  19. package/src/editors/array.js +20 -16
  20. package/src/editors/autocomplete.js +1 -0
  21. package/src/editors/base64.js +5 -4
  22. package/src/editors/button.js +2 -2
  23. package/src/editors/checkbox.js +3 -3
  24. package/src/editors/datetime.js +2 -2
  25. package/src/editors/info.js +1 -1
  26. package/src/editors/multiple.js +8 -2
  27. package/src/editors/multiselect.js +5 -3
  28. package/src/editors/object.js +32 -17
  29. package/src/editors/radio.js +9 -4
  30. package/src/editors/select.js +6 -6
  31. package/src/editors/signature.js +3 -2
  32. package/src/editors/starrating.js +5 -5
  33. package/src/editors/stepper.js +3 -0
  34. package/src/editors/string.js +6 -4
  35. package/src/editors/table.js +24 -14
  36. package/src/editors/upload.js +4 -3
  37. package/src/editors/uuid.js +1 -1
  38. package/src/iconlibs/index.js +2 -0
  39. package/src/iconlibs/openiconic.js +28 -0
  40. package/src/schemaloader.js +112 -28
  41. package/src/theme.js +36 -5
  42. package/src/themes/bootstrap3.js +4 -4
  43. package/src/themes/bootstrap4.js +41 -5
  44. package/src/themes/html.js +1 -2
  45. package/src/themes/materialize.js +1 -1
  46. package/src/themes/spectre.js +11 -8
  47. package/src/themes/tailwind.js +1 -1
  48. package/src/validator.js +129 -17
  49. package/tests/codeceptjs/core_test.js +204 -50
  50. package/tests/codeceptjs/editors/array_test.js +13 -11
  51. package/tests/codeceptjs/editors/button_test.js +6 -1
  52. package/tests/codeceptjs/editors/issues/issue-gh-812_test.js +32 -0
  53. package/tests/codeceptjs/editors/number_test.js +1 -1
  54. package/tests/codeceptjs/editors/object_test.js +194 -98
  55. package/tests/codeceptjs/editors/programmatic-changes_test.js +3 -1
  56. package/tests/codeceptjs/editors/radio_test.js +10 -0
  57. package/tests/codeceptjs/editors/rating_test.js +10 -11
  58. package/tests/codeceptjs/editors/select_test.js +17 -15
  59. package/tests/codeceptjs/editors/stepper_test.js +13 -1
  60. package/tests/codeceptjs/editors/string_test.js +81 -80
  61. package/tests/codeceptjs/editors/table-confirm-delete_test.js +58 -56
  62. package/tests/codeceptjs/editors/tabs_test.js +12 -10
  63. package/tests/codeceptjs/editors/validation_test.js +10 -8
  64. package/tests/codeceptjs/meta-schema_test.js +13 -14
  65. package/tests/codeceptjs/schemaloader_test.js +13 -0
  66. package/tests/codeceptjs/steps_file.js +4 -3
  67. package/tests/codeceptjs/themes_test.js +31 -0
  68. package/tests/docker-compose.yml +4 -3
  69. package/tests/fixtures/validation.json +382 -1
  70. package/tests/pages/_demo.html +2 -0
  71. package/tests/pages/anyof.html +80 -0
  72. package/tests/pages/form-name.html +108 -0
  73. package/tests/pages/issues/issue-gh-812.html +110 -0
  74. package/tests/pages/issues/issue-gh-848.html +81 -0
  75. package/tests/pages/meta_schema.json +0 -1
  76. package/tests/pages/object-no-additional-properties.html +27 -12
  77. package/tests/pages/object-required-properties.html +43 -9
  78. package/tests/pages/object-show-opt-in.html +110 -0
  79. package/tests/pages/object-with-dependencies-array.html +46 -0
  80. package/tests/pages/oneof.html +103 -0
  81. package/tests/pages/read-only.html +19 -4
  82. package/tests/pages/stepper-manual.html +57 -0
  83. package/tests/pages/themes.html +2 -0
  84. package/tests/pages/translate-property.html +247 -0
  85. package/tests/pages/urn.html +93 -0
  86. package/tests/unit/core.spec.js +2 -0
  87. package/tests/unit/defaults.spec.js +4 -2
  88. package/tests/unit/editor.spec.js +2 -0
  89. package/tests/unit/editors/array.spec.js +86 -0
  90. package/tests/unit/editors/table.spec.js +91 -0
  91. package/tests/unit/schemaloader.spec.js +362 -3
  92. package/tests/unit/validator.spec.js +14 -2
package/.eslintrc CHANGED
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "extends":["standard"],
3
- "env": {"browser": true}
4
- }
3
+ "env": {"browser": true},
4
+ "rules": {
5
+ "no-console": "error"
6
+ }
7
+ }
@@ -1,9 +1,9 @@
1
1
  | Q | A
2
2
  | ------------- | ---
3
- | Is bugfix? | ✔️/❌
4
- | New feature? | ✔️/❌
5
- | Breaks backward-compatibility? | ✔️/❌
6
- | Tests pass? | ✔️/❌
3
+ | Is bugfix? | ✔️❌
4
+ | New feature? | ✔️❌
5
+ | Is backward-compatible? | ✔️❌
6
+ | Tests pass? | ✔️❌
7
7
  | Fixed issues | comma-separated list of tickets # fixed by the PR, if any
8
- | Updated README/docs? | ✔️/❌
9
- | Added CHANGELOG entry? | ✔️/❌
8
+ | Updated README/docs? | ✔️❌
9
+ | Added CHANGELOG entry? | ✔️❌
@@ -0,0 +1,58 @@
1
+ name: Build and Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+
7
+ unit-test:
8
+
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - name: Install
13
+ run: npm install
14
+ - name: Test
15
+ run: npm run test-headless
16
+
17
+ end-to-end-test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ include:
23
+ - selenium-browser: "chrome"
24
+ build-env: "build.prod"
25
+ - build-nonmin: "chrome"
26
+ build-env: "build.nonmin.travis"
27
+ - selenium-browser: "firefox"
28
+ build-env: "build.prod"
29
+ - selenium-browser: "firefox"
30
+ build-env: "build.nonmin.travis"
31
+ fail-fast: false
32
+ defaults:
33
+ run:
34
+ shell: bash
35
+ working-directory: tests
36
+
37
+ env:
38
+ SELENIUM_BROWSER: ${{ matrix.selenium-browser }}
39
+ BUILD_ENV: ${{ matrix.build-env }}
40
+
41
+ steps:
42
+ - uses: actions/checkout@v1
43
+ #- name: Install
44
+ # run: |
45
+ # npm install
46
+ - name: Install
47
+ run: docker-compose run -T --rm node npm install
48
+ - name: Start
49
+ run: docker-compose up -d ${SELENIUM_BROWSER}
50
+ - name: Build
51
+ run: docker-compose run -T --rm node npm run ${BUILD_ENV}
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'
54
+ - name: Test (optional)
55
+ continue-on-error: true
56
+ run: docker-compose exec -T node codeceptjs -c /repo/tests/codeceptjs/codecept.json run-multiple basic:${SELENIUM_BROWSER} --grep '@optional'
57
+
58
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  ### Unreleased
2
2
 
3
+ ### 2.6.0
4
+
5
+ - set show_opt_in per object editor
6
+ - stepper manual set init fix
7
+ - don't validate dependant editors when not visible (dependency not fulfilled)
8
+ - hardened tests
9
+ - bootstra3 tabs fix
10
+ - removed datetime from metaschema and readmy (deprecated)
11
+ - not forced required for radios
12
+ - audit fixes
13
+ - pass additional pathDepth parameter to getHeader() to allow themes to render headings hierarchically
14
+ - add Open Iconic iconlib
15
+ - switched CI to Github Actions
16
+ - read-only base64 editors respect enum values when calling setValue()
17
+ - fix bug in validator.fitTest where anyOf schemata were not handled correctly
18
+ - fixes accessibility support for thead that consist of an empty string
19
+ - fix bug in validation where invalid schemata with a good fitTestResult were preferred to valid schemata
20
+
21
+ ### 2.5.4
22
+
23
+ - fixes #997 add accessibility support for string input types
24
+
25
+ ### 2.5.3
26
+
27
+ - fix oneOf and anyOf error messages
28
+ - fix 159 set value
29
+ - Added more read-only tests for #831
30
+ - Update PULL_REQUEST_TEMPLATE.md
31
+ - fixes #922 - translate all buttons; translator no longer throws error
32
+ - fixes #159, #285, #820 - setting array with 0, false, or ""
33
+ - fixes #379 and #923 - strip #fragment from URI so json pointers resolve correctly
34
+ - add Open Iconic iconlib
35
+ - fix for #811 Property names
36
+
37
+ ### 2.5.2
38
+
39
+ - Fixed stepper editor safari bug
40
+ - Added release notes
41
+ - Fixed form_name_root option behaviour
42
+
3
43
  ### 2.5.1
4
44
 
5
45
  - Fix for #837 and chekboxes not displaying error messages #843
@@ -48,7 +88,7 @@
48
88
  - Fix of #701 - editors/number.js and editors/integer.js don't change values when validation is failed
49
89
  - Fix of #716 - add ignore for allOf to fall in line with existing ignores of anyOf/oneOf for additionalProperties validation
50
90
  - Fix of #714 - Checkboxes inside object tables duplicate labels from heading
51
- - Added copy button to arrays in table format
91
+ - Added copy button to arrays in table format
52
92
 
53
93
  ### 2.1.0
54
94
  - fixed vulnerability in "http-server" package (origin/feature/merges-20200227, feature/merges-20200227) - using latest node LTS
package/CONTRIBUTING.md CHANGED
@@ -50,7 +50,7 @@ If you absolutely *must* break a style rule you can disable a rule for the next
50
50
 
51
51
  ### Development
52
52
 
53
- The easiest way to hack on JSON Editor is to run `npm start`, which
53
+ The easiest way to hack on JSON Editor is to run `npm run debug`, which
54
54
  re-builds `dist/jsoneditor.js` every time a source file changes and serves the repo to a
55
55
  development server on port 8080, so you can load test pages such as (http://localhost:8080/tests/pages/array-selectize.html) and immmediately view and debug the results.
56
56
 
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  JSON Editor
2
2
  ===========
3
3
 
4
- [![Build Status](https://travis-ci.org/json-editor/json-editor.svg?branch=master)](https://travis-ci.org/json-editor/json-editor)
4
+ [![Actions Status](https://github.com/json-editor/json-editor/actions/workflows/build.yml/badge.svg)](https://github.com/json-editor/json-editor/actions)
5
+
5
6
  Fork of the inactive [jdorn/json-editor](https://github.com/jdorn/json-editor) using the updated fork [json-editor/json-editor](https://github.com/json-editor/json-editor).
6
7
  Some pull requests added from the original repo.
7
8
 
@@ -10,6 +11,8 @@ Some pull requests added from the original repo.
10
11
  JSON Editor takes a JSON Schema and uses it to generate an HTML form.
11
12
  It has full support for JSON Schema version 3 and 4 and can integrate with several popular CSS frameworks (bootstrap, spectre, tailwind).
12
13
 
14
+ ### Online Demo
15
+
13
16
  Check out an interactive demo: https://json-editor.github.io/json-editor/
14
17
 
15
18
  Or the JSON-Editor Interactive Playground: https://pmk65.github.io/jedemov2/dist/demo.html
@@ -208,7 +211,7 @@ Here are all the available options:
208
211
  </tr>
209
212
  <tr>
210
213
  <td>no_additional_properties</td>
211
- <td>If <code>true</code>, objects can only contain properties defined with the <code>properties</code> keyword.</td>
214
+ <td>If <code>true</code>, objects can only contain properties defined with the <code>properties</code> keyword unless the property <code>additionalProperties: true</code> is specified in the object schema</td>
212
215
  <td><code>false</code></td>
213
216
  </tr>
214
217
  <tr>
@@ -286,6 +289,11 @@ Here are all the available options:
286
289
  <td>If true default values based on the "type" of the property will be used</td>
287
290
  <td><code>true</code></td>
288
291
  </tr>
292
+ <tr>
293
+ <td>urn_resolver</td>
294
+ <td>A callback function to resolve an undefined Uniform Resource Name (URN) for <code>$ref</code>. The function receives a URN and callback to pass back a serialized JSON response. The function should return a boolean (true if the URN can be resolved; false otherwise).</td>
295
+ <td><code>false</code></td>
296
+ </tr>
289
297
  </tbody>
290
298
  </table>
291
299
 
@@ -482,6 +490,7 @@ The supported icon libs are:
482
490
  * fontawesome3
483
491
  * fontawesome4
484
492
  * fontawesome5
493
+ * openiconic
485
494
  * spectre
486
495
 
487
496
  By default, no icons are used. Just like the CSS theme, you can set the icon lib globally or when initializing:
@@ -667,7 +676,6 @@ JSON Editor uses HTML5 input types, so some of these may render as basic text in
667
676
 
668
677
  * color
669
678
  * date
670
- * datetime
671
679
  * datetime-local
672
680
  * email
673
681
  * month
@@ -1507,7 +1515,7 @@ By default, all instances of JSON Editor will use the `en` language. To overrid
1507
1515
  JSONEditor.defaults.language = "es";
1508
1516
  ```
1509
1517
 
1510
- Button Custimization
1518
+ Button Customization
1511
1519
  -----------------
1512
1520
 
1513
1521
  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.
package/README_ADDON.md CHANGED
@@ -141,6 +141,71 @@ For configuration options, see the [Autocomplete homepage](https://autocomplete.
141
141
  **Source:** src/editors/autocomplete.js
142
142
  <br>
143
143
 
144
+ #### Example
145
+
146
+ Javascript
147
+
148
+ ```
149
+ window.JSONEditor.defaults.callbacks = {
150
+ "autocomplete": {
151
+ // This is callback functions for the "autocomplete" editor
152
+ // In the schema you refer to the callback function by key
153
+ // Note: 1st parameter in callback is ALWAYS a reference to the current editor.
154
+ // So you need to add a variable to the callback to hold this (like the
155
+ // "jseditor_editor" variable in the examples below.)
156
+
157
+ // Setup API calls
158
+ "search_za": function search(jseditor_editor, input) {
159
+ var url = '/eiao/api/json-object?filter[or][][data_json][LIKE]=' + encodeURI(input) +'&filter[or][][uuid][LIKE]=' + encodeURI(input);;
160
+
161
+ return new Promise(function (resolve) {
162
+ if (input.length < 2) {
163
+ return resolve([]);
164
+ }
165
+
166
+ fetch(url).then(function (response) {
167
+ return response.json();
168
+ }).then(function (data) {
169
+ resolve(data);
170
+ });
171
+ });
172
+ },
173
+ "renderResult_za": function(jseditor_editor, result, props) {
174
+ return ['<li ' + props + '>',
175
+ '<div class="eiao-object-title">' + result.data_json + '</div>',
176
+ '<div class="eiao-object-snippet">' + result.uuid.substring(0,7) + ' <small>' + result.schema_uuid.substring(0,5) + '<small></div>',
177
+ '</li>'].join('');
178
+ },
179
+ "getResultValue_za": function getResultValue(jseditor_editor, result) {
180
+ return result.uuid;
181
+ }
182
+ }
183
+ };
184
+ ```
185
+
186
+ JSON-schema
187
+
188
+ ```json
189
+ {
190
+ "items": {
191
+ "title": "UUID",
192
+ "type": "string",
193
+ "description": "reference (autocomplete)",
194
+ "format": "autocomplete",
195
+ "options": {
196
+ "autocomplete": {
197
+ "search": "search_za",
198
+ "getResultValue": "getResultValue_za",
199
+ "renderResult": "renderResult_za",
200
+ "autoSelect": true
201
+ }
202
+ }
203
+ },
204
+ "title": "Project references",
205
+ "type": "array"
206
+ }
207
+ ```
208
+
144
209
  ### Checkbox
145
210
  **Description**
146
211
  Checkbox format.
@@ -2,6 +2,10 @@ const assert = require('assert')
2
2
  // eslint-disable-next-line camelcase
3
3
  let Helper = codecept_helper
4
4
 
5
+ const sleep = async (msec) => {
6
+ return new Promise(resolve => setTimeout(resolve, msec))
7
+ }
8
+
5
9
  class customHelpers extends Helper {
6
10
  async donSeeDuplicatedIds () {
7
11
  const helper = this.helpers['Puppeteer'] || this.helpers['WebDriver']