@json-editor/json-editor 2.5.2 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) 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 +39 -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 +3711 -3324
  11. package/dist/nonmin/jsoneditor.js.map +1 -1
  12. package/docs/cleave.html +1 -1
  13. package/docs/datetime.html +1 -1
  14. package/docs/describedby.html +1 -1
  15. package/docs/index.html +4 -2
  16. package/docs/materialize_css.html +1 -1
  17. package/docs/meta_schema.json +0 -1
  18. package/docs/radio.html +1 -1
  19. package/docs/select2.html +1 -1
  20. package/docs/selectize.html +1 -1
  21. package/docs/starrating.html +1 -1
  22. package/docs/wysiwyg.html +1 -1
  23. package/package.json +27 -26
  24. package/release-notes.md +9 -9
  25. package/src/core.js +1 -0
  26. package/src/defaults.js +182 -94
  27. package/src/editor.js +28 -9
  28. package/src/editors/array.js +20 -16
  29. package/src/editors/autocomplete.js +1 -0
  30. package/src/editors/base64.js +5 -4
  31. package/src/editors/button.js +2 -2
  32. package/src/editors/checkbox.js +3 -3
  33. package/src/editors/datetime.js +2 -2
  34. package/src/editors/info.js +1 -1
  35. package/src/editors/multiple.js +8 -2
  36. package/src/editors/multiselect.js +5 -3
  37. package/src/editors/object.js +35 -21
  38. package/src/editors/radio.js +9 -4
  39. package/src/editors/select.js +6 -6
  40. package/src/editors/signature.js +3 -2
  41. package/src/editors/starrating.js +5 -5
  42. package/src/editors/string.js +6 -4
  43. package/src/editors/table.js +24 -14
  44. package/src/editors/upload.js +4 -3
  45. package/src/editors/uuid.js +1 -1
  46. package/src/iconlibs/index.js +2 -0
  47. package/src/iconlibs/openiconic.js +28 -0
  48. package/src/schemaloader.js +112 -28
  49. package/src/theme.js +6 -3
  50. package/src/themes/bootstrap3.js +4 -4
  51. package/src/themes/bootstrap4.js +11 -3
  52. package/src/themes/html.js +1 -2
  53. package/src/themes/materialize.js +1 -1
  54. package/src/themes/spectre.js +11 -8
  55. package/src/themes/tailwind.js +1 -1
  56. package/src/validator.js +128 -16
  57. package/tests/codeceptjs/core_test.js +125 -1
  58. package/tests/codeceptjs/editors/array_test.js +13 -11
  59. package/tests/codeceptjs/editors/button_test.js +6 -1
  60. package/tests/codeceptjs/editors/issues/issue-gh-812_test.js +32 -0
  61. package/tests/codeceptjs/editors/number_test.js +1 -1
  62. package/tests/codeceptjs/editors/object_test.js +216 -100
  63. package/tests/codeceptjs/editors/programmatic-changes_test.js +3 -1
  64. package/tests/codeceptjs/editors/radio_test.js +10 -0
  65. package/tests/codeceptjs/editors/rating_test.js +10 -11
  66. package/tests/codeceptjs/editors/select_test.js +17 -15
  67. package/tests/codeceptjs/editors/stepper_test.js +13 -1
  68. package/tests/codeceptjs/editors/string_test.js +81 -80
  69. package/tests/codeceptjs/editors/table-confirm-delete_test.js +58 -56
  70. package/tests/codeceptjs/editors/tabs_test.js +12 -10
  71. package/tests/codeceptjs/editors/validation_test.js +10 -8
  72. package/tests/codeceptjs/meta-schema_test.js +13 -14
  73. package/tests/codeceptjs/schemaloader_test.js +13 -0
  74. package/tests/codeceptjs/steps_file.js +4 -3
  75. package/tests/codeceptjs/themes_test.js +31 -0
  76. package/tests/docker-compose.yml +4 -3
  77. package/tests/fixtures/validation.json +382 -1
  78. package/tests/pages/_demo.html +2 -0
  79. package/tests/pages/anyof.html +80 -0
  80. package/tests/pages/issues/issue-gh-812.html +110 -0
  81. package/tests/pages/issues/issue-gh-848.html +81 -0
  82. package/tests/pages/meta_schema.json +0 -1
  83. package/tests/pages/object-no-additional-properties.html +27 -12
  84. package/tests/pages/object-required-properties.html +43 -9
  85. package/tests/pages/object-show-opt-in.html +110 -0
  86. package/tests/pages/object-with-dependencies-array.html +56 -0
  87. package/tests/pages/oneof.html +103 -0
  88. package/tests/pages/read-only.html +19 -4
  89. package/tests/pages/stepper-manual.html +57 -0
  90. package/tests/pages/themes.html +2 -0
  91. package/tests/pages/translate-property.html +247 -0
  92. package/tests/pages/urn.html +93 -0
  93. package/tests/unit/core.spec.js +2 -0
  94. package/tests/unit/defaults.spec.js +4 -2
  95. package/tests/unit/editor.spec.js +2 -0
  96. package/tests/unit/editors/array.spec.js +86 -0
  97. package/tests/unit/editors/table.spec.js +91 -0
  98. package/tests/unit/schemaloader.spec.js +362 -3
  99. 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.1
