@json-editor/json-editor 2.6.1 → 2.7.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 (68) hide show
  1. package/.github/workflows/build.yml +12 -3
  2. package/CHANGELOG.md +24 -0
  3. package/README.md +131 -18
  4. package/dist/jsoneditor.js +2 -2
  5. package/dist/nonmin/jsoneditor.js +2607 -582
  6. package/dist/nonmin/jsoneditor.js.map +1 -1
  7. package/docs/form-submission.html +76 -0
  8. package/package.json +4 -3
  9. package/release-notes.md +2 -0
  10. package/src/core.js +36 -37
  11. package/src/defaults.js +9 -2
  12. package/src/editors/array.js +12 -1
  13. package/src/editors/autocomplete.js +4 -3
  14. package/src/editors/button.js +1 -1
  15. package/src/editors/multiselect.js +14 -5
  16. package/src/editors/string.js +4 -0
  17. package/src/editors/table.js +20 -2
  18. package/src/editors/upload.js +1 -1
  19. package/src/editors/uuid.js +2 -12
  20. package/src/iconlib.js +1 -1
  21. package/src/schemaloader.js +231 -108
  22. package/src/style.css +3 -0
  23. package/src/style.css.js +1 -1
  24. package/src/theme.js +0 -2
  25. package/src/themes/bootstrap3.js +1 -0
  26. package/src/themes/spectre.js +2 -1
  27. package/src/utilities.js +18 -0
  28. package/src/validator.js +36 -34
  29. package/tests/codeceptjs/codecept.json +1 -1
  30. package/tests/codeceptjs/core_test.js +98 -0
  31. package/tests/codeceptjs/editors/advanced_test.js +1 -1
  32. package/tests/codeceptjs/editors/array_test.js +74 -0
  33. package/tests/codeceptjs/editors/autocomplete_test.js +16 -0
  34. package/tests/codeceptjs/editors/button_test.js +10 -3
  35. package/tests/codeceptjs/editors/integer_test.js +7 -2
  36. package/tests/codeceptjs/editors/jodit_test.js +3 -3
  37. package/tests/codeceptjs/editors/range_test.js +12 -0
  38. package/tests/codeceptjs/editors/uuid_test.js +31 -4
  39. package/tests/docker-compose.yml +1 -1
  40. package/tests/fixtures/definitions.json +22 -0
  41. package/tests/fixtures/properties.json +20 -0
  42. package/tests/pages/array-checkboxes-infotext.html +52 -0
  43. package/tests/pages/array-move-events.html +4 -2
  44. package/tests/pages/array-unique-items-sort.html +78 -0
  45. package/tests/pages/autocomplete.html +69 -0
  46. package/tests/pages/button-icons.html +38 -0
  47. package/tests/pages/core.html +4 -2
  48. package/tests/pages/error-messages.html +47 -0
  49. package/tests/pages/grid-strict.html +6 -10
  50. package/tests/pages/grid.html +0 -4
  51. package/tests/pages/issues/issue-gh-812.html +4 -2
  52. package/tests/pages/meta_schema.json +14 -0
  53. package/tests/pages/object-required-properties.html +7 -7
  54. package/tests/pages/range.html +60 -0
  55. package/tests/pages/ready.html +43 -0
  56. package/tests/pages/references.html +162 -0
  57. package/tests/pages/string-simplemde-editor.html +81 -0
  58. package/tests/pages/table-move-events.html +4 -1
  59. package/tests/pages/urn.html +11 -8
  60. package/tests/pages/uuid.html +89 -50
  61. package/tests/pages/validation-messages.json +705 -0
  62. package/tests/unit/core.spec.js +79 -66
  63. package/tests/unit/editor.spec.js +20 -8
  64. package/tests/unit/editors/array.spec.js +3 -2
  65. package/tests/unit/editors/object.spec.js +3 -1
  66. package/tests/unit/editors/table.spec.js +4 -2
  67. package/tests/unit/schemaloader.spec.js +77 -105
  68. package/tests/unit/validator.spec.js +2 -2
@@ -12,10 +12,37 @@ Scenario('should have initial value matching uuid @uuid', async (I) => {
12
12
  })
13
13
 
14
14
  Scenario('should have initial value matching uuid in arrays @uuid', async (I) => {
15
- I.click('Add item')
16
- I.click('Add item')
17
- const value0 = await I.grabValueFrom('[name="root[uuidArray][0][uuid]"]')
15
+ I.click('Add uuid string array item')
16
+ I.click('Add uuid string array item')
17
+ const value0 = await I.grabValueFrom('[name="root[uuidStringArray][0]"]')
18
18
  assert.equal((/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value0)), true)
19
- const value1 = await I.grabValueFrom('[name="root[uuidArray][1][uuid]"]')
19
+ const value1 = await I.grabValueFrom('[name="root[uuidStringArray][1]"]')
20
20
  assert.equal((/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value1)), true)
