@json-editor/json-editor 2.15.0 → 2.15.2

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 +0 -4
  2. package/.github/workflows/build.yml +5 -5
  3. package/CHANGELOG.md +19 -0
  4. package/README.md +16 -0
  5. package/config/codeceptjs_helpers.js +11 -0
  6. package/dist/jsoneditor.js +1 -1
  7. package/dist/jsoneditor.js.LICENSE.txt +1 -1
  8. package/dist/nonmin/jsoneditor.js +502 -152
  9. package/dist/nonmin/jsoneditor.js.map +1 -1
  10. package/package.json +1 -1
  11. package/src/core.js +11 -0
  12. package/src/defaults.js +2 -1
  13. package/src/editor.js +26 -15
  14. package/src/editors/ace.js +1 -0
  15. package/src/editors/array/choices.js +1 -0
  16. package/src/editors/array/select2.js +2 -0
  17. package/src/editors/array/selectize.js +2 -0
  18. package/src/editors/array.js +81 -0
  19. package/src/editors/base64.js +2 -0
  20. package/src/editors/checkbox.js +13 -1
  21. package/src/editors/choices.js +2 -0
  22. package/src/editors/colorpicker.js +2 -0
  23. package/src/editors/datetime.js +2 -0
  24. package/src/editors/describedby.js +2 -0
  25. package/src/editors/enum.js +3 -1
  26. package/src/editors/hidden.js +2 -0
  27. package/src/editors/jodit.js +2 -0
  28. package/src/editors/multiple.js +2 -0
  29. package/src/editors/multiselect.js +2 -0
  30. package/src/editors/object.js +10 -3
  31. package/src/editors/radio.js +2 -0
  32. package/src/editors/sceditor.js +2 -0
  33. package/src/editors/select.js +9 -4
  34. package/src/editors/select2.js +2 -0
  35. package/src/editors/selectize.js +2 -0
  36. package/src/editors/signature.js +2 -0
  37. package/src/editors/simplemde.js +3 -1
  38. package/src/editors/starrating.js +2 -0
  39. package/src/editors/string.js +2 -0
  40. package/src/editors/table.js +19 -2
  41. package/src/editors/upload.js +2 -0
  42. package/src/editors/uuid.js +2 -0
  43. package/src/resolvers.js +1 -1
  44. package/src/theme.js +23 -0
  45. package/src/themes/bootstrap3.css +53 -0
  46. package/src/themes/bootstrap3.css.js +1 -1
  47. package/src/themes/bootstrap3.js +30 -0
  48. package/src/themes/bootstrap4.js +27 -0
  49. package/src/themes/bootstrap5.js +28 -0
  50. package/src/themes/spectre.js +28 -0
  51. package/src/themes/tailwind.css +54 -0
  52. package/src/themes/tailwind.css.js +1 -1
  53. package/src/themes/tailwind.js +26 -0
  54. package/tests/codeceptjs/core_test.js +28 -0
  55. package/tests/codeceptjs/editors/integer_test.js +3 -1
  56. package/tests/codeceptjs/editors/multiple_test.js +27 -0
  57. package/tests/codeceptjs/editors/select_test.js +12 -0
  58. package/tests/codeceptjs/issues/issue-gh-1562_test.js +12 -0
  59. package/tests/codeceptjs/issues/issue-gh-1586_test.js +15 -0
  60. package/tests/docker-compose-local.yml +2 -1
  61. package/tests/pages/editor-show-validation-errors.html +54 -0
  62. package/tests/pages/enforce-const.html +10 -18
  63. package/tests/pages/integer.html +9 -10
  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/select-values.html +91 -0
  68. package/tests/pages/switcher-option.html +69 -0
@@ -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>
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8"/>
5
5
  <title>Integer</title>
6
- <script src="../../dist/jsoneditor.js"></script>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
7
  </head>
8
8
  <body>
9
9
 
@@ -15,10 +15,10 @@
15
15
  <div class='container'></div>
16
16
 
17
17
  <script>
18
- var container = document.querySelector('.container');
19
- var value = document.querySelector('.value');
18
+ const container = document.querySelector('.container');
19
+ const value = document.querySelector('.value');
20
20
 
21
- var schema = {
21
+ const schema = {
22
22
  "type": "object",
23
23
  "title": "range",
24
24
  "properties": {
@@ -50,19 +50,18 @@
50
50
  }
51
51
  };
52
52
 
53
- var editor = new JSONEditor(container, {
53
+ const editor = new JSONEditor(container, {
54
54
  schema: schema
55
- });
55
+ })
56
56
 
57
57
  document.querySelector('.get-value').addEventListener('click', function () {
58
58
  value.value = JSON.stringify(editor.getValue());
59
- console.log(editor.getValue());
60
- });
59
+ })
61
60
 
62
61
 
63
62
  document.querySelector('.set-value').addEventListener('click', function () {
64
- editor.setValue({integer_range: 2})
65
- });
63
+ editor.setValue({"integer": 5, "integer_number": 5, "integer_range": 2})
64
+ })
66
65
 
67
66
  </script>
68
67
 
@@ -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,91 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>string-simple-mde-editor</title>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
8
+ </head>
9
+ <body>
10
+ <div class="container">
11
+ <h1>Test</h1>
12
+ <div class="form-group">
13
+ <label for="value">Value</label>
14
+ <textarea class="form-control" id="value" cols="30" rows="10"></textarea>
15
+ </div>
16
+
17
+ <button id="set-value">Set value</button>
18
+ <div id="editor-container"></div>
19
+ </div>
20
+
21
+ <script>
22
+ const container = document.querySelector("#editor-container")
23
+ const debug = document.querySelector("#value")
24
+ const setValueBtn = document.querySelector("#set-value")
25
+ const schema = {
26
+ "type": "object",
27
+ "properties": {
28
+ "data": {
29
+ "type": "array",
30
+ "uniqueItems": true,
31
+ "format": "table",
32
+ "minLength": 1,
33
+ "items": {
34
+ "type": "object",
35
+ "required": [
36
+ "baumart"
37
+ ],
38
+ "properties": {
39
+ "baumart": {
40
+ "type": "string",
41
+ "enum": [
42
+ "not_set",
43
+ "other_hardwood",
44
+ "beech",
45
+ "oak",
46
+ "spruce"
47
+ ]
48
+ },
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+
55
+ const value = {
56
+ "data": [
57
+ {
58
+ "baumart": "other_hardwood",
59
+ },
60
+ {
61
+ "baumart": "beech",
62
+ },
63
+ {
64
+ "baumart": "oak",
65
+ },
66
+ {
67
+ "baumart": "spruce",
68
+ }
69
+ ]
70
+ }
71
+
72
+ const editor = new JSONEditor(container, {
73
+ disable_collapse: true,
74
+ schema: schema,
75
+ theme: 'bootstrap3'
76
+ })
77
+
78
+ editor.on('ready', () => {
79
+ debug.value = JSON.stringify(editor.getValue())
80
+ })
81
+
82
+ editor.on('change', () => {
83
+ debug.value = JSON.stringify(editor.getValue())
84
+ })
85
+
86
+ setValueBtn.addEventListener('click', () => {
87
+ editor.setValue(value)
88
+ })
89
+ </script>
90
+ </body>
91
+ </html>