@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
|
@@ -9,28 +9,38 @@
|
|
|
9
9
|
<div id="editor"></div>
|
|
10
10
|
<script>
|
|
11
11
|
const schema = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"enum": [
|
|
20
|
-
"A",
|
|
21
|
-
"B",
|
|
22
|
-
"C"
|
|
23
|
-
]
|
|
12
|
+
'title': 'Test',
|
|
13
|
+
'type': 'object',
|
|
14
|
+
'properties': {
|
|
15
|
+
'question_1': {
|
|
16
|
+
'type': 'string',
|
|
17
|
+
'title': 'Question 1',
|
|
18
|
+
'enum': ['a', 'b', 'c', 'd']
|
|
24
19
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
'question_1_feedback': {
|
|
21
|
+
'type': 'info',
|
|
22
|
+
'title': 'Question 1 is correct',
|
|
28
23
|
"options": {
|
|
29
24
|
"dependencies": {
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
"question_1": ['b', 'd']
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
'question_2': {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"uniqueItems": true,
|
|
32
|
+
'title': 'Question 2',
|
|
33
|
+
"items": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
'enum': ['a', 'b', 'c', 'd']
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
'question_2_feedback': {
|
|
39
|
+
'type': 'info',
|
|
40
|
+
'title': 'Question 2 is correct',
|
|
41
|
+
"options": {
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"question_2": [['b', 'c']]
|
|
34
44
|
}
|
|
35
45
|
}
|
|
36
46
|
}
|
|
@@ -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>
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>References JSON Editor Example</title>
|
|
6
|
+
|
|
7
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<h1>References JSON Editor Example</h1>
|
|
11
|
+
|
|
12
|
+
<p>This example demonstrates the following:</p>
|
|
13
|
+
<ul>
|
|
14
|
+
<li>Loading external schemas via ajax</li>
|
|
15
|
+
<li>Referencing internal schema definitions</li>
|
|
16
|
+
<li>Referencing external schema definitions</li>
|
|
17
|
+
<li>Referencing external schema properties</li>
|
|
18
|
+
</ul>
|
|
19
|
+
|
|
20
|
+
<button id='submit'>Submit (console.log)</button>
|
|
21
|
+
<button id='restore'>Restore to Default</button>
|
|
22
|
+
<button id='enable_disable'>Disable/Enable Form</button>
|
|
23
|
+
<span id='valid_indicator'></span>
|
|
24
|
+
|
|
25
|
+
<div id='editor_holder'></div>
|
|
26
|
+
|
|
27
|
+
<script>
|
|
28
|
+
// This is the starting value for the editor
|
|
29
|
+
// We will use this to seed the initial editor
|
|
30
|
+
// and to provide a "Restore to Default" button.
|
|
31
|
+
var starting_value = [
|
|
32
|
+
{
|
|
33
|
+
name: "John Smith",
|
|
34
|
+
age: 35,
|
|
35
|
+
gender: "male",
|
|
36
|
+
location: {
|
|
37
|
+
city: "San Francisco",
|
|
38
|
+
state: "California",
|
|
39
|
+
citystate: ""
|
|
40
|
+
},
|
|
41
|
+
pets: [
|
|
42
|
+
{
|
|
43
|
+
name: "Spot",
|
|
44
|
+
type: "dog",
|
|
45
|
+
fixed: true
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "Whiskers",
|
|
49
|
+
type: "cat",
|
|
50
|
+
fixed: false
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
// Initialize the editor
|
|
57
|
+
var editor = new JSONEditor(document.getElementById('editor_holder'),{
|
|
58
|
+
// Enable fetching schemas via ajax
|
|
59
|
+
ajax: true,
|
|
60
|
+
|
|
61
|
+
// The schema for the editor
|
|
62
|
+
schema: {
|
|
63
|
+
$schema: "https://json-schema.org/draft-04/schema",
|
|
64
|
+
title: "Example Organization",
|
|
65
|
+
type: "object",
|
|
66
|
+
definitions: {
|
|
67
|
+
taxid: {
|
|
68
|
+
type: "string",
|
|
69
|
+
title: "Tax ID"
|
|
70
|
+
},
|
|
71
|
+
external: {
|
|
72
|
+
$ref: "../fixtures/string.json"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
properties: {
|
|
76
|
+
external: {
|
|
77
|
+
$ref: "#/definitions/external"
|
|
78
|
+
},
|
|
79
|
+
orgid: { $ref: "#/definitions/taxid" },
|
|
80
|
+
address: {
|
|
81
|
+
$ref: "../fixtures/definitions.json#/definitions/address"
|
|
82
|
+
},
|
|
83
|
+
people: {
|
|
84
|
+
type: "array",
|
|
85
|
+
title: "People",
|
|
86
|
+
format: "tabs",
|
|
87
|
+
items: {
|
|
88
|
+
title: "Person",
|
|
89
|
+
headerTemplate: "{{i}} - {{self.name}}",
|
|
90
|
+
oneOf: [
|
|
91
|
+
{
|
|
92
|
+
$ref: "../fixtures/basic_person.json",
|
|
93
|
+
title: "Basic Person"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
$ref: "../fixtures/person.json",
|
|
97
|
+
title: "Complex Person"
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
link: {
|
|
103
|
+
$ref: '../fixtures/definitions.json#/properties/address'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
// Seed the form with a starting value
|
|
109
|
+
startval: starting_value,
|
|
110
|
+
|
|
111
|
+
// Disable additional properties
|
|
112
|
+
no_additional_properties: true,
|
|
113
|
+
|
|
114
|
+
// Require all properties by default
|
|
115
|
+
required_by_default: true
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Hook up the submit button to log to the console
|
|
119
|
+
document.getElementById('submit').addEventListener('click',function() {
|
|
120
|
+
// Get the value from the editor
|
|
121
|
+
console.log(editor.getValue());
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Hook up the Restore to Default button
|
|
125
|
+
document.getElementById('restore').addEventListener('click',function() {
|
|
126
|
+
editor.setValue(starting_value);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Hook up the enable/disable button
|
|
130
|
+
document.getElementById('enable_disable').addEventListener('click',function() {
|
|
131
|
+
// Enable form
|
|
132
|
+
if(!editor.isEnabled()) {
|
|
133
|
+
editor.enable();
|
|
134
|
+
}
|
|
135
|
+
// Disable form
|
|
136
|
+
else {
|
|
137
|
+
editor.disable();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Hook up the validation indicator to update its
|
|
142
|
+
// status whenever the editor changes
|
|
143
|
+
editor.on('change',function() {
|
|
144
|
+
// Get an array of errors from the validator
|
|
145
|
+
var errors = editor.validate();
|
|
146
|
+
|
|
147
|
+
var indicator = document.getElementById('valid_indicator');
|
|
148
|
+
|
|
149
|
+
// Not valid
|
|
150
|
+
if(errors.length) {
|
|
151
|
+
indicator.style.color = 'red';
|
|
152
|
+
indicator.textContent = "not valid";
|
|
153
|
+
}
|
|
154
|
+
// Valid
|
|
155
|
+
else {
|
|
156
|
+
indicator.style.color = 'green';
|
|
157
|
+
indicator.textContent = "valid";
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
</script>
|
|
161
|
+
</body>
|
|
162
|
+
</html>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<title>Stepper</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
|
+
"type": "object",
|
|
27
|
+
"title": "range",
|
|
28
|
+
"properties": {
|
|
29
|
+
"stepper": {
|
|
30
|
+
'type': 'integer',
|
|
31
|
+
'format': 'stepper',
|
|
32
|
+
"default": ""
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var editor = new JSONEditor(jsonEditorContainer, {
|
|
38
|
+
schema: schema,
|
|
39
|
+
theme: 'bootstrap4',
|
|
40
|
+
use_default_values: false,
|
|
41
|
+
required_by_default: true,
|
|
42
|
+
show_errors: 'always'
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
document.querySelector('.get-value').addEventListener('click', function () {
|
|
46
|
+
value.value = JSON.stringify(editor.getValue());
|
|
47
|
+
console.log(editor.getValue());
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
document.querySelector('.set-value').addEventListener('click', function () {
|
|
51
|
+
editor.setValue({number_range: 2})
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>string-simple-mde-editor</title>
|
|
6
|
+
|
|
7
|
+
<!-- json editor -->
|
|
8
|
+
<script src="../../dist/jsoneditor.js"></script>
|
|
9
|
+
|
|
10
|
+
<!-- simpleMDE-editor -->
|
|
11
|
+
<script src="./../../node_modules/simplemde/dist/simplemde.min.js"></script>
|
|
12
|
+
<link
|
|
13
|
+
rel="stylesheet"
|
|
14
|
+
href="./../../node_modules/simplemde/dist/simplemde.min.css"
|
|
15
|
+
/>
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<textarea class="debug" cols="30" rows="10"></textarea>
|
|
19
|
+
<button class="get-value">Get Value</button>
|
|
20
|
+
<div class="container"></div>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
const container = document.querySelector(".container");
|
|
24
|
+
const debug = document.querySelector(".debug");
|
|
25
|
+
|
|
26
|
+
const schema = {
|
|
27
|
+
type: "array",
|
|
28
|
+
title: "string-simplemde-editor",
|
|
29
|
+
items: {
|
|
30
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
31
|
+
title: "Example",
|
|
32
|
+
type: "object",
|
|
33
|
+
format: "categories",
|
|
34
|
+
basicCategoryTitle: "Main Editor",
|
|
35
|
+
required: ["title"],
|
|
36
|
+
properties: {
|
|
37
|
+
title: {
|
|
38
|
+
type: "string",
|
|
39
|
+
format: "markdown",
|
|
40
|
+
default: "Lorem",
|
|
41
|
+
options: {
|
|
42
|
+
simplemde: {
|
|
43
|
+
spellChecker: false,
|
|
44
|
+
autorefresh: true,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
content: {
|
|
49
|
+
type: "object",
|
|
50
|
+
title: "Tabbed Editor",
|
|
51
|
+
properties: {
|
|
52
|
+
description: {
|
|
53
|
+
title: "Test",
|
|
54
|
+
type: "string",
|
|
55
|
+
format: "markdown",
|
|
56
|
+
default: "Lorem ipsum.",
|
|
57
|
+
options: {
|
|
58
|
+
simplemde: {
|
|
59
|
+
spellChecker: false,
|
|
60
|
+
autorefresh: true,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var editor = new JSONEditor(container, {
|
|
71
|
+
schema: schema,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
document
|
|
75
|
+
.querySelector(".get-value")
|
|
76
|
+
.addEventListener("click", function () {
|
|
77
|
+
debug.value = JSON.stringify(editor.getValue());
|
|
78
|
+
});
|
|
79
|
+
</script>
|
|
80
|
+
</body>
|
|
81
|
+
</html>
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
schema: schema,
|
|
27
27
|
enable_array_copy: true
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
editor.promise.then(() => {
|
|
30
|
+
document.querySelector('.get-value').addEventListener('click', function () {
|
|
30
31
|
debug.value = JSON.stringify(editor.getValue());
|
|
31
32
|
});
|
|
32
33
|
editor.setValue(["A","B","C","D","E"]);
|
|
@@ -50,6 +51,8 @@
|
|
|
50
51
|
alert('deleteAllRows');
|
|
51
52
|
console.log('deleteAllRows');
|
|
52
53
|
});
|
|
54
|
+
})
|
|
55
|
+
|
|
53
56
|
</script>
|
|
54
57
|
|
|
55
58
|
</body>
|
package/tests/pages/urn.html
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
theme: 'bootstrap4',
|
|
29
29
|
use_default_values: false,
|
|
30
30
|
show_errors: 'always',
|
|
31
|
-
urn_resolver: (urn, callback) => {
|
|
31
|
+
urn_resolver: async (urn, callback) => {
|
|
32
32
|
console.log('resolving ' + urn)
|
|
33
33
|
let schema
|
|
34
34
|
|
|
@@ -68,13 +68,16 @@
|
|
|
68
68
|
break
|
|
69
69
|
default: return false
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
// simulate async
|
|
73
|
+
window.setTimeout(() => {
|
|
74
|
+
console.log(schema)
|
|
75
|
+
resolve(JSON.stringify(schema))
|
|
76
|
+
}, 50);
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
//return true
|
|
78
81
|
}
|
|
79
82
|
})
|
|
80
83
|
|
package/tests/pages/uuid.html
CHANGED
|
@@ -1,72 +1,111 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
+
|
|
3
4
|
<head>
|
|
4
|
-
<meta charset="utf-8"/>
|
|
5
|
+
<meta charset="utf-8" />
|
|
5
6
|
<script src="../../dist/jsoneditor.js"></script>
|
|
6
7
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
|
7
8
|
<title>object-no-duplicated-id</title>
|
|
8
9
|
</head>
|
|
10
|
+
|
|
9
11
|
<body>
|
|
10
12
|
|
|
11
|
-
<div class="container">
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
<div class="container">
|
|
14
|
+
<div class="form-group">
|
|
15
|
+
<textarea id="value" class="form-control" rows="10"></textarea>
|
|
16
|
+
</div>
|
|
17
|
+
<button id="get-value" class='btn btn-secondary'>get value</button>
|
|
18
|
+
<hr>
|
|
19
|
+
<div id='form-container'></div>
|
|
14
20
|
</div>
|
|
15
|
-
<button id="get-value" class='btn btn-secondary'>get value</button>
|
|
16
|
-
<hr>
|
|
17
|
-
<div id='form-container'></div>
|
|
18
|
-
</div>
|
|
19
21
|
|
|
20
|
-
<script>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
<script>
|
|
23
|
+
var formContainer = document.querySelector('#form-container')
|
|
24
|
+
var value = document.querySelector('#value')
|
|
25
|
+
var getValue = document.querySelector('#get-value')
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
var today = (offset) => {
|
|
28
|
+
var t = new Date()
|
|
29
|
+
t.setDate(t.getDate() + (offset || 0))
|
|
30
|
+
return t.toISOString().split('T')[0]
|
|
31
|
+
}
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
'
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
var schema = {
|
|
34
|
+
'type': 'object',
|
|
35
|
+
'properties': {
|
|
36
|
+
'uuid': {
|
|
37
|
+
'type': 'string',
|
|
38
|
+
'format': 'uuid',
|
|
39
|
+
'title': 'single uuid',
|
|
40
|
+
'required': true,
|
|
41
|
+
'default': 'banana'
|
|
42
|
+
},
|
|
43
|
+
'uuidStringArray': {
|
|
44
|
+
'type': 'array',
|
|
45
|
+
'required': true,
|
|
46
|
+
'title': 'array of uuids',
|
|
47
|
+
'items': {
|
|
48
|
+
'type': 'string',
|
|
49
|
+
'format': 'uuid',
|
|
50
|
+
'title': 'uuid string array item'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
'uuidObjectArray': {
|
|
54
|
+
'type': 'array',
|
|
55
|
+
'title': 'array of objects with uuid property',
|
|
56
|
+
'required': true,
|
|
57
|
+
'items': {
|
|
58
|
+
'title': 'uuid object array item',
|
|
59
|
+
'type': 'object',
|
|
60
|
+
'properties': {
|
|
61
|
+
'uuid': {
|
|
62
|
+
'type': 'string',
|
|
63
|
+
'format': 'uuid'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
'uuidStringTable': {
|
|
69
|
+
'type': 'array',
|
|
70
|
+
'required': true,
|
|
71
|
+
'format': 'table',
|
|
72
|
+
'title': 'array of uuids (table)',
|
|
73
|
+
'items': {
|
|
74
|
+
'title': 'uuid string table item',
|
|
75
|
+
'type': 'string',
|
|
76
|
+
'format': 'uuid'
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
'uuidObjectTable': {
|
|
80
|
+
"type": "array",
|
|
81
|
+
"format": "table",
|
|
82
|
+
"title": "Array of objects (Table) with uuid property",
|
|
83
|
+
"items": {
|
|
84
|
+
'title': 'uuid object table item',
|
|
85
|
+
"type": "object",
|
|
86
|
+
"properties": {
|
|
87
|
+
"uuid": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"format": "uuid",
|
|
90
|
+
}
|
|
51
91
|
}
|
|
52
92
|
}
|
|
53
93
|
}
|
|
54
94
|
}
|
|
55
95
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
var editor = new JSONEditor(formContainer, {
|
|
59
|
-
schema: schema,
|
|
60
|
-
theme: 'bootstrap4',
|
|
61
|
-
show_errors: 'always'
|
|
62
|
-
})
|
|
63
96
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
97
|
+
var editor = new JSONEditor(formContainer, {
|
|
98
|
+
schema: schema,
|
|
99
|
+
theme: 'bootstrap4',
|
|
100
|
+
show_errors: 'always',
|
|
101
|
+
enable_array_copy: true,
|
|
102
|
+
})
|
|
68
103
|
|
|
69
|
-
|
|
104
|
+
getValue.addEventListener('click', function () {
|
|
105
|
+
value.value = JSON.stringify(editor.getValue())
|
|
106
|
+
console.log(editor.getValue())
|
|
107
|
+
})
|
|
70
108
|
|
|
109
|
+
</script>
|
|
71
110
|
</body>
|
|
72
|
-
</html>
|
|
111
|
+
</html>
|