@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,25 @@
1
+ /* global Feature Scenario */
2
+
3
+ Feature('issues')
4
+
5
+ Scenario('GitHub issue 812 should remain fixed @issue-812', async ({ I }) => {
6
+ I.amOnPage('issues/issue-gh-812.html')
7
+ I.click('.get-value')
8
+ I.waitForValue('.debug', '{"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}]}]}')
9
+
10
+ I.amAcceptingPopups()
11
+ I.click('//*[@id="root.students.0"]/span[2]/button[contains(@class, "json-editor-btn-delete") and @data-i="0"]')
12
+ I.retry({ retries: 5, minTimeout: 500 }).seeInPopup('Are you sure you want to remove this item?')
13
+ I.acceptPopup()
14
+
15
+ I.click('.get-value')
16
+ I.waitForValue('.debug', '{"students":[{"name":"BBB","sessions":[{"student_name":"BBB","minutes":20}]},{"name":"CCC","sessions":[{"student_name":"CCC","minutes":10}]}]}')
17
+
18
+ I.amAcceptingPopups()
19
+ I.click('//*[@id="root.students.0"]/span[2]/button[contains(@class, "json-editor-btn-delete") and @data-i="0"]')
20
+ I.retry({ retries: 5, minTimeout: 500 }).seeInPopup('Are you sure you want to remove this item?')
21
+ I.acceptPopup()
22
+
23
+ I.click('.get-value')
24
+ I.waitForValue('.debug', '{"students":[{"name":"CCC","sessions":[{"student_name":"CCC","minutes":10}]}]}')
25
+ })
@@ -1,6 +1,6 @@
1
1
  /* global Feature Scenario */
2
+
2
3
  const { DEFAULT_WAIT_TIME } = require('./test-config')
3
- var assert = require('assert')
4
4
 
5
5
  Feature('meta-schema')
6
6
 
@@ -9,7 +9,7 @@ Scenario('work with json-schema meta-schema @meta-schema-core', async ({ I }) =>
9
9
  I.waitForElement('.je-ready')
10
10
 
11
11
  I.selectOption('.je-switcher', 'Object')
12
- assert.equal(await I.grabValueFrom('#value'), '{"properties":{},"title":"","type":"object"}')
12
+ I.waitForValue('#value', '{"properties":{},"title":"","type":"object"}')
13
13
  I.click('.json-editor-btn-edit_properties')
14
14
  I.waitForText('type', '.property-selector')
15
15
  I.waitForText('title', '.property-selector')
@@ -37,22 +37,22 @@ Scenario('work with json-schema meta-schema @meta-schema-core', async ({ I }) =>
37
37
  I.waitForText('format', '.property-selector')
38
38
 
39
39
  I.selectOption('.je-switcher', 'Array')
40
- assert.equal(await I.grabValueFrom('#value'), '{"items":{"properties":{},"title":"","type":"object"},"title":"","type":"array"}')
40
+ I.waitForValue('#value', '{"items":{"properties":{},"title":"","type":"object"},"title":"","type":"array"}')
41
41
 
42
42
  I.selectOption('.je-switcher', 'String')
43
- assert.equal(await I.grabValueFrom('#value'), '{"title":"","type":"string"}')
43
+ I.waitForValue('#value', '{"title":"","type":"string"}')
44
44
 
45
45
  I.selectOption('.je-switcher', 'Number')
46
- assert.equal(await I.grabValueFrom('#value'), '{"title":"","type":"number"}')
46
+ I.waitForValue('#value', '{"title":"","type":"number"}')
47
47
 
48
48
  I.selectOption('.je-switcher', 'Integer')
49
- assert.equal(await I.grabValueFrom('#value'), '{"title":"","type":"integer"}')
49
+ I.waitForValue('#value', '{"title":"","type":"integer"}')
50
50
 
51
51
  I.selectOption('.je-switcher', 'Boolean')
52
- assert.equal(await I.grabValueFrom('#value'), '{"title":"","type":"boolean"}')
52
+ I.waitForValue('#value', '{"title":"","type":"boolean"}')
53
53
 
54
54
  I.selectOption('.je-switcher', 'Null')
55
- assert.equal(await I.grabValueFrom('#value'), '{"title":"","type":"null"}')
55
+ I.waitForValue('#value', '{"title":"","type":"null"}')
56
56
  })
