@json-editor/json-editor 2.15.1 → 2.15.3

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 (68) hide show
  1. package/.env +1 -1
  2. package/.github/workflows/build.yml +5 -5
  3. package/CHANGELOG.md +21 -0
  4. package/CONTRIBUTING.md +10 -0
  5. package/README.md +27 -0
  6. package/dist/jsoneditor.js +1 -1
  7. package/dist/jsoneditor.js.LICENSE.txt +1 -1
  8. package/dist/nonmin/jsoneditor.js +497 -150
  9. package/dist/nonmin/jsoneditor.js.map +1 -1
  10. package/docs/form-submission.html +1 -1
  11. package/docs/index.html +18 -0
  12. package/package.json +1 -1
  13. package/src/core.js +11 -0
  14. package/src/defaults.js +2 -1
  15. package/src/editor.js +27 -16
  16. package/src/editors/ace.js +1 -0
  17. package/src/editors/array/choices.js +1 -0
  18. package/src/editors/array/select2.js +2 -0
  19. package/src/editors/array/selectize.js +2 -0
  20. package/src/editors/array.js +81 -0
  21. package/src/editors/base64.js +2 -0
  22. package/src/editors/checkbox.js +13 -1
  23. package/src/editors/choices.js +2 -0
  24. package/src/editors/colorpicker.js +2 -0
  25. package/src/editors/datetime.js +2 -0
  26. package/src/editors/describedby.js +2 -0
  27. package/src/editors/enum.js +3 -1
  28. package/src/editors/hidden.js +2 -0
  29. package/src/editors/jodit.js +2 -0
  30. package/src/editors/multiple.js +2 -0
  31. package/src/editors/multiselect.js +2 -0
  32. package/src/editors/object.js +10 -3
  33. package/src/editors/radio.js +2 -0
  34. package/src/editors/sceditor.js +2 -0
  35. package/src/editors/select.js +2 -1
  36. package/src/editors/select2.js +2 -0
  37. package/src/editors/selectize.js +2 -0
  38. package/src/editors/signature.js +2 -0
  39. package/src/editors/simplemde.js +3 -1
  40. package/src/editors/starrating.js +2 -0
  41. package/src/editors/string.js +2 -0
  42. package/src/editors/table.js +19 -2
  43. package/src/editors/upload.js +2 -0
  44. package/src/editors/uuid.js +2 -0
  45. package/src/resolvers.js +1 -1
  46. package/src/theme.js +23 -0
  47. package/src/themes/bootstrap3.css +53 -0
  48. package/src/themes/bootstrap3.css.js +1 -1
  49. package/src/themes/bootstrap3.js +30 -0
  50. package/src/themes/bootstrap4.js +27 -0
  51. package/src/themes/bootstrap5.js +28 -0
  52. package/src/themes/spectre.js +28 -0
  53. package/src/themes/tailwind.css +54 -0
  54. package/src/themes/tailwind.css.js +1 -1
  55. package/src/themes/tailwind.js +26 -0
  56. package/tests/codeceptjs/core_test.js +28 -0
  57. package/tests/codeceptjs/editors/multiple_test.js +27 -0
  58. package/tests/codeceptjs/issues/issue-gh-1559_test.js +15 -0
  59. package/tests/codeceptjs/issues/issue-gh-1562_test.js +12 -0
  60. package/tests/codeceptjs/issues/issue-gh-1586_test.js +15 -0
  61. package/tests/pages/editor-show-validation-errors.html +54 -0
  62. package/tests/pages/enforce-const.html +10 -18
  63. package/tests/pages/issues/issue-gh-1559.html +68 -0
  64. package/tests/pages/issues/issue-gh-1562.html +170 -0
  65. package/tests/pages/issues/issue-gh-1586.html +48 -0
  66. package/tests/pages/opt-in-widget.html +134 -0
  67. package/tests/pages/switcher-option.html +69 -0
  68. package/tests/docker-compose-local.yml +0 -4
@@ -25,19 +25,16 @@
25
25
  "title": "string (StringEditor)",
26
26
  "type": "string",
27
27
  "const": "Alice",
28
- // "options": { "enforce_const": false }
29
28
  },
30
29
  "integer": {
31
30
  "title": "integer (IntegerEditor)",
32
31
  "type": "integer",
33
32
  "const": 5,
34
- // "options": { "enforce_const": false }
35
33
  },
