@json-editor/json-editor 2.11.0 → 2.13.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.
- package/.env +1 -1
- package/CHANGELOG.md +19 -0
- package/README.md +90 -6
- package/README_ADDON.md +5 -1
- package/dist/jsoneditor.js +1 -1
- package/dist/jsoneditor.js.LICENSE.txt +1 -1
- package/dist/nonmin/jsoneditor.js +417 -227
- package/dist/nonmin/jsoneditor.js.map +1 -1
- package/docs/cleave.html +1 -1
- package/docs/datetime.html +1 -1
- package/docs/describedby.html +1 -1
- package/docs/index.html +66 -14
- package/docs/meta_schema.json +16 -1
- package/docs/radio.html +1 -1
- package/docs/scripts/ajv-validator.js +8695 -0
- package/docs/select2.html +1 -1
- package/docs/selectize.html +2 -5
- package/docs/signature.html +12 -11
- package/docs/wysiwyg.html +1 -1
- package/package.json +1 -1
- package/src/core.js +10 -1
- package/src/defaults.js +3 -1
- package/src/editor.js +19 -1
- package/src/editors/array/selectize.js +0 -2
- package/src/editors/array.js +24 -13
- package/src/editors/base64.js +9 -0
- package/src/editors/button.js +8 -2
- package/src/editors/integer.js +3 -2
- package/src/editors/multiple.js +3 -0
- package/src/editors/number.js +4 -2
- package/src/editors/object.js +71 -3
- package/src/editors/signature.js +16 -16
- package/src/editors/simplemde.js +2 -1
- package/src/editors/string.js +4 -0
- package/src/editors/table.js +17 -14
- package/src/resolvers.js +13 -6
- package/src/schemaloader.js +13 -0
- package/src/theme.js +4 -0
- package/src/themes/bootstrap3.js +6 -0
- package/src/themes/bootstrap4.js +6 -0
- package/src/themes/bootstrap5.js +6 -0
- package/src/validator.js +28 -0
- package/tests/codeceptjs/codecept.json +1 -1
- package/tests/codeceptjs/constrains/contains_test.js +3 -2
- package/tests/codeceptjs/constrains/dependentRequired_test.js +33 -0
- package/tests/codeceptjs/constrains/dependentSchemas_test.js +1 -0
- package/tests/codeceptjs/core_test.js +14 -4
- package/tests/codeceptjs/editors/advanced_test.js +1 -1
- package/tests/codeceptjs/editors/array_test.js +59 -0
- package/tests/codeceptjs/editors/autocomplete_test.js +3 -1
- package/tests/codeceptjs/editors/object_test.js +20 -0
- package/tests/codeceptjs/editors/tabs_test.js +1 -1
- package/tests/codeceptjs/issues/issue-gh-1330_test.js +8 -0
- package/tests/codeceptjs/issues/issue-gh-1338_test.js +2 -0
- package/tests/codeceptjs/issues/issue-gh-1364_test.js +13 -0
- package/tests/codeceptjs/issues/issue-gh-1367_test.js +11 -0
- package/tests/codeceptjs/issues/issue-gh-1383_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1384_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1410_test.js +13 -0
- package/tests/codeceptjs/issues/issue-gh-1422_test.js +9 -0
- package/tests/codeceptjs/issues/issue-gh-1431_test.js +12 -0
- package/tests/codeceptjs/issues/issue-gh-1439_test.js +12 -0
- package/tests/docker-compose-local.yml +4 -0
- package/tests/pages/array-header-template.html +59 -0
- package/tests/pages/array-selectize-create.html +62 -0
- package/tests/pages/array-table-responsive.html +65 -0
- package/tests/pages/button-icons.html +1 -1
- package/tests/pages/button_state_mode_1.html +34 -0
- package/tests/pages/button_state_mode_2.html +35 -0
- package/tests/pages/dependentRequired.html +71 -0
- package/tests/pages/issues/issue-gh-1330.html +52 -0
- package/tests/pages/issues/issue-gh-1364.html +64 -0
- package/tests/pages/issues/issue-gh-1367.html +49 -0
- package/tests/pages/issues/issue-gh-1383.html +31 -0
- package/tests/pages/issues/issue-gh-1383.json +14 -0
- package/tests/pages/issues/issue-gh-1384.html +31 -0
- package/tests/pages/issues/issue-gh-1384.json +36 -0
- package/tests/pages/issues/issue-gh-1410.html +57 -0
- package/tests/pages/issues/issue-gh-1422.html +68 -0
- package/tests/pages/issues/issue-gh-1431.html +49 -0
- package/tests/pages/issues/issue-gh-1439.html +69 -0
- package/tests/pages/keep_only_existing_values.html +1 -1
- package/tests/pages/load-events.html +60 -0
- package/tests/pages/meta-schema.html +16 -2
- package/tests/pages/meta_schema.json +5 -1
- package/tests/pages/object-case-sensitive-property-search-false.html +41 -0
- package/tests/pages/object-case-sensitive-property-search-true.html +41 -0
- package/dist/dev/jsoneditor.js +0 -3687
- package/dist/jsoneditor.js.map +0 -1
package/docs/cleave.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
11
11
|
|
|
12
12
|
<!-- jQuery -->
|
|
13
|
-
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
|
14
14
|
|
|
15
15
|
<!-- Bootstrap4 -->
|
|
16
16
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
package/docs/datetime.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
11
11
|
|
|
12
12
|
<!-- jQuery -->
|
|
13
|
-
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
|
14
14
|
|
|
15
15
|
<!-- Bootstrap4 -->
|
|
16
16
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
package/docs/describedby.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
9
|
|
|
10
10
|
<!-- jQuery -->
|
|
11
|
-
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256
|
|
11
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
|
12
12
|
|
|
13
13
|
<!-- Bootstrap4 -->
|
|
14
14
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
package/docs/index.html
CHANGED
|
@@ -7,18 +7,19 @@
|
|
|
7
7
|
<script src="https://cdn.jsdelivr.net/npm/ace-builds@1.14.0/src-noconflict/ace.js"></script>
|
|
8
8
|
<script src="./polyfills/assign.js"></script>
|
|
9
9
|
<script src="https://cdn.jsdelivr.net/npm/lz-string@1.4.4/libs/lz-string.min.js"></script>
|
|
10
|
+
<script src="./scripts/ajv-validator.js"></script>
|
|
10
11
|
<link rel='stylesheet' id='theme-link'>
|
|
11
12
|
<link rel='stylesheet' id='iconlib-link'>
|
|
12
13
|
</head>
|
|
13
14
|
<body>
|
|
14
|
-
<div class=
|
|
15
|
+
<div class="container grid-xl" style="padding-top: 15px; padding-bottom: 30px;">
|
|
15
16
|
<div class="row columns md:flex">
|
|
16
|
-
<div class='col-
|
|
17
|
+
<div class='col-7 col-md-7 w-7/12'>
|
|
17
18
|
<h1>Editor</h1>
|
|
18
19
|
<p>Below is the editor generated from the JSON Schema.</p>
|
|
19
20
|
<div id="json-editor-form"></div>
|
|
20
21
|
</div>
|
|
21
|
-
<div class='col-
|
|
22
|
+
<div class='col-5 col-md-5 w-5/12'>
|
|
22
23
|
<div>
|
|
23
24
|
<a class="btn btn-primary" id="direct-link" title="preserves schema, value, and options">Direct Link</a>
|
|
24
25
|
<a class="btn btn-secondary" href="?" title="reload editor with default example settings">Reset</a>
|
|
@@ -38,6 +39,10 @@
|
|
|
38
39
|
<div>
|
|
39
40
|
<label for="boolean-options-select">Boolean options</label><br>
|
|
40
41
|
<select multiple size="15" id="boolean-options-select" class="form-control browser-default">
|
|
42
|
+
<option value='use_default_values'>Default values based on the "type"</option>
|
|
43
|
+
<option value='use_name_attributes'>Use name attributes</option>
|
|
44
|
+
<option value='prompt_before_delete'>Prompt before delete</option>
|
|
45
|
+
<option value='case_sensitive_property_search'>Case sensitive property search</option>
|
|
41
46
|
<option value='required_by_default'>Object properties required by default</option>
|
|
42
47
|
<option value='display_required_only'>Only show required properties by default</option>
|
|
43
48
|
<option value='show_opt_in'>Show optional properties (with checkbox)</option>
|
|
@@ -116,18 +121,34 @@
|
|
|
116
121
|
</div>
|
|
117
122
|
</div>
|
|
118
123
|
</div>
|
|
124
|
+
|
|
125
|
+
<h2>Schema</h2>
|
|
126
|
+
|
|
119
127
|
<div class="row columns md:flex">
|
|
120
|
-
<div class='col-
|
|
121
|
-
<
|
|
122
|
-
<label for="schema-textarea">You can change the schema and see how the generated form looks. After you make
|
|
123
|
-
changes, click "Update Schema"</label>
|
|
128
|
+
<div class='col-7 col-md-7 w-7/12'>
|
|
129
|
+
<label for="schema-textarea">You can change the schema and see how the generated form looks. After you make changes, click "Update Schema"</label>
|
|
124
130
|
<button class='btn btn-primary btn-block' id='setschema'>Update Schema</button>
|
|
125
131
|
<textarea id='schema-textarea' style="height: 100vh;"></textarea>
|
|
126
132
|
</div>
|
|
133
|
+
|
|
134
|
+
<div class='col-5 col-md-5 w-5/12'>
|
|
135
|
+
<label for="je-errors-textarea">
|
|
136
|
+
<span>AJV (JE meta-schema): </span>
|
|
137
|
+
<code id="je-errors-count"></code>
|
|
138
|
+
</label>
|
|
139
|
+
<textarea id='je-errors-textarea'></textarea>
|
|
140
|
+
|
|
141
|
+
<br>
|
|
142
|
+
|
|
143
|
+
<label for="ajv-errors-textarea">
|
|
144
|
+
<span>AJV (meta-schema-2020-12): </span>
|
|
145
|
+
<code id="ajv-errors-count"></code>
|
|
146
|
+
</label>
|
|
147
|
+
<textarea id='ajv-errors-textarea'></textarea>
|
|
148
|
+
</div>
|
|
127
149
|
</div>
|
|
128
150
|
</div>
|
|
129
151
|
<script>
|
|
130
|
-
|
|
131
152
|
var defaultSchema = {
|
|
132
153
|
'title': 'Person',
|
|
133
154
|
'type': 'object',
|
|
@@ -238,13 +259,13 @@
|
|
|
238
259
|
|
|
239
260
|
var data = {}
|
|
240
261
|
|
|
241
|
-
var defaultOptions = {
|
|
262
|
+
var defaultOptions = Object.assign({}, JSONEditor.defaults.options, {
|
|
242
263
|
iconlib: 'fontawesome5',
|
|
243
264
|
object_layout: 'normal',
|
|
244
265
|
schema: defaultSchema,
|
|
245
266
|
show_errors: 'interaction',
|
|
246
|
-
theme: 'bootstrap4'
|
|
247
|
-
}
|
|
267
|
+
theme: 'bootstrap4',
|
|
268
|
+
})
|
|
248
269
|
|
|
249
270
|
var jsoneditor = null
|
|
250
271
|
var directLink = document.querySelector('#direct-link')
|
|
@@ -265,14 +286,40 @@
|
|
|
265
286
|
|
|
266
287
|
var aceConfig = {
|
|
267
288
|
mode: 'ace/mode/json',
|
|
268
|
-
selection: false,
|
|
269
289
|
maxLines: Infinity,
|
|
270
|
-
minLines: 5
|
|
290
|
+
minLines: 5,
|
|
291
|
+
showFoldWidgets: false,
|
|
292
|
+
showPrintMargin: false
|
|
271
293
|
}
|
|
272
294
|
|
|
273
295
|
var outputTextarea = ace.edit('output-textarea', aceConfig)
|
|
274
|
-
|
|
275
296
|
var schemaTextarea = ace.edit('schema-textarea', aceConfig)
|
|
297
|
+
var ajvErrorsTextarea = ace.edit('ajv-errors-textarea', aceConfig)
|
|
298
|
+
var jeErrorsTextarea = ace.edit('je-errors-textarea', aceConfig)
|
|
299
|
+
var ajvErrorsCount = document.querySelector('#ajv-errors-count')
|
|
300
|
+
var jeErrorsCount = document.querySelector('#je-errors-count')
|
|
301
|
+
var ajv = new AjvValidator()
|
|
302
|
+
|
|
303
|
+
const validateSchema = () => {
|
|
304
|
+
const dataToValidate = JSON.parse(schemaTextarea.getValue())
|
|
305
|
+
let errors
|
|
306
|
+
|
|
307
|
+
// AJV validation
|
|
308
|
+
ajvErrorsCount.textContent = '0'
|
|
309
|
+
errors = ajv.validate202012(dataToValidate)
|
|
310
|
+
ajvErrorsTextarea.setValue(JSON.stringify(errors, null, 2))
|
|
311
|
+
ajvErrorsCount.textContent = JSON.stringify(errors.length)
|
|
312
|
+
schemaTextarea.clearSelection(1)
|
|
313
|
+
ajvErrorsTextarea.clearSelection(1)
|
|
314
|
+
|
|
315
|
+
// JE validation with AJV
|
|
316
|
+
jeErrorsCount.textContent = '0'
|
|
317
|
+
errors = ajv.validateJeMetaSchema(dataToValidate)
|
|
318
|
+
jeErrorsTextarea.setValue(JSON.stringify(errors, null, 2))
|
|
319
|
+
jeErrorsCount.textContent = JSON.stringify(errors.length)
|
|
320
|
+
schemaTextarea.clearSelection(1)
|
|
321
|
+
jeErrorsTextarea.clearSelection(1)
|
|
322
|
+
}
|
|
276
323
|
|
|
277
324
|
/* -------------------------------------------------------------- parse url */
|
|
278
325
|
|
|
@@ -313,6 +360,8 @@
|
|
|
313
360
|
var refreshUI = function () {
|
|
314
361
|
// schema
|
|
315
362
|
schemaTextarea.setValue(JSON.stringify(data.options.schema, null, 2))
|
|
363
|
+
schemaTextarea.clearSelection(1)
|
|
364
|
+
validateSchema()
|
|
316
365
|
|
|
317
366
|
// theme
|
|
318
367
|
var themeMap = {
|
|
@@ -407,6 +456,7 @@
|
|
|
407
456
|
},
|
|
408
457
|
selectize: {
|
|
409
458
|
js: [
|
|
459
|
+
'https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js',
|
|
410
460
|
'https://cdn.jsdelivr.net/npm/selectize@0.12.6/dist/js/standalone/selectize.min.js'
|
|
411
461
|
],
|
|
412
462
|
css: [
|
|
@@ -506,6 +556,7 @@
|
|
|
506
556
|
// output
|
|
507
557
|
var json = jsoneditor.getValue()
|
|
508
558
|
outputTextarea.setValue(JSON.stringify(json, null, 2))
|
|
559
|
+
outputTextarea.clearSelection(1)
|
|
509
560
|
|
|
510
561
|
// validate
|
|
511
562
|
var validationErrors = jsoneditor.validate()
|
|
@@ -536,6 +587,7 @@
|
|
|
536
587
|
setSchema.addEventListener('click', function () {
|
|
537
588
|
try {
|
|
538
589
|
data.options.schema = JSON.parse(schemaTextarea.getValue())
|
|
590
|
+
validateSchema()
|
|
539
591
|
} catch (e) {
|
|
540
592
|
alert('Invalid Schema: ' + e.message)
|
|
541
593
|
return
|
package/docs/meta_schema.json
CHANGED
|
@@ -122,8 +122,10 @@
|
|
|
122
122
|
"pgsql",
|
|
123
123
|
"php",
|
|
124
124
|
"python",
|
|
125
|
+
"prql",
|
|
125
126
|
"r",
|
|
126
127
|
"ruby",
|
|
128
|
+
"rust",
|
|
127
129
|
"sass",
|
|
128
130
|
"scala",
|
|
129
131
|
"scss",
|
|
@@ -131,10 +133,12 @@
|
|
|
131
133
|
"sql",
|
|
132
134
|
"stylus",
|
|
133
135
|
"svg",
|
|
136
|
+
"typescript",
|
|
134
137
|
"twig",
|
|
135
138
|
"vbscript",
|
|
136
139
|
"xml",
|
|
137
|
-
"yaml"
|
|
140
|
+
"yaml",
|
|
141
|
+
"zig"
|
|
138
142
|
]
|
|
139
143
|
},
|
|
140
144
|
"minLength": {
|
|
@@ -476,6 +480,17 @@
|
|
|
476
480
|
"propertyOrder": 50,
|
|
477
481
|
"format": "table"
|
|
478
482
|
},
|
|
483
|
+
"const": {
|
|
484
|
+
"type": [
|
|
485
|
+
"object",
|
|
486
|
+
"array",
|
|
487
|
+
"string",
|
|
488
|
+
"number",
|
|
489
|
+
"integer",
|
|
490
|
+
"boolean",
|
|
491
|
+
"null"
|
|
492
|
+
]
|
|
493
|
+
},
|
|
479
494
|
"enumSource": {
|
|
480
495
|
"oneOf": [
|
|
481
496
|
{
|
package/docs/radio.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
11
11
|
|
|
12
12
|
<!-- jQuery -->
|
|
13
|
-
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
|
14
14
|
|
|
15
15
|
<!-- Bootstrap4 -->
|
|
16
16
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|