57
57
 
58
58
  // https://github.com/json-editor/json-editor/issues/823
@@ -71,14 +71,14 @@ Scenario('work with json-schema meta-schema @meta-schema', async ({ I }) => {
71
71
  })
72
72
 
73
73
  // https://github.com/json-editor/json-editor/issues/1233
74
- Scenario('passing meta-schema example @meta-schema', async ({ I }) => {
74
+ Scenario('passing meta-schema example @meta-schema @schemaloader', async ({ I }) => {
75
75
  I.amOnPage('issues/issue-gh-1233-passing.html')
76
76
  I.waitForElement('.je-ready', DEFAULT_WAIT_TIME)
77
77
  I.waitForElement('[name="root[name]"]', DEFAULT_WAIT_TIME)
78
78
  })
79
79
 
80
80
  // https://github.com/json-editor/json-editor/issues/1233
81
- Scenario('failing meta-schema example @meta-schema @optional', async ({ I }) => {
81
+ Scenario('failing meta-schema example @meta-schema @schemaloader', async ({ I }) => {
82
82
  I.amOnPage('issues/issue-gh-1233-failing.html')
83
83
  I.waitForElement('.je-ready', DEFAULT_WAIT_TIME)
84
84
  I.waitForElement('[name="root[name]"]', DEFAULT_WAIT_TIME)
@@ -1,14 +1,14 @@
1
- var assert = require('assert');
1
+ /* global Feature Scenario */
2
+
2
3
  const { DEFAULT_WAIT_TIME } = require('./test-config')
3
4
 
4
- Feature('schemaloader');
5
+ Feature('schemaloader')
5
6
 
6
7
  Scenario('resolving nested external URNs', async ({ I }) => {
7
- I.amOnPage('urn.html');
8
- I.waitForElement('[data-schemapath="root"] h3', DEFAULT_WAIT_TIME);
8
+ I.amOnPage('urn.html')
9
+ I.waitForElement('[data-schemapath="root"] h3', DEFAULT_WAIT_TIME)
9
10
  I.seeElementInDOM('[data-schemapath="root.fname"]')
10
11
  I.seeElementInDOM('[data-schemapath="root.lname"]')
11
-
12
12
  I.click('.get-value')
13
- assert.equal(await I.grabValueFrom('.value'), '{"fname":"John","lname":"Doe"}');
14
- });
13
+ I.waitForValue('.value', '{"fname":"John","lname":"Doe"}')
14
+ })
@@ -256,6 +256,37 @@ Scenario('It should hide button Labels: null | bootstrap3', async ({ I }) => {
256
256
  I.seeElementInDOM('i.glyphicon.glyphicon-copy')
257
257
  I.seeElementInDOM('i.glyphicon.glyphicon-list')
258
258
  })
259
+
260
+ Scenario('It should hide button Labels: null | bootstrap icons @themes @iconlib', async ({ I }) => {
261
+ I.amOnPage('themes.html')
262
+ I.selectOption('iconlib', 'bootstrap')
263
+ I.waitForText('Themes Test Page')
264
+ I.dontSee('Collapse')
265
+ I.dontSee('Edit JSON')
266
+ I.dontSee('Object Properties')
267
+ I.dontSee('Delete item')
268
+ I.dontSee('Delete Last item')
269
+ I.dontSee('Delete All')
270
+ I.dontSee('Move down')
271
+ I.dontSee('Move up')
272
+
273
+ I.click('Collapse')
274
+ I.seeElementInDOM('i.bi.bi-chevron-down')
275
+ I.seeElementInDOM('i.bi.bi-chevron-right')
276
+ I.seeElementInDOM('i.bi.bi-trash')
277
+ I.seeElementInDOM('i.bi.bi-pencil')
278
+ I.seeElementInDOM('i.bi.bi-plus')
279
+ I.seeElementInDOM('i.bi.bi-dash')
280
+ I.seeElementInDOM('i.bi.bi-x-circle')
281
+ I.seeElementInDOM('i.bi.bi-save')
282
+ I.seeElementInDOM('i.bi.bi-arrow-up')
283
+ I.seeElementInDOM('i.bi.bi-arrow-right')
284
+ I.seeElementInDOM('i.bi.bi-arrow-down')
285
+ I.seeElementInDOM('i.bi.bi-arrow-left')
286
+ I.seeElementInDOM('i.bi.bi-clipboard')
287
+ I.seeElementInDOM('i.bi.bi-list-ul')
288
+ })
289
+
259
290
  /*
260
291
  Scenario('It should hide button Labels: null | fontawesome3', async (I) => {
261
292
  I.amOnPage('themes.html')
@@ -5,6 +5,7 @@
5
5
  <title>Autocomplete</title>
6
6
  <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
7
7
  <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
8
+ <link rel="stylesheet" href="https://unpkg.com/@trevoreyre/autocomplete-js/dist/style.css"/>
8
9
  <script src="https://unpkg.com/@trevoreyre/autocomplete-js"></script>
9
10
  <script src="../../dist/jsoneditor.js"></script>
10
11
  </head>
@@ -0,0 +1,38 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>contains</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': 'contains',
20
+ "type": "array",
21
+ "contains": {
22
+ "type": "number"
23
+ },
24
+ "items": {
25
+ "type": "number"
26
+ }
27
+ }
28
+
29
+ var editor = new JSONEditor(editorContainer, {
30
+ schema: schema,
31
+ theme: 'bootstrap4',
32
+ iconlib: 'fontawesome',
33
+ show_errors: 'always'
34
+ })
35
+ </script>
36
+
37
+ </body>
38
+ </html>
@@ -0,0 +1,52 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>dependentSchemas</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
+ "type": "object",
20
+ "properties": {
21
+ "credit_card": {
22
+ "type": "number"
23
+ },
24
+ "billing_address": {
25
+ "type": "string"
26
+ }
27
+ },
28
+ "dependentSchemas": {
29
+ "credit_card": {
30
+ "properties": {
31
+ "billing_address": {
32
+ "type": "string"
33
+ }
34
+ },
35
+ "required": [
36
+ "billing_address"
37
+ ]
38
+ }
39
+ }
40
+ }
41
+
42
+ var editor = new JSONEditor(editorContainer, {
43
+ schema: schema,
44
+ theme: 'bootstrap4',
45
+ iconlib: 'fontawesome',
46
+ show_errors: 'always',
47
+ show_opt_in: true
48
+ })
49
+ </script>
50
+
51
+ </body>
52
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>If-Else</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
+ 'type': 'object',
20
+ 'properties': {
21
+ 'country': {
22
+ 'type': 'string',
23
+ 'default': 'America',
24
+ 'enum': [
25
+ 'America',
26
+ 'Canada'
27
+ ]
28
+ },
29
+ 'postal_code': {
30
+ 'type': 'string'
31
+ }
32
+ },
33
+ 'if': {
34
+ 'properties': {
35
+ 'country': {
36
+ 'const': 'America'
37
+ }
38
+ }
39
+ },
40
+ 'else': {
41
+ 'properties': {
42
+ 'postal_code': {
43
+ 'pattern': '[A-Z][0-9][A-Z] [0-9][A-Z][0-9]'
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ var editor = new JSONEditor(editorContainer, {
50
+ schema: schema,
51
+ theme: 'bootstrap4',
52
+ iconlib: 'fontawesome'
53
+ })
54
+ </script>
55
+
56
+ </body>
57
+ </html>
@@ -0,0 +1,117 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>If-Then-Else-UI</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
+
15
+ <div class="form-group">
16
+ <label for="value">Value</label>
17
+ <textarea class="form-control" id="value" cols="30" rows="10"></textarea>
18
+ <button id="set-value">set value</button>
19
+ </div>
20
+ </div>
21
+
22
+ <script>
23
+ var editorContainer = document.querySelector('#editor-container')
24
+ var value = document.querySelector('#value')
25
+ var setValue = document.querySelector('#set-value')
26
+ var schema = {
27
+ "type": "object",
28
+ "required": [
29
+ "country"
30
+ ],
31
+ "properties": {
32
+ "country": {
33
+ "type": "string",
34
+ "default": "United States of America",
35
+ "enum": [
36
+ "United States of America",
37
+ "Canada",
38
+ "Netherlands"
39
+ ]
40
+ },
41
+ "postal_code": {
42
+ "type": "string"
43
+ },
44
+ "street_address": {
45
+ "type": "string"
46
+ }
47
+ },
48
+ "allOf": [
49
+ {
50
+ "if": {
51
+ "properties": {
52
+ "country": {
53
+ "const": "United States of America"
54
+ }
55
+ }
56
+ },
57
+ "then": {
58
+ "properties": {
59
+ "postal_code": {
60
+ "pattern": "[0-9]{5}(-[0-9]{4})?"
61
+ }
62
+ }
63
+ }
64
+ },
65
+ {
66
+ "if": {
67
+ "properties": {
68
+ "country": {
69
+ "const": "Canada"
70
+ }
71
+ }
72
+ },
73
+ "then": {
74
+ "properties": {
75
+ "postal_code": {
76
+ "pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]"
77
+ }
78
+ }
79
+ }
80
+ },
81
+ {
82
+ "if": {
83
+ "properties": {
84
+ "country": {
85
+ "const": "Netherlands"
86
+ }
87
+ }
88
+ },
89
+ "then": {
90
+ "properties": {
91
+ "postal_code": {
92
+ "pattern": "[0-9]{4} [A-Z]{2}"
93
+ }
94
+ }
95
+ }
96
+ }
97
+ ]
98
+ }
99
+
100
+ var editor = new JSONEditor(editorContainer, {
101
+ schema: schema,
102
+ theme: 'bootstrap4',
103
+ iconlib: 'fontawesome',
104
+ show_errors: 'always'
105
+ })
106
+
107
+ editor.on('change', function () {
108
+ value.value = JSON.stringify(editor.getValue())
109
+ })
110
+
111
+ setValue.addEventListener('click', function () {
112
+ editor.setValue(JSON.parse(value.value))
113
+ })
114
+ </script>
115
+
116
+ </body>
117
+ </html>
@@ -0,0 +1,64 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>If-Then-Else</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
+ 'type': 'object',
20
+ 'properties': {
21
+ 'country': {
22
+ 'type': 'string',
23
+ 'default': 'America',
24
+ 'enum': [
25
+ 'America',
26
+ 'Canada'
27
+ ]
28
+ },
29
+ 'postal_code': {
30
+ 'type': 'string'
31
+ }
32
+ },
33
+ 'if': {
34
+ 'properties': {
35
+ 'country': {
36
+ 'const': 'America'
37
+ }
38
+ }
39
+ },
40
+ 'then': {
41
+ 'properties': {
42
+ 'postal_code': {
43
+ 'pattern': '[0-9]{5}(-[0-9]{4})?'
44
+ }
45
+ }
46
+ },
47
+ 'else': {
48
+ 'properties': {
49
+ 'postal_code': {
50
+ 'pattern': '[A-Z][0-9][A-Z] [0-9][A-Z][0-9]'
51
+ }
52
+ }
53
+ }
54
+ }
55
+
56
+ var editor = new JSONEditor(editorContainer, {
57
+ schema: schema,
58
+ theme: 'bootstrap4',
59
+ iconlib: 'fontawesome'
60
+ })
61
+ </script>
62
+
63
+ </body>
64
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>If-Then</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
+ 'type': 'object',
20
+ 'properties': {
21
+ 'country': {
22
+ 'type': 'string',
23
+ 'default': 'America',
24
+ 'enum': [
25
+ 'America',
26
+ 'Canada'
27
+ ]
28
+ },
29
+ 'postal_code': {
30
+ 'type': 'string'
31
+ }
32
+ },
33
+ 'if': {
34
+ 'properties': {
35
+ 'country': {
36
+ 'const': 'America'
37
+ }
38
+ }
39
+ },
40
+ 'then': {
41
+ 'properties': {
42
+ 'postal_code': {
43
+ 'pattern': '[0-9]{5}(-[0-9]{4})?'
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ var editor = new JSONEditor(editorContainer, {
50
+ schema: schema,
51
+ theme: 'bootstrap4',
52
+ iconlib: 'fontawesome'
53
+ })
54
+ </script>
55
+
56
+ </body>
57
+ </html>