@json-editor/json-editor 2.9.0 → 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 (106) hide show
  1. package/.github/workflows/build.yml +2 -0
  2. package/CHANGELOG.md +29 -7
  3. package/README.md +47 -1
  4. package/config/codeceptjs_helpers.js +4 -8
  5. package/config/karma.conf.js +0 -4
  6. package/config/webpack.common.js +1 -1
  7. package/config/webpack.dev.js +1 -1
  8. package/config/webpack.nonmin.js +1 -1
  9. package/config/webpack.prod.js +0 -1
  10. package/dist/dev/jsoneditor.js +3687 -0
  11. package/dist/jsoneditor.js +2 -14
  12. package/dist/jsoneditor.js.LICENSE.txt +1 -1
  13. package/dist/jsoneditor.js.map +1 -1
  14. package/dist/nonmin/jsoneditor.js +25744 -26450
  15. package/dist/nonmin/jsoneditor.js.map +1 -1
  16. package/docs/css_integration.html +17 -15
  17. package/docs/custom-editor.html +92 -0
  18. package/docs/datetime.html +37 -2
  19. package/docs/index.html +4 -1
  20. package/docs/meta_schema.json +426 -398
  21. package/package.json +26 -24
  22. package/src/defaults.js +15 -1
  23. package/src/editor.js +23 -6
  24. package/src/editors/integer.js +5 -3
  25. package/src/editors/multiple.js +67 -8
  26. package/src/editors/number.js +5 -3
  27. package/src/editors/object.js +0 -1
  28. package/src/editors/radio.js +4 -6
  29. package/src/editors/select.js +0 -6
  30. package/src/iconlibs/bootstrap.js +28 -0
  31. package/src/iconlibs/index.js +2 -0
  32. package/src/resolvers.js +5 -2
  33. package/src/schemaloader.js +3 -1
  34. package/src/themes/bootstrap3.js +1 -1
  35. package/src/utilities.js +22 -0
  36. package/src/validator.js +93 -0
  37. package/tests/codeceptjs/constrains/contains_test.js +36 -0
  38. package/tests/codeceptjs/constrains/dependentSchemas_test.js +15 -0
  39. package/tests/codeceptjs/constrains/if-then-else_test.js +143 -0
  40. package/tests/codeceptjs/core_test.js +46 -46
  41. package/tests/codeceptjs/editors/advanced_test.js +12 -11
  42. package/tests/codeceptjs/editors/array_any_of_test.js +37 -37
  43. package/tests/codeceptjs/editors/array_test.js +784 -794
  44. package/tests/codeceptjs/editors/autocomplete_test.js +4 -6
  45. package/tests/codeceptjs/editors/button_test.js +30 -29
  46. package/tests/codeceptjs/editors/checkbox_test.js +19 -18
  47. package/tests/codeceptjs/editors/colorpicker_test.js +20 -18
  48. package/tests/codeceptjs/editors/datetime_test.js +11 -11
  49. package/tests/codeceptjs/editors/inheritance_test.js +8 -9
  50. package/tests/codeceptjs/editors/integer_test.js +77 -78
  51. package/tests/codeceptjs/editors/jodit_test.js +18 -19
  52. package/tests/codeceptjs/editors/multiselect_test.js +6 -6
  53. package/tests/codeceptjs/editors/number_test.js +72 -71
  54. package/tests/codeceptjs/editors/object_test.js +52 -26
  55. package/tests/codeceptjs/editors/option-no_default_values_test.js +6 -6
  56. package/tests/codeceptjs/editors/programmatic-changes_test.js +4 -5
  57. package/tests/codeceptjs/editors/radio_test.js +1 -1
  58. package/tests/codeceptjs/editors/range_test.js +2 -4
  59. package/tests/codeceptjs/editors/rating_test.js +1 -1
  60. package/tests/codeceptjs/editors/select_test.js +5 -7
  61. package/tests/codeceptjs/editors/stepper_test.js +8 -10
  62. package/tests/codeceptjs/editors/string_test.js +16 -16
  63. package/tests/codeceptjs/editors/table-confirm-delete_test.js +11 -13
  64. package/tests/codeceptjs/editors/tabs_test.js +1 -1
  65. package/tests/codeceptjs/editors/uuid_test.js +15 -15
  66. package/tests/codeceptjs/editors/validation_test.js +2 -2
  67. package/tests/codeceptjs/issues/issue-gh-1133_test.js +9 -0
  68. package/tests/codeceptjs/issues/issue-gh-1158-2_test.js +10 -0
  69. package/tests/codeceptjs/{editors/issues → issues}/issue-gh-1158_test.js +1 -3
  70. package/tests/codeceptjs/issues/issue-gh-1164_test.js +10 -0
  71. package/tests/codeceptjs/issues/issue-gh-1211_test.js +17 -0
  72. package/tests/codeceptjs/{editors/issues → issues}/issue-gh-1257_test.js +3 -5
  73. package/tests/codeceptjs/issues/issue-gh-1338_test.js +16 -0
  74. package/tests/codeceptjs/issues/issue-gh-1347_test.js +8 -0
  75. package/tests/codeceptjs/issues/issue-gh-795_test.js +13 -0
  76. package/tests/codeceptjs/issues/issue-gh-810_test.js +52 -0
  77. package/tests/codeceptjs/issues/issue-gh-812_test.js +25 -0
  78. package/tests/codeceptjs/meta-schema_test.js +12 -12
  79. package/tests/codeceptjs/schemaloader_test.js +8 -8
  80. package/tests/codeceptjs/themes_test.js +40 -9
  81. package/tests/pages/autocomplete.html +1 -0
  82. package/tests/pages/contains.html +38 -0
  83. package/tests/pages/dependentSchemas.html +52 -0
  84. package/tests/pages/if-else.html +57 -0
  85. package/tests/pages/if-then-else-allOf.html +117 -0
  86. package/tests/pages/if-then-else.html +64 -0
  87. package/tests/pages/if-then.html +57 -0
  88. package/tests/pages/issues/issue-gh-1133.html +64 -0
  89. package/tests/pages/issues/issue-gh-1158-2.html +189 -0
  90. package/tests/pages/issues/issue-gh-1164.html +71 -0
  91. package/tests/pages/issues/issue-gh-1165.html +63 -0
  92. package/tests/pages/issues/issue-gh-1165.json +8 -0
  93. package/tests/pages/issues/issue-gh-1211.html +1022 -0
  94. package/tests/pages/issues/issue-gh-1338.html +74 -0
  95. package/tests/pages/issues/issue-gh-1347.html +142 -0
  96. package/tests/pages/issues/issue-gh-795.html +58 -0
  97. package/tests/pages/issues/issue-gh-810.html +149 -0
  98. package/tests/pages/maxContains.html +39 -0
  99. package/tests/pages/meta-schema.html +28 -0
  100. package/tests/pages/meta_schema.json +426 -398
  101. package/tests/pages/minContains.html +39 -0
  102. package/tests/pages/number.html +18 -0
  103. package/tests/pages/option-dependencies.html +106 -0
  104. package/tests/pages/themes.html +3 -1
  105. package/tests/unit/core.spec.js +8 -10
  106. package/tests/codeceptjs/editors/issues/issue-gh-812_test.js +0 -32
