@json-editor/json-editor 2.9.0-beta.0 → 2.9.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 (58) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/README.md +16 -7
  3. package/dist/jsoneditor.js +2 -2
  4. package/dist/jsoneditor.js.LICENSE.txt +15 -0
  5. package/dist/jsoneditor.js.map +1 -0
  6. package/dist/nonmin/jsoneditor.js +989 -127
  7. package/dist/nonmin/jsoneditor.js.map +1 -1
  8. package/docs/index.html +22 -10
  9. package/docs/meta_schema.json +3 -2
  10. package/docs/starrating.html +2 -6
  11. package/package.json +4 -2
  12. package/src/defaults.js +9 -1
  13. package/src/editor.js +17 -3
  14. package/src/editors/array.js +7 -4
  15. package/src/editors/multiselect.js +1 -0
  16. package/src/editors/object.css +3 -3
  17. package/src/editors/object.css.js +1 -1
  18. package/src/editors/object.js +5 -2
  19. package/src/editors/table.js +11 -4
  20. package/src/editors/upload.js +3 -2
  21. package/src/themes/barebones.js +3 -1
  22. package/src/themes/bootstrap5.css +97 -0
  23. package/src/themes/bootstrap5.css.js +3 -0
  24. package/src/themes/bootstrap5.js +623 -0
  25. package/src/themes/index.js +2 -0
  26. package/src/themes/tailwind.js +2 -2
  27. package/tests/codeceptjs/core_test.js +107 -17
  28. package/tests/codeceptjs/editors/array_test.js +6 -5
  29. package/tests/codeceptjs/editors/button_test.js +7 -6
  30. package/tests/codeceptjs/editors/checkbox_test.js +3 -2
  31. package/tests/codeceptjs/editors/integer_test.js +3 -2
  32. package/tests/codeceptjs/editors/issues/issue-gh-1158_test.js +10 -0
  33. package/tests/codeceptjs/editors/issues/issue-gh-1257_test.js +13 -0
  34. package/tests/codeceptjs/editors/number_test.js +2 -1
  35. package/tests/codeceptjs/editors/object_test.js +39 -38
  36. package/tests/codeceptjs/editors/option-no_default_values_test.js +1 -1
  37. package/tests/codeceptjs/editors/programmatic-changes_test.js +3 -2
  38. package/tests/codeceptjs/editors/tabs_test.js +5 -3
  39. package/tests/codeceptjs/editors/validation_test.js +3 -1
  40. package/tests/codeceptjs/meta-schema_test.js +72 -4
  41. package/tests/codeceptjs/schemaloader_test.js +2 -1
  42. package/tests/codeceptjs/test-config.js +3 -0
  43. package/tests/codeceptjs/themes_test.js +14 -0
  44. package/tests/pages/anyof-2.html +90 -0
  45. package/tests/pages/anyof.html +1 -1
  46. package/tests/pages/container-attributes.html +50 -0
  47. package/tests/pages/issues/issue-gh-1158.html +50 -0
  48. package/tests/pages/issues/issue-gh-1233-failing.html +46 -0
  49. package/tests/pages/issues/issue-gh-1233-passing.html +49 -0
  50. package/tests/pages/issues/issue-gh-1257.html +77 -0
  51. package/tests/pages/meta-schema.html +747 -0
  52. package/tests/pages/meta_schema.json +3 -16
  53. package/tests/pages/oneof-2.html +90 -0
  54. package/tests/pages/per-editor-options.html +44 -0
  55. package/tests/pages/stepper.html +2 -2
  56. package/tests/pages/themes.html +2 -0
  57. /package/tests/pages/{table-move-events.html → array-events-table.html} +0 -0
  58. /package/tests/pages/{array-move-events.html → array-events.html} +0 -0