36
34
  "number": {
37
35
  "title": "number (NumberEditor)",
38
36
  "type": "number",
39
37
  "const": 5.5,
40
- // "options": { "enforce_const": false }
41
38
  },
42
39
  "string-enum": {
43
40
  "title": "string-enum (SelectEditor)",
@@ -48,33 +45,28 @@
48
45
  "Bob",
49
46
  "Carl"
50
47
  ],
51
- // "options": { "enforce_const": false }
52
48
  },
53
49
  "boolean": {
54
50
  "title": "boolean (SelectEditor)",
55
51
  "type": "boolean",
56
52
  "const": true,
57
- // "options": { "enforce_const": false }
58
53
  },
59
54
  "boolean-checkbox": {
60
55
  "title": "boolean-checkbox (CheckboxEditor)",
61
56
  "type": "boolean",
62
57
  "format": "checkbox",
63
58
  "const": true,
64
- // "options": { "enforce_const": false }
65
59
  },
66
60
  "boolean-choices": {
67
61
  "title": "boolean-choices (ChoicesEditor)",
68
62
  "type": "boolean",
69
63
  "format": "choices",
70
64
  "const": true,
71
- // "options": { "enforce_const": false }
72
65
  },
73
66
  "object": {
74
67
  "title": "object (ObjectEditor)",
75
68
  "type": "object",
76
69
  "const": {"name": "Alice"},
77
- // "options": { "enforce_const": false },
78
70
  "properties": {
79
71
  "name": {
80
72
  "type": "string"
@@ -82,10 +74,9 @@
82
74
  }
83
75
  },
84
76
  "array": {
85
- "title": "array (TableEditor)",
77
+ "title": "array",
86
78
  "type": "array",
87
79
  "const": [{"name": "Alice"}, {"name": "Bob"}],
88
- // "options": { "enforce_const": false },
89
80
  "items": {
90
81
  "title": "object",
91
82
  "type": "object",
@@ -104,31 +95,27 @@
104
95
  "items": {
105
96
  "title": "object",
106
97
  "type": "object",
107
- "const": {"name": "Alice"},
108
98
  "properties": {
109
99
  "name": {
110
100
  "type": "string"
111
101
  }
112
102
  }
113
103
  },
114
- // "options": { "enforce_const": false }
115
104
  },
116
105
  "array-tabs": {
117
- "title": "array (TableEditor)",
106
+ "title": "array (TabsEditor)",
118
107
  "type": "array",
119
108
  "format": "tabs",
120
109
  "const": [{"name": "Alice"}, {"name": "Bob"}],
121
110
  "items": {
122
111
  "title": "object",
123
112
  "type": "object",
124
- "const": {"name": "Alice"},
125
113
  "properties": {
126
114
  "name": {
127
115
  "type": "string"
128
116
  }
129
117
  }
130
118
  },
131
- // "options": { "enforce_const": false }
132
119
  },
133
120
  "array-of-strings": {
134
121
  "title": "array (MultiselectEditor)",
@@ -140,21 +127,18 @@
140
127
  "enum": ["Alice", "Bob"]
141
128
  },
142
129
  "const": ["Alice", "Bob"],
143
- // "options": { "enforce_const": false }
144
130
  },
145
131
  "array-enum": {
146
132
  "title": "array (EnumEditor)",
147
133
  "type": "array",
148
134
  "enum": [["Alice", "Bob"], ["Carl", "Dennis"]],
149
135
  "const": ["Carl", "Dennis"],
150
- // "options": { "enforce_const": false }
151
136
  },
152
137
  "object-enum": {
153
138
  "title": "object (EnumEditor)",
154
139
  "type": "object",
155
140
  "enum": [{"name": "Alice"}, {"name": "Bob"}],
156
141
  "const": {"name": "Bob"},
157
- // "options": { "enforce_const": false }
158
142
  }
159
143
  }
160
144
  }
@@ -170,6 +154,14 @@
170
154
  editor.on('change', function () {
171
155
  value.value = JSON.stringify(editor.getValue())
172
156
  })
157
+
158
+ editor.on('ready', function () {
159
+ editor.getEditor('root.string').setValue('Bob')
160
+ editor.getEditor('root.integer').setValue(10)
161
+ editor.getEditor('root.number').setValue(10)
162
+ editor.getEditor('root.array').setValue([])
163
+ editor.getEditor('root.object').setValue({})
164
+ })
173
165
  </script>
174
166
 
