@json-editor/json-editor 2.5.4 → 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.
- package/.github/workflows/build.yml +12 -3
- package/CHANGELOG.md +51 -14
- package/README.md +159 -20
- package/dist/jsoneditor.js +2 -2
- package/dist/nonmin/jsoneditor.js +5483 -3610
- 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/form-submission.html +76 -0
- package/docs/index.html +2 -2
- package/docs/materialize_css.html +1 -1
- package/docs/meta_schema.json +0 -1
- package/docs/radio.html +1 -1
- package/docs/select2.html +1 -1
- package/docs/selectize.html +1 -1
- package/docs/starrating.html +1 -1
- package/docs/wysiwyg.html +1 -1
- package/package.json +28 -26
- package/release-notes.md +5 -3
- package/src/core.js +36 -37
- package/src/defaults.js +9 -2
- package/src/editor.js +6 -2
- package/src/editors/array.js +12 -1
- package/src/editors/autocomplete.js +4 -3
- package/src/editors/button.js +1 -1
- package/src/editors/multiple.js +2 -0
- package/src/editors/multiselect.js +14 -5
- package/src/editors/object.js +10 -6
- package/src/editors/radio.js +6 -1
- package/src/editors/string.js +7 -1
- package/src/editors/table.js +21 -2
- package/src/editors/upload.js +1 -1
- package/src/editors/uuid.js +2 -12
- package/src/iconlib.js +1 -1
- package/src/schemaloader.js +232 -109
- package/src/style.css +3 -0
- package/src/style.css.js +1 -1
- package/src/theme.js +5 -4
- package/src/themes/bootstrap3.js +3 -2
- package/src/themes/bootstrap4.js +7 -0
- package/src/themes/spectre.js +2 -1
- package/src/utilities.js +18 -0
- package/src/validator.js +65 -47
- package/tests/codeceptjs/codecept.json +1 -1
- package/tests/codeceptjs/core_test.js +98 -0
- package/tests/codeceptjs/editors/advanced_test.js +1 -1
- package/tests/codeceptjs/editors/array_test.js +74 -0
- package/tests/codeceptjs/editors/autocomplete_test.js +16 -0
- package/tests/codeceptjs/editors/button_test.js +11 -4
- package/tests/codeceptjs/editors/integer_test.js +7 -2
- package/tests/codeceptjs/editors/jodit_test.js +3 -3
- package/tests/codeceptjs/editors/object_test.js +84 -13
- package/tests/codeceptjs/editors/range_test.js +12 -0
- package/tests/codeceptjs/editors/stepper_test.js +12 -0
- package/tests/codeceptjs/editors/uuid_test.js +31 -4
- package/tests/codeceptjs/editors/validation_test.js +1 -1
- package/tests/docker-compose.yml +1 -1
- package/tests/fixtures/definitions.json +22 -0
- package/tests/fixtures/properties.json +20 -0
- package/tests/fixtures/validation.json +207 -0
- package/tests/pages/array-checkboxes-infotext.html +52 -0
- package/tests/pages/array-move-events.html +4 -2
- package/tests/pages/array-unique-items-sort.html +78 -0
- package/tests/pages/autocomplete.html +69 -0
- package/tests/pages/button-icons.html +38 -0
- package/tests/pages/core.html +4 -2
- package/tests/pages/error-messages.html +47 -0
- package/tests/pages/grid-strict.html +6 -10
- package/tests/pages/grid.html +0 -4
- package/tests/pages/issues/issue-gh-812.html +4 -2
- package/tests/pages/meta_schema.json +14 -1
- package/tests/pages/object-required-properties.html +37 -14
- package/tests/pages/object-show-opt-in.html +110 -0
- package/tests/pages/object-with-dependencies-array.html +29 -19
- package/tests/pages/range.html +60 -0
- package/tests/pages/ready.html +43 -0
- package/tests/pages/references.html +162 -0
- package/tests/pages/stepper-manual.html +57 -0
- package/tests/pages/string-simplemde-editor.html +81 -0
- package/tests/pages/table-move-events.html +4 -1
- package/tests/pages/urn.html +11 -8
- package/tests/pages/uuid.html +89 -50
- package/tests/pages/validation-messages.json +705 -0
- package/tests/unit/core.spec.js +79 -66
- package/tests/unit/editor.spec.js +20 -8
- package/tests/unit/editors/array.spec.js +3 -2
- package/tests/unit/editors/object.spec.js +3 -1
- package/tests/unit/editors/table.spec.js +4 -2
- package/tests/unit/schemaloader.spec.js +77 -105
- package/tests/unit/validator.spec.js +10 -0
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.
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" 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.
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" 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.
|
|
11
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" 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">
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
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
|
+
<p>
|
|
11
|
+
The form is set to send a POST request to the same page (<code>action="" method="post"</code>).
|
|
12
|
+
A change event listener has been added to the editor so that whenever the form changes, the editor value
|
|
13
|
+
is stored in a hidden input using <code>JSON.stringify()</code>.
|
|
14
|
+
</p>
|
|
15
|
+
<p>
|
|
16
|
+
When the form is submitted only the hidden input is sent in the request.
|
|
17
|
+
By doing so, it is possible to send different types of data structures like arrays and object.
|
|
18
|
+
Also the same schema that is used to build the form can be used as parameter to backend json validators tools.
|
|
19
|
+
Try yourself, submit the form and look in the network tab of the developer tool.
|
|
20
|
+
</p>
|
|
21
|
+
<div class="form-group"></div>
|
|
22
|
+
<form action="" method="post">
|
|
23
|
+
<input id="input" type="hidden" name="json">
|
|
24
|
+
<div id='editor-container'></div>
|
|
25
|
+
<input id="submit" class="btn btn-primary" width="100" type="submit">
|
|
26
|
+
</form>
|
|
27
|
+
</div>
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
|
|
29
|
+
<script>
|
|
30
|
+
var config = {
|
|
31
|
+
theme: 'bootstrap4',
|
|
32
|
+
disable_edit_json: true,
|
|
33
|
+
disable_properties: true,
|
|
34
|
+
disable_collapse: true,
|
|
35
|
+
startval: {
|
|
36
|
+
name: 'Peter Griffin',
|
|
37
|
+
pets: [
|
|
38
|
+
{ name: 'Kitty' },
|
|
39
|
+
{ name: 'Brian' }
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
schema: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
title: 'Person',
|
|
45
|
+
properties: {
|
|
46
|
+
name: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
title: 'Name'
|
|
49
|
+
},
|
|
50
|
+
pets: {
|
|
51
|
+
type: 'array',
|
|
52
|
+
title: 'Pets',
|
|
53
|
+
format: 'tabs',
|
|
54
|
+
items: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
title: 'pet',
|
|
57
|
+
properties: {
|
|
58
|
+
name: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
title: 'Name'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var editor = new JSONEditor(document.querySelector('#editor-container'), config)
|
|
70
|
+
|
|
71
|
+
editor.on('change', function () {
|
|
72
|
+
document.querySelector('#input').value = JSON.stringify(editor.getValue())
|
|
73
|
+
})
|
|
74
|
+
</script>
|
|
75
|
+
</body>
|
|
76
|
+
</html>
|
package/docs/index.html
CHANGED
|
@@ -364,7 +364,7 @@
|
|
|
364
364
|
},
|
|
365
365
|
sceditor: {
|
|
366
366
|
js: [
|
|
367
|
-
'https://cdn.jsdelivr.net/npm/jquery@3.
|
|
367
|
+
'https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js',
|
|
368
368
|
'https://cdn.jsdelivr.net/npm/sceditor@2.1.3/minified/sceditor.min.js',
|
|
369
369
|
'https://cdn.jsdelivr.net/npm/sceditor@2.1.3/minified/formats/bbcode.js',
|
|
370
370
|
'https://cdn.jsdelivr.net/npm/sceditor@2.1.3/minified/formats/xhtml.js'
|
|
@@ -383,7 +383,7 @@
|
|
|
383
383
|
},
|
|
384
384
|
select2: {
|
|
385
385
|
js: [
|
|
386
|
-
'https://cdn.jsdelivr.net/npm/jquery@3.
|
|
386
|
+
'https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js',
|
|
387
387
|
'https://cdn.jsdelivr.net/npm/select2@4.0.6-rc.1/dist/js/select2.min.js'
|
|
388
388
|
],
|
|
389
389
|
css: [
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
</div>
|
|
76
76
|
</div>
|
|
77
77
|
|
|
78
|
-
<script type="text/javascript" src="https://code.jquery.com/jquery-3.
|
|
78
|
+
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.0.min.js"></script>
|
|
79
79
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
|
80
80
|
|
|
81
81
|
<script>
|
package/docs/meta_schema.json
CHANGED
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.
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" 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/select2.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<title>JSON Editor Select2 Integration Example</title>
|
|
6
6
|
<!-- jQuery -->
|
|
7
|
-
<script src="https://cdn.jsdelivr.net/npm/jquery@3.
|
|
7
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
|
|
8
8
|
|
|
9
9
|
<script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
|
|
10
10
|
|
package/docs/selectize.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<title>JSON Editor Selectize Integration Example</title>
|
|
6
6
|
<!-- jQuery -->
|
|
7
|
-
<script src="https://cdn.jsdelivr.net/npm/jquery@3.
|
|
7
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
|
|
8
8
|
|
|
9
9
|
<script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
|
|
10
10
|
|
package/docs/starrating.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.
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" 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/wysiwyg.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<title>JSON Editor WYSIWYG Example</title>
|
|
6
6
|
<!-- jQuery -->
|
|
7
|
-
<script src="https://cdn.jsdelivr.net/npm/jquery@3.
|
|
7
|
+
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
|
|
8
8
|
|
|
9
9
|
<script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@json-editor/json-editor",
|
|
3
3
|
"title": "JSONEditor",
|
|
4
4
|
"description": "JSON Schema based editor",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.7.0",
|
|
6
6
|
"main": "dist/jsoneditor.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Jeremy Dorn",
|
|
@@ -53,48 +53,50 @@
|
|
|
53
53
|
"node": ">= 0.8.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/core": "^7.
|
|
57
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
58
|
-
"@babel/preset-env": "^7.
|
|
59
|
-
"@babel/runtime": "^7.
|
|
60
|
-
"ace-builds": "^1.4.
|
|
61
|
-
"babel-loader": "^8.
|
|
56
|
+
"@babel/core": "^7.14.0",
|
|
57
|
+
"@babel/plugin-transform-runtime": "^7.13.15",
|
|
58
|
+
"@babel/preset-env": "^7.14.1",
|
|
59
|
+
"@babel/runtime": "^7.14.0",
|
|
60
|
+
"ace-builds": "^1.4.12",
|
|
61
|
+
"babel-loader": "^8.2.2",
|
|
62
62
|
"clean-webpack-plugin": "^3.0.0",
|
|
63
|
-
"cleave.js": "^1.
|
|
64
|
-
"codeceptjs": "^2.6.
|
|
65
|
-
"css-loader": "^3.
|
|
63
|
+
"cleave.js": "^1.6.0",
|
|
64
|
+
"codeceptjs": "^2.6.11",
|
|
65
|
+
"css-loader": "^3.6.0",
|
|
66
66
|
"css2json": "^1.1.1",
|
|
67
|
-
"cssnano": "^4.1.
|
|
67
|
+
"cssnano": "^4.1.11",
|
|
68
68
|
"eslint": "^6.8.0",
|
|
69
69
|
"eslint-loader": "^2.2.1",
|
|
70
|
+
"fast-deep-equal": "^3.1.3",
|
|
70
71
|
"http-server": "^0.12.3",
|
|
71
|
-
"jasmine": "^3.
|
|
72
|
-
"jasmine-core": "^3.
|
|
73
|
-
"jodit": "^3.
|
|
74
|
-
"jquery": "^3.
|
|
75
|
-
"karma": "^
|
|
72
|
+
"jasmine": "^3.7.0",
|
|
73
|
+
"jasmine-core": "^3.7.1",
|
|
74
|
+
"jodit": "^3.12.4",
|
|
75
|
+
"jquery": "^3.6.0",
|
|
76
|
+
"karma": "^6.3.14",
|
|
76
77
|
"karma-chrome-launcher": "^3.1.0",
|
|
77
78
|
"karma-jasmine": "^2.0.1",
|
|
78
|
-
"karma-jasmine-html-reporter": "^1.
|
|
79
|
-
"karma-sourcemap-loader": "^0.3.
|
|
79
|
+
"karma-jasmine-html-reporter": "^1.6.0",
|
|
80
|
+
"karma-sourcemap-loader": "^0.3.8",
|
|
80
81
|
"karma-webpack": "^4.0.2",
|
|
81
|
-
"mathjs": "^
|
|
82
|
+
"mathjs": "^7.5.1",
|
|
82
83
|
"mini-css-extract-plugin": "^0.8.2",
|
|
83
84
|
"mocha": "^6.2.2",
|
|
84
85
|
"mochawesome": "^4.1.0",
|
|
85
|
-
"postcss-loader": "^
|
|
86
|
+
"postcss-loader": "^5.2.0",
|
|
86
87
|
"puppeteer": "^1.20.0",
|
|
87
88
|
"remove-strict-webpack-plugin": "^0.1.2",
|
|
88
89
|
"sceditor": "^2.1.3",
|
|
90
|
+
"simplemde": "^1.11.2",
|
|
89
91
|
"sinon": "^8.1.1",
|
|
90
|
-
"standard": "^14.3.
|
|
91
|
-
"style-loader": "^1.
|
|
92
|
-
"webpack": "^4.
|
|
93
|
-
"webpack-cli": "^3.3.
|
|
94
|
-
"webpack-dev-server": "^3.11.
|
|
92
|
+
"standard": "^14.3.4",
|
|
93
|
+
"style-loader": "^1.3.0",
|
|
94
|
+
"webpack": "^4.46.0",
|
|
95
|
+
"webpack-cli": "^3.3.12",
|
|
96
|
+
"webpack-dev-server": "^3.11.2",
|
|
95
97
|
"webpack-merge": "^4.2.2"
|
|
96
98
|
},
|
|
97
99
|
"dependencies": {
|
|
98
|
-
"core-js": "^3.
|
|
100
|
+
"core-js": "^3.12.1"
|
|
99
101
|
}
|
|
100
102
|
}
|
package/release-notes.md
CHANGED
|
@@ -79,10 +79,12 @@ For now I have passed in `JSONEditor.defaults` as `defaults`.
|
|
|
79
79
|
|
|
80
80
|
### NPM Release
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
Set/export `CHROME_BIN=/path/to/chrome_or_chromium`, start stack with `docker-compose up`
|
|
83
|
+
|
|
84
|
+
1. Update `CHANGELOG.md`
|
|
85
|
+
2. Switch to `release` branch and `merge master into release`
|
|
84
86
|
3. NPM login: `npm login`
|
|
85
|
-
4. Build new version: `npm version
|
|
87
|
+
4. Build new version: `npm version 2.x.x`
|
|
86
88
|
|
|
87
89
|
The `npm version` command will automatically build the source files & test the new generated script files.
|
|
88
90
|
On success the `postversion` script will push the source to GitHub and publish the version on NPM.
|
package/src/core.js
CHANGED
|
@@ -31,6 +31,8 @@ export class JSONEditor {
|
|
|
31
31
|
/* Load editors and selected theme style rules */
|
|
32
32
|
if (!themeClass) throw new Error(`Unknown theme ${themeName}`)
|
|
33
33
|
this.element.setAttribute('data-theme', themeName)
|
|
34
|
+
this.element.classList.add('je-not-loaded')
|
|
35
|
+
this.element.classList.remove('je-ready')
|
|
34
36
|
// eslint-disable-next-line new-cap
|
|
35
37
|
this.theme = new themeClass(this)
|
|
36
38
|
const rules = extend(styleRules, this.getEditorsRules())
|
|
@@ -56,67 +58,64 @@ export class JSONEditor {
|
|
|
56
58
|
|
|
57
59
|
this.root_container = this.theme.getContainer()
|
|
58
60
|
this.element.appendChild(this.root_container)
|
|
61
|
+
this.promise = this.load()
|
|
62
|
+
}
|
|
59
63
|
|
|
60
|
-
|
|
64
|
+
async load () {
|
|
61
65
|
const fetchUrl = document.location.origin + document.location.pathname.toString()
|
|
62
66
|
const loader = new SchemaLoader(this.options)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.expandSchema = (schema, fileBase) => loader.expandSchema(schema, fileBase)
|
|
67
|
+
this.expandSchema = (schema) => loader.expandSchema(schema)
|
|
66
68
|
this.expandRefs = (schema, fileBase) => loader.expandRefs(schema, fileBase)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const location = document.location.toString()
|
|
70
|
+
const schema = await loader.load(this.schema, fetchUrl, location)
|
|
71
|
+
const validatorOptions = this.options.custom_validators ? { custom_validators: this.options.custom_validators } : {}
|
|
72
|
+
this.validator = new Validator(this, null, validatorOptions, JSONEditor.defaults)
|
|
73
|
+
const editorClass = this.getEditorClass(schema)
|
|
74
|
+
this.root = this.createEditor(editorClass, {
|
|
75
|
+
jsoneditor: this,
|
|
76
|
+
schema,
|
|
77
|
+
required: true,
|
|
78
|
+
container: this.root_container
|
|
79
|
+
})
|
|
75
80
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
required: true,
|
|
80
|
-
container: this.root_container
|
|
81
|
-
})
|
|
81
|
+
this.root.preBuild()
|
|
82
|
+
this.root.build()
|
|
83
|
+
this.root.postBuild()
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.root.postBuild()
|
|
85
|
+
/* Starting data */
|
|
86
|
+
if (hasOwnProperty(this.options, 'startval')) this.root.setValue(this.options.startval)
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
this.validation_results = this.validator.validate(this.root.getValue())
|
|
89
|
+
this.root.showValidationErrors(this.validation_results)
|
|
90
|
+
this.ready = true
|
|
91
|
+
this.element.classList.remove('je-not-loaded')
|
|
92
|
+
this.element.classList.add('je-ready')
|
|
89
93
|
|
|
94
|
+
/* Fire ready event asynchronously */
|
|
95
|
+
window.requestAnimationFrame(() => {
|
|
96
|
+
if (!this.ready) return
|
|
90
97
|
this.validation_results = this.validator.validate(this.root.getValue())
|
|
91
98
|
this.root.showValidationErrors(this.validation_results)
|
|
92
|
-
this.ready
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
window.requestAnimationFrame(() => {
|
|
96
|
-
if (!this.ready) return
|
|
97
|
-
this.validation_results = this.validator.validate(this.root.getValue())
|
|
98
|
-
this.root.showValidationErrors(this.validation_results)
|
|
99
|
-
this.trigger('ready')
|
|
100
|
-
this.trigger('change')
|
|
101
|
-
})
|
|
102
|
-
}, fetchUrl, location)
|
|
99
|
+
this.trigger('ready')
|
|
100
|
+
this.trigger('change')
|
|
101
|
+
})
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
getValue () {
|
|
106
|
-
if (!this.ready) throw new Error(
|
|
105
|
+
if (!this.ready) throw new Error('JSON Editor not ready yet. Make sure the load method is complete')
|
|
107
106
|
|
|
108
107
|
return this.root.getValue()
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
setValue (value) {
|
|
112
|
-
if (!this.ready) throw new Error(
|
|
111
|
+
if (!this.ready) throw new Error('JSON Editor not ready yet. Make sure the load method is complete')
|
|
113
112
|
|
|
114
113
|
this.root.setValue(value)
|
|
115
114
|
return this
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
validate (value) {
|
|
119
|
-
if (!this.ready) throw new Error(
|
|
118
|
+
if (!this.ready) throw new Error('JSON Editor not ready yet. Make sure the load method is complete')
|
|
120
119
|
|
|
121
120
|
/* Custom value */
|
|
122
121
|
if (arguments.length === 1) {
|
package/src/defaults.js
CHANGED
|
@@ -350,11 +350,18 @@ function upload (type, file, cbs) {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
/* String translate function */
|
|
353
|
-
function translate (key, variables) {
|
|
353
|
+
function translate (key, variables, schema) {
|
|
354
|
+
let schemaMessages = {}
|
|
355
|
+
|
|
356
|
+
if (schema && schema.options && schema.options.error_messages && schema.options.error_messages[defaults.language]) {
|
|
357
|
+
schemaMessages = schema.options.error_messages[defaults.language]
|
|
358
|
+
}
|
|
359
|
+
|
|
354
360
|
const lang = defaults.languages[defaults.language]
|
|
361
|
+
|
|
355
362
|
if (!lang) throw new Error(`Unknown language ${defaults.language}`)
|
|
356
363
|
|
|
357
|
-
let string = lang[key] || defaults.languages[default_language][key] || key
|
|
364
|
+
let string = schemaMessages[key] || lang[key] || defaults.languages[default_language][key] || key
|
|
358
365
|
|
|
359
366
|
if (variables) {
|
|
360
367
|
for (let i = 0; i < variables.length; i++) {
|
package/src/editor.js
CHANGED
|
@@ -153,7 +153,7 @@ export class AbstractEditor {
|
|
|
153
153
|
this.dependenciesFulfilled = false
|
|
154
154
|
} else if (Array.isArray(choices)) {
|
|
155
155
|
this.dependenciesFulfilled = choices.some(choice => {
|
|
156
|
-
if (value === choice) {
|
|
156
|
+
if (JSON.stringify(value) === JSON.stringify(choice)) {
|
|
157
157
|
return true
|
|
158
158
|
}
|
|
159
159
|
})
|
|
@@ -206,7 +206,11 @@ export class AbstractEditor {
|
|
|
206
206
|
})
|
|
207
207
|
|
|
208
208
|
/* append active/deactive checkbox if show_opt_in is true */
|
|
209
|
-
|
|
209
|
+
const globalOptIn = this.jsoneditor.options.show_opt_in
|
|
210
|
+
const parentOptInDefined = (typeof this.parent.options.show_opt_in !== 'undefined')
|
|
211
|
+
const parentOptInEnabled = (parentOptInDefined && this.parent.options.show_opt_in === true)
|
|
212
|
+
const parentOptInDisabled = (parentOptInDefined && this.parent.options.show_opt_in === false)
|
|
213
|
+
if (parentOptInEnabled || (!parentOptInDisabled && globalOptIn) || (!parentOptInDefined && globalOptIn)) {
|
|
210
214
|
/* and control to type object editors if they are not required */
|
|
211
215
|
if (this.parent && this.parent.schema.type === 'object' && !this.isRequired() && this.header) {
|
|
212
216
|
this.header.appendChild(this.optInCheckbox)
|
package/src/editors/array.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractEditor } from '../editor.js'
|
|
2
|
-
import { extend, trigger } from '../utilities.js'
|
|
2
|
+
import { extend, generateUUID, trigger } from '../utilities.js'
|
|
3
3
|
import rules from './array.css.js'
|
|
4
4
|
|
|
5
5
|
export class ArrayEditor extends AbstractEditor {
|
|
@@ -545,6 +545,7 @@ export class ArrayEditor extends AbstractEditor {
|
|
|
545
545
|
|
|
546
546
|
_createCopyButton (i, holder) {
|
|
547
547
|
const button = this.getButton(this.getItemTitle(), 'copy', 'button_copy_row_title', [this.getItemTitle()])
|
|
548
|
+
const schema = this.schema
|
|
548
549
|
button.classList.add('copy', 'json-editor-btntype-copy')
|
|
549
550
|
button.setAttribute('data-i', i)
|
|
550
551
|
button.addEventListener('click', e => {
|
|
@@ -555,6 +556,16 @@ export class ArrayEditor extends AbstractEditor {
|
|
|
555
556
|
|
|
556
557
|
value.forEach((row, j) => {
|
|
557
558
|
if (j === i) {
|
|
559
|
+
/* Force generation of new UUID if the item has been cloned. */
|
|
560
|
+
if (schema.items.type === 'string' && schema.items.format === 'uuid') {
|
|
561
|
+
row = generateUUID()
|
|
562
|
+
} else if (schema.items.type === 'object' && schema.items.properties) {
|
|
563
|
+
for (const key of Object.keys(row)) {
|
|
564
|
+
if (schema.items.properties && schema.items.properties[key] && schema.items.properties[key].format === 'uuid') {
|
|
565
|
+
row[key] = generateUUID()
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
558
569
|
value.push(row)
|
|
559
570
|
}
|
|
560
571
|
})
|
|
@@ -29,18 +29,19 @@ export class AutocompleteEditor extends StringEditor {
|
|
|
29
29
|
/* Get options, either global options from "this.defaults.options.autocomplete" or */
|
|
30
30
|
/* single property options from schema "options.autocomplete" */
|
|
31
31
|
options = this.expandCallbacks('autocomplete', extend({}, {
|
|
32
|
-
search: (jseditor
|
|
32
|
+
search: (jseditor) => {
|
|
33
33
|
// eslint-disable-next-line no-console
|
|
34
34
|
console.log(`No "search" callback defined for autocomplete in property "${jseditor.key}"`)
|
|
35
35
|
return []
|
|
36
36
|
},
|
|
37
|
+
onSubmit: () => {
|
|
38
|
+
this.input.blur()
|
|
39
|
+
},
|
|
37
40
|
baseClass: 'autocomplete'
|
|
38
41
|
}, this.defaults.options.autocomplete || {}, this.options.autocomplete || {}))
|
|
39
42
|
|
|
40
43
|
this.autocomplete_wrapper.classList.add(options.baseClass)
|
|
41
44
|
this.autocomplete_dropdown.classList.add(`${options.baseClass}-result-list`)
|
|
42
|
-
/* this.input.classList.add(options.baseClass + '-input'); */
|
|
43
|
-
|
|
44
45
|
this.autocomplete_instance = new window.Autocomplete(this.autocomplete_wrapper, options)
|
|
45
46
|
}
|
|
46
47
|
super.afterInputReady()
|
package/src/editors/button.js
CHANGED
|
@@ -34,7 +34,7 @@ export class ButtonEditor extends AbstractEditor {
|
|
|
34
34
|
}
|
|
35
35
|
}, this.defaults.options.button || {}, this.options.button || {}))
|
|
36
36
|
|
|
37
|
-
this.input = this.
|
|
37
|
+
this.input = this.getButton(title, options.icon, title)
|
|
38
38
|
this.input.addEventListener('click', options.action, false)
|
|
39
39
|
|
|
40
40
|
if (this.schema.readOnly || this.schema.readonly || this.schema.template) {
|
package/src/editors/multiple.js
CHANGED
|
@@ -31,19 +31,24 @@ export class MultiSelectEditor extends AbstractEditor {
|
|
|
31
31
|
this.select_options = {}
|
|
32
32
|
this.select_values = {}
|
|
33
33
|
this.option_keys = []
|
|
34
|
-
this.
|
|
34
|
+
this.option_enum = []
|
|
35
35
|
|
|
36
36
|
let i
|
|
37
37
|
const itemsSchema = this.jsoneditor.expandRefs(this.schema.items || {})
|
|
38
38
|
const e = itemsSchema.enum || []
|
|
39
|
+
const oe = itemsSchema.options ? itemsSchema.options.enum || [] : []
|
|
40
|
+
/* fallback to enum_titles, when options.enum is not present */
|
|
39
41
|
const t = itemsSchema.options ? itemsSchema.options.enum_titles || [] : []
|
|
40
42
|
|
|
41
43
|
for (i = 0; i < e.length; i++) {
|
|
42
44
|
/* If the sanitized value is different from the enum value, don't include it */
|
|
43
45
|
if (this.sanitize(e[i]) !== e[i]) continue
|
|
44
46
|
|
|
47
|
+
const d = oe[i] || {}
|
|
48
|
+
if (!('title' in d)) d.title = `${t[i] || e[i]}`
|
|
49
|
+
|
|
45
50
|
this.option_keys.push(`${e[i]}`)
|
|
46
|
-
this.
|
|
51
|
+
this.option_enum.push(d)
|
|
47
52
|
this.select_values[`${e[i]}`] = e[i]
|
|
48
53
|
}
|
|
49
54
|
}
|
|
@@ -65,9 +70,13 @@ export class MultiSelectEditor extends AbstractEditor {
|
|
|
65
70
|
this.inputs[this.option_keys[i]] = this.theme.getCheckbox()
|
|
66
71
|
this.inputs[this.option_keys[i]].id = id
|
|
67
72
|
this.select_options[this.option_keys[i]] = this.inputs[this.option_keys[i]]
|
|
68
|
-
const label = this.theme.getCheckboxLabel(this.
|
|
73
|
+
const label = this.theme.getCheckboxLabel(this.option_enum[i].title)
|
|
69
74
|
label.htmlFor = id
|
|
70
|
-
|
|
75
|
+
if (this.option_enum[i].infoText) {
|
|
76
|
+
const infoButton = this.theme.getInfoButton(this.translateProperty(this.option_enum[i].infoText))
|
|
77
|
+
label.appendChild(infoButton)
|
|
78
|
+
}
|
|
79
|
+
this.controls['_' + this.option_keys[i]] = this.theme.getFormControl(label, this.inputs[this.option_keys[i]])
|
|
71
80
|
}
|
|
72
81
|
|
|
73
82
|
this.control = this.theme.getMultiCheckboxHolder(this.controls, this.label, this.description, this.infoButton)
|
|
@@ -75,7 +84,7 @@ export class MultiSelectEditor extends AbstractEditor {
|
|
|
75
84
|
} else {
|
|
76
85
|
this.input_type = 'select'
|
|
77
86
|
this.input = this.theme.getSelectInput(this.option_keys, true)
|
|
78
|
-
this.theme.setSelectOptions(this.input, this.option_keys, this.
|
|
87
|
+
this.theme.setSelectOptions(this.input, this.option_keys, this.option_enum.map(e => e.title))
|
|
79
88
|
/* this.input.multiple = true; */
|
|
80
89
|
this.input.setAttribute('multiple', 'multiple')
|
|
81
90
|
this.input.size = Math.min(10, this.option_keys.length)
|
package/src/editors/object.js
CHANGED
|
@@ -637,7 +637,7 @@ export class ObjectEditor extends AbstractEditor {
|
|
|
637
637
|
this.addproperty_holder.appendChild(spacer)
|
|
638
638
|
|
|
639
639
|
/* Close properties modal if clicked outside modal */
|
|
640
|
-
document.addEventListener('click', this.onOutsideModalClick)
|
|
640
|
+
document.addEventListener('click', this.onOutsideModalClick.bind(this))
|
|
641
641
|
|
|
642
642
|
/* Description */
|
|
643
643
|
if (this.schema.description) {
|
|
@@ -793,7 +793,11 @@ export class ObjectEditor extends AbstractEditor {
|
|
|
793
793
|
|
|
794
794
|
deactivateNonRequiredProperties () {
|
|
795
795
|
/* the show_opt_in editor option is for backward compatibility */
|
|
796
|
-
|
|
796
|
+
const globalOptIn = this.jsoneditor.options.show_opt_in
|
|
797
|
+
const editorOptInDefined = (typeof this.options.show_opt_in !== 'undefined')
|
|
798
|
+
const editorOptInEnabled = (editorOptInDefined && this.options.show_opt_in === true)
|
|
799
|
+
const editorOptInDisabled = (editorOptInDefined && this.options.show_opt_in === false)
|
|
800
|
+
if (editorOptInEnabled || (!editorOptInDisabled && globalOptIn) || (!editorOptInDefined && globalOptIn)) {
|
|
797
801
|
Object.entries(this.editors).forEach(([key, editor]) => {
|
|
798
802
|
if (!this.isRequiredObject(editor)) {
|
|
799
803
|
this.editors[key].deactivate()
|
|
@@ -993,7 +997,8 @@ export class ObjectEditor extends AbstractEditor {
|
|
|
993
997
|
this.editors[name].register()
|
|
994
998
|
/* New property */
|
|
995
999
|
} else {
|
|
996
|
-
if (!this.canHaveAdditionalProperties() && (!this.schema.properties || !this.schema.properties[name])
|
|
1000
|
+
if (!this.canHaveAdditionalProperties() && (!this.schema.properties || !this.schema.properties[name]) &&
|
|
1001
|
+
(!this.schema.patternProperties || !(Object.keys(this.schema.patternProperties).find(i => new RegExp(i).test(name))))) {
|
|
997
1002
|
return
|
|
998
1003
|
}
|
|
999
1004
|
|
|
@@ -1037,9 +1042,8 @@ export class ObjectEditor extends AbstractEditor {
|
|
|
1037
1042
|
}
|
|
1038
1043
|
|
|
1039
1044
|
onOutsideModalClick (e) {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
this.adding_property) {
|
|
1045
|
+
const path = e.path || (e.composedPath && e.composedPath())
|
|
1046
|
+
if (this.addproperty_holder && !this.addproperty_holder.contains(path[0]) && this.adding_property) {
|
|
1043
1047
|
e.preventDefault()
|
|
1044
1048
|
e.stopPropagation()
|
|
1045
1049
|
this.toggleAddProperty()
|