21
21
  })
22
+
23
+ Scenario('should have initial value matching uuid in arrays of objects with @uuid', async (I) => {
24
+ I.click('Add uuid object array item')
25
+ I.click('Add uuid object array item')
26
+ const value0 = await I.grabValueFrom('[name="root[uuidObjectArray][0][uuid]"]')
27
+ assert.equal((/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value0)), true)
28
+ const value1 = await I.grabValueFrom('[name="root[uuidObjectArray][1][uuid]"]')
29
+ assert.equal((/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value1)), true)
30
+ })
31
+
32
+ Scenario('should have initial value matching uuid in arrays (table) of strings with @uuid', async (I) => {
33
+ I.click('Add uuid string table item')
34
+ I.click('Add uuid string table item')
35
+ const value0 = await I.grabValueFrom('[name="root[uuidStringTable][0]')
36
+ assert.equal((/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value0)), true)
37
+ const value1 = await I.grabValueFrom('[name="root[uuidStringTable][1]')
38
+ assert.equal((/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value1)), true)
39
+ })
40
+
41
+ Scenario('should have initial value matching uuid in arrays (table) of objects with @uuid', async (I) => {
42
+ I.click('Add uuid object table item')
43
+ I.click('Add uuid object table item')
44
+ const value0 = await I.grabValueFrom('[name="root[uuidObjectTable][0][uuid]"]')
45
+ assert.equal((/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value0)), true)
46
+ const value1 = await I.grabValueFrom('[name="root[uuidObjectTable][1][uuid]"]')
47
+ assert.equal((/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value1)), true)
48
+ })
@@ -11,7 +11,7 @@ services:
11
11
  expose:
12
12
  - '9001'
13
13
  firefox:
14
- image: selenium/standalone-firefox-debug:3.141.59-20200525
14
+ image: selenium/standalone-firefox-debug:3.141.59-20210929
15
15
  depends_on:
16
16
  - node
