@json-editor/json-editor 2.14.0 → 2.14.1

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/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.14.0",
5
+ "version": "2.14.1",
6
6
  "main": "dist/jsoneditor.js",
7
7
  "author": {
8
8
  "name": "Jeremy Dorn",
package/src/editor.js CHANGED
@@ -535,7 +535,7 @@ export class AbstractEditor {
535
535
  })
536
536
 
537
537
  // object properties
538
- if (Object.keys(this.editors).length) {
538
+ if (this.editors && Object.keys(this.editors).length) {
539
539
  vars.properties = {}
540
540
 
541
541
  Object.keys(this.editors).forEach((key) => {
@@ -283,7 +283,7 @@ export class ArrayEditor extends AbstractEditor {
283
283
  }
284
284
 
285
285
  empty (hard) {
286
- if (!this.rows) return
286
+ if (this.rows === null) return
287
287
 
288
288
  this.rows.forEach((row, i) => {
289
289
  if (hard) {
@@ -293,6 +293,12 @@ export class ArrayEditor extends AbstractEditor {
293
293
  }
294
294
  this.rows[i] = null
295
295
  })
296
+ if (hard) {
297
+ for (let j = this.rows.length; j < this.row_cache.length; j++) {
298
+ this.destroyRow(this.row_cache[j], true)
299
+ this.row_cache[j] = null
300
+ }
301
+ }
296
302
  this.rows = []
297
303
  if (hard) this.row_cache = []
298
304
  }
@@ -107,6 +107,10 @@ export class MultipleEditor extends AbstractEditor {
107
107
  }
108
108
  }
109
109
 
110
+ if (schema?.options?.dependencies) {
111
+ delete schema.options.dependencies
112
+ }
113
+
110
114
  const editor = this.jsoneditor.getEditorClass(schema)
111
115
 
112
116
  this.editors[i] = this.jsoneditor.createEditor(editor, {
@@ -121,7 +125,9 @@ export class MultipleEditor extends AbstractEditor {
121
125
  this.editors[i].build()
122
126
  this.editors[i].postBuild()
123
127
 
124
- if (this.editors[i].header) this.editors[i].header.style.display = 'none'
128
+ if (this.editors[i].header) {
129
+ this.theme.visuallyHidden(this.editors[i].header)
130
+ }
125
131
 
126
132
  this.editors[i].option = this.switcher_options[i]
127
133
 
@@ -19,6 +19,10 @@ export class RadioEditor extends SelectEditor {
19
19
  const radioInputEventhandler = e => {
20
20
  this.setValue(e.currentTarget.value)
21
21
  this.onChange(true)
22
+
23
+ this.radioGroup.forEach((radio) => {
24
+ radio.checked = (radio.value === this.getValue())
25
+ })
22
26
  }
23
27
 
24
28
  for (let i = 0; i < this.enum_values.length; i++) {
@@ -50,7 +50,9 @@ export class StringEditor extends AbstractEditor {
50
50
  if (this.adjust_height) this.adjust_height(this.input)
51
51
 
52
52
  /* Bubble this setValue to parents if the value changed */
53
- this.onChange(changed)
53
+ if (!fromTemplate) {
54
+ this.onChange(changed)
55
+ }
54
56
 
55
57
  /* Return object with changed state and sanitized value for use in editors that extend this */
56
58
  return { changed, value: sanitized }
@@ -22,11 +22,6 @@ export class bootstrap3Theme extends AbstractTheme {
22
22
  if (this.closest(input, '.compact')) {
23
23
  input.controlgroup.style.marginBottom = 0
24
24
  }
25
- if (this.queuedInputErrorText) {
26
- const text = this.queuedInputErrorText
27
- delete this.queuedInputErrorText
28
- this.addInputError(input, text)
29
- }
30
25
 
31
26
  /* TODO: use bootstrap slider */
32
27
  }
@@ -197,7 +192,6 @@ export class bootstrap3Theme extends AbstractTheme {
197
192
 
198
193
  addInputError (input, text) {
199
194
  if (!input.controlgroup) {
200
- this.queuedInputErrorText = text
201
195
  return
202
196
  }
203
197
  input.controlgroup.classList.add('has-error')
@@ -214,9 +208,6 @@ export class bootstrap3Theme extends AbstractTheme {
214
208
  }
215
209
 
216
210
  removeInputError (input) {
217
- if (!input.controlgroup) {
218
- delete this.queuedInputErrorText
219
- }
220
211
  if (!input.errmsg) return
221
212
  input.errmsg.style.display = 'none'
222
213
  input.controlgroup.classList.remove('has-error')
@@ -0,0 +1,11 @@
1
+ /* global Feature Scenario */
2
+
3
+ Feature('issues')
4
+
5
+ Scenario('GitHub issue 1171 should remain fixed @issue-1171', async ({ I }) => {
6
+ I.amOnPage('issues/issue-gh-1171.html')
7
+ I.waitForElement('.je-ready')
8
+ I.dontSeeCheckedAttribute('[id="root[1]"]')
9
+ I.checkOption('[id="root[1]"]')
10
+ I.dontSeeCheckedAttribute('[id="root[0]"]')
11
+ })
@@ -0,0 +1,21 @@
1
+ /* global Feature Scenario */
2
+
3
+ Feature('issues')
4
+
5
+ Scenario('GitHub issue 1272 should remain fixed @issue-1272', async ({ I }) => {
6
+ I.amOnPage('issues/issue-gh-1272.html')
7
+ I.waitForElement('.je-ready')
8
+ I.selectOption('[name="root[recorder][albums]"]', 'album2')
9
+ I.waitForText('song1')
10
+ I.dontSee('array editor')
11
+ I.selectOption('[data-schemapath="root.recorder.album2"] .je-switcher', 'SideB')
12
+ I.waitForText('array editor')
13
+ I.dontSee('song1')
14
+ I.selectOption('[data-schemapath="root.recorder.album2"] .je-switcher', 'SideA')
15
+ I.waitForText('song1')
16
+ I.dontSee('array editor')
17
+ I.selectOption('[name="root[recorder][albums]"]', 'album1')
18
+ I.selectOption('[name="root[recorder][albums]"]', 'album2')
19
+ I.waitForText('song1')
20
+ I.dontSee('array editor')
21
+ })
@@ -0,0 +1,13 @@
1
+ /* global Feature Scenario */
2
+
3
+ Feature('issues')
4
+
5
+ Scenario('GitHub issue 1485 should remain fixed @issue-1485', async ({ I }) => {
6
+ I.amOnPage('issues/issue-gh-1485.html')
7
+ I.waitForElement('.je-ready')
8
+ I.fillField('[name="root[first_name]"]', 'John')
9
+ I.pressKey('Tab')
10
+ I.fillField('[name="root[last_name]"]', 'Doe')
11
+ I.pressKey('Tab')
12
+ I.waitForValue('[name="root[full_name]"]', 'John Doe')
13
+ })
@@ -0,0 +1,9 @@
1
+ /* global Feature Scenario */
2
+
3
+ Feature('issues')
4
+
5
+ Scenario('GitHub issue 1491 should remain fixed @issue-1491', async ({ I }) => {
6
+ I.amOnPage('issues/issue-gh-1491.html')
7
+ I.waitForElement('.je-ready')
8
+ I.dontSee('Value required')
9
+ })
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1171</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="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
10
+ <script src="../../../dist/jsoneditor.js"></script>
11
+ </head>
12
+ <body>
13
+ <div class="container">
14
+ <h1>Test</h1>
15
+ <a href="https://github.com/json-editor/json-editor/issues/1171">Link to issue</a>
16
+ <div id='editor_holder'></div>
17
+ </div>
18
+
19
+ <script>
20
+ const value = document.querySelector('#value')
21
+ const defaultSchema = {
22
+ "type": "string",
23
+ "format": "radio",
24
+ "title": "Gender",
25
+ "enum": [
26
+ "male",
27
+ "female"
28
+ ]
29
+ }
30
+
31
+ const editor = new JSONEditor(document.getElementById('editor_holder'), {
32
+ iconlib: 'fontawesome5',
33
+ schema: defaultSchema,
34
+ theme: 'bootstrap4',
35
+ use_name_attributes: false
36
+ })
37
+ </script>
38
+ </body>
39
+ </html>
@@ -0,0 +1,167 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1272</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="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
10
+ <script src="../../../dist/jsoneditor.js"></script>
11
+ </head>
12
+ <body>
13
+ <div class="container">
14
+ <h1>Test</h1>
15
+ <a href="https://github.com/json-editor/json-editor/issues/1272">Link to issue</a>
16
+ <div id='editor_holder'></div>
17
+ </div>
18
+
19
+ <script>
20
+ const value = document.querySelector('#value')
21
+ const defaultSchema = {
22
+ "$schema": "http://json-schema.org/draft-04/schema#",
23
+ "title": "&nbsp;",
24
+ "description": "&nbsp;",
25
+ "type": "object",
26
+ "format": "categories",
27
+ "options": {
28
+ "keep_oneof_values": false,
29
+ "disable_collapse": true
30
+ },
31
+ "properties": {
32
+ "recorder": {
33
+ "title": "Recorder",
34
+ "type": "object",
35
+ "format": "grid-strict",
36
+ "properties": {
37
+ "albums": {
38
+ "title": "Select album:",
39
+ "type": "string",
40
+ "options": {
41
+ "grid_columns": 2
42
+ },
43
+ "enum": [
44
+ "album1",
45
+ "album2"
46
+ ]
47
+ },
48
+ "album1": {
49
+ "title": "&nbsp;",
50
+ "type": "object",
51
+ "format": "grid-strict",
52
+ "options": {
53
+ "disable_collapse": true,
54
+ "dependencies": {
55
+ "albums": "album1"
56
+ }
57
+ },
58
+ "required": [
59
+ "song1",
60
+ "song2"
61
+ ],
62
+ "properties": {
63
+ "song1": {
64
+ "options": {
65
+ "grid_columns": 4
66
+ },
67
+ "type": "string"
68
+ },
69
+ "song2": {
70
+ "options": {
71
+ "grid_columns": 4
72
+ },
73
+ "type": "string"
74
+ }
75
+ }
76
+ },
77
+ "album2": {
78
+ "title": "&nbsp;",
79
+ "options": {
80
+ "dependencies": {
81
+ "albums": "album2"
82
+ }
83
+ },
84
+ "oneOf": [
85
+ {
86
+ "title": "SideA",
87
+ "type": "object",
88
+ "format": "grid-strict",
89
+ "options": {
90
+ "disable_collapse": true
91
+ },
92
+ "required": [
93
+ "song1",
94
+ "song2"
95
+ ],
96
+ "properties": {
97
+ "song1": {
98
+ "options": {
99
+ "grid_columns": 3
100
+ },
101
+ "type": "string"
102
+ },
103
+ "song2": {
104
+ "options": {
105
+ "grid_columns": 3
106
+ },
107
+ "type": "string"
108
+ }
109
+ }
110
+ },
111
+ {
112
+ "title": "SideB",
113
+ "type": "object",
114
+ "format": "grid-strict",
115
+ "options": {
116
+ "disable_collapse": true
117
+ },
118
+ "required": [
119
+ "songs"
120
+ ],
121
+ "properties": {
122
+ "songs": {
123
+ "title": "array editor",
124
+ "type": "array",
125
+ "format": "table",
126
+ "uniqueItems": true,
127
+ "items": {
128
+ "title": "song",
129
+ "type": "object",
130
+ "options": {
131
+ "disable_collapse": true
132
+ },
133
+ "properties": {
134
+ "song": {
135
+ "type": "integer",
136
+ "enum": [
137
+ 1,
138
+ 2,
139
+ 3,
140
+ 4,
141
+ 5
142
+ ]
143
+ },
144
+ "title": {
145
+ "type": "string"
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+ ]
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+
159
+ const editor = new JSONEditor(document.getElementById('editor_holder'), {
160
+ iconlib: 'fontawesome5',
161
+ schema: defaultSchema,
162
+ theme: 'bootstrap4',
163
+ keep_oneof_values: false
164
+ })
165
+ </script>
166
+ </body>
167
+ </html>
@@ -0,0 +1,63 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1466</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="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
10
+ <script src="../../../dist/nonmin/jsoneditor.js"></script>
11
+ </head>
12
+ <body>
13
+ <div class="container">
14
+ <textarea class="form-control" id="value" cols="30" rows="10"></textarea>
15
+ <a href="https://github.com/json-editor/json-editor/issues/1466">GitHub Issue 1466</a>
16
+
17
+ <p>Remove Item 2, then destroy editor. The row of Item 2 which is only stored in the cache is not destroyed.</p>
18
+ <div id='editor_holder'></div>
19
+ <button onclick="start()">start </button>
20
+ <button onclick="destroyEditor()">destroyEditor </button>
21
+ </div>
22
+
23
+ <script>
24
+ var value = document.querySelector('#value')
25
+ var editor;
26
+ function start()
27
+ {
28
+ var defaultSchema = {
29
+ "type": "object",
30
+ "properties": {
31
+ "array": {
32
+ "type": "array",
33
+ "items": {
34
+ "type": "object",
35
+ "properties": {
36
+ "someProperty": {
37
+ "type": "string"
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ editor = new JSONEditor(document.getElementById('editor_holder'), {
46
+ iconlib: 'fontawesome5',
47
+ schema: defaultSchema,
48
+ show_errors: 'always',
49
+ })
50
+
51
+ editor.on('ready', function () {
52
+ editor.setValue({ "array": [{ someProperty: "Item 1" }, { someProperty: "Item 2" }, { someProperty: "Item 3" }] })
53
+ })
54
+ }
55
+
56
+ function destroyEditor()
57
+ {
58
+ editor.destroy();
59
+ editor = undefined;
60
+ }
61
+ </script>
62
+ </body>
63
+ </html>
@@ -0,0 +1,59 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1485</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="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
10
+ <script src="../../../dist/jsoneditor.js"></script>
11
+ </head>
12
+ <body>
13
+ <div class="container">
14
+ <h1>Test</h1>
15
+ <a href="https://github.com/json-editor/json-editor/issues/1485">Link to issue</a>
16
+ <div id='editor_holder'></div>
17
+ </div>
18
+
19
+ <script>
20
+ const value = document.querySelector('#value')
21
+ const defaultSchema = {
22
+ "title": "json schema example",
23
+ "type": "object",
24
+ "properties": {
25
+ "example": {
26
+ "type": "string",
27
+ "template": "random_string"
28
+ },
29
+ "first_name": {
30
+ "type": "string"
31
+ },
32
+ "last_name": {
33
+ "type": "string"
34
+ },
35
+ "full_name": {
36
+ "type": "string",
37
+ "template": "{{ fname }} {{ lname }}",
38
+ "watch": {
39
+ "fname": "first_name",
40
+ "lname": "last_name"
41
+ }
42
+ }
43
+ }
44
+ }
45
+
46
+ window.JSONEditor.defaults.callbacks.template = {
47
+ "random_string": () => {
48
+ return Math.random() * 2
49
+ }
50
+ }
51
+
52
+ const editor = new JSONEditor(document.getElementById('editor_holder'), {
53
+ iconlib: 'fontawesome5',
54
+ schema: defaultSchema,
55
+ theme: 'bootstrap4'
56
+ })
57
+ </script>
58
+ </body>
59
+ </html>
@@ -0,0 +1,59 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1491</title>
6
+ <link rel="stylesheet" id="theme-link" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/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="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
10
+ <script src="../../../dist/jsoneditor.js"></script>
11
+ </head>
12
+ <body>
13
+ <div class="container">
14
+ <h1>Test</h1>
15
+ <a href="https://github.com/json-editor/json-editor/issues/1491">Link to issue</a>
16
+ <div id='editor_holder'></div>
17
+ </div>
18
+
19
+ <script>
20
+ const value = document.querySelector('#value')
21
+ const defaultSchema = {
22
+ "options": {
23
+ "titleHidden": true
24
+ },
25
+ "type": "object",
26
+ "required": [
27
+ "betreff",
28
+ "text"
29
+ ],
30
+ "properties": {
31
+ "betreff": {
32
+ "title": "Betreff",
33
+ "type": "string",
34
+ "minLength": 1,
35
+ "maxLength": 100
36
+ },
37
+ "text": {
38
+ "title": "Text",
39
+ "type": "string",
40
+ "format": "textarea",
41
+ "minLength": 1,
42
+ "maxLength": 500,
43
+ "options": {
44
+ "inputAttributes": {
45
+ "rows": 3
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ const editor = new JSONEditor(document.getElementById('editor_holder'), {
53
+ iconlib: 'fontawesome5',
54
+ schema: defaultSchema,
55
+ theme: 'bootstrap3'
56
+ })
57
+ </script>
58
+ </body>
59
+ </html>