4
+
5
+ - Fix for #900 to close the properties modal when we click outside modal
6
+ - fix: Rework use of event.path to prevent a ReferenceError in Safari
7
+ - Fix for dependencies when dependency is an array
8
+
9
+ ### 2.6.0
10
+
11
+ - set show_opt_in per object editor
12
+ - stepper manual set init fix
13
+ - don't validate dependant editors when not visible (dependency not fulfilled)
14
+ - hardened tests
15
+ - bootstra3 tabs fix
16
+ - removed datetime from metaschema and readmy (deprecated)
17
+ - not forced required for radios
18
+ - audit fixes
19
+ - pass additional pathDepth parameter to getHeader() to allow themes to render headings hierarchically
20
+ - add Open Iconic iconlib
21
+ - switched CI to Github Actions
22
+ - read-only base64 editors respect enum values when calling setValue()
23
+ - fix bug in validator.fitTest where anyOf schemata were not handled correctly
24
+ - fixes accessibility support for thead that consist of an empty string
25
+ - fix bug in validation where invalid schemata with a good fitTestResult were preferred to valid schemata
26
+
27
+ ### 2.5.4
28
+
29
+ - fixes #997 add accessibility support for string input types
30
+
31
+ ### 2.5.3
32
+
33
+ - fix oneOf and anyOf error messages
34
+ - fix 159 set value
35
+ - Added more read-only tests for #831
36
+ - Update PULL_REQUEST_TEMPLATE.md
37
+ - fixes #922 - translate all buttons; translator no longer throws error
38
+ - fixes #159, #285, #820 - setting array with 0, false, or ""
39
+ - fixes #379 and #923 - strip #fragment from URI so json pointers resolve correctly
40
+ - add Open Iconic iconlib
41
+ - fix for #811 Property names
42
+
3
43
  ### 2.5.2
4
44
 
5
45
  - Fixed stepper editor safari bug
@@ -54,7 +94,7 @@
54
94
  - Fix of #701 - editors/number.js and editors/integer.js don't change values when validation is failed
55
95
  - Fix of #716 - add ignore for allOf to fall in line with existing ignores of anyOf/oneOf for additionalProperties validation
56
96
  - Fix of #714 - Checkboxes inside object tables duplicate labels from heading
57
- - Added copy button to arrays in table format
97
+ - Added copy button to arrays in table format
58
98
 
59
99
  ### 2.1.0
60
100
  - 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
@@ -744,6 +752,33 @@ __SimpleMDE__ is a simple Markdown editor with live preview. To use it, set the
744
752
  }
745
753
  ```
746
754
 
755
+ To customize the editor, add the [configuration](https://github.com/sparksuite/simplemde-markdown-editor#configuration) in the `simplemde` option:
756
+
757
+ ```json
758
+ {
759
+ "type": "string",
760
+ "format": "markdown",
761
+ "options": {
762
+ "simplemde": {
763
+ "toolbar": [
764
+ "bold",
765
+ "italic",
766
+ "heading",
767
+ "|",
768
+ "link",
769
+ "quote",
770
+ "|",
771
+ "preview",
772
+ "fullscreen",
773
+ "guide"
774
+ ],
775
+ "spellChecker": false
776
+ }
777
+ }
778
+ }
779
+ ```
780
+
781
+
747
782
  __Ace Editor__ is a syntax highlighting source code editor. You can use it by setting the format to any of the following:
748
783
 
749
784
  * actionscript
@@ -1507,7 +1542,7 @@ By default, all instances of JSON Editor will use the `en` language. To overrid
1507
1542
  JSONEditor.defaults.language = "es";
1508
1543
  ```
1509
1544
 
1510
- Button Custimization
1545
+ Button Customization
1511
1546
  -----------------
1512
1547
 
1513
1548
  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']