@@ -0,0 +1,747 @@
1
+ <!DOCTYPE html>
2
+ <html lang="de">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>meta-schema</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
+ <label for="value">Value</label>
14
+ <textarea class="form-control" id="value" rows="12" style="font-size: 12px; font-family: monospace;"></textarea>
15
+ <button class='set-value'>Set Value</button>
16
+ <div class='json-editor-container'></div>
17
+ </div>
18
+
19
+ <script>
20
+ var jsonEditorContainer = document.querySelector('.json-editor-container')
21
+ var value = document.querySelector('#value')
22
+
23
+ var schema = {
24
+ 'definitions': {
25
+ 'schemaArray': {
26
+ 'type': 'array',
27
+ 'minItems': 1,
28
+ 'items': {
29
+ '$ref': '#/definitions/schema',
30
+ 'title': 'schema'
31
+ }
32
+ },
33
+ 'null': {
34
+ 'properties': {
35
+ 'type': {
36
+ 'enum': [
37
+ 'null'
38
+ ]
39
+ },
40
+ 'enum': {
41
+ 'items': {
42
+ 'type': 'null'
43
+ }
44
+ },
45
+ 'default': {
46
+ 'type': 'null',
47
+ 'propertyOrder': 10
48
+ }
49
+ }
50
+ },
51
+ 'boolean': {
52
+ 'properties': {
53
+ 'type': {
54
+ 'enum': [
55
+ 'boolean'
56
+ ]
57
+ },
58
+ 'enum': {
59
+ 'items': {
60
+ 'type': 'boolean'
61
+ }
62
+ },
63
+ 'format': {
64
+ 'type': 'string',
65
+ 'enum': [
66
+ 'select',
67
+ 'checkbox'
68
+ ]
69
+ },
70
+ 'default': {
71
+ 'type': 'boolean',
72
+ 'propertyOrder': 10
73
+ }
74
+ }
75
+ },
76
+ 'string': {
77
+ 'properties': {
78
+ 'options': {
79
+ 'properties': {
80
+ 'input_width': {
81
+ 'type': 'string'
82
+ },
83
+ 'input_height': {
84
+ 'type': 'string'
85
+ },
86
+ 'expand_height': {
87
+ 'type': 'boolean'
88
+ },
89
+ 'wysiwyg': {
90
+ 'type': 'boolean'
91
+ }
92
+ }
93
+ },
94
+ 'format': {
95
+ 'type': 'string',
96
+ 'propertyOrder': 20,
97
+ 'enum': [
98
+ 'color',
99
+ 'date',
100
+ 'datetime-local',
101
+ 'email',
102
+ 'month',
103
+ 'number',
104
+ 'range',
105
+ 'tel',
106
+ 'text',
107
+ 'textarea',
108
+ 'time',
109
+ 'url',
110
+ 'week',
111
+ 'actionscript',
112
+ 'batchfile',
113
+ 'c',
114
+ 'c++',
115
+ 'cpp',
116
+ 'coffee',
117
+ 'cshart',
118
+ 'css',
119
+ 'dart',
120
+ 'django',
121
+ 'ejs',
122
+ 'erlang',
123
+ 'golang',
124
+ 'groovy',
125
+ 'handlebars',
126
+ 'haskell',
127
+ 'haxe',
128
+ 'html',
129
+ 'ini',
130
+ 'jade',
131
+ 'java',
132
+ 'javascript',
133
+ 'json',
134
+ 'less',
135
+ 'lisp',
136
+ 'lua',
137
+ 'makefile',
138
+ 'markdown',
139
+ 'matlab',
140
+ 'mysql',
141
+ 'objectivec',
142
+ 'pascal',
143
+ 'perl',
144
+ 'pgsql',
145
+ 'php',
146
+ 'python',
147
+ 'r',
148
+ 'ruby',
149
+ 'sass',
150
+ 'scala',
151
+ 'scss',
152
+ 'smarty',
153
+ 'sql',
154
+ 'stylus',
155
+ 'svg',
156
+ 'twig',
157
+ 'vbscript',
158
+ 'xml',
159
+ 'yaml'
160
+ ]
161
+ },
162
+ 'minLength': {
163
+ 'type': 'integer',
164
+ 'minimum': 0,
165
+ 'propertyOrder': 25
166
+ },
167
+ 'maxLength': {
168
+ 'type': 'integer',
169
+ 'minimum': 0,
170
+ 'propertyOrder': 30
171
+ },
172
+ 'pattern': {
173
+ 'type': 'string',
174
+ 'format': 'regex',
175
+ 'propertyOrder': 35
176
+ },
177
+ 'type': {
178
+ 'enum': [
179
+ 'string'
180
+ ]
181
+ },
182
+ 'enum': {
183
+ 'items': {
184
+ 'type': 'string'
185
+ }
186
+ },
187
+ 'default': {
188
+ 'type': 'string',
189
+ 'propertyOrder': 10
190
+ },
191
+ 'media': {
192
+ 'type': 'object',
193
+ 'additionalProperties': false,
194
+ 'properties': {
195
+ 'type': {
196
+ 'type': 'string'
197
+ }
198
+ }
199
+ },
200
+ 'template': {
201
+ 'type': 'string'
202
+ }
203
+ }
204
+ },
205
+ 'number': {
206
+ 'properties': {
207
+ 'options': {
208
+ 'properties': {
209
+ 'input_width': {
210
+ 'type': 'string'
211
+ },
212
+ 'input_height': {
213
+ 'type': 'string'
214
+ },
215
+ 'expand_height': {
216
+ 'type': 'boolean'
217
+ }
218
+ }
219
+ },
220
+ 'type': {
221
+ 'enum': [
222
+ 'number'
223
+ ]
224
+ },
225
+ 'enum': {
226
+ 'items': {
227
+ 'type': 'number'
228
+ }
229
+ },
230
+ 'default': {
231
+ 'type': 'number'
232
+ },
233
+ 'minimum': {
234
+ 'type': 'number',
235
+ 'propertyOrder': 25
236
+ },
237
+ 'maximum': {
238
+ 'type': 'number',
239
+ 'propertyOrder': 30
240
+ },
241
+ 'multipleOf': {
242
+ 'type': 'number',
243
+ 'propertyOrder': 35
244
+ }
245
+ }
246
+ },
247
+ 'integer': {
248
+ 'properties': {
249
+ 'options': {
250
+ 'properties': {
251
+ 'input_width': {
252
+ 'type': 'string'
253
+ },
254
+ 'input_height': {
255
+ 'type': 'string'
256
+ },
257
+ 'expand_height': {
258
+ 'type': 'boolean'
259
+ }
260
+ }
261
+ },
262
+ 'default': {
263
+ 'type': 'integer'
264
+ },
265
+ 'minimum': {
266
+ 'type': 'number',
267
+ 'propertyOrder': 25
268
+ },
269
+ 'maximum': {
270
+ 'type': 'number',
271
+ 'propertyOrder': 30
272
+ },
273
+ 'multipleOf': {
274
+ 'type': 'number',
275
+ 'propertyOrder': 35
276
+ },
277
+ 'type': {
278
+ 'enum': [
279
+ 'integer'
280
+ ]
281
+ },
282
+ 'enum': {
283
+ 'items': {
284
+ 'type': 'integer'
285
+ }
286
+ }
287
+ }
288
+ },
289
+
290
+ 'object': {
291
+ 'defaultProperties': [
292
+ 'properties'
293
+ ],
294
+ 'properties': {
295
+ 'options': {
296
+ 'properties': {
297
+ 'collapsed': {
298
+ 'type': 'boolean'
299
+ },
300
+ 'disable_collapse': {
301
+ 'type': 'boolean'
302
+ },
303
+ 'disable_edit_json': {
304
+ 'type': 'boolean'
305
+ },
306
+ 'disable_properties': {
307
+ 'type': 'boolean'
308
+ },
309
+ 'remove_empty_properties': {
310
+ 'type': 'boolean'
311
+ },
312
+ 'layout': {
313
+ 'type': 'string',
314
+ 'enum': [
315
+ 'grid'
316
+ ]
317
+ }
318
+ }
319
+ },
320
+ 'type': {
321
+ 'enum': [
322
+ 'object'
323
+ ]
324
+ },
325
+ 'default': {
326
+ 'type': 'object'
327
+ },
328
+ 'properties': {
329
+ 'type': 'object',
330
+ 'patternProperties': {
331
+ '.*': {
332
+ '$ref': '#/definitions/schema'
333
+ }
334
+ }
335
+ },
336
+ 'patternProperties': {
337
+ 'type': 'object',
338
+ 'patternProperties': {
339
+ '.*': {
340
+ '$ref': '#/definitions/schema'
341
+ }
342
+ }
343
+ },
344
+ 'additionalProperties': {
345
+ 'type': 'boolean'
346
+ },
347
+ 'required': {
348
+ 'type': 'array',
349
+ 'uniqueItems': true,
350
+ 'format': 'table',
351
+ 'items': {
352
+ 'type': 'string',
353
+ 'title': 'property'
354
+ }
355
+ },
356
+ 'format': {
357
+ 'type': 'string',
358
+ 'enum': [
359
+ 'grid'
360
+ ]
361
+ }
362
+ }
363
+ },
364
+ 'array': {
365
+ 'defaultProperties': [
366
+ 'items'
367
+ ],
368
+ 'properties': {
369
+ 'options': {
370
+ 'properties': {
371
+ 'collapsed': {
372
+ 'type': 'boolean'
373
+ },
374
+ 'disable_array_add': {
375
+ 'type': 'boolean'
376
+ },
377
+ 'disable_array_delete': {
378
+ 'type': 'boolean'
379
+ },
380
+ 'disable_array_delete_all_rows': {
381
+ 'type': 'boolean'
382
+ },
383
+ 'disable_array_delete_last_row': {
384
+ 'type': 'boolean'
385
+ },
386
+ 'disable_array_reorder': {
387
+ 'type': 'boolean'
388
+ },
389
+ 'disable_collapse': {
390
+ 'type': 'boolean'
391
+ }
392
+ }
393
+ },
394
+ 'type': {
395
+ 'enum': [
396
+ 'array'
397
+ ]
398
+ },
399
+ 'default': {
400
+ 'type': 'array',
401
+ 'format': 'table'
402
+ },
403
+ 'items': {
404
+ 'oneOf': [
405
+ {
406
+ '$ref': '#/definitions/schema'
407
+ },
408
+ {
409
+ 'type': 'array',
410
+ '$ref': '#/definitions/schemaArray',
411
+ 'format': 'tabs'
412
+ }
413
+ ]
414
+ },
415
+ 'uniqueItems': {
416
+ 'type': 'boolean'
417
+ },
418
+ 'minItems': {
419
+ 'type': 'integer',
420
+ 'minimum': 0
421
+ },
422
+ 'maxItems': {
423
+ 'type': 'integer',
424
+ 'minimum': 0
425
+ },
426
+ 'additionalItems': {
427
+ '$ref': '#/definitions/schema'
428
+ },
429
+ 'format': {
430
+ 'type': 'string',
431
+ 'enum': [
432
+ 'array',
433
+ 'table',
434
+ 'tabs',
435
+ 'tabs-top',
436
+ 'checkbox',
437
+ 'select',
438
+ 'categories'
439
+ ]
440
+ }
441
+ }
442
+ },
443
+
444
+ 'schemaBase': {
445
+ 'type': 'object',
446
+ 'defaultProperties': [
447
+ 'title',
448
+ 'type'
449
+ ],
450
+ 'required': ['type'],
451
+
452
+ 'properties': {
453
+ 'type': {
454
+ 'propertyOrder': 1,
455
+ 'type': 'string',
456
+ 'options': {
457
+ 'hidden': true
458
+ }
459
+ },
460
+ 'id': {
461
+ 'type': 'string',
462
+ 'format': 'uri'
463
+ },
464
+ '$schema': {
465
+ 'type': 'string',
466
+ 'format': 'uri'
467
+ },
468
+ 'title': {
469
+ 'type': 'string',
470
+ 'propertyOrder': 2
471
+ },
472
+ 'description': {
473
+ 'type': 'string',
474
+ 'propertyOrder': 4
475
+ },
476
+
477
+ 'enum': {
478
+ 'type': 'array',
479
+ 'minItems': 1,
480
+ 'uniqueItems': true,
481
+ 'propertyOrder': 50,
482
+ 'format': 'table'
483
+ },
484
+ 'enumSource': {
485
+ 'oneOf': [
486
+ {
487
+ 'title': 'Simple Source',
488
+ 'type': 'string'
489
+ },
490
+ {
491
+ 'title': 'Complex Source',
492
+ 'type': 'array',
493
+ 'format': 'tabs',
494
+ 'minItems': 1,
495
+ 'items': {
496
+ 'oneOf': [
497
+ {
498
+ 'title': 'Constant Values',
499
+ 'type': 'array',
500
+ 'format': 'table',
501
+ 'uniqueItems': true,
502
+ 'items': {
503
+ 'type': 'string'
504
+ }
505
+ },
506
+ {
507
+ 'title': 'Source',
508
+ 'type': 'object',
509
+ 'additionalProperties': false,
510
+ 'required': [
511
+ 'source'
512
+ ],
513
+ 'defaultProperties': [
514
+ 'source'
515
+ ],
516
+ 'properties': {
517
+ 'source': {
518
+ 'oneOf': [
519
+ {
520
+ 'title': 'Watched Field',
521
+ 'type': 'string'
522
+ },
523
+ {
524
+ 'title': 'Constant Values',
525
+ 'type': 'array',
526
+ 'format': 'table',
527
+ 'minItems': 1,
528
+ 'items': {
529
+ 'title': 'value',
530
+ 'type': 'object',
531
+ 'additionalProperties': false,
532
+ 'properties': {
533
+ 'value': {
534
+ 'type': 'string'
535
+ },
536
+ 'title': {
537
+ 'type': 'string'
538
+ }
539
+ }
540
+ }
541
+ }
542
+ ]
543
+ },
544
+ 'slice': {
545
+ 'type': 'array',
546
+ 'format': 'table',
547
+ 'minItems': 2,
548
+ 'maxItems': 2,
549
+ 'items': {
550
+ 'type': 'integer'
551
+ }
552
+ },
553
+ 'filter': {
554
+ 'type': 'string'
555
+ },
556
+ 'title': {
557
+ 'type': 'string'
558
+ },
559
+ 'value': {
560
+ 'type': 'string'
561
+ }
562
+ }
563
+ }
564
+ ]
565
+ }
566
+ }
567
+ ]
568
+ },
569
+ '$ref': {
570
+ 'type': 'string'
571
+ },
572
+ 'oneOf': {
573
+ '$ref': '#/definitions/schemaArray'
574
+ },
575
+ 'anyOf': {
576
+ '$ref': '#/definitions/schemaArray'
577
+ },
578
+ 'allOf': {
579
+ '$ref': '#/definitions/schemaArray'
580
+ },
581
+ 'not': {
582
+ '$ref': '#/definitions/schema'
583
+ },
584
+ 'propertyOrder': {
585
+ 'type': 'number',
586
+ 'default': 1000
587
+ },
588
+ 'links': {
589
+ 'type': 'array',
590
+ 'format': 'table',
591
+ 'items': {
592
+ 'type': 'object',
593
+ 'title': 'link',
594
+ 'additionalProperties': false,
595
+ 'properties': {
596
+ 'rel': {
597
+ 'type': 'string'
598
+ },
599
+ 'href': {
600
+ 'type': 'string',
601
+ 'format': 'url'
602
+ },
603
+ 'class': {
604
+ 'type': 'string'
605
+ },
606
+ 'download': {
607
+ 'oneOf': [
608
+ {
609
+ 'type': 'boolean'
610
+ },
611
+ {
612
+ 'type': 'string'
613
+ }
614
+ ]
615
+ },
616
+ 'mediaType': {
617
+ 'type': 'string'
618
+ }
619
+ }
620
+ }
621
+ },
622
+ 'watch': {
623
+ 'type': 'object',
624
+ 'patternProperties': {
625
+ '.*': {
626
+ 'type': 'string'
627
+ }
628
+ }
629
+ },
630
+ 'headerTemplate': {
631
+ 'type': 'string'
632
+ },
633
+ 'options': {
634
+ 'type': 'object',
635
+ 'options': {
636
+ 'keep_oneof_values': false
637
+ },
638
+ 'default': {},
639
+ 'defaultProperties': {},
640
+ 'properties': {
641
+ 'enum_titles': {
642
+ 'type': 'array',
643
+ 'uniqueItems': true,
644
+ 'format': 'table',
645
+ 'items': {
646
+ 'type': 'string',
647
+ 'tilte': 'title'
648
+ }
649
+ },
650
+ 'grid_columns': {
651
+ 'type': 'integer',
652
+ 'default': 1,
653
+ 'minimum': 1,
654
+ 'maximum': 12
655
+ },
656
+ 'hidden': {
657
+ 'type': 'boolean'
658
+ },
659
+ 'keep_oneof_values': {
660
+ 'type': 'boolean'
661
+ }
662
+ }
663
+ }
664
+ }
665
+ },
666
+ 'schema': {
667
+ 'allOf': [{
668
+ '$ref': '#/definitions/schemaBase'
669
+ }],
670
+ 'options': {
671
+ 'keep_oneof_values': false
672
+ },
673
+ 'default': {
674
+ 'type': 'object'
675
+ },
676
+ 'oneOf': [
677
+ {
678
+ 'title': 'Object',
679
+ 'additionalProperties': false,
680
+ '$ref': '#/definitions/object'
681
+ },
682
+ {
683
+ 'title': 'Array',
684
+ 'additionalProperties': false,
685
+ '$ref': '#/definitions/array'
686
+ },
687
+ {
688
+ 'title': 'String',
689
+ 'additionalProperties': false,
690
+ '$ref': '#/definitions/string'
691
+ },
692
+ {
693
+ 'title': 'Number',
694
+ 'additionalProperties': false,
695
+ '$ref': '#/definitions/number'
696
+ },
697
+ {
698
+ 'title': 'Integer',
699
+ 'additionalProperties': false,
700
+ '$ref': '#/definitions/integer'
701
+ },
702
+ {
703
+ 'title': 'Boolean',
704
+ 'additionalProperties': false,
705
+ '$ref': '#/definitions/boolean'
706
+ },
707
+ {
708
+ 'title': 'Null',
709
+ 'additionalProperties': false,
710
+ '$ref': '#/definitions/null'
711
+ }
712
+ ]
713
+ }
714
+ },
715
+ 'title': 'JSON Schema',
716
+ '$ref': '#/definitions/schema',
717
+ 'properties': {
718
+ 'definitions': {
719
+ 'type': 'object',
720
+ 'patternProperties': {
721
+ '.*': {
722
+ '$ref': '#/definitions/schema'
723
+ }
724
+ }
725
+ }
726
+ }
727
+ }
728
+
729
+ var editor = new JSONEditor(jsonEditorContainer, {
730
+ schema: schema,
731
+ theme: 'bootstrap4',
732
+ show_errors: 'always',
733
+ iconlib: 'fontawesome5',
734
+ keep_oneof_values: false
735
+ })
736
+
737
+ editor.on('change', function () {
738
+ value.value = JSON.stringify(editor.getValue())
739
+ })
740
+
741
+ document.querySelector('.set-value').addEventListener('click', function () {
742
+ editor.setValue({ test: 0 })
743
+ })
744
+ </script>
745
+
746
+ </body>
747
+ </html>