@@ -0,0 +1,74 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>GitHub Issue 1338</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 schema = {
18
+ "title": "Test",
19
+ "type": "object",
20
+ "required": [
21
+ "field_a",
22
+ "field_b"
23
+ ],
24
+ "properties": {
25
+ "field_a": {
26
+ "type": "string"
27
+ },
28
+ "field_b": {
29
+ "type": "string"
30
+ },
31
+ },
32
+ "if": {
33
+ "properties": {
34
+ "field_a": {
35
+ "const": ""
36
+ },
37
+ "field_b": {
38
+ "const": ""
39
+ }
40
+ }
41
+ },
42
+ "then": {
43
+ "properties": {
44
+ "field_a": {
45
+ "minLength": 1
46
+ },
47
+ "field_b": {
48
+ "minLength": 1
49
+ }
50
+ }
51
+ }
52
+ }
53
+ var editorContainer = document.querySelector('#editor-container')
54
+ var changeFeedback = document.querySelector('#change-feedback')
55
+ var value = document.querySelector('#value')
56
+ var setValue = document.querySelector('#set-value')
57
+ var editor = new JSONEditor(editorContainer, {
58
+ schema: schema,
59
+ theme: 'bootstrap4',
60
+ iconlib: 'fontawesome',
61
+ show_errors: 'always'
62
+ })
63
+
64
+ editor.on('change', function () {
65
+ value.value = JSON.stringify(editor.getValue())
66
+ })
67
+
68
+ setValue.addEventListener('click', function () {
69
+ editor.setValue(JSON.parse(value.value))
70
+ })
71
+ </script>
72
+
73
+ </body>
74
+ </html>
@@ -0,0 +1,142 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>GitHub Issue 1347</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
+ <label for="value">value</label>
14
+ <textarea class="form-control" id="value" cols="30" rows="10"></textarea>
15
+ <button id="set-value">Set value</button>
16
+ <br><br><br><br><br><br>
17
+ <div id='editor-container'></div>
18
+ </div>
19
+
20
+ <script>
21
+ var schema = {
22
+ 'title': 'Test adding rows',
23
+ 'definitions': {
24
+ 'caplz': {
25
+ 'type': 'object',
26
+ 'properties': {
27
+ 'dateField1': {
28
+ 'title': 'Date',
29
+ 'type': 'string',
30
+ 'format': 'date',
31
+ 'default': ''
32
+ },
33
+ 'amountField1': {
34
+ 'title': 'Amount 1',
35
+ 'type': 'string',
36
+ 'options': {
37
+ 'cleave': {
38
+ 'numeral': true,
39
+ 'prefix': ' €',
40
+ 'tailPrefix': true
41
+ }
42
+ },
43
+ 'default': ''
44
+ },
45
+ 'amountField2': {
46
+ 'title': 'Amount 2',
47
+ 'type': 'string',
48
+ 'options': {
49
+ 'cleave': {
50
+ 'numeral': true,
51
+ 'prefix': ' €',
52
+ 'tailPrefix': true
53
+ }
54
+ },
55
+ 'default': ''
56
+ },
57
+ 'amountField3': {
58
+ 'title': 'Amount 3',
59
+ 'type': 'string',
60
+ 'options': {
61
+ 'cleave': {
62
+ 'numeral': true,
63
+ 'prefix': ' €',
64
+ 'tailPrefix': true
65
+ }
66
+ },
67
+ 'default': ''
68
+ },
69
+ 'amountField4': {
70
+ 'title': 'Amount 4',
71
+ 'type': 'string',
72
+ 'options': {
73
+ 'cleave': {
74
+ 'numeral': true,
75
+ 'prefix': ' €',
76
+ 'tailPrefix': true
77
+ }
78
+ },
79
+ 'default': ''
80
+ }
81
+ }
82
+ }
83
+ },
84
+ 'properties': {
85
+ 'caplzsone': {
86
+ 'type': 'array',
87
+ 'format': 'table',
88
+ 'title': 'Array set with minItems 1',
89
+ 'items': {
90
+ 'title': 'Added row',
91
+ '$ref': '#/definitions/caplz'
92
+ },
93
+ 'minItems': 1
94
+ },
95
+ 'caplzszero': {
96
+ 'type': 'array',
97
+ 'format': 'table',
98
+ 'title': 'Array with no minItems',
99
+ 'items': {
100
+ 'title': 'Added row',
101
+ '$ref': '#/definitions/caplz'
102
+ }
103
+ }
104
+ }
105
+ }
106
+ var editorContainer = document.querySelector('#editor-container')
107
+ var value = document.querySelector('#value')
108
+ var setValue = document.querySelector('#set-value')
109
+ var editor = new JSONEditor(editorContainer, {
110
+ schema: schema,
111
+ theme: 'bootstrap4',
112
+ iconlib: 'fontawesome'
113
+ })
114
+
115
+ editor.on('change', function () {
116
+ value.value = JSON.stringify(editor.getValue())
117
+ })
118
+
119
+ editor.on('ready', function () {
120
+ editor.getEditor('root.caplzszero').setValue([
121
+ {
122
+ 'dateField1': '0000',
123
+ 'amountField1': '1111',
124
+ 'amountField2': '2222',
125
+ 'amountField3': '3333',
126
+ 'amountField4': '4444'
127
+ },
128
+ {
129
+ 'dateField1': '5555',
130
+ 'amountField1': '6666',
131
+ 'amountField2': '7777',
132
+ 'amountField3': '8888',
133
+ 'amountField4': '9999'
134
+ }
135
+ ])
136
+
137
+ editor.getEditor('root.caplzszero.0.amountField1').setValue(9999)
138
+ })
139
+ </script>
140
+
141
+ </body>
142
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>GitHub Issue 795</title>
6
+ <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
7
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
8
+ <script src="../../../dist/jsoneditor.js"></script>
9
+ </head>
10
+ <body>
11
+ <div class="container">
12
+ <h1><a href="https://github.com/json-editor/json-editor/issues/795">GitHub Issue 795</a></h1>
13
+ <div id='editor_holder'></div>
14
+ <label for="value">Value</label>
15
+ <textarea class="form-control" id="value" rows="12" style="font-size: 12px; font-family: monospace;"></textarea>
16
+ <button id="set-value">Set Value</button>
17
+ </div>
18
+
19
+ <script>
20
+ var schema = {
21
+ 'definitions': {
22
+ 'box': {
23
+ 'type': 'array',
24
+ 'items': {
25
+ 'oneOf': [
26
+ {
27
+ 'title': 'box',
28
+ '$ref': '#/definitions/box'
29
+ },
30
+ {
31
+ 'title': 'letter',
32
+ 'type': 'object'
33
+ }
34
+ ]
35
+ }
36
+ }
37
+ },
38
+ '$ref': '#/definitions/box'
39
+ }
40
+
41
+ var value = document.querySelector('#value')
42
+ var setValue = document.querySelector('#set-value')
43
+ var editor = new JSONEditor(document.getElementById('editor_holder'), {
44
+ schema: schema,
45
+ theme: 'bootstrap4',
46
+ keep_oneof_values: false
47
+ })
48
+
49
+ editor.on('change', function () {
50
+ value.value = JSON.stringify(editor.getValue())
51
+ })
52
+
53
+ setValue.addEventListener('click', function () {
54
+ editor.setValue(JSON.parse(value.value))
55
+ })
56
+ </script>
57
+ </body>
58
+ </html>
@@ -0,0 +1,149 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>GitHub Issue 812</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
+ <p>I changed <span id="change-feedback">0</span> times</p>
14
+ <label for="value">value</label>
15
+ <textarea class="form-control" id="value" cols="30" rows="10"></textarea>
16
+ <button id="set-value">Set value</button>
17
+ <br><br><br><br><br><br>
18
+ <div id='editor-container'></div>
19
+ </div>
20
+
21
+ <script>
22
+ var schema = {
23
+ 'title': 'Person',
24
+ 'type': 'object',
25
+ 'required': [
26
+ 'name',
27
+ 'age',
28
+ 'date',
29
+ 'favorite_color',
30
+ 'gender',
31
+ 'location',
32
+ 'pets'
33
+ ],
34
+ 'properties': {
35
+ 'name': {
36
+ 'type': 'string',
37
+ 'description': 'First and Last name',
38
+ 'minLength': 4,
39
+ 'default': 'Jeremy Dorn'
40
+ },
41
+ 'age': {
42
+ 'type': 'integer',
43
+ 'default': 25,
44
+ 'minimum': 18,
45
+ 'maximum': 99
46
+ },
47
+ 'favorite_color': {
48
+ 'type': 'string',
49
+ 'format': 'color',
50
+ 'title': 'favorite color',
51
+ 'default': '#ffa500'
52
+ },
53
+ 'gender': {
54
+ 'type': 'string',
55
+ 'enum': [
56
+ 'male',
57
+ 'female',
58
+ 'other'
59
+ ]
60
+ },
61
+ 'date': {
62
+ 'type': 'string',
63
+ 'format': 'date',
64
+ 'options': {
65
+ 'flatpickr': {}
66
+ }
67
+ },
68
+ 'location': {
69
+ 'type': 'object',
70
+ 'title': 'Location',
71
+ 'properties': {
72
+ 'city': {
73
+ 'type': 'string',
74
+ 'default': 'San Francisco'
75
+ },
76
+ 'state': {
77
+ 'type': 'string',
78
+ 'default': 'CA'
79
+ },
80
+ 'citystate': {
81
+ 'type': 'string',
82
+ 'description': 'This is generated automatically from the previous two fields',
83
+ 'template': '{{city}}, {{state}}',
84
+ 'watch': {
85
+ 'city': 'location.city',
86
+ 'state': 'location.state'
87
+ }
88
+ }
89
+ }
90
+ },
91
+ 'pets': {
92
+ 'type': 'array',
93
+ 'format': 'table',
94
+ 'title': 'Pets',
95
+ 'uniqueItems': true,
96
+ 'items': {
97
+ 'type': 'object',
98
+ 'title': 'Pet',
99
+ 'properties': {
100
+ 'type': {
101
+ 'type': 'string',
102
+ 'enum': [
103
+ 'cat',
104
+ 'dog',
105
+ 'bird',
106
+ 'reptile',
107
+ 'other'
108
+ ],
109
+ 'default': 'dog'
110
+ },
111
+ 'name': {
112
+ 'type': 'string'
113
+ }
114
+ }
115
+ },
116
+ 'default': [
117
+ {
118
+ 'type': 'dog',
119
+ 'name': 'Walter'
120
+ }
121
+ ]
122
+ }
123
+ }
124
+ }
125
+ var editorContainer = document.querySelector('#editor-container')
126
+ var changeFeedback = document.querySelector('#change-feedback')
127
+ var value = document.querySelector('#value')
128
+ var setValue = document.querySelector('#set-value')
129
+ var editor = new JSONEditor(editorContainer, {
130
+ schema: schema,
131
+ theme: 'bootstrap4',
132
+ iconlib: 'fontawesome'
133
+ })
134
+
135
+ var changeCounter = 0
136
+
137
+ editor.on('change', function () {
138
+ changeCounter++
139
+ changeFeedback.textContent = changeCounter
140
+ value.value = JSON.stringify(editor.getValue())
141
+ })
142
+
143
+ setValue.addEventListener('click', function () {
144
+ editor.setValue(JSON.parse(value.value))
145
+ })
146
+ </script>
147
+
148
+ </body>
149
+ </html>
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>maxContains</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': 'maxContains',
20
+ 'type': 'array',
21
+ 'items': {
22
+ 'type': 'number'
23
+ },
24
+ 'contains': {
25
+ 'type': 'number'
26
+ },
27
+ 'maxContains': 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>
@@ -341,6 +341,14 @@
341
341
  }