17
17
  environment:
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-04/schema",
3
+ "title": "Reusable Definitions",
4
+ "type": "object",
5
+ "id": "https://raw.githubusercontent.com/json-editor/json-editor/master/tests/fixtures/definitions.json",
6
+ "definitions": {
7
+ "address": {
8
+ "title": "Address",
9
+ "type": "object",
10
+ "properties": {
11
+ "street_address": { "type": "string" },
12
+ "city": { "type": "string" },
13
+ "state": { "type": "string" }
14
+ },
15
+ "required": ["street_address"]
16
+ },
17
+ "link" : {"$refs": "./properties.json#/properties/title"}
18
+ },
19
+ "properties": {
20
+ "address" : {"$refs": "#/definitions/address"}
21
+ }
22
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "category": "atom",
4
+ "title": "Link",
5
+ "entity": "link",
6
+ "type": "object",
7
+ "format": "grid",
8
+ "properties": {
9
+ "href": {
10
+ "title": "URL",
11
+ "type": "string",
12
+ "format": "url"
13
+ },
14
+ "title": {
15
+ "title": "Title attribute",
16
+ "description": "Shown on mouseover.",
17
+ "type": "string"
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,52 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <script src="../../dist/jsoneditor.js"></script>
6
+ </head>
7
+ <body>
8
+
9
+ <textarea class="debug" cols="30" rows="10"></textarea>
10
+ <button class='get-value'>Get Value</button>
11
+ <div class='container'></div>
12
+
13
+ <script>
14
+ var container = document.querySelector('.container')
15
+ var debug = document.querySelector('.debug')
16
+ var schema = {
17
+ 'title': 'Checkbox with Infotext',
18
+ 'type': 'array',
19
+ 'uniqueItems': true,
20
+ 'items': {
21
+ 'type': 'string',
22
+ 'enum': ['1', '2', '3', '4', '5'],
23
+ 'options': {
24
+ 'enum_titles': ['old a', 'old b'],
25
+ 'enum': [
26
+ {},
27
+ {
28
+ 'title': 'b',
29
+ },
30
+ {},
31
+ { 'infoText': 'dd' },
32
+ {
33
+ 'title': 'e',
34
+ 'infoText': 'ee'
35
+ }
36
+ ]
37
+ }
38
+ }
39
+ }
40
+
41
+ var editor = new JSONEditor(container, {
42
+ schema: schema
43
+ })
44
+
45
+ document.querySelector('.get-value').addEventListener('click', function () {
46
+ debug.value = JSON.stringify(editor.getValue())
47
+ })
48
+
49
+ </script>
50
+
51
+ </body>
52
+ </html>
@@ -27,8 +27,8 @@
27
27
  var editor = new JSONEditor(container, {
28
28
  schema: schema
29
29
  });
30
-
31
- document.querySelector('.get-value').addEventListener('click', function () {
30
+ editor.promise.then(() => {
31
+ document.querySelector('.get-value').addEventListener('click', function () {
32
32
  debug.value = JSON.stringify(editor.getValue());
33
33
  });
34
34
 
@@ -53,6 +53,8 @@
53
53
  action.value = 'deleteAllRows'
54
54
  console.log('deleteAllRows')
55
55
  });
56
+ })
57
+
56
58
 
57
59
 
58
60
  </script>
@@ -0,0 +1,78 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <script src="../../dist/jsoneditor.js"></script>
6
+ </head>
7
+ <body>
8
+
9
+ <textarea class="debug" cols="30" rows="10"></textarea>
10
+ <button class='get-value'>Get Value</button>
11
+ <div class='container'></div>
12
+
13
+ <script>
14
+ var container = document.querySelector('.container');
15
+ var debug = document.querySelector('.debug');
16
+ var schema = {
17
+ "properties": {
18
+ "items": {
19
+ "title": "items",
20
+ "name": "ageband",
21
+ "type": "array",
22
+ "uniqueItems": true,
23
+ "format": "checkbox",
24
+ "items": {
25
+ "type": "string",
26
+ "enum": [
27
+ "01",
28
+ "02",
29
+ "03",
30
+ "04",
31
+ "05",
32
+ "06",
33
+ "07",
34
+ "08",
35
+ "09",
36
+ "10",
37
+ "11",
38
+ "12",
39
+ "13",
40
+ "14",
41
+ "15"
42
+ ],
43
+ "options": {
44
+ "enum_titles": [
45
+ "01",
46
+ "02",
47
+ "03",
48
+ "04",
49
+ "05",
50
+ "06",
51
+ "07",
52
+ "08",
53
+ "09",
54
+ "10",
55
+ "11",
56
+ "12",
57
+ "13",
58
+ "14",
59
+ "15"
60
+ ]
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+
67
+ var editor = new JSONEditor(container, {
68
+ schema: schema
69
+ });
70
+
71
+ document.querySelector('.get-value').addEventListener('click', function () {
72
+ debug.value = JSON.stringify(editor.getValue());
73
+ });
74
+
75
+ </script>
76
+
77
+ </body>
78
+ </html>
@@ -0,0 +1,69 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>Autocomplete</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="https://unpkg.com/@trevoreyre/autocomplete-js"></script>
9
+ <script src="../../dist/jsoneditor.js"></script>
10
+ </head>
11
+ <body>
12
+
13
+ <div class="container">
14
+ <textarea class="value form-control" rows="10"></textarea>
15
+ <div class='json-editor-container'></div>
16
+ </div>
17
+
18
+
19
+ <script>
20
+ window.addEventListener('load', function () {
21
+ var jsonEditorContainer = document.querySelector('.json-editor-container')
22
+ var value = document.querySelector('.value')
23
+
24
+ JSONEditor.defaults.callbacks = {
25
+ 'autocomplete': {
26
+ 'search': function (editor, input) {
27
+ var countries = [
28
+ 'germany',
29
+ 'iran',
30
+ 'iraq',
31
+ 'spain'
32
+ ]
33
+
34
+ if (input.length < 1) { return [] }
35
+
36
+ return countries.filter(country => {
37
+ return country.toLowerCase().startsWith(input.toLowerCase())
38
+ })
39
+ }
40
+ }
41
+ }
42
+
43
+ var schema = {
44
+ 'title': 'Test',
45
+ 'type': 'string',
46
+ 'format': 'autocomplete',
47
+ 'options': {
48
+ 'autocomplete': {
49
+ 'search': 'search',
50
+ 'autoSelect': true
51
+ }
52
+ }
53
+ }
54
+
55
+ var editor = new JSONEditor(jsonEditorContainer, {
56
+ schema: schema,
57
+ theme: 'bootstrap4',
58
+ required_by_default: true,
59
+ show_errors: 'always'
60
+ })
61
+
62
+ editor.on('change', function () {
63
+ value.value = JSON.stringify(editor.getValue())
64
+ })
65
+ })
66
+ </script>
67
+
68
+ </body>
69
+ </html>
@@ -0,0 +1,38 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>Button Callbacks</title>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
8
+ </head>
9
+ <body>
10
+
11
+ <div class='container'></div>
12
+
13
+ <script>
14
+ var container = document.querySelector('.container');
15
+ var schema = {
16
+ 'type': 'object',
17
+ 'title': 'test',
18
+ 'properties': {
19
+ 'search': {
20
+ 'type': 'button',
21
+ 'title': 'Search',
22
+ 'options': {
23
+ 'button': {
24
+ 'icon': 'search'
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+
31
+ var editor = new JSONEditor(container, {
32
+ iconlib: 'fontawesome5',
33
+ schema: schema,
34
+ });
35
+ </script>
36
+
37
+ </body>
38
+ </html>
@@ -58,8 +58,8 @@
58
58
  var editor = new JSONEditor(container, {
59
59
  schema: schema
60
60
  });
61
-
62
- var changeCallback = function () {
61
+ editor.promise.then(() => {
62
+ var changeCallback = function () {
63
63
  if (this.getCount()>1) formChanged.style.display = 'block'
64
64
  }.bind({
65
65
  count:0,
@@ -111,6 +111,8 @@
111
111
  destroy.addEventListener('click', function () {
112
112
  editor.destroy();
113
113
  });
114
+ })
115
+
114
116
 
115
117
  </script>
116
118
 
@@ -0,0 +1,47 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>JSONEditor with forms</title>
6
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
7
+ </head>
8
+ <body>
9
+ <div class="container">
10
+ <button id="switch-es">Switch to ES</button>
11
+ <div id='editor-container'></div>
12
+ </div>
13
+ <script src="../../dist/jsoneditor.js"></script>
14
+ <script>
15
+ JSONEditor.defaults.languages.es = {}
16
+
17
+ var switchEs = document.querySelector('#switch-es')
18
+ var editor = null
19
+
20
+ var initEditor = function () {
21
+ if (editor) {
22
+ editor.destroy()
23
+ }
24
+
25
+ editor = new JSONEditor(document.querySelector('#editor-container'), {
26
+ theme: 'bootstrap4',
27
+ disable_edit_json: true,
28
+ disable_properties: true,
29
+ disable_collapse: true,
30
+ ajax: true,
31
+ show_errors: 'always',
32
+ schema: {
33
+ $ref: './validation-messages.json',
34
+ }
35
+ })
36
+ }
37
+
38
+ switchEs.addEventListener('click', function () {
39
+ JSONEditor.defaults.language = 'es'
40
+ initEditor()
41
+ })
42
+
43
+ initEditor()
44
+
45
+ </script>
46
+ </body>
47
+ </html>
@@ -34,7 +34,6 @@
34
34
  <script>
35
35
  var container = document.querySelector('.json-editor-container');
36
36
  var editor = document.querySelector('.value');
37
-
38
37
  var schema = {
39
38
  "type": "object",
40
39
  "title": "range",
@@ -291,19 +290,16 @@
291
290
  schema: schema,
292
291
  theme: theme
293
292
  });
293
+ document.getElementById('theme_switcher').addEventListener('change',function() {
294
+ setTheme(this.value);
295
+ });
296
+
297
+
294
298
  };
295
-
296
- document.getElementById('theme_switcher').addEventListener('change',function() {
297
- setTheme(this.value);
298
- });
299
-
300
299
  window.addEventListener('load',function() {
301
- editor = new JSONEditor(container, {
302
- schema: schema,
303
- theme: 'bootstrap4'
304
- });
305
300
  setTheme(this.value);
306
301
  });
302
+
307
303
 
308
304
  </script>
309
305
 
@@ -268,10 +268,6 @@
268
268
  });
269
269
 
270
270
  window.addEventListener('load',function() {
271
- editor = new JSONEditor(container, {
272
- schema: schema,
273
- theme: 'bootstrap4'
274
- });
275
271
  setTheme(this.value);
276
272
  });
277
273
 
@@ -59,8 +59,8 @@
59
59
  }
60
60
  },
61
61
  });
62
-
63
- // Hook up the submit button to log to the console
62
+ editor.promise.then(() => {
63
+ // Hook up the submit button to log to the console
64
64
  document.getElementById('submit').addEventListener('click',function() {
65
65
  // Get the value from the editor
66
66
  console.log(editor.getValue());
@@ -105,6 +105,8 @@
105
105
  }
106
106
  ]
107
107
  });
108
+ })
109
+
108
110
  </script>
109
111
  </body>
110
112
  </html>
@@ -625,6 +625,20 @@
625
625
  "tilte":"title"
626
626
  }
627
627
  },
628
+ "enum": {
629
+ "type": "array",
630
+ "items": {
631
+ "type": "object",
632
+ "properties": {
633
+ "title": {
634
+ "type": "string"
635
+ },
636
+ "infoText":{
637
+ "type": "string"
638
+ }
639
+ }
640
+ }
641
+ },
628
642
  "grid_columns":{
629
643
  "type":"integer",
630
644
  "default": 1,
@@ -162,7 +162,7 @@
162
162
  }
163
163
  };
164
164
 
165
- var setTheme = function(theme) {
165
+ var setTheme = async function(theme) {
166
166
  theme = theme || '';
167
167
 
168
168
  var mapping = {
@@ -210,30 +210,30 @@
210
210
  document.getElementById('theme_stylesheet').href = mapping[theme];
211
211
  document.getElementById('theme_switcher').value = JSONEditor.defaults.options.theme;
212
212
 
213
-
213
+ console.log(editor)
214
214
  if (editor) {
215
215
  editor.destroy();
216
216
  }
217
217
 
218
- initJsonEditor();
218
+ await initJsonEditor();
219
219
 
220
220
  };
221
221
 
222
- initJsonEditor = function () {
222
+ initJsonEditor = async function () {
223
223
  editor = new JSONEditor(container, {
224
224
  schema: schema,
225
225
  theme: 'bootstrap4',
226
226
  show_opt_in: true
227
227
  });
228
+ await editor.promise;
228
229
  }
229
230
 
230
231
  document.getElementById('theme_switcher').addEventListener('change',function() {
231
232
  setTheme(this.value);
232
233
  });
233
234
 
234
- window.addEventListener('load',function() {
235
-
236
- initJsonEditor();
235
+ window.addEventListener('load', async function() {
236
+ await initJsonEditor();
237
237
 
238
238
  getValue.addEventListener('click', function () {
239
239
  value.value = JSON.stringify(editor.getValue());
@@ -0,0 +1,60 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>Range</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="https://cdn.jsdelivr.net/npm/mathjs@5.3.1/dist/math.min.js" class="external_mathjs"></script>
9
+ <script src="../../dist/jsoneditor.js"></script>
10
+ </head>
11
+ <body>
12
+
13
+ <div class="container">
14
+ <textarea class="value form-control" rows="10"></textarea>
15
+ <button class='get-value'>Get Value</button>
16
+ <button class='set-value'>Set Value</button>
17
+ <div class='json-editor-container'></div>
18
+ </div>
19
+
20
+
21
+ <script>
22
+ var jsonEditorContainer = document.querySelector('.json-editor-container');
23
+ var value = document.querySelector('.value');
24
+
25
+ var schema = {
26
+ "title": "Settings",
27
+ "type": "object",
28
+ "properties": {
29
+ "speed": {
30
+ "title": "speed",
31
+ "description": "1 - Slowest, 10 - Fastest",
32
+ "type": "integer",
33
+ "minimum": 1,
34
+ "maximum": 10,
35
+ "format": "range"
36
+ }
37
+ }
38
+ }
39
+
40
+ var editor = new JSONEditor(jsonEditorContainer, {
41
+ schema: schema,
42
+ theme: 'bootstrap4',
43
+ use_default_values: false,
44
+ required_by_default: true,
45
+ show_errors: 'always'
46
+ });
47
+
48
+ document.querySelector('.get-value').addEventListener('click', function () {
49
+ value.value = JSON.stringify(editor.getValue());
50
+ console.log(editor.getValue());
51
+ });
52
+
53
+ document.querySelector('.set-value').addEventListener('click', function () {
54
+ editor.setValue({number_range: 2})
55
+ });
56
+
57
+ </script>
58
+
59
+ </body>
60
+ </html>
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>Ready</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
+
12
+ <div class="container">
13
+ <div class='json-editor-container'></div>
14
+ </div>
15
+
16
+
17
+ <script>
18
+ var jsonEditorContainer = document.querySelector('.json-editor-container');
19
+
20
+ var schema = {
21
+ "title": "Test",
22
+ "type": "object",
23
+ "properties": {
24
+ "test": {
25
+ "title": "test",
26
+ "type": "string",
27
+ "default": "lorem ipsum"
28
+ }
29
+ }
30
+ }
31
+
32
+ var editor = new JSONEditor(jsonEditorContainer, {
33
+ schema: schema,
34
+ theme: 'bootstrap4',
35
+ use_default_values: false,
36
+ required_by_default: true,
37
+ show_errors: 'always'
38
+ });
39
+
40
+ </script>
41
+
42
+ </body>
43
+ </html>