@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
@@ -1,6 +1,6 @@
1
1
  /* global Feature Scenario */
2
2
 
3
- var assert = require('assert')
3
+ const assert = require('assert')
4
4
  const { DEFAULT_WAIT_TIME } = require('./test-config')
5
5
 
6
6
  Feature('core')
@@ -65,18 +65,18 @@ Scenario('should destroy', async ({ I }) => {
65
65
  Scenario('should set and get form value', async ({ I }) => {
66
66
  I.amOnPage('core.html')
67
67
  I.click('.get-value')
68
- assert.equal(await I.grabValueFrom('.value'), '{"age":18,"name":"Francesco Avizzano"}')
68
+ I.waitForValue('.value', '{"age":18,"name":"Francesco Avizzano"}')
69
69
  I.click('.set-value')
70
70
  I.click('.get-value')
71
- assert.equal(await I.grabValueFrom('.value'), '{"age":40,"name":"John Smith"}')
71
+ I.waitForValue('.value', '{"age":40,"name":"John Smith"}')
72
72
  })
73
73
 
74
74
  Scenario('should set and get individual values', async ({ I }) => {
75
75
  I.amOnPage('core.html')
76
76
  I.click('.get-individual-value')
77
- assert.equal(await I.grabValueFrom('.value'), '"Francesco Avizzano"')
77
+ I.waitForValue('.value', '"Francesco Avizzano"')
78
78
  I.click('.set-individual-value')
79
- assert.equal(await I.grabValueFrom('.value'), '"john kaminski"')
79
+ I.waitForValue('.value', '"john kaminski"')
80
80
  })
81
81
 
82
82
  Scenario('should watch a specific field for changes', async ({ I }) => {
@@ -116,9 +116,9 @@ Scenario('should change the form if form_name_root option is set @core', async (
116
116
  I.click('[for="form_2[1]"]')
117
117
  I.dontSee('Property must be set.', '.invalid-feedback')
118
118
  I.click('#get-value-form-1')
119
- assert.equal(await I.grabValueFrom('#value-form-1'), '"yes"')
119
+ I.waitForValue('#value-form-1', '"yes"')
120
120
  I.click('#get-value-form-2')
121
- assert.equal(await I.grabValueFrom('#value-form-2'), '"no"')
121
+ I.waitForValue('#value-form-2', '"no"')
122
122
  })
123
123
 
124
124
  Scenario('should validate against oneOf schemas and display single oneOf and editors error messages @core @oneof', async ({ I }) => {
@@ -182,69 +182,69 @@ Scenario('Should switch between all json 7 data types in @oneof and display erro
182
182
  I.waitForElement('.je-ready')
183
183
 
184
184
  I.selectOption('.je-switcher', 'Value, string')
185
- assert.equal(await I.grabValueFrom('#value'), '{"test":""}')
185
+ I.waitForValue('#value', '{"test":""}')
186
186
  I.waitForText('Value must validate against exactly one of the provided schemas.')
187
187
  I.waitForText('Value must be the constant value')
188
188
 
189
189
  I.selectOption('.je-switcher', 'Value, boolean')
190
- assert.equal(await I.grabValueFrom('#value'), '{"test":false}')
190
+ I.waitForValue('#value', '{"test":false}')
191
191
  I.waitForText('Value must validate against exactly one of the provided schemas.')
192
192
  I.waitForText('Value must be the constant value')
193
193
 
194
194
  I.selectOption('.je-switcher', 'Value, array')
195
- assert.equal(await I.grabValueFrom('#value'), '{"test":[]}')
195
+ I.waitForValue('#value', '{"test":[]}')
196
196
  I.waitForText('Value must validate against exactly one of the provided schemas.')
197
197
  I.waitForText('Value must be the constant value')
198
198
 
199
199
  I.selectOption('.je-switcher', 'Value, object')
200
- assert.equal(await I.grabValueFrom('#value'), '{"test":{}}')
200
+ I.waitForValue('#value', '{"test":{}}')
201
201
  I.waitForText('Value must validate against exactly one of the provided schemas.')
202
202
  I.waitForText('Value must be the constant value')
203
203
  I.waitForText('Object is missing the required property \'test\'')
204
204
 
205
205
  I.selectOption('.je-switcher', 'Value, number')
206
- assert.equal(await I.grabValueFrom('#value'), '{"test":0}')
206
+ I.waitForValue('#value', '{"test":0}')
207
207
  I.waitForText('Value must validate against exactly one of the provided schemas.')
208
208
  I.waitForText('Value must be the constant value')
209
209
 
210
210
  I.selectOption('.je-switcher', 'Value, integer')
211
- assert.equal(await I.grabValueFrom('#value'), '{"test":0}')
211
+ I.waitForValue('#value', '{"test":0}')
212
212
  I.waitForText('Value must validate against exactly one of the provided schemas.')
213
213
  I.waitForText('Value must be the constant value')
214
214
 
215
215
  I.selectOption('.je-switcher', 'Value, null')
216
- assert.equal(await I.grabValueFrom('#value'), '{"test":null}')
216
+ I.waitForValue('#value', '{"test":null}')
217
217
  })
218
218
 
219
- Scenario('Should switch between all json 7 data types in @anyof and display error messages for each one @core', async ({ I }) => {
219
+ Scenario('Should switch between all json 7 data types in @anyof and display error messages for each one @core', ({ I }) => {
220
220
  I.amOnPage('anyof-2.html')
221
221
  I.waitForElement('.je-ready')
222
222
 
223
- assert.equal(await I.grabValueFrom('#value'), '{"test":""}')
223
+ I.waitForValue('#value', '{"test":""}')
224
224
  I.waitForText('Value must validate against at least one of the provided schemas')
225
225
 
226
226
  I.selectOption('.je-switcher', 'Value, boolean')
227
- assert.equal(await I.grabValueFrom('#value'), '{"test":false}')
227
+ I.waitForValue('#value', '{"test":false}')
228
228
  I.waitForText('Value must validate against at least one of the provided schemas')
229
229
 
230
230
  I.selectOption('.je-switcher', 'Value, array')
231
- assert.equal(await I.grabValueFrom('#value'), '{"test":[]}')
231
+ I.waitForValue('#value', '{"test":[]}')
232
232
  I.waitForText('Value must validate against at least one of the provided schemas')
233
233
 
234
234
  I.selectOption('.je-switcher', 'Value, object')
235
- assert.equal(await I.grabValueFrom('#value'), '{"test":{}}')
235
+ I.waitForValue('#value', '{"test":{}}')
236
236
  I.waitForText('Value must validate against at least one of the provided schemas')
237
237
 
238
238
  I.selectOption('.je-switcher', 'Value, number')
239
- assert.equal(await I.grabValueFrom('#value'), '{"test":0}')
239
+ I.waitForValue('#value', '{"test":0}')
240
240
  I.waitForText('Value must validate against at least one of the provided schemas')
241
241
 
242
242
  I.selectOption('.je-switcher', 'Value, integer')
243
- assert.equal(await I.grabValueFrom('#value'), '{"test":0}')
243
+ I.waitForValue('#value', '{"test":0}')
244
244
  I.waitForText('Value must validate against at least one of the provided schemas')
245
245
 
246
246
  I.selectOption('.je-switcher', 'Value, null')
247
- assert.equal(await I.grabValueFrom('#value'), '{"test":null}')
247
+ I.waitForValue('#value', '{"test":null}')
248
248
  })
249
249
 
250
250
  Scenario('should validate against oneOf schemas and display single oneOf and editors error messages @core @translate-property', async ({ I }) => {
@@ -346,17 +346,17 @@ Scenario('should load internal schema definitions, external schema definitions a
346
346
  '../fixtures/string.json',
347
347
  '../fixtures/definitions.json',
348
348
  '../fixtures/basic_person.json',
349
- '../fixtures/person.json',
349
+ '../fixtures/person.json'
350
350
  ]
351
351
  for (const path of schemaPaths) {
352
- let key = 'je-cache::' + currentPath + path;
352
+ const key = 'je-cache::' + currentPath + path
353
353
 
354
354
  const item = await I.executeScript(function (storageKey) {
355
- return window.localStorage.getItem(storageKey);
355
+ return window.localStorage.getItem(storageKey)
356
356
  }, key)
357
357
  const itemDecoded = JSON.parse(item)
358
- assert.equal(itemDecoded.cacheBuster, 'abc123');
359
- assert(itemDecoded, 'Cached schema found');
358
+ assert.strictEqual(itemDecoded.cacheBuster, 'abc123')
359
+ assert(itemDecoded, 'Cached schema found')
360
360
  }
361
361
  })
362
362
 
@@ -1,13 +1,14 @@
1
+ /* global Feature Scenario */
1
2
 
2
- Feature('Advanced Editor');
3
+ Feature('Advanced Editor')
3
4
 
4
5
  Scenario('test validation & delete', ({ I }) => {
5
- I.amOnPage('advanced.html');
6
- I.retry({ retries: 5, minTimeout: 500 }).seeElement('#valid_indicator');
7
- I.see('valid', '#valid_indicator');
8
- I.fillField('root[0][location][city]', 'Stuttgart');
9
- I.waitForValue("[name='root[0][location][city]']", 'Stuttgart');
10
- I.amAcceptingPopups();
11
- I.click('.json-editor-btntype-deletelast');
12
- I.acceptPopup();
13
- });
6
+ I.amOnPage('advanced.html')
7
+ I.retry({ retries: 5, minTimeout: 500 }).seeElement('#valid_indicator')
8
+ I.see('valid', '#valid_indicator')
9
+ I.fillField('root[0][location][city]', 'Stuttgart')
10
+ I.waitForValue("[name='root[0][location][city]']", 'Stuttgart')
11
+ I.amAcceptingPopups()
12
+ I.click('.json-editor-btntype-deletelast')
13
+ I.acceptPopup()
14
+ })
@@ -1,50 +1,50 @@
1
- var assert = require('assert');
1
+ /* global Feature Scenario */
2
2
 
3
- Feature('anyof in array');
3
+ const assert = require('assert')
4
+ let value
5
+
6
+ Feature('anyof in array')
4
7
 
5
8
  Scenario('should have correct initial value', async ({ I }) => {
6
- I.amOnPage('array-anyof.html');
7
- I.click('.get-value');
8
- assert.equal(await I.grabValueFrom('.debug'), '{"correct":"","items":[]}');
9
- });
9
+ I.amOnPage('array-anyof.html')
10
+ I.click('.get-value')
11
+ I.waitForValue('.debug', '{"correct":"","items":[]}')
12
+ })
10
13
 
11
14
  Scenario('should show errors @optional', async ({ I }) => {
12
- I.amOnPage('array-anyof.html');
13
- I.seeElement('[data-schemapath="root"]');
14
- I.seeElement('[data-schemapath="root.items"]');
15
+ I.amOnPage('array-anyof.html')
16
+ I.seeElement('[data-schemapath="root"]')
17
+ I.seeElement('[data-schemapath="root.items"]')
15
18
 
16
- I.click('.get-value');
17
- value = await I.grabValueFrom('.debug');
18
- assert.equal(value, '{"correct":"","items":[]}');
19
+ I.click('.get-value')
20
+ I.waitForValue('.debug', '{"correct":"","items":[]}')
19
21
 
20
- I.fillField('root[correct]', 'a');
21
- assert.equal(await I.dontSee('Value must match the pattern ^[a-zA-Z0-9_]+$.'), true, 'should show warning');
22
+ I.fillField('root[correct]', 'a')
23
+ assert.strictEqual(await I.dontSee('Value must match the pattern ^[a-zA-Z0-9_]+$.'), true, 'should show warning')
22
24
 
23
- I.fillField('root[correct]', 'a!');
24
- assert.equal(await I.seeInField('root[correct]', 'a!'), true, 'fillField failed');
25
- assert.equal(await I.see('Value must match the pattern ^[a-zA-Z0-9_]+$.'), true, 'should show warning');
25
+ I.fillField('root[correct]', 'a!')
26
+ assert.strictEqual(await I.seeInField('root[correct]', 'a!'), true, 'fillField failed')
27
+ assert.strictEqual(await I.see('Value must match the pattern ^[a-zA-Z0-9_]+$.'), true, 'should show warning')
26
28
 
27
- I.clearField('root[correct]');
28
- I.seeInField('root[correct]', '');
29
- assert.equal(await I.see('Value must match the pattern ^[a-zA-Z0-9_]+$.'), true, "should show warning");
29
+ I.clearField('root[correct]')
30
+ I.seeInField('root[correct]', '')
31
+ assert.strictEqual(await I.see('Value must match the pattern ^[a-zA-Z0-9_]+$.'), true, 'should show warning')
30
32
 
31
- I.fillField('root[correct]', 'a');
32
- I.dontSee('Value must match the pattern ^[a-zA-Z0-9_]+$.');
33
+ I.fillField('root[correct]', 'a')
34
+ I.dontSee('Value must match the pattern ^[a-zA-Z0-9_]+$.')
33
35
 
34
- I.click('.json-editor-btntype-add');
35
- I.click('.get-value');
36
- value = await I.grabValueFrom('.debug');
37
- assert.equal(value, '{"correct":"a","items":[{"handler":"aaa","id":"","___a":""}]}');
36
+ I.click('.json-editor-btntype-add')
37
+ I.click('.get-value')
38
+ I.waitForValue('.debug', '{"correct":"a","items":[{"handler":"aaa","id":"","___a":""}]}')
38
39
 
39
- I.fillField('root[items][0][id]', 'a');
40
- I.dontSee('Value must match the pattern ^[a-zA-Z0-9_]+$.');
40
+ I.fillField('root[items][0][id]', 'a')
41
+ I.dontSee('Value must match the pattern ^[a-zA-Z0-9_]+$.')
41
42
 
42
- I.clearField('root[items][0][id]');
43
- I.seeInField('root[items][0][id]', '');
43
+ I.clearField('root[items][0][id]')
44
+ I.seeInField('root[items][0][id]', '')
44
45
  // todo still not work
45
- assert.equal(await I.see('Value must match the pattern ^[a-zA-Z0-9_]+$.'), true, 'should show warning');
46
-
47
- I.fillField('root[items][0][id]', 'a!');
48
- I.see('Value must match the pattern ^[a-zA-Z0-9_]+$.');
46
+ assert.strictEqual(await I.see('Value must match the pattern ^[a-zA-Z0-9_]+$.'), true, 'should show warning')
49
47
 
50
- });
48
+ I.fillField('root[items][0][id]', 'a!')
49
+ I.see('Value must match the pattern ^[a-zA-Z0-9_]+$.')
50
+ })