342
342
  }
343
343
  },
344
+ "dependentSchemas": {
345
+ "type": "object",
346
+ "patternProperties": {
347
+ ".*": {
348
+ "$ref": "#/definitions/schema"
349
+ }
350
+ }
351
+ },
344
352
  'additionalProperties': {
345
353
  'type': 'boolean'
346
354
  },
@@ -423,6 +431,17 @@
423
431
  'type': 'integer',
424
432
  'minimum': 0
425
433
  },
434
+ 'contains': {
435
+ '$ref': '#/definitions/schema'
436
+ },
437
+ 'minContains': {
438
+ 'type': 'integer',
439
+ 'minimum': 0
440
+ },
441
+ 'maxContains': {
442
+ 'type': 'integer',
443
+ 'minimum': 0
444
+ },
426
445
  'additionalItems': {
427
446
  '$ref': '#/definitions/schema'
428
447
  },
@@ -581,6 +600,15 @@
581
600
  'not': {
582
601
  '$ref': '#/definitions/schema'
583
602
  },
603
+ 'if': {
604
+ '$ref': '#/definitions/schema'
605
+ },
606
+ 'then': {
607
+ '$ref': '#/definitions/schema'
608
+ },
609
+ 'else': {
610
+ '$ref': '#/definitions/schema'
611
+ },
584
612
  'propertyOrder': {
585
613
  'type': 'number',
586
614
  'default': 1000