175
167
  </body>
@@ -0,0 +1,68 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>GitHub Issue 1559 - Dependencies with false values not fulfilled</title>
6
+ <script src="../../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
8
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
9
+ </head>
10
+ <body>
11
+
12
+ <div class="container">
13
+ <h1>Test - Dependencies with false values not fulfilled</h1>
14
+ <p>When <code>dependent_on_true</code> is unchecked (false), the <code>dependent_on_false</code> field should appear. This tests GitHub issue #1559 - dependencies with false values not being fulfilled.</p>
15
+ <div id='editor-container'></div>
16
+ </div>
17
+
18
+ <script>
19
+ var editorContainer = document.querySelector('#editor-container')
20
+ var schema = {
21
+ "type": "object",
22
+ "title": "Test configuration",
23
+ "description": "Test configuration for dependencies with false values (GitHub issue #1559)",
24
+ "properties": {
25
+ "master_field": {
26
+ "type": "boolean",
27
+ "title": "Master field",
28
+ "format": "checkbox",
29
+ "description": "Master toggle field.",
30
+ "default": true
31
+ },
32
+ "dependent_on_true": {
33
+ "type": "boolean",
34
+ "format": "checkbox",
35
+ "title": "Dependent on true",
36
+ "description": "This field depends on master_field being true.",
37
+ "default": true,
38
+ "options": {
39
+ "dependencies": {
40
+ "master_field": true
41
+ }
42
+ }
43
+ },
44
+ "dependent_on_false": {
45
+ "type": "string",
46
+ "format": "password",
47
+ "title": "Dependent on false",
48
+ "description": "This field depends on dependent_on_true being false.",
49
+ "minLength": 1,
50
+ "options": {
51
+ "dependencies": {
52
+ "dependent_on_true": false
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ var editor = new JSONEditor(editorContainer, {
60
+ schema: schema,
61
+ theme: 'bootstrap4',
62
+ iconlib: 'fontawesome',
63
+ show_errors: 'always'
64
+ })
65
+ </script>
66
+
67
+ </body>
68
+ </html>
@@ -0,0 +1,170 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>issue-1562</title>
6
+ <script src="../../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
8
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
9
+ </head>
10
+ <body>
11
+
12
+ <div class="container">
13
+ <h1>Test</h1>
14
+ <div id='editor-container'></div>
15
+
16
+ <div class="form-group">
17
+ <label for="textarea-value">Value</label>
18
+ <textarea class="form-control" id="textarea-value" cols="30" rows="10"></textarea>
19
+ </div>
20
+ </div>
21
+
22
+ <script>
23
+ var editorContainer = document.querySelector('#editor-container')
24
+ var textareaValue = document.querySelector('#textarea-value')
25
+ var schema = {
26
+ "type": "object",
27
+ "format": "grid",
28
+ "options": {
29
+ "collapsed": false,
30
+ "grid_columns": 12,
31
+ "disable_properties": true
32
+ },
33
+ "defaultProperties": [
34
+ "model"
35
+ ],
36
+ "required": [
37
+ "model"
38
+ ],
39
+ "properties": {
40
+ "model": {
41
+ "type": "object",
42
+ "format": "grid",
43
+ "options": {
44
+ "collapsed": false,
45
+ "grid_columns": 12,
46
+ "disable_properties": true
47
+ },
48
+ "defaultProperties": [
49
+ "name",
50
+ "entities"
51
+ ],
52
+ "required": [
53
+ "name",
54
+ "entities"
55
+ ],
56
+ "properties": {
57
+ "name": {
58
+ "type": "string",
59
+ "propertyOrder": 0,
60
+ "description": "Name of the Model",
61
+ "default": "",
62
+ "pattern": "^\\S+$",
63
+ "options": {
64
+ "grid_columns": 3
65
+ }
66
+ },
67
+ "entities": {
68
+ "type": "object",
69
+ "format": "grid",
70
+ "options": {
71
+ "collapsed": false,
72
+ "grid_columns": 12
73
+ },
74
+ "additionalProperties": {
75
+ "type": "object",
76
+ "format": "grid",
77
+ "options": {
78
+ "grid_columns": 12,
79
+ "collapsed": true,
80
+ "disable_properties": true
81
+ },
82
+ "defaultProperties": [
83
+ "name",
84
+ "properties"
85
+ ],
86
+ "required": [
87
+ "name",
88
+ "properties"
89
+ ],
90
+ "properties": {
91
+ "name": {
92
+ "description": "The name of the entity",
93
+ "type": "string",
94
+ "propertyOrder": 0,
95
+ "default": "",
96
+ "pattern": "^[A-Z]\\S+$",
97
+ "options": {
98
+ "grid_columns": 4
99
+ }
100
+ },
101
+ "properties": {
102
+ "type": "object",
103
+ "format": "grid",
104
+ "options": {
105
+ "grid_columns": 12,
106
+ "collapsed": true,
107
+ "disable_properties": false
108
+ },
109
+ "default": {
110
+ "id": {
111
+ "name": "id"
112
+ },
113
+ "created": {
114
+ "name": "created"
115
+ },
116
+ "lastUpdated": {
117
+ "name": "lastUpdated"
118
+ }
119
+ },
120
+ "propertyOrder": 5,
121
+ "additionalProperties": {
122
+ "type": "object",
123
+ "format": "grid",
124
+ "options": {
125
+ "collapsed": true,
126
+ "grid_columns": 12,
127
+ "disable_properties": true
128
+ },
129
+ "defaultProperties": [
130
+ "name"
131
+ ],
132
+ "required": [
133
+ "name"
134
+ ],
135
+ "properties": {
136
+ "name": {
137
+ "description": "The name of the property",
138
+ "type": "string",
139
+ "propertyOrder": 0,
140
+ "default": "",
141
+ "pattern": "^\\S+$",
142
+ "options": {
143
+ "grid_columns": 4
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+ }
156
+
157
+ var editor = new JSONEditor(editorContainer, {
158
+ schema: schema,
159
+ theme: 'bootstrap4',
160
+ iconlib: 'fontawesome',
161
+ show_errors: 'always',
162
+ })
163
+
164
+ editor.on('change', function () {
165
+ textareaValue.value = JSON.stringify(editor.getValue())
166
+ })
167
+ </script>
168
+
169
+ </body>
170
+ </html>`
@@ -0,0 +1,48 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1586</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
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
9
+ <script src="../../../dist/jsoneditor.js"></script>
10
+ </head>
11
+ <body>
12
+ <div class="container">
13
+ <textarea class="form-control" id="value" cols="30" rows="10"></textarea>
14
+ <a href="https://github.com/json-editor/json-editor/issues/1585">GitHub Issue 1586</a>
15
+ <div id='editor_holder'></div>
16
+ </div>
17
+
18
+ <script>
19
+ var value = document.querySelector('#value')
20
+
21
+ var defaultSchema = {
22
+ "type": "array",
23
+ "items": {
24
+ "type": "object",
25
+ "properties": {
26
+ "type": "string",
27
+ "subtype": {
28
+ "type": "object",
29
+ "properties": {
30
+ "type": "string"
31
+ }
32
+ }
33
+ },
34
+ "required": [
35
+ "subtype"
36
+ ]
37
+ }
38
+ }
39
+
40
+ var editor = new JSONEditor(document.getElementById('editor_holder'), {
41
+ schema: defaultSchema,
42
+ show_errors: 'always',
43
+ show_opt_in: true,
44
+ prompt_before_delete: false
45
+ })
46
+ </script>
47
+ </body>
48
+ </html>
@@ -0,0 +1,134 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>opt-in-widget</title>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
8
+ <!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">-->
9
+ <!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css">-->
10
+ <!-- <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">-->
11
+ <!-- <link rel="stylesheet" href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css">-->
12
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
13
+ </head>
14
+ <body>
15
+
16
+ <div class="container">
17
+ <div id='editor-container'></div>
18
+ <div class="form-group">
19
+ <label for="value">Value</label>
20
+ <textarea class="form-control" id="value" cols="30" rows="30"></textarea>
21
+ </div>
22
+ </div>
23
+
24
+ <script>
25
+ const editorContainer = document.querySelector('#editor-container')
26
+ const schema = {
27
+ "title": "Register",
28
+ "type": "object",
29
+ "properties": {
30
+ "email": {
31
+ "title": "Email",
32
+ "type": "string",
33
+ "format": "email",
34
+ "minLength": 6
35
+ },
36
+ "password": {
37
+ "title": "Password",
38
+ "type": "string",
39
+ "format": "password",
40
+ "minLength": 8
41
+ },
42
+ "name": {
43
+ "title": "Name",
44
+ "type": "string",
45
+ "default": "Random-223"
46
+ },
47
+ "gender": {
48
+ "title": "Gender",
49
+ "type": "string",
50
+ "enum": [
51
+ "Male",
52
+ "Female",
53
+ "Other"
54
+ ]
55
+ },
56
+ "address": {
57
+ "title": "Address",
58
+ "type": "object",
59
+ "properties": {
60
+ "street": {
61
+ "title": "Street",
62
+ "type": "string",
63
+ },
64
+ "number": {
65
+ "title": "Number",
66
+ "type": "string",
67
+ }
68
+ }
69
+ },
70
+ "pets": {
71
+ "type": "array",
72
+ "format": "table",
73
+ "title": "Pets",
74
+ "uniqueItems": true,
75
+ "items": {
76
+ "type": "object",
77
+ "title": "Pet",
78
+ "properties": {
79
+ "type": {
80
+ "type": "string",
81
+ "enum": [
82
+ "cat",
83
+ "dog",
84
+ "bird",
85
+ "reptile",
86
+ "other"
87
+ ],
88
+ "default": "dog"
89
+ },
90
+ "name": {
91
+ "type": "string"
92
+ }
93
+ }
94
+ },
95
+ "default": [
96
+ {
97
+ "type": "dog",
98
+ "name": "Walter"
99
+ }
100
+ ]
101
+ },
102
+ "agree": {
103
+ "title": "Agree",
104
+ "description": "lorem ipsum bla bla",
105
+ "type": "boolean",
106
+ "format": "checkbox"
107
+ },
108
+ }
109
+ }
110
+
111
+ const editor = new JSONEditor(editorContainer, {
112
+ schema: schema,
113
+ theme: 'bootstrap3',
114
+ // theme: 'bootstrap4',
115
+ // theme: 'bootstrap5',
116
+ // theme: 'spectre',
117
+ // theme: 'tailwind',
118
+ iconlib: 'fontawesome',
119
+ show_opt_in: true,
120
+ opt_in_widget: 'switch',
121
+ disable_collapse: true,
122
+ disable_edit_json: true,
123
+ disable_properties: true
124
+ })
125
+
126
+ const textareaValue = document.querySelector('#value')
127
+
128
+ editor.on('change', function () {
129
+ textareaValue.value = JSON.stringify(editor.getValue())
130
+ })
131
+ </script>
132
+
133
+ </body>
134
+ </html>
@@ -0,0 +1,69 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>switcher-option</title>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
8
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
9
+ </head>
10
+ <body>
11
+
12
+ <div class="container">
13
+ <div id='editor-container'></div>
14
+ <div class="form-group">
15
+ <label for="textarea-value">Value</label>
16
+ <textarea class="form-control" id="textarea-value" cols="30" rows="30"></textarea>
17
+ </div>
18
+ </div>
19
+
20
+ <script>
21
+ const editorContainer = document.querySelector('#editor-container')
22
+ const schema = {
23
+ "title": "Register",
24
+ "type": "object",
25
+ "properties": {
26
+ "name": {
27
+ "title": "Name",
28
+ "type": "string",
29
+ "options": {
30
+ "switcher": false,
31
+ "error_messages": {
32
+ "en": {
33
+ "error_oneOf": "If provided, value must be at least 4 and at most 10",
34
+ "error_anyOf": "If provided, value must be at least 4 and at most 10"
35
+ }
36
+ }
37
+ },
38
+ "anyOf": [
39
+ {
40
+ "const": ""
41
+ },
42
+ {
43
+ "minLength": 4,
44
+ "maxLength": 10
45
+ }
46
+ ]
47
+ }
48
+ }
49
+ }
50
+
51
+ const editor = new JSONEditor(editorContainer, {
52
+ schema: schema,
53
+ theme: 'bootstrap4',
54
+ iconlib: 'fontawesome',
55
+ show_errors: 'always',
56
+ disable_collapse: true,
57
+ disable_edit_json: true,
58
+ disable_properties: true
59
+ })
60
+
61
+ const textareaValue = document.querySelector('#textarea-value')
62
+
63
+ editor.on('change', function () {
64
+ textareaValue.value = JSON.stringify(editor.getValue(), null, 2)
65
+ })
66
+ </script>
67
+
68
+ </body>
69
+ </html>
@@ -1,4 +0,0 @@
1
- version: '3'
2
- services:
3
- chrome:
4
- image: seleniarm/standalone-chromium:114.0