@json-editor/json-editor 2.9.1 → 2.10.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 (87) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +47 -1
  3. package/dist/jsoneditor.js +1 -1
  4. package/dist/jsoneditor.js.LICENSE.txt +1 -1
  5. package/dist/nonmin/jsoneditor.js +445 -124
  6. package/dist/nonmin/jsoneditor.js.map +1 -1
  7. package/docs/css_integration.html +17 -15
  8. package/docs/custom-editor.html +92 -0
  9. package/docs/index.html +4 -1
  10. package/docs/meta_schema.json +426 -398
  11. package/package.json +1 -1
  12. package/src/defaults.js +15 -1
  13. package/src/editor.js +23 -6
  14. package/src/editors/multiple.js +64 -7
  15. package/src/editors/object.js +0 -1
  16. package/src/iconlibs/bootstrap.js +28 -0
  17. package/src/iconlibs/index.js +2 -0
  18. package/src/resolvers.js +5 -2
  19. package/src/schemaloader.js +3 -1
  20. package/src/themes/bootstrap3.js +1 -1
  21. package/src/utilities.js +22 -0
  22. package/src/validator.js +93 -0
  23. package/tests/codeceptjs/constrains/contains_test.js +36 -0
  24. package/tests/codeceptjs/constrains/dependentSchemas_test.js +15 -0
  25. package/tests/codeceptjs/constrains/if-then-else_test.js +143 -0
  26. package/tests/codeceptjs/core_test.js +27 -27
  27. package/tests/codeceptjs/editors/advanced_test.js +11 -10
  28. package/tests/codeceptjs/editors/array_any_of_test.js +35 -35
  29. package/tests/codeceptjs/editors/array_test.js +757 -767
  30. package/tests/codeceptjs/editors/autocomplete_test.js +1 -3
  31. package/tests/codeceptjs/editors/button_test.js +25 -24
  32. package/tests/codeceptjs/editors/checkbox_test.js +17 -16
  33. package/tests/codeceptjs/editors/colorpicker_test.js +18 -16
  34. package/tests/codeceptjs/editors/datetime_test.js +7 -7
  35. package/tests/codeceptjs/editors/inheritance_test.js +7 -8
  36. package/tests/codeceptjs/editors/integer_test.js +71 -72
  37. package/tests/codeceptjs/editors/jodit_test.js +16 -17
  38. package/tests/codeceptjs/editors/multiselect_test.js +5 -5
  39. package/tests/codeceptjs/editors/number_test.js +64 -65
  40. package/tests/codeceptjs/editors/object_test.js +39 -13
  41. package/tests/codeceptjs/editors/option-no_default_values_test.js +4 -4
  42. package/tests/codeceptjs/editors/programmatic-changes_test.js +2 -3
  43. package/tests/codeceptjs/editors/range_test.js +1 -3
  44. package/tests/codeceptjs/editors/select_test.js +3 -5
  45. package/tests/codeceptjs/editors/stepper_test.js +5 -7
  46. package/tests/codeceptjs/editors/string_test.js +8 -8
  47. package/tests/codeceptjs/editors/table-confirm-delete_test.js +7 -9
  48. package/tests/codeceptjs/editors/uuid_test.js +10 -10
  49. package/tests/codeceptjs/editors/validation_test.js +1 -1
  50. package/tests/codeceptjs/{editors/issues → issues}/issue-gh-1133_test.js +1 -3
  51. package/tests/codeceptjs/issues/issue-gh-1158-2_test.js +10 -0
  52. package/tests/codeceptjs/{editors/issues → issues}/issue-gh-1158_test.js +0 -2
  53. package/tests/codeceptjs/issues/issue-gh-1164_test.js +10 -0
  54. package/tests/codeceptjs/issues/issue-gh-1211_test.js +17 -0
  55. package/tests/codeceptjs/{editors/issues → issues}/issue-gh-1257_test.js +2 -4
  56. package/tests/codeceptjs/issues/issue-gh-1338_test.js +16 -0
  57. package/tests/codeceptjs/issues/issue-gh-1347_test.js +8 -0
  58. package/tests/codeceptjs/issues/issue-gh-795_test.js +13 -0
  59. package/tests/codeceptjs/issues/issue-gh-810_test.js +52 -0
  60. package/tests/codeceptjs/issues/issue-gh-812_test.js +25 -0
  61. package/tests/codeceptjs/meta-schema_test.js +10 -10
  62. package/tests/codeceptjs/schemaloader_test.js +7 -7
  63. package/tests/codeceptjs/themes_test.js +31 -0
  64. package/tests/pages/autocomplete.html +1 -0
  65. package/tests/pages/contains.html +38 -0
  66. package/tests/pages/dependentSchemas.html +52 -0
  67. package/tests/pages/if-else.html +57 -0
  68. package/tests/pages/if-then-else-allOf.html +117 -0
  69. package/tests/pages/if-then-else.html +64 -0
  70. package/tests/pages/if-then.html +57 -0
  71. package/tests/pages/issues/issue-gh-1158-2.html +189 -0
  72. package/tests/pages/issues/issue-gh-1165.html +63 -0
  73. package/tests/pages/issues/issue-gh-1165.json +8 -0
  74. package/tests/pages/issues/issue-gh-1211.html +1022 -0
  75. package/tests/pages/issues/issue-gh-1338.html +74 -0
  76. package/tests/pages/issues/issue-gh-1347.html +142 -0
  77. package/tests/pages/issues/issue-gh-795.html +58 -0
  78. package/tests/pages/issues/issue-gh-810.html +149 -0
  79. package/tests/pages/maxContains.html +39 -0
  80. package/tests/pages/meta-schema.html +28 -0
  81. package/tests/pages/meta_schema.json +426 -398
  82. package/tests/pages/minContains.html +39 -0
  83. package/tests/pages/option-dependencies.html +106 -0
  84. package/tests/pages/themes.html +3 -1
  85. package/tests/unit/core.spec.js +2 -5
  86. package/tests/codeceptjs/editors/issues/issue-gh-1164_test.js +0 -12
  87. package/tests/codeceptjs/editors/issues/issue-gh-812_test.js +0 -32
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>minContains</title>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
8
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
9
+ </head>
10
+ <body>
11
+
12
+ <div class="container">
13
+ <div id='editor-container'></div>
14
+ </div>
15
+
16
+ <script>
17
+ var editorContainer = document.querySelector('#editor-container')
18
+ var schema = {
19
+ 'title': 'minContains',
20
+ 'type': 'array',
21
+ 'items': {
22
+ 'type': 'number'
23
+ },
24
+ 'contains': {
25
+ 'type': 'number'
26
+ },
27
+ 'minContains': 2
28
+ }
29
+
30
+ var editor = new JSONEditor(editorContainer, {
31
+ schema: schema,
32
+ theme: 'bootstrap4',
33
+ iconlib: 'fontawesome',
34
+ show_errors: 'always'
35
+ })
36
+ </script>
37
+
38
+ </body>
39
+ </html>
@@ -0,0 +1,106 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>option: dependencies</title>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
8
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
9
+ </head>
10
+ <body>
11
+
12
+ <div class="container">
13
+ <div id='editor-container'></div>
14
+ </div>
15
+
16
+ <script>
17
+ var editorContainer = document.querySelector('#editor-container')
18
+ var schema = {
19
+ "title": "Person",
20
+ "type": "object",
21
+ "required": [
22
+ "gender"
23
+ ],
24
+ "properties": {
25
+ "gender": {
26
+ "title": "Gender",
27
+ "type": "string",
28
+ "enum": [
29
+ "female",
30
+ "male",
31
+ "other"
32
+ ]
33
+ },
34
+ "maleSpecific": {
35
+ "type": "string",
36
+ "title": "Male specific question?",
37
+ "options": {
38
+ "dependencies": {
39
+ "gender": "male"
40
+ }
41
+ }
42
+ },
43
+ "femaleSpecific": {
44
+ "type": "string",
45
+ "title": "Female specific question?",
46
+ "options": {
47
+ "dependencies": {
48
+ "gender": "female"
49
+ }
50
+ }
51
+ },
52
+ "otherSpecific": {
53
+ "type": "string",
54
+ "title": "What is your preferred gender?",
55
+ "options": {
56
+ "dependencies": {
57
+ "gender": "other"
58
+ }
59
+ }
60
+ },
61
+ "age": {
62
+ "type": "object",
63
+ "properties": {
64
+ "maleSpecificAge": {
65
+ "type": "string",
66
+ "title": "Male specific age question?",
67
+ "options": {
68
+ "dependencies": {
69
+ "root.gender": "male"
70
+ }
71
+ }
72
+ },
73
+ "femaleSpecificAge": {
74
+ "type": "string",
75
+ "title": "Female specific age question?",
76
+ "options": {
77
+ "dependencies": {
78
+ "root.gender": "female"
79
+ }
80
+ }
81
+ },
82
+ "otherSpecificAge": {
83
+ "type": "string",
84
+ "title": "Other specific age question?",
85
+ "options": {
86
+ "dependencies": {
87
+ "root.gender": "other"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+
96
+
97
+ var editor = new JSONEditor(editorContainer, {
98
+ schema: schema,
99
+ theme: 'bootstrap4',
100
+ iconlib: 'fontawesome',
101
+ show_errors: 'always'
102
+ })
103
+ </script>
104
+
105
+ </body>
106
+ </html>
@@ -41,6 +41,7 @@
41
41
  <option value='materialicons'>Material icons</option>
42
42
  <option value='openiconic'>Open Iconic</option>
43
43
  <option value='spectre'>Spectre</option>
44
+ <option value='bootstrap'>Bootstrap Icons</option>
44
45
  </select>
45
46
  </div>
46
47
  <div class="container">
@@ -514,7 +515,8 @@
514
515
  jqueryui: 'https://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css',
515
516
  materialicons: 'https://fonts.googleapis.com/icon?family=Material+Icons',
516
517
  openiconic: 'https://cdnjs.cloudflare.com/ajax/libs/open-iconic/1.1.1/font/css/open-iconic.min.css',
517
- spectre: 'https://unpkg.com/spectre.css/dist/spectre-icons.min.css'
518
+ spectre: 'https://unpkg.com/spectre.css/dist/spectre-icons.min.css',
519
+ bootstrap: 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css'
518
520
  };
519
521
 
520
522
  document.querySelector('#iconlib_stylesheet').href = mapping[iconlib];
@@ -21,15 +21,12 @@ describe('JSONEditor', function () {
21
21
 
22
22
  // inject the HTML fixture for the tests
23
23
  beforeEach(() => {
24
- const fixture = '<div id="fixture"></div>'
25
-
26
- document.body.insertAdjacentHTML('afterbegin', fixture)
24
+ document.body.insertAdjacentHTML('afterbegin', '<div id="fixture"></div>')
27
25
  element = document.getElementById('fixture')
28
26
  })
29
27
 
30
- // remove the html fixture from the DOM
31
28
  afterEach(() => {
32
- document.body.removeChild(document.getElementById('fixture'))
29
+ editor.destroy()
33
30
  })
34
31
 
35
32
  it('should create an editor', () => {
@@ -1,12 +0,0 @@
1
- /* global Feature Scenario */
2
-
3
- const assert = require('assert')
4
-
5
- Feature('GitHub issue 1164')
6
-
7
- Scenario('GitHub issue 1164 should remain fixed @issue-1164', async ({ I }) => {
8
- I.amOnPage('issues/issue-gh-1164.html')
9
- I.waitForElement('.je-ready')
10
- I.waitForInvisible('option[value="undefined"]')
11
- assert.equal(await I.grabValueFrom('#value'), '{"arrayEnumSelect":["one"],"stringEnumRadio":"one","numberEnumRadio":1.1,"integerEnumRadio":1}')
12
- })
@@ -1,32 +0,0 @@
1
- /* global Feature Scenario */
2
-
3
- const assert = require('assert')
4
- let value
5
-
6
- Feature('issues')
7
-
8
- Scenario('GitHub issue 812 should remain fixed @issue-812', async ({ I }) => {
9
- I.amOnPage('issues/issue-gh-812.html')
10
-
11
- I.click('.get-value')
12
- value = await I.grabValueFrom('.debug')
13
- assert.equal(value, '{"students":[{"name":"AAA","sessions":[{"student_name":"AAA","minutes":15},{"student_name":"AAA","minutes":15}]},{"name":"BBB","sessions":[{"student_name":"BBB","minutes":20}]},{"name":"CCC","sessions":[{"student_name":"CCC","minutes":10}]}]}')
14
-
15
- I.amAcceptingPopups()
16
- I.click('//*[@id="root.students.0"]/span[2]/button[contains(@class, "json-editor-btn-delete") and @data-i="0"]')
17
- I.retry({ retries: 5, minTimeout: 500 }).seeInPopup('Are you sure you want to remove this node?')
18
- I.acceptPopup()
19
-
20
- I.click('.get-value')
21
- value = await I.grabValueFrom('.debug')
22
- assert.equal(value, '{"students":[{"name":"BBB","sessions":[{"student_name":"BBB","minutes":20}]},{"name":"CCC","sessions":[{"student_name":"CCC","minutes":10}]}]}')
23
-
24
- I.amAcceptingPopups()
25
- I.click('//*[@id="root.students.0"]/span[2]/button[contains(@class, "json-editor-btn-delete") and @data-i="0"]')
26
- I.retry({ retries: 5, minTimeout: 500 }).seeInPopup('Are you sure you want to remove this node?')
27
- I.acceptPopup()
28
-
29
- I.click('.get-value')
30
- value = await I.grabValueFrom('.debug')
31
- assert.equal(value, '{"students":[{"name":"CCC","sessions":[{"student_name":"CCC","minutes":10}]}]}')
32
- })